49 #include "commands/uninstalldialog.h" |
49 #include "commands/uninstalldialog.h" |
50 #include "commands/securitywarningdialog.h" |
50 #include "commands/securitywarningdialog.h" |
51 #include "commands/textdialog.h" |
51 #include "commands/textdialog.h" |
52 #include "log.h" |
52 #include "log.h" |
53 |
53 |
|
54 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
54 #include "cleanuputils.h" |
55 #include "cleanuputils.h" |
55 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
56 #include <usif/sif/sifcommon.h> |
56 #include <usif/sif/sifcommon.h> |
57 const TInt KCompInfoBufferSize=4*1024; |
57 const TInt KCompInfoBufferSize=4*1024; |
58 #endif |
58 #endif |
59 |
59 |
60 |
|
61 |
|
62 namespace Swi |
60 namespace Swi |
63 { |
61 { |
64 |
|
65 //Temporary error logging solution. |
|
66 void LogSwiErrorsToFileL(TInt aErrorCode, const TDesC& aAppName); |
|
67 |
|
68 // |
62 // |
69 // A cancel handler |
63 // A cancel handler |
70 // |
64 // |
71 class InternalCancelHandler : public MCancelHandler |
65 class InternalCancelHandler : public MCancelHandler |
72 { |
66 { |
73 public: |
67 public: |
74 InternalCancelHandler(CUissClientHandler& aUissClientHandler); |
68 InternalCancelHandler(CUissClientHandler& aUissClientHandler); |
75 void HandleCancel(); |
69 void HandleCancel(); |
76 private: |
70 private: |
77 CUissClientHandler& iUissClientHandler; |
71 CUissClientHandler& iUissClientHandler; |
78 }; |
72 }; |
79 |
73 |
80 InternalCancelHandler::InternalCancelHandler( |
74 InternalCancelHandler::InternalCancelHandler( |
81 CUissClientHandler& aUissClientHandler) |
75 CUissClientHandler& aUissClientHandler) |
82 : iUissClientHandler(aUissClientHandler) |
76 : iUissClientHandler(aUissClientHandler) |
83 { |
77 { |
84 } |
78 } |
85 |
79 |
86 void InternalCancelHandler::HandleCancel() |
80 void InternalCancelHandler::HandleCancel() |
87 { |
81 { |
88 iUissClientHandler.CancelOperation(); |
82 iUissClientHandler.CancelOperation(); |
89 } |
83 } |
90 |
84 |
91 CUissClientHandler* CUissClientHandler::NewLC(MUiHandler& aUiHandler, TBool aActiveObjectMode) |
85 CUissClientHandler* CUissClientHandler::NewLC(MUiHandler& aUiHandler, TBool aActiveObjectMode) |
92 { |
86 { |
93 CUissClientHandler* self=new(ELeave) CUissClientHandler(aUiHandler, aActiveObjectMode); |
87 CUissClientHandler* self=new(ELeave) CUissClientHandler(aUiHandler, aActiveObjectMode); |
94 CleanupStack::PushL(self); |
88 CleanupStack::PushL(self); |
95 self->ConstructL(); |
89 self->ConstructL(); |
96 return self; |
90 return self; |
97 } |
91 } |
98 |
92 |
99 CUissClientHandler* CUissClientHandler::NewL(MUiHandler& aUiHandler, TBool aActiveObjectMode) |
93 CUissClientHandler* CUissClientHandler::NewL(MUiHandler& aUiHandler, TBool aActiveObjectMode) |
100 { |
94 { |
101 CUissClientHandler* self=NewLC(aUiHandler, aActiveObjectMode); |
95 CUissClientHandler* self=NewLC(aUiHandler, aActiveObjectMode); |
102 CleanupStack::Pop(self); |
96 CleanupStack::Pop(self); |
103 return self; |
97 return self; |
104 } |
98 } |
105 |
99 |
106 CUissClientHandler::CUissClientHandler(MUiHandler& aUiHandler, TBool aActiveObjectMode) |
100 CUissClientHandler::CUissClientHandler(MUiHandler& aUiHandler, TBool aActiveObjectMode) |
107 : CActive(EPriorityStandard), |
101 : CActive(EPriorityStandard), |
108 iUiHandler(aUiHandler), |
102 iUiHandler(aUiHandler), |
109 iPtrIntoBuf(0,0), |
103 iPtrIntoBuf(0,0), |
110 iActiveObjectMode(aActiveObjectMode), |
104 iActiveObjectMode(aActiveObjectMode), |
111 iPtrIntoArgsStream(0,0) |
105 iPtrIntoArgsStream(0,0) |
112 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
106 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
113 ,iCompInfoBufPtr(0,0) |
107 ,iCompInfoBufPtr(0,0) |
114 #endif |
108 #endif |
115 { |
109 { |
116 if (iActiveObjectMode) |
110 if (iActiveObjectMode) |
117 { |
111 { |
118 CActiveScheduler::Add(this); |
112 CActiveScheduler::Add(this); |
119 } |
113 } |
120 } |
114 } |
121 |
115 |
122 void CUissClientHandler::WaitForSisHelperShutdown() |
116 void CUissClientHandler::WaitForSisHelperShutdown() |
123 { |
117 { |
124 if(iSisHelper.Handle() > 0) |
118 if(iSisHelper.Handle() > 0) |
125 { |
119 { |
126 TRequestStatus reqStatus; |
120 TRequestStatus reqStatus; |
127 iSisHelper.Logon(reqStatus); |
121 iSisHelper.Logon(reqStatus); |
128 User::WaitForRequest(reqStatus); |
122 User::WaitForRequest(reqStatus); |
129 iSisHelper.Close(); |
123 iSisHelper.Close(); |
130 } |
124 } |
131 } |
125 } |
132 |
126 |
133 CUissClientHandler::~CUissClientHandler() |
127 CUissClientHandler::~CUissClientHandler() |
134 { |
128 { |
135 //Cancel any outstanding request |
129 //Cancel any outstanding request |
136 CancelOperation(); |
130 CancelOperation(); |
137 |
131 |
138 WaitForSisHelperShutdown(); |
132 WaitForSisHelperShutdown(); |
139 if (iActiveObjectMode) |
133 if (iActiveObjectMode) |
140 { |
134 { |
141 CActive::Cancel(); // Make sure we are cancelled before deletion |
135 CActive::Cancel(); // Make sure we are cancelled before deletion |
142 } |
136 } |
143 |
137 |
144 delete iCancelHandler; |
138 delete iCancelHandler; |
145 delete iArgsStream; |
139 delete iArgsStream; |
146 iUissSession.Close(); |
140 iUissSession.Close(); |
147 delete iBuf; |
141 delete iBuf; |
148 delete iBufLogger; |
142 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
149 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
150 delete iCompInfoBuffer; |
143 delete iCompInfoBuffer; |
151 #endif |
144 #endif |
152 } |
145 } |
153 |
146 |
154 /** |
147 /** |
155 * Allocates a buffer for reverse-completion commands. The buffer is going to |
148 * Allocates a buffer for reverse-completion commands. The buffer is going to |
156 * be resized in case it is not sufficient for a dialog command. |
149 * be resized in case it is not sufficient for a dialog command. |
157 */ |
150 */ |
158 void CUissClientHandler::ConstructL() |
151 void CUissClientHandler::ConstructL() |
159 { |
152 { |
160 iCancelHandler=new(ELeave) InternalCancelHandler(*this); |
153 iCancelHandler=new(ELeave) InternalCancelHandler(*this); |
161 AllocBufL(KBufSize);// Allocate the initial r/c buffer |
154 AllocBufL(KBufSize);// Allocate the initial r/c buffer |
162 |
155 User::LeaveIfError(StartUiss()); // Start UISS |
163 //Logger buffer. |
156 User::LeaveIfError(iUissSession.Connect()); // Connect to UISS |
164 iBufLogger = KNullDesC8().AllocL(); |
157 } |
165 User::LeaveIfError(StartUiss()); // Start UISS |
|
166 User::LeaveIfError(iUissSession.Connect()); // Connect to UISS |
|
167 } |
|
168 |
158 |
169 void CUissClientHandler::AllocBufL(TInt aSize) |
159 void CUissClientHandler::AllocBufL(TInt aSize) |
170 { |
160 { |
171 HBufC8* buf=HBufC8::NewL(aSize); |
161 HBufC8* buf=HBufC8::NewL(aSize); |
172 delete iBuf; |
162 delete iBuf; |
173 iBuf=buf; |
163 iBuf=buf; |
174 } |
164 } |
175 |
165 |
176 void CUissClientHandler::HandleOverflowL() |
166 void CUissClientHandler::HandleOverflowL() |
177 { |
167 { |
178 // Reallocate the buffer to the size received in parameter 1 |
168 // Reallocate the buffer to the size received in parameter 1 |
179 TInt size=0; |
169 TInt size=0; |
180 TPckg<TInt> theSize(size); |
170 TPckg<TInt> theSize(size); |
181 theSize.Copy(iBuf->Left(sizeof(TInt))); |
171 theSize.Copy(iBuf->Left(sizeof(TInt))); |
182 AllocBufL(size); |
172 AllocBufL(size); |
183 } |
173 } |
184 |
174 |
185 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
175 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
186 void CUissClientHandler::AllocCompInfoBufL(TInt aSize) |
176 void CUissClientHandler::AllocCompInfoBufL(TInt aSize) |
187 { |
177 { |
188 HBufC8* buf = HBufC8::NewL(aSize); |
178 HBufC8* buf = HBufC8::NewL(aSize); |
189 delete iCompInfoBuffer; |
179 delete iCompInfoBuffer; |
190 iCompInfoBuffer = buf; |
180 iCompInfoBuffer = buf; |
191 } |
181 } |
192 #endif |
182 #endif |
193 |
183 |
194 ///\short Creates a command handler object for the specified dialog request |
184 ///\short Creates a command handler object for the specified dialog request |
195 CUissCmdHandler* CUissClientHandler::UissCmdHandlerFactoryL(TInt aCommand) const |
185 CUissCmdHandler* CUissClientHandler::UissCmdHandlerFactoryL(TInt aCommand) const |
196 { |
186 { |
197 switch (aCommand) |
187 switch (aCommand) |
198 { |
188 { |
199 case CUissSession::KMessageApplicationsInUseDialog: |
189 case CUissSession::KMessageApplicationsInUseDialog: |
200 return new(ELeave) CApplicationsInUseDialogCmdHandler(iUiHandler); |
190 return new(ELeave) CApplicationsInUseDialogCmdHandler(iUiHandler); |
201 case CUissSession::KMessageCannotOverwriteFileDialog: |
191 case CUissSession::KMessageCannotOverwriteFileDialog: |
202 return new(ELeave) CCannotOverwriteFileDialogCmdHandler(iUiHandler); |
192 return new(ELeave) CCannotOverwriteFileDialogCmdHandler(iUiHandler); |
203 |
193 |
204 case CUissSession::KMessageDependencyBreakDialog: |
194 case CUissSession::KMessageDependencyBreakDialog: |
205 return new(ELeave) CDependencyBreakDialogCmdHandler(iUiHandler); |
195 return new(ELeave) CDependencyBreakDialogCmdHandler(iUiHandler); |
206 case CUissSession::KMessageDeviceIncompatibility: |
196 case CUissSession::KMessageDeviceIncompatibility: |
207 return new(ELeave) CDeviceIncompatibilityDialogCmdHandler(iUiHandler); |
197 return new(ELeave) CDeviceIncompatibilityDialogCmdHandler(iUiHandler); |
208 case CUissSession::KMessageMissingDependency: |
198 case CUissSession::KMessageMissingDependency: |
209 return new(ELeave) CMissingDependencyDialogCmdHandler(iUiHandler); |
199 return new(ELeave) CMissingDependencyDialogCmdHandler(iUiHandler); |
210 case CUissSession::KMessageDriveDialog: |
200 case CUissSession::KMessageDriveDialog: |
211 return new(ELeave) CDriveDialogCmdHandler(iUiHandler); |
201 return new(ELeave) CDriveDialogCmdHandler(iUiHandler); |
212 case CUissSession::KMessageErrorDialog: |
202 case CUissSession::KMessageErrorDialog: |
213 return new(ELeave) CErrorDialogCmdHandler(iUiHandler); |
203 return new(ELeave) CErrorDialogCmdHandler(iUiHandler); |
214 case CUissSession::KMessageGrantCapabilitiesDialog: |
204 case CUissSession::KMessageGrantCapabilitiesDialog: |
215 return new(ELeave) CGrantCapabilitiesDialogCmdHandler(iUiHandler); |
205 return new(ELeave) CGrantCapabilitiesDialogCmdHandler(iUiHandler); |
216 case CUissSession::KMessageHandleCancellableInstallEvent: |
206 case CUissSession::KMessageHandleCancellableInstallEvent: |
217 return new(ELeave) CHandleCancellableInstallEventCmdHandler(iUiHandler, |
207 return new(ELeave) CHandleCancellableInstallEventCmdHandler(iUiHandler, |
218 *iCancelHandler); |
208 *iCancelHandler); |
219 case CUissSession::KMessageHandleInstallEvent: |
209 case CUissSession::KMessageHandleInstallEvent: |
220 return new(ELeave) CHandleInstallEventCmdHandler(iUiHandler); |
210 return new(ELeave) CHandleInstallEventCmdHandler(iUiHandler); |
221 case CUissSession::KMessageInstallDialog: |
211 case CUissSession::KMessageInstallDialog: |
222 return new(ELeave) CInstallDialogCmdHandler(iUiHandler); |
212 return new(ELeave) CInstallDialogCmdHandler(iUiHandler); |
223 case CUissSession::KMessageLanguageDialog: |
213 case CUissSession::KMessageLanguageDialog: |
224 return new(ELeave) CLanguageDialogCmdHandler(iUiHandler); |
214 return new(ELeave) CLanguageDialogCmdHandler(iUiHandler); |
225 case CUissSession::KMessageOcspResultDialog: |
215 case CUissSession::KMessageOcspResultDialog: |
226 return new(ELeave) COcspResultDialogCmdHandler(iUiHandler); |
216 return new(ELeave) COcspResultDialogCmdHandler(iUiHandler); |
227 case CUissSession::KMessageOptionsDialog: |
217 case CUissSession::KMessageOptionsDialog: |
228 return new(ELeave) COptionsDialogCmdHandler(iUiHandler); |
218 return new(ELeave) COptionsDialogCmdHandler(iUiHandler); |
229 case CUissSession::KMessageQuestionDialog: |
219 case CUissSession::KMessageQuestionDialog: |
230 return new(ELeave) CQuestionDialogCmdHandler(iUiHandler); |
220 return new(ELeave) CQuestionDialogCmdHandler(iUiHandler); |
231 case CUissSession::KMessageSecurityWarningDialog: |
221 case CUissSession::KMessageSecurityWarningDialog: |
232 return new(ELeave) CSecurityWarningDialogCmdHandler(iUiHandler); |
222 return new(ELeave) CSecurityWarningDialogCmdHandler(iUiHandler); |
233 case CUissSession::KMessageUninstallDialog: |
223 case CUissSession::KMessageUninstallDialog: |
234 return new(ELeave) CUninstallDialogCmdHandler(iUiHandler); |
224 return new(ELeave) CUninstallDialogCmdHandler(iUiHandler); |
235 |
225 |
236 case CUissSession::KMessageUpgradeDialog: |
226 case CUissSession::KMessageUpgradeDialog: |
237 return new(ELeave) CUpgradeDialogCmdHandler(iUiHandler); |
227 return new(ELeave) CUpgradeDialogCmdHandler(iUiHandler); |
238 |
228 |
239 case CUissSession::KMessageTextDialog: |
229 case CUissSession::KMessageTextDialog: |
240 return new(ELeave) CTextDialogCmdHandler(iUiHandler); |
230 return new(ELeave) CTextDialogCmdHandler(iUiHandler); |
241 |
231 |
242 default: |
232 default: |
243 return NULL; |
233 return NULL; |
244 } |
234 } |
245 } |
235 } |
246 |
236 |
247 void CUissClientHandler::InitializeArgStreamL(const CInstallPrefs& aInstallPrefs) |
237 void CUissClientHandler::InitializeArgStreamL(const CInstallPrefs& aInstallPrefs) |
248 { |
238 { |
249 // Stream out install parameters. Cannot do this in UISSCLIENT because |
239 // Stream out install parameters. Cannot do this in UISSCLIENT because |
250 // the code is in LAUNCHER which depends on UISSCLIENT. |
240 // the code is in LAUNCHER which depends on UISSCLIENT. |
251 delete iArgsStream; |
241 delete iArgsStream; |
252 iArgsStream = 0; |
242 iArgsStream = 0; |
253 iArgsStream = CWriteStream::NewL(); |
243 iArgsStream = CWriteStream::NewL(); |
254 *iArgsStream << aInstallPrefs; |
244 *iArgsStream << aInstallPrefs; |
255 // Save ptr for args (must persist whilst server is processing) |
245 // Save ptr for args (must persist whilst server is processing) |
256 iPtrIntoArgsStream.Set(iArgsStream->Ptr()); |
246 iPtrIntoArgsStream.Set(iArgsStream->Ptr()); |
257 } |
247 } |
258 |
248 |
259 void CUissClientHandler::InstallL(const CInstallPrefs& aInstallPrefs, const RArray<TInt>& aDeviceSupportedLanguages, TRequestStatus& aRequestStatus, RThread& aServer) |
249 void CUissClientHandler::InstallL(const CInstallPrefs& aInstallPrefs, const RArray<TInt>& aDeviceSupportedLanguages, TRequestStatus& aRequestStatus, RThread& aServer) |
260 { |
250 { |
261 iState = KUissClientInstalling; |
251 iState = KUissClientInstalling; |
262 iClientStatus = &aRequestStatus; |
252 iClientStatus = &aRequestStatus; |
263 |
253 |
264 // Save ptr for data returned by request (must persist whilst server is processing) |
254 // Save ptr for data returned by request (must persist whilst server is processing) |
265 iPtrIntoBuf.Set(iBuf->Des()); |
255 iPtrIntoBuf.Set(iBuf->Des()); |
266 |
256 |
267 InitializeArgStreamL(aInstallPrefs); |
257 InitializeArgStreamL(aInstallPrefs); |
268 iArgsStream->Stream().WriteInt32L(aDeviceSupportedLanguages.Count()); |
258 iArgsStream->Stream().WriteInt32L(aDeviceSupportedLanguages.Count()); |
269 //Streaming set of languages that device supports |
259 //Streaming set of languages that device supports |
270 TInt noOfDeviceSupportedLanguages = aDeviceSupportedLanguages.Count(); |
260 TInt noOfDeviceSupportedLanguages = aDeviceSupportedLanguages.Count(); |
271 for(TInt i=0;i<noOfDeviceSupportedLanguages;i++) |
261 for(TInt i=0;i<noOfDeviceSupportedLanguages;i++) |
272 { |
262 { |
273 iArgsStream->Stream().WriteInt32L(aDeviceSupportedLanguages[i]); |
263 iArgsStream->Stream().WriteInt32L(aDeviceSupportedLanguages[i]); |
274 } |
264 } |
275 // Save ptr for args (must persist whilst server is processing) |
265 // Save ptr for args (must persist whilst server is processing) |
276 iPtrIntoArgsStream.Set(iArgsStream->Ptr()); |
266 iPtrIntoArgsStream.Set(iArgsStream->Ptr()); |
277 |
267 |
278 // Issue initial request |
268 // Issue initial request |
279 iUissSession.Install(iPtrIntoArgsStream, iPtrIntoBuf, iStatus); |
269 iUissSession.Install(iPtrIntoArgsStream, iPtrIntoBuf, iStatus); |
280 if (iActiveObjectMode) |
270 if (iActiveObjectMode) |
281 { |
271 { |
282 SetActive(); |
272 SetActive(); |
283 } |
273 } |
284 |
274 |
285 // Update client's TRequestStatus object |
275 // Update client's TRequestStatus object |
286 *iClientStatus = KRequestPending; |
276 *iClientStatus = KRequestPending; |
287 iSisHelper = aServer; |
277 iSisHelper = aServer; |
288 } |
278 } |
289 |
279 |
290 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
280 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
291 void CUissClientHandler::GetComponentInfoL(const CInstallPrefs& aInstallPrefs, Usif::CComponentInfo& aComponentInfo, TRequestStatus& aRequestStatus, RThread& aServer) |
281 void CUissClientHandler::GetComponentInfoL(const CInstallPrefs& aInstallPrefs, Usif::CComponentInfo& aComponentInfo, TRequestStatus& aRequestStatus, RThread& aServer) |
292 { |
282 { |
293 iState = KUissClientGettingCompInfo; |
283 iState = KUissClientGettingCompInfo; |
294 iClientStatus = &aRequestStatus; |
284 iClientStatus = &aRequestStatus; |
295 |
285 |
296 // Store the component info reference to the class reference. So that, the same will be |
286 // Store the component info reference to the class reference. So that, the same will be |
297 // populated after getting the asynchronous method completed. |
287 // populated after getting the asynchronous method completed. |
298 iComponentInfo = &aComponentInfo; |
288 iComponentInfo = &aComponentInfo; |
299 |
289 |
300 InitializeArgStreamL(aInstallPrefs); |
290 InitializeArgStreamL(aInstallPrefs); |
301 |
291 |
302 AllocCompInfoBufL(KCompInfoBufferSize); |
292 AllocCompInfoBufL(KCompInfoBufferSize); |
303 |
293 |
304 // Save the pointer for component info collection buffer |
294 // Save the pointer for component info collection buffer |
305 iCompInfoBufPtr.Set(iCompInfoBuffer->Des()); |
295 iCompInfoBufPtr.Set(iCompInfoBuffer->Des()); |
306 |
296 |
307 // Issue get component info request |
297 // Issue get component info request |
308 iUissSession.GetComponentInfo(iPtrIntoArgsStream, iCompInfoBufPtr, iStatus); |
298 iUissSession.GetComponentInfo(iPtrIntoArgsStream, iCompInfoBufPtr, iStatus); |
309 |
299 |
310 // There is no synchronous API for GetComponentInfo |
300 // There is no synchronous API for GetComponentInfo |
311 __ASSERT_ALWAYS(iActiveObjectMode, User::Invariant()); |
301 __ASSERT_ALWAYS(iActiveObjectMode, User::Invariant()); |
312 SetActive(); |
302 SetActive(); |
313 |
303 |
314 // Update client's TRequestStatus object |
304 // Update client's TRequestStatus object |
315 *iClientStatus = KRequestPending; |
305 *iClientStatus = KRequestPending; |
316 iSisHelper = aServer; |
306 iSisHelper = aServer; |
317 } |
307 } |
318 #endif |
308 #endif |
319 |
309 |
320 void CUissClientHandler::UninstallL(const CSisRegistryPackage& aPackage, TRequestStatus& aRequestStatus) |
310 void CUissClientHandler::UninstallL(const CSisRegistryPackage& aPackage, TRequestStatus& aRequestStatus) |
321 { |
311 { |
322 iState = KUissClientUninstalling; |
312 iState = KUissClientUninstalling; |
323 iClientStatus = &aRequestStatus; |
313 iClientStatus = &aRequestStatus; |
324 |
314 |
325 // Save ptr for data returned by request (must persist whilst server is processing) |
315 // Save ptr for data returned by request (must persist whilst server is processing) |
326 iPtrIntoBuf.Set(iBuf->Des()); |
316 iPtrIntoBuf.Set(iBuf->Des()); |
327 |
317 |
328 delete iArgsStream; |
318 delete iArgsStream; |
329 iArgsStream = 0; |
319 iArgsStream = 0; |
330 iArgsStream = CWriteStream::NewL(); |
320 iArgsStream = CWriteStream::NewL(); |
331 *iArgsStream << aPackage; |
321 *iArgsStream << aPackage; |
332 // Save ptr for args (must persist whilst server is processing) |
322 // Save ptr for args (must persist whilst server is processing) |
333 iPtrIntoArgsStream.Set(iArgsStream->Ptr()); |
323 iPtrIntoArgsStream.Set(iArgsStream->Ptr()); |
334 |
324 |
335 // Issue initial request |
325 // Issue initial request |
336 iUissSession.Uninstall(iPtrIntoArgsStream, iPtrIntoBuf, iStatus); |
326 iUissSession.Uninstall(iPtrIntoArgsStream, iPtrIntoBuf, iStatus); |
337 if (iActiveObjectMode) |
327 if (iActiveObjectMode) |
338 { |
328 { |
339 SetActive(); |
329 SetActive(); |
340 } |
330 } |
341 |
331 |
342 // Update client's TRequestStatus object |
332 // Update client's TRequestStatus object |
343 *iClientStatus = KRequestPending; |
333 *iClientStatus = KRequestPending; |
344 } |
334 } |
345 |
335 |
346 void CUissClientHandler::CancelOperation() |
336 void CUissClientHandler::CancelOperation() |
347 { |
337 { |
348 if (iState == KUissClientIdle) |
338 if (iState == KUissClientIdle) |
349 { |
339 { |
350 return; |
340 return; |
351 } |
341 } |
352 |
342 |
353 // User called this so must have an outstanding request with us. |
343 // User called this so must have an outstanding request with us. |
354 |
344 |
355 // First tell the Uiss that we want to cancel the current |
345 // First tell the Uiss that we want to cancel the current |
356 // operation. |
346 // operation. |
357 // |
347 // |
358 // If we have an outstanding Uiss request, this will complete (with |
348 // If we have an outstanding Uiss request, this will complete (with |
359 // KErrCancel) when the operation has terminated. |
349 // KErrCancel) when the operation has terminated. |
360 // |
350 // |
361 // If we are called inside a dialog callback, then there is no |
351 // If we are called inside a dialog callback, then there is no |
362 // outstanding Uiss request at the moment. When the dialog |
352 // outstanding Uiss request at the moment. When the dialog |
363 // returns, we will issue a request, which will complete (with |
353 // returns, we will issue a request, which will complete (with |
364 // KErrCancel) when the operation has terminated. |
354 // KErrCancel) when the operation has terminated. |
365 (void)iUissSession.Cancel(); |
355 (void)iUissSession.Cancel(); |
366 } |
356 } |
367 |
357 |
368 void CUissClientHandler::WorkUntilCompleteL() |
358 void CUissClientHandler::WorkUntilCompleteL() |
369 { |
359 { |
370 // Keep processing UISS responses and issuing new requests |
360 // Keep processing UISS responses and issuing new requests |
371 // until we update the client status to non-pending. |
361 // until we update the client status to non-pending. |
372 while(iClientStatus && *iClientStatus == KRequestPending) |
362 while(iClientStatus && *iClientStatus == KRequestPending) |
373 { |
363 { |
374 User::WaitForRequest(iStatus); |
364 User::WaitForRequest(iStatus); |
375 TRAPD(err,RunL()); |
365 TRAPD(err,RunL()); |
376 if(err != KErrNone) |
366 if(err != KErrNone) |
377 { |
367 { |
378 RunError(err); |
368 RunError(err); |
379 } |
369 } |
380 } |
370 } |
381 } |
371 } |
382 |
372 |
383 TBool CUissClientHandler::IsBusy() |
373 TBool CUissClientHandler::IsBusy() |
384 { |
374 { |
385 return iState != KUissClientIdle; |
375 return iState != KUissClientIdle; |
386 } |
376 } |
387 |
377 |
388 |
378 |
389 // |
379 // |
390 // Code necessary to run UISS in the same process but in a different thread |
380 // Code necessary to run UISS in the same process but in a different thread |
391 // |
381 // |
392 TInt CUissClientHandler::StartUiss() |
382 TInt CUissClientHandler::StartUiss() |
393 { |
383 { |
394 const TInt KUissServerStackSize=0x2000; |
384 const TInt KUissServerStackSize=0x2000; |
395 const TInt KUissServerInitHeapSize=0x1000; |
385 const TInt KUissServerInitHeapSize=0x1000; |
396 const TInt KUissServerMaxHeapSize=0x1000000; |
386 const TInt KUissServerMaxHeapSize=0x1000000; |
397 |
387 |
398 |
388 |
399 TThreadFunction entryPoint=UissThreadFunction; |
389 TThreadFunction entryPoint=UissThreadFunction; |
400 //TUiSupportStartParams uiSupportParams(aUiHandler); |
390 //TUiSupportStartParams uiSupportParams(aUiHandler); |
401 // The owner of the new thread will be the process, otherwise if the |
391 // The owner of the new thread will be the process, otherwise if the |
402 // current thread dies, the server thread will die, too. |
392 // current thread dies, the server thread will die, too. |
403 RThread server; |
393 RThread server; |
404 TInt err = KErrNone; |
394 TInt err = KErrNone; |
405 |
395 |
406 for (TInt retry=0; retry < 2; ++retry) |
396 for (TInt retry=0; retry < 2; ++retry) |
407 { |
397 { |
408 err = server.Create(KUissServerName, entryPoint, |
398 err = server.Create(KUissServerName, entryPoint, |
409 KUissServerStackSize, KUissServerInitHeapSize, KUissServerMaxHeapSize, |
399 KUissServerStackSize, KUissServerInitHeapSize, KUissServerMaxHeapSize, |
410 NULL, EOwnerThread); |
400 NULL, EOwnerThread); |
411 |
401 |
412 if (err == KErrAlreadyExists) |
402 if (err == KErrAlreadyExists) |
413 { |
403 { |
414 User::After(30000); |
404 User::After(30000); |
415 } |
405 } |
416 else |
406 else |
417 { |
407 { |
418 break; |
408 break; |
419 } |
409 } |
420 } |
410 } |
421 |
411 |
422 if (err==KErrAlreadyExists) |
412 if (err==KErrAlreadyExists) |
423 { |
413 { |
424 return KErrServerBusy; |
414 return KErrServerBusy; |
425 } |
415 } |
426 if (err != KErrNone) |
416 if (err != KErrNone) |
427 { |
417 { |
428 return err; |
418 return err; |
429 } |
419 } |
430 |
420 |
431 // Synchronise with the process to make sure it hasn't died straight away |
421 // Synchronise with the process to make sure it hasn't died straight away |
432 TRequestStatus stat; |
422 TRequestStatus stat; |
433 server.Rendezvous(stat); |
423 server.Rendezvous(stat); |
434 if (stat != KRequestPending) |
424 if (stat != KRequestPending) |
435 { |
425 { |
436 // logon failed - server is not yet running, so cannot have terminated |
426 // logon failed - server is not yet running, so cannot have terminated |
437 server.Kill(0); // Abort startup |
427 server.Kill(0); // Abort startup |
438 } |
428 } |
439 else |
429 else |
440 { |
430 { |
441 // logon OK - start the server |
431 // logon OK - start the server |
442 server.Resume(); |
432 server.Resume(); |
443 } |
433 } |
444 // Wait to synchronise with server - if it dies in the meantime, it |
434 // Wait to synchronise with server - if it dies in the meantime, it |
445 // also gets completed |
435 // also gets completed |
446 User::WaitForRequest(stat); |
436 User::WaitForRequest(stat); |
447 // We can't use the 'exit reason' if the server panicked as this |
437 // We can't use the 'exit reason' if the server panicked as this |
448 // is the panic 'reason' and may be '0' which cannot be distinguished |
438 // is the panic 'reason' and may be '0' which cannot be distinguished |
449 // from KErrNone |
439 // from KErrNone |
450 TInt r=(server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int(); |
440 TInt r=(server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int(); |
451 server.Close(); |
441 server.Close(); |
452 return r; |
442 return r; |
453 } |
443 } |
454 |
444 |
455 // Entry point for the thread the UISS runs in |
445 // Entry point for the thread the UISS runs in |
456 TInt CUissClientHandler::UissThreadFunction(TAny *) |
446 TInt CUissClientHandler::UissThreadFunction(TAny *) |
457 { |
447 { |
458 __UHEAP_MARK; |
448 __UHEAP_MARK; |
459 CTrapCleanup* cleanup = CTrapCleanup::New(); // get clean-up stack |
449 CTrapCleanup* cleanup = CTrapCleanup::New(); // get clean-up stack |
460 |
450 |
461 CActiveScheduler* scheduler=new(ELeave) CActiveScheduler; |
451 CActiveScheduler* scheduler=new(ELeave) CActiveScheduler; |
462 CActiveScheduler::Install(scheduler); |
452 CActiveScheduler::Install(scheduler); |
463 CUissServer* server=NULL; |
453 CUissServer* server=NULL; |
464 |
454 |
465 TRAPD(err, server=CUissServer::NewL()); |
455 TRAPD(err, server=CUissServer::NewL()); |
466 if (err==KErrNone) |
456 if (err==KErrNone) |
467 { |
457 { |
468 RThread::Rendezvous(KErrNone); |
458 RThread::Rendezvous(KErrNone); |
469 scheduler->Start(); |
459 scheduler->Start(); |
470 } |
460 } |
471 |
461 |
472 delete server; |
462 delete server; |
473 |
463 |
474 CActiveScheduler::Install(NULL); |
464 CActiveScheduler::Install(NULL); |
475 delete scheduler; |
465 delete scheduler; |
476 delete cleanup; // destroy clean-up stack |
466 delete cleanup; // destroy clean-up stack |
477 __UHEAP_MARKEND; |
467 __UHEAP_MARKEND; |
478 return KErrNone; |
468 return KErrNone; |
479 } |
469 } |
480 |
470 |
481 void CUissClientHandler::RunL() |
471 void CUissClientHandler::RunL() |
482 { |
472 { |
483 TInt err = iStatus.Int(); |
473 TInt err = iStatus.Int(); |
484 iPtrIntoBuf.Set(iBuf->Des()); // Get ptr to our return buffer |
474 iPtrIntoBuf.Set(iBuf->Des()); // Get ptr to our return buffer |
485 |
475 |
486 DEBUG_PRINTF2(_L8("Sis Helper - UISS Client Handler, RunL(). Status: %d."), err); |
476 DEBUG_PRINTF2(_L8("Sis Helper - UISS Client Handler, RunL(). Status: %d."), err); |
487 if(err > 0) |
477 |
488 { |
478 |
489 // For Logging purpose, store the buffer to retrieve |
|
490 // application info later. |
|
491 delete iBufLogger; |
|
492 iBufLogger = 0; |
|
493 iBufLogger = iBuf->AllocL(); |
|
494 } |
|
495 |
|
496 if (err==KErrOverflow |
479 if (err==KErrOverflow |
497 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
480 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
498 && iState != KUissClientGettingCompInfo // We don't support overflow management for component info |
481 && iState != KUissClientGettingCompInfo // We don't support overflow management for component info |
499 #endif |
482 #endif |
500 ) |
483 ) |
501 { |
484 { |
502 // Grow the respective buffer buffer and re-issue "request". |
485 // Grow the respective buffer buffer and re-issue "request". |
503 // There should now be space for the UISS server to copy in its dialogue message. |
486 // There should now be space for the UISS server to copy in its dialogue message. |
504 HandleOverflowL(); |
487 HandleOverflowL(); |
505 iPtrIntoBuf.Set(iBuf->Des()); |
488 iPtrIntoBuf.Set(iBuf->Des()); |
506 iUissSession.BufferReallocated(iPtrIntoBuf, iStatus); |
489 iUissSession.BufferReallocated(iPtrIntoBuf, iStatus); |
507 |
490 |
508 if (iActiveObjectMode) |
491 if (iActiveObjectMode) |
509 { |
492 { |
510 SetActive(); |
493 SetActive(); |
511 } |
494 } |
512 return; |
495 return; |
513 } |
496 } |
514 else |
497 else |
515 { |
498 { |
516 if (err>CUissSession::KMsgSeparatorMinimumSwisMessage && |
499 if (err>CUissSession::KMsgSeparatorMinimumSwisMessage && |
517 err<CUissSession::KMsgSeparatorMaximumSwisMessage) |
500 err<CUissSession::KMsgSeparatorMaximumSwisMessage) |
518 { |
501 { |
519 // this is a dialog request, unmarshal parameters and display |
502 // this is a dialog request, unmarshal parameters and display |
520 // the dialog |
503 // the dialog |
521 CUissCmdHandler* cmdHandler=UissCmdHandlerFactoryL(err); |
504 CUissCmdHandler* cmdHandler=UissCmdHandlerFactoryL(err); |
522 if (!cmdHandler) |
505 if (!cmdHandler) |
523 { |
506 { |
524 User::Leave(KErrNotSupported); |
507 User::Leave(KErrNotSupported); |
525 } |
508 } |
526 |
|
527 CleanupStack::PushL(cmdHandler); |
|
528 // Note that the callback might call CancelOperation which |
|
529 // would update iState... |
|
530 cmdHandler->HandleMessageL(iPtrIntoBuf, iPtrIntoBuf); |
|
531 CleanupStack::PopAndDestroy(cmdHandler); |
|
532 } |
|
533 else |
|
534 { |
|
535 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
536 // Request has been completed successfully. So, now construct the |
|
537 // component info from the buffer which is populated from the SWI server. |
|
538 if (err == KErrNone && iState == KUissClientGettingCompInfo) |
|
539 { |
|
540 ConstructCompInfoFromBufferL(); |
|
541 } |
|
542 #endif |
|
543 // Either KErrNone or some sort of error status - in any case the processing has finished |
|
544 iState = KUissClientIdle; |
|
545 } |
|
546 } |
|
547 |
|
548 // Re-issue request, if we are still installing/uninstalling |
|
549 switch(iState) |
|
550 { |
|
551 case KUissClientInstalling: |
|
552 case KUissClientUninstalling: |
|
553 iUissSession.CompleteDialog(KErrNone, iPtrIntoBuf, iStatus); |
|
554 if (iActiveObjectMode) |
|
555 { |
|
556 SetActive(); |
|
557 } |
|
558 return; |
|
559 |
|
560 case KUissClientIdle: |
|
561 // All done, or failed... |
|
562 delete iArgsStream; |
|
563 iArgsStream = 0; |
|
564 //Wait for the death of SisHelper |
|
565 WaitForSisHelperShutdown(); |
|
566 // Complete user request (also sets iClientStatus to 0) |
|
567 ASSERT(iClientStatus); |
|
568 User::RequestComplete(iClientStatus, err); |
|
569 |
|
570 // Logging the error to a file |
|
571 // Temporary solution, should be removed once instrumentation is fully operational. |
|
572 if(err != KErrNone) |
|
573 { |
|
574 TRAP_IGNORE( |
|
575 RDesReadStream readStream(iBufLogger->Des()); |
|
576 CleanupClosePushL(readStream); |
|
577 |
509 |
578 //Retrieve package name. |
510 CleanupStack::PushL(cmdHandler); |
579 CAppInfo* appInfo=CAppInfo::NewLC(readStream); |
511 // Note that the callback might call CancelOperation which |
580 LogSwiErrorsToFileL(err, appInfo->AppName()); |
512 // would update iState... |
581 |
513 cmdHandler->HandleMessageL(iPtrIntoBuf, iPtrIntoBuf); |
582 CleanupStack::PopAndDestroy(2, &readStream); |
514 CleanupStack::PopAndDestroy(cmdHandler); |
583 ); |
515 } |
584 } |
516 else |
585 return; |
517 { |
586 } |
518 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
587 ASSERT(false); |
519 // Request has been completed successfully. So, now construct the |
|
520 // component info from the buffer which is populated from the SWI server. |
|
521 if (err == KErrNone && iState == KUissClientGettingCompInfo) |
|
522 { |
|
523 ConstructCompInfoFromBufferL(); |
|
524 } |
|
525 #endif |
|
526 // Either KErrNone or some sort of error status - in any case the processing has finished |
|
527 iState = KUissClientIdle; |
|
528 } |
|
529 } |
|
530 |
|
531 // Re-issue request, if we are still installing/uninstalling |
|
532 switch(iState) |
|
533 { |
|
534 case KUissClientInstalling: |
|
535 case KUissClientUninstalling: |
|
536 iUissSession.CompleteDialog(KErrNone, iPtrIntoBuf, iStatus); |
|
537 if (iActiveObjectMode) |
|
538 { |
|
539 SetActive(); |
|
540 } |
|
541 return; |
|
542 |
|
543 case KUissClientIdle: |
|
544 // All done, or failed... |
|
545 delete iArgsStream; |
|
546 iArgsStream = 0; |
|
547 //Wait for the death of SisHelper |
|
548 WaitForSisHelperShutdown(); |
|
549 // Complete user request (also sets iClientStatus to 0) |
|
550 ASSERT(iClientStatus); |
|
551 User::RequestComplete(iClientStatus, err); |
|
552 return; |
|
553 } |
|
554 ASSERT(false); |
588 } |
555 } |
589 |
556 |
590 |
557 |
591 TInt CUissClientHandler::RunError(TInt aError) |
558 TInt CUissClientHandler::RunError(TInt aError) |
592 { |
559 { |
593 DEBUG_PRINTF2(_L8("Sis Helper - UISS Client Handler, RunError. Error: %d."), aError); |
560 DEBUG_PRINTF2(_L8("Sis Helper - UISS Client Handler, RunError. Error: %d."), aError); |
594 // Pass failure code on to our client. |
561 // Pass failure code on to our client. |
595 iPtrIntoBuf.Zero(); |
562 iPtrIntoBuf.Zero(); |
596 iUissSession.CompleteDialog(aError, iPtrIntoBuf, iStatus); |
563 iUissSession.CompleteDialog(aError, iPtrIntoBuf, iStatus); |
597 if (iActiveObjectMode) |
564 if (iActiveObjectMode) |
598 { |
565 { |
599 SetActive(); |
566 SetActive(); |
600 } |
567 } |
601 return KErrNone; // Do not crash the CActiveScheduler. |
568 return KErrNone; // Do not crash the CActiveScheduler. |
602 } |
569 } |
603 |
570 |
604 void CUissClientHandler::DoCancel() |
571 void CUissClientHandler::DoCancel() |
605 { |
572 { |
606 DEBUG_PRINTF(_L8("Sis Helper - UISS Client Handler, Cancelling.")); |
573 DEBUG_PRINTF(_L8("Sis Helper - UISS Client Handler, Cancelling.")); |
607 |
574 |
611 // We can NOT simply call CancelOperation, because when we return |
578 // We can NOT simply call CancelOperation, because when we return |
612 // into the framework Cancel function it will block on our |
579 // into the framework Cancel function it will block on our |
613 // iStatus, which would stop the active scheduler and hence stop |
580 // iStatus, which would stop the active scheduler and hence stop |
614 // the CancelOperation from being actioned. |
581 // the CancelOperation from being actioned. |
615 |
582 |
616 // Do an emergency abort..... |
583 // Do an emergency abort..... |
617 |
584 |
618 // First kill our helper threads |
585 // First kill our helper threads |
619 |
586 |
620 // SIS helper thread/server |
587 // SIS helper thread/server |
621 CSisHelperServer::Abort(); |
588 CSisHelperServer::Abort(); |
622 |
589 |
623 // UI helper thread/server |
590 // UI helper thread/server |
624 TFullName fullName = RProcess().FullName(); |
591 TFullName fullName = RProcess().FullName(); |
625 fullName.Append(':'); |
592 fullName.Append(':'); |
626 fullName.Append(':'); |
593 fullName.Append(':'); |
627 fullName.Append(KUissServerName); |
594 fullName.Append(KUissServerName); |
628 |
595 |
629 RThread server; |
596 RThread server; |
630 TInt err = server.Open(fullName); |
597 TInt err = server.Open(fullName); |
631 if (err == KErrNone) |
598 if (err == KErrNone) |
632 { |
599 { |
633 server.Terminate(KErrAbort); |
600 server.Terminate(KErrAbort); |
634 server.Close(); |
601 server.Close(); |
635 } |
602 } |
636 |
603 |
637 // Now complete any client request |
604 // Now complete any client request |
638 if (iClientStatus) |
605 if (iClientStatus) |
639 { |
606 { |
640 User::RequestComplete(iClientStatus, err); |
607 User::RequestComplete(iClientStatus, err); |
641 } |
608 } |
642 } |
609 } |
643 |
610 |
644 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
611 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
645 void CUissClientHandler::ConstructCompInfoFromBufferL() |
612 void CUissClientHandler::ConstructCompInfoFromBufferL() |
646 { |
613 { |
647 // create a stream based on the buffer |
614 // create a stream based on the buffer |
648 RDesReadStream stream(*iCompInfoBuffer); |
615 RDesReadStream stream(*iCompInfoBuffer); |
649 CleanupClosePushL(stream); |
616 CleanupClosePushL(stream); |
650 |
617 |
651 CNativeComponentInfo* nativeCompInfo = CNativeComponentInfo::NewLC(); |
618 CNativeComponentInfo* nativeCompInfo = CNativeComponentInfo::NewLC(); |
652 nativeCompInfo->InternalizeL(stream); |
619 nativeCompInfo->InternalizeL(stream); |
653 |
620 |
654 // UISS and SWI cannot use Usif::CComponentInfo directly, as it is implemented in a non-TCB DLL. For this reason, a private structure maintained (CNativeComponentInfo), |
621 // UISS and SWI cannot use Usif::CComponentInfo directly, as it is implemented in a non-TCB DLL. For this reason, a private structure maintained (CNativeComponentInfo), |
655 // which is returned by SWI and is converted here to the CComponentInfo according to the USIF interface |
622 // which is returned by SWI and is converted here to the CComponentInfo according to the USIF interface |
656 Usif::CComponentInfo::CNode* rootNode = MapToComponentInfoL(*nativeCompInfo); |
623 Usif::CComponentInfo::CNode* rootNode = MapToComponentInfoL(*nativeCompInfo); |
657 iComponentInfo->SetRootNodeL(rootNode); |
624 iComponentInfo->SetRootNodeL(rootNode); |
658 |
625 |
659 CleanupStack::PopAndDestroy(nativeCompInfo); |
626 CleanupStack::PopAndDestroy(nativeCompInfo); |
660 CleanupStack::PopAndDestroy(&stream); |
627 CleanupStack::PopAndDestroy(&stream); |
661 } |
628 } |
662 |
629 |
|
630 void CUissClientHandler::MapToApplicationInfoL(RCPointerArray<Swi::CNativeComponentInfo::CNativeApplicationInfo>& aNativeApplicationsInfo, RPointerArray<Usif::CComponentInfo::CApplicationInfo>& aApplicationsInfo) |
|
631 { |
|
632 TInt count = aNativeApplicationsInfo.Count(); |
|
633 for (TInt i = 0; i < count; ++i) |
|
634 { |
|
635 Usif::CComponentInfo::CApplicationInfo* app ; |
|
636 app = Usif::CComponentInfo::CApplicationInfo::NewLC(aNativeApplicationsInfo[i]->AppUid(), aNativeApplicationsInfo[i]->Name(), aNativeApplicationsInfo[i]->GroupName(), aNativeApplicationsInfo[i]->IconFileName()); |
|
637 DEBUG_PRINTF2(_L("App Uid 0x%08x"),app->AppUid()); |
|
638 DEBUG_PRINTF2(_L("File Name %S"),&app->Name()); |
|
639 DEBUG_PRINTF2(_L("Group Name %S"),&app->GroupName()); |
|
640 DEBUG_PRINTF2(_L("Icon File Name %S"),&app->IconFileName()); |
|
641 aApplicationsInfo.AppendL(app); |
|
642 CleanupStack::Pop(app); |
|
643 } |
|
644 } |
|
645 |
663 Usif::CComponentInfo::CNode* CUissClientHandler::MapToComponentInfoL(CNativeComponentInfo& aNativeComponentInfo) |
646 Usif::CComponentInfo::CNode* CUissClientHandler::MapToComponentInfoL(CNativeComponentInfo& aNativeComponentInfo) |
664 { |
647 { |
665 // Create the array to store the children nodes. |
648 // Create the array to store the children nodes. |
666 RPointerArray<Usif::CComponentInfo::CNode> children; |
649 RPointerArray<Usif::CComponentInfo::CNode> children; |
667 CleanupResetAndDestroyPushL(children); |
650 CleanupResetAndDestroyPushL(children); |
668 |
651 |
669 // If there is any child for the current node, call this method with that child object. |
652 // If there is any child for the current node, call this method with that child object. |
670 // Continue this (recursively) until we get the leaf node in the embedded tree (with no children) |
653 // Continue this (recursively) until we get the leaf node in the embedded tree (with no children) |
671 // and add the resultant node as one of the children and pass it to create the parent node further. |
654 // and add the resultant node as one of the children and pass it to create the parent node further. |
672 TInt count = aNativeComponentInfo.iChildren.Count(); |
655 TInt count = aNativeComponentInfo.iChildren.Count(); |
673 for (TInt i = 0; i < count; ++i) |
656 for (TInt i = 0; i < count; ++i) |
674 { |
657 { |
675 Usif::CComponentInfo::CNode* node = MapToComponentInfoL(*aNativeComponentInfo.iChildren[i]); |
658 Usif::CComponentInfo::CNode* node = MapToComponentInfoL(*aNativeComponentInfo.iChildren[i]); |
676 CleanupStack::PushL(node); |
659 CleanupStack::PushL(node); |
677 children.AppendL(node); |
660 children.AppendL(node); |
678 CleanupStack::Pop(node); |
661 CleanupStack::Pop(node); |
679 } |
662 } |
680 |
663 |
681 // Create the CNode object using the appropriate parameters. |
664 RPointerArray<Usif::CComponentInfo::CApplicationInfo> applicationInfo; |
682 // children for leaf nodes (bottom most nodes in the embedded tree) will be null. |
665 CleanupResetAndDestroyPushL(applicationInfo); |
683 Usif::CComponentInfo::CNode* node = Usif::CComponentInfo::CNode::NewLC( |
666 MapToApplicationInfoL(aNativeComponentInfo.iApplications, applicationInfo); |
684 Usif::KSoftwareTypeNative(), |
667 // Create the CNode object using the appropriate parameters. |
685 *(aNativeComponentInfo.iComponentName), |
668 // children for leaf nodes (bottom most nodes in the embedded tree) will be null. |
686 *(aNativeComponentInfo.iVersion), |
669 Usif::CComponentInfo::CNode* node = Usif::CComponentInfo::CNode::NewLC( |
687 *(aNativeComponentInfo.iVendor), |
670 Usif::KSoftwareTypeNative(), |
688 static_cast<Usif::TScomoState>(aNativeComponentInfo.iScomoState), |
671 *(aNativeComponentInfo.iComponentName), |
689 static_cast<Usif::TInstallStatus>(aNativeComponentInfo.iInstallStatus), |
672 *(aNativeComponentInfo.iVersion), |
690 aNativeComponentInfo.iComponentId, |
673 *(aNativeComponentInfo.iVendor), |
691 *(aNativeComponentInfo.iGlobalComponentId), |
674 static_cast<Usif::TScomoState>(aNativeComponentInfo.iScomoState), |
692 static_cast<Usif::TAuthenticity>(aNativeComponentInfo.iAuthenticity), |
675 static_cast<Usif::TInstallStatus>(aNativeComponentInfo.iInstallStatus), |
693 aNativeComponentInfo.iUserGrantableCaps, |
676 aNativeComponentInfo.iComponentId, |
694 aNativeComponentInfo.iMaxInstalledSize, |
677 *(aNativeComponentInfo.iGlobalComponentId), |
695 aNativeComponentInfo.iHasExe, |
678 static_cast<Usif::TAuthenticity>(aNativeComponentInfo.iAuthenticity), |
696 &children); |
679 aNativeComponentInfo.iUserGrantableCaps, |
697 CleanupStack::Pop(node); |
680 aNativeComponentInfo.iMaxInstalledSize, |
698 CleanupStack::Pop(&children); |
681 aNativeComponentInfo.iHasExe, |
699 children.Close(); |
682 aNativeComponentInfo.iIsDriveSelectionRequired, |
700 return (node); |
683 &applicationInfo, |
701 } |
684 &children); |
|
685 CleanupStack::Pop(node); |
|
686 CleanupStack::Pop(&applicationInfo); |
|
687 applicationInfo.Close(); |
|
688 CleanupStack::Pop(&children); |
|
689 children.Close(); |
|
690 return (node); |
|
691 } |
702 #endif |
692 #endif |
703 |
|
704 |
|
705 void LogSwiErrorsToFileL(TInt aErrorCode, const TDesC& aAppName) |
|
706 { |
|
707 _LIT(KErrorString, "%S : Failed with %d"); |
|
708 _LIT(KLogFile, "c:\\data\\swilog.log"); |
|
709 |
|
710 //Format Output string |
|
711 HBufC* outputString = HBufC::NewLC(aAppName.Length()+ 30); |
|
712 outputString->Des().Format(KErrorString, &aAppName, aErrorCode); |
|
713 |
|
714 //Maximum number of log file entries. |
|
715 const TUint KLogFileSize = 10; |
|
716 |
|
717 RFs fs; |
|
718 User::LeaveIfError(fs.Connect()); |
|
719 CleanupClosePushL(fs); |
|
720 |
|
721 RFile logFile; |
|
722 TInt err = logFile.Open(fs, KLogFile, EFileWrite); |
|
723 if(err != KErrNone) |
|
724 { |
|
725 //Attempt to create the file. |
|
726 err = logFile.Create(fs, KLogFile, EFileWrite); |
|
727 User::LeaveIfError(err); |
|
728 } |
|
729 CleanupClosePushL(logFile); |
|
730 |
|
731 |
|
732 //Read the entire log file. |
|
733 RPointerArray<HBufC> linesArray; |
|
734 CleanupResetAndDestroyPushL(linesArray); |
|
735 |
|
736 TFileText logFileManipulator; |
|
737 logFileManipulator.Set(logFile); |
|
738 |
|
739 TBuf<200>buffer; |
|
740 err = logFileManipulator.Read(buffer); |
|
741 TInt count(0); |
|
742 while(err == KErrNone && ++count <= KLogFileSize) |
|
743 { |
|
744 HBufC* line = buffer.AllocLC(); |
|
745 linesArray.AppendL(line); |
|
746 CleanupStack::Pop(line); |
|
747 err = logFileManipulator.Read(buffer); |
|
748 } |
|
749 |
|
750 // If the log file contains less than KLogFileSize entries, |
|
751 // write the new log entry. |
|
752 if(count < KLogFileSize) |
|
753 { |
|
754 logFileManipulator.Seek(ESeekEnd); |
|
755 logFileManipulator.Write(*outputString); |
|
756 } |
|
757 else |
|
758 { |
|
759 // Contains KLogFileSize entries. |
|
760 // Replicate the last KLogFileSize - 1 entries and add the |
|
761 // new log at the end. |
|
762 logFile.Close(); |
|
763 logFile.Replace(fs, KLogFile, EFileWrite); |
|
764 logFileManipulator.Set(logFile); |
|
765 for(TInt i = linesArray.Count()- KLogFileSize +1; i<linesArray.Count(); ++i ) |
|
766 { |
|
767 logFileManipulator.Write(*linesArray[i]); |
|
768 } |
|
769 |
|
770 // New Entry. |
|
771 logFileManipulator.Write(*outputString); |
|
772 } |
|
773 logFile.Close(); |
|
774 CleanupStack::PopAndDestroy(4, outputString); |
|
775 } |
|
776 } // namespace Swi |
693 } // namespace Swi |