|
1 /* |
|
2 * Copyright (c) 1997-2004 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: Implementation of CInstalledAppsRegistry class - as we apply |
|
15 * Bridge patten, almost each method in this class delegates |
|
16 * the call to the implementation class. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include <javaregistryentrytype.h> |
|
24 |
|
25 #include "installedappsregistry.h" |
|
26 #include "installedappsregistryentry.h" |
|
27 #include "javaregistryentrytype.h" |
|
28 #include "javaregistrysuiteentry.h" |
|
29 #include "javasymbianoslayer.h" |
|
30 #include "javastorage.h" |
|
31 #include "javastoragenames.h" |
|
32 #include "logger.h" |
|
33 #include "mjavaregistry.h" |
|
34 |
|
35 using namespace java::storage; |
|
36 using namespace java::util; |
|
37 |
|
38 // ======== MEMBER FUNCTIONS ======== |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // MJavaRegistry::CreateL |
|
42 // This function is defined in MInstalledAppsRegistry. Whoever links to this |
|
43 // file will create a read-only registry. |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 EXPORT_C MInstalledAppsRegistry* MInstalledAppsRegistry::CreateL() |
|
47 { |
|
48 JELOG2(EJavaStorage); |
|
49 return CInstalledAppsRegistry::NewL(); |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // CInstalledAppsRegistry::NewL |
|
54 // We make use of TLS. |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 EXPORT_C CInstalledAppsRegistry* CInstalledAppsRegistry::NewL() |
|
58 { |
|
59 JELOG2(EJavaStorage); |
|
60 |
|
61 CInstalledAppsRegistry* instance = |
|
62 REINTERPRET_CAST(CInstalledAppsRegistry*, Dll::Tls()); |
|
63 |
|
64 if (!instance) |
|
65 { |
|
66 instance = new(ELeave) CInstalledAppsRegistry(); |
|
67 CleanupStack::PushL(instance); |
|
68 instance->ConstructL(); |
|
69 CleanupStack::Pop(instance); |
|
70 |
|
71 // Set the thread local storage pointer for this DLL to be our |
|
72 // singleton instance |
|
73 Dll::SetTls(instance); |
|
74 } |
|
75 |
|
76 // Increment the reference count |
|
77 ++instance->iRefCount; |
|
78 LOG1(EJavaStorage, EInfo, "Reference count: %d", instance->iRefCount); |
|
79 return instance; |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CInstalledAppsRegistry::Release |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 void CInstalledAppsRegistry::Release() |
|
87 { |
|
88 JELOG2(EJavaStorage); |
|
89 |
|
90 // Only delete if the reference count has decremented to 0 |
|
91 TInt refCount = iRefCount-1; |
|
92 |
|
93 LOG1(EJavaStorage, EInfo, "Reference count: %d", iRefCount); |
|
94 |
|
95 if (!--iRefCount) |
|
96 { |
|
97 delete this; |
|
98 Dll::SetTls(NULL); |
|
99 } |
|
100 LOG1(EJavaStorage, EInfo, "Reference count: %d", refCount); |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CInstalledAppsRegistry::~CInstalledAppsRegistry |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 CInstalledAppsRegistry::~CInstalledAppsRegistry() |
|
108 { |
|
109 if (iRegistry) |
|
110 { |
|
111 delete iRegistry; |
|
112 iRegistry = NULL; |
|
113 } |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // CInstalledAppsRegistry::CInstalledAppsRegistry |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 CInstalledAppsRegistry::CInstalledAppsRegistry() |
|
121 { |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // CInstalledAppsRegistry::ConstructL |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 void CInstalledAppsRegistry::ConstructL() |
|
129 { |
|
130 iRegistry = Java::CJavaRegistry::NewL(); |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // CInstalledAppsRegistry::AddEntryL |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 EXPORT_C void CInstalledAppsRegistry::AddEntryL |
|
138 (const CInstalledAppsRegistryEntry& /*aEntry*/) |
|
139 { |
|
140 User::Leave(KErrNotSupported); |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // CInstalledAppsRegistry::DeleteEntry |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 EXPORT_C TInt CInstalledAppsRegistry::DeleteEntry(const TUid& /*aUid*/) |
|
148 { |
|
149 return KErrNotSupported; |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------------------------- |
|
153 // CInstalledAppsRegistry::InstalledUidsL |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 void CInstalledAppsRegistry::InstalledUidsL |
|
157 (RArray<TUid>& aUidArray) const |
|
158 { |
|
159 JELOG2(EJavaStorage); |
|
160 |
|
161 // New registry filters out non-present entries. |
|
162 iRegistry->GetRegistryEntryUidsL(aUidArray); |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------------------------- |
|
166 // CInstalledAppsRegistry::EntryPresentL |
|
167 // --------------------------------------------------------------------------- |
|
168 // |
|
169 TBool CInstalledAppsRegistry::EntryPresentL(const TUid& aUid) const |
|
170 { |
|
171 JELOG2(EJavaStorage); |
|
172 // New registry filters out non-present entries. |
|
173 return iRegistry->RegistryEntryExistsL(aUid); |
|
174 } |
|
175 |
|
176 // --------------------------------------------------------------------------- |
|
177 // CInstalledAppsRegistry::WriteableEntryL |
|
178 // --------------------------------------------------------------------------- |
|
179 // |
|
180 EXPORT_C CInstalledAppsRegistryEntry* CInstalledAppsRegistry::WriteableEntryL |
|
181 (const TUid& /*aUid*/) const |
|
182 { |
|
183 User::Leave(KErrNotSupported); |
|
184 return NULL; |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------------------------- |
|
188 // CInstalledAppsRegistry::WriteableEntryL |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 EXPORT_C CInstalledAppsRegistryEntry* CInstalledAppsRegistry::WriteableEntryL |
|
192 (TLanguage /*aLanguage*/, |
|
193 const TDesC& /*aPackageName*/, |
|
194 const TDesC& /*aVendor*/) const |
|
195 { |
|
196 User::Leave(KErrNotSupported); |
|
197 return NULL; |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------------------------- |
|
201 // CInstalledAppsRegistry::WriteableEntryLC |
|
202 // --------------------------------------------------------------------------- |
|
203 // |
|
204 EXPORT_C CInstalledAppsRegistryEntry* CInstalledAppsRegistry::WriteableEntryLC |
|
205 (const TUid& /*aUid*/) const |
|
206 { |
|
207 User::Leave(KErrNotSupported); |
|
208 return NULL; |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------------------------- |
|
212 // CInstalledAppsRegistry::WriteableEntryLC |
|
213 // --------------------------------------------------------------------------- |
|
214 // |
|
215 EXPORT_C CInstalledAppsRegistryEntry* CInstalledAppsRegistry::WriteableEntryLC |
|
216 (TLanguage /*aLang*/, |
|
217 const TDesC& /*aPackage*/, |
|
218 const TDesC& /*aVendor*/) const |
|
219 { |
|
220 User::Leave(KErrNotSupported); |
|
221 return NULL; |
|
222 } |
|
223 |
|
224 // --------------------------------------------------------------------------- |
|
225 // CInstalledAppsRegistry::EntryL |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 MInstalledAppsRegistryEntry* CInstalledAppsRegistry::EntryL |
|
229 (const TUid& aUid) const |
|
230 { |
|
231 JELOG2(EJavaStorage); |
|
232 |
|
233 if (TUid::Null() == aUid) |
|
234 { |
|
235 User::Leave(KErrArgument); |
|
236 } |
|
237 |
|
238 Java::CJavaRegistryEntry* entry = iRegistry->RegistryEntryL(aUid); |
|
239 |
|
240 if (!entry) |
|
241 { |
|
242 User::Leave(KErrNotFound); |
|
243 } |
|
244 |
|
245 return CInstalledAppsRegistryEntry::NewL(entry); |
|
246 } |
|
247 |
|
248 // --------------------------------------------------------------------------- |
|
249 // CInstalledAppsRegistry::EntryL |
|
250 // --------------------------------------------------------------------------- |
|
251 // |
|
252 MInstalledAppsRegistryEntry* CInstalledAppsRegistry::EntryL |
|
253 (TLanguage /*aLang*/, |
|
254 const TDesC& /*aPackage*/, |
|
255 const TDesC& /*aVendor*/) const |
|
256 { |
|
257 User::Leave(KErrNotSupported); |
|
258 return NULL; |
|
259 } |
|
260 |
|
261 // --------------------------------------------------------------------------- |
|
262 // CInstalledAppsRegistry::EntryLC |
|
263 // --------------------------------------------------------------------------- |
|
264 // |
|
265 MInstalledAppsRegistryEntry* CInstalledAppsRegistry::EntryLC |
|
266 (const TUid& aUid) const |
|
267 { |
|
268 JELOG2(EJavaStorage); |
|
269 if (TUid::Null() == aUid) |
|
270 { |
|
271 User::Leave(KErrArgument); |
|
272 } |
|
273 MInstalledAppsRegistryEntry* entry = EntryL(aUid); |
|
274 CleanupReleasePushL(*entry); |
|
275 return entry; |
|
276 } |
|
277 |
|
278 // --------------------------------------------------------------------------- |
|
279 // CInstalledAppsRegistry::EntryLC |
|
280 // --------------------------------------------------------------------------- |
|
281 // |
|
282 MInstalledAppsRegistryEntry* CInstalledAppsRegistry::EntryLC |
|
283 (TLanguage /*aLang*/, |
|
284 const TDesC& /*aPackage*/, |
|
285 const TDesC& /*aVendor*/) const |
|
286 { |
|
287 User::Leave(KErrNotSupported); |
|
288 return NULL; |
|
289 } |
|
290 |
|
291 // --------------------------------------------------------------------------- |
|
292 // CInstalledAppsRegistry::GetSystemPropertyL |
|
293 // --------------------------------------------------------------------------- |
|
294 // |
|
295 HBufC8* CInstalledAppsRegistry::GetSystemPropertyL |
|
296 (TUid /*aPropertyId*/) const |
|
297 { |
|
298 User::Leave(KErrNotSupported); |
|
299 return NULL; |
|
300 } |
|
301 |
|
302 // --------------------------------------------------------------------------- |
|
303 // CInstalledAppsRegistry::AppsUsingFileL |
|
304 // --------------------------------------------------------------------------- |
|
305 // |
|
306 EXPORT_C void CInstalledAppsRegistry::AppsUsingFileL |
|
307 (const TDesC& /*aFileName*/, |
|
308 RArray<TUid>& /*aUids*/) const |
|
309 { |
|
310 User::Leave(KErrNotSupported); |
|
311 } |
|
312 |
|
313 // --------------------------------------------------------------------------- |
|
314 // CInstalledAppsRegistry::AppsUsingFilesL |
|
315 // --------------------------------------------------------------------------- |
|
316 // |
|
317 EXPORT_C void CInstalledAppsRegistry::AppsUsingFilesL |
|
318 (const RPointerArray<HBufC>& /*aFiles*/, |
|
319 RPointerArray<RArray<TUid> >& /*aUids*/) const |
|
320 { |
|
321 User::Leave(KErrNotSupported); |
|
322 } |
|
323 |
|
324 // --------------------------------------------------------------------------- |
|
325 // CInstalledAppsRegistry::CorruptUidsL |
|
326 // --------------------------------------------------------------------------- |
|
327 // |
|
328 EXPORT_C void CInstalledAppsRegistry::CorruptUidsL |
|
329 (RArray<TUid>& /*aUidArray*/) const |
|
330 { |
|
331 User::Leave(KErrNotSupported); |
|
332 } |
|
333 |
|
334 // --------------------------------------------------------------------------- |
|
335 // CInstalledAppsRegistry::DependentsL |
|
336 // --------------------------------------------------------------------------- |
|
337 // |
|
338 EXPORT_C void CInstalledAppsRegistry::DependentsL(TUid /*aUid*/, |
|
339 RArray<TUid>& /*aDependents*/) const |
|
340 { |
|
341 JELOG2(EJavaStorage); |
|
342 // This is not part of MIntalledAppsRegistry interface. |
|
343 User::Leave(KErrNotSupported); |
|
344 } |