1 /* |
1 /* |
2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2008-2009 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 |
|
27 #include <appmngr2runtime.h> // CAppMngr2Runtime |
25 #include <appmngr2runtime.h> // CAppMngr2Runtime |
28 #include <appmngr2driveutils.h> // TAppMngr2DriveUtils |
26 #include <appmngr2driveutils.h> // TAppMngr2DriveUtils |
29 #include <appmngr2debugutils.h> // FLOG macros |
27 #include <appmngr2debugutils.h> // FLOG macros |
30 #include <eikdoc.h> // CEikDocument |
28 #include <eikdoc.h> // CEikDocument |
31 #include <appmngr2.rsg> // Resource IDs |
29 #include <appmngr2.rsg> // Resource IDs |
32 #include <featmgr.h> // FeatureManager |
30 #include <featmgr.h> // FeatureManager |
33 #include <e32property.h> // RProperty |
31 #include <e32property.h> // RProperty |
34 #include <hlplch.h> // HlpLauncher |
32 #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 |
|
40 |
33 |
41 _LIT( KSWInstCommonUIResourceFileName, "SWInstCommonUI.rsc" ); |
34 _LIT( KSWInstCommonUIResourceFileName, "SWInstCommonUI.rsc" ); |
42 |
35 |
43 |
36 |
44 // ======== MEMBER FUNCTIONS ======== |
37 // ======== MEMBER FUNCTIONS ======== |
54 |
47 |
55 RWsSession& wsSession = iEikonEnv->WsSession(); |
48 RWsSession& wsSession = iEikonEnv->WsSession(); |
56 wsSession.ComputeMode( RWsSession::EPriorityControlDisabled ); |
49 wsSession.ComputeMode( RWsSession::EPriorityControlDisabled ); |
57 |
50 |
58 FeatureManager::InitializeLibL(); |
51 FeatureManager::InitializeLibL(); |
59 |
52 |
60 TFileName* fullName = TAppMngr2DriveUtils::NearestResourceFileLC( |
53 TFileName* fullName = TAppMngr2DriveUtils::NearestResourceFileLC( |
61 KSWInstCommonUIResourceFileName, iEikonEnv->FsSession() ); |
54 KSWInstCommonUIResourceFileName, iEikonEnv->FsSession() ); |
62 FLOG( "CAppMngr2AppUi::ConstructL, opening %S", fullName ); |
55 FLOG( "CAppMngr2AppUi::ConstructL, opening %S", fullName ); |
63 iResourceFileOffset = iEikonEnv->AddResourceFileL( *fullName ); |
56 iResourceFileOffset = iEikonEnv->AddResourceFileL( *fullName ); |
64 CleanupStack::PopAndDestroy( fullName ); |
57 CleanupStack::PopAndDestroy( fullName ); |
65 |
58 |
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 |
|
75 FLOG( "CAppMngr2AppUi::ConstructL, creting model" ); |
59 FLOG( "CAppMngr2AppUi::ConstructL, creting model" ); |
76 iModel = CAppMngr2Model::NewL( iEikonEnv->FsSession(), *this ); |
60 iModel = CAppMngr2Model::NewL( iEikonEnv->FsSession(), *this ); |
77 |
61 |
78 FLOG( "CAppMngr2AppUi::ConstructL, creting views" ); |
62 FLOG( "CAppMngr2AppUi::ConstructL, creting views" ); |
79 CAppMngr2InstalledView* installedView = CAppMngr2InstalledView::NewL(); |
63 CAppMngr2InstalledView* installedView = CAppMngr2InstalledView::NewL(); |
80 AddViewL( installedView ); // takes ownership |
64 AddViewL( installedView ); // takes ownership |
81 CAppMngr2PackagesView* packagesView = CAppMngr2PackagesView::NewL(); |
65 CAppMngr2PackagesView* packagesView = CAppMngr2PackagesView::NewL(); |
82 AddViewL( packagesView ); // takes ownership |
66 AddViewL( packagesView ); // takes ownership |
106 } |
90 } |
107 else |
91 else |
108 { |
92 { |
109 ActivateLocalViewL( KInstalledViewId ); |
93 ActivateLocalViewL( KInstalledViewId ); |
110 } |
94 } |
111 |
95 |
112 FLOG( "CAppMngr2AppUi::ConstructL, starting delayed construct" ); |
96 FLOG( "CAppMngr2AppUi::ConstructL, starting delayed construct" ); |
113 iIdle = CIdle::NewL( CActive::EPriorityStandard ); |
97 iIdle = CIdle::NewL( CActive::EPriorityStandard ); |
114 iIdle->Start( TCallBack( &CAppMngr2AppUi::DelayedConstructL, this ) ); |
98 iIdle->Start( TCallBack( &CAppMngr2AppUi::DelayedConstructL, this ) ); |
115 |
|
116 FLOG( "CAppMngr2AppUi::ConstructL, iExitTimer = NULL" ); |
|
117 iExitTimer = NULL; |
|
118 } |
99 } |
119 |
100 |
120 // --------------------------------------------------------------------------- |
101 // --------------------------------------------------------------------------- |
121 // CAppMngr2AppUi::~CAppMngr2AppUi() |
102 // CAppMngr2AppUi::~CAppMngr2AppUi() |
122 // --------------------------------------------------------------------------- |
103 // --------------------------------------------------------------------------- |
123 // |
104 // |
124 CAppMngr2AppUi::~CAppMngr2AppUi() |
105 CAppMngr2AppUi::~CAppMngr2AppUi() |
125 { |
106 { |
126 FLOG( "CAppMngr2AppUi::~CAppMngr2AppUi" ); |
107 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 |
|
135 delete iIdle; |
108 delete iIdle; |
136 delete iModel; |
109 delete iModel; |
137 |
|
138 if( iResourceFileOffset > 0 ) |
110 if( iResourceFileOffset > 0 ) |
139 { |
111 { |
140 iEikonEnv->DeleteResourceFile( iResourceFileOffset ); |
112 iEikonEnv->DeleteResourceFile( iResourceFileOffset ); |
141 } |
113 } |
142 FeatureManager::UnInitializeLib(); |
114 FeatureManager::UnInitializeLib(); |
143 delete iExitTimer; |
|
144 } |
115 } |
145 |
116 |
146 // --------------------------------------------------------------------------- |
117 // --------------------------------------------------------------------------- |
147 // CAppMngr2AppUi::Model() |
118 // CAppMngr2AppUi::Model() |
148 // --------------------------------------------------------------------------- |
119 // --------------------------------------------------------------------------- |
161 FLOG( "CAppMngr2AppUi::InstalledAppsChanged( %d )", aMoreRefreshesExpected ); |
132 FLOG( "CAppMngr2AppUi::InstalledAppsChanged( %d )", aMoreRefreshesExpected ); |
162 if( iView == View( KInstalledViewId ) ) |
133 if( iView == View( KInstalledViewId ) ) |
163 { |
134 { |
164 CAppMngr2ListView* view = static_cast<CAppMngr2ListView*>( iView ); |
135 CAppMngr2ListView* view = static_cast<CAppMngr2ListView*>( iView ); |
165 TRAP_IGNORE( view->RefreshL( aMoreRefreshesExpected ) ); |
136 TRAP_IGNORE( view->RefreshL( aMoreRefreshesExpected ) ); |
166 |
|
167 // Let's close global wait note since memory scanning is ready. |
|
168 TRAP_IGNORE( CancelNoteL() ); |
|
169 } |
137 } |
170 } |
138 } |
171 |
139 |
172 // --------------------------------------------------------------------------- |
140 // --------------------------------------------------------------------------- |
173 // CAppMngr2AppUi::InstallationFilesChanged() |
141 // CAppMngr2AppUi::InstallationFilesChanged() |
178 FLOG( "CAppMngr2AppUi::InstallationFilesChanged( %d )", aMoreRefreshesExpected ); |
146 FLOG( "CAppMngr2AppUi::InstallationFilesChanged( %d )", aMoreRefreshesExpected ); |
179 if( iView == View( KPackagesViewId ) ) |
147 if( iView == View( KPackagesViewId ) ) |
180 { |
148 { |
181 CAppMngr2ListView* view = static_cast<CAppMngr2ListView*>( iView ); |
149 CAppMngr2ListView* view = static_cast<CAppMngr2ListView*>( iView ); |
182 TRAP_IGNORE( view->RefreshL( aMoreRefreshesExpected ) ); |
150 TRAP_IGNORE( view->RefreshL( aMoreRefreshesExpected ) ); |
183 |
|
184 // Let's close global wait note since memory scanning is ready. |
|
185 TRAP_IGNORE( CancelNoteL() ); |
|
186 } |
151 } |
187 } |
152 } |
188 |
153 |
189 // --------------------------------------------------------------------------- |
154 // --------------------------------------------------------------------------- |
190 // CAppMngr2AppUi::InstalledAppsDisplayed() |
155 // CAppMngr2AppUi::InstalledAppsDisplayed() |
213 if( aSelf ) |
178 if( aSelf ) |
214 { |
179 { |
215 CAppMngr2AppUi* self = static_cast<CAppMngr2AppUi*>( aSelf ); |
180 CAppMngr2AppUi* self = static_cast<CAppMngr2AppUi*>( aSelf ); |
216 FLOG( "CAppMngr2AppUi::DelayedConstructL, step %d", |
181 FLOG( "CAppMngr2AppUi::DelayedConstructL, step %d", |
217 self->iDelayedConstructionStep ); |
182 self->iDelayedConstructionStep ); |
218 |
183 switch( self->iDelayedConstructionStep ) |
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 ) |
|
223 { |
184 { |
224 self->iModel->StartFetchingInstallationFilesL(); |
185 case EFirstStep: |
|
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; |
225 } |
211 } |
226 else |
|
227 { |
|
228 self->iModel->StartFetchingInstalledAppsL(); |
|
229 } |
|
230 |
|
231 self->iDelayedConstructionStep = EAllDone; |
|
232 } |
212 } |
233 return EFalse; // all done |
213 return EFalse; // all done |
234 } |
214 } |
235 |
215 |
236 // --------------------------------------------------------------------------- |
216 // --------------------------------------------------------------------------- |
241 { |
221 { |
242 FLOG( "CAppMngr2AppUi::HandleCommandL( %d )", aCommand ); |
222 FLOG( "CAppMngr2AppUi::HandleCommandL( %d )", aCommand ); |
243 switch ( aCommand ) |
223 switch ( aCommand ) |
244 { |
224 { |
245 case EEikCmdExit: |
225 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 |
|
268 case EAknCmdExit: |
226 case EAknCmdExit: |
269 case EAknSoftkeyExit: |
227 case EAknSoftkeyExit: |
270 Exit(); |
228 Exit(); |
271 break; |
229 break; |
272 |
230 |