installationservices/swi/source/uiss/client/nativecomponentinfo.cpp
branchRCL_3
changeset 26 8b7f4e561641
parent 25 7333d7932ef7
equal deleted inserted replaced
25:7333d7932ef7 26:8b7f4e561641
    54 		}
    54 		}
    55 	}
    55 	}
    56 
    56 
    57 namespace Swi
    57 namespace Swi
    58 {
    58 {
    59 
       
    60 CNativeComponentInfo::CNativeApplicationInfo::CNativeApplicationInfo()
       
    61     {
       
    62     }
       
    63 
       
    64 EXPORT_C CNativeComponentInfo::CNativeApplicationInfo::~CNativeApplicationInfo()
       
    65     {
       
    66     delete iName;
       
    67     delete iGroupName;
       
    68     delete iIconFileName;
       
    69     }
       
    70 
       
    71 EXPORT_C CNativeComponentInfo::CNativeApplicationInfo* CNativeComponentInfo::CNativeApplicationInfo::NewLC(const TUid& aAppUid, const TDesC& aName, const TDesC& aGroupName, const TDesC& aIconFileName)
       
    72     {
       
    73         _LIT(emptyString,"");
       
    74         // Leave if aName, aGroupName or aIconFileName exceeds KMaxDescriptorLength
       
    75        if ((&aName != NULL && aName.Length() > KMaxDescriptorLength) || 
       
    76                (&aGroupName != NULL && aGroupName.Length() > KMaxDescriptorLength) ||
       
    77                (&aIconFileName != NULL && aIconFileName.Length() > KMaxDescriptorLength))
       
    78             {
       
    79             User::Leave(KErrOverflow);
       
    80             }
       
    81         
       
    82     CNativeComponentInfo::CNativeApplicationInfo* self = new (ELeave) CNativeComponentInfo::CNativeApplicationInfo();
       
    83         CleanupStack::PushL(self);
       
    84 
       
    85         self->iAppUid = aAppUid;  
       
    86         if(&aName == NULL)
       
    87             {
       
    88             self->iName = emptyString().AllocL();
       
    89             }
       
    90         else
       
    91             {
       
    92             self->iName = aName.AllocL();
       
    93             }
       
    94    
       
    95         if(&aGroupName == NULL)
       
    96             {
       
    97             self->iGroupName = emptyString().AllocL();
       
    98             }
       
    99         else
       
   100             {
       
   101             self->iGroupName = aGroupName.AllocL();
       
   102             }
       
   103         
       
   104         if(&aIconFileName == NULL)
       
   105             {
       
   106             self->iIconFileName = emptyString().AllocL();
       
   107             }
       
   108         else
       
   109             {
       
   110             self->iIconFileName = aIconFileName.AllocL();
       
   111             }
       
   112         
       
   113         return self;
       
   114     }
       
   115 
       
   116 EXPORT_C const TUid& CNativeComponentInfo::CNativeApplicationInfo::AppUid() const
       
   117     {
       
   118     return iAppUid;
       
   119     }
       
   120 
       
   121 EXPORT_C const TDesC& CNativeComponentInfo::CNativeApplicationInfo::Name() const
       
   122     {
       
   123     return *iName;
       
   124     }
       
   125 
       
   126 EXPORT_C const TDesC& CNativeComponentInfo::CNativeApplicationInfo::GroupName() const
       
   127     {
       
   128     return *iGroupName;
       
   129     }
       
   130 
       
   131 EXPORT_C const TDesC& CNativeComponentInfo::CNativeApplicationInfo::IconFileName() const            
       
   132     {
       
   133     return *iIconFileName;
       
   134     }
       
   135 
       
   136 CNativeComponentInfo::CNativeApplicationInfo* CNativeComponentInfo::CNativeApplicationInfo::NewL(RReadStream& aStream)
       
   137     {    
       
   138     CNativeComponentInfo::CNativeApplicationInfo* self = new (ELeave) CNativeComponentInfo::CNativeApplicationInfo();
       
   139     CleanupStack::PushL(self);
       
   140     
       
   141     self->iAppUid = TUid::Uid(aStream.ReadInt32L());
       
   142     self->iName = HBufC::NewL(aStream, KMaxDescriptorLength);
       
   143     self->iGroupName = HBufC::NewL(aStream, KMaxDescriptorLength);
       
   144     self->iIconFileName = HBufC::NewL(aStream, KMaxDescriptorLength);
       
   145     
       
   146     CleanupStack::Pop(self);
       
   147     return self;
       
   148     }
       
   149 
       
   150 void CNativeComponentInfo::CNativeApplicationInfo::ExternalizeL(RWriteStream& aStream) const
       
   151     {
       
   152     aStream.WriteInt32L(iAppUid.iUid);    
       
   153     aStream << *iName;
       
   154     aStream << *iGroupName;
       
   155     aStream << *iIconFileName;
       
   156     }
       
   157 
       
   158 CNativeComponentInfo::CNativeComponentInfo() : iAuthenticity(Usif::ENotAuthenticated)
    59 CNativeComponentInfo::CNativeComponentInfo() : iAuthenticity(Usif::ENotAuthenticated)
   159 	{
    60 	{
   160 	iUserGrantableCaps.SetEmpty();
    61 	iUserGrantableCaps.SetEmpty();
   161 	}
    62 	}
   162 
    63 
   163 EXPORT_C CNativeComponentInfo::~CNativeComponentInfo()
    64 EXPORT_C CNativeComponentInfo::~CNativeComponentInfo()
   164 	{	
    65 	{	
   165 	delete iComponentName;
    66 	delete iComponentName;
   166 	delete iGlobalComponentId;
    67 	delete iGlobalComponentId;
   167 	delete iVersion;
    68 	delete iVersion;
   168 	delete iVendor;		
    69 	delete iVendor;
   169 	iApplications.ResetAndDestroy();
    70 	
   170 	iChildren.Close();
    71 	iChildren.Close();
   171 	}
    72 	}
   172 
    73 
   173 EXPORT_C CNativeComponentInfo* CNativeComponentInfo::NewL()
    74 EXPORT_C CNativeComponentInfo* CNativeComponentInfo::NewL()
   174 	{
    75 	{
   201 	aStream.WriteInt32L(iComponentId);
   102 	aStream.WriteInt32L(iComponentId);
   202 	aStream.WriteInt32L(static_cast<TInt>(iAuthenticity));
   103 	aStream.WriteInt32L(static_cast<TInt>(iAuthenticity));
   203 	aStream.WriteInt32L(PackCapabilitySet(iUserGrantableCaps));
   104 	aStream.WriteInt32L(PackCapabilitySet(iUserGrantableCaps));
   204 	aStream.WriteInt32L(iMaxInstalledSize);
   105 	aStream.WriteInt32L(iMaxInstalledSize);
   205 	aStream.WriteInt32L(iHasExe);
   106 	aStream.WriteInt32L(iHasExe);
   206 	aStream.WriteInt32L(iIsDriveSelectionRequired);
       
   207 	
       
   208 	const TInt numApplications = iApplications.Count();
       
   209 	aStream.WriteInt32L(numApplications);
       
   210 	for (TInt i=0; i<numApplications; ++i)
       
   211 	    {
       
   212 	    iApplications[i]->ExternalizeL(aStream);
       
   213 	    }
       
   214 	
   107 	
   215 	// Recursively internalize all other childrens as well.
   108 	// Recursively internalize all other childrens as well.
   216 	const TInt numChildren = iChildren.Count();
   109 	const TInt numChildren = iChildren.Count();
   217 	aStream.WriteInt32L(numChildren);
   110 	aStream.WriteInt32L(numChildren);
   218 	for (TInt child = 0; child < numChildren; ++child)
   111 	for (TInt child = 0; child < numChildren; ++child)
   256 	iAuthenticity = static_cast<Usif::TAuthenticity>(aStream.ReadInt32L());
   149 	iAuthenticity = static_cast<Usif::TAuthenticity>(aStream.ReadInt32L());
   257 	TInt capsBitMask = aStream.ReadInt32L();
   150 	TInt capsBitMask = aStream.ReadInt32L();
   258 	UnpackCapabilitySet(capsBitMask, iUserGrantableCaps);	
   151 	UnpackCapabilitySet(capsBitMask, iUserGrantableCaps);	
   259 	iMaxInstalledSize = aStream.ReadInt32L();
   152 	iMaxInstalledSize = aStream.ReadInt32L();
   260 	iHasExe = aStream.ReadInt32L();
   153 	iHasExe = aStream.ReadInt32L();
   261 	iIsDriveSelectionRequired = aStream.ReadInt32L();
       
   262 	
       
   263 	const TInt numApplications = aStream.ReadInt32L();
       
   264 	for (TInt i=0; i<numApplications; ++i)
       
   265 	    {
       
   266 	    Swi::CNativeComponentInfo::CNativeApplicationInfo* app =  Swi::CNativeComponentInfo::CNativeApplicationInfo::NewL(aStream);
       
   267 	    CleanupStack::PushL(app);
       
   268 	    iApplications.AppendL(app);
       
   269 	    CleanupStack::Pop(app);
       
   270 	    }
       
   271 	
   154 	
   272 	// Recursively internalize all other childrens as well.
   155 	// Recursively internalize all other childrens as well.
   273 	const TInt numChildren = aStream.ReadInt32L();
   156 	const TInt numChildren = aStream.ReadInt32L();
   274 	for (TInt child = 0; child < numChildren; ++child)
   157 	for (TInt child = 0; child < numChildren; ++child)
   275 		{
   158 		{