appinstaller/AppinstUi/sisxsifplugin/src/sisxsifplugininstallparams.cpp
branchRCL_3
changeset 26 8b7f4e561641
parent 25 7333d7932ef7
child 27 e8965914fac7
equal deleted inserted replaced
25:7333d7932ef7 26:8b7f4e561641
     1 /*
       
     2 * Copyright (c) 2010 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:  Installation parameters class.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "sisxsifplugininstallparams.h" // CSisxSifPluginInstallParams
       
    19 #include <f32file.h>                    // EDriveC
       
    20 
       
    21 using namespace Usif;
       
    22 
       
    23 
       
    24 // ---------------------------------------------------------------------------
       
    25 // CSisxSifPluginInstallParams::NewL()
       
    26 // ---------------------------------------------------------------------------
       
    27 //
       
    28 CSisxSifPluginInstallParams* CSisxSifPluginInstallParams::NewL(
       
    29         const COpaqueNamedParams& aParams )
       
    30     {
       
    31     CSisxSifPluginInstallParams* self = new ( ELeave ) CSisxSifPluginInstallParams;
       
    32     CleanupStack::PushL( self );
       
    33     self->ConstructL( aParams );
       
    34     CleanupStack::Pop( self );
       
    35     return self;
       
    36     }
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // CSisxSifPluginInstallParams::NewL()
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 CSisxSifPluginInstallParams* CSisxSifPluginInstallParams::NewL(
       
    43         const CSisxSifPluginInstallParams& aParams )
       
    44     {
       
    45     CSisxSifPluginInstallParams* self = new ( ELeave ) CSisxSifPluginInstallParams;
       
    46     CleanupStack::PushL( self );
       
    47     self->ConstructL( aParams );
       
    48     CleanupStack::Pop( self );
       
    49     return self;
       
    50     }
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // CSisxSifPluginInstallParams::~CSisxSifPluginInstallParams()
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CSisxSifPluginInstallParams::~CSisxSifPluginInstallParams()
       
    57     {
       
    58     delete iOCSPUrl;
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // CSisxSifPluginInstallParams::IsSilentMode()
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 TBool CSisxSifPluginInstallParams::IsSilentMode() const
       
    66     {
       
    67     return iUseSilentMode;
       
    68     }
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // CSisxSifPluginInstallParams::IsInstallInactive()
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 TBool CSisxSifPluginInstallParams::IsInstallInactive() const
       
    75     {
       
    76     return iIsInstallInactive;
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // CSisxSifPluginInstallParams::Drive()
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 TUint CSisxSifPluginInstallParams::Drive() const
       
    84     {
       
    85     return iDrive;
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // CSisxSifPluginInstallParams::Language()
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 TLanguage CSisxSifPluginInstallParams::Language() const
       
    93     {
       
    94     return iLanguage;
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // CSisxSifPluginInstallParams::OCSPUrl()
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 const TDesC& CSisxSifPluginInstallParams::OCSPUrl() const
       
   102     {
       
   103     if( iOCSPUrl )
       
   104         {
       
   105         return *iOCSPUrl;
       
   106         }
       
   107     return KNullDesC;
       
   108     }
       
   109 
       
   110 // ---------------------------------------------------------------------------
       
   111 // CSisxSifPluginInstallParams::PerformOCSP()
       
   112 // ---------------------------------------------------------------------------
       
   113 //
       
   114 TSifPolicy CSisxSifPluginInstallParams::PerformOCSP() const
       
   115     {
       
   116     return iPerformOCSP;
       
   117     }
       
   118 
       
   119 // ---------------------------------------------------------------------------
       
   120 // CSisxSifPluginInstallParams::IgnoreOCSPWarnings()
       
   121 // ---------------------------------------------------------------------------
       
   122 //
       
   123 TSifPolicy CSisxSifPluginInstallParams::IgnoreOCSPWarnings() const
       
   124     {
       
   125     return iIgnoreOCSPWarnings;
       
   126     }
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // CSisxSifPluginInstallParams::AllowUpgrade()
       
   130 // ---------------------------------------------------------------------------
       
   131 //
       
   132 TSifPolicy CSisxSifPluginInstallParams::AllowUpgrade() const
       
   133     {
       
   134     return iAllowUpgrade;
       
   135     }
       
   136 
       
   137 // ---------------------------------------------------------------------------
       
   138 // CSisxSifPluginInstallParams::InstallOptionalItems()
       
   139 // ---------------------------------------------------------------------------
       
   140 //
       
   141 TSifPolicy CSisxSifPluginInstallParams::InstallOptionalItems() const
       
   142     {
       
   143     return iInstallOptionalItems;
       
   144     }
       
   145 
       
   146 // ---------------------------------------------------------------------------
       
   147 // CSisxSifPluginInstallParams::AllowUntrusted()
       
   148 // ---------------------------------------------------------------------------
       
   149 //
       
   150 TSifPolicy CSisxSifPluginInstallParams::AllowUntrusted() const
       
   151     {
       
   152     return iAllowUntrusted;
       
   153     }
       
   154 
       
   155 // ---------------------------------------------------------------------------
       
   156 // CSisxSifPluginInstallParams::GrantCapabilities()
       
   157 // ---------------------------------------------------------------------------
       
   158 //
       
   159 TSifPolicy CSisxSifPluginInstallParams::GrantCapabilities() const
       
   160     {
       
   161     return iGrantCapabilities;
       
   162     }
       
   163 
       
   164 // ---------------------------------------------------------------------------
       
   165 // CSisxSifPluginInstallParams::AllowAppShutdown()
       
   166 // ---------------------------------------------------------------------------
       
   167 //
       
   168 TSifPolicy CSisxSifPluginInstallParams::AllowAppShutdown() const
       
   169     {
       
   170     return iAllowAppShutdown;
       
   171     }
       
   172 
       
   173 // ---------------------------------------------------------------------------
       
   174 // CSisxSifPluginInstallParams::AllowAppBreakDependency()
       
   175 // ---------------------------------------------------------------------------
       
   176 //
       
   177 TSifPolicy CSisxSifPluginInstallParams::AllowAppBreakDependency() const
       
   178     {
       
   179     return iAllowAppBreakDependency;
       
   180     }
       
   181 
       
   182 // ---------------------------------------------------------------------------
       
   183 // CSisxSifPluginInstallParams::AllowOverwrite()
       
   184 // ---------------------------------------------------------------------------
       
   185 //
       
   186 TSifPolicy CSisxSifPluginInstallParams::AllowOverwrite() const
       
   187     {
       
   188     return iAllowOverwrite;
       
   189     }
       
   190 
       
   191 // ---------------------------------------------------------------------------
       
   192 // CSisxSifPluginInstallParams::PackageInfo()
       
   193 // ---------------------------------------------------------------------------
       
   194 //
       
   195 TSifPolicy CSisxSifPluginInstallParams::PackageInfo() const
       
   196     {
       
   197     return iPackageInfo;
       
   198     }
       
   199 
       
   200 // ---------------------------------------------------------------------------
       
   201 // CSisxSifPluginInstallParams::AllowIncompatible()
       
   202 // ---------------------------------------------------------------------------
       
   203 //
       
   204 TSifPolicy CSisxSifPluginInstallParams::AllowIncompatible() const
       
   205     {
       
   206     return iAllowIncompatible;
       
   207     }
       
   208 
       
   209 // ---------------------------------------------------------------------------
       
   210 // CSisxSifPluginInstallParams::CSisxSifPluginInstallParams()
       
   211 // ---------------------------------------------------------------------------
       
   212 //
       
   213 CSisxSifPluginInstallParams::CSisxSifPluginInstallParams() : iAllowUntrusted( ENotAllowed )
       
   214     {
       
   215     }
       
   216 
       
   217 // ---------------------------------------------------------------------------
       
   218 // CSisxSifPluginInstallParams::ConstructL()
       
   219 // ---------------------------------------------------------------------------
       
   220 //
       
   221 void CSisxSifPluginInstallParams::ConstructL( const COpaqueNamedParams& aParams )
       
   222     {
       
   223     iUseSilentMode = GetIntParam( aParams, KSifInParam_InstallSilently, EFalse );
       
   224     iIsInstallInactive = GetIntParam( aParams, KSifInParam_InstallInactive, EFalse );
       
   225     // TODO: change drive and language params as arrays when available
       
   226     iDrive = static_cast<TUint>( GetIntParam( aParams, KSifInParam_Drive, EDriveC ) );
       
   227     iLanguage = static_cast<TLanguage>( GetIntParam( aParams, KSifInParam_Languages,
       
   228             ELangNone ) );
       
   229     GetStringParamL( aParams, KSifInParam_OCSPUrl, iOCSPUrl );
       
   230     GetPolicyParam( aParams, KSifInParam_PerformOCSP, iPerformOCSP, EAllowed );
       
   231     GetPolicyParam( aParams, KSifInParam_IgnoreOCSPWarnings, iIgnoreOCSPWarnings, EAllowed );
       
   232     GetPolicyParam( aParams, KSifInParam_AllowUpgrade, iAllowUpgrade, EAllowed );
       
   233     GetPolicyParam( aParams, KSifInParam_InstallOptionalItems, iInstallOptionalItems, EAllowed );
       
   234     GetPolicyParam( aParams, KSifInParam_AllowUntrusted, iAllowUntrusted, ENotAllowed );
       
   235     GetPolicyParam( aParams, KSifInParam_GrantCapabilities, iGrantCapabilities, EAllowed );
       
   236     GetPolicyParam( aParams, KSifInParam_AllowAppShutdown, iAllowAppShutdown, EAllowed );
       
   237     GetPolicyParam( aParams, KSifInParam_AllowAppBreakDependency, iAllowAppBreakDependency,
       
   238             EAllowed );
       
   239     GetPolicyParam( aParams, KSifInParam_AllowOverwrite, iAllowOverwrite, EAllowed );
       
   240     GetPolicyParam( aParams, KSifInParam_PackageInfo, iPackageInfo, EAllowed );
       
   241     GetPolicyParam( aParams, KSifInParam_AllowIncompatible, iAllowIncompatible, EAllowed );
       
   242     }
       
   243 
       
   244 // ---------------------------------------------------------------------------
       
   245 // CSisxSifPluginInstallParams::ConstructL()
       
   246 // ---------------------------------------------------------------------------
       
   247 //
       
   248 void CSisxSifPluginInstallParams::ConstructL( const CSisxSifPluginInstallParams& aParams )
       
   249     {
       
   250 	iUseSilentMode = aParams.iUseSilentMode;
       
   251 	iIsInstallInactive = aParams.iIsInstallInactive;
       
   252     iDrive = aParams.iDrive;
       
   253     iLanguage = aParams.iLanguage;
       
   254     if( aParams.iOCSPUrl )
       
   255         {
       
   256         iOCSPUrl = aParams.iOCSPUrl->AllocL();
       
   257         }
       
   258     iPerformOCSP = aParams.iPerformOCSP;
       
   259     iIgnoreOCSPWarnings = aParams.iIgnoreOCSPWarnings;
       
   260     iAllowUpgrade = aParams.iAllowUpgrade;
       
   261     iInstallOptionalItems = aParams.iInstallOptionalItems;
       
   262     iAllowUntrusted = aParams.iAllowUntrusted;
       
   263     iGrantCapabilities = aParams.iGrantCapabilities;
       
   264     iAllowAppShutdown = aParams.iAllowAppShutdown;
       
   265     iAllowAppBreakDependency = aParams.iAllowAppBreakDependency;
       
   266     iAllowOverwrite = aParams.iAllowOverwrite;
       
   267     iPackageInfo = aParams.iPackageInfo;
       
   268     iAllowIncompatible = aParams.iAllowIncompatible;
       
   269     }
       
   270 
       
   271 // ---------------------------------------------------------------------------
       
   272 // CSisxSifPluginInstallParams::GetIntParam()
       
   273 // ---------------------------------------------------------------------------
       
   274 //
       
   275 TInt CSisxSifPluginInstallParams::GetIntParam( const COpaqueNamedParams& aParams,
       
   276         const TDesC& aParamName, TInt aDefaultValue )
       
   277     {
       
   278     TInt value = aDefaultValue;
       
   279     TBool paramFound = EFalse;
       
   280     TRAPD( err, paramFound = aParams.GetIntByNameL( aParamName, value ) );
       
   281     if( !err && paramFound )
       
   282         {
       
   283         return value;
       
   284         }
       
   285     return aDefaultValue;
       
   286     }
       
   287 
       
   288 // ---------------------------------------------------------------------------
       
   289 // CSisxSifPluginInstallParams::GetPolicyParam()
       
   290 // ---------------------------------------------------------------------------
       
   291 //
       
   292 void CSisxSifPluginInstallParams::GetPolicyParam( const COpaqueNamedParams& aParams,
       
   293         const TDesC& aParamName, TSifPolicy& aPolicy, const TSifPolicy& aDefault )
       
   294     {
       
   295     TInt value = aDefault;
       
   296     TBool paramFound = EFalse;
       
   297     TRAPD( err, paramFound = aParams.GetIntByNameL( aParamName, value ) );
       
   298     if( !err && paramFound )
       
   299         {
       
   300         aPolicy = static_cast<TSifPolicy>( value );
       
   301         }
       
   302     }
       
   303 
       
   304 // ---------------------------------------------------------------------------
       
   305 // CSisxSifPluginInstallParams::GetStringParamL()
       
   306 // ---------------------------------------------------------------------------
       
   307 //
       
   308 void CSisxSifPluginInstallParams::GetStringParamL( const COpaqueNamedParams& aParams,
       
   309         const TDesC& aParamName, HBufC*& aBuf )
       
   310     {
       
   311     TPtrC value( aParams.StringByNameL( aParamName ) );
       
   312     if( value.Length() )
       
   313         {
       
   314         if( aBuf )
       
   315             {
       
   316             delete aBuf;
       
   317             aBuf = NULL;
       
   318             }
       
   319         aBuf = value.AllocL();
       
   320         }
       
   321     }
       
   322