installationservices/swinstallationfw/source/sifnotifierdata.cpp
branchRCL_3
changeset 66 8b7f4e561641
parent 65 7333d7932ef7
child 70 e8965914fac7
equal deleted inserted replaced
65:7333d7932ef7 66:8b7f4e561641
     1 /*
       
     2 * Copyright (c) 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 * This file implements the data classes provided by the SifNotifier library
       
    16 *
       
    17 */
       
    18 
       
    19 #include <usif/sif/sifnotification.h> 
       
    20 #include <scs/cleanuputils.h>
       
    21 #include <scs/streamingarray.h>
       
    22 #include "sifnotification_internal.h"
       
    23 #include <usif/sif/sif.h>
       
    24 
       
    25 
       
    26 using namespace Usif;
       
    27 
       
    28 //////////////////////////
       
    29 // CSifOperationStartData
       
    30 //////////////////////////
       
    31 
       
    32 CSifOperationStartData::CSifOperationStartData()
       
    33     {
       
    34     // empty
       
    35     }
       
    36 
       
    37 EXPORT_C CSifOperationStartData::~CSifOperationStartData()
       
    38     {
       
    39     delete iGlobalComponentId;                                    
       
    40     delete iComponentName;
       
    41     delete iComponentIcon;
       
    42     iApplicationNames.ResetAndDestroy();
       
    43     iApplicationIcons.ResetAndDestroy();          
       
    44     delete iIconPath;      
       
    45     delete iSoftwareType;
       
    46     }
       
    47 
       
    48 
       
    49 EXPORT_C CSifOperationStartData* CSifOperationStartData::NewL(RReadStream& aStream)
       
    50     {
       
    51     CSifOperationStartData *self = new(ELeave) CSifOperationStartData();
       
    52     CleanupStack::PushL(self);
       
    53     self->InternalizeL(aStream);
       
    54     CleanupStack::Pop(self);
       
    55     return self;
       
    56     }
       
    57 
       
    58 EXPORT_C CSifOperationStartData* CSifOperationStartData::NewL(const TDesC& aGlobalComponentId, const TDesC& aComponentName,
       
    59                                         const RPointerArray<HBufC>& aApplicationNames, const RPointerArray<HBufC>& aApplicationIcons, 
       
    60                                         TInt aComponentSize, const TDesC& aIconPath, const TDesC& aComponentIcon, const TDesC& aSoftwareType)
       
    61     {
       
    62     return CSifOperationStartData::NewL(aGlobalComponentId, aComponentName, 
       
    63                                         aApplicationNames, aApplicationIcons, aComponentSize, aIconPath, aComponentIcon, aSoftwareType, EInstalling);
       
    64     }
       
    65 
       
    66 EXPORT_C CSifOperationStartData* CSifOperationStartData::NewL(const TDesC& aGlobalComponentId, const TDesC& aComponentName,
       
    67                                         const RPointerArray<HBufC>& aApplicationNames, const RPointerArray<HBufC>& aApplicationIcons, 
       
    68                                         TInt aComponentSize, const TDesC& aIconPath, const TDesC& aComponentIcon, const TDesC& aSoftwareType, 
       
    69                                         TSifOperationPhase aOperationPhase)
       
    70     {
       
    71     CSifOperationStartData *self = CSifOperationStartData::NewLC(aGlobalComponentId, aComponentName, 
       
    72                                         aApplicationNames, aApplicationIcons, aComponentSize, aIconPath, aComponentIcon, aSoftwareType, aOperationPhase);
       
    73     CleanupStack::Pop(self);
       
    74     return self;
       
    75     }
       
    76 
       
    77 
       
    78 EXPORT_C CSifOperationStartData* CSifOperationStartData::NewLC(const TDesC& aGlobalComponentId, const TDesC& aComponentName,
       
    79                                         const RPointerArray<HBufC>& aApplicationNames, const RPointerArray<HBufC>& aApplicationIcons, const TInt aComponentSize, 
       
    80                                         const TDesC& aIconPath, const TDesC& aComponentIcon, const TDesC& aSoftwareType)
       
    81     {
       
    82     return CSifOperationStartData::NewLC(aGlobalComponentId, aComponentName, 
       
    83                                         aApplicationNames, aApplicationIcons, aComponentSize, aIconPath, aComponentIcon, aSoftwareType, EInstalling);
       
    84     }
       
    85 
       
    86 EXPORT_C CSifOperationStartData* CSifOperationStartData::NewLC(const TDesC& aGlobalComponentId, const TDesC& aComponentName,
       
    87 										const RPointerArray<HBufC>& aApplicationNames, const RPointerArray<HBufC>& aApplicationIcons, const TInt aComponentSize, 
       
    88                                         const TDesC& aIconPath, const TDesC& aComponentIcon, const TDesC& aSoftwareType, TSifOperationPhase aOperationPhase)
       
    89     {
       
    90     CSifOperationStartData *self = new(ELeave) CSifOperationStartData();
       
    91     CleanupStack::PushL(self);
       
    92     self->ConstructL(aGlobalComponentId, aComponentName, aApplicationNames, aApplicationIcons, aComponentSize, aIconPath, aComponentIcon, aSoftwareType, aOperationPhase);
       
    93     return self;
       
    94     }
       
    95 
       
    96 void CSifOperationStartData::ConstructL(const TDesC& aGlobalComponentId, const TDesC& aComponentName, const RPointerArray<HBufC>& aApplicationNames,
       
    97                                         const RPointerArray<HBufC>& aApplicationIcons, TInt aComponentSize, const TDesC& aIconPath, const TDesC& aComponentIcon, 
       
    98                                         const TDesC& aSoftwareType, TSifOperationPhase aOperationPhase)
       
    99     {
       
   100 	iGlobalComponentId = aGlobalComponentId.AllocL();
       
   101     iComponentName = aComponentName.AllocL();
       
   102     iComponentIcon = aComponentIcon.AllocL();
       
   103 
       
   104     for(TInt i=0; i<aApplicationNames.Count();++i)
       
   105         {
       
   106         HBufC* applicationName = aApplicationNames[i]->AllocLC();
       
   107         iApplicationNames.AppendL(applicationName);
       
   108         CleanupStack::Pop(applicationName);
       
   109         }
       
   110 
       
   111     for(TInt i=0; i<aApplicationIcons.Count();++i)
       
   112         {
       
   113         HBufC* applicationIcon = aApplicationIcons[i]->AllocLC();
       
   114         iApplicationIcons.AppendL(applicationIcon);
       
   115         CleanupStack::Pop(applicationIcon);
       
   116         }
       
   117     
       
   118     iComponentSize = aComponentSize;
       
   119     iIconPath = aIconPath.AllocL();      
       
   120     iSoftwareType = aSoftwareType.AllocL();
       
   121     iOperationPhase = aOperationPhase;
       
   122     }
       
   123 
       
   124 EXPORT_C void CSifOperationStartData::ExternalizeL(RWriteStream& aStream) const
       
   125 	{
       
   126 	aStream.WriteUint32L(ESifOperationStart);
       
   127 	aStream << *iGlobalComponentId;
       
   128 	aStream << *iComponentName;
       
   129 	ExternalizePointersArrayL(iApplicationNames, aStream);
       
   130 	ExternalizePointersArrayL(iApplicationIcons, aStream);
       
   131 	aStream.WriteUint16L(iComponentSize);
       
   132 	aStream << *iIconPath;
       
   133 	aStream << *iComponentIcon;
       
   134 	aStream << *iSoftwareType;
       
   135 	aStream << TCardinality(iOperationPhase);
       
   136 	}
       
   137 	
       
   138 void CSifOperationStartData::InternalizeL(RReadStream& aStream)
       
   139     {
       
   140     iOperationType = static_cast<TSifOperation>(aStream.ReadUint32L());
       
   141     DeleteObjectZ(iGlobalComponentId);
       
   142     iGlobalComponentId = HBufC::NewL(aStream, KMaxTInt);
       
   143     DeleteObjectZ(iComponentName);
       
   144     iComponentName = HBufC::NewL(aStream, KMaxTInt);
       
   145     iApplicationNames.ResetAndDestroy();
       
   146     InternalizePointersArrayL(iApplicationNames, aStream);
       
   147     iApplicationIcons.ResetAndDestroy();
       
   148     InternalizePointersArrayL(iApplicationIcons, aStream);
       
   149     iComponentSize = aStream.ReadUint16L();
       
   150     DeleteObjectZ(iIconPath);
       
   151     iIconPath = HBufC::NewL(aStream, KMaxTInt);
       
   152     DeleteObjectZ(iComponentIcon);
       
   153     iComponentIcon = HBufC::NewL(aStream, KMaxTInt);
       
   154     DeleteObjectZ(iSoftwareType);
       
   155     iSoftwareType = HBufC::NewL(aStream, KMaxTInt);
       
   156     TCardinality c;
       
   157     aStream >> c;
       
   158     iOperationPhase = static_cast<TSifOperationPhase>(static_cast<TInt>(c));
       
   159     }
       
   160 
       
   161 EXPORT_C const HBufC& CSifOperationStartData::GlobalComponentId() const
       
   162     {
       
   163     return *iGlobalComponentId;
       
   164     }
       
   165 
       
   166 EXPORT_C const HBufC& CSifOperationStartData::ComponentName() const
       
   167     {
       
   168     return *iComponentName;
       
   169     }
       
   170 
       
   171 EXPORT_C const RPointerArray<HBufC>& CSifOperationStartData::ApplicationNames() const
       
   172     {
       
   173     return iApplicationNames;
       
   174     }
       
   175 
       
   176 EXPORT_C const RPointerArray<HBufC>& CSifOperationStartData::ApplicationIcons() const
       
   177     {
       
   178     return iApplicationIcons;
       
   179     }
       
   180 
       
   181 EXPORT_C const HBufC& CSifOperationStartData::IconPath() const
       
   182     {
       
   183     return *iIconPath;
       
   184     }
       
   185 
       
   186 EXPORT_C const HBufC& CSifOperationStartData::ComponentIcon() const
       
   187     {
       
   188     return *iComponentIcon;
       
   189     }
       
   190 
       
   191 EXPORT_C const HBufC& CSifOperationStartData::SoftwareType() const
       
   192     {
       
   193     return *iSoftwareType;
       
   194     }
       
   195 
       
   196 
       
   197 EXPORT_C TInt CSifOperationStartData::ComponentSize() const
       
   198     {
       
   199     return iComponentSize;
       
   200     }
       
   201 
       
   202 EXPORT_C TSifOperationPhase CSifOperationStartData::OperationPhase() const
       
   203     {
       
   204     return iOperationPhase;
       
   205     }
       
   206 
       
   207 ////////////////////////
       
   208 // CSifOperationEndData
       
   209 ////////////////////////
       
   210 
       
   211 CSifOperationEndData::CSifOperationEndData()
       
   212     {
       
   213     // empty
       
   214     }
       
   215 
       
   216 EXPORT_C CSifOperationEndData::~CSifOperationEndData()
       
   217     {
       
   218     delete iGlobalComponentId;
       
   219     delete iErrMsg;                                    
       
   220     delete iErrMsgDetails;
       
   221     }
       
   222 
       
   223 
       
   224 EXPORT_C CSifOperationEndData* CSifOperationEndData::NewL(RReadStream& aStream)
       
   225     {
       
   226     CSifOperationEndData *self = new(ELeave) CSifOperationEndData();
       
   227     CleanupStack::PushL(self);
       
   228     self->InternalizeL(aStream);
       
   229     CleanupStack::Pop(self);
       
   230     return self;
       
   231     }
       
   232 
       
   233 EXPORT_C CSifOperationEndData* CSifOperationEndData::NewL(const TDesC& aGlobalComponentId, TErrorCategory aErrCategory, TInt aErrCode, const TDesC& aErrMsg, const TDesC& aErrMsgDetails)
       
   234     {
       
   235     CSifOperationEndData *self = CSifOperationEndData::NewLC(aGlobalComponentId, aErrCategory, aErrCode, aErrMsg, aErrMsgDetails);
       
   236     CleanupStack::Pop(self);
       
   237     return self;
       
   238     }
       
   239 
       
   240 EXPORT_C CSifOperationEndData* CSifOperationEndData::NewLC(const TDesC& aGlobalComponentId, TErrorCategory aErrCategory, TInt aErrCode, const TDesC& aErrMsg, const TDesC& aErrMsgDetails)
       
   241     {
       
   242     CSifOperationEndData *self = new(ELeave) CSifOperationEndData();
       
   243     CleanupStack::PushL(self);
       
   244     self->ConstructL(aGlobalComponentId, aErrCategory, aErrCode, aErrMsg, aErrMsgDetails);
       
   245     return self;
       
   246     }
       
   247 
       
   248 void CSifOperationEndData::ConstructL(const TDesC& aGlobalComponentId, TErrorCategory aErrCategory, TInt aErrCode, const TDesC& aErrMsg, const TDesC& aErrMsgDetails)
       
   249     {
       
   250 	iGlobalComponentId = aGlobalComponentId.AllocL();      
       
   251     iErrCategory = aErrCategory;
       
   252     iErrCode = aErrCode;
       
   253     iErrMsg = aErrMsg.AllocL();
       
   254     iErrMsgDetails = aErrMsgDetails.AllocL();
       
   255     }
       
   256 
       
   257 EXPORT_C void CSifOperationEndData::ExternalizeL(RWriteStream& aStream) const
       
   258     {
       
   259 	aStream.WriteUint32L(ESifOperationEnd);
       
   260     aStream << *iGlobalComponentId;
       
   261     aStream << TCardinality(iErrCategory);
       
   262     aStream.WriteUint16L(iErrCode);
       
   263     aStream << *iErrMsg;
       
   264     aStream << *iErrMsgDetails;
       
   265     }
       
   266     
       
   267 void CSifOperationEndData::InternalizeL(RReadStream& aStream)
       
   268     {
       
   269     iOperationType = static_cast<TSifOperation>(aStream.ReadUint32L());
       
   270     iGlobalComponentId = HBufC::NewL(aStream, KMaxTInt);
       
   271     TCardinality c;
       
   272     aStream >> c;
       
   273 	iErrCategory = static_cast<TErrorCategory>(static_cast<TInt>(c));
       
   274     iErrCode = aStream.ReadUint16L();
       
   275     DeleteObjectZ(iErrMsg);
       
   276     iErrMsg = HBufC::NewL(aStream, KMaxTInt);
       
   277     DeleteObjectZ(iErrMsgDetails);
       
   278     iErrMsgDetails = HBufC::NewL(aStream, KMaxTInt);
       
   279     }
       
   280 
       
   281 EXPORT_C const HBufC& CSifOperationEndData::GlobalComponentId() const
       
   282     {
       
   283     return *iGlobalComponentId;
       
   284     }
       
   285 
       
   286 EXPORT_C TErrorCategory CSifOperationEndData::ErrorCategory() const
       
   287     {
       
   288     return iErrCategory;
       
   289     }
       
   290 
       
   291 EXPORT_C TInt CSifOperationEndData::ErrorCode() const
       
   292     {
       
   293     return iErrCode;
       
   294     }
       
   295 
       
   296 EXPORT_C const HBufC& CSifOperationEndData::ErrorMessage() const
       
   297     {
       
   298     return *iErrMsg;
       
   299     }
       
   300 
       
   301 EXPORT_C const HBufC& CSifOperationEndData::ErrorMessageDetails() const
       
   302     {
       
   303     return *iErrMsgDetails;
       
   304     }
       
   305 
       
   306 /////////////////////////////
       
   307 // CSifOperationProgressData
       
   308 /////////////////////////////
       
   309 
       
   310 CSifOperationProgressData::CSifOperationProgressData()
       
   311     {
       
   312     // empty
       
   313     }
       
   314 
       
   315 
       
   316 EXPORT_C CSifOperationProgressData* CSifOperationProgressData::NewL(RReadStream& aStream)
       
   317     {
       
   318     CSifOperationProgressData *self = new(ELeave) CSifOperationProgressData();
       
   319     CleanupStack::PushL(self);
       
   320     self->InternalizeL(aStream);
       
   321     CleanupStack::Pop(self);
       
   322     return self;
       
   323     }
       
   324 
       
   325 EXPORT_C CSifOperationProgressData* CSifOperationProgressData::NewL(const TDesC& aGlobalComponentId, TSifOperationPhase aPhase, TSifOperationSubPhase aSubPhase, TInt aCurrentProgress, TInt aTotal)
       
   326     {
       
   327     CSifOperationProgressData *self = CSifOperationProgressData::NewLC(aGlobalComponentId, aPhase, aSubPhase, aCurrentProgress, aTotal);
       
   328     CleanupStack::Pop(self);
       
   329     return self;
       
   330     }
       
   331 
       
   332 EXPORT_C CSifOperationProgressData* CSifOperationProgressData::NewLC(const TDesC& aGlobalComponentId, TSifOperationPhase aPhase, TSifOperationSubPhase aSubPhase, TInt aCurrentProgress, TInt aTotal)
       
   333     {
       
   334     CSifOperationProgressData *self = new(ELeave) CSifOperationProgressData();
       
   335     CleanupStack::PushL(self);
       
   336     self->ConstructL(aGlobalComponentId, aPhase, aSubPhase, aCurrentProgress, aTotal);
       
   337     return self;
       
   338     }
       
   339 
       
   340 void CSifOperationProgressData::ConstructL(const TDesC& aGlobalComponentId, TSifOperationPhase aPhase, TSifOperationSubPhase aSubPhase, TInt aCurrentProgress, TInt aTotal)
       
   341     {
       
   342     iGlobalComponentId = aGlobalComponentId.AllocL();      
       
   343     iPhase = aPhase;
       
   344     iSubPhase = aSubPhase;
       
   345     iCurrentProgress = aCurrentProgress;
       
   346     iTotal = aTotal;
       
   347     }
       
   348 
       
   349 EXPORT_C void CSifOperationProgressData::ExternalizeL(RWriteStream& aStream) const
       
   350     {
       
   351     aStream << *iGlobalComponentId;
       
   352     aStream << TCardinality(iPhase);
       
   353     aStream << TCardinality(iSubPhase);
       
   354     aStream.WriteUint16L(iCurrentProgress);
       
   355     aStream.WriteUint16L(iTotal);
       
   356     }
       
   357     
       
   358 void CSifOperationProgressData::InternalizeL(RReadStream& aStream)
       
   359     {
       
   360     iGlobalComponentId = HBufC::NewL(aStream, KMaxTInt);
       
   361     TCardinality c;
       
   362     aStream >> c;
       
   363     iPhase = static_cast<TSifOperationPhase>(static_cast<TInt>(c));
       
   364     aStream >> c;
       
   365     iSubPhase = static_cast<TSifOperationSubPhase>(static_cast<TInt>(c));
       
   366     iCurrentProgress = aStream.ReadUint16L();
       
   367     iTotal = aStream.ReadUint16L();
       
   368     }
       
   369 
       
   370 EXPORT_C const HBufC& CSifOperationProgressData::GlobalComponentId() const
       
   371     {
       
   372     return *iGlobalComponentId;
       
   373     }
       
   374 
       
   375 EXPORT_C TSifOperationPhase CSifOperationProgressData::Phase() const
       
   376     {
       
   377     return iPhase;
       
   378     }
       
   379 
       
   380 EXPORT_C TSifOperationSubPhase CSifOperationProgressData::SubPhase() const
       
   381     {
       
   382     return iSubPhase;
       
   383     }
       
   384 
       
   385 EXPORT_C TInt CSifOperationProgressData::CurrentProgress() const
       
   386     {
       
   387     return iCurrentProgress;
       
   388     }
       
   389 
       
   390 EXPORT_C TInt CSifOperationProgressData::CurrentProgess() const
       
   391     {
       
   392     return CurrentProgress();
       
   393     }
       
   394 
       
   395 EXPORT_C TInt CSifOperationProgressData::Total() const
       
   396     {
       
   397     return iTotal;
       
   398     }
       
   399 
       
   400 
       
   401 EXPORT_C CSifOperationProgressData::~CSifOperationProgressData()
       
   402     {
       
   403     delete iGlobalComponentId;
       
   404     }