|
1 /* |
|
2 * Copyright (c) 2008 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: Java MIDlet runtime type for AppMngr2 |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "appmngr2midletruntime.h" // CAppMngr2MidletRuntime |
|
20 #include "appmngr2midletappinfo.h" // CAppMngr2MidletAppInfo |
|
21 #include "appmngr2midletpackageinfo.h" // CAppMngr2MidletPackageInfo |
|
22 #include "appmngr2midletpckginfofactory.h" // CAppMngr2MidletPckgInfoFactory |
|
23 #include "appmngr2midletsettingsview.h" // KMidletSuiteSettingsViewId |
|
24 #include "appmngr2recognizedfile.h" // CAppMngr2RecognizedFile |
|
25 #include "appmngr2midletresourcehandler.h" // CAppMngr2MidletResourceHandler |
|
26 |
|
27 #include <appmngr2midlet.mbg> // icon IDs |
|
28 #include <appmngr2runtimeobserver.h> // MAppMngr2RuntimeObserver |
|
29 |
|
30 #include <data_caging_path_literals.hrh> // KDC_APP_BITMAP_DIR |
|
31 #include <AknIconArray.h> // CAknIconArray |
|
32 #include <AknsUtils.h> // AknsUtils |
|
33 #include <gulicon.h> // CGulIcon |
|
34 #include <eikenv.h> // CEikonEnv |
|
35 #include <SWInstDefs.h> // KJadMIMEType, KJarMIMEType |
|
36 #include <aknViewAppUi.h> // CAknViewAppUi |
|
37 #include <bldvariant.hrh> |
|
38 |
|
39 #include "logger.h" // LOG |
|
40 |
|
41 // MIDlet icon file name |
|
42 _LIT(KAppMngr2MidletIconFileNameMif, "AppMngr2Midlet.mif"); |
|
43 |
|
44 // ======== MEMBER FUNCTIONS ======== |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CAppMngr2MidletRuntime::NewL() |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CAppMngr2MidletRuntime* CAppMngr2MidletRuntime::NewL( |
|
51 MAppMngr2RuntimeObserver& aObserver) |
|
52 { |
|
53 LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletRuntime::NewL "); |
|
54 CAppMngr2MidletRuntime* self |
|
55 = new(ELeave) CAppMngr2MidletRuntime(aObserver); |
|
56 CleanupStack::PushL(self); |
|
57 self->ConstructL(); |
|
58 CleanupStack::Pop(self); |
|
59 LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletRuntime::NewL "); |
|
60 |
|
61 return self; |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CAppMngr2MidletRuntime::~CAppMngr2MidletRuntime() |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 CAppMngr2MidletRuntime::~CAppMngr2MidletRuntime() |
|
69 { |
|
70 LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletRuntime::~CAppMngr2MidletRuntime "); |
|
71 |
|
72 // MIDlet suite settings view must be removed and destroyed before |
|
73 // MIDlet Runtime Plug-in is unloaded |
|
74 CEikonEnv* eikonEnv = CEikonEnv::Static(); |
|
75 CAknViewAppUi* appUi = static_cast<CAknViewAppUi*>(eikonEnv->EikAppUi()); |
|
76 |
|
77 if (appUi) |
|
78 { |
|
79 appUi->RemoveView(KMidletSuiteSettingsViewId); |
|
80 } |
|
81 |
|
82 if (iPckgFactory) |
|
83 { |
|
84 delete iPckgFactory; |
|
85 iPckgFactory = NULL; |
|
86 } |
|
87 |
|
88 if (iJavaRegistry) |
|
89 { |
|
90 delete iJavaRegistry; |
|
91 iJavaRegistry = NULL; |
|
92 } |
|
93 if (iResourceHandler) |
|
94 { |
|
95 delete iResourceHandler; |
|
96 iResourceHandler = NULL; |
|
97 } |
|
98 LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletRuntime::~CAppMngr2MidletRuntime "); |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CAppMngr2MidletRuntime::LoadIconsL() |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 void CAppMngr2MidletRuntime::LoadIconsL(CAknIconArray& aIconArray) |
|
106 { |
|
107 LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletRuntime::LoadIconsL "); |
|
108 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
109 HBufC* iconFilePath = NULL; |
|
110 |
|
111 iconFilePath = FullBitmapFileNameLC(KAppMngr2MidletIconFileNameMif); |
|
112 |
|
113 // Icon 0: qgn_menu_am_midlet |
|
114 CGulIcon* icon = AknsUtils::CreateGulIconL(skinInstance, |
|
115 KAknsIIDQgnMenuAmMidlet, *iconFilePath, |
|
116 EMbmAppmngr2midletQgn_menu_am_midlet, |
|
117 EMbmAppmngr2midletQgn_menu_am_midlet_mask); |
|
118 CleanupStack::PushL(icon); |
|
119 aIconArray.AppendL(icon); |
|
120 CleanupStack::Pop(icon); |
|
121 |
|
122 // Icon 1: qgn_prop_drm_exp_large |
|
123 icon = AknsUtils::CreateGulIconL(skinInstance, |
|
124 KAknsIIDQgnPropDrmRightsExpLarge, *iconFilePath, |
|
125 EMbmAppmngr2midletQgn_prop_drm_exp_large, |
|
126 EMbmAppmngr2midletQgn_prop_drm_exp_large_mask); |
|
127 CleanupStack::PushL(icon); |
|
128 aIconArray.AppendL(icon); |
|
129 CleanupStack::Pop(icon); |
|
130 |
|
131 CleanupStack::PopAndDestroy(iconFilePath); |
|
132 LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletRuntime::LoadIconsL "); |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // CAppMngr2MidletRuntime::GetSupportedDataTypesL() |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 void CAppMngr2MidletRuntime::GetSupportedDataTypesL( |
|
140 CDataTypeArray& aDataTypeArray) |
|
141 { |
|
142 LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletRuntime::GetSupportedDataTypesL "); |
|
143 TDataType jarFile(SwiUI::KJarMIMEType); |
|
144 aDataTypeArray.AppendL(jarFile); |
|
145 |
|
146 TDataType jadFile(SwiUI::KJadMIMEType); |
|
147 aDataTypeArray.AppendL(jadFile); |
|
148 LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletRuntime::GetSupportedDataTypesL "); |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // CAppMngr2MidletRuntime::GetInstallationFilesL() |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 void CAppMngr2MidletRuntime::GetInstallationFilesL( |
|
156 RPointerArray<CAppMngr2PackageInfo>& aPackageInfos, |
|
157 const RPointerArray<CAppMngr2RecognizedFile>& aFileList, |
|
158 RFs& aFsSession, |
|
159 TRequestStatus& aStatus) |
|
160 { |
|
161 LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletRuntime::GetInstallationFilesL "); |
|
162 |
|
163 if (!iPckgFactory) |
|
164 { |
|
165 iPckgFactory = CAppMngr2MidletPckgInfoFactory::NewL(*this, aFsSession, *iResourceHandler); |
|
166 } |
|
167 |
|
168 iPckgFactory->GetInstallationFilesL(aPackageInfos, aFileList, |
|
169 aStatus); |
|
170 LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletRuntime::GetInstallationFilesL "); |
|
171 } |
|
172 |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // CAppMngr2MidletRuntime::CancelGetInstallationFiles() |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 void CAppMngr2MidletRuntime::CancelGetInstallationFiles() |
|
179 { |
|
180 LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletRuntime::CancelGetInstallationFiles "); |
|
181 if (iPckgFactory) |
|
182 { |
|
183 iPckgFactory->Cancel(); |
|
184 } |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------------------------- |
|
188 // CAppMngr2MidletRuntime::GetInstalledAppsL() |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 void CAppMngr2MidletRuntime::GetInstalledAppsL( |
|
192 RPointerArray<CAppMngr2AppInfo>& aApps, |
|
193 RFs& aFsSession, TRequestStatus& aStatus) |
|
194 { |
|
195 LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletRuntime::GetInstalledAppsL "); |
|
196 RArray<TUid> uids; |
|
197 CleanupClosePushL(uids); |
|
198 |
|
199 iJavaRegistry->GetRegistryEntryUidsL(Java::EGeneralPackage, uids); |
|
200 for (TInt index = 0; index < uids.Count(); index++) |
|
201 { |
|
202 Java::CJavaRegistryPackageEntry* entry |
|
203 = (Java::CJavaRegistryPackageEntry*) |
|
204 iJavaRegistry->RegistryEntryL(uids[index]); |
|
205 |
|
206 //CleanupStack::PushL(entry); |
|
207 // Entry ownership is taken. |
|
208 TRAP_IGNORE(GetInstalledAppL(aApps, aFsSession, entry)); |
|
209 |
|
210 //CleanupStack::Pop(aEntry); |
|
211 } |
|
212 |
|
213 CleanupStack::PopAndDestroy(&uids); |
|
214 |
|
215 TRequestStatus* status = &aStatus; |
|
216 User::RequestComplete(status, KErrNone); |
|
217 |
|
218 LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletRuntime::GetInstalledAppsL "); |
|
219 } |
|
220 |
|
221 // --------------------------------------------------------------------------- |
|
222 // CAppMngr2MidletRuntime::CancelGetInstalledApps() |
|
223 // --------------------------------------------------------------------------- |
|
224 // |
|
225 void CAppMngr2MidletRuntime::CancelGetInstalledApps() |
|
226 { |
|
227 LOG(EJavaAppMngrPlugin, EInfo, " CAppMngr2MidletRuntime::CancelGetInstalledApps "); |
|
228 // Implementation of GetInstalledAppsL in synchronous, therefore there is no |
|
229 // need to cancel operation. |
|
230 } |
|
231 |
|
232 // --------------------------------------------------------------------------- |
|
233 // CAppMngr2MidletRuntime::GetInstalledAppL() |
|
234 // --------------------------------------------------------------------------- |
|
235 // |
|
236 void CAppMngr2MidletRuntime::GetInstalledAppL( |
|
237 RPointerArray<CAppMngr2AppInfo>& aApps, |
|
238 RFs& aFsSession, |
|
239 Java::CJavaRegistryPackageEntry* aEntry) |
|
240 { |
|
241 LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletRuntime::GetInstalledAppL "); |
|
242 |
|
243 // Entry ownership is taken and it must be set to CleanupStack |
|
244 // to avoid double deletion. |
|
245 CAppMngr2MidletAppInfo* appInfo = CAppMngr2MidletAppInfo::NewLC( |
|
246 *this, aEntry, aFsSession, *iResourceHandler); |
|
247 //CleanupStack::Pop(aEntry); |
|
248 |
|
249 aApps.AppendL(appInfo); // takes ownership |
|
250 CleanupStack::Pop(appInfo); |
|
251 |
|
252 LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletRuntime::GetInstalledAppL "); |
|
253 } |
|
254 |
|
255 // --------------------------------------------------------------------------- |
|
256 // CAppMngr2MidletRuntime::CAppMngr2MidletRuntime() |
|
257 // --------------------------------------------------------------------------- |
|
258 // |
|
259 CAppMngr2MidletRuntime::CAppMngr2MidletRuntime( |
|
260 MAppMngr2RuntimeObserver& aObserver) : CAppMngr2Runtime(aObserver) |
|
261 { |
|
262 } |
|
263 |
|
264 // --------------------------------------------------------------------------- |
|
265 // CAppMngr2MidletRuntime::ConstructL() |
|
266 // --------------------------------------------------------------------------- |
|
267 // |
|
268 void CAppMngr2MidletRuntime::ConstructL() |
|
269 { |
|
270 LOG(EJavaAppMngrPlugin, EInfo, " + CAppMngr2MidletRuntime::ConstructL "); |
|
271 iJavaRegistry = Java::CJavaRegistry::NewL(); |
|
272 iResourceHandler = CAppMngr2MidletResourceHandler::NewL(); |
|
273 LOG(EJavaAppMngrPlugin, EInfo, " - CAppMngr2MidletRuntime::ConstructL "); |
|
274 } |