ncdengine/provider/server/src/ncdnodecontentinfoimpl.cpp
branchRCL_3
changeset 18 3ba40be8e484
parent 0 ba25891c3a9e
equal deleted inserted replaced
15:51c0f5edf5ef 18:3ba40be8e484
     1 /*
     1 /*
     2 * Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2006-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 "Eclipse Public License v1.0"
     5 * under the terms of "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 "ncdproviderutils.h"
    31 #include "ncdproviderutils.h"
    32 #include "ncdinstallationservice.h"
    32 #include "ncdinstallationservice.h"
    33 #include "ncdpurchasedetails.h"
    33 #include "ncdpurchasedetails.h"
    34 
    34 
    35 #include "catalogsdebug.h"
    35 #include "catalogsdebug.h"
       
    36 #include "catalogsconstants.h"
       
    37 
    36 
    38 
    37 CNcdNodeContentInfo::CNcdNodeContentInfo( NcdNodeClassIds::TNcdNodeClassId aClassId )
    39 CNcdNodeContentInfo::CNcdNodeContentInfo( NcdNodeClassIds::TNcdNodeClassId aClassId )
    38 : CNcdCommunicable(),
    40 : CNcdCommunicable(),
    39   iClassId( aClassId )
    41   iClassId( aClassId )
    40     {
    42     {
    42 
    44 
    43 void CNcdNodeContentInfo::ConstructL()
    45 void CNcdNodeContentInfo::ConstructL()
    44     {
    46     {
    45     iMimeType = KNullDesC().AllocL();
    47     iMimeType = KNullDesC().AllocL();
    46     iVersion = KNullDesC().AllocL();
    48     iVersion = KNullDesC().AllocL();
    47 
    49     iIdentifier = KNullDesC().AllocL();
    48     }
    50     }
    49 
    51 
    50 
    52 
    51 CNcdNodeContentInfo* CNcdNodeContentInfo::NewL()
    53 CNcdNodeContentInfo* CNcdNodeContentInfo::NewL()
    52     {
    54     {
    74     delete iMimeType;
    76     delete iMimeType;
    75     iMimeType = NULL;
    77     iMimeType = NULL;
    76 
    78 
    77     delete iVersion;
    79     delete iVersion;
    78     iVersion = NULL;
    80     iVersion = NULL;
       
    81     
       
    82     delete iIdentifier;
       
    83     iIdentifier = NULL;
    79 
    84 
    80     DLTRACEOUT((""));
    85     DLTRACEOUT((""));
    81     }        
    86     }        
    82 
    87 
    83 NcdNodeClassIds::TNcdNodeClassId CNcdNodeContentInfo::ClassId() const
    88 NcdNodeClassIds::TNcdNodeClassId CNcdNodeContentInfo::ClassId() const
    96     }
   101     }
    97 
   102 
    98 const TUid& CNcdNodeContentInfo::Uid() const
   103 const TUid& CNcdNodeContentInfo::Uid() const
    99     {
   104     {
   100     return iUid;
   105     return iUid;
       
   106     }
       
   107 
       
   108 const TDesC& CNcdNodeContentInfo::Identifier() const
       
   109     {
       
   110     return *iIdentifier;
   101     }
   111     }
   102 
   112 
   103 const TDesC& CNcdNodeContentInfo::Version() const
   113 const TDesC& CNcdNodeContentInfo::Version() const
   104     {
   114     {
   105     return *iVersion;
   115     return *iVersion;
   132 
   142 
   133     delete iMimeType;
   143     delete iMimeType;
   134     iMimeType = NULL;
   144     iMimeType = NULL;
   135 
   145 
   136     iUid = TUid::Null();
   146     iUid = TUid::Null();
   137 
   147     
       
   148     delete iIdentifier;
       
   149     iIdentifier = NULL;
       
   150     iIdentifier = KNullDesC().AllocL();  
       
   151     
   138     delete iVersion;
   152     delete iVersion;
   139     iVersion = NULL;
   153     iVersion = NULL;
   140 
   154 
   141     // Construct purpose.
   155     // Construct purpose.
   142     TInt purposeCount = aData.DownloadableContent()->ContentPurposeCount();
   156     TInt purposeCount = aData.DownloadableContent()->ContentPurposeCount();
   192         else
   206         else
   193             {
   207             {
   194             iPurpose |= ENcdItemPurposeUnknown;
   208             iPurpose |= ENcdItemPurposeUnknown;
   195             }
   209             }
   196         }
   210         }
   197 
       
   198     iMimeType = aData.DownloadableContent()->Mime().AllocL();
   211     iMimeType = aData.DownloadableContent()->Mime().AllocL();
   199 
   212 
   200     if ( iPurpose & ENcdItemPurposeApplication )
   213     if ( iPurpose & ENcdItemPurposeApplication )
   201         {
   214         {
   202         TInt uid = 0;
   215         if ( iMimeType->Compare(KMimeTypeMatchSisx) == 0 )
   203         TRAPD( err, uid = DesHexToIntL( aData.DownloadableContent()->Id() ) );
   216             {
   204         if( err != KErrNone )
   217             // sis package, convert the string to uid
   205             {
   218             TInt uid = 0;
   206             DLERROR(( _L("DownloadableContent()->Id() was not valid hex, using ZERO: %S"),
   219             TRAPD( err, uid = DesHexToIntL( aData.DownloadableContent()->Id() ) );
   207                       &aData.DownloadableContent()->Id() ));
   220             if( err != KErrNone )
   208             iUid.iUid = 0;
   221                 {
   209             }
   222                 DLERROR(( _L("DownloadableContent()->Id() was not valid hex, using ZERO: %S"),
   210         else
   223                            &aData.DownloadableContent()->Id() ));
   211             {
   224                 iUid.iUid = 0;
   212             iUid.iUid = uid;
   225                 }
       
   226             else
       
   227                 {
       
   228                 iUid.iUid = uid;
       
   229                 }
       
   230             }
       
   231          
       
   232         if ( iMimeType->Compare( KMimeTypeMatchWidget ) == 0 )
       
   233             {
       
   234             // widget, save identifier
       
   235             iIdentifier = aData.DownloadableContent()->Id().AllocL();
   213             }
   236             }
   214         }
   237         }
   215 
   238 
   216     iVersion = aData.DownloadableContent()->Version().AllocL();
   239     iVersion = aData.DownloadableContent()->Version().AllocL();
   217     iSize = aData.DownloadableContent()->Size();
   240     iSize = aData.DownloadableContent()->Size();
   228 
   251 
   229     aStream.WriteInt32L( ClassId() );
   252     aStream.WriteInt32L( ClassId() );
   230     
   253     
   231     aStream.WriteUint16L( iPurpose );
   254     aStream.WriteUint16L( iPurpose );
   232     ExternalizeDesL( *iMimeType, aStream );
   255     ExternalizeDesL( *iMimeType, aStream );
   233     aStream.WriteInt32L( iUid.iUid );
   256     
       
   257     // The code here must be sync with the Internalization code in CNcdNodeContentInfoProxy
       
   258     if ( iMimeType->Compare( KMimeTypeMatchWidget ) == 0 )
       
   259         {
       
   260         ExternalizeDesL( *iIdentifier, aStream );
       
   261         }
       
   262     else
       
   263         {
       
   264         aStream.WriteInt32L( iUid.iUid );
       
   265         }
       
   266     
   234     ExternalizeDesL( *iVersion, aStream );
   267     ExternalizeDesL( *iVersion, aStream );
   235     aStream.WriteInt32L( iSize );
   268     aStream.WriteInt32L( iSize );
   236 
   269 
   237     DLTRACEOUT((""));
   270     DLTRACEOUT((""));
   238     }
   271     }
   253         User::Leave( KErrCorrupt );
   286         User::Leave( KErrCorrupt );
   254         }
   287         }
   255     
   288     
   256     iPurpose = aStream.ReadUint16L();
   289     iPurpose = aStream.ReadUint16L();
   257     InternalizeDesL( iMimeType, aStream );
   290     InternalizeDesL( iMimeType, aStream );
   258     iUid.iUid = aStream.ReadInt32L();
   291     
       
   292     // This Internalize function is called when the node is loaded from cache. RReadStream is a sign of that.
       
   293     // So same logic here also. Check mimetype and then decide to save uid or identifier.
       
   294     if ( iMimeType->Compare( KMimeTypeMatchWidget ) == 0  )
       
   295         {
       
   296         InternalizeDesL( iIdentifier, aStream );
       
   297         }
       
   298     else
       
   299         {
       
   300         iUid.iUid = aStream.ReadInt32L();
       
   301         }
       
   302     
   259     InternalizeDesL( iVersion, aStream );
   303     InternalizeDesL( iVersion, aStream );
   260     iSize = aStream.ReadInt32L();
   304     iSize = aStream.ReadInt32L();
   261 
   305 
   262     DLTRACEOUT((""));
   306     DLTRACEOUT((""));
   263     }
   307     }