47 using namespace java::comms; |
47 using namespace java::comms; |
48 |
48 |
49 _LIT(KPrivateDataCage, "\\private\\"); |
49 _LIT(KPrivateDataCage, "\\private\\"); |
50 _LIT(KInboxDataCage, "\\private\\1000484b\\"); |
50 _LIT(KInboxDataCage, "\\private\\1000484b\\"); |
51 _LIT(KJavaInstallerProcess, "Installer*"); |
51 _LIT(KJavaInstallerProcess, "Installer*"); |
|
52 _LIT(KJavaInstallCopierProcess, "javainstallcopier.exe"); |
52 _LIT(KJavaInstallerDataCage, "\\private\\102033e6\\"); |
53 _LIT(KJavaInstallerDataCage, "\\private\\102033e6\\"); |
53 _LIT(KJavaInstallerTmp, "\\private\\102033E6\\installer\\tmp\\"); |
54 _LIT(KJavaInstallerTmp, "\\private\\102033E6\\installer\\tmp\\"); |
54 _LIT(KAnyExtension, ".*"); |
55 _LIT(KAnyExtension, ".*"); |
55 _LIT(KComponentInfo, " componentinfo"); |
56 _LIT(KComponentInfo, " componentinfo"); |
56 _LIT(KCommsResult, " -commsresult="); |
57 _LIT(KCommsResult, " -commsresult="); |
91 const TInt KShortCmdLineLen = 256; |
92 const TInt KShortCmdLineLen = 256; |
92 |
93 |
93 // Java Installer is executed with same Uid as Java Runtime |
94 // Java Installer is executed with same Uid as Java Runtime |
94 _LIT_SECURE_ID(KJavaInstallerSecureID, KJavaMidpSecureId); |
95 _LIT_SECURE_ID(KJavaInstallerSecureID, KJavaMidpSecureId); |
95 |
96 |
96 |
97 /** |
|
98 * This function is called to hide the 'Preparing Installation' dialog. |
|
99 */ |
|
100 LOCAL_C TInt HidePrepInstDialog(TAny* aPlugin) |
|
101 { |
|
102 CJavaSifPlugin *pPlugin = (CJavaSifPlugin *)aPlugin; |
|
103 if (NULL != pPlugin) |
|
104 { |
|
105 TRAP_IGNORE(pPlugin->HidePrepInstDialogL()); |
|
106 } |
|
107 return KErrNone; |
|
108 } |
97 |
109 |
98 // ============================ MEMBER FUNCTIONS =============================== |
110 // ============================ MEMBER FUNCTIONS =============================== |
99 |
111 |
100 CJavaSifPlugin* CJavaSifPlugin::NewL() |
112 CJavaSifPlugin* CJavaSifPlugin::NewL() |
101 { |
113 { |
124 delete mDummyResults; |
136 delete mDummyResults; |
125 mDummyResults = NULL; |
137 mDummyResults = NULL; |
126 |
138 |
127 delete mDummyInfo; |
139 delete mDummyInfo; |
128 mDummyInfo = NULL; |
140 mDummyInfo = NULL; |
|
141 |
|
142 delete mPrepInstDialog; |
|
143 mPrepInstDialog = NULL; |
|
144 |
|
145 if (mWaitToHideDialog) |
|
146 { |
|
147 delete mWaitToHideDialog; |
|
148 mWaitToHideDialog = NULL; |
|
149 } |
129 } |
150 } |
130 |
151 |
131 CJavaSifPlugin::CJavaSifPlugin() |
152 CJavaSifPlugin::CJavaSifPlugin() |
132 { |
153 { |
133 } |
154 } |
137 User::LeaveIfError(mRFs.Connect()); |
158 User::LeaveIfError(mRFs.Connect()); |
138 User::LeaveIfError(mRFs.ShareProtected()); |
159 User::LeaveIfError(mRFs.ShareProtected()); |
139 mResultsServer = NULL; |
160 mResultsServer = NULL; |
140 mDummyResults = COpaqueNamedParams::NewL(); // codescanner::forgottoputptroncleanupstack |
161 mDummyResults = COpaqueNamedParams::NewL(); // codescanner::forgottoputptroncleanupstack |
141 mDummyInfo = CComponentInfo::NewL(); |
162 mDummyInfo = CComponentInfo::NewL(); |
|
163 mWaitToHideDialog = NULL; |
142 } |
164 } |
143 |
165 |
144 void CJavaSifPlugin::GetComponentInfo( |
166 void CJavaSifPlugin::GetComponentInfo( |
145 const TDesC& aFileName, |
167 const TDesC& aFileName, |
146 const TSecurityContext& aSecurityContext, |
168 const TSecurityContext& aSecurityContext, |
275 |
297 |
276 rJavaInstaller.Resume(); |
298 rJavaInstaller.Resume(); |
277 |
299 |
278 // Do NOT close rJavaInstaller now -> the caller gets notification when the |
300 // Do NOT close rJavaInstaller now -> the caller gets notification when the |
279 // process actually closes. |
301 // process actually closes. |
280 mHandlesToClose.Append(rJavaInstaller); |
302 err = mHandlesToClose.Append(rJavaInstaller); |
|
303 if ( err ) |
|
304 { |
|
305 rJavaInstaller.Close(); |
|
306 ELOG1(EJavaInstaller, "CJavaSifPlugin::GetComponentInfo mHandles" |
|
307 "ToClose.Append failed with error %d", err); |
|
308 TRequestStatus *statusPtr(&aStatus); |
|
309 User::RequestComplete(statusPtr, err); |
|
310 return; |
|
311 } |
281 } |
312 } |
282 |
313 |
283 void CJavaSifPlugin::Install( |
314 void CJavaSifPlugin::Install( |
284 const TDesC& aFileName, |
315 const TDesC& aFileName, |
285 const TSecurityContext& aSecurityContext, |
316 const TSecurityContext& aSecurityContext, |
349 User::RequestComplete(statusPtr, KErrPermissionDenied); |
380 User::RequestComplete(statusPtr, KErrPermissionDenied); |
350 return; |
381 return; |
351 } |
382 } |
352 |
383 |
353 commandLine.Append(KSilent); |
384 commandLine.Append(KSilent); |
|
385 } |
|
386 else |
|
387 { |
|
388 // Uncomment this to enable 'preparing installation' dialog. |
|
389 //TRAP(err, CreatePrepInstDialogL()); |
|
390 //if (KErrNone != err) |
|
391 //{ |
|
392 // WLOG1(EJavaInstaller, |
|
393 // "CJavaSifPlugin::Install Creating preparing installation dialog failed, err=%d", |
|
394 // err); |
|
395 //} |
354 } |
396 } |
355 |
397 |
356 BuildInstallCommandLine(commandLine, aArguments); |
398 BuildInstallCommandLine(commandLine, aArguments); |
357 |
399 |
358 // Ask Java Installer to send installation results back |
400 // Ask Java Installer to send installation results back |
438 TRequestStatus *statusPtr(&aStatus); |
480 TRequestStatus *statusPtr(&aStatus); |
439 User::RequestComplete(statusPtr, err); |
481 User::RequestComplete(statusPtr, err); |
440 return; |
482 return; |
441 } |
483 } |
442 |
484 |
|
485 if (!silentInstall) |
|
486 { |
|
487 TRAP(err, mWaitToHideDialog = |
|
488 CAsyncWaitCallBack::NewL(TCallBack(HidePrepInstDialog, this))); |
|
489 if (KErrNone == err) |
|
490 { |
|
491 // The active object will wait until JavaInstaller process calls Rendezvous. |
|
492 // If JavaInstaller specifies reason code EJavaInstaller, then |
|
493 // the active object will call callback function that will hide the |
|
494 // 'Preparing installation' dialog. If reason code is not EJavaInstaller, |
|
495 // the wait object will automatically wait for the next rendezvous. |
|
496 mWaitToHideDialog->Wait( rJavaInstaller, EJavaInstaller ); |
|
497 } |
|
498 else |
|
499 { |
|
500 ELOG1(EJavaInstaller, "CJavaSifPlugin::Install: Creating " |
|
501 "mWaitToHideDialog failed, err %d", err); |
|
502 } |
|
503 } |
443 rJavaInstaller.Resume(); |
504 rJavaInstaller.Resume(); |
444 |
505 |
445 // Do NOT close rJavaInstaller now -> the caller gets notification when the |
506 // Do NOT close rJavaInstaller now -> the caller gets notification when the |
446 // process actually closes. |
507 // process actually closes. |
447 mHandlesToClose.Append(rJavaInstaller); |
508 err = mHandlesToClose.Append(rJavaInstaller); |
|
509 if ( err ) |
|
510 { |
|
511 rJavaInstaller.Close(); |
|
512 ELOG1(EJavaInstaller, "CJavaSifPlugin::Install mHandles" |
|
513 "ToClose.Append failed with error %d", err); |
|
514 TRAP_IGNORE(aResults.AddIntL(KSifOutParam_ErrCategory, ELowMemory)); |
|
515 TRequestStatus *statusPtr(&aStatus); |
|
516 User::RequestComplete(statusPtr, err); |
|
517 return; |
|
518 } |
|
519 |
448 } |
520 } |
449 |
521 |
450 void CJavaSifPlugin::Uninstall( |
522 void CJavaSifPlugin::Uninstall( |
451 TComponentId aComponentId, |
523 TComponentId aComponentId, |
452 const TSecurityContext& aSecurityContext, |
524 const TSecurityContext& aSecurityContext, |
537 return; |
609 return; |
538 } |
610 } |
539 |
611 |
540 // Do NOT close rJavaInstaller now -> the caller gets notification when the |
612 // Do NOT close rJavaInstaller now -> the caller gets notification when the |
541 // process actually closes. |
613 // process actually closes. |
542 mHandlesToClose.Append(rJavaInstaller); |
614 err = mHandlesToClose.Append(rJavaInstaller); |
|
615 if ( err ) |
|
616 { |
|
617 rJavaInstaller.Close(); |
|
618 ELOG1(EJavaInstaller, "CJavaSifPlugin::Uninstall mHandles" |
|
619 "ToClose.Append failed with error %d", err); |
|
620 TRAP_IGNORE(aResults.AddIntL(KSifOutParam_ErrCategory, ELowMemory)); |
|
621 TRequestStatus *statusPtr(&aStatus); |
|
622 User::RequestComplete(statusPtr, err); |
|
623 return; |
|
624 } |
543 } |
625 } |
544 |
626 |
545 void CJavaSifPlugin::Activate( |
627 void CJavaSifPlugin::Activate( |
546 TComponentId /* aComponentId */, |
628 TComponentId /* aComponentId */, |
547 const TSecurityContext& /* aSecurityContext */, |
629 const TSecurityContext& /* aSecurityContext */, |
657 // the corresponding .jar file are copied. |
739 // the corresponding .jar file are copied. |
658 // (aFileName is <path>\<name>.<ext>, copy <path>\<name>.* |
740 // (aFileName is <path>\<name>.<ext>, copy <path>\<name>.* |
659 // to Java Installer tmp dir.) |
741 // to Java Installer tmp dir.) |
660 TParse fp; |
742 TParse fp; |
661 mRFs.Parse(aFileName, fp); |
743 mRFs.Parse(aFileName, fp); |
662 |
|
663 CFileMan* fm = CFileMan::NewL(mRFs); |
|
664 TFileName filesToCopy = fp.DriveAndPath(); |
744 TFileName filesToCopy = fp.DriveAndPath(); |
665 filesToCopy.Append(fp.Name()); |
745 filesToCopy.Append(fp.Name()); |
666 filesToCopy.Append(KAnyExtension); |
746 filesToCopy.Append(KAnyExtension); |
667 TInt err = fm->Copy(filesToCopy, KJavaInstallerTmp, CFileMan::ERecurse); |
747 |
668 delete fm; |
748 // Use JavaInstallCopier.exe to copy the files. |
669 if (KErrNone != err) |
749 RProcess rJavaInstallCopier; |
670 { |
750 TInt err = rJavaInstallCopier.Create( |
|
751 KJavaInstallCopierProcess, filesToCopy); |
|
752 if (KErrNone == err) |
|
753 { |
|
754 TRequestStatus status; |
|
755 rJavaInstallCopier.Logon(status); |
|
756 rJavaInstallCopier.Resume(); |
|
757 User::WaitForRequest(status); // codescanner::userWaitForRequest |
|
758 err = rJavaInstallCopier.ExitReason(); |
|
759 rJavaInstallCopier.Close(); |
|
760 if (KErrNone != err) |
|
761 { |
|
762 ELOG1(EJavaInstaller, |
|
763 "CJavaSifPlugin::CopyFilesIfNeededL: copying files " |
|
764 "to JavaInstaller data cage failed, err=%d", err); |
|
765 User::Leave(err); |
|
766 } |
|
767 } |
|
768 else |
|
769 { |
|
770 rJavaInstallCopier.Close(); |
671 ELOG1(EJavaInstaller, |
771 ELOG1(EJavaInstaller, |
672 "CJavaSifPlugin::CopyFilesIfNeededL: copying files " |
772 "CJavaSifPlugin::CopyFilesIfNeededL: starting " |
673 "to Java Installer data cage failed, err=%d", err); |
773 "JavaInstallCopier failed, err=%d", err); |
674 User::Leave(err); |
774 User::Leave(err); |
675 } |
775 } |
676 |
776 |
677 // aFileName must point to the copy of the file |
777 // aFileName must point to the copy of the file |
678 aFileName = fp.Drive(); |
778 aFileName = fp.Drive(); |
801 aCommandLine.Append(KUpgrade); |
901 aCommandLine.Append(KUpgrade); |
802 aCommandLine.Append(KNo); |
902 aCommandLine.Append(KNo); |
803 } |
903 } |
804 // AskUser is not supported |
904 // AskUser is not supported |
805 |
905 |
806 |
906 // KSifInParam_AllowUpgradeData Yes/No/AskUser -> -upgrade_data=yes|no |
807 |
907 intValue = GetPositiveIntParam(KSifInParam_AllowUpgradeData, aArguments); |
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 |
908 if (intValue == 0) // Yes |
814 { |
909 { |
815 aCommandLine.Append(KUpgradeData); |
910 aCommandLine.Append(KUpgradeData); |
816 aCommandLine.Append(KYes); |
911 aCommandLine.Append(KYes); |
817 } |
912 } |
819 { |
914 { |
820 aCommandLine.Append(KUpgradeData); |
915 aCommandLine.Append(KUpgradeData); |
821 aCommandLine.Append(KNo); |
916 aCommandLine.Append(KNo); |
822 } |
917 } |
823 // AskUser is not supported |
918 // AskUser is not supported |
824 */ |
|
825 |
919 |
826 // KSifInParam_AllowUntrusted Yes/No/AskUser -> -untrusted=yes|no |
920 // KSifInParam_AllowUntrusted Yes/No/AskUser -> -untrusted=yes|no |
827 intValue = GetPositiveIntParam(KSifInParam_AllowUntrusted, aArguments); |
921 intValue = GetPositiveIntParam(KSifInParam_AllowUntrusted, aArguments); |
828 if (intValue == 0) // Yes |
922 if (intValue == 0) // Yes |
829 { |
923 { |
1099 } |
1193 } |
1100 |
1194 |
1101 return EFalse; |
1195 return EFalse; |
1102 } |
1196 } |
1103 |
1197 |
|
1198 /** |
|
1199 * Creates 'preparing installation' dialog. |
|
1200 */ |
|
1201 void CJavaSifPlugin::CreatePrepInstDialogL() |
|
1202 { |
|
1203 ILOG(EJavaInstaller, "CJavaSifPlugin::CreatePrepInstDialogL creating dialog"); |
|
1204 mPrepInstDialog = CHbDeviceNotificationDialogSymbian::NewL(); |
|
1205 _LIT(KPrepInstText, "Preparing installation..."); |
|
1206 mPrepInstDialog->SetTitleL(KPrepInstText); |
|
1207 mPrepInstDialog->SetTimeout(20*1000); // ms |
|
1208 mPrepInstDialog->ShowL(); |
|
1209 ILOG(EJavaInstaller, "CJavaSifPlugin::CreatePrepInstDialogL dialog created"); |
|
1210 } |
|
1211 |
|
1212 void CJavaSifPlugin::HidePrepInstDialogL() |
|
1213 { |
|
1214 ILOG(EJavaInstaller, "CJavaSifPlugin::HidePrepInstDialogL hiding dialog"); |
|
1215 // Stop further timed calls |
|
1216 if (mWaitToHideDialog) |
|
1217 { |
|
1218 mWaitToHideDialog->Cancel(); |
|
1219 } |
|
1220 // Close wait dialog. |
|
1221 if (mPrepInstDialog) |
|
1222 { |
|
1223 mPrepInstDialog->Close(); |
|
1224 } |
|
1225 ILOG(EJavaInstaller, "CJavaSifPlugin::HidePrepInstDialogL dialog hidden"); |
|
1226 } |
1104 |
1227 |
1105 // End of File |
1228 // End of File |