18 */ |
18 */ |
19 |
19 |
20 |
20 |
21 #include <apgcli.h> |
21 #include <apgcli.h> |
22 #include <apmstd.h> |
22 #include <apmstd.h> |
|
23 #include <charconv.h> |
|
24 #include <data_caging_path_literals.hrh> |
23 #include <e32cmn.h> |
25 #include <e32cmn.h> |
24 #include <e32property.h> |
26 #include <e32property.h> |
25 #include <charconv.h> |
27 #include <string.h> |
26 #include <data_caging_path_literals.hrh> |
28 #include <usif/usiferror.h> |
27 #include <usiferror.h> |
|
28 |
29 |
29 #include "comms.h" |
30 #include "comms.h" |
|
31 #include "commsclientendpoint.h" |
30 #include "commsmessage.h" |
32 #include "commsmessage.h" |
31 #include "commsclientendpoint.h" |
33 #include "javacommonutils.h" |
32 #include "javasifplugin.h" |
|
33 #include "javauids.h" |
|
34 #include "logger.h" |
|
35 #include "javaoslayer.h" |
34 #include "javaoslayer.h" |
36 #include "javaprocessconstants.h" |
35 #include "javaprocessconstants.h" |
37 #include "javasymbianoslayer.h" |
36 #include "javasymbianoslayer.h" |
|
37 #include "javauids.h" |
|
38 #include "logger.h" |
|
39 #include "resultsserver.h" |
38 #include "runtimeexception.h" |
40 #include "runtimeexception.h" |
39 |
41 |
40 |
42 #include "javasifplugin.h" |
41 using namespace Java::Installer; |
43 |
|
44 |
|
45 using namespace java::installer; |
42 using namespace java::util; |
46 using namespace java::util; |
43 using namespace java::comms; |
47 using namespace java::comms; |
44 |
48 |
45 _LIT(KPrivateDataCage, "\\private\\"); |
49 _LIT(KPrivateDataCage, "\\private\\"); |
46 _LIT(KInboxDataCage, "\\private\\1000484b\\"); |
50 _LIT(KInboxDataCage, "\\private\\1000484b\\"); |
47 _LIT(KJavaInstallerProcess, "Installer"); |
51 _LIT(KJavaInstallerProcess, "Installer*"); |
48 _LIT(KJavaInstallerDataCage, "\\private\\102033e6\\"); |
52 _LIT(KJavaInstallerDataCage, "\\private\\102033e6\\"); |
49 _LIT(KJavaInstallerTmp, "\\private\\102033E6\\installer\\tmp\\"); |
53 _LIT(KJavaInstallerTmp, "\\private\\102033E6\\installer\\tmp\\"); |
50 _LIT(KAnyExtension, ".*"); |
54 _LIT(KAnyExtension, ".*"); |
|
55 _LIT(KComponentInfo, " componentinfo"); |
|
56 _LIT(KCommsResult, " -commsresult="); |
|
57 _LIT(KJad, " -jad="); |
|
58 _LIT(KJar, " -jar="); |
|
59 _LIT(KDoubleQuote, "\""); |
|
60 _LIT(KInstall, " install"); |
|
61 _LIT(KSilent, " -silent"); |
|
62 _LIT(KUninstall, " uninstall"); |
|
63 _LIT(KCid, " -cid="); |
|
64 _LIT(KDrive, " -drive="); |
|
65 _LIT(KYes, "yes"); |
|
66 _LIT(KNo, "no"); |
|
67 _LIT(KOcsp, " -ocsp="); |
|
68 _LIT(KIgnoreOcspWarnings, " -ignore_ocsp_warnings="); |
|
69 _LIT(KUpgrade, " -upgrade="); |
|
70 _LIT(KUpgradeData, " -upgrade_data="); |
|
71 _LIT(KUntrusted, " -untrusted="); |
|
72 _LIT(KOverwrite, " -overwrite="); |
|
73 _LIT(KDownload, " -download="); |
|
74 _LIT(KIap, " -iap="); |
|
75 _LIT(KSnap, " -snap="); |
|
76 _LIT(KForceCancel, " -forcecancel"); |
|
77 _LIT(KBase64, " -base64="); |
|
78 _LIT(KUsername, " -username="); |
|
79 _LIT(KPassword, " -password="); |
|
80 _LIT(KSourceUrl, " -sourceurl="); |
|
81 _LIT(KCharSet, " -charset="); |
|
82 |
|
83 _LIT(KJadMimeType, "text/vnd.sun.j2me.app-descriptor"); |
|
84 _LIT8(K8JadMimeType, "text/vnd.sun.j2me.app-descriptor"); |
|
85 |
|
86 // Long Java Installer command lines contain max 2 path names (512 chars max) and |
|
87 // some options -> 1536 is long enough buffer |
|
88 const TInt KLongCmdLineLen = 1536; |
|
89 |
|
90 // When starting Java Installer for uninstallation the command line is much shorter |
|
91 const TInt KShortCmdLineLen = 256; |
51 |
92 |
52 // Java Installer is executed with same Uid as Java Runtime |
93 // Java Installer is executed with same Uid as Java Runtime |
53 _LIT_SECURE_ID(KJavaInstallerSecureID, KJavaMidpSecureId); |
94 _LIT_SECURE_ID(KJavaInstallerSecureID, KJavaMidpSecureId); |
54 |
95 |
55 |
96 |
65 return self; |
106 return self; |
66 } |
107 } |
67 |
108 |
68 CJavaSifPlugin::~CJavaSifPlugin() |
109 CJavaSifPlugin::~CJavaSifPlugin() |
69 { |
110 { |
70 iRFs.Close(); |
111 mRFs.Close(); |
71 |
112 |
72 TInt nHandles = iHandlesToClose.Count(); |
113 TInt nHandles = mHandlesToClose.Count(); |
73 while (nHandles > 0) |
114 while (nHandles > 0) |
74 { |
115 { |
75 nHandles--; |
116 nHandles--; |
76 iHandlesToClose[nHandles].Close(); |
117 mHandlesToClose[nHandles].Close(); |
77 } |
118 } |
78 iHandlesToClose.Reset(); |
119 mHandlesToClose.Reset(); |
79 |
120 |
80 delete iResultsServer; |
121 delete mResultsServer; |
81 iResultsServer = NULL; |
122 mResultsServer = NULL; |
82 |
123 |
83 delete iDummyResults; |
124 delete mDummyResults; |
84 iDummyResults = NULL; |
125 mDummyResults = NULL; |
85 |
126 |
86 delete iDummyInfo; |
127 delete mDummyInfo; |
87 iDummyInfo = NULL; |
128 mDummyInfo = NULL; |
88 } |
129 } |
89 |
130 |
90 CJavaSifPlugin::CJavaSifPlugin() |
131 CJavaSifPlugin::CJavaSifPlugin() |
91 { |
132 { |
92 } |
133 } |
93 |
134 |
94 void CJavaSifPlugin::ConstructL() |
135 void CJavaSifPlugin::ConstructL() |
95 { |
136 { |
96 User::LeaveIfError(iRFs.Connect()); |
137 User::LeaveIfError(mRFs.Connect()); |
97 User::LeaveIfError(iRFs.ShareProtected()); |
138 User::LeaveIfError(mRFs.ShareProtected()); |
98 iResultsServer = NULL; |
139 mResultsServer = NULL; |
99 iDummyResults = COpaqueNamedParams::NewL(); |
140 mDummyResults = COpaqueNamedParams::NewL(); // codescanner::forgottoputptroncleanupstack |
100 iDummyInfo = CComponentInfo::NewL(); |
141 mDummyInfo = CComponentInfo::NewL(); |
101 } |
142 } |
102 |
143 |
103 void CJavaSifPlugin::GetComponentInfo( |
144 void CJavaSifPlugin::GetComponentInfo( |
104 const TDesC& aFileName, |
145 const TDesC& aFileName, |
105 const TSecurityContext& aSecurityContext, |
146 const TSecurityContext& aSecurityContext, |
106 CComponentInfo& aComponentInfo, |
147 CComponentInfo& aComponentInfo, |
107 TRequestStatus& aStatus) |
148 TRequestStatus& aStatus) |
108 { |
149 { |
109 RFile fileHandle; |
150 RFile fileHandle; |
110 TInt err = fileHandle.Open(iRFs, aFileName, EFileShareReadersOnly | EFileRead); |
151 TInt err = fileHandle.Open(mRFs, aFileName, EFileShareReadersOnly | EFileRead); |
111 if (KErrNone != err) |
152 if (KErrNone != err) |
112 { |
153 { |
113 ELOG1(EJavaInstaller, |
154 ELOG1(EJavaInstaller, |
114 "CJavaSifPlugin::GetComponentInfo Opening file for reading failed with error %d", |
155 "CJavaSifPlugin::GetComponentInfo Opening file for reading failed with error %d", |
115 err); |
156 err); |
126 RFile& aFileHandle, |
167 RFile& aFileHandle, |
127 const TSecurityContext& /* aSecurityContext */, |
168 const TSecurityContext& /* aSecurityContext */, |
128 CComponentInfo& aComponentInfo, |
169 CComponentInfo& aComponentInfo, |
129 TRequestStatus& aStatus) |
170 TRequestStatus& aStatus) |
130 { |
171 { |
131 if (ExitIfJavaInstallerRunning(aStatus)) |
172 if (ExitIfJavaInstallerRunning(*mDummyResults, aStatus)) |
132 { |
173 { |
133 return; |
174 return; |
134 } |
175 } |
135 |
176 |
136 RProcess rJavaInstaller; |
177 RProcess rJavaInstaller; |
137 TFileName fileName; |
178 TFileName fileName; |
138 TBuf<1536> commandLine; |
179 HBufC* pBufCommandLine = NULL; |
|
180 TRAPD(err, pBufCommandLine = HBufC::NewL(KLongCmdLineLen)) |
|
181 if (KErrNone != err) |
|
182 { |
|
183 TRequestStatus *statusPtr(&aStatus); |
|
184 User::RequestComplete(statusPtr, err); |
|
185 return; |
|
186 } |
|
187 std::auto_ptr<HBufC> bufCommandLine(pBufCommandLine); |
|
188 TPtr commandLine = pBufCommandLine->Des(); |
139 |
189 |
140 // Build command line used to pass all necessary info to Java Installer |
190 // Build command line used to pass all necessary info to Java Installer |
141 std::auto_ptr<HBufC> installerStarterDll( |
191 std::auto_ptr<HBufC> installerStarterDll( |
142 stringToDes(java::runtime::JAVA_INSTALLER_STARTER_DLL)); |
192 stringToDes(java::runtime::JAVA_INSTALLER_STARTER_DLL)); |
143 commandLine = installerStarterDll->Des(); |
193 commandLine = installerStarterDll->Des(); |
144 commandLine.Append(_L(" componentinfo")); |
194 commandLine.Append(KComponentInfo); |
145 |
195 |
146 // Ask Java Installer to send component info back |
196 // Ask Java Installer to send component info back |
147 // as Comms message. 11000 is IPC_ADDRESS_JAVA_SIF_PLUGIN_C Comms endpoint |
197 // as Comms message. 11000 is IPC_ADDRESS_JAVA_SIF_PLUGIN_C Comms endpoint |
148 // that our ResultsServer will listen to. |
198 // that our ResultsServer will listen to. |
149 commandLine.Append(_L(" -commsresult=11000")); |
199 commandLine.Append(KCommsResult); |
150 |
200 commandLine.AppendNum(IPC_ADDRESS_JAVA_SIF_PLUGIN_C); |
151 TInt err = aFileHandle.FullName(fileName); |
201 |
|
202 err = aFileHandle.FullName(fileName); |
152 |
203 |
153 // Java Installer does not have AllFiles capability. |
204 // Java Installer does not have AllFiles capability. |
154 // So if the .jad/.jar file is in the private data cage of |
205 // So if the .jad/.jar file is in the private data cage of |
155 // Remove Application Management system, it must be copied |
206 // Remove Application Management system, it must be copied |
156 // to the private data cage of Java Installer in this |
207 // to the private data cage of Java Installer in this |
163 User::RequestComplete(statusPtr, err); |
214 User::RequestComplete(statusPtr, err); |
164 return; |
215 return; |
165 } |
216 } |
166 |
217 |
167 // Check whether the file is .jad or .jar |
218 // Check whether the file is .jad or .jar |
168 RApaLsSession apaSession; |
219 TBool isJad; |
169 err = apaSession.Connect(); |
220 err = IsJadFile(aFileHandle, isJad); |
170 if (KErrNone != err) |
221 if (KErrNone != err) |
171 { |
222 { |
172 ELOG1(EJavaInstaller, |
|
173 "CJavaSifPlugin::GetComponentInfo RApaLsSession Connect error %d", err); |
|
174 TRequestStatus *statusPtr(&aStatus); |
223 TRequestStatus *statusPtr(&aStatus); |
175 User::RequestComplete(statusPtr, err); |
224 User::RequestComplete(statusPtr, err); |
176 return; |
225 return; |
177 } |
226 } |
178 TDataType jadFileMimeType(_L8("text/vnd.sun.j2me.app-descriptor")); |
|
179 TBool isJad = EFalse; |
|
180 err = apaSession.RecognizeSpecificData(aFileHandle, jadFileMimeType, isJad); |
|
181 apaSession.Close(); |
|
182 if (KErrNone != err) |
|
183 { |
|
184 // Just log the error |
|
185 ELOG1(EJavaInstaller, |
|
186 "CJavaSifPlugin::GetComponentInfo RApaLsSession RecognizeSpecificData error %d", |
|
187 err); |
|
188 } |
|
189 if (isJad) |
227 if (isJad) |
190 { |
228 { |
191 // Installation should be started from JAD file |
229 // Installation should be started from JAD file |
192 commandLine.Append(_L(" -jad=")); |
230 commandLine.Append(KJad); |
193 } |
231 } |
194 else |
232 else |
195 { |
233 { |
196 // from JAR file |
234 // from JAR file |
197 commandLine.Append(_L(" -jar=")); |
235 commandLine.Append(KJar); |
198 } |
236 } |
|
237 |
199 // Filename parameter must be surrounded in double quotes to |
238 // Filename parameter must be surrounded in double quotes to |
200 // ensure that spaces in filename are passed correctly. |
239 // ensure that spaces in filename are passed correctly. |
201 commandLine.Append(_L("\"")); |
240 commandLine.Append(KDoubleQuote); |
202 commandLine.Append(fileName); |
241 commandLine.Append(fileName); |
203 commandLine.Append(_L("\"")); |
242 commandLine.Append(KDoubleQuote); |
204 |
243 |
205 // Start JavaInstaller |
244 // Start JavaInstaller |
206 std::auto_ptr<HBufC> installerProcess( |
245 std::auto_ptr<HBufC> installerProcess( |
207 stringToDes(java::runtime::JAVA_PROCESS)); |
246 stringToDes(java::runtime::JAVA_PROCESS)); |
208 err = rJavaInstaller.Create(installerProcess->Des(), commandLine); |
247 err = rJavaInstaller.Create(installerProcess->Des(), commandLine); |
209 if (KErrNone == err) |
248 if (KErrNone == err) |
210 { |
249 { |
211 // Destroy old Comms server if it exists |
250 err = StartResultsServer(*mDummyResults, aComponentInfo); |
212 delete iResultsServer; |
|
213 iResultsServer = NULL; |
|
214 // Start new Comms server that receives component info and sets it to |
|
215 // to aComponentInfo. |
|
216 iResultsServer = new ResultsServer(*iDummyResults, aComponentInfo); |
|
217 if (NULL == iResultsServer) |
|
218 { |
|
219 err = KErrNoMemory; |
|
220 } |
|
221 else |
|
222 { |
|
223 // Start the server |
|
224 err = iResultsServer->start(); |
|
225 } |
|
226 if (KErrNone != err) |
251 if (KErrNone != err) |
227 { |
252 { |
228 // server cannot be started |
253 // server cannot be started |
229 rJavaInstaller.Close(); |
254 rJavaInstaller.Close(); |
230 ELOG1(EJavaInstaller, |
255 ELOG1(EJavaInstaller, |
308 // Silent installation requires TrustedUI capability |
342 // Silent installation requires TrustedUI capability |
309 if (!aSecurityContext.HasCapability(ECapabilityTrustedUI)) |
343 if (!aSecurityContext.HasCapability(ECapabilityTrustedUI)) |
310 { |
344 { |
311 ELOG(EJavaInstaller, |
345 ELOG(EJavaInstaller, |
312 "CJavaSifPlugin::Install The caller did not have TrustedUI capability"); |
346 "CJavaSifPlugin::Install The caller did not have TrustedUI capability"); |
|
347 TRAP_IGNORE(aResults.AddIntL(KSifOutParam_ErrCategory, ESecurityError)); |
313 TRequestStatus *statusPtr(&aStatus); |
348 TRequestStatus *statusPtr(&aStatus); |
314 User::RequestComplete(statusPtr, KErrPermissionDenied); |
349 User::RequestComplete(statusPtr, KErrPermissionDenied); |
315 return; |
350 return; |
316 } |
351 } |
317 |
352 |
318 commandLine.Append(_L(" -silent")); |
353 commandLine.Append(KSilent); |
319 } |
354 } |
320 |
355 |
321 TBool paramFound = EFalse; |
356 BuildInstallCommandLine(commandLine, aArguments); |
322 TInt intValue = 0; |
|
323 TDesC desValue = KNullDesC; |
|
324 |
|
325 // KSifInParam_Drive -> -drive=install_target_drive (A, B, C, ..., Z) |
|
326 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_Drive, intValue)); |
|
327 if (paramFound) |
|
328 { |
|
329 // Value 0 is 'A:' drive and value 25 is 'Z:' drive |
|
330 if ((intValue > -1) && (intValue < 26)) |
|
331 { |
|
332 commandLine.Append(_L(" -drive=")); |
|
333 TChar drive('A'); |
|
334 drive += intValue; |
|
335 commandLine.Append(drive); |
|
336 } |
|
337 else |
|
338 { |
|
339 WLOG1(EJavaInstaller, |
|
340 "CJavaSifPlugin::Install Ignoring illegal KSifInParam_Drive param (value %d)", |
|
341 intValue); |
|
342 } |
|
343 } |
|
344 |
|
345 // KSifInParam_PerformOCSP Yes/No/AskUser -> -ocsp=yes|no |
|
346 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_PerformOCSP, intValue)); |
|
347 if (paramFound) |
|
348 { |
|
349 if (intValue == 0) // Yes |
|
350 { |
|
351 commandLine.Append(_L(" -ocsp=yes")); |
|
352 } |
|
353 else if (intValue == 1) // No |
|
354 { |
|
355 commandLine.Append(_L(" -ocsp=no")); |
|
356 } |
|
357 // AskUser is not supported |
|
358 } |
|
359 |
|
360 // KSifInParam_IgnoreOCSPWarnings Yes/No/AskUser -> -ignore_ocsp_warnings=yes|no |
|
361 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_IgnoreOCSPWarnings, intValue)); |
|
362 if (paramFound) |
|
363 { |
|
364 if (intValue == 0) // Yes |
|
365 { |
|
366 commandLine.Append(_L(" -ignore_ocsp_warnings=yes")); |
|
367 } |
|
368 else if (intValue == 1) // No |
|
369 { |
|
370 commandLine.Append(_L(" -ignore_ocsp_warnings=no")); |
|
371 } |
|
372 // AskUser is not supported |
|
373 } |
|
374 |
|
375 // KSifInParam_AllowUpgrade Yes/No/AskUser -> -upgrade=yes|no |
|
376 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_AllowUpgrade, intValue)); |
|
377 if (paramFound) |
|
378 { |
|
379 if (intValue == 0) // Yes |
|
380 { |
|
381 commandLine.Append(_L(" -upgrade=yes")); |
|
382 } |
|
383 else if (intValue == 1) // No |
|
384 { |
|
385 commandLine.Append(_L(" -upgrade=no")); |
|
386 } |
|
387 // AskUser is not supported |
|
388 } |
|
389 |
|
390 |
|
391 // TODO: activate this code block when KSifInParam_UpgradeData has been |
|
392 // defined in sifcommon.h |
|
393 /* |
|
394 // KSifInParam_UpgradeData Yes/No/AskUser -> -upgrade_data=yes|no |
|
395 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_UpgradeData, intValue)); |
|
396 if (paramFound) |
|
397 { |
|
398 if (intValue == 0) // Yes |
|
399 { |
|
400 commandLine.Append(_L(" -upgrade_data=yes")); |
|
401 } |
|
402 else if (intValue == 1) // No |
|
403 { |
|
404 commandLine.Append(_L(" -upgrade_data=no")); |
|
405 } |
|
406 // AskUser is not supported |
|
407 } |
|
408 */ |
|
409 |
|
410 // KSifInParam_AllowUntrusted Yes/No/AskUser -> -untrusted=yes|no |
|
411 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_AllowUntrusted, intValue)); |
|
412 if (paramFound) |
|
413 { |
|
414 if (intValue == 0) // Yes |
|
415 { |
|
416 commandLine.Append(_L(" -untrusted=yes")); |
|
417 } |
|
418 else if (intValue == 1) // No |
|
419 { |
|
420 commandLine.Append(_L(" -untrusted=no")); |
|
421 } |
|
422 // AskUser is not supported |
|
423 } |
|
424 |
|
425 // KSifInParam_AllowOverwrite Yes/No/AskUser -> -overwrite=yes|no |
|
426 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_AllowOverwrite, intValue)); |
|
427 if (paramFound) |
|
428 { |
|
429 if (intValue == 0) // Yes |
|
430 { |
|
431 commandLine.Append(_L(" -overwrite=yes")); |
|
432 } |
|
433 else if (intValue == 1) // No |
|
434 { |
|
435 commandLine.Append(_L(" -overwrite=no")); |
|
436 } |
|
437 // AskUser is not supported |
|
438 } |
|
439 |
|
440 // KSifInParam_AllowDownload Yes/No/AskUser -> -download=yes|no |
|
441 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_AllowDownload, intValue)); |
|
442 if (paramFound) |
|
443 { |
|
444 if (intValue == 0) // Yes |
|
445 { |
|
446 commandLine.Append(_L(" -download=yes")); |
|
447 } |
|
448 else if (intValue == 1) // No |
|
449 { |
|
450 commandLine.Append(_L(" -download=no")); |
|
451 } |
|
452 // AskUser is not supported |
|
453 } |
|
454 |
|
455 // KSifInParam_UserName -> -username=download_username |
|
456 TRAP_IGNORE(desValue = aArguments.StringByNameL(KSifInParam_UserName)); |
|
457 if (desValue.Length() > 0) |
|
458 { |
|
459 commandLine.Append(_L(" -username=")); |
|
460 commandLine.Append(desValue); |
|
461 } |
|
462 |
|
463 // KSifInParam_Password -> -password=download_password |
|
464 TRAP_IGNORE(desValue = aArguments.StringByNameL(KSifInParam_Password)); |
|
465 if (desValue.Length() > 0) |
|
466 { |
|
467 commandLine.Append(_L(" -password=")); |
|
468 commandLine.Append(desValue); |
|
469 } |
|
470 |
|
471 // KSifInParam_SourceUrl -> -sourceurl=original (HTTP) URL of the JAD or JAR file |
|
472 TRAP_IGNORE(desValue = aArguments.StringByNameL(KSifInParam_SourceUrl)); |
|
473 if (desValue.Length() > 0) |
|
474 { |
|
475 commandLine.Append(_L(" -sourceurl=")); |
|
476 commandLine.Append(desValue); |
|
477 } |
|
478 |
|
479 // KSifInParam_IAP -> -iap=IAP_ID (internet access point id) |
|
480 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_IAP, intValue)); |
|
481 if (paramFound) |
|
482 { |
|
483 commandLine.Append(_L(" -iap=")); |
|
484 commandLine.AppendNum(intValue); |
|
485 } |
|
486 |
|
487 // KSifInParam_Charset -> -charset=Internet-standard character set name |
|
488 TRAP_IGNORE(desValue = aArguments.StringByNameL(KSifInParam_Charset)); |
|
489 if (desValue.Length() > 0) |
|
490 { |
|
491 commandLine.Append(_L(" -charset=")); |
|
492 commandLine.Append(desValue); |
|
493 } |
|
494 |
|
495 |
357 |
496 // Ask Java Installer to send installation results back |
358 // Ask Java Installer to send installation results back |
497 // as Comms message. 11000 is IPC_ADDRESS_JAVA_SIF_PLUGIN_C Comms endpoint |
359 // as Comms message. 11000 is IPC_ADDRESS_JAVA_SIF_PLUGIN_C Comms endpoint |
498 // that our ResultsServer will listen to. |
360 // that our ResultsServer will listen to. |
499 commandLine.Append(_L(" -commsresult=11000")); |
361 commandLine.Append(KCommsResult); |
500 |
362 commandLine.AppendNum(IPC_ADDRESS_JAVA_SIF_PLUGIN_C); |
501 TInt err = aFileHandle.FullName(fileName); |
363 |
|
364 TFileName fileName; |
|
365 err = aFileHandle.FullName(fileName); |
502 |
366 |
503 // Java Installer does not have AllFiles capability. |
367 // Java Installer does not have AllFiles capability. |
504 // So if the .jad/.jar file is in the private data cage of |
368 // So if the .jad/.jar file is in the private data cage of |
505 // Remove Application Management system, it must be copied |
369 // Remove Application Management system, it must be copied |
506 // to the private data cage of Java Installer in this |
370 // to the private data cage of Java Installer in this |
507 // plugin which is executed in process which hopefully has |
371 // plugin which is executed in process which hopefully has |
508 // AllFiles capability. |
372 // AllFiles capability. |
509 TRAP(err, CopyFilesIfNeededL(fileName)); |
373 TRAP(err, CopyFilesIfNeededL(fileName)); |
510 if (KErrNone != err) |
374 if (KErrNone != err) |
511 { |
375 { |
|
376 TRAP_IGNORE(aResults.AddIntL(KSifOutParam_ErrCategory, EUnexpectedError)); |
512 TRequestStatus *statusPtr(&aStatus); |
377 TRequestStatus *statusPtr(&aStatus); |
513 User::RequestComplete(statusPtr, err); |
378 User::RequestComplete(statusPtr, err); |
514 return; |
379 return; |
515 } |
380 } |
516 |
381 |
517 // Check whether the file is .jad or .jar |
382 // Check whether the file is .jad or .jar |
518 RApaLsSession apaSession; |
383 TBool isJad = EFalse; |
519 err = apaSession.Connect(); |
384 err = IsJadFile(aFileHandle, aArguments, isJad); |
520 if (KErrNone != err) |
385 if (KErrNone != err) |
521 { |
386 { |
522 ELOG1(EJavaInstaller, |
387 TRAP_IGNORE(aResults.AddIntL(KSifOutParam_ErrCategory, EUnexpectedError)); |
523 "CJavaSifPlugin::Install RApaLsSession Connect error %d", err); |
|
524 TRequestStatus *statusPtr(&aStatus); |
388 TRequestStatus *statusPtr(&aStatus); |
525 User::RequestComplete(statusPtr, err); |
389 User::RequestComplete(statusPtr, err); |
526 return; |
390 return; |
527 } |
391 } |
528 TDataType jadFileMimeType(_L8("text/vnd.sun.j2me.app-descriptor")); |
|
529 TBool isJad = EFalse; |
|
530 err = apaSession.RecognizeSpecificData(aFileHandle, jadFileMimeType, isJad); |
|
531 apaSession.Close(); |
|
532 if (KErrNone != err) |
|
533 { |
|
534 ELOG1(EJavaInstaller, |
|
535 "CJavaSifPlugin::Install RApaLsSession RecognizeSpecificData error %d", err); |
|
536 } |
|
537 if (isJad) |
392 if (isJad) |
538 { |
393 { |
539 // Installation should be started from JAD file |
394 // Installation should be started from JAD file |
540 commandLine.Append(_L(" -jad=")); |
395 commandLine.Append(KJad); |
541 } |
396 } |
542 else |
397 else |
543 { |
398 { |
544 // from JAR file |
399 // from JAR file |
545 commandLine.Append(_L(" -jar=")); |
400 commandLine.Append(KJar); |
546 } |
401 } |
547 // Filename parameter must be surrounded in double quotes to |
402 // Filename parameter must be surrounded in double quotes to |
548 // ensure that spaces in filename are passed correctly. |
403 // ensure that spaces in filename are passed correctly. |
549 commandLine.Append(_L("\"")); |
404 commandLine.Append(KDoubleQuote); |
550 commandLine.Append(fileName); |
405 commandLine.Append(fileName); |
551 commandLine.Append(_L("\"")); |
406 commandLine.Append(KDoubleQuote); |
552 |
407 |
553 // Start JavaInstaller |
408 // Start JavaInstaller |
554 std::auto_ptr<HBufC> installerProcess( |
409 std::auto_ptr<HBufC> installerProcess( |
555 stringToDes(java::runtime::JAVA_PROCESS)); |
410 stringToDes(java::runtime::JAVA_PROCESS)); |
|
411 RProcess rJavaInstaller; |
556 err = rJavaInstaller.Create(installerProcess->Des(), commandLine); |
412 err = rJavaInstaller.Create(installerProcess->Des(), commandLine); |
557 if (KErrNone == err) |
413 if (KErrNone == err) |
558 { |
414 { |
559 // Destroy old Comms server if it exists |
415 err = StartResultsServer(aResults, *mDummyInfo); |
560 delete iResultsServer; |
|
561 iResultsServer = NULL; |
|
562 // Start new Comms server that receives component ids, sets them |
|
563 // to aResults. |
|
564 iResultsServer = new ResultsServer(aResults, *iDummyInfo); |
|
565 if (NULL == iResultsServer) |
|
566 { |
|
567 err = KErrNoMemory; |
|
568 } |
|
569 else |
|
570 { |
|
571 // Start the server |
|
572 err = iResultsServer->start(); |
|
573 } |
|
574 if (KErrNone != err) |
416 if (KErrNone != err) |
575 { |
417 { |
576 // server cannot be started |
418 // server cannot be started |
577 rJavaInstaller.Close(); |
419 rJavaInstaller.Close(); |
578 ELOG1(EJavaInstaller, |
420 ELOG1(EJavaInstaller, |
579 "CJavaSifPlugin::Install: Cannot start results server, err %d", err); |
421 "CJavaSifPlugin::Install: Cannot start results server, err %d", err); |
|
422 TRAP_IGNORE(aResults.AddIntL(KSifOutParam_ErrCategory, EUnexpectedError)); |
580 TRequestStatus *statusPtr(&aStatus); |
423 TRequestStatus *statusPtr(&aStatus); |
581 User::RequestComplete(statusPtr, err); |
424 User::RequestComplete(statusPtr, err); |
582 return; |
425 return; |
583 } |
426 } |
584 |
427 |
637 // Silent uninstallation requires TrustedUI capability |
489 // Silent uninstallation requires TrustedUI capability |
638 if (!aSecurityContext.HasCapability(ECapabilityTrustedUI)) |
490 if (!aSecurityContext.HasCapability(ECapabilityTrustedUI)) |
639 { |
491 { |
640 ELOG(EJavaInstaller, |
492 ELOG(EJavaInstaller, |
641 "CJavaSifPlugin::Uninstall The caller did not have TrustedUI capability"); |
493 "CJavaSifPlugin::Uninstall The caller did not have TrustedUI capability"); |
|
494 TRAP_IGNORE(aResults.AddIntL(KSifOutParam_ErrCategory, ESecurityError)); |
642 TRequestStatus *statusPtr(&aStatus); |
495 TRequestStatus *statusPtr(&aStatus); |
643 User::RequestComplete(statusPtr, KErrPermissionDenied); |
496 User::RequestComplete(statusPtr, KErrPermissionDenied); |
644 return; |
497 return; |
645 } |
498 } |
646 |
499 |
647 commandLine.Append(_L(" -silent")); |
500 commandLine.Append(KSilent); |
648 } |
501 } |
649 |
|
650 // No need to start iResultsServer because Uninstall() does not |
|
651 // return anything usefull in aResults. We could return extended |
|
652 // error code there. |
|
653 |
502 |
654 // start JavaInstaller |
503 // start JavaInstaller |
655 std::auto_ptr<HBufC> installerProcess( |
504 std::auto_ptr<HBufC> installerProcess( |
656 stringToDes(java::runtime::JAVA_PROCESS)); |
505 stringToDes(java::runtime::JAVA_PROCESS)); |
657 TInt err = rJavaInstaller.Create(installerProcess->Des(), commandLine); |
506 RProcess rJavaInstaller; |
|
507 err = rJavaInstaller.Create(installerProcess->Des(), commandLine); |
658 if (KErrNone == err) |
508 if (KErrNone == err) |
659 { |
509 { |
|
510 err = StartResultsServer(aResults, *mDummyInfo); |
|
511 if (KErrNone != err) |
|
512 { |
|
513 // server cannot be started |
|
514 rJavaInstaller.Close(); |
|
515 ELOG1(EJavaInstaller, |
|
516 "CJavaSifPlugin::Uninstall: Cannot start results server, err %d", err); |
|
517 TRAP_IGNORE(aResults.AddIntL(KSifOutParam_ErrCategory, EUnexpectedError)); |
|
518 TRequestStatus *statusPtr(&aStatus); |
|
519 User::RequestComplete(statusPtr, err); |
|
520 return; |
|
521 } |
|
522 |
660 // the exit status of Java Installer will be passed to |
523 // the exit status of Java Installer will be passed to |
661 // the asynch caller through aStatus |
524 // the asynch caller through aStatus |
662 rJavaInstaller.Logon(aStatus); |
525 rJavaInstaller.Logon(aStatus); |
663 |
526 |
664 rJavaInstaller.Resume(); |
527 rJavaInstaller.Resume(); |
703 void CJavaSifPlugin::CancelOperation() |
567 void CJavaSifPlugin::CancelOperation() |
704 { |
568 { |
705 // Send cancel message to Java Installer |
569 // Send cancel message to Java Installer |
706 |
570 |
707 // Check whether there is anything to cancel |
571 // Check whether there is anything to cancel |
708 if (iHandlesToClose.Count() < 1) |
572 if (mHandlesToClose.Count() < 1) |
709 { |
573 { |
710 // No Java Installer process running, do nothing |
574 // No Java Installer process running, do nothing |
711 WLOG(EJavaInstaller, |
575 WLOG(EJavaInstaller, |
712 "CJavaSifPlugin::CancelOperation: Cancel called but there is no operation to cancel"); |
576 "CJavaSifPlugin::CancelOperation: Cancel called but there is no operation to cancel"); |
713 return; |
577 return; |
714 } |
578 } |
715 |
579 |
716 try |
580 CommsMessage message; |
717 { |
581 message.setReceiver(IPC_ADDRESS_JAVA_INSTALLER_SERVER_C); |
718 CommsMessage message; |
582 message.setSender(IPC_ADDRESS_JAVA_SIF_PLUGIN_C); |
719 message.setModuleId(PLUGIN_ID_SAMPLE_C); |
583 message.setMessageId(INSTALLER_CANCEL_MESSAGE_ID); |
720 message.setReceiver(IPC_ADDRESS_JAVA_INSTALLER_SERVER_C); |
584 |
721 message.setSender(IPC_ADDRESS_JAVA_SIF_PLUGIN_C); |
585 CommsMessage replyMessage; |
722 message.setMessageId(INSTALLER_CANCEL_MESSAGE_ID); |
586 int timeout = 10; // 10 seconds // codescanner::magicnumbers |
723 |
587 |
724 CommsMessage replyMessage; |
588 CommsClientEndpoint comms; |
725 int timeout = 10; // 10 seconds |
589 int err = comms.connect(IPC_ADDRESS_JAVA_INSTALLER_SERVER_C); |
726 |
590 if (KErrNone == err) |
727 CommsClientEndpoint comms; |
591 { |
728 int err = comms.connect(IPC_ADDRESS_JAVA_INSTALLER_SERVER_C); |
592 err = comms.sendReceive(message, replyMessage, timeout); |
729 if (KErrNone == err) |
593 } |
730 { |
594 else |
731 err = comms.sendReceive(message, replyMessage, timeout); |
595 { |
732 } |
596 // Cannot connect to Java Installer Comms end point, |
733 else |
597 // for example Java Installer is still starting up or |
734 { |
598 // already exiting |
735 // Cannot connect to Java Installer Comms end point, |
599 WLOG1(EJavaInstaller, |
736 // for example Java Installer is still starting up or |
600 "CJavaSifPlugin:CancelOperation: Cannot connect to Java Installer " |
737 // already exiting |
601 "Comms end point, err %d", err); |
738 WLOG1(EJavaInstaller, |
602 return; |
739 "CJavaSifPlugin:CancelOperation: Cannot connect to Java Installer " |
603 } |
740 "Comms end point, err %d", err); |
604 if (err != 0) |
741 return; |
605 { |
742 } |
606 // Sending message to Java Installer failed. |
743 if (err != 0) |
607 ELOG1(EJavaInstaller, |
744 { |
608 "CJavaSifPlugin:CancelOperation: Cannot send message to Java Installer, err %d", |
745 // Sending message to Java Installer failed. |
609 err); |
746 ELOG1(EJavaInstaller, |
|
747 "CJavaSifPlugin:CancelOperation: Cannot send message to Java Installer, err %d", |
|
748 err); |
|
749 // Ignore possible errors in disconnect |
|
750 (void)comms.disconnect(); |
|
751 return; |
|
752 } |
|
753 |
|
754 // Ignore the cancel result returned in replyMessage |
|
755 // because current SIF API does not return cancel result |
|
756 |
|
757 // Ignore possible errors in disconnect |
610 // Ignore possible errors in disconnect |
758 (void)comms.disconnect(); |
611 (void)comms.disconnect(); // codescanner::voidparameter |
759 } |
612 return; |
760 catch (ExceptionBase& e) |
613 } |
761 { |
614 |
762 ELOG1(EJavaInstaller, |
615 // Ignore the cancel result returned in replyMessage |
763 "CJavaSifPlugin: Send cancel msg failed: ExceptionBase caught: %s ", |
616 // because current SIF API does not return cancel result |
764 e.toString().c_str()); |
617 |
765 return; |
618 // Ignore possible errors in disconnect |
766 } |
619 (void)comms.disconnect(); // codescanner::voidparameter |
767 catch (std::exception& e) |
|
768 { |
|
769 ELOG1(EJavaInstaller, |
|
770 "CJavaSifPlugin: Send cancel msg failed: Exception %s caught", e.what()); |
|
771 return; |
|
772 } |
|
773 |
620 |
774 // It takes some time before Java Installer had really cancelled |
621 // It takes some time before Java Installer had really cancelled |
775 // the operation and exited. Wait for it to happen because this function |
622 // the operation and exited. Wait for it to happen because this function |
776 // must return only after the original asynchronous call is completed. |
623 // must return only after the original asynchronous call is completed. |
777 TRequestStatus status; |
624 TRequestStatus status; |
778 // This array contains process handles for all Java Installer processes |
625 // This array contains process handles for all Java Installer processes |
779 // started from this sif plugin. The last handle is the active one. |
626 // started from this sif plugin. The last handle is the active one. |
780 // Check if it is still running |
627 // Check if it is still running |
781 if (iHandlesToClose[iHandlesToClose.Count()-1].ExitReason() != 0) |
628 if (mHandlesToClose[mHandlesToClose.Count()-1].ExitReason() != 0) |
782 { |
629 { |
783 // Process has already closed |
630 // Process has already closed |
784 return; |
631 return; |
785 } |
632 } |
786 // Wait until it exits |
633 // Wait until it exits |
787 iHandlesToClose[iHandlesToClose.Count()-1].Logon(status); |
634 mHandlesToClose[mHandlesToClose.Count()-1].Logon(status); |
788 User::WaitForRequest(status); |
635 User::WaitForRequest(status); // codescanner::userWaitForRequest |
789 // Ignore the exit status of Java Installer because current SIF API |
636 // Ignore the exit status of Java Installer because current SIF API |
790 // does not return cancel result |
637 // does not return cancel result |
791 |
638 |
792 return; |
639 return; |
793 } |
640 } |
794 |
641 |
795 void CJavaSifPlugin::CopyFilesIfNeededL(TFileName &aFileName) |
642 void CJavaSifPlugin::CopyFilesIfNeededL(TFileName &aFileName) |
796 { |
643 { |
797 // Check if the file is in the private data cage of some process |
644 // Check if the file is in the private data cage of some process |
798 TInt idx = aFileName.FindF(KPrivateDataCage); |
645 TInt idx = aFileName.FindF(KPrivateDataCage); |
799 if ((idx != KErrNotFound) && (idx < 3)) |
646 if ((idx != KErrNotFound) && (idx < 3)) // codescanner::magicnumbers |
800 { |
647 { |
801 // In case of device Inbox or Java Installer itself do nothing |
648 // In case of device Inbox or Java Installer itself do nothing |
802 if ((aFileName.FindF(KInboxDataCage) != KErrNotFound) || |
649 if ((aFileName.FindF(KInboxDataCage) != KErrNotFound) || |
803 (aFileName.FindF(KJavaInstallerDataCage) != KErrNotFound)) |
650 (aFileName.FindF(KJavaInstallerDataCage) != KErrNotFound)) |
804 { |
651 { |
833 aFileName.Append(fp.NameAndExt()); |
680 aFileName.Append(fp.NameAndExt()); |
834 } |
681 } |
835 |
682 |
836 return; |
683 return; |
837 } |
684 } |
|
685 |
|
686 |
|
687 TInt CJavaSifPlugin::IsJadFile( |
|
688 RFile& aFileHandle, |
|
689 const COpaqueNamedParams& aArguments, |
|
690 TBool& aIsJad) |
|
691 { |
|
692 TBool mimeTypeGiven = EFalse; |
|
693 |
|
694 TRAP_IGNORE( |
|
695 const TDesC &desValue = aArguments.StringByNameL(KSifInParam_MimeType); |
|
696 if (desValue.Length() > 0) |
|
697 { |
|
698 mimeTypeGiven = ETrue; |
|
699 if (!desValue.Compare(KJadMimeType)) |
|
700 { |
|
701 aIsJad = ETrue; |
|
702 } |
|
703 else |
|
704 { |
|
705 aIsJad = EFalse; |
|
706 } |
|
707 } |
|
708 ) |
|
709 if (mimeTypeGiven) |
|
710 { |
|
711 return KErrNone; |
|
712 } |
|
713 |
|
714 // Mime type was not given in the input arguments, must check the contents |
|
715 // of the file itself |
|
716 return IsJadFile(aFileHandle, aIsJad); |
|
717 } |
|
718 |
|
719 |
|
720 TInt CJavaSifPlugin::IsJadFile( |
|
721 RFile& aFileHandle, |
|
722 TBool& aIsJad) |
|
723 { |
|
724 RApaLsSession apaSession; |
|
725 TInt err = apaSession.Connect(); |
|
726 if (KErrNone != err) |
|
727 { |
|
728 ELOG1(EJavaInstaller, |
|
729 "CJavaSifPlugin::IsJadFile RApaLsSession Connect error %d", err); |
|
730 return err; |
|
731 } |
|
732 |
|
733 TDataType jadFileMimeType(K8JadMimeType); |
|
734 err = apaSession.RecognizeSpecificData(aFileHandle, jadFileMimeType, aIsJad); |
|
735 apaSession.Close(); |
|
736 if (KErrNone != err) |
|
737 { |
|
738 // Just log the error |
|
739 ELOG1(EJavaInstaller, |
|
740 "CJavaSifPlugin::IsJadFile RApaLsSession RecognizeSpecificData error %d", |
|
741 err); |
|
742 return err; |
|
743 } |
|
744 |
|
745 return KErrNone; |
|
746 } |
|
747 |
|
748 |
|
749 void CJavaSifPlugin::BuildInstallCommandLine( |
|
750 TPtr& aCommandLine, |
|
751 const COpaqueNamedParams& aArguments) |
|
752 { |
|
753 // KSifInParam_Drive -> -drive=install_target_drive (A, B, C, ..., Z) |
|
754 TInt intValue = GetPositiveIntParam(KSifInParam_Drive, aArguments); |
|
755 // Value 0 is 'A:' drive and value 25 is 'Z:' drive |
|
756 if ((intValue > -1) && (intValue < 26)) // codescanner::magicnumbers |
|
757 { |
|
758 aCommandLine.Append(KDrive); |
|
759 TChar drive('A'); |
|
760 drive += intValue; |
|
761 aCommandLine.Append(drive); |
|
762 } |
|
763 |
|
764 // KSifInParam_PerformOCSP Yes/No/AskUser -> -ocsp=yes|no |
|
765 intValue = GetPositiveIntParam(KSifInParam_PerformOCSP, aArguments); |
|
766 if (intValue == 0) // Yes |
|
767 { |
|
768 aCommandLine.Append(KOcsp); |
|
769 aCommandLine.Append(KYes); |
|
770 } |
|
771 else if (intValue == 1) // No |
|
772 { |
|
773 aCommandLine.Append(KOcsp); |
|
774 aCommandLine.Append(KNo); |
|
775 } |
|
776 // AskUser is not supported |
|
777 |
|
778 // KSifInParam_IgnoreOCSPWarnings Yes/No/AskUser -> -ignore_ocsp_warnings=yes|no |
|
779 intValue = GetPositiveIntParam(KSifInParam_IgnoreOCSPWarnings, aArguments); |
|
780 if (intValue == 0) // Yes |
|
781 { |
|
782 aCommandLine.Append(KIgnoreOcspWarnings); |
|
783 aCommandLine.Append(KYes); |
|
784 } |
|
785 else if (intValue == 1) // No |
|
786 { |
|
787 aCommandLine.Append(KIgnoreOcspWarnings); |
|
788 aCommandLine.Append(KNo); |
|
789 } |
|
790 // AskUser is not supported |
|
791 |
|
792 // KSifInParam_AllowUpgrade Yes/No/AskUser -> -upgrade=yes|no |
|
793 intValue = GetPositiveIntParam(KSifInParam_AllowUpgrade, aArguments); |
|
794 if (intValue == 0) // Yes |
|
795 { |
|
796 aCommandLine.Append(KUpgrade); |
|
797 aCommandLine.Append(KYes); |
|
798 } |
|
799 else if (intValue == 1) // No |
|
800 { |
|
801 aCommandLine.Append(KUpgrade); |
|
802 aCommandLine.Append(KNo); |
|
803 } |
|
804 // AskUser is not supported |
|
805 |
|
806 |
|
807 |
|
808 // TODO: activate this code block when KSifInParam_UpgradeData has been |
|
809 // defined in sifcommon.h |
|
810 /* |
|
811 // KSifInParam_UpgradeData Yes/No/AskUser -> -upgrade_data=yes|no |
|
812 intValue = GetPositiveIntParam(KSifInParam_UpgradeData, aArguments); |
|
813 if (intValue == 0) // Yes |
|
814 { |
|
815 aCommandLine.Append(KUpgradeData); |
|
816 aCommandLine.Append(KYes); |
|
817 } |
|
818 else if (intValue == 1) // No |
|
819 { |
|
820 aCommandLine.Append(KUpgradeData); |
|
821 aCommandLine.Append(KNo); |
|
822 } |
|
823 // AskUser is not supported |
|
824 */ |
|
825 |
|
826 // KSifInParam_AllowUntrusted Yes/No/AskUser -> -untrusted=yes|no |
|
827 intValue = GetPositiveIntParam(KSifInParam_AllowUntrusted, aArguments); |
|
828 if (intValue == 0) // Yes |
|
829 { |
|
830 aCommandLine.Append(KUntrusted); |
|
831 aCommandLine.Append(KYes); |
|
832 } |
|
833 else if (intValue == 1) // No |
|
834 { |
|
835 aCommandLine.Append(KUntrusted); |
|
836 aCommandLine.Append(KNo); |
|
837 } |
|
838 // AskUser is not supported |
|
839 |
|
840 // KSifInParam_AllowOverwrite Yes/No/AskUser -> -overwrite=yes|no |
|
841 intValue = GetPositiveIntParam(KSifInParam_AllowOverwrite, aArguments); |
|
842 if (intValue == 0) // Yes |
|
843 { |
|
844 aCommandLine.Append(KOverwrite); |
|
845 aCommandLine.Append(KYes); |
|
846 } |
|
847 else if (intValue == 1) // No |
|
848 { |
|
849 aCommandLine.Append(KOverwrite); |
|
850 aCommandLine.Append(KNo); |
|
851 } |
|
852 // AskUser is not supported |
|
853 |
|
854 // KSifInParam_AllowDownload Yes/No/AskUser -> -download=yes|no |
|
855 intValue = GetPositiveIntParam(KSifInParam_AllowDownload, aArguments); |
|
856 if (intValue == 0) // Yes |
|
857 { |
|
858 aCommandLine.Append(KDownload); |
|
859 aCommandLine.Append(KYes); |
|
860 } |
|
861 else if (intValue == 1) // No |
|
862 { |
|
863 aCommandLine.Append(KDownload); |
|
864 aCommandLine.Append(KNo); |
|
865 } |
|
866 // AskUser is not supported |
|
867 |
|
868 // KSifInParam_IAP -> -iap=IAP_ID (internet access point id) |
|
869 intValue = GetPositiveIntParam(KSifInParam_IAP, aArguments); |
|
870 if (intValue > -1) |
|
871 { |
|
872 // IAP ids are always positive |
|
873 aCommandLine.Append(KIap); |
|
874 aCommandLine.AppendNum(intValue); |
|
875 } |
|
876 |
|
877 // KSifInParam_SNAP -> -snap=SNAP_ID (service network access point id) |
|
878 intValue = GetPositiveIntParam(KSifInParam_SNAP, aArguments); |
|
879 if (intValue > -1) |
|
880 { |
|
881 // SNAP ids are always positive |
|
882 aCommandLine.Append(KSnap); |
|
883 aCommandLine.AppendNum(intValue); |
|
884 } |
|
885 |
|
886 // When this param is given, Java Installer will cancel installation |
|
887 // before committing anything. This option is for debugging purposes only. |
|
888 // KForceCancel -> -forcecancel |
|
889 // The value of parameter is ignored |
|
890 TRAP_IGNORE( |
|
891 const TDesC &desValue = aArguments.StringByNameL(KForceCancel); |
|
892 if (desValue.Length() > 0) |
|
893 { |
|
894 aCommandLine.Append(KForceCancel); |
|
895 } |
|
896 ) |
|
897 |
|
898 std::wstring base64EncodedArgs; |
|
899 // KSifInParam_UserName -> -username=download_username |
|
900 TRAP_IGNORE( |
|
901 const TDesC &desValue = aArguments.StringByNameL(KSifInParam_UserName); |
|
902 if (desValue.Length() > 0) |
|
903 { |
|
904 try |
|
905 { |
|
906 std::wstring value((wchar_t *)(desValue.Ptr()), desValue.Length()); |
|
907 std::wstring encodedValue = JavaCommonUtils::wbase64encode(value); |
|
908 aCommandLine.Append(KUsername); |
|
909 aCommandLine.Append( |
|
910 (const unsigned short *)encodedValue.c_str(), (int)encodedValue.length()); |
|
911 base64EncodedArgs.append(L"username,"); |
|
912 } |
|
913 catch (std::exception& e) |
|
914 { |
|
915 ELOG1(EJavaInstaller, |
|
916 "CJavaSifPlugin::BuildInstallCommandLine Base64 encoding user " |
|
917 "name failed, err %s", e.what()); |
|
918 } |
|
919 } |
|
920 ) |
|
921 |
|
922 // KSifInParam_Password -> -password=download_password |
|
923 TRAP_IGNORE( |
|
924 const TDesC &desValue = aArguments.StringByNameL(KSifInParam_Password); |
|
925 if (desValue.Length() > 0) |
|
926 { |
|
927 try |
|
928 { |
|
929 std::wstring value((wchar_t *)(desValue.Ptr()), desValue.Length()); |
|
930 std::wstring encodedValue = JavaCommonUtils::wbase64encode(value); |
|
931 aCommandLine.Append(KPassword); |
|
932 aCommandLine.Append( |
|
933 (const unsigned short *)encodedValue.c_str(), (int)encodedValue.length()); |
|
934 base64EncodedArgs.append(L"password,"); |
|
935 } |
|
936 catch (std::exception& e) |
|
937 { |
|
938 ELOG1(EJavaInstaller, |
|
939 "CJavaSifPlugin::BuildInstallCommandLine Base64 encoding password " |
|
940 "failed, err %s", e.what()); |
|
941 } |
|
942 } |
|
943 ) |
|
944 |
|
945 // KSifInParam_SourceUrl -> -sourceurl=original (HTTP) URL of the JAD or JAR file |
|
946 TRAP_IGNORE( |
|
947 const TDesC &desValue = aArguments.StringByNameL(KSifInParam_SourceUrl); |
|
948 if (desValue.Length() > 0) |
|
949 { |
|
950 try |
|
951 { |
|
952 std::wstring value((wchar_t *)(desValue.Ptr()), desValue.Length()); |
|
953 std::wstring encodedValue = JavaCommonUtils::wbase64encode(value); |
|
954 aCommandLine.Append(KSourceUrl); |
|
955 aCommandLine.Append( |
|
956 (const unsigned short *)encodedValue.c_str(), (int)encodedValue.length()); |
|
957 base64EncodedArgs.append(L"sourceurl,"); |
|
958 } |
|
959 catch (std::exception& e) |
|
960 { |
|
961 ELOG1(EJavaInstaller, |
|
962 "CJavaSifPlugin::BuildInstallCommandLine Base64 encoding source " |
|
963 "url failed, err %s", e.what()); |
|
964 } |
|
965 } |
|
966 ) |
|
967 |
|
968 // KSifInParam_Charset -> -charset=Internet-standard character set name |
|
969 TRAP_IGNORE( |
|
970 const TDesC &desValue = aArguments.StringByNameL(KSifInParam_Charset); |
|
971 if (desValue.Length() > 0) |
|
972 { |
|
973 try |
|
974 { |
|
975 std::wstring value((wchar_t *)(desValue.Ptr()), desValue.Length()); |
|
976 std::wstring encodedValue = JavaCommonUtils::wbase64encode(value); |
|
977 aCommandLine.Append(KCharSet); |
|
978 aCommandLine.Append( |
|
979 (const unsigned short *)encodedValue.c_str(), (int)encodedValue.length()); |
|
980 base64EncodedArgs.append(L"charset,"); |
|
981 } |
|
982 catch (std::exception& e) |
|
983 { |
|
984 ELOG1(EJavaInstaller, |
|
985 "CJavaSifPlugin::BuildInstallCommandLine Base64 encoding charset " |
|
986 "failed, err %s", e.what()); |
|
987 } |
|
988 } |
|
989 ) |
|
990 |
|
991 if (base64EncodedArgs.length() > 0) |
|
992 { |
|
993 // Tell Java Installer which arguments have been Base64 encoded |
|
994 aCommandLine.Append(KBase64); |
|
995 aCommandLine.Append( |
|
996 (const unsigned short *)base64EncodedArgs.c_str(), (int)base64EncodedArgs.length()); |
|
997 } |
|
998 |
|
999 return; |
|
1000 } |
|
1001 |
|
1002 TInt CJavaSifPlugin::GetPositiveIntParam( |
|
1003 const TDesC& aName, |
|
1004 const COpaqueNamedParams& aArguments) |
|
1005 { |
|
1006 // Assume that the value will not be found |
|
1007 TInt intValue = -1; |
|
1008 |
|
1009 // If the value can be read, intValue will be set, otherwise this function |
|
1010 // returns -1 |
|
1011 TRAP_IGNORE((void)aArguments.GetIntByNameL(aName, intValue)); // codescanner::voidparameter |
|
1012 |
|
1013 return intValue; |
|
1014 } |
|
1015 |
|
1016 |
|
1017 TInt CJavaSifPlugin::StartResultsServer( |
|
1018 COpaqueNamedParams& aResults, |
|
1019 CComponentInfo& aComponentInfo) |
|
1020 { |
|
1021 // Destroy old Comms server if it exists |
|
1022 delete mResultsServer; |
|
1023 mResultsServer = NULL; |
|
1024 |
|
1025 // Start new Comms server |
|
1026 mResultsServer = new ResultsServer(aResults, aComponentInfo); // codescanner::nonleavenew |
|
1027 if (NULL == mResultsServer) |
|
1028 { |
|
1029 return KErrNoMemory; |
|
1030 } |
|
1031 else |
|
1032 { |
|
1033 // Start the server |
|
1034 return mResultsServer->start(); |
|
1035 } |
|
1036 } |
|
1037 |
838 |
1038 |
839 TBool CJavaSifPlugin::ExitIfJavaInstallerRunning( |
1039 TBool CJavaSifPlugin::ExitIfJavaInstallerRunning( |
840 COpaqueNamedParams& aResults, |
1040 COpaqueNamedParams& aResults, |
841 TRequestStatus& aStatus) |
1041 TRequestStatus& aStatus) |
842 { |
1042 { |