ncdengine/provider/deviceinteraction/src/ncdsilentinstallactiveobserver.cpp
branchRCL_3
changeset 26 8b7f4e561641
parent 25 7333d7932ef7
equal deleted inserted replaced
25:7333d7932ef7 26:8b7f4e561641
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include "ncdsilentinstallactiveobserver.h"
    19 #include "ncdsilentinstallactiveobserver.h"
    20 #include "ncdasyncsilentinstallobserver.h"
    20 #include "ncdasyncsilentinstallobserver.h"
    21 
       
    22 #include <usif/scr/scr.h>
       
    23 
    21 
    24 
    22 
    25 CNcdSilentInstallActiveObserver* CNcdSilentInstallActiveObserver::NewL( MNcdAsyncSilentInstallObserver& aObserver )
    23 CNcdSilentInstallActiveObserver* CNcdSilentInstallActiveObserver::NewL( MNcdAsyncSilentInstallObserver& aObserver )
    26     {
    24     {
    27     CNcdSilentInstallActiveObserver* self = 
    25     CNcdSilentInstallActiveObserver* self = 
    49     }
    47     }
    50 
    48 
    51 
    49 
    52 void CNcdSilentInstallActiveObserver::ConstructL()
    50 void CNcdSilentInstallActiveObserver::ConstructL()
    53     {
    51     {
    54     
       
    55     iResults = 0;
       
    56     
       
    57     CActiveScheduler::Add( this );
    52     CActiveScheduler::Add( this );
    58     }
    53     }
    59 
    54 
    60 
    55 
    61 CNcdSilentInstallActiveObserver::~CNcdSilentInstallActiveObserver()
    56 CNcdSilentInstallActiveObserver::~CNcdSilentInstallActiveObserver()
    63     // It is always good and safe to do cancel in CActive objects.
    58     // It is always good and safe to do cancel in CActive objects.
    64     // If silent installation is going on, this operation will
    59     // If silent installation is going on, this operation will
    65     // cancel install operation and closes the silent installer. 
    60     // cancel install operation and closes the silent installer. 
    66     // If no operation is going on, the installer is already closed. 
    61     // If no operation is going on, the installer is already closed. 
    67     // So, no need to close the silent launcher here separately.
    62     // So, no need to close the silent launcher here separately.
    68     
       
    69     delete (iResults);
       
    70 
       
    71     CancelAsyncOperation();
    63     CancelAsyncOperation();
    72     }
    64     }
    73 
    65 
    74 
    66 
    75 void CNcdSilentInstallActiveObserver::DoCancel()
    67 void CNcdSilentInstallActiveObserver::DoCancel()
    78     // silent launcher to send request complete before cancel of this
    70     // silent launcher to send request complete before cancel of this
    79     // active object can finish. This is normal active object canel operation behaviour.
    71     // active object can finish. This is normal active object canel operation behaviour.
    80     // Notice, that we do not call the callback functions of the observer here
    72     // Notice, that we do not call the callback functions of the observer here
    81     // because we suppose that the observer has started the cancel operation itself
    73     // because we suppose that the observer has started the cancel operation itself
    82     // or the caller will inform the observer itself.
    74     // or the caller will inform the observer itself.
    83     
    75     SilentLauncher().CancelAsyncRequest( iCancelCode );
    84     SilentLauncher().CancelOperation();
       
    85     }
    76     }
    86 
    77 
    87 
    78 
    88 void CNcdSilentInstallActiveObserver::StartToObserveL( const TDesC& aFileName,
    79 void CNcdSilentInstallActiveObserver::StartToObserveL( const TDesC& aFileName,
    89                                                        const Usif::COpaqueNamedParams* aSilentInstallOptions )
    80                                                        const SwiUI::TInstallOptionsPckg& aSilentInstallOptionsPckg )
    90     {
    81     {
    91     // For silent installation
    82     // For silent installation
    92     // Notice that if the user does not have TrustedUI capabilities
    83     // Notice that if the user does not have TrustedUI capabilities
    93     // then this will given KErrPermissionDenied.
    84     // then this will given KErrPermissionDenied.
    94     // Connect to the launcher here just before it is needed, 
    85     // Connect to the launcher here just before it is needed, 
    95     // because the launcher will be shown in the application list.
    86     // because the launcher will be shown in the application list.
    96     // So, it would not be nice to connect in the ConstructL and to show
    87     // So, it would not be nice to connect in the ConstructL and to show
    97     // the icon in the list all the time.
    88     // the icon in the list all the time.
    98     // User::LeaveIfError( SilentLauncher().Connect() );
       
    99     User::LeaveIfError( SilentLauncher().Connect() );
    89     User::LeaveIfError( SilentLauncher().Connect() );
   100     
    90     
   101     if (!iResults)
    91     iCancelCode = SwiUI::ERequestSilentInstall;
   102         {
    92     SilentLauncher().SilentInstall( iStatus,
   103         iResults = Usif::COpaqueNamedParams::NewL();
    93                                     aFileName,
   104         }
    94                                     aSilentInstallOptionsPckg );
   105     
       
   106     iInstaller.Install( aFileName, *aSilentInstallOptions, *iResults, iStatus ); 
       
   107         
       
   108 
    95 
       
    96     SetActive();
   109     }
    97     }
   110 
    98 
   111 
    99 
   112 void CNcdSilentInstallActiveObserver::StartToObserveL( RFile& aFile,
   100 void CNcdSilentInstallActiveObserver::StartToObserveL( RFile& aFile,
   113                                                        const Usif::COpaqueNamedParams* aSilentInstallOptions )
   101                                                        const SwiUI::TInstallOptionsPckg& aSilentInstallOptionsPckg )
   114     {
   102     {
   115     // For silent installation
   103     // For silent installation
   116     // Notice that if the user does not have TrustedUI capabilities
   104     // Notice that if the user does not have TrustedUI capabilities
   117     // then this will given KErrPermissionDenied.
   105     // then this will given KErrPermissionDenied.
   118     // Connect to the launcher here just before it is needed, 
   106     // Connect to the launcher here just before it is needed, 
   119     // because the launcher will be shown in the application list.
   107     // because the launcher will be shown in the application list.
   120     // So, it would not be nice to connect in the ConstructL and to show
   108     // So, it would not be nice to connect in the ConstructL and to show
   121     // the icon in the list all the time.
   109     // the icon in the list all the time.
   122 
       
   123     User::LeaveIfError( SilentLauncher().Connect() );
   110     User::LeaveIfError( SilentLauncher().Connect() );
   124     
   111     
   125     if (!iResults)
   112     iCancelCode = SwiUI::ERequestSilentInstallHandle;
   126         {
   113     SilentLauncher().SilentInstall( iStatus,
   127         iResults = Usif::COpaqueNamedParams::NewL();
   114                                     aFile,
   128         }
   115                                     aSilentInstallOptionsPckg );
   129     
   116 
   130     iInstaller.Install( aFile, *aSilentInstallOptions, *iResults, iStatus ); 
       
   131     
       
   132     SetActive();
   117     SetActive();
   133     }
   118     }
   134 
   119 
   135 
   120 
   136 TInt CNcdSilentInstallActiveObserver::CancelAsyncOperation()
   121 TInt CNcdSilentInstallActiveObserver::CancelAsyncOperation()
   153     {
   138     {
   154     // This is called when the silent installer has done its job.
   139     // This is called when the silent installer has done its job.
   155     // Close the installer. 
   140     // Close the installer. 
   156     // The launcher is shown in the application list.
   141     // The launcher is shown in the application list.
   157     // So, it would not be nice to leave it there after operation is completed.
   142     // So, it would not be nice to leave it there after operation is completed.
   158     
       
   159    
       
   160     TInt ErrCategory = 0;
       
   161     TInt ErrCode = 0;
       
   162     TInt ExtendedErrCode =0;
       
   163     
       
   164     TBool ret = iResults->GetIntByNameL(Usif::KSifOutParam_ErrCategory, ErrCategory);
       
   165     ret = iResults->GetIntByNameL(Usif::KSifOutParam_ErrCode, ErrCode);
       
   166     ret = iResults->GetIntByNameL(Usif::KSifOutParam_ExtendedErrCode, ExtendedErrCode);
       
   167     SilentLauncher().Close();
   143     SilentLauncher().Close();
   168 
   144 
   169     TInt errorCode( ConvertErrorCode( iStatus.Int() ) );
   145     TInt errorCode( ConvertErrorCode( iStatus.Int() ) );
   170     
   146     
   171     // Just forward the information to the observer.
   147     // Just forward the information to the observer.
   176 MNcdAsyncSilentInstallObserver& CNcdSilentInstallActiveObserver::AsyncObserver() const
   152 MNcdAsyncSilentInstallObserver& CNcdSilentInstallActiveObserver::AsyncObserver() const
   177     {
   153     {
   178     return iObserver;
   154     return iObserver;
   179     }
   155     }
   180 
   156 
   181 Usif::RSoftwareInstall& CNcdSilentInstallActiveObserver::SilentLauncher()
   157 
       
   158 SwiUI::RSWInstSilentLauncher& CNcdSilentInstallActiveObserver::SilentLauncher()
   182     {
   159     {
   183     // return iSilentLauncher;
   160     return iSilentLauncher;
   184     return iInstaller;
       
   185     }
   161     }
   186 
   162 
   187 
   163 
   188 TInt CNcdSilentInstallActiveObserver::ConvertErrorCode( TInt aErrorCode )
   164 TInt CNcdSilentInstallActiveObserver::ConvertErrorCode( TInt aErrorCode )
   189     {
   165     {
       
   166     switch ( aErrorCode )
       
   167         {
       
   168         case SwiUI::KSWInstErrUserCancel:
       
   169             // To simplify the cancel response and cancel handling,
       
   170             // convert the error code to normal cancel error code.
       
   171             aErrorCode = KErrCancel;
       
   172             break;
       
   173 
       
   174         case SwiUI::KSWInstErrInsufficientMemory:
       
   175             // To simplify the insufficient memory response and its handling,
       
   176             // convert the error code to normal no memory code.
       
   177             aErrorCode = KErrNoMemory;
       
   178             break;
       
   179                     
       
   180         default:
       
   181             // Nothing to do here.
       
   182             break;
       
   183         }
       
   184 
   190     return aErrorCode;
   185     return aErrorCode;
   191     }
   186     }
   192 
   187