|
1 /* |
|
2 * Copyright (c) 2009 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: Utility class to listen SWI operations. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "appmngr2sisxswimonitor.h" // CAppMngr2SisxSwiMonitor |
|
20 #include <swi/swispubsubdefs.h> // KUidSoftwareInstallKey |
|
21 #include <appmngr2debugutils.h> // FLOG macros |
|
22 |
|
23 |
|
24 // ======== MEMBER FUNCTIONS ======== |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // CAppMngr2SisxSwiMonitor::NewL() |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 CAppMngr2SisxSwiMonitor* CAppMngr2SisxSwiMonitor::NewL( MAppMngr2RuntimeObserver& aObs ) |
|
31 { |
|
32 CAppMngr2SisxSwiMonitor* self = new( ELeave ) CAppMngr2SisxSwiMonitor( aObs ); |
|
33 CleanupStack::PushL( self ); |
|
34 self->ConstructL(); |
|
35 CleanupStack::Pop( self ); |
|
36 return self; |
|
37 } |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // CAppMngr2SisxSwiMonitor::~CAppMngr2SisxSwiMonitor() |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 CAppMngr2SisxSwiMonitor::~CAppMngr2SisxSwiMonitor() |
|
44 { |
|
45 Cancel(); |
|
46 iSwInstallKey.Close(); |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // CAppMngr2SisxSwiMonitor::DoCancel() |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 void CAppMngr2SisxSwiMonitor::DoCancel() |
|
54 { |
|
55 iSwInstallKey.Cancel(); |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CAppMngr2SisxSwiMonitor::RunL() |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 void CAppMngr2SisxSwiMonitor::RunL() |
|
63 { |
|
64 iSwInstallKey.Subscribe( iStatus ); |
|
65 SetActive(); |
|
66 |
|
67 TInt value = 0; |
|
68 if( iSwInstallKey.Get( value ) == KErrNone ) |
|
69 { |
|
70 TInt operation( value & Swi::KSwisOperationMask ); |
|
71 TInt operationStatus( value & Swi::KSwisOperationStatusMask ); |
|
72 FLOG( "CAppMngr2SisxSwiMonitor::RunL(): operation %d, status %d", |
|
73 operation, operationStatus ); |
|
74 |
|
75 if( operationStatus == Swi::ESwisStatusSuccess && ( |
|
76 operation == Swi::ESwisInstall || |
|
77 operation == Swi::ESwisUninstall || |
|
78 operation == Swi::ESwisRestore ) ) |
|
79 { |
|
80 iObs.RefreshInstalledApps(); |
|
81 } |
|
82 } |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // CAppMngr2SisxSwiMonitor::CAppMngr2SisxSwiMonitor() |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 CAppMngr2SisxSwiMonitor::CAppMngr2SisxSwiMonitor( MAppMngr2RuntimeObserver& aObs ) |
|
90 : CActive( CActive::EPriorityStandard ), iObs( aObs ) |
|
91 { |
|
92 CActiveScheduler::Add( this ); |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // CAppMngr2SisxSwiMonitor::ConstructL() |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 void CAppMngr2SisxSwiMonitor::ConstructL() |
|
100 { |
|
101 User::LeaveIfError( iSwInstallKey.Attach( KUidSystemCategory, Swi::KUidSoftwareInstallKey ) ); |
|
102 iSwInstallKey.Subscribe( iStatus ); |
|
103 SetActive(); |
|
104 |
|
105 FLOG( "CAppMngr2SisxSwiMonitor::ConstructL(): subscribed to Swi::KUidSoftwareInstallKey" ); |
|
106 } |
|
107 |