|
1 /* |
|
2 * Copyright (c) 2005-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: javaregistry implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "javaregistry.h" |
|
20 #include "javaregistryapplicationentry.h" |
|
21 #include "javaregistryentry.h" |
|
22 #include "javaregistrypackageentry.h" |
|
23 #include "logger.h" |
|
24 #include "writeablejavaregistry.h" |
|
25 #include "writeablejavaregistryentry.h" |
|
26 |
|
27 using namespace Java; |
|
28 using namespace Java::Manager::Registry; |
|
29 // ============================ MEMBER FUNCTIONS ============================== |
|
30 |
|
31 // --------------------------------------------------------------------------- |
|
32 // CJavaRegistry::NewL |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 EXPORT_C CJavaRegistry* CJavaRegistry::NewL() |
|
36 { |
|
37 JELOG2(EJavaStorage); |
|
38 LOG(EJavaStorage, EInfo, "CJavaRegistry::NewL"); |
|
39 |
|
40 CJavaRegistry* self = CJavaRegistry::NewLC(); |
|
41 CleanupStack::Pop(self); |
|
42 return self; |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // CJavaRegistry::NewLC |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 EXPORT_C CJavaRegistry* CJavaRegistry::NewLC() |
|
50 { |
|
51 JELOG2(EJavaStorage); |
|
52 LOG(EJavaStorage, EInfo, "CJavaRegistry::NewLC"); |
|
53 |
|
54 CJavaRegistry* self = new(ELeave) CJavaRegistry(); |
|
55 CleanupStack::PushL(self); |
|
56 self->ConstructL(); |
|
57 return self; |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // CJavaRegistry::RegistryEntryExistsL |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 EXPORT_C TBool CJavaRegistry::RegistryEntryExistsL(const TUid& aUid) const |
|
65 { |
|
66 return iJavaReg->RegistryEntryExistsL(aUid); |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // CJavaRegistry::GetRegistryEntryUidsL |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 EXPORT_C void CJavaRegistry::GetRegistryEntryUidsL(RArray<TUid>& aUids) const |
|
74 { |
|
75 iJavaReg->GetRegistryEntryUidsL(aUids); |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CJavaRegistry::GetRegistryEntryUidsL |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 EXPORT_C void CJavaRegistry::GetRegistryEntryUidsL( |
|
83 TJavaRegistryEntryType aType, RArray<TUid>& aUids) const |
|
84 { |
|
85 JELOG2(EJavaStorage); |
|
86 iJavaReg->GetRegistryEntryUidsL(aType, aUids); |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CJavaRegistry::RegistryEntryL |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 EXPORT_C CJavaRegistryEntry* CJavaRegistry::RegistryEntryL( |
|
94 const TUid& aUid) const |
|
95 { |
|
96 JELOG2(EJavaStorage); |
|
97 if (0 == aUid.iUid) |
|
98 { |
|
99 WLOG(EJavaStorage, |
|
100 "Can't find entry for uid 0, returning NULL."); |
|
101 return NULL; |
|
102 } |
|
103 |
|
104 CWriteableJavaRegistryEntry* writableEntry |
|
105 = iJavaReg->RegistryEntryL(aUid); |
|
106 |
|
107 if (writableEntry == NULL) |
|
108 { |
|
109 WLOG(EJavaStorage, |
|
110 "Can't find entry for the given uid, returning NULL."); |
|
111 return NULL; |
|
112 } |
|
113 |
|
114 CleanupStack::PushL(writableEntry); |
|
115 |
|
116 CJavaRegistryEntry* regEntry = NULL; |
|
117 TJavaRegistryEntryType entryType = writableEntry->Type(); |
|
118 |
|
119 if (EGeneralPackage <= entryType && entryType < EGeneralApplication) |
|
120 { |
|
121 CWriteableJavaRegistryPackageEntry* writablePackageEntry |
|
122 = (CWriteableJavaRegistryPackageEntry*) writableEntry; |
|
123 |
|
124 regEntry = new(ELeave) |
|
125 CJavaRegistryPackageEntry(writablePackageEntry); |
|
126 // pointer ownership passed over |
|
127 LOG(EJavaStorage, EInfo, "PackageEntry created"); |
|
128 } |
|
129 else if (EGeneralApplication <= entryType) |
|
130 { |
|
131 CWriteableJavaRegistryApplicationEntry* writableAppEntry |
|
132 = (CWriteableJavaRegistryApplicationEntry*) writableEntry; |
|
133 |
|
134 regEntry = new(ELeave) |
|
135 CJavaRegistryApplicationEntry(writableAppEntry); |
|
136 // pointer ownership passed over |
|
137 LOG(EJavaStorage, EInfo, "ApplicationEntry created"); |
|
138 } |
|
139 else |
|
140 { |
|
141 ELOG1(EJavaStorage, "Invalid type, returning NULL: %d", entryType); |
|
142 CleanupStack::PopAndDestroy(writableEntry); |
|
143 return NULL; |
|
144 } |
|
145 |
|
146 CleanupStack::Pop(writableEntry); |
|
147 return regEntry; |
|
148 } |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // CJavaRegistry::~CJavaRegistry |
|
152 // --------------------------------------------------------------------------- |
|
153 // |
|
154 CJavaRegistry::~CJavaRegistry() |
|
155 { |
|
156 JELOG2(EJavaStorage); |
|
157 if (iJavaReg) |
|
158 { |
|
159 delete iJavaReg; |
|
160 iJavaReg = NULL; |
|
161 } |
|
162 } |
|
163 |
|
164 // --------------------------------------------------------------------------- |
|
165 // CJavaRegistry::CJavaRegistry |
|
166 // --------------------------------------------------------------------------- |
|
167 // |
|
168 CJavaRegistry::CJavaRegistry() |
|
169 { |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // CJavaRegistry::ConstructL |
|
174 // --------------------------------------------------------------------------- |
|
175 // |
|
176 void CJavaRegistry::ConstructL() |
|
177 { |
|
178 JELOG2(EJavaStorage); |
|
179 iJavaReg = CWriteableJavaRegistry::NewL(EFalse); |
|
180 } |