1 /* |
1 /* |
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
20 #include "appmngr2model.h" // CAppMngr2Model |
20 #include "appmngr2model.h" // CAppMngr2Model |
21 #include "appmngr2internalpskeys.h" // KAppManagerApplicationMode |
21 #include "appmngr2internalpskeys.h" // KAppManagerApplicationMode |
22 #include "appmngr2installedview.h" // CAppMngr2InstalledView |
22 #include "appmngr2installedview.h" // CAppMngr2InstalledView |
23 #include "appmngr2packagesview.h" // CAppMngr2PackagesView |
23 #include "appmngr2packagesview.h" // CAppMngr2PackagesView |
24 #include "appmngr2.hrh" // Command IDs |
24 #include "appmngr2.hrh" // Command IDs |
|
25 #include "appmngr2exittimer.h" // Exit Timer |
|
26 |
25 #include <appmngr2runtime.h> // CAppMngr2Runtime |
27 #include <appmngr2runtime.h> // CAppMngr2Runtime |
26 #include <appmngr2driveutils.h> // TAppMngr2DriveUtils |
28 #include <appmngr2driveutils.h> // TAppMngr2DriveUtils |
27 #include <appmngr2debugutils.h> // FLOG macros |
29 #include <appmngr2debugutils.h> // FLOG macros |
28 #include <eikdoc.h> // CEikDocument |
30 #include <eikdoc.h> // CEikDocument |
29 #include <appmngr2.rsg> // Resource IDs |
31 #include <appmngr2.rsg> // Resource IDs |
30 #include <featmgr.h> // FeatureManager |
32 #include <featmgr.h> // FeatureManager |
31 #include <e32property.h> // RProperty |
33 #include <e32property.h> // RProperty |
32 #include <hlplch.h> // HlpLauncher |
34 #include <hlplch.h> // HlpLauncher |
|
35 #include <StringLoader.h> // StringLoader |
|
36 #include <appmngr2.rsg> // Resource IDs |
|
37 #include <AknGlobalNote.h> // WaitNote |
|
38 #include <avkon.rsg> |
|
39 |
33 |
40 |
34 _LIT( KSWInstCommonUIResourceFileName, "SWInstCommonUI.rsc" ); |
41 _LIT( KSWInstCommonUIResourceFileName, "SWInstCommonUI.rsc" ); |
35 |
42 |
36 |
43 |
37 // ======== MEMBER FUNCTIONS ======== |
44 // ======== MEMBER FUNCTIONS ======== |
47 |
54 |
48 RWsSession& wsSession = iEikonEnv->WsSession(); |
55 RWsSession& wsSession = iEikonEnv->WsSession(); |
49 wsSession.ComputeMode( RWsSession::EPriorityControlDisabled ); |
56 wsSession.ComputeMode( RWsSession::EPriorityControlDisabled ); |
50 |
57 |
51 FeatureManager::InitializeLibL(); |
58 FeatureManager::InitializeLibL(); |
52 |
59 |
53 TFileName* fullName = TAppMngr2DriveUtils::NearestResourceFileLC( |
60 TFileName* fullName = TAppMngr2DriveUtils::NearestResourceFileLC( |
54 KSWInstCommonUIResourceFileName, iEikonEnv->FsSession() ); |
61 KSWInstCommonUIResourceFileName, iEikonEnv->FsSession() ); |
55 FLOG( "CAppMngr2AppUi::ConstructL, opening %S", fullName ); |
62 FLOG( "CAppMngr2AppUi::ConstructL, opening %S", fullName ); |
56 iResourceFileOffset = iEikonEnv->AddResourceFileL( *fullName ); |
63 iResourceFileOffset = iEikonEnv->AddResourceFileL( *fullName ); |
57 CleanupStack::PopAndDestroy( fullName ); |
64 CleanupStack::PopAndDestroy( fullName ); |
58 |
65 |
|
66 // Let's start global wait note so user can see that |
|
67 // App. Mngr is scanning memory. |
|
68 HBufC* string = StringLoader::LoadLC( R_QTN_AM_SCANNING_MEMORY ); |
|
69 CAknGlobalNote* note = CAknGlobalNote::NewLC(); |
|
70 note->SetSoftkeys( R_AVKON_SOFTKEYS_EMPTY ); |
|
71 FLOG( "CAppMngr2AppUi::ConstructL: ShowNoteL EAknGlobalWaitNote " ); |
|
72 iNoteId = note->ShowNoteL( EAknGlobalWaitNote, *string ); |
|
73 CleanupStack::PopAndDestroy( 2, string ); |
|
74 |
59 FLOG( "CAppMngr2AppUi::ConstructL, creting model" ); |
75 FLOG( "CAppMngr2AppUi::ConstructL, creting model" ); |
60 iModel = CAppMngr2Model::NewL( iEikonEnv->FsSession(), *this ); |
76 iModel = CAppMngr2Model::NewL( iEikonEnv->FsSession(), *this ); |
61 |
77 |
62 FLOG( "CAppMngr2AppUi::ConstructL, creting views" ); |
78 FLOG( "CAppMngr2AppUi::ConstructL, creting views" ); |
63 CAppMngr2InstalledView* installedView = CAppMngr2InstalledView::NewL(); |
79 CAppMngr2InstalledView* installedView = CAppMngr2InstalledView::NewL(); |
64 AddViewL( installedView ); // takes ownership |
80 AddViewL( installedView ); // takes ownership |
65 CAppMngr2PackagesView* packagesView = CAppMngr2PackagesView::NewL(); |
81 CAppMngr2PackagesView* packagesView = CAppMngr2PackagesView::NewL(); |
66 AddViewL( packagesView ); // takes ownership |
82 AddViewL( packagesView ); // takes ownership |
90 } |
106 } |
91 else |
107 else |
92 { |
108 { |
93 ActivateLocalViewL( KInstalledViewId ); |
109 ActivateLocalViewL( KInstalledViewId ); |
94 } |
110 } |
95 |
111 |
96 FLOG( "CAppMngr2AppUi::ConstructL, starting delayed construct" ); |
112 FLOG( "CAppMngr2AppUi::ConstructL, starting delayed construct" ); |
97 iIdle = CIdle::NewL( CActive::EPriorityStandard ); |
113 iIdle = CIdle::NewL( CActive::EPriorityStandard ); |
98 iIdle->Start( TCallBack( &CAppMngr2AppUi::DelayedConstructL, this ) ); |
114 iIdle->Start( TCallBack( &CAppMngr2AppUi::DelayedConstructL, this ) ); |
|
115 |
|
116 FLOG( "CAppMngr2AppUi::ConstructL, iExitTimer = NULL" ); |
|
117 iExitTimer = NULL; |
99 } |
118 } |
100 |
119 |
101 // --------------------------------------------------------------------------- |
120 // --------------------------------------------------------------------------- |
102 // CAppMngr2AppUi::~CAppMngr2AppUi() |
121 // CAppMngr2AppUi::~CAppMngr2AppUi() |
103 // --------------------------------------------------------------------------- |
122 // --------------------------------------------------------------------------- |
104 // |
123 // |
105 CAppMngr2AppUi::~CAppMngr2AppUi() |
124 CAppMngr2AppUi::~CAppMngr2AppUi() |
106 { |
125 { |
107 FLOG( "CAppMngr2AppUi::~CAppMngr2AppUi" ); |
126 FLOG( "CAppMngr2AppUi::~CAppMngr2AppUi" ); |
|
127 |
|
128 if( iNoteId ) |
|
129 { |
|
130 // If appmngr is closed for some reason let's make sure |
|
131 // the note is closed. |
|
132 TRAP_IGNORE( CancelNoteL() ); |
|
133 } |
|
134 |
108 delete iIdle; |
135 delete iIdle; |
109 delete iModel; |
136 delete iModel; |
|
137 |
110 if( iResourceFileOffset > 0 ) |
138 if( iResourceFileOffset > 0 ) |
111 { |
139 { |
112 iEikonEnv->DeleteResourceFile( iResourceFileOffset ); |
140 iEikonEnv->DeleteResourceFile( iResourceFileOffset ); |
113 } |
141 } |
114 FeatureManager::UnInitializeLib(); |
142 FeatureManager::UnInitializeLib(); |
|
143 delete iExitTimer; |
115 } |
144 } |
116 |
145 |
117 // --------------------------------------------------------------------------- |
146 // --------------------------------------------------------------------------- |
118 // CAppMngr2AppUi::Model() |
147 // CAppMngr2AppUi::Model() |
119 // --------------------------------------------------------------------------- |
148 // --------------------------------------------------------------------------- |
132 FLOG( "CAppMngr2AppUi::InstalledAppsChanged( %d )", aMoreRefreshesExpected ); |
161 FLOG( "CAppMngr2AppUi::InstalledAppsChanged( %d )", aMoreRefreshesExpected ); |
133 if( iView == View( KInstalledViewId ) ) |
162 if( iView == View( KInstalledViewId ) ) |
134 { |
163 { |
135 CAppMngr2ListView* view = static_cast<CAppMngr2ListView*>( iView ); |
164 CAppMngr2ListView* view = static_cast<CAppMngr2ListView*>( iView ); |
136 TRAP_IGNORE( view->RefreshL( aMoreRefreshesExpected ) ); |
165 TRAP_IGNORE( view->RefreshL( aMoreRefreshesExpected ) ); |
|
166 |
|
167 // Let's close global wait note since memory scanning is ready. |
|
168 TRAP_IGNORE( CancelNoteL() ); |
137 } |
169 } |
138 } |
170 } |
139 |
171 |
140 // --------------------------------------------------------------------------- |
172 // --------------------------------------------------------------------------- |
141 // CAppMngr2AppUi::InstallationFilesChanged() |
173 // CAppMngr2AppUi::InstallationFilesChanged() |
146 FLOG( "CAppMngr2AppUi::InstallationFilesChanged( %d )", aMoreRefreshesExpected ); |
178 FLOG( "CAppMngr2AppUi::InstallationFilesChanged( %d )", aMoreRefreshesExpected ); |
147 if( iView == View( KPackagesViewId ) ) |
179 if( iView == View( KPackagesViewId ) ) |
148 { |
180 { |
149 CAppMngr2ListView* view = static_cast<CAppMngr2ListView*>( iView ); |
181 CAppMngr2ListView* view = static_cast<CAppMngr2ListView*>( iView ); |
150 TRAP_IGNORE( view->RefreshL( aMoreRefreshesExpected ) ); |
182 TRAP_IGNORE( view->RefreshL( aMoreRefreshesExpected ) ); |
|
183 |
|
184 // Let's close global wait note since memory scanning is ready. |
|
185 TRAP_IGNORE( CancelNoteL() ); |
151 } |
186 } |
152 } |
187 } |
153 |
188 |
154 // --------------------------------------------------------------------------- |
189 // --------------------------------------------------------------------------- |
155 // CAppMngr2AppUi::InstalledAppsDisplayed() |
190 // CAppMngr2AppUi::InstalledAppsDisplayed() |
178 if( aSelf ) |
213 if( aSelf ) |
179 { |
214 { |
180 CAppMngr2AppUi* self = static_cast<CAppMngr2AppUi*>( aSelf ); |
215 CAppMngr2AppUi* self = static_cast<CAppMngr2AppUi*>( aSelf ); |
181 FLOG( "CAppMngr2AppUi::DelayedConstructL, step %d", |
216 FLOG( "CAppMngr2AppUi::DelayedConstructL, step %d", |
182 self->iDelayedConstructionStep ); |
217 self->iDelayedConstructionStep ); |
183 switch( self->iDelayedConstructionStep ) |
218 |
|
219 // Only necessary part of the model is constructed. AppMngr2 runs |
|
220 // as embedded application in Control panel. It is started either |
|
221 // to display installed applications, or installation files. |
|
222 if( self->iConstructInstallationFilesFirst ) |
184 { |
223 { |
185 case EFirstStep: |
224 self->iModel->StartFetchingInstallationFilesL(); |
186 if( self->iConstructInstallationFilesFirst ) |
|
187 { |
|
188 self->iModel->StartFetchingInstallationFilesL(); |
|
189 } |
|
190 else |
|
191 { |
|
192 self->iModel->StartFetchingInstalledAppsL(); |
|
193 } |
|
194 self->iDelayedConstructionStep = ESecondStep; |
|
195 return ETrue; // call DelayedConstruct again |
|
196 |
|
197 case ESecondStep: |
|
198 if( self->iConstructInstallationFilesFirst ) |
|
199 { |
|
200 self->iModel->StartFetchingInstalledAppsL(); |
|
201 } |
|
202 else |
|
203 { |
|
204 self->iModel->StartFetchingInstallationFilesL(); |
|
205 } |
|
206 self->iDelayedConstructionStep = EAllDone; |
|
207 break; |
|
208 |
|
209 default: |
|
210 break; |
|
211 } |
225 } |
|
226 else |
|
227 { |
|
228 self->iModel->StartFetchingInstalledAppsL(); |
|
229 } |
|
230 |
|
231 self->iDelayedConstructionStep = EAllDone; |
212 } |
232 } |
213 return EFalse; // all done |
233 return EFalse; // all done |
214 } |
234 } |
215 |
235 |
216 // --------------------------------------------------------------------------- |
236 // --------------------------------------------------------------------------- |
221 { |
241 { |
222 FLOG( "CAppMngr2AppUi::HandleCommandL( %d )", aCommand ); |
242 FLOG( "CAppMngr2AppUi::HandleCommandL( %d )", aCommand ); |
223 switch ( aCommand ) |
243 switch ( aCommand ) |
224 { |
244 { |
225 case EEikCmdExit: |
245 case EEikCmdExit: |
|
246 if ( iModel->IsUninstall() && iModel->IsActive() ) |
|
247 { |
|
248 // In case we have uninstall process ongoing we need to |
|
249 // start delay timer for Exit. This is because in some cases |
|
250 // like VPN plug-in the GS is closed and app.mngr exit may come |
|
251 // just when SWInstLauncer is completing req. in RunL (long |
|
252 // running task). CActive do not return from Cancel and |
|
253 // AppMngr2Model's destructor jams. |
|
254 if ( !iExitTimer ) |
|
255 { |
|
256 // If there is not exit timer already let's make one. |
|
257 iExitTimer = CAppMngr2ExitTimer::NewL( this ); |
|
258 iExitTimer->StartExitTimer(); |
|
259 } |
|
260 } |
|
261 else |
|
262 { |
|
263 // if we do not have uninstall request let's do Exit now. |
|
264 Exit(); |
|
265 } |
|
266 break; |
|
267 |
226 case EAknCmdExit: |
268 case EAknCmdExit: |
227 case EAknSoftkeyExit: |
269 case EAknSoftkeyExit: |
228 Exit(); |
270 Exit(); |
229 break; |
271 break; |
230 |
272 |