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