ncdengine/provider/deviceinteraction/src/ncdsilentinstallactiveobserver.cpp
changeset 53 ae54820ef82c
parent 0 ba25891c3a9e
child 64 48c14c385b0e
equal deleted inserted replaced
52:92f864ef0288 53:ae54820ef82c
    17 
    17 
    18 
    18 
    19 #include "ncdsilentinstallactiveobserver.h"
    19 #include "ncdsilentinstallactiveobserver.h"
    20 #include "ncdasyncsilentinstallobserver.h"
    20 #include "ncdasyncsilentinstallobserver.h"
    21 
    21 
       
    22 #include <usif/scr/scr.h>
       
    23 
    22 
    24 
    23 CNcdSilentInstallActiveObserver* CNcdSilentInstallActiveObserver::NewL( MNcdAsyncSilentInstallObserver& aObserver )
    25 CNcdSilentInstallActiveObserver* CNcdSilentInstallActiveObserver::NewL( MNcdAsyncSilentInstallObserver& aObserver )
    24     {
    26     {
    25     CNcdSilentInstallActiveObserver* self = 
    27     CNcdSilentInstallActiveObserver* self = 
    26         CNcdSilentInstallActiveObserver::NewLC( aObserver ); 
    28         CNcdSilentInstallActiveObserver::NewLC( aObserver ); 
    47     }
    49     }
    48 
    50 
    49 
    51 
    50 void CNcdSilentInstallActiveObserver::ConstructL()
    52 void CNcdSilentInstallActiveObserver::ConstructL()
    51     {
    53     {
       
    54     
       
    55     iResults = 0;
       
    56     
    52     CActiveScheduler::Add( this );
    57     CActiveScheduler::Add( this );
    53     }
    58     }
    54 
    59 
    55 
    60 
    56 CNcdSilentInstallActiveObserver::~CNcdSilentInstallActiveObserver()
    61 CNcdSilentInstallActiveObserver::~CNcdSilentInstallActiveObserver()
    58     // It is always good and safe to do cancel in CActive objects.
    63     // It is always good and safe to do cancel in CActive objects.
    59     // If silent installation is going on, this operation will
    64     // If silent installation is going on, this operation will
    60     // cancel install operation and closes the silent installer. 
    65     // cancel install operation and closes the silent installer. 
    61     // If no operation is going on, the installer is already closed. 
    66     // If no operation is going on, the installer is already closed. 
    62     // So, no need to close the silent launcher here separately.
    67     // So, no need to close the silent launcher here separately.
       
    68     
       
    69     delete (iResults);
       
    70 
    63     CancelAsyncOperation();
    71     CancelAsyncOperation();
    64     }
    72     }
    65 
    73 
    66 
    74 
    67 void CNcdSilentInstallActiveObserver::DoCancel()
    75 void CNcdSilentInstallActiveObserver::DoCancel()
    70     // silent launcher to send request complete before cancel of this
    78     // silent launcher to send request complete before cancel of this
    71     // active object can finish. This is normal active object canel operation behaviour.
    79     // active object can finish. This is normal active object canel operation behaviour.
    72     // Notice, that we do not call the callback functions of the observer here
    80     // Notice, that we do not call the callback functions of the observer here
    73     // because we suppose that the observer has started the cancel operation itself
    81     // because we suppose that the observer has started the cancel operation itself
    74     // or the caller will inform the observer itself.
    82     // or the caller will inform the observer itself.
    75     SilentLauncher().CancelAsyncRequest( iCancelCode );
    83     
       
    84     SilentLauncher().CancelOperation();
    76     }
    85     }
    77 
    86 
    78 
    87 
    79 void CNcdSilentInstallActiveObserver::StartToObserveL( const TDesC& aFileName,
    88 void CNcdSilentInstallActiveObserver::StartToObserveL( const TDesC& aFileName,
    80                                                        const SwiUI::TInstallOptionsPckg& aSilentInstallOptionsPckg )
    89                                                        const Usif::COpaqueNamedParams* aSilentInstallOptions )
    81     {
    90     {
    82     // For silent installation
    91     // For silent installation
    83     // Notice that if the user does not have TrustedUI capabilities
    92     // Notice that if the user does not have TrustedUI capabilities
    84     // then this will given KErrPermissionDenied.
    93     // then this will given KErrPermissionDenied.
    85     // Connect to the launcher here just before it is needed, 
    94     // Connect to the launcher here just before it is needed, 
    86     // because the launcher will be shown in the application list.
    95     // because the launcher will be shown in the application list.
    87     // So, it would not be nice to connect in the ConstructL and to show
    96     // So, it would not be nice to connect in the ConstructL and to show
    88     // the icon in the list all the time.
    97     // the icon in the list all the time.
       
    98     // User::LeaveIfError( SilentLauncher().Connect() );
    89     User::LeaveIfError( SilentLauncher().Connect() );
    99     User::LeaveIfError( SilentLauncher().Connect() );
    90     
   100     
    91     iCancelCode = SwiUI::ERequestSilentInstall;
   101     if (!iResults)
    92     SilentLauncher().SilentInstall( iStatus,
   102         {
    93                                     aFileName,
   103         iResults = Usif::COpaqueNamedParams::NewL();
    94                                     aSilentInstallOptionsPckg );
   104         }
    95 
   105     
    96     SetActive();
   106     iInstaller.Install( aFileName, *aSilentInstallOptions, *iResults, iStatus ); 
       
   107         
       
   108 
    97     }
   109     }
    98 
   110 
    99 
   111 
   100 void CNcdSilentInstallActiveObserver::StartToObserveL( RFile& aFile,
   112 void CNcdSilentInstallActiveObserver::StartToObserveL( RFile& aFile,
   101                                                        const SwiUI::TInstallOptionsPckg& aSilentInstallOptionsPckg )
   113                                                        const Usif::COpaqueNamedParams* aSilentInstallOptions )
   102     {
   114     {
   103     // For silent installation
   115     // For silent installation
   104     // Notice that if the user does not have TrustedUI capabilities
   116     // Notice that if the user does not have TrustedUI capabilities
   105     // then this will given KErrPermissionDenied.
   117     // then this will given KErrPermissionDenied.
   106     // Connect to the launcher here just before it is needed, 
   118     // Connect to the launcher here just before it is needed, 
   107     // because the launcher will be shown in the application list.
   119     // because the launcher will be shown in the application list.
   108     // So, it would not be nice to connect in the ConstructL and to show
   120     // So, it would not be nice to connect in the ConstructL and to show
   109     // the icon in the list all the time.
   121     // the icon in the list all the time.
       
   122 
   110     User::LeaveIfError( SilentLauncher().Connect() );
   123     User::LeaveIfError( SilentLauncher().Connect() );
   111     
   124     
   112     iCancelCode = SwiUI::ERequestSilentInstallHandle;
   125     if (!iResults)
   113     SilentLauncher().SilentInstall( iStatus,
   126         {
   114                                     aFile,
   127         iResults = Usif::COpaqueNamedParams::NewL();
   115                                     aSilentInstallOptionsPckg );
   128         }
   116 
   129     /*
       
   130     if (iResults)
       
   131         {
       
   132         delete (iResults);
       
   133         iResults = 0;
       
   134         }
       
   135    iResults = Usif::COpaqueNamedParams::NewL();
       
   136 
       
   137     if (iArguments)
       
   138         {
       
   139         delete (iArguments);
       
   140         iArguments = 0;
       
   141         }
       
   142     iArguments = Usif::COpaqueNamedParams::NewL();
       
   143 
       
   144     // Silent installation request
       
   145     
       
   146     TBool iSet = ETrue;
       
   147     
       
   148     enum TSifPolicy
       
   149         {
       
   150         EAllowed        = 0,
       
   151         ENotAllowed     = 1,
       
   152         EUserConfirm    = 2
       
   153         };
       
   154     
       
   155     if (iSet)
       
   156        iArguments->AddIntL( Usif::KSifInParam_InstallSilently, ETrue );
       
   157     else
       
   158         iArguments->AddIntL( Usif::KSifInParam_InstallSilently, EFalse ); 
       
   159     if (iSet)
       
   160         iArguments->AddIntL( Usif::KSifInParam_PerformOCSP, Usif::ENotAllowed );  
       
   161     if (iSet)
       
   162         iArguments->AddIntL( Usif::KSifInParam_AllowUpgrade, Usif::EAllowed );
       
   163     if (iSet)
       
   164         iArguments->AddIntL( Usif::KSifInParam_AllowUntrusted, Usif::ENotAllowed );
       
   165     if (iSet)
       
   166         iArguments->AddIntL( Usif::KSifInParam_GrantCapabilities, Usif::ENotAllowed );
       
   167     if (iSet)
       
   168         iArguments->AddIntL( Usif::KSifInParam_InstallOptionalItems, Usif::EAllowed );
       
   169     if (iSet)
       
   170         iArguments->AddIntL( Usif::KSifInParam_IgnoreOCSPWarnings, Usif::EAllowed );   
       
   171     //iArguments->AddIntL( Usif::KSifInParam_PackageInfo, ETrue );
       
   172     if (iSet)
       
   173         iArguments->AddIntL( Usif::KSifInParam_AllowAppShutdown, Usif::EAllowed );
       
   174     if (iSet)
       
   175        iArguments->AddIntL( Usif::KSifInParam_AllowDownload, Usif::EAllowed );
       
   176     if (iSet)
       
   177        iArguments->AddIntL( Usif::KSifInParam_AllowOverwrite, Usif::EAllowed );
       
   178     
       
   179     
       
   180     //iArguments->AddIntL(Usif::KSifInParam_InstallSilently, 1);
       
   181     //iArguments->AddIntL( Usif::KSifInParam_DisplayPackageInfo, ETrue );     
       
   182     
       
   183     iInstaller.Install(aFile, *iArguments, *iResults, iStatus); 
       
   184     */
       
   185     
       
   186     iInstaller.Install( aFile, *aSilentInstallOptions, *iResults, iStatus ); 
       
   187     
       
   188     
   117     SetActive();
   189     SetActive();
   118     }
   190     }
   119 
   191 
   120 
   192 
   121 TInt CNcdSilentInstallActiveObserver::CancelAsyncOperation()
   193 TInt CNcdSilentInstallActiveObserver::CancelAsyncOperation()
   138     {
   210     {
   139     // This is called when the silent installer has done its job.
   211     // This is called when the silent installer has done its job.
   140     // Close the installer. 
   212     // Close the installer. 
   141     // The launcher is shown in the application list.
   213     // The launcher is shown in the application list.
   142     // So, it would not be nice to leave it there after operation is completed.
   214     // So, it would not be nice to leave it there after operation is completed.
       
   215     
       
   216    
       
   217     TInt ErrCategory = 0;
       
   218     TInt ErrCode = 0;
       
   219     TInt ExtendedErrCode =0;
       
   220     
       
   221     TBool ret = iResults->GetIntByNameL(Usif::KSifOutParam_ErrCategory, ErrCategory);
       
   222     ret = iResults->GetIntByNameL(Usif::KSifOutParam_ErrCode, ErrCode);
       
   223     ret = iResults->GetIntByNameL(Usif::KSifOutParam_ExtendedErrCode, ExtendedErrCode);
   143     SilentLauncher().Close();
   224     SilentLauncher().Close();
   144 
   225 
   145     TInt errorCode( ConvertErrorCode( iStatus.Int() ) );
   226     TInt errorCode( ConvertErrorCode( iStatus.Int() ) );
   146     
   227     
   147     // Just forward the information to the observer.
   228     // Just forward the information to the observer.
   152 MNcdAsyncSilentInstallObserver& CNcdSilentInstallActiveObserver::AsyncObserver() const
   233 MNcdAsyncSilentInstallObserver& CNcdSilentInstallActiveObserver::AsyncObserver() const
   153     {
   234     {
   154     return iObserver;
   235     return iObserver;
   155     }
   236     }
   156 
   237 
   157 
   238 Usif::RSoftwareInstall& CNcdSilentInstallActiveObserver::SilentLauncher()
   158 SwiUI::RSWInstSilentLauncher& CNcdSilentInstallActiveObserver::SilentLauncher()
   239     {
   159     {
   240     // return iSilentLauncher;
   160     return iSilentLauncher;
   241     return iInstaller;
   161     }
   242     }
   162 
   243 
   163 
   244 
   164 TInt CNcdSilentInstallActiveObserver::ConvertErrorCode( TInt aErrorCode )
   245 TInt CNcdSilentInstallActiveObserver::ConvertErrorCode( TInt aErrorCode )
   165     {
   246     {
       
   247     /*
   166     switch ( aErrorCode )
   248     switch ( aErrorCode )
   167         {
   249         {
   168         case SwiUI::KSWInstErrUserCancel:
   250         case SwiUI::KSWInstErrUserCancel:
   169             // To simplify the cancel response and cancel handling,
   251             // To simplify the cancel response and cancel handling,
   170             // convert the error code to normal cancel error code.
   252             // convert the error code to normal cancel error code.
   179                     
   261                     
   180         default:
   262         default:
   181             // Nothing to do here.
   263             // Nothing to do here.
   182             break;
   264             break;
   183         }
   265         }
   184 
   266     */
       
   267     
   185     return aErrorCode;
   268     return aErrorCode;
   186     }
   269     }
   187 
   270