|
1 /* |
|
2 * Copyright (c) 2000 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: Implementation of applicationmanagement components |
|
15 * |
|
16 */ |
|
17 |
|
18 #define __INCLUDE_CAPABILITY_NAMES__ |
|
19 |
|
20 #include <e32svr.h> |
|
21 #include <badesca.h> |
|
22 #include <e32cmn.h> |
|
23 #include <bautils.h> |
|
24 #include <featmgr.h> |
|
25 #include <imcvcodc.h> |
|
26 #include <uikon.hrh> |
|
27 #include <e32property.h> |
|
28 #include "ApplicationManagementConst.h" |
|
29 #include "ampskeys.h" |
|
30 #include <SWInstDefs.h> |
|
31 #include "amprivateCRKeys.h" |
|
32 #include <PolicyEngineClient.h> |
|
33 #include <PolicyEngineXACML.h> |
|
34 #include <pathinfo.h> |
|
35 #include <driveinfo.h> |
|
36 |
|
37 #include "ApplicationManagementCommon.h" |
|
38 #include "ApplicationManagementClientServer.h" |
|
39 #include "ApplicationManagementServer.h" |
|
40 #include "AMDeploymentComponent.h" |
|
41 #include "amsmlhelper.h" |
|
42 #include "ApplicationManagementUtility.h" |
|
43 #include "ApplicationManagementUtilityFactory.h" |
|
44 |
|
45 #include "debug.h" |
|
46 |
|
47 #include "coemain.h" |
|
48 #include <aknnotewrappers.h> |
|
49 #include "SyncService.h" |
|
50 #include "AMPreInstallApp.h" |
|
51 #include <DevManInternalCRKeys.h> |
|
52 |
|
53 using namespace NApplicationManagement; |
|
54 |
|
55 #ifdef __AM_CONNECT_INSTALLER_ONSTARTUP_ |
|
56 |
|
57 #pragma message("AM Connecting installer at startup") |
|
58 #else |
|
59 #pragma message("AM Connecting installer when needed") |
|
60 #endif |
|
61 |
|
62 // Needed only for jad+jar installation |
|
63 _LIT( KInstallDir, "c:\\temp\\" ); |
|
64 _LIT8(KMIDletJarURL, "MIDlet-Jar-URL"); |
|
65 |
|
66 //OMA SCOMO Specific |
|
67 _LIT8(KDownloadState, "./SCOMO/Download/"); |
|
68 _LIT8(KDeliveredState, "./SCOMO/Inventory/Delivered/"); |
|
69 _LIT8(KDeployedState, "./SCOMO/Inventory/Deployed/"); |
|
70 |
|
71 // ------------------------------------------------------------------------------------------------ |
|
72 // CShutDown::CShutdown() |
|
73 // ------------------------------------------------------------------------------------------------ |
|
74 |
|
75 inline CShutdown::CShutdown() : |
|
76 CTimer(-1) |
|
77 { |
|
78 CActiveScheduler::Add(this); |
|
79 } |
|
80 |
|
81 // ------------------------------------------------------------------------------------------------ |
|
82 // CShutDown::ConstructL() |
|
83 // ------------------------------------------------------------------------------------------------ |
|
84 |
|
85 inline void CShutdown::ConstructL() |
|
86 { |
|
87 CTimer::ConstructL(); |
|
88 } |
|
89 |
|
90 // ------------------------------------------------------------------------------------------------ |
|
91 // CShutDown::Start() |
|
92 // ------------------------------------------------------------------------------------------------ |
|
93 |
|
94 inline void CShutdown::Start() |
|
95 { |
|
96 RDEBUG( "ApplicationManagementServer: starting shutdown timeout" ); |
|
97 After(KApplicationManagementShutdownDelay); |
|
98 } |
|
99 |
|
100 // ------------------------------------------------------------------------------------------------ |
|
101 // CShutDown::RunL() |
|
102 // ------------------------------------------------------------------------------------------------ |
|
103 |
|
104 void CShutdown::RunL() |
|
105 { |
|
106 RDEBUG( "ApplicationManagementServer timeout ... closing" ); |
|
107 CActiveScheduler::Stop(); |
|
108 } |
|
109 |
|
110 // ------------------------------------------------------------------------------------------------ |
|
111 // CShutDown::Start() |
|
112 // ------------------------------------------------------------------------------------------------ |
|
113 |
|
114 inline void CShutdown::Stop() |
|
115 { |
|
116 RDEBUG( "ApplicationManagementServer: Stop" ); |
|
117 CActiveScheduler::Stop(); |
|
118 } |
|
119 |
|
120 |
|
121 // ------------------------------------------------------------------------------------------------ |
|
122 // CApplicationManagementServer::CreateServiceL() |
|
123 // ------------------------------------------------------------------------------------------------ |
|
124 CApaAppServiceBase* CApplicationManagementServer::CreateServiceL( |
|
125 TUid aServiceType) const |
|
126 { |
|
127 RDEBUG( "ApplicationManagementServer CreateServiceL" ); |
|
128 if (aServiceType.iUid == KAMServiceUid) |
|
129 { |
|
130 return ((CApaAppServiceBase*) (new (ELeave) CApplicationManagementSession)); |
|
131 } |
|
132 else |
|
133 { |
|
134 return CAknAppServer::CreateServiceL(aServiceType); |
|
135 } |
|
136 } |
|
137 |
|
138 // ------------------------------------------------------------------------------------------------ |
|
139 // CApplicationManagementServer::SendServerToBackground() |
|
140 // ------------------------------------------------------------------------------------------------ |
|
141 |
|
142 void CApplicationManagementServer::SendServerToBackground() |
|
143 { |
|
144 |
|
145 RDEBUG( "ApplicationManagementServer SendServerToBackground - Start " ); |
|
146 TApaTaskList taskList(CEikonEnv::Static()->WsSession() ); |
|
147 TApaTask task = taskList.FindApp(TUid::Uid(KAppMgmtServerUid)); |
|
148 |
|
149 TInt id = CEikonEnv::Static()->RootWin().Identifier(); |
|
150 |
|
151 RDEBUG_2( "CApplicationManagementServer:::SendServerToBackground %d", id ); |
|
152 |
|
153 task.SetWgId(id); |
|
154 |
|
155 if (task.Exists()) |
|
156 { |
|
157 RDEBUG( "ApplicationManagementServer SendServerToBackground - Start 1" ); |
|
158 task.SendToBackground(); |
|
159 } |
|
160 RDEBUG( "ApplicationManagementServer SendServerToBackground - End " ); |
|
161 TInt amServerEnabled = 0; |
|
162 RProperty::Set(KUidPSApplicationManagementKeys, KAMServerUIEnabled, |
|
163 amServerEnabled); |
|
164 RDEBUG( "ApplicationManagementServer SendServerToBackground - End 2 " ); |
|
165 |
|
166 } |
|
167 |
|
168 // ------------------------------------------------------------------------------------------------ |
|
169 // CApplicationManagementServer::BringServertoForeground() |
|
170 // ------------------------------------------------------------------------------------------------ |
|
171 |
|
172 void CApplicationManagementServer::BringServertoForeground() |
|
173 { |
|
174 |
|
175 RDEBUG( "CApplicationManagementServer:::BringServertoForeground " ); |
|
176 TApaTaskList taskList(CEikonEnv::Static()->WsSession() ); |
|
177 TApaTask task = taskList.FindApp(TUid::Uid(KAppMgmtServerUid)); |
|
178 |
|
179 TInt id = CEikonEnv::Static()->RootWin().Identifier(); |
|
180 |
|
181 RDEBUG_2( "CApplicationManagementServer:::BringServertoForeground %d", id ); |
|
182 |
|
183 task.SetWgId(id); |
|
184 if (task.Exists()) |
|
185 { |
|
186 RDEBUG( "ApplicationManagementServer SendServerToBackground - BringServertoForeground " ); |
|
187 task.BringToForeground(); |
|
188 } |
|
189 } |
|
190 |
|
191 // ------------------------------------------------------------------------------------------------ |
|
192 // CApplicationManagementServer::BringServertoForeground() |
|
193 // ------------------------------------------------------------------------------------------------ |
|
194 |
|
195 void CApplicationManagementServer::BringDMUItoForeground() |
|
196 { |
|
197 RDEBUG( "ApplicationManagementServer DownloadComplete - DM UI Broughtto foreground Start " ); |
|
198 |
|
199 TApaTaskList taskList(CEikonEnv::Static()->WsSession() ); |
|
200 TApaTask task = taskList.FindApp(KPSUidNSmlDMSyncApp); |
|
201 |
|
202 const TInt id = task.WgId(); |
|
203 task.SetWgId(id); |
|
204 RDEBUG_2( "CApplicationManagementServer:::BringDMUItoForeground %d", id ); |
|
205 |
|
206 if (task.Exists()) |
|
207 { |
|
208 RDEBUG( "ApplicationManagementServer DownloadComplete - DM UI Broughtto foreground " ); |
|
209 task.BringToForeground(); |
|
210 } |
|
211 } |
|
212 |
|
213 // ------------------------------------------------------------------------------------------------ |
|
214 // CApplicationManagementServer::ComponentDownloadComplete() |
|
215 // ------------------------------------------------------------------------------------------------ |
|
216 |
|
217 void CApplicationManagementServer::ComponentDownloadComplete( |
|
218 CDeploymentComponent *aComponent, TInt iapid, HBufC8 *aServerId) |
|
219 { |
|
220 TInt err = KErrNone; |
|
221 TRAP( err, DownloadCompleteL( aComponent, iapid, aServerId )); |
|
222 } |
|
223 |
|
224 // ------------------------------------------------------------------------------------------------ |
|
225 // CApplicationManagementServer::DownloadCompleteL() |
|
226 // ------------------------------------------------------------------------------------------------ |
|
227 |
|
228 void CApplicationManagementServer::DownloadCompleteL( |
|
229 CDeploymentComponent *aComponent, TInt iapid, HBufC8 *aServerId) |
|
230 { |
|
231 RDEBUG( "ApplicationManagementServer DownloadComplete - start" ); |
|
232 __ASSERT_DEBUG( aComponent, User::Invariant() ); |
|
233 iStorage->UpdateL( *aComponent); |
|
234 TInt errdownload = KErrNone; |
|
235 TInt errInstall = KErrNone; |
|
236 TInt status = KStatusSuccess; |
|
237 if ( !aComponent->DownloadFailed() ) |
|
238 { |
|
239 CDeploymentComponent *old = DoDataUpdateCheckL( *aComponent); |
|
240 TDownloadTarget trgt = aComponent->DownloadTarget(); |
|
241 switch (trgt) |
|
242 { |
|
243 case EDeliver: |
|
244 { |
|
245 break; |
|
246 } |
|
247 case EInstall: |
|
248 case EInstallAndActivate: |
|
249 { |
|
250 TRAP(errInstall,DoTheInstallL( *aComponent)); |
|
251 if (trgt == EInstall && errInstall == KErrNone) |
|
252 { |
|
253 iStorage->DeactivateL( *aComponent); |
|
254 } |
|
255 /* to avoid duplicates in deployed tree if user delivered upgrade package |
|
256 * by using "Install/InstallActivate" operation. if upgrade package is delivered |
|
257 * by Update/UpdateandActivate" , this been handled in next switch case |
|
258 */ |
|
259 |
|
260 break; |
|
261 } |
|
262 |
|
263 case EUpdate: |
|
264 case EUpdateAndActivate: |
|
265 { |
|
266 if (old) |
|
267 { |
|
268 FullUpdateL( *aComponent, *old); |
|
269 if (trgt == EUpdate) |
|
270 { |
|
271 iStorage->DeactivateL( *aComponent); |
|
272 } |
|
273 } |
|
274 break; |
|
275 } |
|
276 default: |
|
277 { |
|
278 break; |
|
279 } |
|
280 } |
|
281 |
|
282 } |
|
283 else |
|
284 { |
|
285 errdownload = aComponent->DownloadStatus(); |
|
286 } |
|
287 |
|
288 RDEBUG( "ApplicationManagementServer DownloadComplete - Start Send to background" ); |
|
289 //Download Completed/ Failed or installation success/ failure Send server to Background. |
|
290 |
|
291 SendServerToBackground(); |
|
292 |
|
293 // Bring DM UI to foreground provided operation is in non silent mode. |
|
294 TInt operNonSilent = KErrNotFound; |
|
295 |
|
296 RProperty::Get(KUidPSApplicationManagementKeys, KAMOperationNonSilent, |
|
297 operNonSilent); |
|
298 |
|
299 if (operNonSilent==1 || operNonSilent==KErrNotFound) |
|
300 { |
|
301 RDEBUG( "ApplicationManagementServer DownloadComplete - DM UI Bring " ); |
|
302 BringDMUItoForeground(); |
|
303 } |
|
304 |
|
305 iOMASCOMOEnabled = IsOMASCOMOEnabledL(); |
|
306 |
|
307 |
|
308 if (iOMASCOMOEnabled) |
|
309 { |
|
310 |
|
311 |
|
312 status = GetErrorStatus(errdownload,errInstall); |
|
313 |
|
314 TInt ASyncSupported = -1; |
|
315 |
|
316 CRepository *repository = CRepository::NewLC( KUidPSApplicationManagementKeys ); |
|
317 repository->Get(KAsyncEnabled, ASyncSupported); |
|
318 CleanupStack::PopAndDestroy(); |
|
319 |
|
320 // For Sync Reporting |
|
321 if (!ASyncSupported) |
|
322 { |
|
323 |
|
324 // Update Central Repository with proper error code for Sync |
|
325 |
|
326 |
|
327 CRepository *repository= CRepository::NewLC ( KUidPSApplicationManagementKeys ) ; |
|
328 repository->Set(KAMSyncStatus, status); |
|
329 CleanupStack::PopAndDestroy(); |
|
330 |
|
331 RProperty counter; |
|
332 |
|
333 TInt r=counter.Attach(KUidPSApplicationManagementKeys, |
|
334 KSyncNotifier, EOwnerThread); |
|
335 User::LeaveIfError(r); |
|
336 |
|
337 TInt err = counter.Set(KErrCancel); |
|
338 User::LeaveIfError(err); |
|
339 counter.Close(); |
|
340 |
|
341 } |
|
342 else// Do AsyncReporting |
|
343 { |
|
344 |
|
345 // Get deployement component entries |
|
346 TInt internalid = aComponent->InternalId(); |
|
347 |
|
348 TBuf8<256> targetURI; |
|
349 |
|
350 TDeploymentComponentState state = aComponent->State(); |
|
351 |
|
352 if (state == EDCSDownload) |
|
353 { |
|
354 targetURI.Append(KDownloadState); |
|
355 targetURI.Append(aComponent->UserId()); |
|
356 } |
|
357 else |
|
358 if (state == EDCSDelivered) |
|
359 { |
|
360 targetURI.Append(KDeliveredState); |
|
361 targetURI.Append(aComponent->UserId()); |
|
362 |
|
363 } |
|
364 else |
|
365 if (state == EDCSActive|| state == EDCSInactive) |
|
366 { |
|
367 targetURI.Append(KDeployedState); |
|
368 targetURI.Append(aComponent->UserId()); |
|
369 } |
|
370 |
|
371 //Save Entry to database with status and target URI of deployment component |
|
372 |
|
373 TInt index; |
|
374 iAMServerDB->SaveToDatabaseL(index, internalid, status, |
|
375 targetURI, iapid); |
|
376 |
|
377 EnableDMNetworkMonL(iapid, aServerId); |
|
378 } |
|
379 |
|
380 } |
|
381 if (iDownloadMngr->DownloadCount() == 0) |
|
382 { |
|
383 |
|
384 RDEBUG_2( "CApplicationManagementServer::ConstructL - ERROR leaving cannot connect installer: %d", iSessionCount ); |
|
385 |
|
386 // Is session count is not modified whenever there is error then at the end of download complete decrement |
|
387 // the session count. |
|
388 |
|
389 if(status != KStatusSuccess && iSessionCount != 0 ) |
|
390 { |
|
391 iSessionCount--; |
|
392 } |
|
393 |
|
394 if (iSessionCount == 0) |
|
395 { |
|
396 iShutdown.Stop(); |
|
397 } |
|
398 } |
|
399 |
|
400 RDEBUG( "ApplicationManagementServer DownloadComplete - end" ); |
|
401 } |
|
402 |
|
403 // ------------------------------------------------------------------------------------------------ |
|
404 // CApplicationManagementServer::IsOMASCOMOEnabledL() |
|
405 // ------------------------------------------------------------------------------------------------ |
|
406 |
|
407 TBool CApplicationManagementServer::IsOMASCOMOEnabledL() |
|
408 { |
|
409 TInt adapterValue; |
|
410 |
|
411 CRepository *repository = CRepository::NewLC ( KCRUidPrivateApplicationManagementKeys ) ; |
|
412 repository->Get(KAMAdapterValue, adapterValue); |
|
413 CleanupStack::PopAndDestroy(); |
|
414 |
|
415 if(adapterValue ==0 || adapterValue == 1) |
|
416 return EFalse; |
|
417 else |
|
418 return ETrue; |
|
419 |
|
420 } |
|
421 |
|
422 // ------------------------------------------------------------------------------------------------ |
|
423 // CApplicationManagementServer::GetErrorStatus() |
|
424 // ------------------------------------------------------------------------------------------------ |
|
425 TInt CApplicationManagementServer::GetErrorStatus(TInt aErrorDownload, TInt aErrorInstall) |
|
426 { |
|
427 TInt status = KStatusSuccess; |
|
428 |
|
429 if (aErrorDownload!=KErrNone) |
|
430 { |
|
431 if (aErrorDownload == KStatusUserCancelled || aErrorDownload |
|
432 == KStatusDowloadFailedOOM || aErrorDownload |
|
433 == KStatusUnSupportedEnvironment || aErrorDownload |
|
434 ==KStatusAlternateDownldAuthFail || aErrorDownload == KStatusAltDowldUnavailable) |
|
435 { |
|
436 status = aErrorDownload; |
|
437 } |
|
438 else |
|
439 status = KStatusDownloadFailed; |
|
440 } |
|
441 |
|
442 else |
|
443 if (aErrorInstall!=KErrNone) |
|
444 { |
|
445 if (aErrorInstall == SwiUI::KSWInstErrSecurityFailure) |
|
446 status = KStatusPkgValidationFailed; |
|
447 if (aErrorInstall == SwiUI::KSWInstErrInsufficientMemory) |
|
448 status = KStatusInstallFailedOOM; |
|
449 else |
|
450 status = KStatusInstallFailed; |
|
451 |
|
452 } |
|
453 |
|
454 return status; |
|
455 |
|
456 } |
|
457 |
|
458 |
|
459 // ------------------------------------------------------------------------------------------------ |
|
460 // CApplicationManagementServer::EnableDMNetworkMonL() |
|
461 // ------------------------------------------------------------------------------------------------ |
|
462 void CApplicationManagementServer::EnableDMNetworkMonL(TInt iapid, HBufC8 *aServerId) |
|
463 { |
|
464 TInt retryenabled = 1; |
|
465 _LIT( KNetMon,"\\dmnetworkmon.exe" ); |
|
466 |
|
467 // Enable DM Network Monitoring for retry of Generic alert in case of N/W loss |
|
468 |
|
469 CRepository *repository= CRepository::NewLC ( KCRUidDeviceManagementInternalKeys ); |
|
470 repository->Set(KDevManEnableDMNetworkMon, retryenabled); |
|
471 repository->Set(KDevManServerIdKey, *aServerId); |
|
472 repository->Set(KDevManIapIdKey, iapid); |
|
473 CleanupStack::PopAndDestroy(); |
|
474 |
|
475 // create NetMon EXE |
|
476 RProcess rp; |
|
477 TInt err = rp.Create(KNetMon,KNullDesC); |
|
478 User::LeaveIfError(err); |
|
479 TRequestStatus stat; |
|
480 rp.Rendezvous(stat); |
|
481 |
|
482 if (stat!=KRequestPending) |
|
483 rp.Kill(0); // abort startup |
|
484 else |
|
485 rp.Resume(); // logon OK - start the server |
|
486 TInt r=(rp.ExitType()==EExitPanic) ? KErrGeneral : stat.Int(); |
|
487 rp.Close(); |
|
488 |
|
489 |
|
490 } |
|
491 |
|
492 // ------------------------------------------------------------------------------------------------ |
|
493 // CApplicationManagementServer::CApplicationManagementServer |
|
494 // ------------------------------------------------------------------------------------------------ |
|
495 |
|
496 inline CApplicationManagementServer::CApplicationManagementServer() |
|
497 { |
|
498 } |
|
499 |
|
500 // ------------------------------------------------------------------------------------------------ |
|
501 // CApplicationManagementServer::AddSession() |
|
502 // ------------------------------------------------------------------------------------------------ |
|
503 |
|
504 void CApplicationManagementServer::AddSession() |
|
505 { |
|
506 // A new session is being created |
|
507 RDEBUG( "ApplicationManagementServer: CApplicationManagementServer::AddSession" ); |
|
508 ++iSessionCount; |
|
509 |
|
510 // Cancel the shutdown timer if it was running |
|
511 iShutdown.Cancel(); |
|
512 } |
|
513 |
|
514 // ------------------------------------------------------------------------------------------------ |
|
515 // CApplicationManagementServer::DropSession() |
|
516 // ------------------------------------------------------------------------------------------------ |
|
517 |
|
518 void CApplicationManagementServer::DropSession() |
|
519 { |
|
520 // A session is being destroyed |
|
521 RDEBUG( "ApplicationManagementServer: CApplicationManagementServer::DropSession" ); |
|
522 |
|
523 // Start the shutdown timer if it is the last session |
|
524 if ( --iSessionCount == 0) |
|
525 { |
|
526 if (iDownloadMngr->DownloadCount() > 0) |
|
527 { |
|
528 RDEBUG( "ApplicationManagementServer: CApplicationManagementServer::DropSession download in progress" ); |
|
529 } |
|
530 else |
|
531 { |
|
532 iShutdown.Start(); |
|
533 } |
|
534 } |
|
535 } |
|
536 |
|
537 // ----------------------------------------------------------------------------------------------------------- |
|
538 // CApplicationManagementServer::AddDownloadL( CDeploymentComponent *aComponent ) |
|
539 // ----------------------------------------------------------------------------------------------------------- |
|
540 |
|
541 void CApplicationManagementServer::AddDownloadL( |
|
542 CDeploymentComponent *aComponent) |
|
543 { |
|
544 __ASSERT_DEBUG( aComponent, User::Invariant() ); |
|
545 iDownloadMngr->AddDownloadL(aComponent); |
|
546 } |
|
547 |
|
548 // ------------------------------------------------------------------------------------------------ |
|
549 // CApplicationManagementServer::NewLC |
|
550 // ------------------------------------------------------------------------------------------------ |
|
551 |
|
552 CApplicationManagementServer* CApplicationManagementServer::NewL() |
|
553 { |
|
554 |
|
555 CApplicationManagementServer* self=new(ELeave) CApplicationManagementServer; |
|
556 |
|
557 return self; |
|
558 } |
|
559 |
|
560 // ------------------------------------------------------------------------------------------------ |
|
561 // CApplicationManagementServer::CreateServiceSecurityCheckL |
|
562 // ------------------------------------------------------------------------------------------------ |
|
563 |
|
564 CPolicyServer::TCustomResult CApplicationManagementServer::CreateServiceSecurityCheckL( |
|
565 TUid aServiceType, const RMessage2& aMsg, TInt& aAction, |
|
566 TSecurityInfo& aMissing) |
|
567 { |
|
568 TInt32 trustRange = EAddTrust; |
|
569 TInt32 performRFS = EPerformRfs; |
|
570 TInt32 last = ELast; |
|
571 |
|
572 if ( (aServiceType.iUid >= trustRange) |
|
573 && (aServiceType.iUid < performRFS )) |
|
574 { |
|
575 if (aMsg.HasCapability(TCapability(ECapabilityTrustedUI) ) ) |
|
576 { |
|
577 return CPolicyServer::EPass; |
|
578 } |
|
579 else |
|
580 { |
|
581 return CPolicyServer::EFail; |
|
582 } |
|
583 } |
|
584 |
|
585 else |
|
586 if ( (aServiceType.iUid >= performRFS) && (aServiceType.iUid < last)) |
|
587 |
|
588 { |
|
589 if (aMsg.HasCapability(TCapability(ECapabilityDiskAdmin)) |
|
590 && (aMsg.SecureId().iId == 0x101f9a02 )) |
|
591 { |
|
592 return CPolicyServer::EPass; |
|
593 } |
|
594 else |
|
595 { |
|
596 return CPolicyServer::EFail; |
|
597 } |
|
598 } |
|
599 |
|
600 else |
|
601 if (aServiceType.iUid == last) |
|
602 { |
|
603 return CPolicyServer::EFail; |
|
604 } |
|
605 |
|
606 else |
|
607 { |
|
608 return CAknAppServer::CreateServiceSecurityCheckL( |
|
609 aServiceType, aMsg, aAction, aMissing); |
|
610 } |
|
611 |
|
612 } |
|
613 |
|
614 // ------------------------------------------------------------------------------------------------ |
|
615 // CApplicationManagementServer::~CApplicationManagementServer |
|
616 // ------------------------------------------------------------------------------------------------ |
|
617 |
|
618 CApplicationManagementServer::~CApplicationManagementServer() |
|
619 { |
|
620 RDEBUG_3("CApplicationManagementServer::~CApplicationManagementServer 0x%X - 0x%X", reinterpret_cast<TUint>(this ), |
|
621 reinterpret_cast<TUint>(this)+sizeof( CApplicationManagementServer ) ); |
|
622 FeatureManager::UnInitializeLib(); |
|
623 iInstaller.Close(); |
|
624 delete iStorage; |
|
625 |
|
626 delete iUtility; |
|
627 delete iAMServerDB; |
|
628 |
|
629 RProperty::Delete(KUidPSApplicationManagementKeys, KAMServerUIEnabled); |
|
630 |
|
631 RProperty::Delete(KUidPSApplicationManagementKeys, KAMOperationNonSilent); |
|
632 |
|
633 RProperty::Delete(KUidPSApplicationManagementKeys, KSyncNotifier); |
|
634 |
|
635 RProperty::Delete(KUidPSApplicationManagementKeys, KDMUINotClosed); |
|
636 |
|
637 |
|
638 iInstallFile.Close(); |
|
639 iInstallRFs.Close(); |
|
640 |
|
641 delete iDownloadMngr; |
|
642 } |
|
643 |
|
644 // ------------------------------------------------------------------------------------------------ |
|
645 // CApplicationManagementServer::HandleAllClientsClosed |
|
646 // ------------------------------------------------------------------------------------------------ |
|
647 void CApplicationManagementServer::HandleAllClientsClosed() |
|
648 { |
|
649 // Do Nothing |
|
650 RDEBUG( "CApplicationManagementServer::HandleAllClientsClosed" ); |
|
651 } |
|
652 |
|
653 // ------------------------------------------------------------------------------------------------ |
|
654 // CApplicationManagementServer::ConstructL |
|
655 // ------------------------------------------------------------------------------------------------ |
|
656 |
|
657 void CApplicationManagementServer::ConstructL(const TDesC &aServerName) |
|
658 { |
|
659 |
|
660 // 2nd phase construction - ensure the timer and server objects are running |
|
661 RDEBUG( "CApplicationManagementServer::ConstructL - Start" ); |
|
662 |
|
663 iOMASCOMOEnabled = ETrue; |
|
664 |
|
665 CAknAppServer::ConstructL(aServerName); |
|
666 TRAPD( errf, FeatureManager::InitializeLibL() ) |
|
667 ; |
|
668 if (errf != KErrNone) |
|
669 { |
|
670 User::Leave(errf); |
|
671 } |
|
672 |
|
673 RDEBUG( "CApplicationManagementServer::ConstructL - start" ); |
|
674 |
|
675 iStorage = CDeliveryComponentStorage::NewL(); |
|
676 |
|
677 iUtility |
|
678 = ApplicationManagementUtilityFactory::CreateManagementUtilityL(); |
|
679 iDownloadMngr = CAMDownloadManager::NewL( *this); |
|
680 iAMServerDB = CAMDownloaddb::NewL(); |
|
681 |
|
682 // Define P&S Keys |
|
683 RProperty::Define(KUidPSApplicationManagementKeys, KAMServerUIEnabled, |
|
684 RProperty::EInt); |
|
685 |
|
686 RProperty::Define(KUidPSApplicationManagementKeys, KAMOperationNonSilent, |
|
687 RProperty::EInt); |
|
688 |
|
689 RProperty::Define(KUidPSApplicationManagementKeys, KSyncNotifier, |
|
690 RProperty::EInt); |
|
691 |
|
692 RProperty::Define(KUidPSApplicationManagementKeys, KDMUINotClosed, |
|
693 RProperty::EInt); |
|
694 |
|
695 RProperty syncproperty; |
|
696 |
|
697 //Ignore error status |
|
698 syncproperty.Attach(KUidPSApplicationManagementKeys, KSyncNotifier, |
|
699 EOwnerThread); |
|
700 syncproperty.Set(KErrNone); |
|
701 syncproperty.Close(); |
|
702 |
|
703 SendServerToBackground(); |
|
704 |
|
705 #ifdef __AM_CONNECT_INSTALLER_ONSTARTUP_ |
|
706 TInt err( iInstaller.Connect() ); |
|
707 if ( err != KErrNone ) |
|
708 { |
|
709 RDEBUG_2( "CApplicationManagementServer::ConstructL - ERROR leaving cannot connect installer: %d", err ); |
|
710 User::LeaveIfError( err ); |
|
711 } |
|
712 #endif |
|
713 RDEBUG( "CApplicationManagementServer::ConstructL - end" ); |
|
714 } |
|
715 |
|
716 // ------------------------------------------------------------------------------------------------ |
|
717 // CApplicationManagementServer::StartShutDownTimer() |
|
718 // ------------------------------------------------------------------------------------------------ |
|
719 |
|
720 void CApplicationManagementServer::StartShutDownTimerL() |
|
721 { |
|
722 |
|
723 RDEBUG( "CApplicationManagementServer::ConstructL - end" ); |
|
724 |
|
725 iShutdown.ConstructL(); |
|
726 // ensure that the server still exits even if the 1st client fails to connect |
|
727 iShutdown.Start(); |
|
728 |
|
729 RDEBUG( "CApplicationManagementServer::ConstructL - end" ); |
|
730 } |
|
731 |
|
732 // ------------------------------------------------------------------------------------------------ |
|
733 // CApplicationManagementServer::CustomSecurityCheckL() |
|
734 // ------------------------------------------------------------------------------------------------ |
|
735 |
|
736 CPolicyServer::TCustomResult CApplicationManagementServer::CustomSecurityCheckL( |
|
737 const RMessage2& /*aMsg*/, TInt& /*aAction*/, TSecurityInfo& /*aMissing*/) |
|
738 { |
|
739 return EPass; |
|
740 } |
|
741 |
|
742 // ------------------------------------------------------------------------------------------------ |
|
743 // CApplicationManagementServer::InstallCompleteL() |
|
744 // ------------------------------------------------------------------------------------------------ |
|
745 |
|
746 void CApplicationManagementServer::InstallCompleteL( |
|
747 const CDeploymentComponent& aCompo, const TBool &aInstallSuccess) |
|
748 { |
|
749 RDEBUG_2("CApplicationManagementServer::InstallCompleteL start (%d)", aInstallSuccess); |
|
750 iInstallFile.Close(); |
|
751 |
|
752 // if java jad + jar install, remove files from c:\temp directory |
|
753 if (CDeploymentComponent::IsJavaMimeL(aCompo.MetaData().MimeType() ) && CDeploymentComponent::IsJavaMimeL(aCompo.Data().MimeType() ) ) |
|
754 { |
|
755 TFileName fn, fn2; |
|
756 GenerateTempFileNameL(iInstallRFs, aCompo, fn, fn2); |
|
757 RDEBUG_3("CApplicationManagementServer::InstallCompleteL delete files: (%S) (%S)", &fn, &fn2); |
|
758 User::LeaveIfError(iInstallRFs.Delete(fn) ); |
|
759 User::LeaveIfError(iInstallRFs.Delete(fn2) ); |
|
760 } |
|
761 |
|
762 if (aInstallSuccess) |
|
763 { |
|
764 // Remove temporary files from private directory |
|
765 const_cast<CDeploymentComponent&>(aCompo).ResetDataL(iInstallRFs); |
|
766 } |
|
767 |
|
768 iInstallRFs.Close(); |
|
769 |
|
770 iInstallInProgress = EFalse; |
|
771 #ifndef __AM_CONNECT_INSTALLER_ONSTARTUP_ |
|
772 iInstaller.Close() ; |
|
773 #endif |
|
774 RDEBUG("CApplicationManagementServer::InstallCompleteL end"); |
|
775 } |
|
776 |
|
777 // ------------------------------------------------------------------------------------------------ |
|
778 // CApplicationManagementServer::GenerateTempJarFileNameL() |
|
779 // ------------------------------------------------------------------------------------------------ |
|
780 |
|
781 void CApplicationManagementServer::GenerateTempJarFileNameL(RFs &aFs, |
|
782 const TDesC& aMetaSource, TFileName &aFileName) const |
|
783 { |
|
784 if (aMetaSource != KNullDesC) |
|
785 { |
|
786 RFile file; |
|
787 User::LeaveIfError(file.Open(aFs, aMetaSource, EFileRead) ); |
|
788 CleanupClosePushL(file); |
|
789 TFileName temp; |
|
790 temp = ReadJarFileNameL(file); |
|
791 GenerateTempFileNameL(aFs, temp, aFileName); |
|
792 CleanupStack::PopAndDestroy( &file); |
|
793 } |
|
794 } |
|
795 |
|
796 // ------------------------------------------------------------------------------------------------ |
|
797 // CApplicationManagementServer::GenerateTempFileNameL() |
|
798 // ------------------------------------------------------------------------------------------------ |
|
799 |
|
800 void CApplicationManagementServer::GenerateTempFileNameL(const RFs &aFs, |
|
801 const TDesC& aSource, TFileName &aFileName) const |
|
802 { |
|
803 if (aSource != KNullDesC) |
|
804 { |
|
805 aFileName.Copy(KInstallDir); |
|
806 TParse p; |
|
807 User::LeaveIfError(aFs.Parse(aSource, p) ); |
|
808 aFileName.Append(p.NameAndExt() ); |
|
809 } |
|
810 } |
|
811 |
|
812 // ------------------------------------------------------------------------------------------------ |
|
813 // CApplicationManagementServer::GenerateTempFileNameL() |
|
814 // ------------------------------------------------------------------------------------------------ |
|
815 |
|
816 void CApplicationManagementServer::GenerateTempFileNameL(RFs &aFs, |
|
817 const CDeploymentComponent& aCompo, TFileName& aSource, |
|
818 TFileName &aMetaSource, TFileName &aFileName, |
|
819 TFileName &aMetaFileName) const |
|
820 { |
|
821 if ( !BaflUtils::FolderExists(aFs, KInstallDir) ) |
|
822 { |
|
823 aFs.MkDirAll(KInstallDir); |
|
824 } |
|
825 |
|
826 aMetaSource.Copy(aCompo.MetaData().DataFileName() ); |
|
827 GenerateTempFileNameL(aFs, aMetaSource, aMetaFileName); |
|
828 aSource.Copy(aCompo.Data().DataFileName() ); |
|
829 GenerateTempJarFileNameL(aFs, aMetaSource, aFileName); |
|
830 } |
|
831 |
|
832 // ------------------------------------------------------------------------------------------------ |
|
833 // CApplicationManagementServer::GenerateTempFileNameL() |
|
834 // ------------------------------------------------------------------------------------------------ |
|
835 |
|
836 void CApplicationManagementServer::GenerateTempFileNameL(RFs &aFs, |
|
837 const CDeploymentComponent& aCompo, TFileName &aFileName, |
|
838 TFileName &aMetaFileName) const |
|
839 { |
|
840 TFileName ftemp, msource; |
|
841 GenerateTempFileNameL(aFs, aCompo, ftemp, msource, aFileName, |
|
842 aMetaFileName); |
|
843 } |
|
844 |
|
845 // ------------------------------------------------------------------------------------------------ |
|
846 // CApplicationManagementServer::ReadJarFileNameL() |
|
847 // ------------------------------------------------------------------------------------------------ |
|
848 |
|
849 TFileName CApplicationManagementServer::ReadJarFileNameL(RFile& aFile) const |
|
850 { |
|
851 TFileName jarFileName; |
|
852 HBufC8* lineBuffer = HBufC8::NewLC(KMaxFileName+72); // lets hope all lines fit to this |
|
853 TPtr8 linePtr(lineBuffer->Des() ); |
|
854 TInt length(0); |
|
855 aFile.Size(length); |
|
856 HBufC8* data = HBufC8::NewLC(length); |
|
857 TPtr8 ptr(data->Des() ); |
|
858 aFile.Read(ptr); |
|
859 RDesReadStream stream(*data); |
|
860 CleanupClosePushL(stream); |
|
861 TInt colonIndex = -1; |
|
862 TInt err(KErrNone); |
|
863 TInt found(KErrNotFound); |
|
864 const TInt KJadNameValueSeparator = 0x3A; //':' |
|
865 |
|
866 for (;;) |
|
867 { |
|
868 TRAP( err, ReadLineL(stream, linePtr) ); |
|
869 if (err == KErrNone) |
|
870 { |
|
871 RDEBUG8_2("Read line: (%S)", &linePtr); |
|
872 found = linePtr.Find(KMIDletJarURL); |
|
873 if (found != KErrNotFound && found == 0) // found |
|
874 { |
|
875 TPtrC8 filename(linePtr); |
|
876 colonIndex = linePtr.Locate(KJadNameValueSeparator); |
|
877 if (colonIndex != KErrNotFound) |
|
878 { |
|
879 filename.Set(linePtr.Mid(colonIndex+1)); // get jar filename, format is: MIDlet-Jar-URL: bomber.jar |
|
880 jarFileName.Copy(filename); |
|
881 jarFileName.Trim(); |
|
882 break; |
|
883 } |
|
884 } |
|
885 } |
|
886 else |
|
887 { |
|
888 User::Leave(err); |
|
889 } |
|
890 } |
|
891 CleanupStack::PopAndDestroy(3, lineBuffer); // stream, data |
|
892 return jarFileName; |
|
893 } |
|
894 |
|
895 // ------------------------------------------------------------------------------------------------ |
|
896 // CApplicationManagementServer::ReadLineL() |
|
897 // ------------------------------------------------------------------------------------------------ |
|
898 |
|
899 void CApplicationManagementServer::ReadLineL(RReadStream& aStream, |
|
900 TDes8& aLineBuffer) const |
|
901 { |
|
902 TBuf8<1> input; |
|
903 const TUint32 LF = 10; |
|
904 const TUint32 CR = 13; |
|
905 TBool endOfLine(EFalse); |
|
906 TInt errRead(KErrNone); |
|
907 |
|
908 // reset |
|
909 aLineBuffer.Zero(); |
|
910 |
|
911 while ( !endOfLine) |
|
912 { |
|
913 TRAP(errRead, aStream.ReadL(input, 1)); |
|
914 |
|
915 if (errRead == KErrEof) |
|
916 { |
|
917 // EOF |
|
918 User::Leave(KErrEof); |
|
919 } |
|
920 // check special characters |
|
921 if (input[0] == LF) |
|
922 { |
|
923 // End of line |
|
924 endOfLine = ETrue; |
|
925 } |
|
926 else |
|
927 if (input[0] == CR) |
|
928 { |
|
929 // Only end of line if not followed by a LF |
|
930 } |
|
931 else |
|
932 { |
|
933 // We put any other character in the buffer |
|
934 if (aLineBuffer.Length() < aLineBuffer.MaxLength()) |
|
935 { |
|
936 aLineBuffer.Append(input[0]); |
|
937 } |
|
938 } |
|
939 } |
|
940 } |
|
941 |
|
942 // ------------------------------------------------------------------------------------------------ |
|
943 // CApplicationManagementServer::PrepareInstallL() |
|
944 // ------------------------------------------------------------------------------------------------ |
|
945 |
|
946 TBool CApplicationManagementServer::PrepareInstallL( |
|
947 const CDeploymentComponent &aComponent, TFileName &aFileName) |
|
948 { |
|
949 RDEBUG( "CApplicationManagementServer::PrepareInstallL" ); |
|
950 TBool res(ETrue); |
|
951 |
|
952 #ifndef __AM_CONNECT_INSTALLER_ONSTARTUP_ |
|
953 TInt err(iInstaller.Connect() ); |
|
954 if (err != KErrNone) |
|
955 { |
|
956 RDEBUG_2( "CApplicationManagementServer::PrepareInstallL - ERROR leaving cannot connect installer: %d", err ); |
|
957 User::LeaveIfError(err); |
|
958 } |
|
959 CleanupClosePushL(iInstaller); |
|
960 #endif |
|
961 |
|
962 RDEBUG( "CApplicationManagementServer::PrepareInstallL - connected to installer" ); |
|
963 // Copy data file name (install file) |
|
964 if (aComponent.Data().DataFileName().Length() > 0) |
|
965 { |
|
966 aFileName.Copy(aComponent.Data().DataFileName() ); |
|
967 } |
|
968 else |
|
969 { |
|
970 // data file has not been created for component! |
|
971 User::Leave(KErrNotFound); |
|
972 } |
|
973 // Open RFs session |
|
974 User::LeaveIfError(iInstallRFs.Connect() ); |
|
975 User::LeaveIfError(iInstallRFs.ShareProtected() ); |
|
976 |
|
977 // set installoptions and correct mime type |
|
978 using namespace SwiUI; |
|
979 iInstallOptions = aComponent.InstallOpts().iOptions; |
|
980 TInstallReq req; |
|
981 if (aComponent.Data().MimeType() == SwiUI::KSisMimeType) |
|
982 { |
|
983 //convert if MIME type is application/vnd.symbian.install to x-epoc/x-sisx-app |
|
984 //as installer doesn't support application/vnd.symbian.install MIME type from S60 3rd edition onwards. |
|
985 req.iMIME = SwiUI::KSisxMimeType; |
|
986 } |
|
987 else |
|
988 { |
|
989 req.iMIME = aComponent.Data().MimeType(); |
|
990 } |
|
991 |
|
992 if (CDeploymentComponent::IsJavaMimeL(aComponent.MetaData().MimeType() ) ) { |
|
993 // Check if both jad and jar files already exist in the phone |
|
994 if (CDeploymentComponent::IsJavaMimeL(aComponent.Data().MimeType() ) && aComponent.MetaData().MimeType() == SwiUI::KJadMIMEType) { |
|
995 // Move both files to temporary location and use jad to install java application |
|
996 CFileMan *fm = CFileMan::NewL(iInstallRFs); |
|
997 CleanupStack::PushL(fm); |
|
998 TFileName source, metasource, metatarget; |
|
999 aFileName.Copy(KNullDesC8() ); // reset |
|
1000 GenerateTempFileNameL(iInstallRFs, aComponent, source, metasource, |
|
1001 aFileName, metatarget); |
|
1002 |
|
1003 RDEBUG_2( "CApplicationManagementServer::PrepareInstallL - temp jar file '%S'", &aFileName ); |
|
1004 RDEBUG_2( "CApplicationManagementServer::PrepareInstallL - temp jad file '%S'", &metatarget ); |
|
1005 |
|
1006 // Copy datafile (jar) |
|
1007 TInt copyer(fm->Copy(source, aFileName) ); |
|
1008 |
|
1009 // Copy metadatafile (jad) |
|
1010 TInt copyer2(fm->Copy(metasource, metatarget) ); |
|
1011 |
|
1012 CleanupStack::PopAndDestroy(fm); |
|
1013 |
|
1014 RDEBUG_3( "CApplicationManagementServer::PrepareInstallL - (%d)-(%d)", copyer, copyer2 ); |
|
1015 |
|
1016 if (copyer == KErrNone && copyer2 == KErrNone) |
|
1017 { |
|
1018 res = ETrue; |
|
1019 aFileName = metatarget; |
|
1020 req.iMIME = aComponent.MetaData().MimeType(); |
|
1021 } |
|
1022 else |
|
1023 { |
|
1024 User::Leave(KErrWrite); |
|
1025 } |
|
1026 } |
|
1027 else |
|
1028 if (aComponent.MetaData().MimeType() == SwiUI::KJadMIMEType) |
|
1029 { |
|
1030 aFileName.Copy(aComponent.MetaData().DataFileName() ); |
|
1031 req.iMIME = aComponent.MetaData().MimeType(); |
|
1032 RDEBUG_2( "CApplicationManagementServer::PrepareInstallL - Using Jad file to install java application: %S", &aFileName ); |
|
1033 } |
|
1034 } |
|
1035 |
|
1036 if (aComponent.GetIAP() > -1) |
|
1037 { |
|
1038 req.iIAP = aComponent.GetIAP(); |
|
1039 RDEBUG_2( "CApplicationManagementServer::PrepareInstallL: setting iap to %d", req.iIAP ); |
|
1040 } |
|
1041 else |
|
1042 { |
|
1043 TInt iap = KErrNotFound; |
|
1044 TRAPD( err, SmlHelper::GetDefaultIAPFromDMProfileL( iap ) ) |
|
1045 ; |
|
1046 if (err == KErrNone) |
|
1047 { |
|
1048 req.iIAP = iap; |
|
1049 RDEBUG_2(" -> using DM profile default IAP: %d", iap); |
|
1050 } |
|
1051 else |
|
1052 { |
|
1053 RDEBUG_2("**** ERROR while fetching DM profile default iap: %d", err ); |
|
1054 } |
|
1055 } |
|
1056 |
|
1057 iInstallReq = SwiUI::TInstallReqPckg(req); |
|
1058 RDEBUG8_2( "CApplicationManagementServer::PrepareInstallL: mime type is (%S)", &req.iMIME); |
|
1059 RDEBUG_2( "CApplicationManagementServer::PrepareInstallL - Using temp file '%S'", &aFileName ); |
|
1060 |
|
1061 User::LeaveIfError(iInstallFile.Open(iInstallRFs, aFileName, EFileRead) ); |
|
1062 TInt sz; |
|
1063 User::LeaveIfError(iInstallFile.Size(sz) ); |
|
1064 if ( !(sz > 0)) |
|
1065 { |
|
1066 res = EFalse; |
|
1067 RDEBUG( "CApplicationManagementServer::PrepareInstallL - ERROR size of source file is 0!" ); |
|
1068 } |
|
1069 |
|
1070 #ifndef __AM_CONNECT_INSTALLER_ONSTARTUP_ |
|
1071 CleanupStack::Pop( &iInstaller); |
|
1072 #endif |
|
1073 |
|
1074 RDEBUG( "CApplicationManagementServer::PrepareInstallL end" ); |
|
1075 return res; |
|
1076 } |
|
1077 |
|
1078 // ------------------------------------------------------------------------------------------------ |
|
1079 // CApplicationManagementServer::InstallL() |
|
1080 // ------------------------------------------------------------------------------------------------ |
|
1081 |
|
1082 void CApplicationManagementServer::InstallL( |
|
1083 const CDeploymentComponent &aComponent, TRequestStatus &aStatus) |
|
1084 { |
|
1085 RDEBUG( "CApplicationManagementServer::InstallL (async): begin" ); |
|
1086 |
|
1087 if (iInstallInProgress == EFalse) |
|
1088 { |
|
1089 TFileName fn; |
|
1090 if (PrepareInstallL(aComponent, fn) ) |
|
1091 { |
|
1092 RDEBUG_3( "CApplicationManagementServer::InstallL: Install '%S' sizeof opts: %d", &fn, sizeof (aComponent.InstallOpts())); |
|
1093 |
|
1094 // Silent or Non Silent Installation is choosen based on DM session started in silent or non silent |
|
1095 |
|
1096 TInt err = KErrNone; |
|
1097 TInt nonSilentOperation = KErrNotFound; |
|
1098 RProperty::Get(KUidPSApplicationManagementKeys, |
|
1099 KAMOperationNonSilent, nonSilentOperation); |
|
1100 |
|
1101 if (!nonSilentOperation) |
|
1102 { |
|
1103 TRAP( err ,iInstaller.SilentInstall( aStatus, iInstallFile, iInstallReq, iInstallOptions ) ); |
|
1104 } |
|
1105 else |
|
1106 { |
|
1107 TRAP( err ,iInstaller.Install( aStatus, iInstallFile, iInstallReq ) ); |
|
1108 } |
|
1109 |
|
1110 RDEBUG_2( "CApplicationManagementServer::InstallL: status: %d", err); |
|
1111 User::LeaveIfError(err); |
|
1112 iInstallInProgress = ETrue; |
|
1113 } |
|
1114 else |
|
1115 { |
|
1116 RDEBUG( "CApplicationManagementServer::InstallL - PrepareInstallL failed, leaving" ); |
|
1117 User::Leave(KErrArgument); |
|
1118 } |
|
1119 } |
|
1120 else |
|
1121 { |
|
1122 RDEBUG( "CApplicationManagementServer::InstallL (async): previous install still in progress...bailing out" ); |
|
1123 TRequestStatus * status = &aStatus; |
|
1124 User::RequestComplete(status, KErrInUse); |
|
1125 } |
|
1126 RDEBUG( "CApplicationManagementServer::InstallL (async): end" ); |
|
1127 } |
|
1128 |
|
1129 // ------------------------------------------------------------------------------------------------ |
|
1130 // CApplicationManagementServer::PrepareInstallL() |
|
1131 // ------------------------------------------------------------------------------------------------ |
|
1132 |
|
1133 void CApplicationManagementServer::InstallL( |
|
1134 const CDeploymentComponent &aComponent) |
|
1135 { |
|
1136 RDEBUG( "CApplicationManagementServer::InstallL: begin" ); |
|
1137 |
|
1138 if (iInstallInProgress == EFalse) |
|
1139 { |
|
1140 TFileName fn; |
|
1141 if (PrepareInstallL(aComponent, fn) ) |
|
1142 { |
|
1143 iInstallInProgress = ETrue; |
|
1144 RDEBUG_2( "CApplicationManagementServer::InstallL: Install '%S' ", &fn); |
|
1145 SwiUI::TInstallOptionsPckg pkg(aComponent.InstallOpts().iOptions); |
|
1146 TRAPD( err ,iInstaller.SilentInstall( fn, pkg ) ) |
|
1147 ; |
|
1148 User::LeaveIfError(err); |
|
1149 iInstallInProgress = EFalse; |
|
1150 } |
|
1151 else |
|
1152 { |
|
1153 RDEBUG( "CApplicationManagementServer::InstallL - PrepareInstallL failed, leaving" ); |
|
1154 User::Leave(KErrArgument); |
|
1155 } |
|
1156 } |
|
1157 RDEBUG( "CApplicationManagementServer::InstallL: end" ); |
|
1158 } |
|
1159 |
|
1160 // ------------------------------------------------------------------------------------------------ |
|
1161 // CApplicationManagementServer::UninstallL() |
|
1162 // ------------------------------------------------------------------------------------------------ |
|
1163 |
|
1164 void CApplicationManagementServer::UninstallL( |
|
1165 const CDeploymentComponent &aComponent, TRequestStatus &aStatus) |
|
1166 { |
|
1167 RDEBUG( "CApplicationManagementServer::UninstallL: begin" ); |
|
1168 if (iInstallInProgress == EFalse) |
|
1169 { |
|
1170 TInt err(iInstaller.Connect() ); |
|
1171 User::LeaveIfError(err); |
|
1172 RDEBUG_2( "CApplicationManagementServer::UninstallL: UninstallL '0x%X' ", aComponent.Uid()); |
|
1173 using namespace SwiUI; |
|
1174 iUninstallOptions = aComponent.UninstallOpts(); |
|
1175 |
|
1176 TInt nonSilentOperation = KErrNotFound; |
|
1177 |
|
1178 RProperty::Get(KPSUidNSmlDMSyncApp, KSilentSession, |
|
1179 nonSilentOperation); |
|
1180 |
|
1181 iOMASCOMOEnabled = IsOMASCOMOEnabledL(); |
|
1182 |
|
1183 if (!iOMASCOMOEnabled) |
|
1184 nonSilentOperation = 0; |
|
1185 if (!nonSilentOperation) |
|
1186 { |
|
1187 TRAP( err ,iInstaller.SilentUninstall( aStatus, aComponent.Uid(), |
|
1188 iUninstallOptions, aComponent.MimeType() ) ); |
|
1189 } |
|
1190 else |
|
1191 { |
|
1192 TRAP( err ,iInstaller.Uninstall( aStatus, aComponent.Uid(), aComponent.MimeType() ) ); |
|
1193 CSyncService *syncService = |
|
1194 CSyncService::NewL(NULL, KDevManServiceStart); |
|
1195 if (syncService) |
|
1196 { |
|
1197 syncService->EnableProgressNoteL(EFalse); |
|
1198 } |
|
1199 |
|
1200 delete syncService; |
|
1201 } |
|
1202 |
|
1203 RDEBUG_2( "CApplicationManagementServer::UninstallL: UninstallL result '0x%X'", err ); |
|
1204 User::LeaveIfError(err); |
|
1205 iInstallInProgress = ETrue; |
|
1206 } |
|
1207 else |
|
1208 { |
|
1209 RDEBUG( "CApplicationManagementServer::UninstallL: previous uninstall still in progress...bailing out" ); |
|
1210 TRequestStatus * status = &aStatus; |
|
1211 User::RequestComplete(status, KErrInUse); |
|
1212 } |
|
1213 |
|
1214 RDEBUG( "CApplicationManagementServer::UninstallL: end" ); |
|
1215 } |
|
1216 // ------------------------------------------------------------------------------------------------ |
|
1217 // CApplicationManagementServer::PerformRFSL() |
|
1218 // ------------------------------------------------------------------------------------------------ |
|
1219 |
|
1220 void CApplicationManagementServer::PerformRFSL() |
|
1221 { |
|
1222 RDEBUG( "CApplicationManagementServer::PerformRFSL: begin" ); |
|
1223 const RComponentIdArray &arrt = iStorage->GetComponentIds(); |
|
1224 TCertInfoPckg *corcert= NULL; |
|
1225 for (TInt i( 0); i < arrt.Count(); i++) |
|
1226 { |
|
1227 RDEBUG_3( "CApplicationManagementServer::PerformRFSL processing dc %d of %d", i, arrt.Count() ); |
|
1228 CDeploymentComponent &c = iStorage->ComponentL(arrt[i]); |
|
1229 |
|
1230 const RCertArray &certs = iStorage->Certificates(); |
|
1231 TInt index = c.Owner(); |
|
1232 TCertInfoPckg *certp = NULL; |
|
1233 if (index >= 0) |
|
1234 { |
|
1235 certp = certs[ c.Owner() ]; |
|
1236 } |
|
1237 if ( !corcert && certp) |
|
1238 { |
|
1239 if (CheckCertL( (*certp)() ) ) |
|
1240 { |
|
1241 corcert = certp; |
|
1242 RDEBUG_2( "CApplicationManagementServer::PerformRFSL Found CORP Cert! Removing %d ", i ); |
|
1243 RemoveInternalL(c); |
|
1244 } |
|
1245 else |
|
1246 { |
|
1247 RDEBUG_2( "CApplicationManagementServer::PerformRFSL skipping %d because not corp dc", i ); |
|
1248 } |
|
1249 } |
|
1250 else |
|
1251 { |
|
1252 if (corcert == certp) |
|
1253 { |
|
1254 RDEBUG_2( "CApplicationManagementServer::PerformRFSL Removing %d ", i ); |
|
1255 RemoveInternalL(c); |
|
1256 } |
|
1257 else |
|
1258 { |
|
1259 RDEBUG_2( "CApplicationManagementServer::PerformRFSL skipping %d because not corp dc", i ); |
|
1260 } |
|
1261 } |
|
1262 } |
|
1263 RDEBUG( "CApplicationManagementServer::PerformRFSL: end" ); |
|
1264 } |
|
1265 |
|
1266 // ------------------------------------------------------------------------------------------------ |
|
1267 // CApplicationManagementServer::RemoveInternalL() |
|
1268 // ------------------------------------------------------------------------------------------------ |
|
1269 |
|
1270 void CApplicationManagementServer::RemoveInternalL( |
|
1271 const CDeploymentComponent &aCompo, TBool aDoUninstall /* = ETrue */) |
|
1272 { |
|
1273 RDEBUG_2("CApplicationManagementServer: RemoveInternalL - Remove id: (%d)", aCompo.InternalId() ); |
|
1274 |
|
1275 aCompo.SetStatusNode(EDelivered_RemoveProgress); |
|
1276 TInt err(KErrNone); |
|
1277 TDeploymentComponentState st(aCompo.State() ); |
|
1278 if (st == EDCSDelivered || st == EDCSDownload) |
|
1279 { |
|
1280 TRAP(err,iStorage->RemoveL( aCompo.InternalId() )); |
|
1281 } |
|
1282 else |
|
1283 if (st == EDCSActive || st == EDCSInactive) |
|
1284 { |
|
1285 if (aDoUninstall) |
|
1286 { |
|
1287 if (aCompo.Uid() != TUid::Null() ) |
|
1288 { |
|
1289 //TInt err= KErrNone; |
|
1290 |
|
1291 TInt nonSilentOperation = KErrNotFound; |
|
1292 |
|
1293 RProperty::Get(KPSUidNSmlDMSyncApp, KSilentSession, |
|
1294 nonSilentOperation); |
|
1295 |
|
1296 iOMASCOMOEnabled = IsOMASCOMOEnabledL(); |
|
1297 |
|
1298 if (!iOMASCOMOEnabled) |
|
1299 nonSilentOperation = 0; |
|
1300 |
|
1301 if (nonSilentOperation!=0) |
|
1302 { |
|
1303 |
|
1304 BringServertoForeground(); |
|
1305 |
|
1306 TInt amServerEnabled = 1; |
|
1307 err = RProperty::Set(KUidPSApplicationManagementKeys, |
|
1308 KAMServerUIEnabled, amServerEnabled); |
|
1309 User::LeaveIfError(err); // invalid |
|
1310 |
|
1311 } |
|
1312 |
|
1313 TRequestStatus s; |
|
1314 TRAP(err,UninstallL( aCompo, s )); |
|
1315 User::WaitForRequest(s); |
|
1316 iInstallInProgress = EFalse; |
|
1317 // Capturing Installer errors,if any |
|
1318 err = s.Int(); |
|
1319 |
|
1320 TInt amServerEnabled = 0; |
|
1321 RProperty::Set(KUidPSApplicationManagementKeys, |
|
1322 KAMServerUIEnabled, amServerEnabled); |
|
1323 //User::LeaveIfError(err); // invalid |
|
1324 |
|
1325 SendServerToBackground(); |
|
1326 |
|
1327 // Bring DM UI to foreground |
|
1328 if (nonSilentOperation!=0) |
|
1329 { |
|
1330 BringDMUItoForeground(); |
|
1331 } |
|
1332 |
|
1333 if (s.Int() == KErrNone) |
|
1334 { |
|
1335 RDEBUG("CApplicationManagementServer::RemoveInternalL Uninstalled"); |
|
1336 } |
|
1337 else |
|
1338 if (s.Int() == KErrNotFound) |
|
1339 { |
|
1340 RDEBUG( "CApplicationManagementServer: RemoveInternalL WARNING component was not found by uninstaller" ); |
|
1341 } |
|
1342 else |
|
1343 { |
|
1344 RDEBUG_2("CApplicationManagementServer: RemoveInternalL ERROR uninstall failed %d", s.Int() ); |
|
1345 |
|
1346 } |
|
1347 } |
|
1348 else |
|
1349 { |
|
1350 RDEBUG( "CApplicationManagementServer: RemoveInternalL ERROR component is deployed but has null uid - it cannot be uninstalled!" ); |
|
1351 } |
|
1352 } |
|
1353 else |
|
1354 { |
|
1355 RDEBUG_2("CApplicationManagementServer: RemoveInternalL - Skipped uninstall of %d", aCompo.InternalId() ); |
|
1356 } |
|
1357 /* |
|
1358 * if (unstall is sucesss) then remove component from storage |
|
1359 * |
|
1360 */ |
|
1361 if (err == KErrNone) |
|
1362 { |
|
1363 iStorage->RemoveL(aCompo.InternalId() ); |
|
1364 } |
|
1365 } |
|
1366 else |
|
1367 { |
|
1368 RDEBUG_2("CApplicationManagementServer: RemoveInternalL ERROR called with illegal state component id %d", aCompo.State() ); |
|
1369 User::Leave(KErrArgument); |
|
1370 } |
|
1371 /* |
|
1372 * if error set state to remove failed |
|
1373 * Finally call userleaveiferror() |
|
1374 * */ |
|
1375 if (err != KErrNone) |
|
1376 { |
|
1377 aCompo.SetStatusNode(EDelivered_RemoveFailed); |
|
1378 } |
|
1379 User::LeaveIfError(err); |
|
1380 } |
|
1381 |
|
1382 // ------------------------------------------------------------------------------------------------ |
|
1383 // CApplicationManagementServer::CheckCertL() |
|
1384 // ------------------------------------------------------------------------------------------------ |
|
1385 |
|
1386 TBool CApplicationManagementServer::CheckCertL(const TCertInfo &aInfo) const |
|
1387 { |
|
1388 TBool go(EFalse); |
|
1389 |
|
1390 if (FeatureManager::FeatureSupported( KFeatureIdSapPolicyManagement) ) |
|
1391 { |
|
1392 // #ifdef __SAP_POLICY_MANAGEMENT |
|
1393 RPolicyEngine peng; |
|
1394 |
|
1395 // The management session |
|
1396 // |
|
1397 TInt err(peng.Connect() ); |
|
1398 |
|
1399 if (err == KErrNone) |
|
1400 { |
|
1401 CleanupClosePushL(peng); |
|
1402 RPolicyRequest rq; |
|
1403 err = rq.Open(peng) ; |
|
1404 if (err == KErrNone) |
|
1405 { |
|
1406 CleanupClosePushL(rq); |
|
1407 |
|
1408 TRequestContext rc; |
|
1409 |
|
1410 using namespace PolicyEngineXACML; |
|
1411 using namespace NPolicyConstants; |
|
1412 |
|
1413 rc.AddSubjectAttributeL(KTrustedSubject, aInfo); |
|
1414 rc.AddResourceAttributeL(KResourceId, KApplicationManagement, |
|
1415 KStringDataType); |
|
1416 |
|
1417 TResponse resp; |
|
1418 err = rq.MakeRequest(rc, resp); |
|
1419 if (err == KErrNone) |
|
1420 { |
|
1421 if (resp.GetResponseValue() == EResponsePermit |
|
1422 #ifdef _DEBUG |
|
1423 || resp.GetResponseValue() |
|
1424 == EResponseNotApplicable |
|
1425 #endif |
|
1426 ) |
|
1427 { |
|
1428 go = ETrue; |
|
1429 } |
|
1430 else |
|
1431 { |
|
1432 RDEBUG_2( "CApplicationManagementSession::CheckCertL; Policy response denies access! %d", resp.GetResponseValue()); |
|
1433 } |
|
1434 } |
|
1435 else |
|
1436 { |
|
1437 RDEBUG_2( "CApplicationManagementSession::CheckCertL; ERROR making policy request! %d", err); |
|
1438 } |
|
1439 CleanupStack::PopAndDestroy( &rq) ; |
|
1440 } |
|
1441 else |
|
1442 { |
|
1443 RDEBUG_2( "CApplicationManagementSession::CheckCertL; ERROR Failed to open policy engine session! %d", err); |
|
1444 } |
|
1445 CleanupStack::PopAndDestroy( &peng) ; |
|
1446 } |
|
1447 else |
|
1448 { |
|
1449 RDEBUG_2( "CApplicationManagementSession::CheckCertL; ERROR Failed to connect policy engine! %d", err); |
|
1450 } |
|
1451 User::LeaveIfError(err); |
|
1452 } |
|
1453 else |
|
1454 { |
|
1455 RDEBUG( "CApplicationManagementSession::CheckCertL; No PolicyManagement by featmgr-> cert ok!" ); |
|
1456 go = ETrue; |
|
1457 } |
|
1458 return go; |
|
1459 } |
|
1460 |
|
1461 // ------------------------------------------------------------------------------------------------ |
|
1462 // CApplicationManagementServer::HasUidL() |
|
1463 // ------------------------------------------------------------------------------------------------ |
|
1464 |
|
1465 TBool CApplicationManagementServer::HasUidL(const TUid &aUid, |
|
1466 CDeploymentComponent *& aCompo, CDeploymentComponent *aIgnored /* = NULL */) |
|
1467 { |
|
1468 TBool found(EFalse); |
|
1469 const RComponentIdArray &arrt = iStorage->GetComponentIds(); |
|
1470 TInt count(arrt.Count() ); |
|
1471 for (TInt i( 0); i < count; i++) |
|
1472 { |
|
1473 CDeploymentComponent &compo = iStorage->ComponentL(arrt[i]); |
|
1474 if (compo.Uid() == aUid) |
|
1475 { |
|
1476 if ( &compo != aIgnored) |
|
1477 { |
|
1478 aCompo = &compo; |
|
1479 found = ETrue; |
|
1480 RDEBUG_3( "ApplicationManagementServer: UidExistsL 0x%X - Found NOT ignored %d", aUid.iUid, compo.InternalId() ); |
|
1481 } |
|
1482 else |
|
1483 { |
|
1484 RDEBUG( "ApplicationManagementServer: UidExistsL - Found ignored " ); |
|
1485 } |
|
1486 } |
|
1487 } |
|
1488 if ( !found) |
|
1489 { |
|
1490 found = FindInstalledSisUidL(aUid); |
|
1491 if ( !found) |
|
1492 { |
|
1493 found = FindInstalledJavaUidL(aUid); |
|
1494 } |
|
1495 } |
|
1496 return found; |
|
1497 } |
|
1498 |
|
1499 // ------------------------------------------------------------------------------------------------ |
|
1500 // CApplicationManagementServer::FindInstalledSisUidL() |
|
1501 // ------------------------------------------------------------------------------------------------ |
|
1502 |
|
1503 TBool CApplicationManagementServer::FindInstalledSisUidL(const TUid &aUid) const |
|
1504 { |
|
1505 TBool found(EFalse); |
|
1506 Swi::RSisRegistrySession sisses; |
|
1507 TInt r(sisses.Connect() ); |
|
1508 User::LeaveIfError(r) ; |
|
1509 CleanupClosePushL(sisses); |
|
1510 |
|
1511 RArray<TUid> uids; |
|
1512 sisses.InstalledUidsL(uids); |
|
1513 CleanupClosePushL(uids); |
|
1514 |
|
1515 TInt uidc(uids.Count() ); |
|
1516 for (TInt j( 0); found == EFalse && j < uidc; j++) |
|
1517 { |
|
1518 if (uids[j] == aUid) |
|
1519 { |
|
1520 found = ETrue; |
|
1521 } |
|
1522 } |
|
1523 CleanupStack::PopAndDestroy( &uids); |
|
1524 CleanupStack::PopAndDestroy( &sisses); |
|
1525 |
|
1526 return found; |
|
1527 } |
|
1528 |
|
1529 // ------------------------------------------------------------------------------------------------ |
|
1530 // CApplicationManagementServer::FindInstalledJavaUidL() |
|
1531 // ------------------------------------------------------------------------------------------------ |
|
1532 |
|
1533 TBool CApplicationManagementServer::FindInstalledJavaUidL(const TUid &aUid) const |
|
1534 { |
|
1535 TBool found(EFalse); |
|
1536 iUtility->RefreshJavaRegistryL(); |
|
1537 found = iUtility->FindInstalledJavaUidL(aUid); |
|
1538 return found; |
|
1539 } |
|
1540 |
|
1541 // ------------------------------------------------------------------------------------------------ |
|
1542 // CApplicationManagementServer::FindNewUid() |
|
1543 // ------------------------------------------------------------------------------------------------ |
|
1544 |
|
1545 TUid CApplicationManagementServer::FindNewUid(const RArray<TUid> &aUidsOrig, |
|
1546 const RArray<TUid> &aUidsNew) const |
|
1547 { |
|
1548 TUid ret(TUid::Null() ); |
|
1549 TInt c1(aUidsOrig.Count() ); |
|
1550 TInt c2(aUidsNew.Count() ); |
|
1551 if (c2 >= c1) |
|
1552 { |
|
1553 for (TInt i(c2 - 1); i >= 0 && !ret.iUid; i--) |
|
1554 { |
|
1555 if (aUidsOrig.Find(aUidsNew[i]) == KErrNotFound) |
|
1556 { |
|
1557 ret = aUidsNew[i]; |
|
1558 } |
|
1559 |
|
1560 } |
|
1561 } |
|
1562 return ret; |
|
1563 } |
|
1564 |
|
1565 // ------------------------------------------------------------------------------------------------ |
|
1566 // CApplicationManagementServer::JavaUidsL() |
|
1567 // ------------------------------------------------------------------------------------------------ |
|
1568 |
|
1569 void CApplicationManagementServer::JavaUidsL(RArray<TUid> &aUids) const |
|
1570 { |
|
1571 iUtility->RefreshJavaRegistryL(); |
|
1572 iUtility->JavaUidsL(aUids); |
|
1573 } |
|
1574 |
|
1575 void CApplicationManagementServer::CheckforDuplicateMidletsL( |
|
1576 TMidletParameters& amidletParameters) |
|
1577 { |
|
1578 RDEBUG( "CApplicationManagementServer::CheckforDuplicateMidletsL: Start"); |
|
1579 const RComponentIdArray &arrt = iStorage->GetComponentIds(); |
|
1580 TInt cont(arrt.Count() ); |
|
1581 for (TInt i( 0); i < cont; i++) |
|
1582 { |
|
1583 CDeploymentComponent &compo = iStorage->ComponentL(arrt[i]); |
|
1584 if (((compo.State() == EDCSActive) || (compo.State() == EDCSInactive )) |
|
1585 && (compo.MidletName()== amidletParameters.iMidletName) |
|
1586 && (compo.MidletVendor()== amidletParameters.iMidletVenorName)) |
|
1587 { |
|
1588 //remove old one |
|
1589 iStorage->RemoveL(compo.InternalId() ); |
|
1590 } |
|
1591 } |
|
1592 |
|
1593 RDEBUG( "CApplicationManagementServer::CheckforDuplicateMidletsL: End"); |
|
1594 } |
|
1595 // ------------------------------------------------------------------------------------------------ |
|
1596 // CApplicationManagementServer::JavaInstallL() |
|
1597 // ------------------------------------------------------------------------------------------------ |
|
1598 |
|
1599 void CApplicationManagementServer::JavaInstallL(CDeploymentComponent &aCompo) |
|
1600 { |
|
1601 RDEBUG( "CApplicationManagementServer::JavaInstallL: Start"); |
|
1602 |
|
1603 TRequestStatus s; |
|
1604 TInt err(KErrNone); |
|
1605 // set state to install progress |
|
1606 aCompo.SetStatusNode(EDelivered_InstallProgress); |
|
1607 TRAP(err,InstallL( aCompo,s )); |
|
1608 if (err != KErrNone) |
|
1609 { |
|
1610 aCompo.SetStatusNode(EDelivered_InstalledFailedWithData); |
|
1611 User::Leave(err); |
|
1612 } |
|
1613 User::WaitForRequest(s); |
|
1614 SendServerToBackground(); |
|
1615 if (s != KErrNone) |
|
1616 { |
|
1617 RDEBUG_2( "ApplicationManagementSession: JavaInstallL failed with code %d", |
|
1618 s.Int() ); |
|
1619 // set state to install failed with data |
|
1620 aCompo.SetStatusNode(EDelivered_InstalledFailedWithData); |
|
1621 User::Leave(s.Int() ); |
|
1622 } |
|
1623 else |
|
1624 { |
|
1625 TMidletParameters midletParameters; |
|
1626 iUtility->RefreshJavaRegistryL(); |
|
1627 //Ignore if any error comes |
|
1628 TRAPD(err,iUtility->GetInstalledMidletParametersL(midletParameters)) |
|
1629 ; |
|
1630 TRAP(err,CheckforDuplicateMidletsL(midletParameters)); |
|
1631 |
|
1632 if (err != KErrNone) |
|
1633 { |
|
1634 aCompo.SetStatusNode(EDelivered_InstalledFailedWithData); |
|
1635 User::Leave(err); |
|
1636 } |
|
1637 else |
|
1638 { |
|
1639 aCompo.SetStatusNode(EIdle); |
|
1640 } |
|
1641 aCompo.SetUid(midletParameters.iMidletUid); |
|
1642 |
|
1643 RDEBUG( "CApplicationManagementServer::JavaInstallL: Step1"); |
|
1644 if (aCompo.ComponentVersion() == KNullDesC8) |
|
1645 { |
|
1646 aCompo.SetVersionL(midletParameters.bufVersion); |
|
1647 |
|
1648 } |
|
1649 |
|
1650 TBool status = EFalse; |
|
1651 |
|
1652 //Since "C" drive is not removable |
|
1653 |
|
1654 if (midletParameters.iDrive!=EDriveC) |
|
1655 { |
|
1656 status = IsInstalledAppRemovableL(midletParameters.iDrive); |
|
1657 } |
|
1658 if (status) |
|
1659 { |
|
1660 RDEBUG( "IsInstalledAppRemovableL(midletParameters.iDrive); True"); |
|
1661 } |
|
1662 else |
|
1663 { |
|
1664 RDEBUG( "IsInstalledAppRemovableL(midletParameters.iDrive); False"); |
|
1665 } |
|
1666 |
|
1667 //check for status drive |
|
1668 aCompo.SetAppRemovableStatus(status); |
|
1669 } |
|
1670 |
|
1671 RDEBUG( "CApplicationManagementServer::JavaInstallL: End"); |
|
1672 } |
|
1673 |
|
1674 // ------------------------------------------------------------------------------------------------ |
|
1675 // CApplicationManagementServer::SisInstallL() |
|
1676 // ------------------------------------------------------------------------------------------------ |
|
1677 |
|
1678 void CApplicationManagementServer::SisInstallL( |
|
1679 const CDeploymentComponent &aCompo) |
|
1680 { |
|
1681 TRequestStatus s; |
|
1682 // set state to install progress |
|
1683 aCompo.SetStatusNode(EDelivered_InstallProgress); |
|
1684 TInt err(KErrNone); |
|
1685 TRAP(err,InstallL( aCompo,s )); |
|
1686 if (err != KErrNone) |
|
1687 { |
|
1688 aCompo.SetStatusNode(EDelivered_InstalledFailedWithData); |
|
1689 User::Leave(err); |
|
1690 } |
|
1691 User::WaitForRequest(s); |
|
1692 if (s != KErrNone) |
|
1693 { |
|
1694 RDEBUG_2("ApplicationManagementSession: SisInstallL failed with code %d", |
|
1695 s.Int() ); |
|
1696 // set state to install failed with data |
|
1697 aCompo.SetStatusNode(EDelivered_InstalledFailedWithData); |
|
1698 User::Leave(s.Int() ); |
|
1699 } |
|
1700 else |
|
1701 { |
|
1702 // set state to install sucessful |
|
1703 aCompo.SetStatusNode(EIdle); |
|
1704 RDEBUG("ApplicationManagementSession: SisInstallL successfull" ); |
|
1705 } |
|
1706 RDEBUG( "CApplicationManagementServer::SisInstallL: End"); |
|
1707 } |
|
1708 |
|
1709 // ------------------------------------------------------------------------------------------------ |
|
1710 // CApplicationManagementServer::DoTheInstallL() |
|
1711 // ------------------------------------------------------------------------------------------------ |
|
1712 |
|
1713 void CApplicationManagementServer::DoTheInstallL(CDeploymentComponent &aCompo) |
|
1714 { |
|
1715 RDEBUG( "CApplicationManagementServer::DoTheInstallL: Start"); |
|
1716 TInt error(KErrNone); |
|
1717 if (CDeploymentComponent::IsJavaMimeL(aCompo.Data().MimeType() ) |
|
1718 || CDeploymentComponent::IsJavaMimeL(aCompo.MetaData().MimeType() ) ) |
|
1719 { |
|
1720 TRAP( error, JavaInstallL( aCompo ) ); |
|
1721 } |
|
1722 else |
|
1723 { |
|
1724 TRAP( error, SisInstallL( aCompo ) ); |
|
1725 SetSisAppVersionAndDriveL(aCompo); |
|
1726 } |
|
1727 |
|
1728 SendServerToBackground(); |
|
1729 |
|
1730 if (error == KErrNone) |
|
1731 { |
|
1732 InstallCompleteL(aCompo, ETrue); |
|
1733 CDeploymentComponent *old = DoDataUpdateCheckL(aCompo); |
|
1734 if (old) |
|
1735 { |
|
1736 if (aCompo.State() == EDCSDelivered) |
|
1737 { |
|
1738 if (old->State() == EDCSActive || old->State()== EDCSInactive) |
|
1739 { |
|
1740 RDEBUG("AMSession: DoTheInstallL ** deleting old node **" ); |
|
1741 iStorage->RemoveL(old->InternalId() ); |
|
1742 } |
|
1743 } |
|
1744 } |
|
1745 iStorage->InstalledL(aCompo); |
|
1746 } |
|
1747 else |
|
1748 { |
|
1749 InstallCompleteL(aCompo, EFalse); |
|
1750 User::Leave(error); |
|
1751 } |
|
1752 RDEBUG( "CApplicationManagementServer::DoTheInstallL: End"); |
|
1753 } |
|
1754 |
|
1755 // ------------------------------------------------------------------------------------------------ |
|
1756 // CApplicationManagementServer::DoDataUpdateCheckL() |
|
1757 // ------------------------------------------------------------------------------------------------ |
|
1758 |
|
1759 CDeploymentComponent *CApplicationManagementServer::DoDataUpdateCheckL( |
|
1760 CDeploymentComponent &aCompo) |
|
1761 { |
|
1762 CDeploymentComponent *old= NULL; |
|
1763 if (aCompo.Uid() != TUid::Null() && HasUidL(aCompo.Uid(), old, &aCompo) ) |
|
1764 { |
|
1765 // check for Uid component.. Legacy code removed. |
|
1766 } |
|
1767 return old; |
|
1768 } |
|
1769 |
|
1770 // ------------------------------------------------------------------------------------------------ |
|
1771 // CApplicationManagementServer::SetDataL() |
|
1772 // ------------------------------------------------------------------------------------------------ |
|
1773 |
|
1774 void CApplicationManagementServer::SetDataL(CDeploymentComponent &aCompo, |
|
1775 const TDesC8 &aData, const TDesC8 &aMime) |
|
1776 { |
|
1777 aCompo.SetDataL(aData, aMime); |
|
1778 DoDataUpdateCheckL(aCompo); |
|
1779 } |
|
1780 |
|
1781 // ------------------------------------------------------------------------------------------------ |
|
1782 // CApplicationManagementServer::FullUpdateL() |
|
1783 // ------------------------------------------------------------------------------------------------ |
|
1784 |
|
1785 void CApplicationManagementServer::FullUpdateL(const TUint32 sid, |
|
1786 const TUint32 tid) |
|
1787 { |
|
1788 CDeploymentComponent &scompo = iStorage->ComponentL(sid); |
|
1789 CDeploymentComponent &tcompo = iStorage->ComponentL(tid); |
|
1790 FullUpdateL(scompo, tcompo); |
|
1791 } |
|
1792 |
|
1793 // ------------------------------------------------------------------------------------------------ |
|
1794 // CApplicationManagementServer::FullUpdateL() |
|
1795 // ------------------------------------------------------------------------------------------------ |
|
1796 |
|
1797 void CApplicationManagementServer::FullUpdateL(CDeploymentComponent &scompo, |
|
1798 const CDeploymentComponent &tcompo) |
|
1799 { |
|
1800 if (scompo.State() == EDCSDelivered) |
|
1801 { |
|
1802 if (tcompo.State() == EDCSActive || tcompo.State() == EDCSInactive) |
|
1803 { |
|
1804 TRequestStatus s2; |
|
1805 InstallL(scompo, s2); |
|
1806 User::WaitForRequest(s2); |
|
1807 if (s2 != KErrNone) |
|
1808 { |
|
1809 RDEBUG_2( "ApplicationManagementSession: FullUpdateL failed with code %d", s2.Int() ); |
|
1810 User::Leave(s2.Int() ); |
|
1811 } |
|
1812 else |
|
1813 { |
|
1814 InstallCompleteL(scompo); |
|
1815 // Before deleting old node ,copy node values which are not set in new node from old node |
|
1816 if (scompo.ComponentId()== KNullDesC8) |
|
1817 scompo.SetIdL(tcompo.ComponentId()); |
|
1818 |
|
1819 if (scompo.ComponentName()== KNullDesC8) |
|
1820 scompo.SetNameL(tcompo.ComponentName()); |
|
1821 |
|
1822 if (scompo.ComponentVersion()== KNullDesC8) |
|
1823 scompo.SetVersionL(tcompo.ComponentVersion()); |
|
1824 |
|
1825 //Tag tcompo state for deletion. Cant delete now, since nsmldmtree woudnt be updated |
|
1826 //Remove the const'ness since state needs to be updated. |
|
1827 |
|
1828 iStorage->SetDeploymentComponentState(const_cast <CDeploymentComponent &>(tcompo),EDCSDelete); |
|
1829 |
|
1830 iStorage->InstalledL( scompo ); |
|
1831 RDEBUG( "ApplicationManagementSession: FullUpdateL ok" ); |
|
1832 } |
|
1833 } |
|
1834 else |
|
1835 { |
|
1836 RDEBUG_2( "ApplicationManagementSession: ERROR FullUpdateL called for illegal state component: %d!", scompo.State() ); |
|
1837 User::Leave(KErrArgument); |
|
1838 } |
|
1839 } |
|
1840 else |
|
1841 { |
|
1842 RDEBUG( "ApplicationManagementSession: ERROR FullUpdateL called for illegal state message!" ); |
|
1843 User::Leave(KErrArgument); |
|
1844 } |
|
1845 } |
|
1846 |
|
1847 // ------------------------------------------------------------------------------------------------------------------- |
|
1848 // CApplicationManagementServer::IsDataFileB64EncodedL() |
|
1849 // ------------------------------------------------------------------------------------------------------------------- |
|
1850 TBool CApplicationManagementServer::IsDataFileB64EncodedL(RFile &aFile, |
|
1851 TInt& aLength) |
|
1852 { |
|
1853 RDEBUG("CApplicationManagementServer::IsDataFileB64EncodedL() : start"); |
|
1854 TBool encoded = ETrue; // assume b64 encoded |
|
1855 TInt bufSize(KBase64BufSize); |
|
1856 TInt offset(0); |
|
1857 HBufC8 *dataBuf = HBufC8::NewLC(bufSize); |
|
1858 TPtr8 dataPtr = dataBuf->Des(); |
|
1859 aFile.Size(aLength); |
|
1860 aFile.Seek(ESeekStart, offset); |
|
1861 |
|
1862 while (encoded) |
|
1863 { |
|
1864 aFile.Read(dataPtr); |
|
1865 if ( !dataPtr.Length() ) |
|
1866 { |
|
1867 break; |
|
1868 } |
|
1869 offset = 0; |
|
1870 aFile.Seek(ESeekCurrent, offset); |
|
1871 RDEBUG_2("OFFSET: %d", offset); |
|
1872 encoded = CheckB64Encode(dataPtr); |
|
1873 } |
|
1874 RDEBUG_2("Encoded: %d", encoded); |
|
1875 CleanupStack::PopAndDestroy(dataBuf); |
|
1876 offset = 0; |
|
1877 aFile.Seek(ESeekStart, offset); |
|
1878 |
|
1879 RDEBUG("CApplicationManagementServer::IsDataFileB64EncodedL() : end"); |
|
1880 return encoded; |
|
1881 } |
|
1882 |
|
1883 // ------------------------------------------------------------------------------------------------------------------- |
|
1884 // CApplicationManagementServer::CheckB64Encode( const TDesC8& aData ) |
|
1885 // ------------------------------------------------------------------------------------------------------------------- |
|
1886 TBool CApplicationManagementServer::CheckB64Encode(const TDesC8& aData) |
|
1887 { |
|
1888 TInt inputIndex = 0; |
|
1889 TInt inputLen = aData.Length(); |
|
1890 |
|
1891 while (inputIndex < inputLen) |
|
1892 { |
|
1893 const TUint8& p = aData[ inputIndex ]; |
|
1894 |
|
1895 if ((p >= 48 && p <= 57) || (p >= 65 && p <= 90) || (p >= 97 && p |
|
1896 <= 122) || p == 43 || p == 47 || p == 61 || p == 10 || p |
|
1897 == 13) |
|
1898 { |
|
1899 } |
|
1900 else |
|
1901 { |
|
1902 return EFalse; |
|
1903 } |
|
1904 |
|
1905 inputIndex++; |
|
1906 |
|
1907 } |
|
1908 |
|
1909 return ETrue; |
|
1910 } |
|
1911 |
|
1912 // ------------------------------------------------------------------------------------------------ |
|
1913 // CApplicationManagementServer::GetAMServerDownloadDBL() |
|
1914 // ------------------------------------------------------------------------------------------------ |
|
1915 |
|
1916 void CApplicationManagementServer::GetAMServerDownloadDBL(TUint32 internalid, |
|
1917 TInt& finalresult, TDes8& aTargetURI) |
|
1918 { |
|
1919 RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step1" ); |
|
1920 |
|
1921 TBuf<50> internalidbuf; |
|
1922 |
|
1923 RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step2" ); |
|
1924 internalidbuf.Num(internalid); |
|
1925 |
|
1926 RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step3" ); |
|
1927 |
|
1928 RPointerArray<CAMDbItem> aItemArray; |
|
1929 |
|
1930 RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step4" ); |
|
1931 |
|
1932 iAMServerDB->GetEntryForLUIDL(aItemArray, internalidbuf); |
|
1933 |
|
1934 RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step5" ); |
|
1935 |
|
1936 if (aItemArray.Count()!=0) |
|
1937 { |
|
1938 RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step6" ); |
|
1939 |
|
1940 finalresult = aItemArray[0]->iResult; |
|
1941 |
|
1942 RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step7" ); |
|
1943 |
|
1944 if (finalresult < KErrNone) |
|
1945 User::Leave(KErrGeneral); |
|
1946 |
|
1947 RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step8" ); |
|
1948 |
|
1949 if (*aItemArray[0]->iTargetURI == KNullDesC8()) |
|
1950 User::Leave(KErrGeneral); |
|
1951 |
|
1952 RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step9" ); |
|
1953 aTargetURI.Copy(*aItemArray[0]->iTargetURI); |
|
1954 |
|
1955 } |
|
1956 RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step10" ); |
|
1957 aItemArray.ResetAndDestroy(); |
|
1958 |
|
1959 } |
|
1960 |
|
1961 // ------------------------------------------------------------------------------------------------ |
|
1962 // CApplicationManagementServer::DeleteGenericAlertForIDL() |
|
1963 // ------------------------------------------------------------------------------------------------ |
|
1964 |
|
1965 void CApplicationManagementServer::DeleteGenericAlertForIDL(TUint32 internalid) |
|
1966 { |
|
1967 iAMServerDB->DeleteFromDatabaseL(internalid); |
|
1968 } |
|
1969 |
|
1970 // ------------------------------------------------------------------------------------------------------------------- |
|
1971 // CApplicationManagementServer::DecodeB64DataFileL( RFile& aDataFile, RFile& aDestinationFile ) |
|
1972 // ------------------------------------------------------------------------------------------------------------------- |
|
1973 void CApplicationManagementServer::DecodeB64DataFileL(RFile& aSourceFile, |
|
1974 RFile& aDestinationFile) |
|
1975 { |
|
1976 RDEBUG( "CApplicationManagementServer::DecodeB64DataFileL(): Start" ); |
|
1977 // Create buffers |
|
1978 //TInt b64bufferSize = 131072; |
|
1979 TInt decodedBufferSize = ( (KBase64BufSize*3) / 4 + 16 ); |
|
1980 HBufC8 *dataBuf = HBufC8::NewLC(KBase64BufSize); |
|
1981 TPtr8 dataPtr = dataBuf->Des(); |
|
1982 HBufC8* targetBuf = HBufC8::NewLC(decodedBufferSize); |
|
1983 TPtr8 targetPtr(targetBuf->Des() ); |
|
1984 |
|
1985 TInt offset(0); |
|
1986 TInt length(0); |
|
1987 TBool reading(ETrue); |
|
1988 aSourceFile.Size(length); |
|
1989 RDEBUG_2( "CApplicationManagementServer::DecodeB64DataFileL(): b64 file total size: (%d)", length ); |
|
1990 aSourceFile.Seek(ESeekStart, offset); |
|
1991 |
|
1992 // Initialize decoder |
|
1993 TImCodecB64 B64Coder; |
|
1994 B64Coder.Initialise(); |
|
1995 |
|
1996 while (reading) |
|
1997 { |
|
1998 aSourceFile.Read(dataPtr); |
|
1999 if ( !dataPtr.Length() ) |
|
2000 { |
|
2001 // EOF |
|
2002 break; |
|
2003 } |
|
2004 offset = 0; |
|
2005 aSourceFile.Seek(ESeekCurrent, offset); |
|
2006 RDEBUG_2("OFFSET: %d", offset); |
|
2007 |
|
2008 // decode data |
|
2009 B64Coder.Decode(dataPtr, targetPtr); |
|
2010 // write decoded data to temporary file |
|
2011 aDestinationFile.Write(targetPtr); |
|
2012 } |
|
2013 CleanupStack::PopAndDestroy(targetBuf); |
|
2014 CleanupStack::PopAndDestroy(dataBuf); |
|
2015 |
|
2016 offset = 0; |
|
2017 aDestinationFile.Seek(ESeekStart, offset); |
|
2018 RDEBUG( "CApplicationManagementServer::DecodeB64DataFileL(): end" ); |
|
2019 } |
|
2020 |
|
2021 // ------------------------------------------------------------------------------------------------------------------- |
|
2022 // CApplicationManagementServer::DecodeB64DataLC( const TDesC8& aData ) |
|
2023 // ------------------------------------------------------------------------------------------------------------------- |
|
2024 HBufC8* CApplicationManagementServer::DecodeB64DataLC(const TDesC8 &aData) |
|
2025 { |
|
2026 RDEBUG( "CApplicationManagementServer::DecodeB64DataLC(): Start" ); |
|
2027 TImCodecB64 B64Coder; |
|
2028 B64Coder.Initialise(); |
|
2029 HBufC8 *target = HBufC8::NewLC( (aData.Length() * 3 ) / 4 + 16); |
|
2030 TPtr8 targetPtr(target->Des() ); |
|
2031 B64Coder.Decode(aData, targetPtr); |
|
2032 RDEBUG( "CApplicationManagementServer::DecodeB64DataLC(): End" ); |
|
2033 return target; |
|
2034 } |
|
2035 |
|
2036 // ------------------------------------------------------------------------------------------------------------------- |
|
2037 // CApplicationManagementServer::EncodeDataL( const TDesC8& aData, CBufBase &aTarget ) |
|
2038 // ------------------------------------------------------------------------------------------------------------------- |
|
2039 void CApplicationManagementServer::EncodeDataL(const TDesC8& aData, |
|
2040 CBufBase &aTarget) |
|
2041 { |
|
2042 TInt outLen(aData.Length() * 2); |
|
2043 aTarget.ExpandL(0, outLen); |
|
2044 TImCodecB64 B64Coder; |
|
2045 B64Coder.Initialise(); |
|
2046 TPtr8 target(aTarget.Ptr(0) ); |
|
2047 TInt decoded(B64Coder.Encode(aData, target) ); |
|
2048 TInt s(target.Length() ); |
|
2049 aTarget.ResizeL(s); |
|
2050 // TInt s2( aTarget.Size()); |
|
2051 aTarget.Compress(); |
|
2052 // TInt s3( aTarget.Size() ); |
|
2053 if ( !decoded) |
|
2054 { |
|
2055 RDEBUG( "CApplicationManagementServer::EncodeDataL(): Encoding b64 failed?" ); |
|
2056 } |
|
2057 } |
|
2058 |
|
2059 // ------------------------------------------------------------------------------------------------------------------- |
|
2060 // CApplicationManagementSession::CApplicationManagementSession |
|
2061 // ------------------------------------------------------------------------------------------------------------------- |
|
2062 inline CApplicationManagementSession::CApplicationManagementSession() |
|
2063 { |
|
2064 RDEBUG_2( "CApplicationManagementSession::CApplicationManagementSession 0x%x", this); |
|
2065 } |
|
2066 |
|
2067 // ------------------------------------------------------------------------------------------------------------------- |
|
2068 // CApplicationManagementSession::CApplicationManagementSession |
|
2069 // ------------------------------------------------------------------------------------------------------------------- |
|
2070 |
|
2071 inline CApplicationManagementSession::CApplicationManagementSession( |
|
2072 const TCertInfo &aInfo) : |
|
2073 iCertInfo(aInfo) |
|
2074 { |
|
2075 RDEBUG( "CApplicationManagementSession::CApplicationManagementSession (cert) " ); |
|
2076 } |
|
2077 |
|
2078 // ------------------------------------------------------------------------------------------------------------------- |
|
2079 // CApplicationManagementSession::Server() |
|
2080 // ------------------------------------------------------------------------------------------------------------------- |
|
2081 |
|
2082 inline CApplicationManagementServer& CApplicationManagementSession::Server() const |
|
2083 { |
|
2084 return *static_cast<CApplicationManagementServer*>( const_cast<CServer2*>(CSession2::Server())); |
|
2085 } |
|
2086 |
|
2087 // ------------------------------------------------------------------------------------------------------------------- |
|
2088 // CApplicationManagementSession::CreateL() |
|
2089 // ------------------------------------------------------------------------------------------------------------------- |
|
2090 // 2nd phase construct for sessions - called by the CServer framework |
|
2091 |
|
2092 void CApplicationManagementSession::CreateL() |
|
2093 { |
|
2094 RDEBUG_2( "ApplicationManagementSession: CApplicationManagementSession::CreateL: 0x%x", this ); |
|
2095 |
|
2096 Server().AddSession(); |
|
2097 CAknAppServiceBase::CreateL(); |
|
2098 } |
|
2099 |
|
2100 // ------------------------------------------------------------------------------------------------------------------- |
|
2101 // CApplicationManagementSession::~CApplicationManagementSession() |
|
2102 // ------------------------------------------------------------------------------------------------------------------- |
|
2103 |
|
2104 CApplicationManagementSession::~CApplicationManagementSession() |
|
2105 { |
|
2106 RDEBUG_3("CApplicationManagementSession::~CApplicationManagementSession 0x%X - 0x%X", reinterpret_cast<TUint>(this), |
|
2107 reinterpret_cast<TUint>(this)+sizeof( CApplicationManagementSession ) ); |
|
2108 RDEBUG_2("CApplicationManagementSession::~CApplicationManagementSession iCertInfo offs 0x%X", |
|
2109 reinterpret_cast<TUint>(&this->iCertInfo) - reinterpret_cast<TUint>(this) ); |
|
2110 |
|
2111 Server().DropSession(); |
|
2112 } |
|
2113 |
|
2114 // ------------------------------------------------------------------------------------------------------------------- |
|
2115 // CApplicationManagementSession::ServiceL() |
|
2116 // ------------------------------------------------------------------------------------------------------------------- |
|
2117 |
|
2118 void CApplicationManagementSession::ServiceL(const RMessage2& aMessage) |
|
2119 { |
|
2120 if (aMessage.Function() == EPerformRfs) |
|
2121 { |
|
2122 TRAPD( err, Server().PerformRFSL() ) |
|
2123 ; |
|
2124 aMessage.Complete(err); |
|
2125 } |
|
2126 else |
|
2127 { |
|
2128 TBool handled(EFalse); |
|
2129 TInt err(KErrNone); |
|
2130 TRAP( err, handled = PreDispatchMessageL( aMessage ) ); |
|
2131 if ( !handled) |
|
2132 { |
|
2133 TRAP(err,DispatchMessageL(aMessage)); |
|
2134 } |
|
2135 |
|
2136 // Some of the functions contains operations that already complete message |
|
2137 // doing Complete() twice will cause panic |
|
2138 if (aMessage.Handle() ) |
|
2139 { |
|
2140 aMessage.Complete(err); |
|
2141 } |
|
2142 } |
|
2143 } |
|
2144 |
|
2145 // CApplicationManagementSession::PreDispatchMessageL() |
|
2146 // ------------------------------------------------------------------------------------------------------------------- |
|
2147 |
|
2148 TBool CApplicationManagementSession::PreDispatchMessageL( |
|
2149 const RMessage2 &aMessage) |
|
2150 { |
|
2151 TBool ret(EFalse); |
|
2152 // These succeed regardless of certificate.... |
|
2153 switch (aMessage.Function() ) |
|
2154 { |
|
2155 case EGetStateChangingIdsCountOperation: |
|
2156 { |
|
2157 // gets count of items list of ids that are potentially changing state |
|
2158 StateChangeComponentIdsCountL(aMessage); |
|
2159 ret = ETrue; |
|
2160 break; |
|
2161 } |
|
2162 case EGetStateChangingIdsOperation: |
|
2163 { |
|
2164 // gets list of ids that are potentially changing state |
|
2165 StateChangeComponentIdsL(aMessage); |
|
2166 ret = ETrue; |
|
2167 break; |
|
2168 } |
|
2169 case ECompleteStateChangeOperation: // completes change of state |
|
2170 { |
|
2171 StateChangeCompleteL(aMessage); |
|
2172 ret = ETrue; |
|
2173 break; |
|
2174 } |
|
2175 default: |
|
2176 { |
|
2177 break; |
|
2178 } |
|
2179 } |
|
2180 return ret; |
|
2181 } |
|
2182 |
|
2183 // ------------------------------------------------------------------------------------------------------------------- |
|
2184 // CApplicationManagementSession::DispatchMessageL() |
|
2185 // ------------------------------------------------------------------------------------------------------------------- |
|
2186 |
|
2187 void CApplicationManagementSession::DispatchMessageL(const RMessage2& aMessage) |
|
2188 { |
|
2189 RDEBUG_2( "CApplicationManagementSession::DispatchMessageL; %d" , |
|
2190 aMessage.Function() ); |
|
2191 |
|
2192 TBool go(EFalse); |
|
2193 if (iTrustAdded) |
|
2194 { |
|
2195 go = Server().CheckCertL(iCertInfo); |
|
2196 } |
|
2197 else |
|
2198 { |
|
2199 go = ETrue; |
|
2200 } |
|
2201 |
|
2202 if (go) |
|
2203 { |
|
2204 switch (aMessage.Function() ) |
|
2205 { |
|
2206 case EAddTrust: |
|
2207 { |
|
2208 RDEBUG_2( "CApplicationManagementSession::DispatchMessageL; EAddTrust this=0x%x", this ); |
|
2209 AddTrustL(aMessage); |
|
2210 break; |
|
2211 } |
|
2212 case EDeplCompCountOperation: |
|
2213 { |
|
2214 ComponentCountL(aMessage); |
|
2215 return; |
|
2216 } |
|
2217 case EDeplCompIdsOperation: |
|
2218 { |
|
2219 ComponentIdsL(aMessage); |
|
2220 return; |
|
2221 } |
|
2222 case EDeplCompDeliverCompleteOperation: |
|
2223 { |
|
2224 DeliverCompleteL(aMessage); |
|
2225 break; |
|
2226 } |
|
2227 case EDeplCompGetOperation: |
|
2228 { |
|
2229 GetComponentL(aMessage) ; |
|
2230 break; |
|
2231 } |
|
2232 case EInstallOperation: |
|
2233 { |
|
2234 InstallL(aMessage) ; |
|
2235 break; |
|
2236 } |
|
2237 case EDeplCompAttrUpdateOperation: |
|
2238 { |
|
2239 UpdateL(aMessage) ; |
|
2240 break; |
|
2241 } |
|
2242 case EDeplCompGetDataOperation: |
|
2243 { |
|
2244 GetDataL(aMessage) ; |
|
2245 break; |
|
2246 } |
|
2247 case EDeplCompGetDataLengthOperation: |
|
2248 { |
|
2249 GetDataLengthL(aMessage) ; |
|
2250 break; |
|
2251 } |
|
2252 case EDeplCompRemoveOperation: |
|
2253 { |
|
2254 RemoveL(aMessage) ; |
|
2255 break; |
|
2256 } |
|
2257 case EDeplCompDeliverStartOperation2: |
|
2258 { |
|
2259 Deliver2L(aMessage) ; |
|
2260 break; |
|
2261 } |
|
2262 case EDeplCompUpdateDataOperation: |
|
2263 { |
|
2264 UpdateDataL(aMessage) ; |
|
2265 break; |
|
2266 } |
|
2267 case EDeplCompUpdateStreamedDataOperation: |
|
2268 { |
|
2269 UpdateStreamedDataL(aMessage) ; |
|
2270 break; |
|
2271 } |
|
2272 case EDeplCompDownloadOperation: |
|
2273 { |
|
2274 DownloadL(aMessage) ; |
|
2275 break; |
|
2276 } |
|
2277 case EDeplCompUpdateOperation: |
|
2278 { |
|
2279 FullUpdateL(aMessage) ; |
|
2280 break; |
|
2281 } |
|
2282 case EDeplCompGetUserIdOperation: |
|
2283 { |
|
2284 GetUserIdL(aMessage); |
|
2285 break; |
|
2286 } |
|
2287 case EDeplCompStartDownloadOperation: |
|
2288 { |
|
2289 StartDownloadL(aMessage); |
|
2290 break; |
|
2291 } |
|
2292 case EDeplCompDeactivateOperation: |
|
2293 { |
|
2294 DeactivateL(aMessage); |
|
2295 break; |
|
2296 } |
|
2297 case EDeplCompActivateOperation: |
|
2298 { |
|
2299 ActivateL(aMessage); |
|
2300 break; |
|
2301 } |
|
2302 case EDeplCompGetTemporaryInstFile: |
|
2303 { |
|
2304 GetTemporaryInstFileL(aMessage); |
|
2305 break; |
|
2306 } |
|
2307 |
|
2308 case EDeplCompGetFinalResultForGA: |
|
2309 { |
|
2310 GetFinalResultForGAL(aMessage); |
|
2311 break; |
|
2312 |
|
2313 } |
|
2314 case EDeplCompGenericAlertSent: |
|
2315 { |
|
2316 GenericAlertSentForIdL(aMessage); |
|
2317 break; |
|
2318 } |
|
2319 case ECheckStatusNodes: |
|
2320 { |
|
2321 CheckStatusNodesValuesL(); |
|
2322 break; |
|
2323 } |
|
2324 |
|
2325 default: |
|
2326 { |
|
2327 User::Leave(KErrNotSupported); |
|
2328 break; |
|
2329 } |
|
2330 } |
|
2331 } |
|
2332 else |
|
2333 { |
|
2334 RDEBUG_2( "CApplicationManagementSession::DispatchMessageL; Policy prevented action this=0x%x", this ); |
|
2335 User::Leave(KErrAccessDenied); |
|
2336 } |
|
2337 } |
|
2338 |
|
2339 // ------------------------------------------------------------------------------------------------------------------- |
|
2340 // CApplicationManagementSession::GenericAlertSentForIdL() |
|
2341 // ------------------------------------------------------------------------------------------------------------------- |
|
2342 |
|
2343 void CApplicationManagementSession::GenericAlertSentForIdL( |
|
2344 const RMessage2& aMessage) const |
|
2345 { |
|
2346 TUint32 luid; |
|
2347 TPckg<TUint32> pk(luid); |
|
2348 TInt read(aMessage.Read(0, pk)); |
|
2349 |
|
2350 Server().DeleteGenericAlertForIDL(luid); |
|
2351 |
|
2352 } |
|
2353 |
|
2354 // ------------------------------------------------------------------------------------------------------------------- |
|
2355 // CApplicationManagementSession::GetFinalResultForGAL() |
|
2356 // ------------------------------------------------------------------------------------------------------------------- |
|
2357 |
|
2358 void CApplicationManagementSession::GetFinalResultForGAL( |
|
2359 const RMessage2& aMessage) |
|
2360 { |
|
2361 |
|
2362 RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 1" ); |
|
2363 TUint32 luid; |
|
2364 TPckg<TUint32> pk(luid); |
|
2365 |
|
2366 TInt finalresult = KErrNone; |
|
2367 |
|
2368 RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 2" ); |
|
2369 |
|
2370 HBufC8 *targetURI = HBufC8::NewL(512); |
|
2371 TPtr8 ptr = targetURI->Des(); |
|
2372 |
|
2373 RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 3" ); |
|
2374 |
|
2375 TInt read(aMessage.Read(0, pk)); |
|
2376 |
|
2377 RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 4" ); |
|
2378 |
|
2379 Server().GetAMServerDownloadDBL(luid, finalresult, ptr); |
|
2380 |
|
2381 RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 5" ); |
|
2382 |
|
2383 RDEBUG_2( "ApplicationManagementServer: GetFinalResultForGAL Count is %d", finalresult ); |
|
2384 TPckg<TInt> p1(finalresult); |
|
2385 aMessage.WriteL(1, p1); |
|
2386 |
|
2387 RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 6" ); |
|
2388 aMessage.WriteL(2, ptr); |
|
2389 |
|
2390 RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 7" ); |
|
2391 if (targetURI) |
|
2392 delete targetURI; |
|
2393 |
|
2394 } |
|
2395 |
|
2396 // ------------------------------------------------------------------------------------------------------------------- |
|
2397 // CApplicationManagementSession::ComponentCountL() |
|
2398 // ------------------------------------------------------------------------------------------------------------------- |
|
2399 |
|
2400 void CApplicationManagementSession::ComponentCountL(const RMessage2& aMessage) |
|
2401 { |
|
2402 RDEBUG( "CApplicationManagementSession: ComponentCountL" ); |
|
2403 TDeploymentComponentState st; |
|
2404 TPckg<TDeploymentComponentState> pk(st); |
|
2405 |
|
2406 TInt read(aMessage.Read( 1, pk) ); |
|
2407 RDEBUG_3( "CApplicationManagementSession: ComponentCountL State is %d, read %d", st, read); |
|
2408 |
|
2409 const RComponentIdArray &arrt = Server().Storage()->GetComponentIds(); |
|
2410 RComponentIdArray arr; |
|
2411 CleanupClosePushL(arr); |
|
2412 if ((st == EDCSActive)||(st == EDCSInactive)) |
|
2413 { |
|
2414 ActiveComponentsL(arrt, arr,st); |
|
2415 } |
|
2416 else |
|
2417 { |
|
2418 TInt count(arrt.Count() ); |
|
2419 for (TInt i( 0); i < count; i++) |
|
2420 { |
|
2421 CDeploymentComponent &compo = Server().Storage()->ComponentL(arrt[i]); |
|
2422 if (st == EDCSNone || compo.State() == st) |
|
2423 { |
|
2424 arr.Append(arrt[i]); |
|
2425 } |
|
2426 } |
|
2427 } |
|
2428 TInt n(arr.Count() ); |
|
2429 CleanupStack::PopAndDestroy( &arr); |
|
2430 |
|
2431 RDEBUG_2( "ApplicationManagementServer: ComponentCountL Count is %d", n ); |
|
2432 TPckg<TInt> p(n); |
|
2433 |
|
2434 aMessage.WriteL(0, p); |
|
2435 |
|
2436 } |
|
2437 |
|
2438 // ------------------------------------------------------------------------------------------------------------------- |
|
2439 // CApplicationManagementSession::ActiveComponentsL() |
|
2440 // ------------------------------------------------------------------------------------------------------------------- |
|
2441 |
|
2442 void CApplicationManagementSession::ActiveComponentsL( |
|
2443 const RComponentIdArray &aArrt, RComponentIdArray &aArr,TDeploymentComponentState &aState) const |
|
2444 { |
|
2445 Swi::RSisRegistrySession sisses; |
|
2446 TInt r(sisses.Connect() ); |
|
2447 User::LeaveIfError(r) ; |
|
2448 CleanupClosePushL(sisses); |
|
2449 |
|
2450 RArray<TUid> uids; |
|
2451 sisses.InstalledUidsL(uids); |
|
2452 CleanupClosePushL(uids); |
|
2453 TInt cont(aArrt.Count() ); |
|
2454 TInt uidc(uids.Count() ); |
|
2455 RArray<TUid> juids; |
|
2456 Server().JavaUidsL(juids); |
|
2457 CleanupClosePushL(juids); |
|
2458 TInt juidc(juids.Count() ); |
|
2459 RComponentIdArray rem; |
|
2460 CleanupClosePushL(rem); |
|
2461 for (TInt i( 0); i < cont; i++) |
|
2462 { |
|
2463 CDeploymentComponent &compo = Server().Storage()->ComponentL(aArrt[i]); |
|
2464 TDeploymentComponentState state = compo.State(); |
|
2465 if (state == aState) |
|
2466 { |
|
2467 TBool add(EFalse); |
|
2468 const TUid &uid(compo.Uid() ); |
|
2469 for (TInt j( 0); add == EFalse && j < uidc; j++) |
|
2470 { |
|
2471 |
|
2472 if (uids[j] == uid) |
|
2473 { |
|
2474 |
|
2475 RDEBUG( "CApplicationManagementSession::ActiveComponentsL Entered" ); |
|
2476 |
|
2477 // Check if this registry entry is present |
|
2478 Swi::RSisRegistrySession sisSession; |
|
2479 User::LeaveIfError(sisSession.Connect()); |
|
2480 CleanupClosePushL(sisSession); |
|
2481 |
|
2482 Swi::RSisRegistryEntry sisEntry; |
|
2483 |
|
2484 //Opens the base package entry by specifying a UID. |
|
2485 User::LeaveIfError(sisEntry.Open(sisSession, compo.Uid())); |
|
2486 CleanupClosePushL(sisEntry); |
|
2487 |
|
2488 add = sisEntry.IsPresentL(); |
|
2489 |
|
2490 if(add) |
|
2491 RDEBUG( "CApplicationManagementSession::ActiveComponentsL ETrue" ); |
|
2492 else |
|
2493 RDEBUG( "CApplicationManagementSession::ActiveComponentsL EFalse" ); |
|
2494 |
|
2495 |
|
2496 CleanupStack::PopAndDestroy(2, &sisSession); |
|
2497 |
|
2498 } |
|
2499 } |
|
2500 if ( !add) // go throug java suites |
|
2501 { |
|
2502 for (TInt k( 0); add == EFalse && k < juidc; k++) |
|
2503 { |
|
2504 if (juids[k] == uid) |
|
2505 { |
|
2506 add = ETrue; |
|
2507 } |
|
2508 } |
|
2509 } |
|
2510 if (add) |
|
2511 { |
|
2512 aArr.Append(aArrt[i]); |
|
2513 } |
|
2514 else |
|
2515 { |
|
2516 RDEBUG8_3( "ApplicationManagementServer: ActiveComponentCountL skipping 0x%x, %S", |
|
2517 compo.Uid() ,&compo.ComponentId() ); |
|
2518 rem.Append(aArrt[i]); |
|
2519 } |
|
2520 } |
|
2521 } |
|
2522 TInt rc(rem.Count() ); |
|
2523 for (TInt t( 0); t < rc; t++) |
|
2524 { |
|
2525 RDEBUG_2( "ApplicationManagementServer: ActiveComponentCountL removing non existing %d", rem[t] ); |
|
2526 CDeploymentComponent &compo = Server().Storage()->ComponentL(rem[t]); |
|
2527 if(!compo.AppRemovable()) |
|
2528 Server().RemoveInternalL(compo, EFalse); |
|
2529 } |
|
2530 CleanupStack::PopAndDestroy( &rem); |
|
2531 CleanupStack::PopAndDestroy( &juids); |
|
2532 CleanupStack::PopAndDestroy( &uids); |
|
2533 CleanupStack::PopAndDestroy( &sisses); |
|
2534 } |
|
2535 |
|
2536 // ------------------------------------------------------------------------------------------------------------------- |
|
2537 // CApplicationManagementSession::ComponentIdsL() |
|
2538 // ------------------------------------------------------------------------------------------------------------------- |
|
2539 |
|
2540 void CApplicationManagementSession::ComponentIdsL(const RMessage2& aMessage) const |
|
2541 { |
|
2542 RDEBUG( "CApplicationManagementSession: ComponentIdsL" ); |
|
2543 TDeploymentComponentState st; |
|
2544 TPckg<TDeploymentComponentState> pk(st); |
|
2545 |
|
2546 TInt read(aMessage.Read( 1, pk) ); |
|
2547 RDEBUG_3( "CApplicationManagementSession: ComponentIdsL State is %d, read %d", st, read); |
|
2548 |
|
2549 const RComponentIdArray &arrt = Server().Storage()->GetComponentIds(); |
|
2550 TInt buflen( 0); |
|
2551 TUint32* buf= NULL; |
|
2552 if (st == EDCSNone) |
|
2553 { |
|
2554 buflen = arrt.Count() ; |
|
2555 buf = new ( ELeave ) TUint32[buflen]; |
|
2556 CleanupArrayDeletePushL(buf); |
|
2557 for (TInt i( 0); i < buflen; i++) |
|
2558 { |
|
2559 RDEBUG_2("ApplicationManagementSession: ComponentIdsL Adding %d!!", arrt[i]); |
|
2560 buf[i] = arrt[i]; |
|
2561 } |
|
2562 } |
|
2563 else |
|
2564 { |
|
2565 RComponentIdArray arr; |
|
2566 if (st == EDCSActive) |
|
2567 { |
|
2568 ActiveComponentsL(arrt, arr,st); |
|
2569 } |
|
2570 else |
|
2571 { |
|
2572 TInt artc(arrt.Count() ); |
|
2573 for (TInt i( 0); i < artc; i++) |
|
2574 { |
|
2575 CDeploymentComponent &compo = Server().Storage()->ComponentL(arrt[i]); |
|
2576 if (compo.State() == st) |
|
2577 { |
|
2578 arr.Append(arrt[i]); |
|
2579 } |
|
2580 } |
|
2581 } |
|
2582 buflen = arr.Count() ; |
|
2583 buf = new ( ELeave ) TUint32[buflen]; |
|
2584 CleanupArrayDeletePushL(buf); |
|
2585 |
|
2586 TUint32 len(aMessage.GetDesMaxLength( 0) / 4); |
|
2587 if (buflen == len) |
|
2588 { |
|
2589 RDEBUG( "CApplicationManagementSession: ComponentIdsL Right count!!" ); |
|
2590 } |
|
2591 else |
|
2592 { |
|
2593 RDEBUG_3( "CApplicationManagementSession: ComponentIdsL Wrong count (is %d, should be %d)!!", len, buflen); |
|
2594 if (len < buflen) |
|
2595 { |
|
2596 buflen = len; |
|
2597 } |
|
2598 } |
|
2599 for (TInt i( 0); i < buflen; i++) |
|
2600 { |
|
2601 RDEBUG_2( "CApplicationManagementSession: ComponentIdsL Adding %d!!", |
|
2602 arr[i] ); |
|
2603 buf[i] = arr[i]; |
|
2604 } |
|
2605 arr.Close(); |
|
2606 } |
|
2607 |
|
2608 TPtrC8 p( ( TUint8* ) buf, buflen * sizeof(TUint32)); |
|
2609 aMessage.WriteL( 0, p); |
|
2610 |
|
2611 CleanupStack::PopAndDestroy(buf); |
|
2612 } |
|
2613 |
|
2614 #ifdef _DEBUG |
|
2615 HBufC* Des8to16LC(const TDesC8 &aDes) |
|
2616 { |
|
2617 HBufC *b = HBufC::NewLC(aDes.Length() ); |
|
2618 TPtr p(b->Des() ); |
|
2619 p.Copy(aDes); |
|
2620 return b; |
|
2621 } |
|
2622 |
|
2623 HBufC* ToStringLC(TDeploymentComponent &aComp) |
|
2624 { |
|
2625 HBufC *b = HBufC::NewLC(aComp.iId.Length() + aComp.iName.Length() |
|
2626 + aComp.iVersion.Length() + 10 + 50); |
|
2627 TPtr p(b->Des() ); |
|
2628 _LIT( KFormat, "Id: '%S', Name: '%S', Version: '%S', State: %d, OldState: %d"); |
|
2629 p.Format(KFormat, &*Des8to16LC(aComp.iId), &*Des8to16LC(aComp.iName), |
|
2630 &*Des8to16LC(aComp.iVersion), aComp.iState, aComp.iOldState) ; |
|
2631 CleanupStack::PopAndDestroy( 3); |
|
2632 return b; |
|
2633 } |
|
2634 #endif |
|
2635 |
|
2636 // ------------------------------------------------------------------------------------------------------------------- |
|
2637 // CApplicationManagementSession::Deliver2L() |
|
2638 // ------------------------------------------------------------------------------------------------------------------- |
|
2639 |
|
2640 void CApplicationManagementSession::Deliver2L(const RMessage2& aMessage) const |
|
2641 { |
|
2642 RDEBUG( "ApplicationManagementSession: Deliver2L" ); |
|
2643 |
|
2644 TDeploymentComponentIPC comp; |
|
2645 TPckg< TDeploymentComponentIPC> pcomp(comp); |
|
2646 TInt read2(aMessage.Read( 0, pcomp) ); |
|
2647 |
|
2648 HBufC8 *data = HBufC8::NewLC(aMessage.GetDesLength( 1) ); |
|
2649 TPtr8 pbuf(data->Des()); |
|
2650 TInt read(aMessage.Read( 1, pbuf) ); |
|
2651 |
|
2652 CDeploymentComponent *compo= NULL; |
|
2653 if (iTrustAdded) |
|
2654 { |
|
2655 compo = Server().Storage()->NewComponentL(EDCSDelivered, comp.iUserId, &iCertInfo); |
|
2656 } |
|
2657 else |
|
2658 { |
|
2659 compo = Server().Storage()->NewComponentL(EDCSDelivered, comp.iUserId); |
|
2660 } |
|
2661 |
|
2662 compo->Set(comp.iComponent); |
|
2663 compo->Data().SetDataL(pbuf, comp.iMimeType); |
|
2664 Server().Storage()->UpdateL( *compo); |
|
2665 compo->CopyStateTo(comp.iComponent); |
|
2666 |
|
2667 #ifdef _DEBUG |
|
2668 RDEBUG_2( "Deliver2L: TDeploymentComponent is '%S'", |
|
2669 ToStringLC( comp.iComponent ) ); |
|
2670 CleanupStack::PopAndDestroy(); |
|
2671 #endif |
|
2672 |
|
2673 TPckg< TDeploymentComponent> pcomp2(comp.iComponent); |
|
2674 aMessage.Write( 0, pcomp2); |
|
2675 CleanupStack::PopAndDestroy(data) ; |
|
2676 TInt n(compo->InternalId() ); |
|
2677 TPckg<TUint32> p(n); |
|
2678 aMessage.WriteL( 2, p); |
|
2679 } |
|
2680 |
|
2681 // ------------------------------------------------------------------------------------------------------------------- |
|
2682 // CApplicationManagementSession::DeliverCompleteL() |
|
2683 // ------------------------------------------------------------------------------------------------------------------- |
|
2684 |
|
2685 void CApplicationManagementSession::DeliverCompleteL(const RMessage2& aMessage) const |
|
2686 { |
|
2687 RDEBUG( "ApplicationManagementSession: DeliverCompleteL" ); |
|
2688 TUint32 id; |
|
2689 TPckg<TUint32> pid(id); |
|
2690 |
|
2691 TInt read(aMessage.Read( 0, pid) ); |
|
2692 RDEBUG_2( "ApplicationManagementSession: DeliverCompleteL id is %d", id ); |
|
2693 |
|
2694 CDeploymentComponent &compo = Server().Storage()->ComponentL(id); |
|
2695 |
|
2696 HBufC8 *opts = HBufC8::NewLC(aMessage.GetDesLength( 1) ); |
|
2697 TPtr8 popts(opts->Des() ); |
|
2698 TInt read1(aMessage.Read( 1, popts) ); |
|
2699 compo.SetInstallOptsL( *opts); |
|
2700 |
|
2701 HBufC8 *meta = HBufC8::NewLC(aMessage.GetDesLength( 2) ); |
|
2702 TPtr8 pmeta(meta->Des() ); |
|
2703 TInt read2(aMessage.Read( 2, pmeta) ); |
|
2704 compo.SetMetaDataL( *meta, KNullDesC8); |
|
2705 |
|
2706 CleanupStack::PopAndDestroy(meta) ; |
|
2707 CleanupStack::PopAndDestroy(opts) ; |
|
2708 Server().Storage()->UpdateL(compo); |
|
2709 } |
|
2710 |
|
2711 // ------------------------------------------------------------------------------------------------------------------- |
|
2712 // CApplicationManagementSession::GetComponentL() |
|
2713 // ------------------------------------------------------------------------------------------------------------------- |
|
2714 |
|
2715 void CApplicationManagementSession::GetComponentL(const RMessage2& aMessage) const |
|
2716 { |
|
2717 RDEBUG( "ApplicationManagementSession: GetComponentL" ); |
|
2718 TUint32 id; |
|
2719 TPckg<TUint32> pid(id); |
|
2720 TInt read(aMessage.Read( 0, pid) ); |
|
2721 |
|
2722 RDEBUG_2( "ApplicationManagementSession: GetComponentL id is %d", id ); |
|
2723 CDeploymentComponent &compo = Server().Storage()->ComponentL(id); |
|
2724 |
|
2725 TDeploymentComponent comp; |
|
2726 compo.CopyStateTo(comp); |
|
2727 |
|
2728 TPckg< TDeploymentComponent> pcomp(comp); |
|
2729 aMessage.Write( 1, pcomp); |
|
2730 } |
|
2731 |
|
2732 // ------------------------------------------------------------------------------------------------------------------- |
|
2733 // CApplicationManagementSession::StartDownloadL() |
|
2734 // ------------------------------------------------------------------------------------------------------------------- |
|
2735 |
|
2736 void CApplicationManagementSession::StartDownloadL(const RMessage2& aMessage) const |
|
2737 { |
|
2738 RDEBUG( "ApplicationManagementSession: StartDownloadL" ); |
|
2739 TUint32 id = 0; |
|
2740 TPckg<TUint32> pid(id); |
|
2741 TInt read(aMessage.Read( 0, pid) ); |
|
2742 |
|
2743 TPckgBuf<TDownloadTarget> target; |
|
2744 read = aMessage.Read( 1, target) ; |
|
2745 RDEBUG_2( "ApplicationManagementSession: StartDownloadL id is %d", id ); |
|
2746 |
|
2747 CDeploymentComponent &compo = Server().Storage()->ComponentL(id); |
|
2748 compo.SetDownloadTarget(target() ); |
|
2749 Server().AddDownloadL( &compo); |
|
2750 } |
|
2751 |
|
2752 // ------------------------------------------------------------------------------------------------------------------- |
|
2753 // CApplicationManagementSession::DeactivateL() |
|
2754 // ------------------------------------------------------------------------------------------------------------------- |
|
2755 |
|
2756 void CApplicationManagementSession::DeactivateL(const RMessage2& aMessage) const |
|
2757 { |
|
2758 RDEBUG( "ApplicationManagementSession: DeactivateL" ); |
|
2759 TUint32 id = 0; |
|
2760 TPckg<TUint32> pid(id); |
|
2761 TInt read(aMessage.Read( 0, pid) ); |
|
2762 |
|
2763 RDEBUG_2( "ApplicationManagementSession: DeactivateL id is %d", id ); |
|
2764 CDeploymentComponent &compo = Server().Storage()->ComponentL(id); |
|
2765 Server().Storage()->DeactivateL(compo); |
|
2766 } |
|
2767 |
|
2768 // ------------------------------------------------------------------------------------------------------------------- |
|
2769 // CApplicationManagementSession::ActivateL() |
|
2770 // ------------------------------------------------------------------------------------------------------------------- |
|
2771 |
|
2772 void CApplicationManagementSession::ActivateL(const RMessage2& aMessage) const |
|
2773 { |
|
2774 RDEBUG( "ApplicationManagementSession: ActivateL" ); |
|
2775 TUint32 id; |
|
2776 TPckg<TUint32> pid(id); |
|
2777 TInt read(aMessage.Read( 0, pid) ); |
|
2778 |
|
2779 RDEBUG_2( "ApplicationManagementSession: ActivateL id is %d", id ); |
|
2780 CDeploymentComponent &compo = Server().Storage()->ComponentL(id); |
|
2781 Server().Storage()->ActivateL(compo); |
|
2782 } |
|
2783 |
|
2784 // ------------------------------------------------------------------------------------------------------------------- |
|
2785 // CApplicationManagementSession::GetUserIdL() |
|
2786 // ------------------------------------------------------------------------------------------------------------------- |
|
2787 |
|
2788 void CApplicationManagementSession::GetUserIdL(const RMessage2& aMessage) const |
|
2789 { |
|
2790 RDEBUG( "ApplicationManagementSession: GetUserIdL" ); |
|
2791 TUint32 id = 0; |
|
2792 TPckg<TUint32> pid(id); |
|
2793 TInt read(aMessage.Read( 0, pid) ); |
|
2794 |
|
2795 RDEBUG_2( "ApplicationManagementSession: GetUserIdL id is %d", id ); |
|
2796 CDeploymentComponent &compo = Server().Storage()->ComponentL(id); |
|
2797 |
|
2798 aMessage.Write( 1, compo.UserId() ); |
|
2799 } |
|
2800 |
|
2801 // ------------------------------------------------------------------------------------------------------------------- |
|
2802 // CApplicationManagementSession::GetTemporaryInstFileL() |
|
2803 // ------------------------------------------------------------------------------------------------------------------- |
|
2804 |
|
2805 void CApplicationManagementSession::GetTemporaryInstFileL( |
|
2806 const RMessage2& aMessage) const |
|
2807 { |
|
2808 // TIpcArgs( &id, &itemid, &filehandle ) |
|
2809 RDEBUG( "ApplicationManagementSession: GetTemporaryInstFileL" ); |
|
2810 TUint32 id; |
|
2811 TPckg<TUint32> pid(id); |
|
2812 TInt read(aMessage.Read( 0, pid) ); |
|
2813 |
|
2814 TDeplCompAttrType item; |
|
2815 TPckg<TDeplCompAttrType> itemid(item); |
|
2816 read = aMessage.Read( 1, itemid); |
|
2817 |
|
2818 RDEBUG_2( "ApplicationManagementSession: GetTemporaryInstFileL id is %d", id ); |
|
2819 CDeploymentComponent &compo = Server().Storage()->ComponentL(id); |
|
2820 |
|
2821 TFileName fileName; |
|
2822 |
|
2823 if (item == EDCData) |
|
2824 { |
|
2825 fileName.Copy(compo.Data().DataFileName() ); |
|
2826 } |
|
2827 else |
|
2828 if (item == EDCMetaData) |
|
2829 { |
|
2830 fileName.Copy(compo.MetaData().DataFileName() ); |
|
2831 } |
|
2832 else |
|
2833 { |
|
2834 RDEBUG_2( "ApplicationManagementSession: GetTemporaryInstFileL: Not supported type: (%d)", item); |
|
2835 User::Leave(KErrNotSupported); |
|
2836 } |
|
2837 |
|
2838 RDEBUG_2( "ApplicationManagementSession: GetTemporaryInstFileL: (%S)", &fileName); |
|
2839 |
|
2840 RFs fs; |
|
2841 User::LeaveIfError(fs.Connect() ); |
|
2842 User::LeaveIfError(fs.ShareProtected() ); |
|
2843 CleanupClosePushL(fs); |
|
2844 RFile file; |
|
2845 User::LeaveIfError(file.Open(fs, fileName, EFileWrite) ); |
|
2846 CleanupClosePushL(file); |
|
2847 |
|
2848 // Takes care of completing with session (RFs), |
|
2849 // SendReceieve returns session handle at client side |
|
2850 User::LeaveIfError(file.TransferToClient(aMessage, 2) ); |
|
2851 CleanupStack::PopAndDestroy(2, &fs); // fs , file |
|
2852 } |
|
2853 |
|
2854 // ------------------------------------------------------------------------------------------------------------------- |
|
2855 // CApplicationManagementSession::PackageSizeL() |
|
2856 // ------------------------------------------------------------------------------------------------------------------- |
|
2857 |
|
2858 TInt CApplicationManagementSession::PackageSizeL( |
|
2859 Swi::RSisRegistrySession& aSession, Swi::RSisRegistryEntry& aEntry) |
|
2860 { |
|
2861 RPointerArray<Swi::CSisRegistryPackage> listPackages; |
|
2862 TInt size(0); |
|
2863 TInt err(0); |
|
2864 CleanupClosePushL(listPackages); |
|
2865 |
|
2866 aEntry.AugmentationsL(listPackages); |
|
2867 |
|
2868 for (TInt index(0); index < listPackages.Count(); index++) |
|
2869 { |
|
2870 TRAP(err, AugmentationSizeL( aSession, *listPackages[index])) |
|
2871 if (err != KErrNone) |
|
2872 { |
|
2873 break; |
|
2874 } |
|
2875 } |
|
2876 |
|
2877 if (err != KErrNone) |
|
2878 { |
|
2879 size = 0; |
|
2880 } |
|
2881 else |
|
2882 { |
|
2883 TRAP(err, size += aEntry.SizeL() ); |
|
2884 } |
|
2885 |
|
2886 listPackages.ResetAndDestroy(); |
|
2887 CleanupStack::PopAndDestroy( &listPackages); |
|
2888 |
|
2889 if (err != KErrNone) |
|
2890 { |
|
2891 //We leave if there was an error, |
|
2892 // but we have to clean up the listPackages before the leave. |
|
2893 User::Leave(err); |
|
2894 } |
|
2895 |
|
2896 return size; |
|
2897 } |
|
2898 |
|
2899 // ------------------------------------------------------------------------------------------------ |
|
2900 // CAppMngrSisxInfo::AugmentationSizeL() |
|
2901 // Returns the Size of the package |
|
2902 // (other items were commented in a header). |
|
2903 // ------------------------------------------------------------------------------------------------ |
|
2904 // |
|
2905 TInt CApplicationManagementSession::AugmentationSizeL( |
|
2906 Swi::RSisRegistrySession& aSession, |
|
2907 const Swi::CSisRegistryPackage& aPackage) |
|
2908 { |
|
2909 TInt size(0); |
|
2910 Swi::RSisRegistryEntry regEntry; |
|
2911 CleanupClosePushL(regEntry); |
|
2912 |
|
2913 regEntry.OpenL(aSession, aPackage); |
|
2914 size += PackageSizeL(aSession, regEntry); |
|
2915 |
|
2916 CleanupStack::PopAndDestroy( ®Entry); |
|
2917 |
|
2918 return size; |
|
2919 } |
|
2920 |
|
2921 // ------------------------------------------------------------------------------------------------------------------- |
|
2922 // CApplicationManagementSession::LookupSisRegistryL() |
|
2923 // ------------------------------------------------------------------------------------------------------------------- |
|
2924 |
|
2925 void CApplicationManagementSession::LookupSisRegistryL() |
|
2926 { |
|
2927 Swi::RSisRegistrySession sisses; |
|
2928 TInt r(sisses.Connect() ); |
|
2929 RPointerArray<Swi::CSisRegistryPackage> pkgs(12); |
|
2930 sisses.InstalledPackagesL(pkgs); |
|
2931 |
|
2932 TInt count(pkgs.Count() ); |
|
2933 for (TInt i( 0); i < count; i++) |
|
2934 { |
|
2935 Swi::CSisRegistryPackage* p = pkgs[i]; |
|
2936 |
|
2937 RDEBUG_5(" Found package: %d, '%S', uid: 0x%X, size: %d" , |
|
2938 i, &p->Name(), p->Uid().iUid, AugmentationSizeL( sisses, *p ) ); |
|
2939 } |
|
2940 |
|
2941 sisses.Close(); |
|
2942 pkgs.ResetAndDestroy(); |
|
2943 |
|
2944 } |
|
2945 |
|
2946 // ------------------------------------------------------------------------------------------------------------------- |
|
2947 // CApplicationManagementSession::InstallL() |
|
2948 // ------------------------------------------------------------------------------------------------------------------- |
|
2949 |
|
2950 void CApplicationManagementSession::InstallL(const RMessage2& aMessage) const |
|
2951 { |
|
2952 RDEBUG( "ApplicationManagementSession: InstallL" ); |
|
2953 TUint32 id; |
|
2954 TPckg<TUint32> pid(id); |
|
2955 TInt read(aMessage.Read( 0, pid) ); |
|
2956 |
|
2957 TDeploymentComponentState targetst; |
|
2958 TPckg<TDeploymentComponentState> pk(targetst); |
|
2959 |
|
2960 read = aMessage.Read( 1, pk) ; |
|
2961 |
|
2962 RDEBUG_3( "ApplicationManagementSession: InstallL id is %d, targetstate %d", |
|
2963 id, targetst ); |
|
2964 |
|
2965 CDeploymentComponent &compo = Server().Storage()->ComponentL(id); |
|
2966 if (compo.State() == EDCSDelivered) |
|
2967 { |
|
2968 Server().DoTheInstallL(compo) ; |
|
2969 } |
|
2970 else |
|
2971 { |
|
2972 User::Leave(KErrArgument); |
|
2973 } |
|
2974 RDEBUG_2( "ApplicationManagementSession: InstallL success. New compo state (%d)", compo.State()); |
|
2975 } |
|
2976 |
|
2977 // ------------------------------------------------------------------------------------------------------------------- |
|
2978 // CApplicationManagementSession::UpdateDataL() |
|
2979 // ------------------------------------------------------------------------------------------------------------------- |
|
2980 |
|
2981 void CApplicationManagementSession::UpdateDataL(const RMessage2& aMessage) const |
|
2982 { |
|
2983 RDEBUG( "ApplicationManagementSession: UpdateDataL" ); |
|
2984 |
|
2985 TDeplCompDataIPC ipc; |
|
2986 TPckg<TDeplCompDataIPC> pipc(ipc); |
|
2987 TInt read(aMessage.Read( 0, pipc) ); |
|
2988 RDEBUG_2( "ApplicationManagementSession: UpdateDataL id is %d", ipc.iInternalId ); |
|
2989 |
|
2990 HBufC8 *buf = HBufC8::NewLC(aMessage.GetDesLength( 1) ); |
|
2991 TPtr8 pbuf(buf->Des() ); |
|
2992 TInt read2(aMessage.Read( 1, pbuf) ); |
|
2993 |
|
2994 CDeploymentComponent &compo = Server().Storage()->ComponentL(ipc.iInternalId); |
|
2995 |
|
2996 if (Server().CheckB64Encode(pbuf) ) |
|
2997 { |
|
2998 RDEBUG( "ApplicationManagementSession: UpdateDataL data is base64 encoded"); |
|
2999 // b64 encoded data, decode it |
|
3000 HBufC8* tmp; |
|
3001 tmp = Server().DecodeB64DataLC(pbuf); |
|
3002 pbuf.Copy( *tmp); |
|
3003 pbuf = buf->Des(); |
|
3004 CleanupStack::PopAndDestroy(tmp); |
|
3005 } |
|
3006 |
|
3007 if (compo.State() == EDCSDelivered) |
|
3008 { |
|
3009 if (ipc.iAttrType == EDCData) |
|
3010 { |
|
3011 compo.SetDataL(pbuf, ipc.iDataMime); |
|
3012 } |
|
3013 else |
|
3014 if (ipc.iAttrType == EDCMetaData) |
|
3015 { |
|
3016 compo.SetMetaDataL(pbuf, ipc.iDataMime); |
|
3017 } |
|
3018 else |
|
3019 { |
|
3020 RDEBUG_2( "ApplicationManagementSession::UpdateDataL - ERROR UpdateDataL called for illegal item: %d!", ipc.iAttrType ); |
|
3021 User::Leave(KErrArgument); |
|
3022 } |
|
3023 |
|
3024 Server().Storage()->UpdateL(compo); |
|
3025 } |
|
3026 else |
|
3027 { |
|
3028 RDEBUG( "ApplicationManagementSession::UpdateDataL - ERROR UpdateDataL called for illegal state message!" ); |
|
3029 User::Leave(KErrArgument); |
|
3030 } |
|
3031 CleanupStack::PopAndDestroy(buf); |
|
3032 } |
|
3033 |
|
3034 // ------------------------------------------------------------------------------------------------------------------- |
|
3035 // CApplicationManagementSession::UpdateStreamedDataL() |
|
3036 // ------------------------------------------------------------------------------------------------------------------- |
|
3037 |
|
3038 void CApplicationManagementSession::UpdateStreamedDataL( |
|
3039 const RMessage2& aMessage) const |
|
3040 { |
|
3041 RDEBUG( "ApplicationManagementSession: UpdateStreamedDataL() Start"); |
|
3042 TDeplCompDataIPC ipc; |
|
3043 TPckg<TDeplCompDataIPC> pipc(ipc); |
|
3044 TInt read(aMessage.Read( 0, pipc) ); |
|
3045 RDEBUG_2( "ApplicationManagementSession: UpdateStreamedDataL id is %d", ipc.iInternalId ); |
|
3046 |
|
3047 CDeploymentComponent &compo = Server().Storage()->ComponentL(ipc.iInternalId); |
|
3048 |
|
3049 if (compo.State() == EDCSDelivered) |
|
3050 { |
|
3051 RFs fs; |
|
3052 User::LeaveIfError(fs.Connect() ); |
|
3053 CleanupClosePushL(fs); |
|
3054 RFile file; |
|
3055 TFileName dataFileName; |
|
3056 TInt length(0); |
|
3057 |
|
3058 if (ipc.iAttrType == EDCData) |
|
3059 { |
|
3060 dataFileName.Copy(compo.Data().DataFileName() ) ; |
|
3061 } |
|
3062 else |
|
3063 if (ipc.iAttrType == EDCMetaData) |
|
3064 { |
|
3065 dataFileName.Copy(compo.MetaData().DataFileName() ) ; |
|
3066 } |
|
3067 else |
|
3068 { |
|
3069 RDEBUG_2( "ApplicationManagementSession::UpdateStreamedDataL - ERROR called for illegal item: %d!", ipc.iAttrType ); |
|
3070 User::Leave(KErrArgument); |
|
3071 } |
|
3072 |
|
3073 RDEBUG_2( "ApplicationManagementSession::UpdateStreamedDataL(): using dataFile: (%S)", &dataFileName ); |
|
3074 |
|
3075 // EFileWrite So we can delete the original decoded data file |
|
3076 User::LeaveIfError(file.Open(fs, dataFileName, EFileWrite) ); |
|
3077 CleanupClosePushL(file) ; |
|
3078 if (Server().IsDataFileB64EncodedL(file, length) ) |
|
3079 { |
|
3080 RDEBUG( "CApplicationManagementServer::UpdateStreamedDataL(): data is decoded" ); |
|
3081 |
|
3082 TFileName tempFileName; |
|
3083 TBuf<30> privatePath; |
|
3084 fs.PrivatePath(privatePath); |
|
3085 RFile tempFile; |
|
3086 TInt err(KErrNone); |
|
3087 err = tempFile.Temp(fs, privatePath, tempFileName, EFileWrite); |
|
3088 if (err == KErrNone) |
|
3089 { |
|
3090 RDEBUG_2( "ApplicationManagementSession::UpdateStreamedDataL(): created tempFile: (%S)", &tempFileName ); |
|
3091 } |
|
3092 else |
|
3093 { |
|
3094 User::Leave(err); |
|
3095 } |
|
3096 CleanupClosePushL(tempFile); |
|
3097 |
|
3098 TRAP( err, Server().DecodeB64DataFileL( file, tempFile ) ); |
|
3099 if (err != KErrNone) |
|
3100 { |
|
3101 RDEBUG_2( "ApplicationManagementSession::UpdateStreamedDataL - failed to decode datafile: %d", err ); |
|
3102 CleanupStack::PopAndDestroy( 2, &file); |
|
3103 compo.ResetDataL(fs); // Remove both files if exists |
|
3104 User::Leave(err); |
|
3105 } |
|
3106 else |
|
3107 { |
|
3108 // close both files, delete decode file and rename temp file to correct one |
|
3109 CleanupStack::PopAndDestroy( 2, &file); |
|
3110 fs.Delete(dataFileName); |
|
3111 err = fs.Rename(tempFileName, dataFileName); |
|
3112 RDEBUG_2( "ApplicationManagementSession::UpdateStreamedDataL - successfully decoded datafile: %d", err ); |
|
3113 } |
|
3114 CleanupStack::PopAndDestroy( &fs); |
|
3115 } |
|
3116 else |
|
3117 { |
|
3118 RDEBUG( "ApplicationManagementSession::UpdateStreamedDataL(): data is NOT decoded" ); |
|
3119 CleanupStack::PopAndDestroy( 2, &fs); |
|
3120 } |
|
3121 |
|
3122 if (ipc.iAttrType == EDCData) |
|
3123 { |
|
3124 compo.SetDataL(ipc.iDataMime); |
|
3125 } |
|
3126 else |
|
3127 { |
|
3128 compo.SetMetaDataL(ipc.iDataMime); |
|
3129 } |
|
3130 |
|
3131 Server().Storage()->UpdateL(compo); |
|
3132 } |
|
3133 else |
|
3134 { |
|
3135 RDEBUG( "ApplicationManagementSession::UpdateStreamedDataL - ERROR called for illegal state message!" ); |
|
3136 User::Leave(KErrArgument); |
|
3137 } |
|
3138 RDEBUG( "ApplicationManagementSession: UpdateStreamedDataL() End"); |
|
3139 } |
|
3140 |
|
3141 // ------------------------------------------------------------------------------------------------------------------- |
|
3142 // CApplicationManagementSession::UpdateL() |
|
3143 // ------------------------------------------------------------------------------------------------------------------- |
|
3144 |
|
3145 void CApplicationManagementSession::UpdateL(const RMessage2& aMessage) const |
|
3146 { |
|
3147 RDEBUG( "ApplicationManagementSession: UpdateL" ); |
|
3148 |
|
3149 TUint32 id; |
|
3150 TPckg<TUint32> pid(id); |
|
3151 TInt read(aMessage.Read( 0, pid) ); |
|
3152 RDEBUG_2("ApplicationManagementSession: UpdateL id is %d", id ); |
|
3153 |
|
3154 TDeplCompAttrType item; |
|
3155 TPckg<TDeplCompAttrType> itemid(item); |
|
3156 TInt read1(aMessage.Read( 1, itemid) ); |
|
3157 HBufC8 *buf = HBufC8::NewLC(aMessage.GetDesLength( 2) ); |
|
3158 TPtr8 pbuf(buf->Des() ); |
|
3159 TInt read2(aMessage.Read( 2, pbuf) ); |
|
3160 |
|
3161 CDeploymentComponent &c = Server().Storage()->ComponentL(id); |
|
3162 TDeploymentComponentState st(c.State() ); |
|
3163 if (st == EDCSDelivered || st == EDCSDownload) |
|
3164 { |
|
3165 switch (item) |
|
3166 { |
|
3167 case EDCId: |
|
3168 { |
|
3169 c.SetIdL(pbuf); |
|
3170 break; |
|
3171 } |
|
3172 case EDCName: |
|
3173 { |
|
3174 c.SetNameL(pbuf); |
|
3175 break; |
|
3176 } |
|
3177 case EDCVersion: |
|
3178 { |
|
3179 c.SetVersionL(pbuf); |
|
3180 break; |
|
3181 } |
|
3182 case EDCDescriptionRef: |
|
3183 { |
|
3184 c.SetDescriptionL(pbuf); |
|
3185 break; |
|
3186 } |
|
3187 case EDCInstallOptions: |
|
3188 { |
|
3189 c.SetInstallOptsL(pbuf); |
|
3190 break; |
|
3191 } |
|
3192 case EDCMetaData: |
|
3193 { |
|
3194 c.SetMetaDataL(pbuf, KNullDesC8); |
|
3195 break; |
|
3196 } |
|
3197 case EDCPkgID: |
|
3198 { |
|
3199 c.SetPkgIDL(pbuf); |
|
3200 break; |
|
3201 } |
|
3202 case EDCPkgType: |
|
3203 { |
|
3204 c.SetPkgTypeL(pbuf); |
|
3205 break; |
|
3206 } |
|
3207 |
|
3208 default: |
|
3209 { |
|
3210 if (st == EDCSDelivered) |
|
3211 { |
|
3212 switch (item) |
|
3213 { |
|
3214 case EDCData: |
|
3215 { |
|
3216 c.SetDataL(pbuf, KNullDesC8); |
|
3217 if (c.State() == EDCSDownload) |
|
3218 { |
|
3219 // Server().StartDownload( *compo ); |
|
3220 } |
|
3221 break; |
|
3222 } |
|
3223 default: |
|
3224 { |
|
3225 RDEBUG_2("ApplicationManagementSession: ERROR UpdateL called for illegal item type!!!! %d", item ); |
|
3226 User::Leave(KErrArgument); |
|
3227 } |
|
3228 } |
|
3229 } |
|
3230 else |
|
3231 if (st == EDCSDownload) |
|
3232 { |
|
3233 switch (item) |
|
3234 { |
|
3235 case EDCId: |
|
3236 { |
|
3237 c.SetIdL(pbuf); |
|
3238 break; |
|
3239 } |
|
3240 case EDCName: |
|
3241 { |
|
3242 c.SetNameL(pbuf); |
|
3243 break; |
|
3244 } |
|
3245 case EDCVersion: |
|
3246 { |
|
3247 c.SetVersionL(pbuf); |
|
3248 break; |
|
3249 } |
|
3250 case EDCDownloadURI: |
|
3251 { |
|
3252 c.SetDownloadURIL(pbuf); |
|
3253 break; |
|
3254 } |
|
3255 case EDCConRef: |
|
3256 { |
|
3257 TPckgBuf<TInt> aInt; |
|
3258 aInt.Copy(pbuf); |
|
3259 c.SetIAPL(aInt() ); |
|
3260 break; |
|
3261 } |
|
3262 default: |
|
3263 { |
|
3264 RDEBUG_2( "ApplicationManagementSession: ERROR UpdateL called for illegal item type!!!! %d", item ); |
|
3265 User::Leave(KErrArgument); |
|
3266 break; |
|
3267 } |
|
3268 } |
|
3269 } |
|
3270 break; |
|
3271 } |
|
3272 } |
|
3273 Server().Storage()->UpdateL(c); |
|
3274 } |
|
3275 else |
|
3276 if (st == EDCSActive ||st == EDCSInactive) |
|
3277 { |
|
3278 switch (item) |
|
3279 { |
|
3280 case EDCName: |
|
3281 { |
|
3282 c.SetNameL(pbuf); |
|
3283 break; |
|
3284 } |
|
3285 case EDCVersion: |
|
3286 { |
|
3287 c.SetVersionL(pbuf); |
|
3288 break; |
|
3289 } |
|
3290 case EDCDescriptionRef: |
|
3291 { |
|
3292 c.SetDescriptionL(pbuf); |
|
3293 break; |
|
3294 } |
|
3295 default: |
|
3296 { |
|
3297 RDEBUG_2( "ApplicationManagementSession: ERROR UpdateL called for illegal item type!!!! %d", item ); |
|
3298 User::Leave(KErrArgument); |
|
3299 break; |
|
3300 } |
|
3301 } |
|
3302 Server().Storage()->UpdateL(c); |
|
3303 } |
|
3304 else |
|
3305 { |
|
3306 RDEBUG( "ApplicationManagementSession: ERROR UpdateL called for illegal state message!" ); |
|
3307 User::Leave(KErrArgument); |
|
3308 } |
|
3309 CleanupStack::PopAndDestroy(buf); |
|
3310 } |
|
3311 |
|
3312 // ------------------------------------------------------------------------------------------------------------------- |
|
3313 // CApplicationManagementSession::GetDataLengthL() |
|
3314 // ------------------------------------------------------------------------------------------------------------------- |
|
3315 |
|
3316 void CApplicationManagementSession::GetDataLengthL(const RMessage2& aMessage) const |
|
3317 { |
|
3318 RDEBUG( "ApplicationManagementSession: GetDataLengthL" ); |
|
3319 TUint32 id; |
|
3320 TPckg<TUint32> pid(id); |
|
3321 |
|
3322 TInt read(aMessage.Read( 0, pid) ); |
|
3323 |
|
3324 TInt length( 0); |
|
3325 |
|
3326 TDeplCompAttrType dt; |
|
3327 TPckg< TDeplCompAttrType> pdt(dt); |
|
3328 read = aMessage.Read( 1, pdt) ; |
|
3329 CDeploymentComponent &compo = Server().Storage()->ComponentL(id); |
|
3330 if (compo.State() == EDCSDelivered) |
|
3331 { |
|
3332 if (dt == EDCInstallOptions) |
|
3333 { |
|
3334 if (compo.InstallOptsSet() ) |
|
3335 { |
|
3336 length = sizeof(TAMInstallOptions); |
|
3337 } |
|
3338 } |
|
3339 else |
|
3340 if (dt == EDCData) |
|
3341 { |
|
3342 length = compo.Data().DataLengthL(); |
|
3343 } |
|
3344 else |
|
3345 if (dt == EDCDataMime) |
|
3346 { |
|
3347 length = compo.Data().MimeType().Length(); |
|
3348 } |
|
3349 else |
|
3350 if (dt == EDCMetaData) |
|
3351 { |
|
3352 length = compo.MetaData().DataLengthL(); |
|
3353 } |
|
3354 else |
|
3355 if (dt == EDCMetaDataMime) |
|
3356 { |
|
3357 length = compo.MetaData().MimeType().Length(); |
|
3358 } |
|
3359 else |
|
3360 { |
|
3361 RDEBUG_2( "ApplicationManagementSession: GetDataLengthL ERROR called with illegal type %d", dt ); |
|
3362 User::Leave(KErrArgument); |
|
3363 } |
|
3364 } |
|
3365 else |
|
3366 if (compo.State() == EDCSDownload) |
|
3367 { |
|
3368 if (dt == EDCDownloadURI) |
|
3369 { |
|
3370 length = compo.DownloadURI().Length(); |
|
3371 } |
|
3372 else |
|
3373 if (dt == EDCInstallOptions) |
|
3374 { |
|
3375 if (compo.InstallOptsSet() ) |
|
3376 { |
|
3377 length = sizeof(TAMInstallOptions); |
|
3378 } |
|
3379 } |
|
3380 else |
|
3381 { |
|
3382 RDEBUG_2( "ApplicationManagementSession: GetDataLengthL ERROR Download / called with illegal state component id %d", |
|
3383 compo.State() ); |
|
3384 User::Leave(KErrArgument); |
|
3385 } |
|
3386 } |
|
3387 else |
|
3388 { |
|
3389 RDEBUG_2( "ApplicationManagementSession: GetDataLengthL ERROR called with illegal state component id %d", |
|
3390 compo.State() ); |
|
3391 User::Leave(KErrArgument); |
|
3392 } |
|
3393 |
|
3394 TPckg< TInt> pcomp(length); |
|
3395 aMessage.Write( 2, pcomp); |
|
3396 } |
|
3397 |
|
3398 // ------------------------------------------------------------------------------------------------------------------- |
|
3399 // CApplicationManagementSession::GetDataL() |
|
3400 // ------------------------------------------------------------------------------------------------------------------- |
|
3401 |
|
3402 void CApplicationManagementSession::GetDataL(const RMessage2& aMessage) const |
|
3403 { |
|
3404 RDEBUG( "ApplicationManagementSession: GetDataL" ); |
|
3405 TUint32 id; |
|
3406 TPckg<TUint32> pid(id); |
|
3407 |
|
3408 TInt read(aMessage.Read( 0, pid) ); |
|
3409 |
|
3410 TDeplCompAttrType dt; |
|
3411 TPckg< TDeplCompAttrType> pdt(dt); |
|
3412 read = aMessage.Read( 1, pdt) ; |
|
3413 |
|
3414 RDEBUG_3( "ApplicationManagementSession: GetDataL id is %d, and attribute %d", id, dt ); |
|
3415 CDeploymentComponent &compo = Server().Storage()->ComponentL(id); |
|
3416 if (dt == EDCStatus) |
|
3417 { |
|
3418 TPckg<TInt> p(compo.Status() ); |
|
3419 aMessage.Write( 2, p); |
|
3420 } |
|
3421 else |
|
3422 if (compo.State() == EDCSDelivered) |
|
3423 { |
|
3424 if (dt == EDCInstallOptions) |
|
3425 { |
|
3426 if (compo.InstallOptsSet() ) |
|
3427 { |
|
3428 TAMInstallOptionsPckgBuf pckg(compo.InstallOpts() ); |
|
3429 aMessage.Write( 2, pckg); |
|
3430 } |
|
3431 else |
|
3432 { |
|
3433 aMessage.Write( 2, KNullDesC8); |
|
3434 } |
|
3435 } |
|
3436 else |
|
3437 if (dt == EDCData) |
|
3438 { |
|
3439 aMessage.Write( 2, compo.Data().Data() ); |
|
3440 } |
|
3441 else |
|
3442 if (dt == EDCDataMime) |
|
3443 { |
|
3444 aMessage.Write( 2, compo.Data().MimeType() ); |
|
3445 } |
|
3446 else |
|
3447 if (dt == EDCMetaData) |
|
3448 { |
|
3449 aMessage.Write( 2, compo.MetaData().Data() ); |
|
3450 } |
|
3451 else |
|
3452 if (dt == EDCMetaDataMime) |
|
3453 { |
|
3454 aMessage.Write( 2, compo.MetaData().MimeType() ); |
|
3455 } |
|
3456 else |
|
3457 { |
|
3458 RDEBUG_2( "ApplicationManagementSession: GetDataL ERROR called with illegal type %d", dt ); |
|
3459 User::Leave(KErrArgument); |
|
3460 } |
|
3461 } |
|
3462 else |
|
3463 if (compo.State() == EDCSDownload) |
|
3464 { |
|
3465 |
|
3466 if (dt == EDCDownloadURI) |
|
3467 { |
|
3468 aMessage.Write( 2, compo.DownloadURI() ); |
|
3469 } |
|
3470 |
|
3471 else |
|
3472 if (dt == EDCInstallOptions) |
|
3473 { |
|
3474 if (compo.InstallOptsSet() ) |
|
3475 { |
|
3476 TAMInstallOptionsPckgBuf |
|
3477 pckg(compo.InstallOpts() ); |
|
3478 aMessage.Write( 2, pckg); |
|
3479 } |
|
3480 else |
|
3481 { |
|
3482 aMessage.Write( 2, KNullDesC8); |
|
3483 } |
|
3484 } |
|
3485 else |
|
3486 if (dt == EDCConRef) |
|
3487 { |
|
3488 TPckg<TInt> p(compo.GetIAP() ); |
|
3489 aMessage.Write( 2, p); |
|
3490 } |
|
3491 else |
|
3492 { |
|
3493 RDEBUG_2( "ApplicationManagementSession:GetDataL ERROR called with illegal type %d", dt ); |
|
3494 User::Leave(KErrArgument); |
|
3495 } |
|
3496 } |
|
3497 else |
|
3498 { |
|
3499 RDEBUG_2("ApplicationManagementSession: GetDataL ERROR called with illegal state component id %d", compo.State() ); |
|
3500 User::Leave(KErrArgument); |
|
3501 } |
|
3502 } |
|
3503 |
|
3504 // ------------------------------------------------------------------------------------------------------------------- |
|
3505 // CApplicationManagementSession::RemoveL() |
|
3506 // ------------------------------------------------------------------------------------------------------------------- |
|
3507 |
|
3508 void CApplicationManagementSession::RemoveL(const RMessage2& aMessage) const |
|
3509 { |
|
3510 RDEBUG( "ApplicationManagementSession: RemoveL" ); |
|
3511 TUint32 id; |
|
3512 TPckg<TUint32> pid(id); |
|
3513 TInt read(aMessage.Read( 0, pid) ); |
|
3514 RDEBUG_2( "ApplicationManagementSession: RemoveL id is %d", id ); |
|
3515 RemoveInternalL(id); |
|
3516 } |
|
3517 |
|
3518 // ------------------------------------------------------------------------------------------------------------------- |
|
3519 // CApplicationManagementSession::RemoveInternalL() |
|
3520 // ------------------------------------------------------------------------------------------------------------------- |
|
3521 |
|
3522 void CApplicationManagementSession::RemoveInternalL(const TUint32 &aId) const |
|
3523 { |
|
3524 CDeploymentComponent &compo = Server().Storage()->ComponentL(aId); |
|
3525 |
|
3526 Server().RemoveInternalL(compo); |
|
3527 } |
|
3528 |
|
3529 // ------------------------------------------------------------------------------------------------------------------- |
|
3530 // CApplicationManagementSession::DownloadL() |
|
3531 // ------------------------------------------------------------------------------------------------------------------- |
|
3532 |
|
3533 void CApplicationManagementSession::DownloadL(const RMessage2& aMessage) const |
|
3534 { |
|
3535 RDEBUG( "ApplicationManagementSession: DownloadL" ); |
|
3536 |
|
3537 TDCUserId userId; |
|
3538 aMessage.ReadL( 1, userId); |
|
3539 CDeploymentComponent *compo= NULL; |
|
3540 |
|
3541 if (iTrustAdded) |
|
3542 { |
|
3543 compo = Server().Storage()->NewComponentL(EDCSDownload, userId, &iCertInfo); |
|
3544 } |
|
3545 else |
|
3546 { |
|
3547 compo = Server().Storage()->NewComponentL(EDCSDownload, userId); |
|
3548 } |
|
3549 TUint32 i(compo->InternalId() ); |
|
3550 TPckg<TUint32> p(i); |
|
3551 aMessage.WriteL(0, p); |
|
3552 } |
|
3553 |
|
3554 // ------------------------------------------------------------------------------------------------------------------- |
|
3555 // CApplicationManagementSession::FullUpdateL() |
|
3556 // ------------------------------------------------------------------------------------------------------------------- |
|
3557 |
|
3558 void CApplicationManagementSession::FullUpdateL(const RMessage2& aMessage) const |
|
3559 { |
|
3560 RDEBUG( "ApplicationManagementSession: FullUpdateL" ); |
|
3561 |
|
3562 TUint32 sid; |
|
3563 |
|
3564 TPckg<TUint32> psid(sid); |
|
3565 TInt read(aMessage.Read( 0, psid) ); |
|
3566 TUint32 tid; |
|
3567 TPckg<TUint32> ptid(tid); |
|
3568 TInt read2(aMessage.Read( 1, ptid) ); |
|
3569 |
|
3570 RDEBUG_3( "ApplicationManagementSession: FullUpdateL sid is %d, tid is %d", sid, tid ); |
|
3571 CApplicationManagementServer &server = Server(); |
|
3572 server.FullUpdateL(sid, tid); |
|
3573 } |
|
3574 |
|
3575 // ------------------------------------------------------------------------------------------------------------------- |
|
3576 // CApplicationManagementSession::ServiceError() |
|
3577 // ------------------------------------------------------------------------------------------------------------------- |
|
3578 |
|
3579 void CApplicationManagementSession::ServiceError(const RMessage2& aMessage, |
|
3580 TInt aError) |
|
3581 { |
|
3582 RDEBUG_2( "ApplicationManagementSession: CApplicationManagementSession::ServiceError %d", aError); |
|
3583 CSession2::ServiceError(aMessage, aError); |
|
3584 } |
|
3585 |
|
3586 // ------------------------------------------------------------------------------------------------------------------- |
|
3587 // CApplicationManagementSession::AddTrustL() |
|
3588 // ------------------------------------------------------------------------------------------------------------------- |
|
3589 |
|
3590 void CApplicationManagementSession::AddTrustL(const RMessage2 &aMessage) |
|
3591 { |
|
3592 TPckg<TCertInfo> pkg(iCertInfo); |
|
3593 aMessage.ReadL( 0, pkg); |
|
3594 iTrustAdded = ETrue; |
|
3595 } |
|
3596 |
|
3597 // ------------------------------------------------------------------------------------------------------------------- |
|
3598 // CApplicationManagementSession::StateChangeComponentIdsL() |
|
3599 // ------------------------------------------------------------------------------------------------------------------- |
|
3600 |
|
3601 void CApplicationManagementSession::StateChangeComponentIdsL( |
|
3602 const RMessage2& aMessage) const |
|
3603 { |
|
3604 RDEBUG( "CApplicationManagementSession: StateChangeComponentIdsL" ); |
|
3605 RComponentIdArray arr; |
|
3606 Server().Storage()->GetStateChangeComponentIdsL(arr); |
|
3607 TInt buflen(arr.Count() ); |
|
3608 TUint32* buf = new ( ELeave ) TUint32[buflen]; |
|
3609 CleanupArrayDeletePushL(buf); |
|
3610 for (TInt i( 0); i < buflen; i++) |
|
3611 { |
|
3612 RDEBUG_2( "ApplicationManagementSession:ComponentIdsL Adding %d!!", arr[i]); |
|
3613 buf[i] = arr[i]; |
|
3614 } |
|
3615 TPtrC8 p( ( TUint8* ) buf, buflen * sizeof(TUint32)); |
|
3616 aMessage.WriteL( 0, p); |
|
3617 arr.Close(); |
|
3618 CleanupStack::PopAndDestroy(buf); |
|
3619 RDEBUG( "CApplicationManagementSession: StateChangeComponentIdsL end" ); |
|
3620 |
|
3621 } |
|
3622 |
|
3623 // ------------------------------------------------------------------------------------------------------------------- |
|
3624 // CApplicationManagementSession::StateChangeComponentIdsCountL() |
|
3625 // ------------------------------------------------------------------------------------------------------------------- |
|
3626 |
|
3627 void CApplicationManagementSession::StateChangeComponentIdsCountL( |
|
3628 const RMessage2& aMessage) const |
|
3629 { |
|
3630 RDEBUG( "CApplicationManagementSession: StateChangeComponentIdsCountL" ); |
|
3631 RPointerArray<TPreInstalledAppParams> preInstalledAppParams; |
|
3632 CAMPreInstallApp* preInstallApp = CAMPreInstallApp::NewL(); |
|
3633 preInstallApp->GetPreInstalledAppsL(preInstalledAppParams); |
|
3634 TInt count = 0; |
|
3635 for (count = 0; count< preInstalledAppParams.Count(); count++) |
|
3636 { |
|
3637 RDEBUG8_2("CApplicationManagementSession::DownloadL: Installed App Name is: %S",&(preInstalledAppParams[count]->iPreInstalledAppame)); |
|
3638 RDEBUG8_2("CApplicationManagementSession::DownloadL: Installed App Vendor is: %S",&(preInstalledAppParams[count]->iPreInstalledAppVendorName)); |
|
3639 RDEBUG_2("CApplicationManagementSession::DownloadL: Installed App UID is : '0x%X'",preInstalledAppParams[count]->iPreInstalledAppUid); |
|
3640 |
|
3641 TBool found = EFalse; |
|
3642 const RComponentIdArray &arrt = Server().Storage()->GetComponentIds(); |
|
3643 TInt countval(arrt.Count() ); |
|
3644 for (TInt i( 0); i < countval; i++) |
|
3645 { |
|
3646 CDeploymentComponent &compo = Server().Storage()->ComponentL(arrt[i]); |
|
3647 if (compo.Uid()== preInstalledAppParams[count]->iPreInstalledAppUid) |
|
3648 { |
|
3649 RDEBUG( "CApplicationManagementSession: ActiveComponentsL found= TRUE" ); |
|
3650 found = ETrue; |
|
3651 } |
|
3652 } |
|
3653 if (!found) |
|
3654 { |
|
3655 RDEBUG( "CApplicationManagementSession: Adding Pre-installed app" ); |
|
3656 TDCUserId preInstalledAppName; |
|
3657 preInstalledAppName.Copy(preInstalledAppParams[count]->iPreInstalledAppame); |
|
3658 CDeploymentComponent *preInstallCompo= NULL; |
|
3659 RDEBUG8_2("CApplicationManagementSession: Installed App Name is: %S",&preInstalledAppName); |
|
3660 preInstallCompo = Server().Storage()->NewComponentL(EDCSActive, preInstalledAppName); |
|
3661 preInstallCompo->SetUid(preInstalledAppParams[count]->iPreInstalledAppUid); |
|
3662 preInstallCompo->SetNameL(preInstalledAppName); |
|
3663 preInstallCompo->SetVersionL(preInstalledAppParams[count]->iVersion); |
|
3664 preInstallCompo->SetMimeTypeL(preInstalledAppParams[count]->iMimeType); |
|
3665 Server().Storage()->UpdateL( *preInstallCompo ); |
|
3666 Server().Storage()->CheckForDuplicateNodesInDeployedL(*preInstallCompo); |
|
3667 } |
|
3668 } |
|
3669 delete preInstallApp; |
|
3670 RComponentIdArray arr; |
|
3671 Server().Storage()->GetStateChangeComponentIdsL(arr); |
|
3672 TPckgBuf<TInt> buflen(arr.Count() ); |
|
3673 aMessage.WriteL( 0, buflen); |
|
3674 arr.Close(); |
|
3675 RDEBUG( "CApplicationManagementSession: StateChangeComponentIdsCountL end" ); |
|
3676 } |
|
3677 |
|
3678 // ------------------------------------------------------------------------------------------------------------------- |
|
3679 // CApplicationManagementSession::StateChangeCompleteL() |
|
3680 // ------------------------------------------------------------------------------------------------------------------- |
|
3681 |
|
3682 void CApplicationManagementSession::StateChangeCompleteL( |
|
3683 const RMessage2& aMessage) const |
|
3684 { |
|
3685 RDEBUG( "CApplicationManagementSession: StateChangeCompleteL" ); |
|
3686 TUint32 tid; |
|
3687 TPckg<TUint32> ptid(tid); |
|
3688 TInt read2(aMessage.Read( 0, ptid) ); |
|
3689 Server().Storage()->StateChangedL(tid); |
|
3690 } |
|
3691 void CApplicationManagementSession::CheckStatusNodesValuesL() |
|
3692 { |
|
3693 const RComponentIdArray &arrt = Server().Storage()->GetComponentIds(); |
|
3694 TInt cont(arrt.Count() ); |
|
3695 TBool isUpdateRequired = ETrue; |
|
3696 for (TInt i( 0); i < cont; i++) |
|
3697 { |
|
3698 CDeploymentComponent &compo = Server().Storage()->ComponentL(arrt[i]); |
|
3699 isUpdateRequired = EFalse; |
|
3700 if (compo.Status() == EDownload_DownloadProgress) |
|
3701 { |
|
3702 compo.SetStatusNode(EDownload_DownloadFailed); |
|
3703 isUpdateRequired = ETrue; |
|
3704 } |
|
3705 else |
|
3706 if (compo.Status() == EDelivered_InstallProgress) |
|
3707 { |
|
3708 compo.SetStatusNode(EDelivered_InstalledFailedWithData); |
|
3709 isUpdateRequired = ETrue; |
|
3710 } |
|
3711 else |
|
3712 if (compo.Status() == EDelivered_RemoveProgress) |
|
3713 { |
|
3714 compo.SetStatusNode(EDelivered_RemoveFailed); |
|
3715 isUpdateRequired = ETrue; |
|
3716 } |
|
3717 else |
|
3718 if (compo.Status() == EDeployed_RemoveProgress) |
|
3719 { |
|
3720 compo.SetStatusNode(EDeployed_RemoveFailed); |
|
3721 isUpdateRequired = ETrue; |
|
3722 } |
|
3723 else |
|
3724 if (compo.Status() == EDeployed_ActivateProgress) |
|
3725 { |
|
3726 compo.SetStatusNode(EDeployed_ActivateFailed); |
|
3727 isUpdateRequired = ETrue; |
|
3728 } |
|
3729 else |
|
3730 if (compo.Status() |
|
3731 == EDeployed_DeactivateProgress) |
|
3732 { |
|
3733 compo.SetStatusNode(EDeployed_DeactivateFailed); |
|
3734 isUpdateRequired = ETrue; |
|
3735 } |
|
3736 if (isUpdateRequired) |
|
3737 Server().Storage()->UpdateL(compo); |
|
3738 } |
|
3739 |
|
3740 } |
|
3741 |
|
3742 void CApplicationManagementServer::SetSisAppVersionAndDriveL( |
|
3743 CDeploymentComponent &aCompo) |
|
3744 { |
|
3745 RDEBUG( "CApplicationManagementSession: SetSisAppVersionAndDriveL: Begin" ); |
|
3746 |
|
3747 Swi::RSisRegistrySession sisSession; |
|
3748 User::LeaveIfError(sisSession.Connect()); |
|
3749 CleanupClosePushL(sisSession); |
|
3750 |
|
3751 Swi::RSisRegistryEntry sisEntry; |
|
3752 |
|
3753 //Opens the base package entry by specifying a UID. |
|
3754 User::LeaveIfError(sisEntry.Open(sisSession, aCompo.Uid())); |
|
3755 CleanupClosePushL(sisEntry); |
|
3756 |
|
3757 TUint drivesMask = sisEntry.InstalledDrivesL(); |
|
3758 |
|
3759 TInt drive= EDriveA; |
|
3760 TDriveNumber installedDrive = EDriveC; |
|
3761 |
|
3762 if( drivesMask ) |
|
3763 { |
|
3764 // Select the highest drive as location drive. That's the case when |
|
3765 // all installation is not in same drive |
|
3766 |
|
3767 while( drivesMask >>= 1 ) |
|
3768 { |
|
3769 drive++; |
|
3770 } |
|
3771 |
|
3772 RDEBUG_2( "drive -> SetSisAppVersionAndDriveL %d", drive); |
|
3773 |
|
3774 installedDrive = (TDriveNumber)drive; |
|
3775 } |
|
3776 |
|
3777 |
|
3778 TBool status = EFalse; |
|
3779 |
|
3780 //Since "C" drive is not removable |
|
3781 |
|
3782 if (installedDrive!=EDriveC) |
|
3783 { |
|
3784 status = IsInstalledAppRemovableL(installedDrive); |
|
3785 } |
|
3786 if (status) |
|
3787 { |
|
3788 RDEBUG( "IsInstalledAppRemovableL(SetSisAppVersionAndDriveL); True"); |
|
3789 } |
|
3790 else |
|
3791 { |
|
3792 RDEBUG( "IsInstalledAppRemovableL(SetSisAppVersionAndDriveL); False"); |
|
3793 } |
|
3794 |
|
3795 //check for status drive |
|
3796 aCompo.SetAppRemovableStatus(status); |
|
3797 |
|
3798 TVersion version = sisEntry.VersionL(); |
|
3799 |
|
3800 if (aCompo.ComponentVersion() == KNullDesC8) |
|
3801 { |
|
3802 TBuf8<KVersionLength> pkgDes; |
|
3803 pkgDes.AppendNum(version.iMajor); |
|
3804 pkgDes.Append(KLiteralPeriod); |
|
3805 pkgDes.AppendNum(version.iMinor); |
|
3806 aCompo.SetVersionL(pkgDes); |
|
3807 |
|
3808 } |
|
3809 CleanupStack::PopAndDestroy(2, &sisSession); |
|
3810 |
|
3811 RDEBUG( "CApplicationManagementSession: SetSisAppVersionAndDriveL: End" ); |
|
3812 } |
|
3813 |
|
3814 TBool CApplicationManagementServer::IsInstalledAppRemovableL( |
|
3815 TDriveNumber &iDrive) |
|
3816 { |
|
3817 |
|
3818 RDEBUG( "IsInstalledAppRemovableL: Step1" ); |
|
3819 TBool removable=EFalse; |
|
3820 RFs rfs; |
|
3821 User::LeaveIfError(rfs.Connect() ); |
|
3822 CleanupClosePushL(rfs); |
|
3823 TDriveList driveList; |
|
3824 TInt driveCount; |
|
3825 |
|
3826 //Get all removeable drive, both physically and logically |
|
3827 User::LeaveIfError(DriveInfo::GetUserVisibleDrives(rfs, driveList, |
|
3828 driveCount, KDriveAttRemovable)); |
|
3829 |
|
3830 TInt max(driveList.Length()); |
|
3831 |
|
3832 RDEBUG_2( "driveList.Length() %d", max); |
|
3833 |
|
3834 RDEBUG_2( "driveCount %d", driveCount); |
|
3835 |
|
3836 TBuf<26> buf; |
|
3837 buf.Copy(driveList); |
|
3838 RDEBUG_2( "Drive Info (%S)", &buf); |
|
3839 |
|
3840 for (TInt i=0; i<max; ++i) |
|
3841 { |
|
3842 |
|
3843 //RDEBUG( "IsInstalledAppRemovableL: Step2" ); |
|
3844 if (driveList[i]) |
|
3845 { |
|
3846 TUint status; |
|
3847 RDEBUG( "IsInstalledAppRemovableL: Step3" ); |
|
3848 DriveInfo::GetDriveStatus(rfs, i, status); |
|
3849 |
|
3850 RDEBUG( "IsInstalledAppRemovableL: Step4" ); |
|
3851 //To make sure the drive is physically removeable not logically removeable |
|
3852 if (status & DriveInfo::EDriveRemovable) |
|
3853 { |
|
3854 RDEBUG( "IsInstalledAppRemovableL: Drive removable" ); |
|
3855 RDEBUG_2( "IsInstalledAppRemovableL: Drive removable Drive ID %d", i); |
|
3856 if (i == iDrive) |
|
3857 { |
|
3858 RDEBUG( "IsInstalledAppRemovableL: Step5" ); |
|
3859 removable=ETrue; |
|
3860 break; |
|
3861 } |
|
3862 } |
|
3863 } |
|
3864 } |
|
3865 |
|
3866 CleanupStack::PopAndDestroy( &rfs); |
|
3867 |
|
3868 return removable; |
|
3869 |
|
3870 } |
|
3871 // End of File |