installationservices/swinstallationfw/source/sifcommon.cpp
changeset 25 98b66e4fb0be
parent 24 84a16765cd86
child 42 d17dc5398051
equal deleted inserted replaced
24:84a16765cd86 25:98b66e4fb0be
     1 /*
     1 /*
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2008-2010 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".
    87 	return iMsg.SecureId();
    87 	return iMsg.SecureId();
    88 	}
    88 	}
    89 
    89 
    90 // ##########################################################################################
    90 // ##########################################################################################
    91 
    91 
       
    92 CComponentInfo::CApplicationInfo::CApplicationInfo()
       
    93     {
       
    94     }
       
    95 
       
    96 EXPORT_C CComponentInfo::CApplicationInfo::~CApplicationInfo()
       
    97     {
       
    98     delete iName;
       
    99     delete iGroupName;
       
   100     delete iIconFileName;
       
   101     }
       
   102 
       
   103 EXPORT_C CComponentInfo::CApplicationInfo* CComponentInfo::CApplicationInfo::NewLC(const TUid& aAppUid, const TDesC& aName, const TDesC& aGroupName, const TDesC& aIconFileName)
       
   104     {
       
   105         _LIT(emptyString,"");
       
   106         // Leave if aName, aGroupName or aIconFileName exceeds KMaxDescriptorLength
       
   107        if ((&aName != NULL && aName.Length() > KMaxDescriptorLength) || 
       
   108                (&aGroupName != NULL && aGroupName.Length() > KMaxDescriptorLength) ||
       
   109                (&aIconFileName != NULL && aIconFileName.Length() > KMaxDescriptorLength))
       
   110             {
       
   111             User::Leave(KErrOverflow);
       
   112             }
       
   113         
       
   114        CComponentInfo::CApplicationInfo* self = new (ELeave) CComponentInfo::CApplicationInfo();
       
   115        CleanupStack::PushL(self);
       
   116 
       
   117         self->iAppUid = aAppUid;  
       
   118         if(&aName == NULL)
       
   119             {
       
   120             self->iName = emptyString().AllocL();
       
   121             }
       
   122         else
       
   123             {
       
   124             self->iName = aName.AllocL();
       
   125             }
       
   126    
       
   127         if(&aGroupName == NULL)
       
   128             {
       
   129             self->iGroupName = emptyString().AllocL();
       
   130             }
       
   131         else
       
   132             {
       
   133             self->iGroupName = aGroupName.AllocL();
       
   134             }
       
   135         
       
   136         if(&aIconFileName == NULL)
       
   137             {
       
   138             self->iIconFileName = emptyString().AllocL();
       
   139             }
       
   140         else
       
   141             {
       
   142             self->iIconFileName = aIconFileName.AllocL();
       
   143             }     
       
   144     
       
   145         return self;
       
   146     }
       
   147 
       
   148 EXPORT_C const TUid& CComponentInfo::CApplicationInfo::AppUid() const
       
   149     {
       
   150     return iAppUid;
       
   151     }
       
   152 
       
   153 EXPORT_C const TDesC& CComponentInfo::CApplicationInfo::Name() const
       
   154     {
       
   155     return *iName;
       
   156     }
       
   157 
       
   158 EXPORT_C const TDesC& CComponentInfo::CApplicationInfo::GroupName() const
       
   159     {
       
   160     return *iGroupName;
       
   161     }
       
   162 
       
   163 EXPORT_C const TDesC& CComponentInfo::CApplicationInfo::IconFileName() const            
       
   164     {
       
   165     return *iIconFileName;
       
   166     }
       
   167 
       
   168 CComponentInfo::CApplicationInfo* CComponentInfo::CApplicationInfo::NewL(RReadStream& aStream)
       
   169     {    
       
   170     CApplicationInfo* self = new (ELeave) CApplicationInfo();
       
   171     CleanupStack::PushL(self);
       
   172     
       
   173     self->iAppUid = TUid::Uid(aStream.ReadInt32L());
       
   174     self->iName = HBufC::NewL(aStream, KMaxDescriptorLength);
       
   175     self->iGroupName = HBufC::NewL(aStream, KMaxDescriptorLength);
       
   176     self->iIconFileName = HBufC::NewL(aStream, KMaxDescriptorLength);
       
   177     
       
   178     CleanupStack::Pop(self);
       
   179     return self;
       
   180     }
       
   181 
       
   182 void CComponentInfo::CApplicationInfo::ExternalizeL(RWriteStream& aStream) const
       
   183     {
       
   184     aStream.WriteInt32L(iAppUid.iUid);    
       
   185     aStream << *iName;
       
   186     aStream << *iGroupName;
       
   187     aStream << *iIconFileName;
       
   188     }
       
   189             
       
   190 // ##########################################################################################
       
   191 
    92 CComponentInfo::CNode::CNode() : iAuthenticity(ENotAuthenticated)
   192 CComponentInfo::CNode::CNode() : iAuthenticity(ENotAuthenticated)
    93 	{
   193 	{
    94 	iUserGrantableCaps.SetEmpty();
   194 	iUserGrantableCaps.SetEmpty();
    95 	}
   195 	}
    96 
   196 
   100 	delete iComponentName;
   200 	delete iComponentName;
   101 	delete iGlobalComponentId;
   201 	delete iGlobalComponentId;
   102 	delete iVersion;
   202 	delete iVersion;
   103 	delete iVendor;
   203 	delete iVendor;
   104 
   204 
   105 	iChildren.Close();
   205 	iApplications.Close();
       
   206 	iChildren.Close();	
   106 	}
   207 	}
   107 
   208 
   108 EXPORT_C CComponentInfo::CNode* CComponentInfo::CNode::NewLC(const TDesC& aSoftwareTypeName, const TDesC& aComponentName,
   209 EXPORT_C CComponentInfo::CNode* CComponentInfo::CNode::NewLC(const TDesC& aSoftwareTypeName, const TDesC& aComponentName,
   109 															const TDesC& aVersion, const TDesC& aVendor, TScomoState aScomoState,
   210 															const TDesC& aVersion, const TDesC& aVendor, TScomoState aScomoState,
   110 															TInstallStatus aInstallStatus, TComponentId aComponentId,
   211 															TInstallStatus aInstallStatus, TComponentId aComponentId,
   111 															const TDesC& aGlobalComponentId, TAuthenticity aAuthenticity,
   212 															const TDesC& aGlobalComponentId, TAuthenticity aAuthenticity,
   112 															const TCapabilitySet& aUserGrantableCaps, TInt aMaxInstalledSize,
   213 															const TCapabilitySet& aUserGrantableCaps, TInt aMaxInstalledSize,
   113 															TBool aHasExe,
   214 															TBool aHasExe, TBool aIsDriveSelectionRequired,
   114 															RPointerArray<CNode>* aChildren)
   215 															RPointerArray<CApplicationInfo>* aApplications, RPointerArray<CNode>* aChildren)
   115 	{
   216 	{
   116 	// We leave if aSoftwareTypeName, aComponentName, aVersion, aVendor or aGlobalComponentId exceeds KMaxDescriptorLength
   217 	// We leave if aSoftwareTypeName, aComponentName, aVersion, aVendor or aGlobalComponentId exceeds KMaxDescriptorLength
   117 	if (aSoftwareTypeName.Length() > KMaxDescriptorLength ||
   218 	if (aSoftwareTypeName.Length() > KMaxDescriptorLength ||
   118 		aComponentName.Length() > KMaxDescriptorLength ||
   219 		aComponentName.Length() > KMaxDescriptorLength ||
   119 		aVersion.Length() > KMaxDescriptorLength ||
   220 		aVersion.Length() > KMaxDescriptorLength ||
   145 	self->iComponentId = aComponentId;
   246 	self->iComponentId = aComponentId;
   146 	self->iAuthenticity = aAuthenticity;
   247 	self->iAuthenticity = aAuthenticity;
   147 	self->iUserGrantableCaps = aUserGrantableCaps;
   248 	self->iUserGrantableCaps = aUserGrantableCaps;
   148 	self->iMaxInstalledSize = aMaxInstalledSize;
   249 	self->iMaxInstalledSize = aMaxInstalledSize;
   149 	self->iHasExe = aHasExe;
   250 	self->iHasExe = aHasExe;
   150 
   251 	self->iIsDriveSelectionRequired = aIsDriveSelectionRequired;
       
   252 
       
   253 	if(aApplications != NULL)
       
   254         {
       
   255         for (TInt i=aApplications->Count()-1; i>=0; --i)
       
   256             {
       
   257             self->iApplications.InsertL((*aApplications)[i], 0);
       
   258             aApplications->Remove(i);
       
   259             }
       
   260         }
       
   261 	
   151 	// Embedded Components
   262 	// Embedded Components
   152 	if(aChildren != NULL)
   263 	if(aChildren != NULL)
   153 		{
   264 		{
   154 		for (TInt i=aChildren->Count()-1; i>=0; --i)
   265 		for (TInt i=aChildren->Count()-1; i>=0; --i)
   155 			{
   266 			{
   187 	self->iComponentId = aStream.ReadInt32L();
   298 	self->iComponentId = aStream.ReadInt32L();
   188 	self->iAuthenticity = static_cast<TAuthenticity>(aStream.ReadInt32L());
   299 	self->iAuthenticity = static_cast<TAuthenticity>(aStream.ReadInt32L());
   189 	UnpackCapabilitySet(aStream.ReadInt32L(), self->iUserGrantableCaps);
   300 	UnpackCapabilitySet(aStream.ReadInt32L(), self->iUserGrantableCaps);
   190 	self->iMaxInstalledSize = aStream.ReadInt32L();
   301 	self->iMaxInstalledSize = aStream.ReadInt32L();
   191 	self->iHasExe = aStream.ReadInt32L();
   302 	self->iHasExe = aStream.ReadInt32L();
   192 
   303 	self->iIsDriveSelectionRequired = aStream.ReadInt32L();	
       
   304 	
       
   305 	const TInt numApplications = aStream.ReadInt32L();
       
   306     for (TInt i=0; i<numApplications; ++i)
       
   307         {
       
   308         CApplicationInfo* app = CApplicationInfo::NewL(aStream);
       
   309         CleanupStack::PushL(app);
       
   310         self->iApplications.AppendL(app);
       
   311         CleanupStack::Pop(app);
       
   312         }
       
   313 	
   193 	const TInt numChildren = aStream.ReadInt32L();
   314 	const TInt numChildren = aStream.ReadInt32L();
   194 	for (TInt i=0; i<numChildren; ++i)
   315 	for (TInt i=0; i<numChildren; ++i)
   195 		{
   316 		{
   196 		CNode* node = CNode::NewL(aStream);
   317 		CNode* node = CNode::NewL(aStream);
   197 		CleanupStack::PushL(node);
   318 		CleanupStack::PushL(node);
   218 	aStream.WriteInt32L(iComponentId);
   339 	aStream.WriteInt32L(iComponentId);
   219 	aStream.WriteInt32L(static_cast<TInt>(iAuthenticity));
   340 	aStream.WriteInt32L(static_cast<TInt>(iAuthenticity));
   220 	aStream.WriteInt32L(PackCapabilitySet(iUserGrantableCaps));
   341 	aStream.WriteInt32L(PackCapabilitySet(iUserGrantableCaps));
   221 	aStream.WriteInt32L(iMaxInstalledSize);
   342 	aStream.WriteInt32L(iMaxInstalledSize);
   222 	aStream.WriteInt32L(iHasExe);
   343 	aStream.WriteInt32L(iHasExe);
       
   344 	aStream.WriteInt32L(iIsDriveSelectionRequired);
       
   345 	
       
   346 	const TInt numApplications = iApplications.Count();
       
   347     aStream.WriteInt32L(numApplications);
       
   348     for (TInt i=0; i<numApplications; ++i)
       
   349         {
       
   350         iApplications[i]->ExternalizeL(aStream);
       
   351         }
   223 	
   352 	
   224 	const TInt numChildren = iChildren.Count();
   353 	const TInt numChildren = iChildren.Count();
   225 	aStream.WriteInt32L(numChildren);
   354 	aStream.WriteInt32L(numChildren);
   226 	for (TInt i=0; i<numChildren; ++i)
   355 	for (TInt i=0; i<numChildren; ++i)
   227 		{
   356 		{
   286 
   415 
   287 EXPORT_C TBool CComponentInfo::CNode::HasExecutable() const
   416 EXPORT_C TBool CComponentInfo::CNode::HasExecutable() const
   288 	{
   417 	{
   289 	return iHasExe;
   418 	return iHasExe;
   290 	}
   419 	}
       
   420 
       
   421 EXPORT_C TBool CComponentInfo::CNode::DriveSeletionRequired() const
       
   422     {
       
   423     return iIsDriveSelectionRequired;
       
   424     }
       
   425 
       
   426 EXPORT_C const RPointerArray<CComponentInfo::CApplicationInfo>& CComponentInfo::CNode::Applications() const
       
   427     {
       
   428     return iApplications;
       
   429     }
   291 
   430 
   292 EXPORT_C const RPointerArray<CComponentInfo::CNode>& CComponentInfo::CNode::Children() const
   431 EXPORT_C const RPointerArray<CComponentInfo::CNode>& CComponentInfo::CNode::Children() const
   293 	{
   432 	{
   294 	return iChildren;
   433 	return iChildren;
   295 	}
   434 	}