javamanager/javainstaller/javasifplugin/src/javasifplugin.cpp
changeset 80 d6dafc5d983f
parent 78 71ad690e91f5
equal deleted inserted replaced
78:71ad690e91f5 80:d6dafc5d983f
    92 const TInt KShortCmdLineLen = 256;
    92 const TInt KShortCmdLineLen = 256;
    93 
    93 
    94 // Java Installer is executed with same Uid as Java Runtime
    94 // Java Installer is executed with same Uid as Java Runtime
    95 _LIT_SECURE_ID(KJavaInstallerSecureID, KJavaMidpSecureId);
    95 _LIT_SECURE_ID(KJavaInstallerSecureID, KJavaMidpSecureId);
    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 }
       
   109 
       
   110 // ============================ MEMBER FUNCTIONS ===============================
    97 // ============================ MEMBER FUNCTIONS ===============================
   111 
    98 
   112 CJavaSifPlugin* CJavaSifPlugin::NewL()
    99 CJavaSifPlugin* CJavaSifPlugin::NewL()
   113 {
   100 {
   114     CJavaSifPlugin* self = new(ELeave) CJavaSifPlugin();
   101     CJavaSifPlugin* self = new(ELeave) CJavaSifPlugin();
   136     delete mDummyResults;
   123     delete mDummyResults;
   137     mDummyResults = NULL;
   124     mDummyResults = NULL;
   138 
   125 
   139     delete mDummyInfo;
   126     delete mDummyInfo;
   140     mDummyInfo = NULL;
   127     mDummyInfo = NULL;
   141 
       
   142     delete mPrepInstDialog;
       
   143     mPrepInstDialog = NULL;
       
   144 
       
   145     if (mWaitToHideDialog)
       
   146     {
       
   147         delete mWaitToHideDialog;
       
   148         mWaitToHideDialog = NULL;
       
   149     }
       
   150 }
   128 }
   151 
   129 
   152 CJavaSifPlugin::CJavaSifPlugin()
   130 CJavaSifPlugin::CJavaSifPlugin()
   153 {
   131 {
   154 }
   132 }
   158     User::LeaveIfError(mRFs.Connect());
   136     User::LeaveIfError(mRFs.Connect());
   159     User::LeaveIfError(mRFs.ShareProtected());
   137     User::LeaveIfError(mRFs.ShareProtected());
   160     mResultsServer = NULL;
   138     mResultsServer = NULL;
   161     mDummyResults = COpaqueNamedParams::NewL(); // codescanner::forgottoputptroncleanupstack
   139     mDummyResults = COpaqueNamedParams::NewL(); // codescanner::forgottoputptroncleanupstack
   162     mDummyInfo = CComponentInfo::NewL();
   140     mDummyInfo = CComponentInfo::NewL();
   163     mWaitToHideDialog = NULL;
       
   164 }
   141 }
   165 
   142 
   166 void CJavaSifPlugin::GetComponentInfo(
   143 void CJavaSifPlugin::GetComponentInfo(
   167     const TDesC& aFileName,
   144     const TDesC& aFileName,
   168     const TSecurityContext& aSecurityContext,
   145     const TSecurityContext& aSecurityContext,
   381             return;
   358             return;
   382         }
   359         }
   383 
   360 
   384         commandLine.Append(KSilent);
   361         commandLine.Append(KSilent);
   385     }
   362     }
   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         //}
       
   396     }
       
   397 
   363 
   398     BuildInstallCommandLine(commandLine, aArguments);
   364     BuildInstallCommandLine(commandLine, aArguments);
   399 
   365 
   400     // Ask Java Installer to send installation results back
   366     // Ask Java Installer to send installation results back
   401     // as Comms message. 11000 is IPC_ADDRESS_JAVA_SIF_PLUGIN_C Comms endpoint
   367     // as Comms message. 11000 is IPC_ADDRESS_JAVA_SIF_PLUGIN_C Comms endpoint
   480         TRequestStatus *statusPtr(&aStatus);
   446         TRequestStatus *statusPtr(&aStatus);
   481         User::RequestComplete(statusPtr, err);
   447         User::RequestComplete(statusPtr, err);
   482         return;
   448         return;
   483     }
   449     }
   484 
   450 
   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     }
       
   504     rJavaInstaller.Resume();
   451     rJavaInstaller.Resume();
   505 
   452 
   506     // Do NOT close rJavaInstaller now -> the caller gets notification when the
   453     // Do NOT close rJavaInstaller now -> the caller gets notification when the
   507     // process actually closes.
   454     // process actually closes.
   508     err = mHandlesToClose.Append(rJavaInstaller);
   455     err = mHandlesToClose.Append(rJavaInstaller);
   849 void CJavaSifPlugin::BuildInstallCommandLine(
   796 void CJavaSifPlugin::BuildInstallCommandLine(
   850     TPtr& aCommandLine,
   797     TPtr& aCommandLine,
   851     const COpaqueNamedParams& aArguments)
   798     const COpaqueNamedParams& aArguments)
   852 {
   799 {
   853     // KSifInParam_Drive -> -drive=install_target_drive (A, B, C, ..., Z)
   800     // KSifInParam_Drive -> -drive=install_target_drive (A, B, C, ..., Z)
   854     TInt intValue = GetPositiveIntParam(KSifInParam_Drive, aArguments);
   801     TInt intValue;
   855     // Value 0 is 'A:' drive and  value 25 is 'Z:' drive
   802     RArray<TInt> intArray;
   856     if ((intValue > -1) && (intValue < 26))  // codescanner::magicnumbers
   803     TRAPD(err, intArray = aArguments.IntArrayByNameL(KSifInParam_Drive));
   857     {
   804     if (err == KErrNone && intArray.Count() > 0)
   858         aCommandLine.Append(KDrive);
   805     {
   859         TChar drive('A');
   806         // Java installer supports one installation drive only, so take
   860         drive += intValue;
   807         // the first parameter which is the most preferred drive.
   861         aCommandLine.Append(drive);
   808         intValue = intArray[0];
       
   809         // Value 0 is 'A:' drive and  value 25 is 'Z:' drive
       
   810         if ((intValue > -1) && (intValue < 26))  // codescanner::magicnumbers
       
   811         {
       
   812             aCommandLine.Append(KDrive);
       
   813             TChar drive('A');
       
   814             drive += intValue;
       
   815             aCommandLine.Append(drive);
       
   816         }
   862     }
   817     }
   863 
   818 
   864     // KSifInParam_PerformOCSP Yes/No/AskUser -> -ocsp=yes|no
   819     // KSifInParam_PerformOCSP Yes/No/AskUser -> -ocsp=yes|no
   865     intValue = GetPositiveIntParam(KSifInParam_PerformOCSP, aArguments);
   820     intValue = GetPositiveIntParam(KSifInParam_PerformOCSP, aArguments);
   866     if (intValue == 0) // Yes
   821     if (intValue == Usif::EAllowed) // Yes
   867     {
   822     {
   868         aCommandLine.Append(KOcsp);
   823         aCommandLine.Append(KOcsp);
   869         aCommandLine.Append(KYes);
   824         aCommandLine.Append(KYes);
   870     }
   825     }
   871     else if (intValue == 1) // No
   826     else if (intValue == Usif::ENotAllowed) // No
   872     {
   827     {
   873         aCommandLine.Append(KOcsp);
   828         aCommandLine.Append(KOcsp);
   874         aCommandLine.Append(KNo);
   829         aCommandLine.Append(KNo);
   875     }
   830     }
   876     // AskUser is not supported
   831     // AskUser is not supported
   877 
   832 
   878     // KSifInParam_IgnoreOCSPWarnings Yes/No/AskUser -> -ignore_ocsp_warnings=yes|no
   833     // KSifInParam_IgnoreOCSPWarnings Yes/No/AskUser -> -ignore_ocsp_warnings=yes|no
   879     intValue = GetPositiveIntParam(KSifInParam_IgnoreOCSPWarnings, aArguments);
   834     intValue = GetPositiveIntParam(KSifInParam_IgnoreOCSPWarnings, aArguments);
   880     if (intValue == 0) // Yes
   835     if (intValue == Usif::EAllowed) // Yes
   881     {
   836     {
   882         aCommandLine.Append(KIgnoreOcspWarnings);
   837         aCommandLine.Append(KIgnoreOcspWarnings);
   883         aCommandLine.Append(KYes);
   838         aCommandLine.Append(KYes);
   884     }
   839     }
   885     else if (intValue == 1) // No
   840     else if (intValue == Usif::ENotAllowed) // No
   886     {
   841     {
   887         aCommandLine.Append(KIgnoreOcspWarnings);
   842         aCommandLine.Append(KIgnoreOcspWarnings);
   888         aCommandLine.Append(KNo);
   843         aCommandLine.Append(KNo);
   889     }
   844     }
   890     // AskUser is not supported
   845     // AskUser is not supported
   891 
   846 
   892     // KSifInParam_AllowUpgrade Yes/No/AskUser -> -upgrade=yes|no
   847     // KSifInParam_AllowUpgrade Yes/No/AskUser -> -upgrade=yes|no
   893     intValue = GetPositiveIntParam(KSifInParam_AllowUpgrade, aArguments);
   848     intValue = GetPositiveIntParam(KSifInParam_AllowUpgrade, aArguments);
   894     if (intValue == 0) // Yes
   849     if (intValue == Usif::EAllowed) // Yes
   895     {
   850     {
   896         aCommandLine.Append(KUpgrade);
   851         aCommandLine.Append(KUpgrade);
   897         aCommandLine.Append(KYes);
   852         aCommandLine.Append(KYes);
   898     }
   853     }
   899     else if (intValue == 1) // No
   854     else if (intValue == Usif::ENotAllowed) // No
   900     {
   855     {
   901         aCommandLine.Append(KUpgrade);
   856         aCommandLine.Append(KUpgrade);
   902         aCommandLine.Append(KNo);
   857         aCommandLine.Append(KNo);
   903     }
   858     }
   904     // AskUser is not supported
   859     // AskUser is not supported
   905 
   860 
   906     // KSifInParam_AllowUpgradeData Yes/No/AskUser -> -upgrade_data=yes|no
   861     // KSifInParam_AllowUpgradeData Yes/No/AskUser -> -upgrade_data=yes|no
   907     intValue = GetPositiveIntParam(KSifInParam_AllowUpgradeData, aArguments);
   862     intValue = GetPositiveIntParam(KSifInParam_AllowUpgradeData, aArguments);
   908     if (intValue == 0) // Yes
   863     if (intValue == Usif::EAllowed) // Yes
   909     {
   864     {
   910         aCommandLine.Append(KUpgradeData);
   865         aCommandLine.Append(KUpgradeData);
   911         aCommandLine.Append(KYes);
   866         aCommandLine.Append(KYes);
   912     }
   867     }
   913     else if (intValue == 1) // No
   868     else if (intValue == Usif::ENotAllowed) // No
   914     {
   869     {
   915         aCommandLine.Append(KUpgradeData);
   870         aCommandLine.Append(KUpgradeData);
   916         aCommandLine.Append(KNo);
   871         aCommandLine.Append(KNo);
   917     }
   872     }
   918     // AskUser is not supported
   873     // AskUser is not supported
   919 
   874 
   920     // KSifInParam_AllowUntrusted Yes/No/AskUser -> -untrusted=yes|no
   875     // KSifInParam_AllowUntrusted Yes/No/AskUser -> -untrusted=yes|no
   921     intValue = GetPositiveIntParam(KSifInParam_AllowUntrusted, aArguments);
   876     intValue = GetPositiveIntParam(KSifInParam_AllowUntrusted, aArguments);
   922     if (intValue == 0) // Yes
   877     if (intValue == Usif::EAllowed) // Yes
   923     {
   878     {
   924         aCommandLine.Append(KUntrusted);
   879         aCommandLine.Append(KUntrusted);
   925         aCommandLine.Append(KYes);
   880         aCommandLine.Append(KYes);
   926     }
   881     }
   927     else if (intValue == 1) // No
   882     else if (intValue == Usif::ENotAllowed) // No
   928     {
   883     {
   929         aCommandLine.Append(KUntrusted);
   884         aCommandLine.Append(KUntrusted);
   930         aCommandLine.Append(KNo);
   885         aCommandLine.Append(KNo);
   931     }
   886     }
   932     // AskUser is not supported
   887     // AskUser is not supported
   933 
   888 
   934     // KSifInParam_AllowOverwrite Yes/No/AskUser -> -overwrite=yes|no
   889     // KSifInParam_AllowOverwrite Yes/No/AskUser -> -overwrite=yes|no
   935     intValue = GetPositiveIntParam(KSifInParam_AllowOverwrite, aArguments);
   890     intValue = GetPositiveIntParam(KSifInParam_AllowOverwrite, aArguments);
   936     if (intValue == 0) // Yes
   891     if (intValue == Usif::EAllowed) // Yes
   937     {
   892     {
   938         aCommandLine.Append(KOverwrite);
   893         aCommandLine.Append(KOverwrite);
   939         aCommandLine.Append(KYes);
   894         aCommandLine.Append(KYes);
   940     }
   895     }
   941     else if (intValue == 1) // No
   896     else if (intValue == Usif::ENotAllowed) // No
   942     {
   897     {
   943         aCommandLine.Append(KOverwrite);
   898         aCommandLine.Append(KOverwrite);
   944         aCommandLine.Append(KNo);
   899         aCommandLine.Append(KNo);
   945     }
   900     }
   946     // AskUser is not supported
   901     // AskUser is not supported
   947 
   902 
   948     // KSifInParam_AllowDownload Yes/No/AskUser -> -download=yes|no
   903     // KSifInParam_AllowDownload Yes/No/AskUser -> -download=yes|no
   949     intValue = GetPositiveIntParam(KSifInParam_AllowDownload, aArguments);
   904     intValue = GetPositiveIntParam(KSifInParam_AllowDownload, aArguments);
   950     if (intValue == 0) // Yes
   905     if (intValue == Usif::EAllowed) // Yes
   951     {
   906     {
   952         aCommandLine.Append(KDownload);
   907         aCommandLine.Append(KDownload);
   953         aCommandLine.Append(KYes);
   908         aCommandLine.Append(KYes);
   954     }
   909     }
   955     else if (intValue == 1) // No
   910     else if (intValue == Usif::ENotAllowed) // No
   956     {
   911     {
   957         aCommandLine.Append(KDownload);
   912         aCommandLine.Append(KDownload);
   958         aCommandLine.Append(KNo);
   913         aCommandLine.Append(KNo);
   959     }
   914     }
   960     // AskUser is not supported
   915     // AskUser is not supported
  1185     }
  1140     }
  1186 
  1141 
  1187     return EFalse;
  1142     return EFalse;
  1188 }
  1143 }
  1189 
  1144 
  1190 /**
       
  1191  * Creates 'preparing installation' dialog.
       
  1192  */
       
  1193 void CJavaSifPlugin::CreatePrepInstDialogL()
       
  1194 {
       
  1195     ILOG(EJavaInstaller, "CJavaSifPlugin::CreatePrepInstDialogL creating dialog");
       
  1196     mPrepInstDialog = CHbDeviceNotificationDialogSymbian::NewL();
       
  1197     _LIT(KPrepInstText, "Preparing installation...");
       
  1198     mPrepInstDialog->SetTitleL(KPrepInstText);
       
  1199     mPrepInstDialog->SetTimeout(20*1000); // ms
       
  1200     mPrepInstDialog->ShowL();
       
  1201     ILOG(EJavaInstaller, "CJavaSifPlugin::CreatePrepInstDialogL dialog created");
       
  1202 }
       
  1203 
       
  1204 void CJavaSifPlugin::HidePrepInstDialogL()
       
  1205 {
       
  1206     ILOG(EJavaInstaller, "CJavaSifPlugin::HidePrepInstDialogL hiding dialog");
       
  1207     // Stop further timed calls
       
  1208     if (mWaitToHideDialog)
       
  1209     {
       
  1210         mWaitToHideDialog->Cancel();
       
  1211     }
       
  1212     // Close wait dialog.
       
  1213     if (mPrepInstDialog)
       
  1214     {
       
  1215         mPrepInstDialog->Close();
       
  1216     }
       
  1217     ILOG(EJavaInstaller, "CJavaSifPlugin::HidePrepInstDialogL dialog hidden");
       
  1218 }
       
  1219 
       
  1220 //  End of File
  1145 //  End of File