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> |
|
27 #include <usif/usiferror.h> |
28 #include <usif/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 |
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 BuildInstallCommandLine(commandLine, aArguments); |
356 BuildInstallCommandLine(commandLine, aArguments); |
322 |
357 |
323 // Ask Java Installer to send installation results back |
358 // Ask Java Installer to send installation results back |
324 // 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 |
325 // that our ResultsServer will listen to. |
360 // that our ResultsServer will listen to. |
326 commandLine.Append(_L(" -commsresult=11000")); |
361 commandLine.Append(KCommsResult); |
327 |
362 commandLine.AppendNum(IPC_ADDRESS_JAVA_SIF_PLUGIN_C); |
328 TInt err = aFileHandle.FullName(fileName); |
363 |
|
364 TFileName fileName; |
|
365 err = aFileHandle.FullName(fileName); |
329 |
366 |
330 // Java Installer does not have AllFiles capability. |
367 // Java Installer does not have AllFiles capability. |
331 // 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 |
332 // Remove Application Management system, it must be copied |
369 // Remove Application Management system, it must be copied |
333 // to the private data cage of Java Installer in this |
370 // to the private data cage of Java Installer in this |
334 // plugin which is executed in process which hopefully has |
371 // plugin which is executed in process which hopefully has |
335 // AllFiles capability. |
372 // AllFiles capability. |
336 TRAP(err, CopyFilesIfNeededL(fileName)); |
373 TRAP(err, CopyFilesIfNeededL(fileName)); |
337 if (KErrNone != err) |
374 if (KErrNone != err) |
338 { |
375 { |
|
376 TRAP_IGNORE(aResults.AddIntL(KSifOutParam_ErrCategory, EUnexpectedError)); |
339 TRequestStatus *statusPtr(&aStatus); |
377 TRequestStatus *statusPtr(&aStatus); |
340 User::RequestComplete(statusPtr, err); |
378 User::RequestComplete(statusPtr, err); |
341 return; |
379 return; |
342 } |
380 } |
343 |
381 |
344 // Check whether the file is .jad or .jar |
382 // Check whether the file is .jad or .jar |
345 RApaLsSession apaSession; |
383 TBool isJad = EFalse; |
346 err = apaSession.Connect(); |
384 err = IsJadFile(aFileHandle, aArguments, isJad); |
347 if (KErrNone != err) |
385 if (KErrNone != err) |
348 { |
386 { |
349 ELOG1(EJavaInstaller, |
387 TRAP_IGNORE(aResults.AddIntL(KSifOutParam_ErrCategory, EUnexpectedError)); |
350 "CJavaSifPlugin::Install RApaLsSession Connect error %d", err); |
|
351 TRequestStatus *statusPtr(&aStatus); |
388 TRequestStatus *statusPtr(&aStatus); |
352 User::RequestComplete(statusPtr, err); |
389 User::RequestComplete(statusPtr, err); |
353 return; |
390 return; |
354 } |
391 } |
355 TDataType jadFileMimeType(_L8("text/vnd.sun.j2me.app-descriptor")); |
|
356 TBool isJad = EFalse; |
|
357 err = apaSession.RecognizeSpecificData(aFileHandle, jadFileMimeType, isJad); |
|
358 apaSession.Close(); |
|
359 if (KErrNone != err) |
|
360 { |
|
361 ELOG1(EJavaInstaller, |
|
362 "CJavaSifPlugin::Install RApaLsSession RecognizeSpecificData error %d", err); |
|
363 } |
|
364 if (isJad) |
392 if (isJad) |
365 { |
393 { |
366 // Installation should be started from JAD file |
394 // Installation should be started from JAD file |
367 commandLine.Append(_L(" -jad=")); |
395 commandLine.Append(KJad); |
368 } |
396 } |
369 else |
397 else |
370 { |
398 { |
371 // from JAR file |
399 // from JAR file |
372 commandLine.Append(_L(" -jar=")); |
400 commandLine.Append(KJar); |
373 } |
401 } |
374 // Filename parameter must be surrounded in double quotes to |
402 // Filename parameter must be surrounded in double quotes to |
375 // ensure that spaces in filename are passed correctly. |
403 // ensure that spaces in filename are passed correctly. |
376 commandLine.Append(_L("\"")); |
404 commandLine.Append(KDoubleQuote); |
377 commandLine.Append(fileName); |
405 commandLine.Append(fileName); |
378 commandLine.Append(_L("\"")); |
406 commandLine.Append(KDoubleQuote); |
379 |
407 |
380 // Start JavaInstaller |
408 // Start JavaInstaller |
381 std::auto_ptr<HBufC> installerProcess( |
409 std::auto_ptr<HBufC> installerProcess( |
382 stringToDes(java::runtime::JAVA_PROCESS)); |
410 stringToDes(java::runtime::JAVA_PROCESS)); |
|
411 RProcess rJavaInstaller; |
383 err = rJavaInstaller.Create(installerProcess->Des(), commandLine); |
412 err = rJavaInstaller.Create(installerProcess->Des(), commandLine); |
384 if (KErrNone == err) |
413 if (KErrNone == err) |
385 { |
414 { |
386 // Destroy old Comms server if it exists |
415 err = StartResultsServer(aResults, *mDummyInfo); |
387 delete iResultsServer; |
|
388 iResultsServer = NULL; |
|
389 // Start new Comms server that receives component ids, sets them |
|
390 // to aResults. |
|
391 iResultsServer = new ResultsServer(aResults, *iDummyInfo); |
|
392 if (NULL == iResultsServer) |
|
393 { |
|
394 err = KErrNoMemory; |
|
395 } |
|
396 else |
|
397 { |
|
398 // Start the server |
|
399 err = iResultsServer->start(); |
|
400 } |
|
401 if (KErrNone != err) |
416 if (KErrNone != err) |
402 { |
417 { |
403 // server cannot be started |
418 // server cannot be started |
404 rJavaInstaller.Close(); |
419 rJavaInstaller.Close(); |
405 ELOG1(EJavaInstaller, |
420 ELOG1(EJavaInstaller, |
406 "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)); |
407 TRequestStatus *statusPtr(&aStatus); |
423 TRequestStatus *statusPtr(&aStatus); |
408 User::RequestComplete(statusPtr, err); |
424 User::RequestComplete(statusPtr, err); |
409 return; |
425 return; |
410 } |
426 } |
411 |
427 |
530 void CJavaSifPlugin::CancelOperation() |
567 void CJavaSifPlugin::CancelOperation() |
531 { |
568 { |
532 // Send cancel message to Java Installer |
569 // Send cancel message to Java Installer |
533 |
570 |
534 // Check whether there is anything to cancel |
571 // Check whether there is anything to cancel |
535 if (iHandlesToClose.Count() < 1) |
572 if (mHandlesToClose.Count() < 1) |
536 { |
573 { |
537 // No Java Installer process running, do nothing |
574 // No Java Installer process running, do nothing |
538 WLOG(EJavaInstaller, |
575 WLOG(EJavaInstaller, |
539 "CJavaSifPlugin::CancelOperation: Cancel called but there is no operation to cancel"); |
576 "CJavaSifPlugin::CancelOperation: Cancel called but there is no operation to cancel"); |
540 return; |
577 return; |
541 } |
578 } |
542 |
579 |
543 try |
580 CommsMessage message; |
544 { |
581 message.setReceiver(IPC_ADDRESS_JAVA_INSTALLER_SERVER_C); |
545 CommsMessage message; |
582 message.setSender(IPC_ADDRESS_JAVA_SIF_PLUGIN_C); |
546 message.setModuleId(PLUGIN_ID_SAMPLE_C); |
583 message.setMessageId(INSTALLER_CANCEL_MESSAGE_ID); |
547 message.setReceiver(IPC_ADDRESS_JAVA_INSTALLER_SERVER_C); |
584 |
548 message.setSender(IPC_ADDRESS_JAVA_SIF_PLUGIN_C); |
585 CommsMessage replyMessage; |
549 message.setMessageId(INSTALLER_CANCEL_MESSAGE_ID); |
586 int timeout = 10; // 10 seconds // codescanner::magicnumbers |
550 |
587 |
551 CommsMessage replyMessage; |
588 CommsClientEndpoint comms; |
552 int timeout = 10; // 10 seconds |
589 int err = comms.connect(IPC_ADDRESS_JAVA_INSTALLER_SERVER_C); |
553 |
590 if (KErrNone == err) |
554 CommsClientEndpoint comms; |
591 { |
555 int err = comms.connect(IPC_ADDRESS_JAVA_INSTALLER_SERVER_C); |
592 err = comms.sendReceive(message, replyMessage, timeout); |
556 if (KErrNone == err) |
593 } |
557 { |
594 else |
558 err = comms.sendReceive(message, replyMessage, timeout); |
595 { |
559 } |
596 // Cannot connect to Java Installer Comms end point, |
560 else |
597 // for example Java Installer is still starting up or |
561 { |
598 // already exiting |
562 // Cannot connect to Java Installer Comms end point, |
599 WLOG1(EJavaInstaller, |
563 // for example Java Installer is still starting up or |
600 "CJavaSifPlugin:CancelOperation: Cannot connect to Java Installer " |
564 // already exiting |
601 "Comms end point, err %d", err); |
565 WLOG1(EJavaInstaller, |
602 return; |
566 "CJavaSifPlugin:CancelOperation: Cannot connect to Java Installer " |
603 } |
567 "Comms end point, err %d", err); |
604 if (err != 0) |
568 return; |
605 { |
569 } |
606 // Sending message to Java Installer failed. |
570 if (err != 0) |
607 ELOG1(EJavaInstaller, |
571 { |
608 "CJavaSifPlugin:CancelOperation: Cannot send message to Java Installer, err %d", |
572 // Sending message to Java Installer failed. |
609 err); |
573 ELOG1(EJavaInstaller, |
|
574 "CJavaSifPlugin:CancelOperation: Cannot send message to Java Installer, err %d", |
|
575 err); |
|
576 // Ignore possible errors in disconnect |
|
577 (void)comms.disconnect(); |
|
578 return; |
|
579 } |
|
580 |
|
581 // Ignore the cancel result returned in replyMessage |
|
582 // because current SIF API does not return cancel result |
|
583 |
|
584 // Ignore possible errors in disconnect |
610 // Ignore possible errors in disconnect |
585 (void)comms.disconnect(); |
611 (void)comms.disconnect(); // codescanner::voidparameter |
586 } |
612 return; |
587 catch (ExceptionBase& e) |
613 } |
588 { |
614 |
589 ELOG1(EJavaInstaller, |
615 // Ignore the cancel result returned in replyMessage |
590 "CJavaSifPlugin: Send cancel msg failed: ExceptionBase caught: %s ", |
616 // because current SIF API does not return cancel result |
591 e.toString().c_str()); |
617 |
592 return; |
618 // Ignore possible errors in disconnect |
593 } |
619 (void)comms.disconnect(); // codescanner::voidparameter |
594 catch (std::exception& e) |
|
595 { |
|
596 ELOG1(EJavaInstaller, |
|
597 "CJavaSifPlugin: Send cancel msg failed: Exception %s caught", e.what()); |
|
598 return; |
|
599 } |
|
600 |
620 |
601 // It takes some time before Java Installer had really cancelled |
621 // It takes some time before Java Installer had really cancelled |
602 // 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 |
603 // must return only after the original asynchronous call is completed. |
623 // must return only after the original asynchronous call is completed. |
604 TRequestStatus status; |
624 TRequestStatus status; |
605 // This array contains process handles for all Java Installer processes |
625 // This array contains process handles for all Java Installer processes |
606 // 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. |
607 // Check if it is still running |
627 // Check if it is still running |
608 if (iHandlesToClose[iHandlesToClose.Count()-1].ExitReason() != 0) |
628 if (mHandlesToClose[mHandlesToClose.Count()-1].ExitReason() != 0) |
609 { |
629 { |
610 // Process has already closed |
630 // Process has already closed |
611 return; |
631 return; |
612 } |
632 } |
613 // Wait until it exits |
633 // Wait until it exits |
614 iHandlesToClose[iHandlesToClose.Count()-1].Logon(status); |
634 mHandlesToClose[mHandlesToClose.Count()-1].Logon(status); |
615 User::WaitForRequest(status); |
635 User::WaitForRequest(status); // codescanner::userWaitForRequest |
616 // Ignore the exit status of Java Installer because current SIF API |
636 // Ignore the exit status of Java Installer because current SIF API |
617 // does not return cancel result |
637 // does not return cancel result |
618 |
638 |
619 return; |
639 return; |
620 } |
640 } |
621 |
641 |
622 void CJavaSifPlugin::CopyFilesIfNeededL(TFileName &aFileName) |
642 void CJavaSifPlugin::CopyFilesIfNeededL(TFileName &aFileName) |
623 { |
643 { |
624 // 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 |
625 TInt idx = aFileName.FindF(KPrivateDataCage); |
645 TInt idx = aFileName.FindF(KPrivateDataCage); |
626 if ((idx != KErrNotFound) && (idx < 3)) |
646 if ((idx != KErrNotFound) && (idx < 3)) // codescanner::magicnumbers |
627 { |
647 { |
628 // In case of device Inbox or Java Installer itself do nothing |
648 // In case of device Inbox or Java Installer itself do nothing |
629 if ((aFileName.FindF(KInboxDataCage) != KErrNotFound) || |
649 if ((aFileName.FindF(KInboxDataCage) != KErrNotFound) || |
630 (aFileName.FindF(KJavaInstallerDataCage) != KErrNotFound)) |
650 (aFileName.FindF(KJavaInstallerDataCage) != KErrNotFound)) |
631 { |
651 { |
662 |
682 |
663 return; |
683 return; |
664 } |
684 } |
665 |
685 |
666 |
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 |
667 void CJavaSifPlugin::BuildInstallCommandLine( |
749 void CJavaSifPlugin::BuildInstallCommandLine( |
668 TBuf<1536>& aCommandLine, |
750 TPtr& aCommandLine, |
669 const COpaqueNamedParams& aArguments) |
751 const COpaqueNamedParams& aArguments) |
670 { |
752 { |
671 TBool paramFound = EFalse; |
|
672 TInt intValue = 0; |
|
673 TDesC desValue = KNullDesC; |
|
674 |
|
675 // KSifInParam_Drive -> -drive=install_target_drive (A, B, C, ..., Z) |
753 // KSifInParam_Drive -> -drive=install_target_drive (A, B, C, ..., Z) |
676 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_Drive, intValue)); |
754 TInt intValue = GetPositiveIntParam(KSifInParam_Drive, aArguments); |
677 if (paramFound) |
755 // Value 0 is 'A:' drive and value 25 is 'Z:' drive |
678 { |
756 if ((intValue > -1) && (intValue < 26)) // codescanner::magicnumbers |
679 // Value 0 is 'A:' drive and value 25 is 'Z:' drive |
757 { |
680 if ((intValue > -1) && (intValue < 26)) |
758 aCommandLine.Append(KDrive); |
681 { |
759 TChar drive('A'); |
682 aCommandLine.Append(_L(" -drive=")); |
760 drive += intValue; |
683 TChar drive('A'); |
761 aCommandLine.Append(drive); |
684 drive += intValue; |
|
685 aCommandLine.Append(drive); |
|
686 } |
|
687 else |
|
688 { |
|
689 WLOG1(EJavaInstaller, |
|
690 "CJavaSifPlugin::Install Ignoring illegal KSifInParam_Drive param (value %d)", |
|
691 intValue); |
|
692 } |
|
693 } |
762 } |
694 |
763 |
695 // KSifInParam_PerformOCSP Yes/No/AskUser -> -ocsp=yes|no |
764 // KSifInParam_PerformOCSP Yes/No/AskUser -> -ocsp=yes|no |
696 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_PerformOCSP, intValue)); |
765 intValue = GetPositiveIntParam(KSifInParam_PerformOCSP, aArguments); |
697 if (paramFound) |
766 if (intValue == 0) // Yes |
698 { |
767 { |
699 if (intValue == 0) // Yes |
768 aCommandLine.Append(KOcsp); |
700 { |
769 aCommandLine.Append(KYes); |
701 aCommandLine.Append(_L(" -ocsp=yes")); |
770 } |
702 } |
771 else if (intValue == 1) // No |
703 else if (intValue == 1) // No |
772 { |
704 { |
773 aCommandLine.Append(KOcsp); |
705 aCommandLine.Append(_L(" -ocsp=no")); |
774 aCommandLine.Append(KNo); |
706 } |
775 } |
707 // AskUser is not supported |
776 // AskUser is not supported |
708 } |
|
709 |
777 |
710 // KSifInParam_IgnoreOCSPWarnings Yes/No/AskUser -> -ignore_ocsp_warnings=yes|no |
778 // KSifInParam_IgnoreOCSPWarnings Yes/No/AskUser -> -ignore_ocsp_warnings=yes|no |
711 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_IgnoreOCSPWarnings, intValue)); |
779 intValue = GetPositiveIntParam(KSifInParam_IgnoreOCSPWarnings, aArguments); |
712 if (paramFound) |
780 if (intValue == 0) // Yes |
713 { |
781 { |
714 if (intValue == 0) // Yes |
782 aCommandLine.Append(KIgnoreOcspWarnings); |
715 { |
783 aCommandLine.Append(KYes); |
716 aCommandLine.Append(_L(" -ignore_ocsp_warnings=yes")); |
784 } |
717 } |
785 else if (intValue == 1) // No |
718 else if (intValue == 1) // No |
786 { |
719 { |
787 aCommandLine.Append(KIgnoreOcspWarnings); |
720 aCommandLine.Append(_L(" -ignore_ocsp_warnings=no")); |
788 aCommandLine.Append(KNo); |
721 } |
789 } |
722 // AskUser is not supported |
790 // AskUser is not supported |
723 } |
|
724 |
791 |
725 // KSifInParam_AllowUpgrade Yes/No/AskUser -> -upgrade=yes|no |
792 // KSifInParam_AllowUpgrade Yes/No/AskUser -> -upgrade=yes|no |
726 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_AllowUpgrade, intValue)); |
793 intValue = GetPositiveIntParam(KSifInParam_AllowUpgrade, aArguments); |
727 if (paramFound) |
794 if (intValue == 0) // Yes |
728 { |
795 { |
729 if (intValue == 0) // Yes |
796 aCommandLine.Append(KUpgrade); |
730 { |
797 aCommandLine.Append(KYes); |
731 aCommandLine.Append(_L(" -upgrade=yes")); |
798 } |
732 } |
799 else if (intValue == 1) // No |
733 else if (intValue == 1) // No |
800 { |
734 { |
801 aCommandLine.Append(KUpgrade); |
735 aCommandLine.Append(_L(" -upgrade=no")); |
802 aCommandLine.Append(KNo); |
736 } |
803 } |
737 // AskUser is not supported |
804 // AskUser is not supported |
738 } |
805 |
739 |
806 |
740 |
807 |
741 // TODO: activate this code block when KSifInParam_UpgradeData has been |
808 // TODO: activate this code block when KSifInParam_UpgradeData has been |
742 // defined in sifcommon.h |
809 // defined in sifcommon.h |
743 /* |
810 /* |
744 // KSifInParam_UpgradeData Yes/No/AskUser -> -upgrade_data=yes|no |
811 // KSifInParam_UpgradeData Yes/No/AskUser -> -upgrade_data=yes|no |
745 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_UpgradeData, intValue)); |
812 intValue = GetPositiveIntParam(KSifInParam_UpgradeData, aArguments); |
746 if (paramFound) |
813 if (intValue == 0) // Yes |
747 { |
814 { |
748 if (intValue == 0) // Yes |
815 aCommandLine.Append(KUpgradeData); |
749 { |
816 aCommandLine.Append(KYes); |
750 aCommandLine.Append(_L(" -upgrade_data=yes")); |
817 } |
751 } |
818 else if (intValue == 1) // No |
752 else if (intValue == 1) // No |
819 { |
753 { |
820 aCommandLine.Append(KUpgradeData); |
754 aCommandLine.Append(_L(" -upgrade_data=no")); |
821 aCommandLine.Append(KNo); |
755 } |
822 } |
756 // AskUser is not supported |
823 // AskUser is not supported |
757 } |
|
758 */ |
824 */ |
759 |
825 |
760 // KSifInParam_AllowUntrusted Yes/No/AskUser -> -untrusted=yes|no |
826 // KSifInParam_AllowUntrusted Yes/No/AskUser -> -untrusted=yes|no |
761 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_AllowUntrusted, intValue)); |
827 intValue = GetPositiveIntParam(KSifInParam_AllowUntrusted, aArguments); |
762 if (paramFound) |
828 if (intValue == 0) // Yes |
763 { |
829 { |
764 if (intValue == 0) // Yes |
830 aCommandLine.Append(KUntrusted); |
765 { |
831 aCommandLine.Append(KYes); |
766 aCommandLine.Append(_L(" -untrusted=yes")); |
832 } |
767 } |
833 else if (intValue == 1) // No |
768 else if (intValue == 1) // No |
834 { |
769 { |
835 aCommandLine.Append(KUntrusted); |
770 aCommandLine.Append(_L(" -untrusted=no")); |
836 aCommandLine.Append(KNo); |
771 } |
837 } |
772 // AskUser is not supported |
838 // AskUser is not supported |
773 } |
|
774 |
839 |
775 // KSifInParam_AllowOverwrite Yes/No/AskUser -> -overwrite=yes|no |
840 // KSifInParam_AllowOverwrite Yes/No/AskUser -> -overwrite=yes|no |
776 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_AllowOverwrite, intValue)); |
841 intValue = GetPositiveIntParam(KSifInParam_AllowOverwrite, aArguments); |
777 if (paramFound) |
842 if (intValue == 0) // Yes |
778 { |
843 { |
779 if (intValue == 0) // Yes |
844 aCommandLine.Append(KOverwrite); |
780 { |
845 aCommandLine.Append(KYes); |
781 aCommandLine.Append(_L(" -overwrite=yes")); |
846 } |
782 } |
847 else if (intValue == 1) // No |
783 else if (intValue == 1) // No |
848 { |
784 { |
849 aCommandLine.Append(KOverwrite); |
785 aCommandLine.Append(_L(" -overwrite=no")); |
850 aCommandLine.Append(KNo); |
786 } |
851 } |
787 // AskUser is not supported |
852 // AskUser is not supported |
788 } |
|
789 |
853 |
790 // KSifInParam_AllowDownload Yes/No/AskUser -> -download=yes|no |
854 // KSifInParam_AllowDownload Yes/No/AskUser -> -download=yes|no |
791 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_AllowDownload, intValue)); |
855 intValue = GetPositiveIntParam(KSifInParam_AllowDownload, aArguments); |
792 if (paramFound) |
856 if (intValue == 0) // Yes |
793 { |
857 { |
794 if (intValue == 0) // Yes |
858 aCommandLine.Append(KDownload); |
795 { |
859 aCommandLine.Append(KYes); |
796 aCommandLine.Append(_L(" -download=yes")); |
860 } |
797 } |
861 else if (intValue == 1) // No |
798 else if (intValue == 1) // No |
862 { |
799 { |
863 aCommandLine.Append(KDownload); |
800 aCommandLine.Append(_L(" -download=no")); |
864 aCommandLine.Append(KNo); |
801 } |
865 } |
802 // AskUser is not supported |
866 // AskUser is not supported |
803 } |
867 |
804 |
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; |
805 // KSifInParam_UserName -> -username=download_username |
899 // KSifInParam_UserName -> -username=download_username |
806 TRAP_IGNORE(desValue = aArguments.StringByNameL(KSifInParam_UserName)); |
900 TRAP_IGNORE( |
807 if (desValue.Length() > 0) |
901 const TDesC &desValue = aArguments.StringByNameL(KSifInParam_UserName); |
808 { |
902 if (desValue.Length() > 0) |
809 aCommandLine.Append(_L(" -username=")); |
903 { |
810 aCommandLine.Append(desValue); |
904 try |
811 } |
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 ) |
812 |
921 |
813 // KSifInParam_Password -> -password=download_password |
922 // KSifInParam_Password -> -password=download_password |
814 TRAP_IGNORE(desValue = aArguments.StringByNameL(KSifInParam_Password)); |
923 TRAP_IGNORE( |
815 if (desValue.Length() > 0) |
924 const TDesC &desValue = aArguments.StringByNameL(KSifInParam_Password); |
816 { |
925 if (desValue.Length() > 0) |
817 aCommandLine.Append(_L(" -password=")); |
926 { |
818 aCommandLine.Append(desValue); |
927 try |
819 } |
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 ) |
820 |
944 |
821 // KSifInParam_SourceUrl -> -sourceurl=original (HTTP) URL of the JAD or JAR file |
945 // KSifInParam_SourceUrl -> -sourceurl=original (HTTP) URL of the JAD or JAR file |
822 TRAP_IGNORE(desValue = aArguments.StringByNameL(KSifInParam_SourceUrl)); |
946 TRAP_IGNORE( |
823 if (desValue.Length() > 0) |
947 const TDesC &desValue = aArguments.StringByNameL(KSifInParam_SourceUrl); |
824 { |
948 if (desValue.Length() > 0) |
825 aCommandLine.Append(_L(" -sourceurl=")); |
949 { |
826 aCommandLine.Append(desValue); |
950 try |
827 } |
951 { |
828 |
952 std::wstring value((wchar_t *)(desValue.Ptr()), desValue.Length()); |
829 // KSifInParam_IAP -> -iap=IAP_ID (internet access point id) |
953 std::wstring encodedValue = JavaCommonUtils::wbase64encode(value); |
830 TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_IAP, intValue)); |
954 aCommandLine.Append(KSourceUrl); |
831 if (paramFound) |
955 aCommandLine.Append( |
832 { |
956 (const unsigned short *)encodedValue.c_str(), (int)encodedValue.length()); |
833 aCommandLine.Append(_L(" -iap=")); |
957 base64EncodedArgs.append(L"sourceurl,"); |
834 aCommandLine.AppendNum(intValue); |
958 } |
835 } |
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 ) |
836 |
967 |
837 // KSifInParam_Charset -> -charset=Internet-standard character set name |
968 // KSifInParam_Charset -> -charset=Internet-standard character set name |
838 TRAP_IGNORE(desValue = aArguments.StringByNameL(KSifInParam_Charset)); |
969 TRAP_IGNORE( |
839 if (desValue.Length() > 0) |
970 const TDesC &desValue = aArguments.StringByNameL(KSifInParam_Charset); |
840 { |
971 if (desValue.Length() > 0) |
841 aCommandLine.Append(_L(" -charset=")); |
972 { |
842 aCommandLine.Append(desValue); |
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()); |
843 } |
997 } |
844 |
998 |
845 return; |
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 } |
846 } |
1036 } |
847 |
1037 |
848 |
1038 |
849 TBool CJavaSifPlugin::ExitIfJavaInstallerRunning( |
1039 TBool CJavaSifPlugin::ExitIfJavaInstallerRunning( |
850 COpaqueNamedParams& aResults, |
1040 COpaqueNamedParams& aResults, |