1 /* |
|
2 * Copyright (c) 2008-2010 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 the License "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: |
|
15 * RSoftwareComponentRegistry implementation. See class and function |
|
16 * declarations for more detail. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #include "scr.h" |
|
22 #include "scrclient.inl" |
|
23 #include "scrcommon.h" |
|
24 #include "usiflog.h" |
|
25 #include "scr_internal.h" |
|
26 #include <e32cmn.h> |
|
27 #include <scs/streamingarray.h> |
|
28 #include <scs/scscommon.h> |
|
29 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
30 #include "screntries_internal.h" |
|
31 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS |
|
32 |
|
33 using namespace Usif; |
|
34 |
|
35 TInt RSoftwareComponentRegistry::SendSyncMessage(TInt aFunction, const TIpcArgs& aArgs) const |
|
36 { |
|
37 return CallSessionFunction(aFunction, aArgs); |
|
38 } |
|
39 |
|
40 EXPORT_C RSoftwareComponentRegistry::RSoftwareComponentRegistry() |
|
41 : RScsClientBase() |
|
42 { |
|
43 // empty |
|
44 } |
|
45 |
|
46 EXPORT_C TInt RSoftwareComponentRegistry::Connect() |
|
47 { |
|
48 DEBUG_PRINTF2(_L("Connecting to %S."), &KSoftwareComponentRegistryName); |
|
49 TVersion version = ScrServerVersion(); |
|
50 TUidType scrFullUid = ScrServerImageFullUid(); |
|
51 |
|
52 return RScsClientBase::Connect(KSoftwareComponentRegistryName(), version, KScrServerImageName(), scrFullUid); |
|
53 } |
|
54 |
|
55 EXPORT_C void RSoftwareComponentRegistry::Close() |
|
56 { |
|
57 DEBUG_PRINTF2(_L("Closing connection to %S."), &KSoftwareComponentRegistryName); |
|
58 RScsClientBase::Close(); |
|
59 } |
|
60 |
|
61 EXPORT_C void RSoftwareComponentRegistry::CreateTransactionL() |
|
62 { |
|
63 DEBUG_PRINTF(_L("Sending Create Transaction request.")); |
|
64 User::LeaveIfError(CallSessionFunction(ECreateTransaction)); |
|
65 } |
|
66 |
|
67 EXPORT_C void RSoftwareComponentRegistry::RollbackTransactionL() |
|
68 { |
|
69 DEBUG_PRINTF(_L("Sending Rollback Transaction request.")); |
|
70 User::LeaveIfError(CallSessionFunction(ERollbackTransaction)); |
|
71 } |
|
72 |
|
73 EXPORT_C void RSoftwareComponentRegistry::CommitTransactionL() |
|
74 { |
|
75 DEBUG_PRINTF(_L("Sending Commit Transaction request.")); |
|
76 User::LeaveIfError(CallSessionFunction(ECommitTransaction)); |
|
77 } |
|
78 |
|
79 |
|
80 EXPORT_C TComponentId RSoftwareComponentRegistry::AddComponentL(const TDesC& aName, const TDesC& aVendor, const TDesC& aUniqueSwTypeName, const TDesC* aGlobalId, TScrComponentOperationType aCompOpType) |
|
81 { |
|
82 DEBUG_PRINTF3(_L("Sending add a new component ('%S','%S') request."), &aName, &aVendor); |
|
83 |
|
84 CLocalizableComponentInfo *cmpInfo = CLocalizableComponentInfo::NewLC(aName, aVendor, KNonLocalized); |
|
85 RPointerArray<CLocalizableComponentInfo> cmpInfoList; |
|
86 cmpInfoList.AppendL(cmpInfo); |
|
87 CleanupStack::Pop(cmpInfo); |
|
88 CleanupResetAndDestroyPushL(cmpInfoList); |
|
89 TComponentId compId = AddComponentL(cmpInfoList, aUniqueSwTypeName, aGlobalId, aCompOpType); |
|
90 CleanupStack::PopAndDestroy(&cmpInfoList); |
|
91 return compId; |
|
92 } |
|
93 |
|
94 EXPORT_C TComponentId RSoftwareComponentRegistry::AddComponentL(const RPointerArray<CLocalizableComponentInfo>& aComponentInfo, const TDesC& aUniqueSwTypeName, const TDesC* aGlobalId, TScrComponentOperationType aCompOpType) |
|
95 { |
|
96 if(!aComponentInfo.Count()) |
|
97 { |
|
98 DEBUG_PRINTF(_L("The localizables component info array is empty!.")); |
|
99 User::Leave(KErrArgument); |
|
100 } |
|
101 DEBUG_PRINTF(_L("Sending add a new component request with a set of localizable names.")); |
|
102 |
|
103 TComponentId compId = static_cast<TComponentId>(aCompOpType); |
|
104 // compId variable carries the component operation type to the SCR server. |
|
105 // On return, it will contain the actual component Id value. |
|
106 TPckg<TComponentId> compIdPckg(compId); |
|
107 HBufC8* arrayBuf = ExternalizePointersArrayLC(aComponentInfo); |
|
108 const TDesC *globalId = aGlobalId ? aGlobalId : &KNullDesC(); |
|
109 TIpcArgs args(&aUniqueSwTypeName, arrayBuf, globalId, &compIdPckg); |
|
110 User::LeaveIfError(CallSessionFunction(EAddComponent, args)); |
|
111 CleanupStack::PopAndDestroy(arrayBuf); |
|
112 return compId; |
|
113 } |
|
114 |
|
115 template <class C> |
|
116 void RSoftwareComponentRegistry::SendDependencyArgsL(TInt aFunction, const C& aSupplierId, const CGlobalComponentId& aDependantGlobalCompId) |
|
117 { |
|
118 RBuf8 suppVerCompId; |
|
119 suppVerCompId.CleanupClosePushL(); |
|
120 ExternalizeObjectL(&aSupplierId, suppVerCompId); |
|
121 |
|
122 RBuf8 depGlobalId; |
|
123 depGlobalId.CleanupClosePushL(); |
|
124 ExternalizeObjectL(&aDependantGlobalCompId, depGlobalId); |
|
125 // Send the software type of the dependant component seperately in order to apply custom security check properly on the server side. |
|
126 TIpcArgs args(&aDependantGlobalCompId.SoftwareTypeName(),&suppVerCompId, &depGlobalId); |
|
127 User::LeaveIfError(CallSessionFunction(aFunction, args)); |
|
128 CleanupStack::PopAndDestroy(2, &suppVerCompId); // suppVerCompId, depGlobalId |
|
129 } |
|
130 |
|
131 EXPORT_C void RSoftwareComponentRegistry::AddComponentDependencyL(const CVersionedComponentId& aSupplierVerCompId, const CGlobalComponentId& aDependantGlobalCompId) |
|
132 { |
|
133 DEBUG_PRINTF3(_L("Sending a request to add a new dependency between two components (%S depends on %S)."), &aDependantGlobalCompId.GlobalIdName(), &aSupplierVerCompId.GlobalId().GlobalIdName()); |
|
134 SendDependencyArgsL(EAddComponentDependency, aSupplierVerCompId, aDependantGlobalCompId); |
|
135 } |
|
136 |
|
137 EXPORT_C void RSoftwareComponentRegistry::SetComponentPropertyL(TComponentId aComponentId, const TDesC& aName, const TDesC8& aValue) |
|
138 { |
|
139 DEBUG_PRINTF3(_L("Sending a request to set the binary property(%S) of the component(%d)."), &aName, aComponentId); |
|
140 TIpcArgs args(aComponentId, &aName, &aValue); |
|
141 User::LeaveIfError(CallSessionFunction(ESetComponentBinaryProperty, args)); |
|
142 } |
|
143 |
|
144 EXPORT_C void RSoftwareComponentRegistry::SetComponentPropertyL(TComponentId aComponentId, const TDesC& aName, const TDesC& aValue, TLanguage aLocale) |
|
145 { |
|
146 DEBUG_PRINTF4(_L("Sending a request to set the string property(%S,%S) of the component(%d)."), &aName, &aValue, aComponentId); |
|
147 TIpcArgs args(aComponentId, &aName, &aValue, aLocale); |
|
148 User::LeaveIfError(CallSessionFunction(ESetComponentLocalizableProperty, args)); |
|
149 } |
|
150 |
|
151 EXPORT_C void RSoftwareComponentRegistry::SetComponentPropertyL(TComponentId aComponentId, const TDesC& aName, TInt64 aValue) |
|
152 { |
|
153 DEBUG_PRINTF4(_L("Sending a request to set the numeric property(%S,%Ld) of the component(%d)."), &aName, aValue, aComponentId); |
|
154 TIpcArgs args(aComponentId, &aName, I64HIGH(aValue), I64LOW(aValue)); |
|
155 User::LeaveIfError(CallSessionFunction(ESetComponentNumericProperty, args)); |
|
156 } |
|
157 |
|
158 EXPORT_C void RSoftwareComponentRegistry::RegisterComponentFileL(TComponentId aComponentId, const TDesC& aFileName, TBool aConsiderForInstalledDrives /*= ETrue*/ ) |
|
159 { |
|
160 DEBUG_PRINTF4(_L("Sending a request to register the file(%S) for the component(%d). ConsiderFilesInDriveList:%d"), &aFileName, aComponentId, aConsiderForInstalledDrives); |
|
161 TIpcArgs args(aComponentId, &aFileName, aConsiderForInstalledDrives); |
|
162 User::LeaveIfError(CallSessionFunction(ERegisterComponentFile, args)); |
|
163 } |
|
164 |
|
165 EXPORT_C void RSoftwareComponentRegistry::SetFilePropertyL(TComponentId aComponentId, const TDesC& aFileName, const TDesC& aPropName, const TDesC8& aPropValue) |
|
166 { |
|
167 DEBUG_PRINTF4(_L("Sending a request to set the string property(%S) of the file(%S) of the component(%d)."), &aPropName, &aFileName, aComponentId); |
|
168 TIpcArgs args(aComponentId, &aFileName, &aPropName, &aPropValue); |
|
169 User::LeaveIfError(CallSessionFunction(ESetFileStringProperty, args)); |
|
170 } |
|
171 EXPORT_C void RSoftwareComponentRegistry::SetFilePropertyL(TComponentId aComponentId, const TDesC& aFileName, const TDesC& aPropName, TInt aPropValue) |
|
172 { |
|
173 DEBUG_PRINTF5(_L("Sending a request to set the numeric property(%S,%d) of the file(%S) of the component(%d)."), &aPropName, aPropValue, &aFileName, aComponentId); |
|
174 TIpcArgs args(aComponentId, &aFileName, &aPropName, aPropValue); |
|
175 User::LeaveIfError(CallSessionFunction(ESetFileNumericProperty, args)); |
|
176 } |
|
177 |
|
178 EXPORT_C void RSoftwareComponentRegistry::SetComponentNameL(TComponentId aComponentId, const TDesC& aName, TLanguage aLocale) |
|
179 { |
|
180 DEBUG_PRINTF4(_L("Sending a request to update the name(%S,%d) of the component(%d)."), &aName, aLocale, aComponentId); |
|
181 TIpcArgs args(aComponentId, &aName, aLocale); |
|
182 User::LeaveIfError(CallSessionFunction(ESetComponentName, args)); |
|
183 } |
|
184 |
|
185 EXPORT_C void RSoftwareComponentRegistry::SetVendorNameL(TComponentId aComponentId, const TDesC& aVendor, TLanguage aLocale) |
|
186 { |
|
187 DEBUG_PRINTF4(_L("Sending a request to update the vendor(%S,%d) of the component(%d)."), &aVendor, aLocale, aComponentId); |
|
188 TIpcArgs args(aComponentId, &aVendor, aLocale); |
|
189 User::LeaveIfError(CallSessionFunction(ESetComponentVendor, args)); |
|
190 } |
|
191 |
|
192 EXPORT_C void RSoftwareComponentRegistry::SetComponentVersionL(TComponentId aComponentId, const TDesC& aVersion) |
|
193 { |
|
194 DEBUG_PRINTF3(_L("Sending a request to set the version(%S) of the component(%d)."), &aVersion, aComponentId); |
|
195 TIpcArgs args(aComponentId, &aVersion); |
|
196 User::LeaveIfError(CallSessionFunction(ESetComponentVersion, args)); |
|
197 } |
|
198 |
|
199 EXPORT_C void RSoftwareComponentRegistry::SetIsComponentRemovableL(TComponentId aComponentId, TBool aValue) |
|
200 { |
|
201 DEBUG_PRINTF3(_L("Sending a request to set the removable attribute(%d) of the component(%d)."), aValue, aComponentId); |
|
202 TIpcArgs args(aComponentId, aValue); |
|
203 User::LeaveIfError(CallSessionFunction(ESetIsComponentRemovable, args)); |
|
204 } |
|
205 |
|
206 EXPORT_C void RSoftwareComponentRegistry::SetIsComponentDrmProtectedL(TComponentId aComponentId, TBool aValue) |
|
207 { |
|
208 DEBUG_PRINTF3(_L("Sending a request to set the DRM protected attribute(%d) of the component(%d)."), aValue, aComponentId); |
|
209 TIpcArgs args(aComponentId, aValue); |
|
210 User::LeaveIfError(CallSessionFunction(ESetIsComponentDrmProtected, args)); |
|
211 } |
|
212 |
|
213 EXPORT_C void RSoftwareComponentRegistry::SetIsComponentHiddenL(TComponentId aComponentId, TBool aValue) |
|
214 { |
|
215 DEBUG_PRINTF3(_L("Sending a request to set the hidden attribute(%d) of the component(%d)."), aValue, aComponentId); |
|
216 TIpcArgs args(aComponentId, aValue); |
|
217 User::LeaveIfError(CallSessionFunction(ESetIsComponentHidden, args)); |
|
218 } |
|
219 |
|
220 EXPORT_C void RSoftwareComponentRegistry::SetIsComponentKnownRevokedL(TComponentId aComponentId, TBool aValue) |
|
221 { |
|
222 DEBUG_PRINTF3(_L("Sending a request to set the known-revoked attribute(%d) of the component(%d)."), aValue, aComponentId); |
|
223 TIpcArgs args(aComponentId, aValue); |
|
224 User::LeaveIfError(CallSessionFunction(ESetIsComponentKnownRevoked, args)); |
|
225 } |
|
226 |
|
227 EXPORT_C void RSoftwareComponentRegistry::SetIsComponentOriginVerifiedL(TComponentId aComponentId, TBool aValue) |
|
228 { |
|
229 DEBUG_PRINTF3(_L("Sending a request to set the origin-verified attribute(%d) of the component(%d)."), aValue, aComponentId); |
|
230 TIpcArgs args(aComponentId, aValue); |
|
231 User::LeaveIfError(CallSessionFunction(ESetIsComponentOriginVerified, args)); |
|
232 } |
|
233 |
|
234 EXPORT_C void RSoftwareComponentRegistry::SetComponentSizeL(TComponentId aComponentId, TInt64 aComponentSizeInBytes) |
|
235 { |
|
236 DEBUG_PRINTF3(_L("Sending a request to set the install-time size (%Ld) of the component(%d)."), aComponentSizeInBytes, aComponentId); |
|
237 TIpcArgs args(aComponentId, I64HIGH(aComponentSizeInBytes), I64LOW(aComponentSizeInBytes)); |
|
238 User::LeaveIfError(CallSessionFunction(ESetComponentSize, args)); |
|
239 } |
|
240 |
|
241 EXPORT_C void RSoftwareComponentRegistry::DeleteComponentPropertyL(TComponentId aComponentId, const TDesC& aPropName) |
|
242 { |
|
243 DEBUG_PRINTF3(_L("Sending a request to delete the property(%S) of the component(%d)."), &aPropName, aComponentId); |
|
244 TIpcArgs args(aComponentId, &aPropName); |
|
245 User::LeaveIfError(CallSessionFunction(EDeleteComponentProperty, args)); |
|
246 } |
|
247 |
|
248 EXPORT_C void RSoftwareComponentRegistry::DeleteFilePropertyL(TComponentId aComponentId, const TDesC& aFileName, const TDesC& aPropName) |
|
249 { |
|
250 DEBUG_PRINTF4(_L("Sending a request to delete the property(%S) of the file(%S) of the component(%d)."), &aPropName, &aFileName, aComponentId); |
|
251 TIpcArgs args(aComponentId, &aFileName, &aPropName); |
|
252 User::LeaveIfError(CallSessionFunction(EDeleteFileProperty, args)); |
|
253 } |
|
254 |
|
255 EXPORT_C void RSoftwareComponentRegistry::UnregisterComponentFileL(TComponentId aComponentId, const TDesC& aFileName) |
|
256 { |
|
257 DEBUG_PRINTF3(_L("Sending a request to deregister the file(%S) for the component(%d)."), &aFileName, aComponentId); |
|
258 TIpcArgs args(aComponentId, &aFileName); |
|
259 User::LeaveIfError(CallSessionFunction(EUnregisterComponentFile, args)); |
|
260 } |
|
261 |
|
262 EXPORT_C void RSoftwareComponentRegistry::DeleteComponentL(TComponentId aComponentId) |
|
263 { |
|
264 DEBUG_PRINTF2(_L("Sending a request to delete the component(%d)."), aComponentId); |
|
265 TIpcArgs args(aComponentId); |
|
266 User::LeaveIfError(CallSessionFunction(EDeleteComponent, args)); |
|
267 } |
|
268 |
|
269 EXPORT_C void RSoftwareComponentRegistry::DeleteComponentDependencyL(const CGlobalComponentId& aSupplierGlobalCompId, const CGlobalComponentId& aDependantGlobalCompId) |
|
270 { |
|
271 DEBUG_PRINTF3(_L("Sending a request to delete an existing dependency between two components (%S depends on %S)."), &aDependantGlobalCompId.GlobalIdName(), &aSupplierGlobalCompId.GlobalIdName()); |
|
272 SendDependencyArgsL(EDeleteComponentDependency, aSupplierGlobalCompId, aDependantGlobalCompId); |
|
273 } |
|
274 |
|
275 EXPORT_C TBool RSoftwareComponentRegistry::GetComponentL(TComponentId aComponentId, CComponentEntry& aEntry, TLanguage aLocale) const |
|
276 { |
|
277 DEBUG_PRINTF2(_L("Sending a request to retrieve the entry of the component(%d)."), aComponentId); |
|
278 TIpcArgs args(aComponentId, aLocale); |
|
279 TInt argNum = 2; // size descriptor will be added to this slot |
|
280 return GetObjectL(*this, aEntry, EGetSingleComponentSize, EGetSingleComponentData, argNum, args); |
|
281 } |
|
282 |
|
283 EXPORT_C void RSoftwareComponentRegistry::GetComponentLocalizedInfoL(TComponentId aComponentId, RPointerArray<CLocalizableComponentInfo>& aCompLocalizedInfoArray) const |
|
284 { |
|
285 DEBUG_PRINTF2(_L("Sending a request to retrieve the localized entry of the component(%d)."), aComponentId); |
|
286 TIpcArgs args(aComponentId); |
|
287 TInt argNum = 1; // size descriptor will be added to this slot |
|
288 GetObjectArrayL(*this, EGetLocalizedComponentSize, EGetLocalizedComponentData, argNum, args, aCompLocalizedInfoArray); |
|
289 } |
|
290 |
|
291 EXPORT_C void RSoftwareComponentRegistry::GetComponentIdsL(RArray<TComponentId>& aComponentIdList, CComponentFilter* aFilter) const |
|
292 { |
|
293 RBuf8 buf; |
|
294 buf.CleanupClosePushL(); |
|
295 ExternalizeObjectL(aFilter, buf); |
|
296 |
|
297 TIpcArgs args(&buf); |
|
298 TInt argNum = 1; |
|
299 GetObjectArrayL(*this, EGetComponentIdListSize, EGetComponentIdListData, argNum, args, aComponentIdList); |
|
300 CleanupStack::PopAndDestroy(&buf); |
|
301 } |
|
302 |
|
303 EXPORT_C TComponentId RSoftwareComponentRegistry::GetComponentIdL(const TDesC& aGlobalIdName, const TDesC& aUniqueSwTypeName) const |
|
304 { |
|
305 DEBUG_PRINTF3(_L("Sending a request to retrieve the local component Id of a global component id (%S,%S)."), &aGlobalIdName, &aUniqueSwTypeName); |
|
306 |
|
307 TComponentId compId; |
|
308 TPckg<TComponentId> compIdPckg(compId); |
|
309 |
|
310 TIpcArgs args(&aGlobalIdName, &aUniqueSwTypeName, &compIdPckg); |
|
311 User::LeaveIfError(CallSessionFunction(EGetLocalComponentId, args)); |
|
312 |
|
313 return compId; |
|
314 } |
|
315 |
|
316 EXPORT_C CComponentEntry* RSoftwareComponentRegistry::GetComponentL(const TDesC& aGlobalIdName, const TDesC& aUniqueSwTypeName, TLanguage aLocale) const |
|
317 { |
|
318 DEBUG_PRINTF3(_L("Sending a request with the global id(%S,%S) to retrieve the entry of the component."), &aGlobalIdName, &aUniqueSwTypeName); |
|
319 |
|
320 TIpcArgs args(&aGlobalIdName, &aUniqueSwTypeName, aLocale); |
|
321 TInt argNum = 3; // size descriptor will be added to this slot |
|
322 return GetObjectL<CComponentEntry>(*this, EGetComponentWithGlobalIdSize, EGetComponentWithGlobalIdData, argNum, args); |
|
323 } |
|
324 |
|
325 EXPORT_C void RSoftwareComponentRegistry::GetSupplierComponentsL(const CGlobalComponentId& aDependantGlobalId, RPointerArray<CVersionedComponentId>& aSupplierList) const |
|
326 { |
|
327 DEBUG_PRINTF2(_L("Sending a request to retrieve the supplier list of a dependant component (%S)."), &aDependantGlobalId.GlobalIdName()); |
|
328 |
|
329 RBuf8 depGlobalId; |
|
330 depGlobalId.CleanupClosePushL(); |
|
331 ExternalizeObjectL(&aDependantGlobalId, depGlobalId); |
|
332 |
|
333 TIpcArgs args(&depGlobalId); |
|
334 TInt argNum = 1; |
|
335 GetObjectArrayL(*this, EGetSupplierComponentsSize, EGetSupplierComponentsData, argNum, args, aSupplierList); |
|
336 CleanupStack::PopAndDestroy(&depGlobalId); |
|
337 } |
|
338 |
|
339 EXPORT_C void RSoftwareComponentRegistry::GetDependantComponentsL(const CGlobalComponentId& aSupplierGlobalId, RPointerArray<CVersionedComponentId>& aDependantList) const |
|
340 { |
|
341 DEBUG_PRINTF2(_L("Sending a request to retrieve the dependant list of a supplier component (%S)."), &aSupplierGlobalId.GlobalIdName()); |
|
342 |
|
343 RBuf8 supGlobalId; |
|
344 supGlobalId.CleanupClosePushL(); |
|
345 ExternalizeObjectL(&aSupplierGlobalId, supGlobalId); |
|
346 |
|
347 TIpcArgs args(&supGlobalId); |
|
348 TInt argNum = 1; |
|
349 GetObjectArrayL(*this, EGetDependantComponentsSize, EGetDependantComponentsData, argNum, args, aDependantList); |
|
350 CleanupStack::PopAndDestroy(&supGlobalId); |
|
351 } |
|
352 |
|
353 EXPORT_C void RSoftwareComponentRegistry::GetFilePropertiesL(TComponentId aComponentId, const TDesC& aFileName, RPointerArray<CPropertyEntry>& aProperties) const |
|
354 { |
|
355 DEBUG_PRINTF2(_L("Sending a request to retrieve the properties of the file(%S)."), &aFileName); |
|
356 TIpcArgs args(aComponentId, &aFileName); |
|
357 TInt argNum = 2; |
|
358 GetObjectArrayL(*this, EGetFilePropertiesSize, EGetFilePropertiesData, argNum, args, aProperties); |
|
359 } |
|
360 |
|
361 EXPORT_C CPropertyEntry* RSoftwareComponentRegistry::GetFilePropertyL(TComponentId aComponentId, const TDesC& aFileName, const TDesC& aPropertyName) const |
|
362 { |
|
363 DEBUG_PRINTF3(_L("Sending a request to retrieve the property(%S) of the file(%S)."), &aPropertyName, &aFileName); |
|
364 TIpcArgs args(aComponentId, &aFileName, &aPropertyName); |
|
365 TInt argNum = 3; |
|
366 return GetObjectL<CPropertyEntry>(*this, EGetSingleFilePropertySize, EGetSingleFilePropertyData, argNum, args); |
|
367 } |
|
368 |
|
369 EXPORT_C TUint RSoftwareComponentRegistry::GetComponentFilesCountL(TComponentId aComponentId) const |
|
370 { |
|
371 TUint registeredFilesNum; |
|
372 TPckg<TUint> resPckg(registeredFilesNum); |
|
373 TIpcArgs args(aComponentId, &resPckg); |
|
374 User::LeaveIfError(CallSessionFunction(EGetComponentFilesCount, args)); |
|
375 return registeredFilesNum; |
|
376 } |
|
377 |
|
378 EXPORT_C void RSoftwareComponentRegistry::GetComponentsL(const TDesC& aFileName, RArray<TComponentId>& aComponents) const |
|
379 { |
|
380 TIpcArgs args(&aFileName); |
|
381 TInt argNum = 1; |
|
382 GetObjectArrayL(*this, EGetFileComponentsSize, EGetFileComponentsData, argNum, args, aComponents); |
|
383 } |
|
384 |
|
385 EXPORT_C CPropertyEntry* RSoftwareComponentRegistry::GetComponentPropertyL(TComponentId aComponentId, const TDesC& aPropertyName, TLanguage aLocale) const |
|
386 { |
|
387 TIpcArgs args(aComponentId, &aPropertyName, aLocale); |
|
388 TInt argNum = 3; |
|
389 return GetObjectL<CPropertyEntry>(*this, EGetComponentSinglePropertySize, EGetComponentSinglePropertyData, argNum, args); |
|
390 } |
|
391 |
|
392 EXPORT_C void RSoftwareComponentRegistry::GetComponentPropertiesL(TComponentId aComponentId, RPointerArray<CPropertyEntry>& aProperties, TLanguage aLocale) const |
|
393 { |
|
394 TIpcArgs args(aComponentId, aLocale); |
|
395 TInt argNum = 2; |
|
396 GetObjectArrayL(*this, EGetComponentPropertiesSize, EGetComponentPropertiesData, argNum, args, aProperties); |
|
397 } |
|
398 |
|
399 EXPORT_C TBool RSoftwareComponentRegistry::IsMediaPresentL(TComponentId aComponentId) const |
|
400 { |
|
401 DEBUG_PRINTF2(_L("Sending a request to retrieve the media presence status of component (%d)."), aComponentId); |
|
402 TBool result; |
|
403 TPckg<TBool> isMediaPresent(result); |
|
404 User::LeaveIfError(CallSessionFunction(EGetIsMediaPresent, TIpcArgs(aComponentId, &isMediaPresent))); |
|
405 |
|
406 DEBUG_PRINTF3(_L("Received media presence status of component (%d) - result is %d."), aComponentId, result); |
|
407 return result; |
|
408 } |
|
409 |
|
410 EXPORT_C void RSoftwareComponentRegistry::SetScomoStateL(TComponentId aComponentId, TScomoState aScomoState) const |
|
411 { |
|
412 DEBUG_PRINTF3(_L("Sending a request to set the scomo state (%d) of component(%d) at install time."), aScomoState, aComponentId); |
|
413 TIpcArgs args(aComponentId, aScomoState); |
|
414 User::LeaveIfError(CallSessionFunction(ESetScomoState, args)); |
|
415 } |
|
416 |
|
417 EXPORT_C TUid RSoftwareComponentRegistry::GetPluginUidL(const TDesC& aMimeType) const |
|
418 { |
|
419 DEBUG_PRINTF2(_L("Sending a request to retrieve the list of plugins for mime types %S."), &aMimeType); |
|
420 TUint32 uidNum(0); |
|
421 TPckg<TUint32> uidDes(uidNum); |
|
422 TIpcArgs args(&aMimeType, &uidDes); |
|
423 User::LeaveIfError(CallSessionFunction(EGetPluginUidWithMimeType, args)); |
|
424 TUid pluginUid = TUid::Uid(uidNum); |
|
425 return pluginUid; |
|
426 } |
|
427 |
|
428 EXPORT_C TUid RSoftwareComponentRegistry::GetPluginUidL(TComponentId aComponentId) const |
|
429 { |
|
430 DEBUG_PRINTF2(_L("Sending a request to retrieve the list of plugins for the component(%d)."), aComponentId); |
|
431 TUint32 uidNum(0); |
|
432 TPckg<TUint32> uidDes(uidNum); |
|
433 TIpcArgs args(aComponentId, &uidDes); |
|
434 User::LeaveIfError(CallSessionFunction(EGetPluginUidWithComponentId, args)); |
|
435 TUid pluginUid = TUid::Uid(uidNum); |
|
436 return pluginUid; |
|
437 } |
|
438 |
|
439 EXPORT_C void RSoftwareComponentRegistry::AddSoftwareTypeL(const CSoftwareTypeRegInfo& aSwTypeRegInfo) |
|
440 { |
|
441 if(!aSwTypeRegInfo.MimeTypes().Count()) |
|
442 { |
|
443 DEBUG_PRINTF(_L("MIME types list cannot be empty!")); |
|
444 User::Leave(KErrArgument); |
|
445 } |
|
446 |
|
447 RBuf8 buf; |
|
448 buf.CleanupClosePushL(); |
|
449 ExternalizeRefObjectL(aSwTypeRegInfo, buf); |
|
450 |
|
451 TIpcArgs swTypeArgs(&buf); |
|
452 User::LeaveIfError(CallSessionFunction(EAddSoftwareType, swTypeArgs)); |
|
453 |
|
454 CleanupStack::PopAndDestroy();//buf, reginfo |
|
455 } |
|
456 |
|
457 EXPORT_C void RSoftwareComponentRegistry::DeleteSoftwareTypeL(const TDesC& aUniqueSwTypeName, RPointerArray<HBufC>& aDeletedMimeTypes) |
|
458 { |
|
459 DEBUG_PRINTF2(_L("Sending a request to delete the software type (%S)."), &aUniqueSwTypeName); |
|
460 TIpcArgs args(&aUniqueSwTypeName); |
|
461 TInt argNum = 1; |
|
462 GetObjectArrayL(*this, EDeleteSoftwareType, EGetDeletedMimeTypes, argNum, args, aDeletedMimeTypes); |
|
463 // Please note that EDeleteSoftwareType IPC function returns the size of the deleted MIME types list. |
|
464 } |
|
465 |
|
466 EXPORT_C TBool RSoftwareComponentRegistry::IsComponentOrphanedL(TComponentId aComponentId) |
|
467 { |
|
468 DEBUG_PRINTF2(_L("Sending a request to get whether the component (%d) is orphaned."), aComponentId); |
|
469 TBool result; |
|
470 TPckg<TBool> isComponentOrphaned(result); |
|
471 User::LeaveIfError(CallSessionFunction(EGetIsComponentOrphaned, TIpcArgs(aComponentId, &isComponentOrphaned))); |
|
472 return result; |
|
473 } |
|
474 |
|
475 EXPORT_C void RSoftwareComponentRegistry::RetrieveLogEntriesL(RPointerArray<CScrLogEntry>& aLogEntries, const TDesC* aUniqueSwTypeName) const |
|
476 { |
|
477 DEBUG_PRINTF(_L("Sending a request to retrieve log entries.")); |
|
478 // Retrieve the RFs and RFile handles from the server |
|
479 TInt fsh; // File server handle (RFs - session) |
|
480 TPckgBuf<TInt> fh; // File handle (RFile - subsession) |
|
481 |
|
482 fsh = CallSessionFunction(EGetLogFileHandle, TIpcArgs(&fh)); // pointer to fh in slot 0 |
|
483 User::LeaveIfError(fsh); |
|
484 |
|
485 // Adopt the file using the returned handles |
|
486 RFile logFile; |
|
487 User::LeaveIfError(logFile.AdoptFromServer(fsh, fh())); |
|
488 CleanupClosePushL(logFile); |
|
489 |
|
490 RFileReadStream logStream(logFile); |
|
491 CleanupClosePushL(logStream); |
|
492 (void)logStream.ReadInt32L(); // skip the major version of the log file |
|
493 (void)logStream.ReadInt32L(); // skip the minor version of the log file |
|
494 TInt logCount = logStream.ReadInt32L(); |
|
495 |
|
496 CScrLogEntry *log = NULL; |
|
497 |
|
498 for (TInt i = 0; i < logCount; ++i) |
|
499 { |
|
500 log = CScrLogEntry::NewLC(logStream); |
|
501 if(aUniqueSwTypeName && aUniqueSwTypeName->CompareF(log->SoftwareTypeName())) |
|
502 { // if unique sw type name is given and the log doesn't belong to that sw type, continue. |
|
503 CleanupStack::PopAndDestroy(log); |
|
504 continue; |
|
505 } |
|
506 // Otherwise, append the log into the log entries list |
|
507 aLogEntries.AppendL(log); |
|
508 CleanupStack::Pop(log); // Ownership is transferred |
|
509 } // for |
|
510 |
|
511 CleanupStack::PopAndDestroy(2, &logFile); // logFile, logStream |
|
512 } |
|
513 |
|
514 TInt GetNextNumberFromVersionL(TLex& aVersion) |
|
515 { |
|
516 TInt number = KErrNotFound; |
|
517 if(aVersion.Eos()) |
|
518 return number; // if the end of string has already been reached, return KErrNotFound. |
|
519 |
|
520 TChar c = aVersion.Peek(); // show the next character |
|
521 |
|
522 while(c != 0 && c != '.') |
|
523 { // Go forward until coming across a dot or reaching the end of the string |
|
524 aVersion.Inc(); |
|
525 c = aVersion.Peek(); |
|
526 } |
|
527 |
|
528 if(!aVersion.TokenLength()) |
|
529 {// unexpected format |
|
530 DEBUG_PRINTF(_L8("Version token length is unexpectedly zero.")); |
|
531 User::Leave(KErrArgument); |
|
532 } |
|
533 |
|
534 // Get the token and convert it to a decimal number |
|
535 TInt err = TLex(aVersion.MarkedToken()).Val(number); |
|
536 if(KErrNone != err) |
|
537 { |
|
538 if(KErrGeneral == err) |
|
539 { // Convert KErrGeneral (if nun-numeric chars exist in the token) to KErrArgument |
|
540 err = KErrArgument; |
|
541 } |
|
542 User::Leave(err); |
|
543 } |
|
544 |
|
545 if(c != 0) |
|
546 { // if it is not the end of the string |
|
547 aVersion.Inc(); // Increment to get over the last dot |
|
548 aVersion.Mark(); // and mark the extraction position |
|
549 } |
|
550 return number; |
|
551 } |
|
552 |
|
553 EXPORT_C TInt RSoftwareComponentRegistry::CompareVersionsL(const TDesC& aVersionLeft, const TDesC& aVersionRight) |
|
554 { |
|
555 DEBUG_PRINTF3(_L("Comparing version left (%S) to version right (%S)."), &aVersionLeft, &aVersionRight); |
|
556 __ASSERT_ALWAYS(aVersionLeft.Length()>0 && aVersionRight.Length()>0, User::Leave(KErrArgument)); |
|
557 |
|
558 if(!aVersionLeft.Compare(aVersionRight)) |
|
559 return 0; // if the version strings are identical, simply return zero (means equality) |
|
560 |
|
561 TLex lVer(aVersionLeft); |
|
562 TLex rVer(aVersionRight); |
|
563 |
|
564 TInt lNum = GetNextNumberFromVersionL(lVer); |
|
565 TInt rNum = GetNextNumberFromVersionL(rVer); |
|
566 |
|
567 while(lNum != KErrNotFound && rNum != KErrNotFound) |
|
568 { |
|
569 TInt diff = lNum - rNum; |
|
570 if(diff != 0) |
|
571 return diff; |
|
572 |
|
573 lNum = GetNextNumberFromVersionL(lVer); |
|
574 rNum = GetNextNumberFromVersionL(rVer); |
|
575 } |
|
576 |
|
577 TInt lVal (0); |
|
578 TInt rVal (0); |
|
579 |
|
580 // The following two while-loops are used to consider trailing zeros. |
|
581 // Theoritically, 1.2.0 is equal to 1.2, however, 1.2.0.1 is greater than 1.2. |
|
582 // In order to handle these conditions the extra parts of the version are sum up |
|
583 // to see whether it is greater than zero. |
|
584 while(lNum != KErrNotFound) |
|
585 { |
|
586 lVal += lNum; |
|
587 lNum = GetNextNumberFromVersionL(lVer); |
|
588 } |
|
589 |
|
590 while(rNum != KErrNotFound) |
|
591 { |
|
592 rVal += rNum; |
|
593 rNum = GetNextNumberFromVersionL(rVer); |
|
594 } |
|
595 |
|
596 return (lVal - rVal); |
|
597 } |
|
598 |
|
599 EXPORT_C TBool RSoftwareComponentRegistry::IsComponentOnReadOnlyDriveL(TComponentId aComponentId) const |
|
600 { |
|
601 DEBUG_PRINTF2(_L("Sending a request to determine if the component (%d) is on read-only drive."), aComponentId); |
|
602 |
|
603 TBool result; |
|
604 TPckg<TBool> isOnReadOnlyDrive(result); |
|
605 User::LeaveIfError(CallSessionFunction(EGetIsComponentOnReadOnlyDrive, TIpcArgs(aComponentId, &isOnReadOnlyDrive))); |
|
606 return result; |
|
607 } |
|
608 |
|
609 EXPORT_C TBool RSoftwareComponentRegistry::IsComponentPresentL(TComponentId aComponentId) const |
|
610 { |
|
611 DEBUG_PRINTF2(_L("Sending a request to determine if the component(%d) is fully present."), aComponentId); |
|
612 TBool result; |
|
613 TPckg<TBool> isCompPresent(result); |
|
614 User::LeaveIfError(CallSessionFunction(EGetIsComponentPresent, TIpcArgs(aComponentId, &isCompPresent))); |
|
615 return result; |
|
616 } |
|
617 |
|
618 EXPORT_C void RSoftwareComponentRegistry::SetIsComponentPresentL(TComponentId aComponentId, TBool aValue) |
|
619 { |
|
620 DEBUG_PRINTF3(_L("Sending a request to set the CompPresence attribute(%d) of the component(%d)."), aValue, aComponentId); |
|
621 TIpcArgs args(aComponentId, aValue); |
|
622 User::LeaveIfError(CallSessionFunction(ESetIsComponentPresent, args)); |
|
623 } |
|
624 |
|
625 EXPORT_C void RSoftwareComponentRegistry::GetComponentSupportedLocalesListL(TComponentId aComponentId,RArray<TLanguage>& aMatchingSupportedLanguages) const |
|
626 { |
|
627 TIpcArgs args(aComponentId); |
|
628 TInt argNum = 1; |
|
629 GetObjectArrayL(*this, EGetComponentSupportedLocalesListSize, EGetComponentSupportedLocalesListData, argNum, args, aMatchingSupportedLanguages); |
|
630 } |
|
631 |
|
632 |
|
633 EXPORT_C void RSoftwareComponentRegistry::AddApplicationEntryL(const TComponentId aComponentId, const CApplicationRegistrationData& aApplicationRegistrationData) |
|
634 { |
|
635 DEBUG_PRINTF2(_L("Sending a request to add an application to be associated with component (%d) from SCR"), aComponentId); |
|
636 |
|
637 if(aApplicationRegistrationData.AppUid() == KNullUid || !((aApplicationRegistrationData.AppFile()).CompareF(KNullDesC())) ) |
|
638 { |
|
639 DEBUG_PRINTF(_L8("AppUid is zero or the App filename is absent. In either of the above cases values cannot be inserted into the db")); |
|
640 User::Leave(KErrArgument); |
|
641 } |
|
642 RBuf8 buf; |
|
643 buf.CleanupClosePushL(); |
|
644 ExternalizeObjectL(&aApplicationRegistrationData, buf); |
|
645 |
|
646 TIpcArgs args(aComponentId, &buf); |
|
647 User::LeaveIfError(CallSessionFunction(EAddApplicationEntry, args)); |
|
648 CleanupStack::PopAndDestroy(&buf); |
|
649 } |
|
650 |
|
651 EXPORT_C void RSoftwareComponentRegistry::DeleteApplicationEntriesL(TComponentId aComponentId) |
|
652 { |
|
653 TIpcArgs args(aComponentId); |
|
654 DEBUG_PRINTF2(_L("Sending a request to delete the applications associated with component (%d) from SCR"), aComponentId); |
|
655 User::LeaveIfError(CallSessionFunction(EDeleteApplicationEntries, args)); |
|
656 } |
|
657 |
|
658 EXPORT_C void RSoftwareComponentRegistry::DeleteApplicationEntryL(TUid aApplicationUid) |
|
659 { |
|
660 TIpcArgs args(aApplicationUid.iUid); |
|
661 DEBUG_PRINTF2(_L("Sending a request to delete an application 0x%x from SCR" ), aApplicationUid.iUid); |
|
662 User::LeaveIfError(CallSessionFunction(EDeleteApplicationEntry, args)); |
|
663 } |
|
664 |
|
665 EXPORT_C TComponentId RSoftwareComponentRegistry::GetComponentIdForAppL(TUid aAppUid) const |
|
666 { |
|
667 DEBUG_PRINTF2(_L("Sending a request to retrieve the component id for AppUid(%d)."), aAppUid); |
|
668 TPckg<TUid> appUidPckg(aAppUid); |
|
669 TComponentId compId; |
|
670 TPckg<TComponentId> compIdPckg(compId); |
|
671 TIpcArgs args(&appUidPckg, &compIdPckg); |
|
672 User::LeaveIfError(CallSessionFunction(EGetComponentIdForApp, args)); |
|
673 return compId; |
|
674 } |
|
675 |
|
676 EXPORT_C void RSoftwareComponentRegistry::GetAppUidsForComponentL(TComponentId aCompId, RArray<TUid>& aAppUids) const |
|
677 { |
|
678 DEBUG_PRINTF2(_L("Sending a request to retrieve the list of apps associated with component(%d)."), aCompId); |
|
679 TIpcArgs args(aCompId); |
|
680 TInt argNum = 1; // size descriptor will be added to this slot |
|
681 GetObjectArrayL(*this, EGetAppUidsForComponentSize, EGetAppUidsForComponentData, argNum, args, aAppUids); |
|
682 } |
|
683 |
|
684 EXPORT_C void RSoftwareComponentRegistry::GetApplicationLaunchersL(RPointerArray<CLauncherExecutable>& aLaunchers) const |
|
685 { |
|
686 DEBUG_PRINTF(_L("Getting the list of applicaiton launchers.")); |
|
687 TIpcArgs args; |
|
688 TInt argNum = 1; |
|
689 GetObjectArrayL(*this, EGetApplicationLaunchersSize, EGetApplicationLaunchersData, argNum, args, aLaunchers); |
|
690 } |
|
691 |
|
692 /* |
|
693 * RScrInternalClient Implementation. |
|
694 */ |
|
695 EXPORT_C RScrInternalClient::RScrInternalClient() |
|
696 : RScsClientBase() |
|
697 { |
|
698 // empty |
|
699 } |
|
700 |
|
701 EXPORT_C TInt RScrInternalClient::Connect() |
|
702 { |
|
703 DEBUG_PRINTF2(_L("Connecting to %S using the internal client(RScrInternalClient)."), &KSoftwareComponentRegistryName); |
|
704 TVersion version = ScrServerVersion(); |
|
705 TUidType scrFullUid = ScrServerImageFullUid(); |
|
706 |
|
707 return RScsClientBase::Connect(KSoftwareComponentRegistryName(), version, KScrServerImageName(), scrFullUid); |
|
708 } |
|
709 |
|
710 EXPORT_C void RScrInternalClient::Close() |
|
711 { |
|
712 DEBUG_PRINTF2(_L("Closing connection to %S using the internal client(RScrInternalClient)."), &KSoftwareComponentRegistryName); |
|
713 RScsClientBase::Close(); |
|
714 } |
|
715 |
|
716 |
|
717 EXPORT_C TUid RScrInternalClient::GenerateNewAppUidL() const |
|
718 { |
|
719 DEBUG_PRINTF(_L("Sending a request to generate a new Application Uid for non native applications.")); |
|
720 |
|
721 TUid newUid = TUid::Null(); |
|
722 TPckg<TUid> appUidPckg(newUid); |
|
723 |
|
724 TIpcArgs args(&appUidPckg); |
|
725 User::LeaveIfError(CallSessionFunction(EGenerateNonNativeAppUid, args)); |
|
726 return newUid; |
|
727 } |
|
728 |
|