installationservices/swi/source/sisregistry/client/sisregistrywritablesession.cpp
branchRCL_3
changeset 26 8b7f4e561641
parent 25 7333d7932ef7
equal deleted inserted replaced
25:7333d7932ef7 26:8b7f4e561641
     1 /*
     1 /*
     2 * Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    31 #include "siscontroller.h"
    31 #include "siscontroller.h"
    32 #include "sisinfo.h"
    32 #include "sisinfo.h"
    33 #include "sisuid.h"
    33 #include "sisuid.h"
    34 #include "cleanuputils.h"
    34 #include "cleanuputils.h"
    35 #include "arrayutils.h"
    35 #include "arrayutils.h"
    36 #include "installtypes.h"
       
    37 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
    36 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
    38 #include "swtypereginfo.h"
    37 #include "swtypereginfo.h"
    39 #include "ipcutil.h"
       
    40 #include "sisregistrypackage.h"
       
    41 #endif
    38 #endif
    42 
    39 
    43 using namespace Swi;
    40 using namespace Swi;
    44 
    41 
    45 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
    42 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   104 	}
   101 	}
   105 
   102 
   106 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   103 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   107 EXPORT_C void RSisRegistryWritableSession::AddEntryL(const CApplication& aApplication,
   104 EXPORT_C void RSisRegistryWritableSession::AddEntryL(const CApplication& aApplication,
   108 													 const TDesC8& aController,
   105 													 const TDesC8& aController,
   109 													 const RPointerArray<Usif::CSoftwareTypeRegInfo>& aSwTypeRegInfoArray,
   106 													 const RPointerArray<CSoftwareTypeRegInfo>& aSwTypeRegInfoArray,
   110 													 TInt64 aTransactionID)
   107 													 TInt64 aTransactionID)
   111 	{
   108 	{
   112 	RBuf8 serializedArray;
   109 	RBuf8 serializedArray;
   113 	serializedArray.CleanupClosePushL();
   110 	serializedArray.CleanupClosePushL();
   114 	SoftwareTypeRegInfoUtils::SerializeArrayL(aSwTypeRegInfoArray, serializedArray);
   111 	SoftwareTypeRegInfoUtils::SerializeArrayL(aSwTypeRegInfoArray, serializedArray);
   117 
   114 
   118 	AddEntryImplL(EAddSoftwareTypeEntry, aApplication, aController, aTransactionID, ipcArgs);
   115 	AddEntryImplL(EAddSoftwareTypeEntry, aApplication, aController, aTransactionID, ipcArgs);
   119 
   116 
   120 	CleanupStack::PopAndDestroy(&serializedArray);
   117 	CleanupStack::PopAndDestroy(&serializedArray);
   121 	}
   118 	}
   122 
       
   123 EXPORT_C void RSisRegistryWritableSession::AddEntryL(const Usif::CApplicationRegistrationData& aApparcRegFileData,
       
   124                                                      const CSisRegistryPackage& aSisRegistryPackage)
       
   125     {
       
   126     TIpcArgs ipcArgs;
       
   127     
       
   128     Usif::TComponentId componentUid = GetComponentIdForPackageL(aSisRegistryPackage.Name(),aSisRegistryPackage.Vendor()); 
       
   129     ipcArgs.Set(0, componentUid);
       
   130 
       
   131     TInt objectSize = 0;
       
   132     objectSize = GetObjectSizeL(&aApparcRegFileData);
       
   133     
       
   134     HBufC8* appRegData = HBufC8::NewMaxLC(objectSize);
       
   135     TPtr8 appRegDataDes = appRegData->Des();
       
   136 
       
   137     RDesWriteStream ipcstream(appRegDataDes);
       
   138     CleanupClosePushL(ipcstream);
       
   139     
       
   140     ipcstream << aApparcRegFileData;
       
   141     ipcstream.CommitL();
       
   142     ipcArgs.Set(1, &appRegDataDes);
       
   143     
       
   144     User::LeaveIfError(SendReceive(EAddAppRegEntry, ipcArgs));
       
   145     CleanupStack::PopAndDestroy(2, appRegData);
       
   146     }
       
   147 #endif
   119 #endif
   148 
   120 
   149 void RSisRegistryWritableSession::UpdateEntryImplL(TInt aMessage,
   121 void RSisRegistryWritableSession::UpdateEntryImplL(TInt aMessage,
   150 												   const CApplication& aApplication, 
   122 												   const CApplication& aApplication, 
   151 												   const TDesC8& aController, 
   123 												   const TDesC8& aController, 
   221 	}
   193 	}
   222 
   194 
   223 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   195 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   224 EXPORT_C void RSisRegistryWritableSession::UpdateEntryL(const CApplication& aApplication, 
   196 EXPORT_C void RSisRegistryWritableSession::UpdateEntryL(const CApplication& aApplication, 
   225 														const TDesC8& aController,
   197 														const TDesC8& aController,
   226 														const RPointerArray<Usif::CSoftwareTypeRegInfo>& aSwTypeRegInfoArray,
   198 														const RPointerArray<CSoftwareTypeRegInfo>& aSwTypeRegInfoArray,
   227 														TInt64 aTransactionID)
   199 														TInt64 aTransactionID)
   228 	{
   200 	{
   229 	RBuf8 serializedArray;
   201 	RBuf8 serializedArray;
   230 	serializedArray.CleanupClosePushL();
   202 	serializedArray.CleanupClosePushL();
   231 	SoftwareTypeRegInfoUtils::SerializeArrayL(aSwTypeRegInfoArray, serializedArray);
   203 	SoftwareTypeRegInfoUtils::SerializeArrayL(aSwTypeRegInfoArray, serializedArray);
   234 	
   206 	
   235 	UpdateEntryImplL(EUpdateSoftwareTypeEntry, aApplication, aController, aTransactionID, ipcArgs);
   207 	UpdateEntryImplL(EUpdateSoftwareTypeEntry, aApplication, aController, aTransactionID, ipcArgs);
   236 	
   208 	
   237 	CleanupStack::PopAndDestroy(&serializedArray);
   209 	CleanupStack::PopAndDestroy(&serializedArray);
   238 	}
   210 	}
   239 
       
   240 EXPORT_C void RSisRegistryWritableSession::UpdateEntryL(const CApplication& aApplication, 
       
   241                                                         const Usif::CApplicationRegistrationData& aApparcRegFileData,
       
   242                                                         const CSisRegistryPackage& aSisRegistryPackage) 
       
   243     {
       
   244     TIpcArgs ipcArgs;
       
   245     Usif::TComponentId componentUid = 0;  
       
   246 
       
   247     TRAPD(err,componentUid = GetComponentIdForPackageL(aSisRegistryPackage.Name(),aSisRegistryPackage.Vendor());)
       
   248 
       
   249 	if (err != KErrNone && err != KErrNotFound)
       
   250         {
       
   251         User::Leave(err);
       
   252         }
       
   253     else if (err == KErrNotFound) // Possible only in PU and SA.
       
   254         {
       
   255         componentUid = GetComponentIdForUidL(aApplication.ControllerL().Info().Uid().Uid());
       
   256         }
       
   257 
       
   258     ipcArgs.Set(0, componentUid);
       
   259     
       
   260     TInt objectSize = 0;
       
   261     objectSize = GetObjectSizeL(&aApparcRegFileData);
       
   262     HBufC8* appRegData=HBufC8::NewMaxLC(objectSize);
       
   263     TPtr8 appRegDataDes = appRegData->Des();
       
   264 
       
   265     RDesWriteStream ipcstream(appRegDataDes);
       
   266     CleanupClosePushL(ipcstream);
       
   267     
       
   268     ipcstream << aApparcRegFileData;
       
   269     ipcstream.CommitL();
       
   270     ipcArgs.Set(1, &appRegDataDes);
       
   271     User::LeaveIfError(SendReceive(EUpdateAppRegEntry, ipcArgs));
       
   272     CleanupStack::PopAndDestroy(2, appRegData);
       
   273     }
       
   274 #endif
   211 #endif
   275 
   212 
   276 EXPORT_C void RSisRegistryWritableSession::DeleteEntryL(const CSisRegistryPackage& aPackage, TInt64 aTransactionID)
   213 EXPORT_C void RSisRegistryWritableSession::DeleteEntryL(const CSisRegistryPackage& aPackage, TInt64 aTransactionID)
   277 	{
   214 	{
   278 	TPckgC<TUid> packageUid(aPackage.Uid());
   215 	TPckgC<TUid> packageUid(aPackage.Uid());
   393 	TPckgC<TComponentId> packageComponentId(aComponentId);
   330 	TPckgC<TComponentId> packageComponentId(aComponentId);
   394 	TPckgC<TScomoState> packageState(aState);	
   331 	TPckgC<TScomoState> packageState(aState);	
   395 	TInt returnCode = SendReceive(ESetComponentState, TIpcArgs(&packageComponentId, &packageState));
   332 	TInt returnCode = SendReceive(ESetComponentState, TIpcArgs(&packageComponentId, &packageState));
   396 	User::LeaveIfError(returnCode);
   333 	User::LeaveIfError(returnCode);
   397 	}
   334 	}
   398 
   335 #endif
   399 EXPORT_C void RSisRegistryWritableSession::SetComponentPresenceL(TComponentId aComponentId, TBool aState)
       
   400     {
       
   401     TPckgC<TComponentId> componentId(aComponentId);
       
   402     TPckgC<TBool> componentPresence(aState);   
       
   403     User::LeaveIfError(SendReceive(ESetComponentPresence, TIpcArgs(&componentId, &componentPresence)));
       
   404     }
       
   405 #endif