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 } |
|
105 |
|
106 iInstaller.Install( aFileName, *aSilentInstallOptions, *iResults, iStatus ); |
|
107 |
95 |
108 |
96 SetActive(); |
|
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 iInstaller.Install( aFile, *aSilentInstallOptions, *iResults, iStatus ); |
|
131 |
117 SetActive(); |
132 SetActive(); |
118 } |
133 } |
119 |
134 |
120 |
135 |
121 TInt CNcdSilentInstallActiveObserver::CancelAsyncOperation() |
136 TInt CNcdSilentInstallActiveObserver::CancelAsyncOperation() |
138 { |
153 { |
139 // This is called when the silent installer has done its job. |
154 // This is called when the silent installer has done its job. |
140 // Close the installer. |
155 // Close the installer. |
141 // The launcher is shown in the application list. |
156 // The launcher is shown in the application list. |
142 // So, it would not be nice to leave it there after operation is completed. |
157 // 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); |
143 SilentLauncher().Close(); |
167 SilentLauncher().Close(); |
144 |
168 |
145 TInt errorCode( ConvertErrorCode( iStatus.Int() ) ); |
169 TInt errorCode( ConvertErrorCode( iStatus.Int() ) ); |
146 |
170 |
147 // Just forward the information to the observer. |
171 // Just forward the information to the observer. |
152 MNcdAsyncSilentInstallObserver& CNcdSilentInstallActiveObserver::AsyncObserver() const |
176 MNcdAsyncSilentInstallObserver& CNcdSilentInstallActiveObserver::AsyncObserver() const |
153 { |
177 { |
154 return iObserver; |
178 return iObserver; |
155 } |
179 } |
156 |
180 |
157 |
181 Usif::RSoftwareInstall& CNcdSilentInstallActiveObserver::SilentLauncher() |
158 SwiUI::RSWInstSilentLauncher& CNcdSilentInstallActiveObserver::SilentLauncher() |
|
159 { |
182 { |
160 return iSilentLauncher; |
183 // return iSilentLauncher; |
|
184 return iInstaller; |
161 } |
185 } |
162 |
186 |
163 |
187 |
164 TInt CNcdSilentInstallActiveObserver::ConvertErrorCode( TInt aErrorCode ) |
188 TInt CNcdSilentInstallActiveObserver::ConvertErrorCode( TInt aErrorCode ) |
165 { |
189 { |
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 |
|
185 return aErrorCode; |
190 return aErrorCode; |
186 } |
191 } |
187 |
192 |