javamanager/javainstaller/javasifplugin/src/javasifplugin.cpp
changeset 47 f40128debb5d
parent 35 85266cc22c7f
child 48 e0d6e9bd3ca7
equal deleted inserted replaced
35:85266cc22c7f 47:f40128debb5d
     1 /*
     1 /*
     2 * Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    22 #include <apmstd.h>
    22 #include <apmstd.h>
    23 #include <e32cmn.h>
    23 #include <e32cmn.h>
    24 #include <e32property.h>
    24 #include <e32property.h>
    25 #include <charconv.h>
    25 #include <charconv.h>
    26 #include <data_caging_path_literals.hrh>
    26 #include <data_caging_path_literals.hrh>
    27 #include <usiferror.h>
    27 #include <usif/usiferror.h>
    28 
    28 
    29 #include "comms.h"
    29 #include "comms.h"
    30 #include "commsmessage.h"
    30 #include "commsmessage.h"
    31 #include "commsclientendpoint.h"
    31 #include "commsclientendpoint.h"
    32 #include "javasifplugin.h"
    32 #include "javasifplugin.h"
   316         }
   316         }
   317 
   317 
   318         commandLine.Append(_L(" -silent"));
   318         commandLine.Append(_L(" -silent"));
   319     }
   319     }
   320 
   320 
   321     TBool paramFound = EFalse;
   321     BuildInstallCommandLine(commandLine, aArguments);
   322     TInt  intValue = 0;
       
   323     TDesC desValue = KNullDesC;
       
   324 
       
   325     // KSifInParam_Drive -> -drive=install_target_drive (A, B, C, ..., Z)
       
   326     TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_Drive, intValue));
       
   327     if (paramFound)
       
   328     {
       
   329         // Value 0 is 'A:' drive and  value 25 is 'Z:' drive
       
   330         if ((intValue > -1) && (intValue < 26))
       
   331         {
       
   332             commandLine.Append(_L(" -drive="));
       
   333             TChar drive('A');
       
   334             drive += intValue;
       
   335             commandLine.Append(drive);
       
   336         }
       
   337         else
       
   338         {
       
   339             WLOG1(EJavaInstaller,
       
   340                 "CJavaSifPlugin::Install Ignoring illegal KSifInParam_Drive param (value %d)",
       
   341                 intValue);
       
   342         }
       
   343     }
       
   344 
       
   345     // KSifInParam_PerformOCSP Yes/No/AskUser -> -ocsp=yes|no
       
   346     TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_PerformOCSP, intValue));
       
   347     if (paramFound)
       
   348     {
       
   349         if (intValue == 0) // Yes
       
   350         {
       
   351             commandLine.Append(_L(" -ocsp=yes"));
       
   352         }
       
   353         else if (intValue == 1) // No
       
   354         {
       
   355             commandLine.Append(_L(" -ocsp=no"));
       
   356         }
       
   357         // AskUser is not supported
       
   358     }
       
   359 
       
   360     // KSifInParam_IgnoreOCSPWarnings Yes/No/AskUser -> -ignore_ocsp_warnings=yes|no
       
   361     TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_IgnoreOCSPWarnings, intValue));
       
   362     if (paramFound)
       
   363     {
       
   364         if (intValue == 0) // Yes
       
   365         {
       
   366             commandLine.Append(_L(" -ignore_ocsp_warnings=yes"));
       
   367         }
       
   368         else if (intValue == 1) // No
       
   369         {
       
   370             commandLine.Append(_L(" -ignore_ocsp_warnings=no"));
       
   371         }
       
   372         // AskUser is not supported
       
   373     }
       
   374 
       
   375     // KSifInParam_AllowUpgrade Yes/No/AskUser -> -upgrade=yes|no
       
   376     TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_AllowUpgrade, intValue));
       
   377     if (paramFound)
       
   378     {
       
   379         if (intValue == 0) // Yes
       
   380         {
       
   381             commandLine.Append(_L(" -upgrade=yes"));
       
   382         }
       
   383         else if (intValue == 1) // No
       
   384         {
       
   385             commandLine.Append(_L(" -upgrade=no"));
       
   386         }
       
   387         // AskUser is not supported
       
   388     }
       
   389 
       
   390 
       
   391     // TODO: activate this code block when KSifInParam_UpgradeData has been
       
   392     // defined in sifcommon.h
       
   393 /*
       
   394     // KSifInParam_UpgradeData Yes/No/AskUser -> -upgrade_data=yes|no
       
   395     TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_UpgradeData, intValue));
       
   396     if (paramFound)
       
   397     {
       
   398         if (intValue == 0) // Yes
       
   399         {
       
   400             commandLine.Append(_L(" -upgrade_data=yes"));
       
   401         }
       
   402         else if (intValue == 1) // No
       
   403         {
       
   404             commandLine.Append(_L(" -upgrade_data=no"));
       
   405         }
       
   406         // AskUser is not supported
       
   407     }
       
   408 */
       
   409 
       
   410     // KSifInParam_AllowUntrusted Yes/No/AskUser -> -untrusted=yes|no
       
   411     TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_AllowUntrusted, intValue));
       
   412     if (paramFound)
       
   413     {
       
   414         if (intValue == 0) // Yes
       
   415         {
       
   416             commandLine.Append(_L(" -untrusted=yes"));
       
   417         }
       
   418         else if (intValue == 1) // No
       
   419         {
       
   420             commandLine.Append(_L(" -untrusted=no"));
       
   421         }
       
   422         // AskUser is not supported
       
   423     }
       
   424 
       
   425     // KSifInParam_AllowOverwrite Yes/No/AskUser -> -overwrite=yes|no
       
   426     TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_AllowOverwrite, intValue));
       
   427     if (paramFound)
       
   428     {
       
   429         if (intValue == 0) // Yes
       
   430         {
       
   431             commandLine.Append(_L(" -overwrite=yes"));
       
   432         }
       
   433         else if (intValue == 1) // No
       
   434         {
       
   435             commandLine.Append(_L(" -overwrite=no"));
       
   436         }
       
   437         // AskUser is not supported
       
   438     }
       
   439 
       
   440     // KSifInParam_AllowDownload Yes/No/AskUser -> -download=yes|no
       
   441     TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_AllowDownload, intValue));
       
   442     if (paramFound)
       
   443     {
       
   444         if (intValue == 0) // Yes
       
   445         {
       
   446             commandLine.Append(_L(" -download=yes"));
       
   447         }
       
   448         else if (intValue == 1) // No
       
   449         {
       
   450             commandLine.Append(_L(" -download=no"));
       
   451         }
       
   452         // AskUser is not supported
       
   453     }
       
   454 
       
   455     // KSifInParam_UserName -> -username=download_username
       
   456     TRAP_IGNORE(desValue = aArguments.StringByNameL(KSifInParam_UserName));
       
   457     if (desValue.Length() > 0)
       
   458     {
       
   459         commandLine.Append(_L(" -username="));
       
   460         commandLine.Append(desValue);
       
   461     }
       
   462 
       
   463     // KSifInParam_Password -> -password=download_password
       
   464     TRAP_IGNORE(desValue = aArguments.StringByNameL(KSifInParam_Password));
       
   465     if (desValue.Length() > 0)
       
   466     {
       
   467         commandLine.Append(_L(" -password="));
       
   468         commandLine.Append(desValue);
       
   469     }
       
   470 
       
   471     // KSifInParam_SourceUrl -> -sourceurl=original (HTTP) URL of the JAD or JAR file
       
   472     TRAP_IGNORE(desValue = aArguments.StringByNameL(KSifInParam_SourceUrl));
       
   473     if (desValue.Length() > 0)
       
   474     {
       
   475         commandLine.Append(_L(" -sourceurl="));
       
   476         commandLine.Append(desValue);
       
   477     }
       
   478 
       
   479     // KSifInParam_IAP -> -iap=IAP_ID (internet access point id)
       
   480     TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_IAP, intValue));
       
   481     if (paramFound)
       
   482     {
       
   483         commandLine.Append(_L(" -iap="));
       
   484         commandLine.AppendNum(intValue);
       
   485     }
       
   486 
       
   487     // KSifInParam_Charset -> -charset=Internet-standard character set name
       
   488     TRAP_IGNORE(desValue = aArguments.StringByNameL(KSifInParam_Charset));
       
   489     if (desValue.Length() > 0)
       
   490     {
       
   491         commandLine.Append(_L(" -charset="));
       
   492         commandLine.Append(desValue);
       
   493     }
       
   494 
       
   495 
   322 
   496     // Ask Java Installer to send installation results back
   323     // Ask Java Installer to send installation results back
   497     // as Comms message. 11000 is IPC_ADDRESS_JAVA_SIF_PLUGIN_C Comms endpoint
   324     // as Comms message. 11000 is IPC_ADDRESS_JAVA_SIF_PLUGIN_C Comms endpoint
   498     // that our ResultsServer will listen to.
   325     // that our ResultsServer will listen to.
   499     commandLine.Append(_L(" -commsresult=11000"));
   326     commandLine.Append(_L(" -commsresult=11000"));
   834     }
   661     }
   835 
   662 
   836     return;
   663     return;
   837 }
   664 }
   838 
   665 
       
   666 
       
   667 void CJavaSifPlugin::BuildInstallCommandLine(
       
   668         TBuf<1536>& aCommandLine,
       
   669         const COpaqueNamedParams& aArguments)
       
   670 {
       
   671     TBool paramFound = EFalse;
       
   672     TInt  intValue = 0;
       
   673     TDesC desValue = KNullDesC;
       
   674 
       
   675     // KSifInParam_Drive -> -drive=install_target_drive (A, B, C, ..., Z)
       
   676     TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_Drive, intValue));
       
   677     if (paramFound)
       
   678     {
       
   679         // Value 0 is 'A:' drive and  value 25 is 'Z:' drive
       
   680         if ((intValue > -1) && (intValue < 26))
       
   681         {
       
   682             aCommandLine.Append(_L(" -drive="));
       
   683             TChar drive('A');
       
   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     }
       
   694 
       
   695     // KSifInParam_PerformOCSP Yes/No/AskUser -> -ocsp=yes|no
       
   696     TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_PerformOCSP, intValue));
       
   697     if (paramFound)
       
   698     {
       
   699         if (intValue == 0) // Yes
       
   700         {
       
   701             aCommandLine.Append(_L(" -ocsp=yes"));
       
   702         }
       
   703         else if (intValue == 1) // No
       
   704         {
       
   705             aCommandLine.Append(_L(" -ocsp=no"));
       
   706         }
       
   707         // AskUser is not supported
       
   708     }
       
   709 
       
   710     // KSifInParam_IgnoreOCSPWarnings Yes/No/AskUser -> -ignore_ocsp_warnings=yes|no
       
   711     TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_IgnoreOCSPWarnings, intValue));
       
   712     if (paramFound)
       
   713     {
       
   714         if (intValue == 0) // Yes
       
   715         {
       
   716             aCommandLine.Append(_L(" -ignore_ocsp_warnings=yes"));
       
   717         }
       
   718         else if (intValue == 1) // No
       
   719         {
       
   720             aCommandLine.Append(_L(" -ignore_ocsp_warnings=no"));
       
   721         }
       
   722         // AskUser is not supported
       
   723     }
       
   724 
       
   725     // KSifInParam_AllowUpgrade Yes/No/AskUser -> -upgrade=yes|no
       
   726     TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_AllowUpgrade, intValue));
       
   727     if (paramFound)
       
   728     {
       
   729         if (intValue == 0) // Yes
       
   730         {
       
   731             aCommandLine.Append(_L(" -upgrade=yes"));
       
   732         }
       
   733         else if (intValue == 1) // No
       
   734         {
       
   735             aCommandLine.Append(_L(" -upgrade=no"));
       
   736         }
       
   737         // AskUser is not supported
       
   738     }
       
   739 
       
   740 
       
   741     // TODO: activate this code block when KSifInParam_UpgradeData has been
       
   742     // defined in sifcommon.h
       
   743 /*
       
   744     // KSifInParam_UpgradeData Yes/No/AskUser -> -upgrade_data=yes|no
       
   745     TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_UpgradeData, intValue));
       
   746     if (paramFound)
       
   747     {
       
   748         if (intValue == 0) // Yes
       
   749         {
       
   750             aCommandLine.Append(_L(" -upgrade_data=yes"));
       
   751         }
       
   752         else if (intValue == 1) // No
       
   753         {
       
   754             aCommandLine.Append(_L(" -upgrade_data=no"));
       
   755         }
       
   756         // AskUser is not supported
       
   757     }
       
   758 */
       
   759 
       
   760     // KSifInParam_AllowUntrusted Yes/No/AskUser -> -untrusted=yes|no
       
   761     TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_AllowUntrusted, intValue));
       
   762     if (paramFound)
       
   763     {
       
   764         if (intValue == 0) // Yes
       
   765         {
       
   766             aCommandLine.Append(_L(" -untrusted=yes"));
       
   767         }
       
   768         else if (intValue == 1) // No
       
   769         {
       
   770             aCommandLine.Append(_L(" -untrusted=no"));
       
   771         }
       
   772         // AskUser is not supported
       
   773     }
       
   774 
       
   775     // KSifInParam_AllowOverwrite Yes/No/AskUser -> -overwrite=yes|no
       
   776     TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_AllowOverwrite, intValue));
       
   777     if (paramFound)
       
   778     {
       
   779         if (intValue == 0) // Yes
       
   780         {
       
   781             aCommandLine.Append(_L(" -overwrite=yes"));
       
   782         }
       
   783         else if (intValue == 1) // No
       
   784         {
       
   785             aCommandLine.Append(_L(" -overwrite=no"));
       
   786         }
       
   787         // AskUser is not supported
       
   788     }
       
   789 
       
   790     // KSifInParam_AllowDownload Yes/No/AskUser -> -download=yes|no
       
   791     TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_AllowDownload, intValue));
       
   792     if (paramFound)
       
   793     {
       
   794         if (intValue == 0) // Yes
       
   795         {
       
   796             aCommandLine.Append(_L(" -download=yes"));
       
   797         }
       
   798         else if (intValue == 1) // No
       
   799         {
       
   800             aCommandLine.Append(_L(" -download=no"));
       
   801         }
       
   802         // AskUser is not supported
       
   803     }
       
   804 
       
   805     // KSifInParam_UserName -> -username=download_username
       
   806     TRAP_IGNORE(desValue = aArguments.StringByNameL(KSifInParam_UserName));
       
   807     if (desValue.Length() > 0)
       
   808     {
       
   809         aCommandLine.Append(_L(" -username="));
       
   810         aCommandLine.Append(desValue);
       
   811     }
       
   812 
       
   813     // KSifInParam_Password -> -password=download_password
       
   814     TRAP_IGNORE(desValue = aArguments.StringByNameL(KSifInParam_Password));
       
   815     if (desValue.Length() > 0)
       
   816     {
       
   817         aCommandLine.Append(_L(" -password="));
       
   818         aCommandLine.Append(desValue);
       
   819     }
       
   820 
       
   821     // KSifInParam_SourceUrl -> -sourceurl=original (HTTP) URL of the JAD or JAR file
       
   822     TRAP_IGNORE(desValue = aArguments.StringByNameL(KSifInParam_SourceUrl));
       
   823     if (desValue.Length() > 0)
       
   824     {
       
   825         aCommandLine.Append(_L(" -sourceurl="));
       
   826         aCommandLine.Append(desValue);
       
   827     }
       
   828 
       
   829     // KSifInParam_IAP -> -iap=IAP_ID (internet access point id)
       
   830     TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_IAP, intValue));
       
   831     if (paramFound)
       
   832     {
       
   833         aCommandLine.Append(_L(" -iap="));
       
   834         aCommandLine.AppendNum(intValue);
       
   835     }
       
   836 
       
   837     // KSifInParam_Charset -> -charset=Internet-standard character set name
       
   838     TRAP_IGNORE(desValue = aArguments.StringByNameL(KSifInParam_Charset));
       
   839     if (desValue.Length() > 0)
       
   840     {
       
   841         aCommandLine.Append(_L(" -charset="));
       
   842         aCommandLine.Append(desValue);
       
   843     }
       
   844 
       
   845     return;
       
   846 }
       
   847 
       
   848 
   839 TBool CJavaSifPlugin::ExitIfJavaInstallerRunning(
   849 TBool CJavaSifPlugin::ExitIfJavaInstallerRunning(
   840     COpaqueNamedParams& aResults,
   850     COpaqueNamedParams& aResults,
   841     TRequestStatus& aStatus)
   851     TRequestStatus& aStatus)
   842 {
   852 {
   843     // If Java Installer is already running, set error category EInstallerBusy etc
   853     // If Java Installer is already running, set error category EInstallerBusy etc