1 /* |
|
2 * Copyright (c) 2008-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: CAppMngr2AppUi implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "appmngr2appui.h" // CAppMngr2AppUi |
|
20 #include "appmngr2model.h" // CAppMngr2Model |
|
21 #include "appmngr2internalpskeys.h" // KAppManagerApplicationMode |
|
22 #include "appmngr2installedview.h" // CAppMngr2InstalledView |
|
23 #include "appmngr2packagesview.h" // CAppMngr2PackagesView |
|
24 #include "appmngr2.hrh" // Command IDs |
|
25 #include <appmngr2runtime.h> // CAppMngr2Runtime |
|
26 #include <appmngr2driveutils.h> // TAppMngr2DriveUtils |
|
27 #include <appmngr2debugutils.h> // FLOG macros |
|
28 #include <eikdoc.h> // CEikDocument |
|
29 #include <appmngr2.rsg> // Resource IDs |
|
30 #include <featmgr.h> // FeatureManager |
|
31 #include <e32property.h> // RProperty |
|
32 #include <hlplch.h> // HlpLauncher |
|
33 |
|
34 _LIT( KSWInstCommonUIResourceFileName, "SWInstCommonUI.rsc" ); |
|
35 |
|
36 |
|
37 // ======== MEMBER FUNCTIONS ======== |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // CAppMngr2AppUi::ConstructL() |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 void CAppMngr2AppUi::ConstructL() |
|
44 { |
|
45 FLOG( "CAppMngr2AppUi::ConstructL" ); |
|
46 BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible ); |
|
47 |
|
48 RWsSession& wsSession = iEikonEnv->WsSession(); |
|
49 wsSession.ComputeMode( RWsSession::EPriorityControlDisabled ); |
|
50 |
|
51 FeatureManager::InitializeLibL(); |
|
52 |
|
53 TFileName* fullName = TAppMngr2DriveUtils::NearestResourceFileLC( |
|
54 KSWInstCommonUIResourceFileName, iEikonEnv->FsSession() ); |
|
55 FLOG( "CAppMngr2AppUi::ConstructL, opening %S", fullName ); |
|
56 iResourceFileOffset = iEikonEnv->AddResourceFileL( *fullName ); |
|
57 CleanupStack::PopAndDestroy( fullName ); |
|
58 |
|
59 FLOG( "CAppMngr2AppUi::ConstructL, creting model" ); |
|
60 iModel = CAppMngr2Model::NewL( iEikonEnv->FsSession(), *this ); |
|
61 |
|
62 FLOG( "CAppMngr2AppUi::ConstructL, creting views" ); |
|
63 CAppMngr2InstalledView* installedView = CAppMngr2InstalledView::NewL(); |
|
64 AddViewL( installedView ); // takes ownership |
|
65 CAppMngr2PackagesView* packagesView = CAppMngr2PackagesView::NewL(); |
|
66 AddViewL( packagesView ); // takes ownership |
|
67 |
|
68 if( iEikonEnv->StartedAsServerApp() ) |
|
69 { |
|
70 TInt appMode; |
|
71 TInt err = RProperty::Get( KPSUidAppManagerNotification, |
|
72 KAppManagerApplicationMode, appMode ); |
|
73 FLOG( "CAppMngr2AppUi::ConstructL, appMode = %d, err = %d", appMode, err ); |
|
74 if( err == KErrNone ) |
|
75 { |
|
76 if( appMode == EInstalled ) |
|
77 { |
|
78 ActivateLocalViewL( KInstalledViewId ); |
|
79 } |
|
80 else |
|
81 { |
|
82 ActivateLocalViewL( KPackagesViewId ); |
|
83 iConstructInstallationFilesFirst = ETrue; |
|
84 } |
|
85 } |
|
86 else |
|
87 { |
|
88 ActivateLocalViewL( KInstalledViewId ); |
|
89 } |
|
90 } |
|
91 else |
|
92 { |
|
93 ActivateLocalViewL( KInstalledViewId ); |
|
94 } |
|
95 |
|
96 FLOG( "CAppMngr2AppUi::ConstructL, starting delayed construct" ); |
|
97 iIdle = CIdle::NewL( CActive::EPriorityStandard ); |
|
98 iIdle->Start( TCallBack( &CAppMngr2AppUi::DelayedConstructL, this ) ); |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CAppMngr2AppUi::~CAppMngr2AppUi() |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 CAppMngr2AppUi::~CAppMngr2AppUi() |
|
106 { |
|
107 FLOG( "CAppMngr2AppUi::~CAppMngr2AppUi" ); |
|
108 delete iIdle; |
|
109 delete iModel; |
|
110 if( iResourceFileOffset > 0 ) |
|
111 { |
|
112 iEikonEnv->DeleteResourceFile( iResourceFileOffset ); |
|
113 } |
|
114 FeatureManager::UnInitializeLib(); |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // CAppMngr2AppUi::Model() |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 CAppMngr2Model& CAppMngr2AppUi::Model() const |
|
122 { |
|
123 return *iModel; |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // CAppMngr2AppUi::InstalledAppsChanged() |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 void CAppMngr2AppUi::InstalledAppsChanged( TInt aMoreRefreshesExpected ) |
|
131 { |
|
132 FLOG( "CAppMngr2AppUi::InstalledAppsChanged( %d )", aMoreRefreshesExpected ); |
|
133 if( iView == View( KInstalledViewId ) ) |
|
134 { |
|
135 CAppMngr2ListView* view = static_cast<CAppMngr2ListView*>( iView ); |
|
136 TRAP_IGNORE( view->RefreshL( aMoreRefreshesExpected ) ); |
|
137 } |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // CAppMngr2AppUi::InstallationFilesChanged() |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 void CAppMngr2AppUi::InstallationFilesChanged( TInt aMoreRefreshesExpected ) |
|
145 { |
|
146 FLOG( "CAppMngr2AppUi::InstallationFilesChanged( %d )", aMoreRefreshesExpected ); |
|
147 if( iView == View( KPackagesViewId ) ) |
|
148 { |
|
149 CAppMngr2ListView* view = static_cast<CAppMngr2ListView*>( iView ); |
|
150 TRAP_IGNORE( view->RefreshL( aMoreRefreshesExpected ) ); |
|
151 } |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // CAppMngr2AppUi::InstalledAppsDisplayed() |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 TBool CAppMngr2AppUi::InstalledAppsDisplayed() |
|
159 { |
|
160 return ( iView == View( KInstalledViewId ) ); |
|
161 } |
|
162 |
|
163 // --------------------------------------------------------------------------- |
|
164 // CAppMngr2AppUi::InstallationFilesDisplayed() |
|
165 // --------------------------------------------------------------------------- |
|
166 // |
|
167 TBool CAppMngr2AppUi::InstallationFilesDisplayed() |
|
168 { |
|
169 return ( iView == View( KPackagesViewId ) ); |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // CAppMngr2AppUi::DelayedConstructL() |
|
174 // --------------------------------------------------------------------------- |
|
175 // |
|
176 TInt CAppMngr2AppUi::DelayedConstructL( TAny* aSelf ) |
|
177 { |
|
178 if( aSelf ) |
|
179 { |
|
180 CAppMngr2AppUi* self = static_cast<CAppMngr2AppUi*>( aSelf ); |
|
181 FLOG( "CAppMngr2AppUi::DelayedConstructL, step %d", |
|
182 self->iDelayedConstructionStep ); |
|
183 switch( self->iDelayedConstructionStep ) |
|
184 { |
|
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; |
|
211 } |
|
212 } |
|
213 return EFalse; // all done |
|
214 } |
|
215 |
|
216 // --------------------------------------------------------------------------- |
|
217 // CAppMngr2AppUi::HandleCommandL() |
|
218 // --------------------------------------------------------------------------- |
|
219 // |
|
220 void CAppMngr2AppUi::HandleCommandL( TInt aCommand ) |
|
221 { |
|
222 FLOG( "CAppMngr2AppUi::HandleCommandL( %d )", aCommand ); |
|
223 switch ( aCommand ) |
|
224 { |
|
225 case EEikCmdExit: |
|
226 case EAknCmdExit: |
|
227 case EAknSoftkeyExit: |
|
228 Exit(); |
|
229 break; |
|
230 |
|
231 case EAknCmdHelp: |
|
232 case EEikCmdHelpContents: |
|
233 if( FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
234 { |
|
235 HlpLauncher::LaunchHelpApplicationL( |
|
236 iEikonEnv->WsSession(), AppHelpContextL() ); |
|
237 } |
|
238 break; |
|
239 |
|
240 default: |
|
241 break; |
|
242 } |
|
243 } |
|
244 |
|