javamanager/javainstaller/appinstuiplugin/src/javainstalllauncher.cpp
branchRCL_3
changeset 19 04becd199f91
child 35 85266cc22c7f
child 60 6c158198356e
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  This file contains the implementation of CJavaInstallLauncher
       
    15 *               class member functions. ECOM Plugin for native installer.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <memory>
       
    21 #include <e32cmn.h>
       
    22 #include <e32property.h>
       
    23 #include <charconv.h>
       
    24 #include <data_caging_path_literals.hrh>
       
    25 #include <SWInstDefs.h>
       
    26 
       
    27 #include <CUIUtils.h>
       
    28 #include <eikenv.h>
       
    29 #include <SisxUIData.rsg>
       
    30 
       
    31 #include <javadomainpskeys.h>
       
    32 
       
    33 #include "javauids.h"
       
    34 #include "logger.h"
       
    35 #include "javainstalllauncher.h"
       
    36 #include "javaoslayer.h"
       
    37 #include "javaprocessconstants.h"
       
    38 #include "javasymbianoslayer.h"
       
    39 
       
    40 using namespace SwiUI;
       
    41 using namespace Java::Installer;
       
    42 using namespace java::util;
       
    43 
       
    44 _LIT(KJavaInstUIResourceFileName, "SisxUIData.rsc");
       
    45 _LIT(KJavaInstUIResourceDir, "\\Resource\\");
       
    46 _LIT(KPrivateDataCage, "\\private\\");
       
    47 _LIT(KInboxDataCage, "\\private\\1000484b\\");
       
    48 _LIT(KJavaInstallerDataCage, "\\private\\102033e6\\");
       
    49 _LIT(KJavaInstallerTmp, "\\private\\102033E6\\installer\\tmp\\");
       
    50 _LIT(KAnyExtension, ".*");
       
    51 
       
    52 
       
    53 /**
       
    54  * This function is called to hide the 'Preparing Installation' dialog
       
    55  * from a timer after 7 seconds have elapsed.
       
    56  */
       
    57 LOCAL_C TInt HidePreInstDialog(TAny* aInstallLauncher)
       
    58 {
       
    59     CJavaInstallLauncher *pLauncher = (CJavaInstallLauncher *)aInstallLauncher;
       
    60     if (NULL != pLauncher)
       
    61     {
       
    62         TRAP_IGNORE(pLauncher->HidePreparingInstallationDialogL());
       
    63     }
       
    64     return KErrNone;
       
    65 }
       
    66 
       
    67 
       
    68 // ============================ MEMBER FUNCTIONS ===============================
       
    69 
       
    70 CJavaInstallLauncher* CJavaInstallLauncher::NewL()
       
    71 {
       
    72     CJavaInstallLauncher* self = new(ELeave) CJavaInstallLauncher();
       
    73     CleanupStack::PushL(self);
       
    74     self->ConstructL();
       
    75     CleanupStack::Pop(self);
       
    76     return self;
       
    77 }
       
    78 
       
    79 CJavaInstallLauncher::~CJavaInstallLauncher()
       
    80 {
       
    81     if (iWaitToHideDialog)
       
    82     {
       
    83         iWaitToHideDialog->Cancel();
       
    84         delete iWaitToHideDialog;
       
    85         iWaitToHideDialog = NULL;
       
    86     }
       
    87 
       
    88     if (iCommonDialogs != NULL)
       
    89     {
       
    90         TRAP_IGNORE(HidePreparingInstallationDialogL());
       
    91     }
       
    92 
       
    93     if (iEik && iResourceFileOffset)
       
    94     {
       
    95         iEik->DeleteResourceFile(iResourceFileOffset);
       
    96     }
       
    97     iRFs.Close();
       
    98 
       
    99     TInt nHandles = iHandlesToClose.Count();
       
   100     while (nHandles > 0)
       
   101     {
       
   102         nHandles--;
       
   103         iHandlesToClose[nHandles].Close();
       
   104     }
       
   105     iHandlesToClose.Reset();
       
   106 }
       
   107 
       
   108 void CJavaInstallLauncher::InstallL(RFile& aFile, TInstallReq& aInstallParams,
       
   109                                     TBool /* aIsDRM */, TRequestStatus& aStatus)
       
   110 {
       
   111     // aIsDRM parameter is ignored because DRM protected .jar files are always
       
   112     // passed to Installer
       
   113 //    JavaOsLayer::startUpTrace("CJavaInstallLauncher::InstallL start", -1, -1);
       
   114 
       
   115     // Show preparing installation dialog to user.
       
   116     ShowPreparingInstallationDialogL();
       
   117 
       
   118     RProcess rJavaInstaller;
       
   119     TFileName fileName;
       
   120     // Max two path names and some options -> 1536 is enough
       
   121     TBuf<1536> commandLine;
       
   122 
       
   123     // Build command line used to pass all necessary info to Java Installer
       
   124     std::auto_ptr<HBufC> installerStarterDll(
       
   125         stringToDes(java::runtime::JAVA_INSTALLER_STARTER_DLL));
       
   126     commandLine = installerStarterDll->Des();
       
   127     commandLine.Append(_L(" install"));
       
   128 
       
   129     TInt err = aFile.FullName(fileName);
       
   130 
       
   131     // Java Installer does not have AllFiles capability.
       
   132     // So if the .jad/.jar file is in the private data cage of
       
   133     // Remove Application Management system, it must be copied
       
   134     // to the private data cage of Java Installer in this
       
   135     // plugin which is executed in native installer which has
       
   136     // AllFiles capability.
       
   137     CopyFilesIfNeededL(fileName, aFile);
       
   138 
       
   139     if (aInstallParams.iMIME == _L8("text/vnd.sun.j2me.app-descriptor"))
       
   140     {
       
   141         // installation should be started from JAD file
       
   142         commandLine.Append(_L(" -jad="));
       
   143     }
       
   144     else
       
   145     {
       
   146         // from JAR file
       
   147         commandLine.Append(_L(" -jar="));
       
   148     }
       
   149     // Filename parameter must be surrounded in double quotes to
       
   150     // ensure that spaces in filename are passed correctly.
       
   151     commandLine.Append(_L("\""));
       
   152     commandLine.Append(fileName);
       
   153     commandLine.Append(_L("\""));
       
   154 
       
   155     // Find source url. If iSourceURL length is KSWInstHeapPointerLength,
       
   156     // iSourceURL contains pointer to URL allocated from heap.
       
   157     HBufC* sourceURL= NULL;
       
   158     if (aInstallParams.iSourceURL.Length() == KSWInstHeapPointerLength)
       
   159     {
       
   160         TInstallReqURLPckg urlPckg;
       
   161         urlPckg.Copy(aInstallParams.iSourceURL);
       
   162         TInstallReqHeapURL heapURL = urlPckg();
       
   163         sourceURL = heapURL.iSourcePtr->AllocL();
       
   164     }
       
   165     else
       
   166     {
       
   167         sourceURL = aInstallParams.iSourceURL.AllocL();
       
   168     }
       
   169     // pass also source url
       
   170     commandLine.Append(_L(" -sourceurl="));
       
   171     commandLine.Append(*sourceURL);
       
   172     delete sourceURL;
       
   173 
       
   174     commandLine.Append(_L(" -iap="));
       
   175     commandLine.AppendNum(aInstallParams.iIAP);
       
   176 
       
   177     // Charset is identified by S60 platform Uid,
       
   178     // get the Internet-standard name of the charset and
       
   179     // pass that to Java Installer
       
   180     if (aInstallParams.iCharsetId != 0)
       
   181     {
       
   182         CCnvCharacterSetConverter *pConverter =
       
   183             CCnvCharacterSetConverter::NewL();
       
   184         CleanupStack::PushL(pConverter);
       
   185         HBufC8* pName =
       
   186             pConverter->ConvertCharacterSetIdentifierToStandardNameL(
       
   187                 aInstallParams.iCharsetId, iRFs);
       
   188         CleanupStack::PushL(pName);
       
   189         // must convert the 8-bit name to 16-bit
       
   190         HBufC16* pLName = Convert(*pName);
       
   191         if (pLName)
       
   192         {
       
   193             commandLine.Append(_L(" -charset="));
       
   194             commandLine.Append(*pLName);
       
   195         }
       
   196         delete pLName;
       
   197         CleanupStack::PopAndDestroy(pName);
       
   198         CleanupStack::PopAndDestroy(pConverter);
       
   199     }
       
   200 
       
   201     // start JavaInstaller
       
   202     std::auto_ptr<HBufC> installerProcess(
       
   203         stringToDes(java::runtime::JAVA_PROCESS));
       
   204     err = rJavaInstaller.Create(installerProcess->Des(), commandLine);
       
   205     if (KErrNone == err)
       
   206     {
       
   207         // the exit status of Java Installer will be passed to
       
   208         // the asynch caller through aStatus
       
   209         rJavaInstaller.Logon(aStatus);
       
   210     }
       
   211     else
       
   212     {
       
   213         ELOG1(EJavaInstaller,
       
   214               "CJavaInstallLauncher::InstallL: starting JavaInstaller failed, err=%d", err);
       
   215         User::Leave(err);
       
   216     }
       
   217 
       
   218     iWaitToHideDialog = CAsyncWaitCallBack::NewL(TCallBack(HidePreInstDialog, this));
       
   219     // The active object will wait until Java Installer process calls Rendezvous.
       
   220     // If Java Installer specifies reason code EJavaInstaller, then
       
   221     // the active object will call call back function that will hide the
       
   222     // 'Preparing installation' dialog. If reason code is not EJavaInstaller,
       
   223     // the wait object will automatically wait for the next rendezvous.
       
   224     //iWaitToHideDialog->Wait( rJavaInstaller, EJavaInstaller );
       
   225     iWaitToHideDialog->Wait(rJavaInstaller, 0);
       
   226 
       
   227     rJavaInstaller.Resume();
       
   228 
       
   229     // Do NOT close rJavaInstaller now -> the caller gets notification when the
       
   230     // process actually closes.
       
   231     iHandlesToClose.Append(rJavaInstaller);
       
   232 }
       
   233 
       
   234 void CJavaInstallLauncher::SilentInstallL(RFile& aFile,
       
   235         TInstallReq& aInstallParams, TBool /*aIsDRM*/, TInstallOptions& aOptions,
       
   236         TRequestStatus& aStatus)
       
   237 {
       
   238 //    JavaOsLayer::startUpTrace("CJavaInstallLauncher::SilentInstallL start", -1, -1);
       
   239     // aIsDRM parameter is ignored because DRM protected .jar files are always
       
   240     // passed to Installer
       
   241 
       
   242     RProcess rJavaInstaller;
       
   243     TFileName fileName;
       
   244     // Max two path name, user name and password and some options ->
       
   245     // 1536 is still enough
       
   246     TBuf<1536> commandLine;
       
   247 
       
   248     // Build command line used to pass all necessary info to Java Installer
       
   249     std::auto_ptr<HBufC> installerStarterDll(
       
   250         stringToDes(java::runtime::JAVA_INSTALLER_STARTER_DLL));
       
   251     commandLine = installerStarterDll->Des();
       
   252     commandLine.Append(_L(" install -silent"));
       
   253 
       
   254     TInt err = aFile.FullName(fileName);
       
   255 
       
   256     // Java Installer does not have AllFiles capability.
       
   257     // So if the .jad/.jar file is in the private data cage of
       
   258     // Remove Application Management system, it must be copied
       
   259     // to the private data cage of Java Installer in this
       
   260     // plugin which is executed in native installer which has
       
   261     // AllFiles capability.
       
   262     CopyFilesIfNeededL(fileName, aFile);
       
   263 
       
   264     if (aInstallParams.iMIME == _L8("text/vnd.sun.j2me.app-descriptor"))
       
   265     {
       
   266         // installation should be started from JAD file
       
   267         commandLine.Append(_L(" -jad="));
       
   268     }
       
   269     else
       
   270     {
       
   271         // from JAR file
       
   272         commandLine.Append(_L(" -jar="));
       
   273     }
       
   274     // Filename parameter must be surrounded in double quotes to
       
   275     // ensure that spaces in filename are passed correctly.
       
   276     commandLine.Append(_L("\""));
       
   277     commandLine.Append(fileName);
       
   278     commandLine.Append(_L("\""));
       
   279 
       
   280     commandLine.Append(_L(" -iap="));
       
   281     commandLine.AppendNum(aInstallParams.iIAP);
       
   282 
       
   283     // pass also source url
       
   284     commandLine.Append(_L(" -sourceurl="));
       
   285     commandLine.Append(aInstallParams.iSourceURL);
       
   286 
       
   287     // Charset is identified by S60 platform Uid,
       
   288     // get the Internet-standard name of the charset and
       
   289     // pass that to Java Installer
       
   290     if (aInstallParams.iCharsetId != 0)
       
   291     {
       
   292         CCnvCharacterSetConverter *pConverter =
       
   293             CCnvCharacterSetConverter::NewL();
       
   294         CleanupStack::PushL(pConverter);
       
   295         HBufC8* pName =
       
   296             pConverter->ConvertCharacterSetIdentifierToStandardNameL(
       
   297                 aInstallParams.iCharsetId, iRFs);
       
   298         CleanupStack::PushL(pName);
       
   299         // must convert the 8-bit name to 16-bit
       
   300         HBufC16* pLName = Convert(*pName);
       
   301         if (pLName)
       
   302         {
       
   303             commandLine.Append(_L(" -charset="));
       
   304             commandLine.Append(*pLName);
       
   305         }
       
   306         delete pLName;
       
   307         CleanupStack::PopAndDestroy(pName);
       
   308         CleanupStack::PopAndDestroy(pConverter);
       
   309     }
       
   310 
       
   311     // pass also information in aOptions
       
   312     if (EPolicyAllowed == aOptions.iUpgrade)
       
   313     {
       
   314         commandLine.Append(_L(" -upgrade=yes"));
       
   315     }
       
   316     else
       
   317     {
       
   318         commandLine.Append(_L(" -upgrade=no"));
       
   319     }
       
   320 
       
   321     if (EPolicyAllowed == aOptions.iOCSP)
       
   322     {
       
   323         commandLine.Append(_L(" -ocsp=yes"));
       
   324     }
       
   325     else
       
   326     {
       
   327         commandLine.Append(_L(" -ocsp=no"));
       
   328     }
       
   329 
       
   330     if (EPolicyAllowed == aOptions.iIgnoreOCSPWarnings)
       
   331     {
       
   332         commandLine.Append(_L(" -ignore_ocsp_warnings=yes"));
       
   333     }
       
   334     else
       
   335     {
       
   336         commandLine.Append(_L(" -ignore_ocsp_warnings=no"));
       
   337     }
       
   338 
       
   339     if (EPolicyAllowed == aOptions.iUntrusted)
       
   340     {
       
   341         commandLine.Append(_L(" -untrusted=yes"));
       
   342     }
       
   343     else
       
   344     {
       
   345         commandLine.Append(_L(" -untrusted=no"));
       
   346     }
       
   347 
       
   348     if (EPolicyAllowed == aOptions.iOverwrite)
       
   349     {
       
   350         commandLine.Append(_L(" -overwrite=yes"));
       
   351     }
       
   352     else
       
   353     {
       
   354         commandLine.Append(_L(" -overwrite=no"));
       
   355     }
       
   356 
       
   357     if (EPolicyAllowed == aOptions.iDownload)
       
   358     {
       
   359         commandLine.Append(_L(" -download=yes"));
       
   360     }
       
   361     else
       
   362     {
       
   363         commandLine.Append(_L(" -download=no"));
       
   364     }
       
   365 
       
   366     if (aOptions.iLogin.Length() > 0)
       
   367     {
       
   368         commandLine.Append(_L(" -username="));
       
   369         commandLine.Append(aOptions.iLogin);
       
   370     }
       
   371 
       
   372     if (aOptions.iPassword.Length() > 0)
       
   373     {
       
   374         commandLine.Append(_L(" -password="));
       
   375         commandLine.Append(aOptions.iPassword);
       
   376     }
       
   377 
       
   378     if (aOptions.iDrive > 'C')
       
   379     {
       
   380         commandLine.Append(_L(" -drive="));
       
   381         commandLine.Append(aOptions.iDrive);
       
   382     }
       
   383 
       
   384     if (EPolicyAllowed == aOptions.iUpgradeData)
       
   385     {
       
   386         commandLine.Append(_L(" -upgrade_data=yes"));
       
   387     }
       
   388     else
       
   389     {
       
   390         commandLine.Append(_L(" -upgrade_data=no"));
       
   391     }
       
   392 
       
   393     // start JavaInstaller
       
   394     std::auto_ptr<HBufC> installerProcess(
       
   395         stringToDes(java::runtime::JAVA_PROCESS));
       
   396     err = rJavaInstaller.Create(installerProcess->Des(), commandLine);
       
   397     if (KErrNone == err)
       
   398     {
       
   399         // the exit status of Java Installer will be passed to
       
   400         // the asynch caller through aStatus
       
   401         rJavaInstaller.Logon(aStatus);
       
   402 
       
   403         rJavaInstaller.Resume();
       
   404     }
       
   405     else
       
   406     {
       
   407         ELOG1(EJavaInstaller,
       
   408               "CJavaInstallLauncher::SilentInstallL: starting JavaInstaller failed, err=%d", err);
       
   409     }
       
   410 
       
   411     // Do NOT close rJavaInstaller now -> the caller gets notification when the
       
   412     // process actually closes.
       
   413     iHandlesToClose.Append(rJavaInstaller);
       
   414 }
       
   415 
       
   416 void CJavaInstallLauncher::UninstallL(const TUid& aUid, const TDesC8&, /*aMIME*/
       
   417                                       TRequestStatus& aStatus)
       
   418 {
       
   419 //    JavaOsLayer::startUpTrace("CJavaInstallLauncher::UninstallL start", -1, -1);
       
   420     RProcess rJavaInstaller;
       
   421     TFileName fileName;
       
   422     // Max one uid and some options -> 256 is enough
       
   423     TBuf<256> commandLine;
       
   424 
       
   425     // Build command line used to pass all necessary info to Java Installer
       
   426     std::auto_ptr<HBufC> installerStarterDll(
       
   427         stringToDes(java::runtime::JAVA_INSTALLER_STARTER_DLL));
       
   428     commandLine = installerStarterDll->Des();
       
   429     commandLine.Append(_L(" uninstall"));
       
   430 
       
   431     commandLine.Append(_L(" -uid="));
       
   432     commandLine.Append(aUid.Name());
       
   433 
       
   434     // start JavaInstaller
       
   435     std::auto_ptr<HBufC> installerProcess(
       
   436         stringToDes(java::runtime::JAVA_PROCESS));
       
   437     TInt err = rJavaInstaller.Create(installerProcess->Des(), commandLine);
       
   438     if (KErrNone == err)
       
   439     {
       
   440         // the exit status of Java Installer will be passed to
       
   441         // the asynch caller through aStatus
       
   442         rJavaInstaller.Logon(aStatus);
       
   443 
       
   444         rJavaInstaller.Resume();
       
   445     }
       
   446     else
       
   447     {
       
   448         ELOG1(EJavaInstaller,
       
   449               "CJavaInstallLauncher::UninstallL: starting JavaInstaller failed, err=%d", err);
       
   450     }
       
   451 
       
   452     // Do NOT close rJavaInstaller now -> the caller gets notification when the
       
   453     // process actually closes.
       
   454     iHandlesToClose.Append(rJavaInstaller);
       
   455 }
       
   456 
       
   457 void CJavaInstallLauncher::SilentUninstallL(const TUid& aUid, const TDesC8&, /*aMIME*/
       
   458         TUninstallOptions& /*aOptions*/, TRequestStatus& aStatus)
       
   459 {
       
   460 //    JavaOsLayer::startUpTrace("CJavaInstallLauncher::SilentUninstallL start", -1, -1);
       
   461     RProcess rJavaInstaller;
       
   462     TFileName fileName;
       
   463     // Max one uid and some options -> 256 is enough
       
   464     TBuf<256> commandLine;
       
   465 
       
   466 
       
   467 #ifdef RD_JAVA_S60_RELEASE_5_0_IAD
       
   468     // When upgrading Java 2.0 to S60 5.0 devices that already have an older
       
   469     // version of Java we have to do one special operation.
       
   470 
       
   471     // In old Java environment the PS key that is used to tell how the
       
   472     // installation of MIDlet suite proceeds was owned by the native
       
   473     // installer (appinstui) process, not by Java Installer.
       
   474     // In Java 2.0 environment Java Installer has to own it.
       
   475 
       
   476     // We have to destroy the old PS key from this plugin that is loaded and
       
   477     // executed by the native installer because the PS key was created so that
       
   478     // only the native installer can update and destroy it.
       
   479     if (aUid.iUid == KRandomIllegalAppUid)
       
   480     {
       
   481         // The Uid tells that this is actually request (from javapostupdater.exe)
       
   482         // to destroy the PS key.
       
   483         LOG(EJavaInstaller, EInfo,
       
   484             "CJavaInstallLauncher: SilentUninstallL was called with KRandomIllegalAppUid.");
       
   485 
       
   486         TInt err = RProperty::Delete(KUidSystemCategory, KPSUidJavaLatestInstallation);
       
   487         if ((err == KErrNone) || (err == KErrNotFound))
       
   488         {
       
   489             LOG(EJavaInstaller, EInfo,
       
   490                 "CJavaInstallLauncher: deleted PS key KPSUidJavaLatestInstallation");
       
   491             // The caller expects that we leave with cancel status if delete succeeded
       
   492             User::Leave(KErrCancel);
       
   493         }
       
   494         else if (err == KErrPermissionDenied)
       
   495         {
       
   496             WLOG(EJavaInstaller,
       
   497                  "CJavaInstallLauncher: SilentUninstallL: Not owner, so cannot "
       
   498                  "delete PS key KPSUidJavaLatestInstallation");
       
   499             // It makes no sense to try this again so leave with cancel status
       
   500             User::Leave(KErrCancel);
       
   501         }
       
   502         else
       
   503         {
       
   504             ELOG1(EJavaInstaller,
       
   505                   "CJavaInstallLauncher: SilentUninstallL: Deleting PS key "
       
   506                   "KPSUidJavaLatestInstallation error %d", err);
       
   507             // Leave with current error code, caller can try deleting PS key again
       
   508             User::Leave(err);
       
   509         }
       
   510     }
       
   511 #endif
       
   512 
       
   513     // Build command line used to pass all necessary info to Java Installer
       
   514     std::auto_ptr<HBufC> installerStarterDll(
       
   515         stringToDes(java::runtime::JAVA_INSTALLER_STARTER_DLL));
       
   516     commandLine = installerStarterDll->Des();
       
   517     commandLine.Append(_L(" uninstall -silent"));
       
   518 
       
   519     commandLine.Append(_L(" -uid="));
       
   520     commandLine.Append(aUid.Name());
       
   521 
       
   522     // start JavaInstaller
       
   523     std::auto_ptr<HBufC> installerProcess(
       
   524         stringToDes(java::runtime::JAVA_PROCESS));
       
   525     TInt err = rJavaInstaller.Create(installerProcess->Des(), commandLine);
       
   526     if (KErrNone == err)
       
   527     {
       
   528         // the exit status of Java Installer will be passed to
       
   529         // the asynch caller through aStatus
       
   530         rJavaInstaller.Logon(aStatus);
       
   531 
       
   532         rJavaInstaller.Resume();
       
   533     }
       
   534     else
       
   535     {
       
   536         ELOG1(EJavaInstaller,
       
   537               "CJavaInstallLauncher::SilentUninstallL: starting JavaInstaller failed, err=%d", err);
       
   538     }
       
   539 
       
   540     // Do NOT close rJavaInstaller now -> the caller gets notification when the
       
   541     // process actually closes.
       
   542     iHandlesToClose.Append(rJavaInstaller);
       
   543 }
       
   544 
       
   545 TBool CJavaInstallLauncher::IsAppShellUpdate()
       
   546 {
       
   547     // All successfull install/uninstall operations cause need to
       
   548     // update AppShell.
       
   549     // This method has been marked obsolete in SWInstUIPluginAPI.h
       
   550     return ETrue;
       
   551 }
       
   552 
       
   553 void CJavaInstallLauncher::Cancel()
       
   554 {
       
   555     // Cancel is not supported.
       
   556     // Do nothing.
       
   557     return;
       
   558 }
       
   559 
       
   560 void CJavaInstallLauncher::CompleteL()
       
   561 {
       
   562     // Do nothing. JavaInstaller process has already exited.
       
   563 }
       
   564 
       
   565 CErrDetails* CJavaInstallLauncher::GetErrorDetails()
       
   566 {
       
   567     // Java Installer will log the possible errors
       
   568     // also in release builds. It will also show detailed error
       
   569     // messages in UI in dialog if not in -silent mode
       
   570     return NULL;
       
   571 }
       
   572 
       
   573 void CJavaInstallLauncher::CustomUninstallL(TOperation, /*aOperation*/
       
   574         const TDesC8&, /*aParams*/
       
   575         TRequestStatus& /*aStatus*/)
       
   576 {
       
   577     WLOG(EJavaInstaller, "CJavaInstallLauncher: Not supported CustomUninstallL was called.");
       
   578     User::Leave(KErrNotSupported);
       
   579 }
       
   580 
       
   581 void CJavaInstallLauncher::SilentCustomUninstallL(TOperation, /*aOperation*/
       
   582         TUninstallOptions&, /*aOptions*/
       
   583         const TDesC8&, /*aParams*/
       
   584         TRequestStatus& /*aStatus*/)
       
   585 {
       
   586     WLOG(EJavaInstaller, "CJavaInstallLauncher: Not supported SilentCustomUninstallL was called.");
       
   587     User::Leave(KErrNotSupported);
       
   588 }
       
   589 
       
   590 CJavaInstallLauncher::CJavaInstallLauncher()
       
   591 {
       
   592 }
       
   593 
       
   594 void CJavaInstallLauncher::ConstructL()
       
   595 {
       
   596     User::LeaveIfError(iRFs.Connect());
       
   597     iWaitToHideDialog = NULL;
       
   598 }
       
   599 
       
   600 HBufC16* CJavaInstallLauncher::Convert(const TDesC8& aSrc)
       
   601 {
       
   602     if (aSrc.Length() < 1)
       
   603     {
       
   604         return NULL;
       
   605     }
       
   606 
       
   607     HBufC16* buf = HBufC16::New(aSrc.Length() + 1);
       
   608     if (buf)
       
   609     {
       
   610         TPtr16 ptr = buf->Des();
       
   611         ptr.Copy(aSrc);
       
   612         ptr.ZeroTerminate();
       
   613     }
       
   614     return buf;
       
   615 }
       
   616 
       
   617 void CJavaInstallLauncher::OpenUiResourcesL()
       
   618 {
       
   619     // Open UI env and resource file.
       
   620     if (!iEik)
       
   621     {
       
   622         iEik = CEikonEnv::Static();
       
   623     }
       
   624     if (!iEik)
       
   625     {
       
   626         ELOG(EJavaInstaller, "CJavaInstallLauncher: CEikonEnv::Static() call returned NULL.");
       
   627         User::Leave(KErrGeneral);
       
   628     }
       
   629     if (!iResourceFileOffset)
       
   630     {
       
   631         TFileName resourceFileName;
       
   632         resourceFileName.Append(KJavaInstUIResourceDir);
       
   633         resourceFileName.Append(KJavaInstUIResourceFileName);
       
   634         iResourceFileOffset = CommonUI::CUIUtils::LoadResourceFileL(resourceFileName, iEik);
       
   635     }
       
   636 }
       
   637 
       
   638 void CJavaInstallLauncher::ShowPreparingInstallationDialogL()
       
   639 {
       
   640     // Open UI resources before showing the dialog.
       
   641     OpenUiResourcesL();
       
   642     // Open wait dialog.
       
   643     iCommonDialogs = CommonUI::CCUIDialogs::NewL();
       
   644     iCommonDialogs->ShowWaitDialogL(R_SISXUI_PREPARING, this, R_AVKON_SOFTKEYS_EMPTY);
       
   645 }
       
   646 
       
   647 void CJavaInstallLauncher::HidePreparingInstallationDialogL()
       
   648 {
       
   649     // Stop further timed calls
       
   650     if (iWaitToHideDialog)
       
   651     {
       
   652         iWaitToHideDialog->Cancel();
       
   653     }
       
   654 
       
   655     // Close wait dialog.
       
   656     if (iCommonDialogs)
       
   657     {
       
   658         iCommonDialogs->CloseWaitDialogL();
       
   659         delete iCommonDialogs;
       
   660         iCommonDialogs = NULL;
       
   661     }
       
   662 }
       
   663 
       
   664 TBool CJavaInstallLauncher::HandleDialogExitL(TInt /*aButtonId*/)
       
   665 {
       
   666     // There is no way to cancel wait dialog, so this method
       
   667     // will never be called.
       
   668     return ETrue;
       
   669 }
       
   670 
       
   671 void CJavaInstallLauncher::CopyFilesIfNeededL(
       
   672     TFileName &aFileName,
       
   673     RFile& aFile)
       
   674 {
       
   675     // If the file in the private data cage of some process?
       
   676     TInt idx = aFileName.FindF(KPrivateDataCage);
       
   677     if ((idx != KErrNotFound) && (idx < 3))
       
   678     {
       
   679         // In case of device Inbox or Java Installer itself do nothing
       
   680         if ((aFileName.FindF(KInboxDataCage) != KErrNotFound)
       
   681                 || (aFileName.FindF(KJavaInstallerDataCage) != KErrNotFound))
       
   682         {
       
   683             return;
       
   684         }
       
   685 
       
   686         // The file handle must be shared or copy operation fails
       
   687         TInt tmpErr = aFile.ChangeMode(EFileShareReadersOnly);
       
   688         if (KErrNone != tmpErr)
       
   689         {
       
   690             ELOG1(EJavaInstaller,
       
   691                   "CJavaInstallLauncher::CopyFilesIfNeededL: "
       
   692                   "Err (%d) when changing the mode of the file handle to shared.", tmpErr);
       
   693         }
       
   694 
       
   695 
       
   696         // Copy ALL files with the same base filename as aFileName
       
   697         // to Java Installer tmp dir so that both .jad file and
       
   698         // the corresponding .jar file are copied.
       
   699         // (aFileName is <path>\<name>.<ext>, copy <path>\<name>.*
       
   700         // to Java Installer tmp dir.)
       
   701         TParse fp;
       
   702         iRFs.Parse(aFileName, fp);
       
   703 
       
   704         CFileMan* fm = CFileMan::NewL(iRFs);
       
   705         TFileName filesToCopy = fp.DriveAndPath();
       
   706         filesToCopy.Append(fp.Name());
       
   707         filesToCopy.Append(KAnyExtension);
       
   708 
       
   709         TInt err = fm->Copy(
       
   710                        filesToCopy, KJavaInstallerTmp, CFileMan::ERecurse | CFileMan::EOverWrite);
       
   711         delete fm;
       
   712         if (KErrNone != err)
       
   713         {
       
   714             ELOG1(EJavaInstaller,
       
   715                   "CJavaInstallLauncher::CopyFilesIfNeededL: err (%d), copying files "
       
   716                   "to Java Installer data cage failed", err);
       
   717             User::Leave(err);
       
   718         }
       
   719 
       
   720         // aFileName must point to the copy of the file
       
   721         aFileName = fp.Drive();
       
   722         aFileName.Append(KJavaInstallerTmp);
       
   723         aFileName.Append(fp.NameAndExt());
       
   724     }
       
   725 
       
   726     return;
       
   727 }
       
   728 
       
   729 //  End of File