ncdengine/provider/client/src/ncdnodemetadataproxy.cpp
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2006 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 "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:   Contains CNcdNodeMetadataProxy class implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ncdnodemetadataproxy.h"
       
    20 #include "ncdnodeproxy.h"
       
    21 #include "ncdnodemanagerproxy.h"
       
    22 #include "ncdnodedisclaimerproxy.h"
       
    23 #include "ncdnodedownloadproxy.h"
       
    24 #include "ncdnodeiconproxy.h"
       
    25 #include "ncdnodescreenshotproxy.h"
       
    26 #include "ncdnodepurchaseproxy.h"
       
    27 #include "ncdnodeuricontentproxy.h"
       
    28 #include "ncdnodecontentinfoproxy.h"
       
    29 #include "ncdnodeinstallproxy.h"
       
    30 #include "ncdnodeactivateimpl.h"
       
    31 #include "ncdnodepreviewproxy.h"
       
    32 #include "ncdnodeupgradeproxy.h"
       
    33 #include "ncdnodedependencyproxy.h"
       
    34 #include "ncdnodeskinproxy.h"
       
    35 #include "catalogsclientserver.h"
       
    36 #include "ncdnodeidentifier.h"
       
    37 #include "ncdnodefunctionids.h"
       
    38 #include "ncdnodeclassids.h"
       
    39 #include "ncdnodeuserdataproxy.h"
       
    40 #include "catalogsinterfaceidentifier.h"
       
    41 #include "catalogsdebug.h"
       
    42 #include "catalogsutils.h"
       
    43 #include "ncdutils.h"
       
    44 #include "ncderrors.h"
       
    45 
       
    46 
       
    47 // ======== PUBLIC MEMBER FUNCTIONS ========
       
    48 
       
    49 CNcdNodeMetadataProxy::CNcdNodeMetadataProxy( MCatalogsClientServer& aSession,
       
    50                                               TInt aHandle,
       
    51                                               CNcdNodeProxy& aNode ) 
       
    52 : CNcdInterfaceBaseProxy( aSession, aHandle, &aNode ),
       
    53   iNode( aNode )
       
    54     {
       
    55     }
       
    56 
       
    57 
       
    58 void CNcdNodeMetadataProxy::ConstructL()
       
    59     {
       
    60     // Register the interface
       
    61     MNcdNodeMetadata* metadata( this );
       
    62     DLTRACE(("Metadata-ptr: %X, this: %X", metadata, this));
       
    63     AddInterfaceL( 
       
    64         CCatalogsInterfaceIdentifier::NewL( metadata, this, MNcdNodeMetadata::KInterfaceUid ) );
       
    65     
       
    66     InternalizeL();
       
    67     }
       
    68 
       
    69 
       
    70 CNcdNodeMetadataProxy* CNcdNodeMetadataProxy::NewL( MCatalogsClientServer& aSession,
       
    71                                                     TInt aHandle,
       
    72                                                     CNcdNodeProxy& aNode )
       
    73     {
       
    74     CNcdNodeMetadataProxy* self = 
       
    75         CNcdNodeMetadataProxy::NewLC( aSession, aHandle, aNode );
       
    76     CleanupStack::Pop( self );
       
    77     return self;
       
    78     }
       
    79 
       
    80 CNcdNodeMetadataProxy* CNcdNodeMetadataProxy::NewLC( MCatalogsClientServer& aSession,
       
    81                                                      TInt aHandle,
       
    82                                                      CNcdNodeProxy& aNode )
       
    83     {
       
    84     CNcdNodeMetadataProxy* self = 
       
    85         new( ELeave ) CNcdNodeMetadataProxy( aSession, aHandle, aNode );
       
    86     // Using PushL because the object does not have any references yet
       
    87     CleanupStack::PushL( self );
       
    88     self->ConstructL();
       
    89     return self;
       
    90     }
       
    91 
       
    92 
       
    93 CNcdNodeMetadataProxy::~CNcdNodeMetadataProxy()
       
    94     {
       
    95     DLTRACEIN(("Metadata: %X", this));
       
    96     // Remove interfaces implemented by this class from the interface list.
       
    97     // So, the interface list is up to date when this class object is deleted.
       
    98     RemoveInterface( MNcdNodeMetadata::KInterfaceUid );
       
    99     
       
   100     // Do not delete parent node. It is just a reference to the parent and the
       
   101     // parent owns this metadata, not vice versa.
       
   102 
       
   103     delete iIdentifier;
       
   104     iIdentifier = NULL;
       
   105     
       
   106     delete iName;
       
   107     iName = NULL;
       
   108     
       
   109     delete iDescription;
       
   110     iDescription = NULL;
       
   111     
       
   112     delete iLayoutType;
       
   113     iLayoutType = NULL;
       
   114     
       
   115     delete iActionName;
       
   116     iActionName = NULL;
       
   117 
       
   118 
       
   119     // Delete the objects that are owned by this class and provide functionality
       
   120     // through the api.
       
   121     // Notice that the api-objects are Released (not deleted) from the UI side.
       
   122     // This object owns the data and the reference counter of this object keeps
       
   123     // track of the api objects it owns. When the reference counter of this object
       
   124     // reaches zero, it means that nobody is using this object or the classes owned
       
   125     // by this object. If somebody is using the object owned by this object, 
       
   126     // the reference counter can not be zero until everything is released.
       
   127     // Thus, this object may delete the data here.
       
   128 
       
   129     delete iDisclaimer;
       
   130     iDisclaimer = NULL;
       
   131 
       
   132     DLTRACE(("Deleting iMoreInfo")); 
       
   133     delete iMoreInfo;
       
   134     iMoreInfo = NULL;
       
   135 
       
   136     DLTRACE(("Deleting iUserData")); 
       
   137     delete iUserData;
       
   138     iUserData = NULL;
       
   139 
       
   140     DLTRACE(("Deleting iDownload")); 
       
   141     delete iDownload;
       
   142     iDownload = NULL;
       
   143 
       
   144     DLTRACE(("Deleting iIcon")); 
       
   145     delete iIcon;
       
   146     iIcon = NULL;
       
   147 
       
   148     DLTRACE(("Deleting iScreenshot")); 
       
   149     delete iScreenshot;
       
   150     iScreenshot = NULL;
       
   151 
       
   152     DLTRACE(("Deleting iPurchase")); 
       
   153     delete iPurchase;
       
   154     iPurchase = NULL;
       
   155 
       
   156     DLTRACE(("Deleting iUriContent")); 
       
   157     delete iUriContent;
       
   158     iUriContent = NULL;
       
   159     
       
   160     DLTRACE(("Deleting iContentInfo")); 
       
   161     delete iContentInfo;
       
   162     iContentInfo = NULL;
       
   163     
       
   164     DLTRACE(("Delete install"));
       
   165     delete iInstall;
       
   166     iInstall = NULL;
       
   167 
       
   168     DLTRACE(("Deleting iPreview")); 
       
   169     delete iPreview;
       
   170     iPreview = NULL;
       
   171 
       
   172     DLTRACE(("Deleting iUpgrade")); 
       
   173     delete iUpgrade;
       
   174     iUpgrade = NULL;
       
   175 
       
   176     DLTRACE(("Deleting iDependency")); 
       
   177     delete iDependency;
       
   178     iDependency = NULL;
       
   179     
       
   180     DLTRACE(("Deleting iSkin")); 
       
   181     delete iSkin;
       
   182     iSkin = NULL;
       
   183 
       
   184     DLTRACE(("Deleting iActivate")); 
       
   185     delete iActivate;
       
   186     iActivate = NULL;
       
   187     
       
   188     DLTRACE(("Deleting iDetails"));    
       
   189     iDetails.ResetAndDestroy();    
       
   190     DLTRACEOUT(( "Metadata deleted, this: %x", this ));
       
   191     }
       
   192 
       
   193 CNcdNodeIdentifier& CNcdNodeMetadataProxy::Identifier() const
       
   194     {
       
   195     return *iIdentifier;    
       
   196     }
       
   197 
       
   198 CNcdNodeProxy& CNcdNodeMetadataProxy::Node() const
       
   199     {
       
   200     return iNode;
       
   201     }
       
   202 
       
   203 CNcdNodeDownloadProxy* CNcdNodeMetadataProxy::Download() const
       
   204     {
       
   205     return iDownload;
       
   206     }
       
   207 
       
   208 
       
   209 CNcdNodeInstallProxy* CNcdNodeMetadataProxy::Install() const
       
   210     {
       
   211     return iInstall;
       
   212     }
       
   213 
       
   214 
       
   215 CNcdNodeUriContentProxy* CNcdNodeMetadataProxy::UriContent() const
       
   216     {
       
   217     return iUriContent;
       
   218     }
       
   219 
       
   220 
       
   221 CNcdNodeContentInfoProxy* CNcdNodeMetadataProxy::ContentInfo() const
       
   222     {
       
   223     return iContentInfo;
       
   224     }
       
   225 
       
   226 
       
   227 void CNcdNodeMetadataProxy::InternalizeL()
       
   228     {
       
   229     DLTRACEIN(("Metadata: %X", this));
       
   230 
       
   231     HBufC8* data( NULL );
       
   232         
       
   233     // Because we do not know the exact size of the data id, use
       
   234     // the alloc method, which creates the buffer of the right size
       
   235     // and sets the pointer to point to the created buffer.
       
   236     User::LeaveIfError(
       
   237             ClientServerSession().
       
   238                 SendSyncAlloc( NcdNodeFunctionIds::ENcdInternalize,
       
   239                                KNullDesC8,
       
   240                                data,
       
   241                                Handle(),
       
   242                                0 ) );
       
   243 
       
   244     if ( data == NULL )
       
   245         {
       
   246         User::Leave( KErrNotFound );
       
   247         }
       
   248 
       
   249     CleanupStack::PushL( data );
       
   250 
       
   251 
       
   252     // Read the data from the stream and insert it to the memeber variables
       
   253     RDesReadStream stream( *data );
       
   254     CleanupClosePushL( stream );
       
   255     
       
   256     InternalizeDataL( stream );
       
   257     
       
   258     // Closes the stream
       
   259     CleanupStack::PopAndDestroy( &stream ); 
       
   260     CleanupStack::PopAndDestroy( data );
       
   261 
       
   262     // These functions internalize objects that may exist
       
   263     // in the server side metadata.
       
   264     
       
   265     // The node should always contain user data object.
       
   266     DLINFO(("Internalize user data"));
       
   267     TRAP_IGNORE( InternalizeUserDataL() );    
       
   268     
       
   269     DLINFO(("Internalize icon"));
       
   270     TRAP_IGNORE( InternalizeIconL() );
       
   271 
       
   272     DLINFO(("Internalize content info"));    
       
   273     TRAP_IGNORE( InternalizeContentInfoL() );
       
   274 
       
   275     DLINFO(("Internalize upgrade target info"));
       
   276     TRAP_IGNORE( InternalizeUpgradeL() );
       
   277 
       
   278     DLINFO(("Internalize dependency target info"));
       
   279     TRAP_IGNORE( InternalizeDependencyL() );
       
   280 
       
   281     DLINFO(("Internalize preview"));    
       
   282     TRAP_IGNORE( InternalizePreviewL() );
       
   283 
       
   284     DLINFO(("Internalize node purchase"));    
       
   285     TRAP_IGNORE( InternalizePurchaseL() );
       
   286        
       
   287     DLINFO(("Internalize uri content"));    
       
   288     TRAP_IGNORE( InternalizeUriContentL() );
       
   289 
       
   290     DLINFO(("Internalize download"));
       
   291     TRAP_IGNORE( InternalizeDownloadL() );
       
   292 
       
   293     DLINFO(("Internalize install"));    
       
   294     TRAP_IGNORE( InternalizeInstallL() );
       
   295 
       
   296     DLINFO(("Internalize skin"));
       
   297     TRAP_IGNORE( InternalizeSkinL() );
       
   298 
       
   299     // Activate can exist only after install info has been gotten.
       
   300     DLINFO(("Internalize activate"));    
       
   301     TRAP_IGNORE( InternalizeActivateL() );    
       
   302 
       
   303     DLINFO(("Internalize screenshot"));
       
   304     TRAPD( err, InternalizeScreenshotL() );
       
   305     
       
   306     // Ignore errors caused by obsolete screenshot
       
   307     LeaveIfNotErrorL( err, KNcdErrorObsolete );
       
   308     
       
   309     DLTRACEOUT((""));    
       
   310     }
       
   311 
       
   312 
       
   313 // MNcdNodeMetaData functions
       
   314 
       
   315 const TDesC& CNcdNodeMetadataProxy::Id() const
       
   316     {
       
   317     return iIdentifier->NodeId();
       
   318     }
       
   319     
       
   320 const TDesC& CNcdNodeMetadataProxy::Namespace() const
       
   321     {
       
   322     return iIdentifier->NodeNameSpace();
       
   323     }
       
   324 
       
   325     
       
   326 const TDesC& CNcdNodeMetadataProxy::Name() const
       
   327     {
       
   328     DLTRACEIN(("Metadata: %X", this));
       
   329     DASSERT( iName );
       
   330     DLINFO(( _L("Name: %S, length: %d"), iName, 
       
   331         iName->Length() ));
       
   332     return *iName;
       
   333     }
       
   334 
       
   335 
       
   336 const TDesC& CNcdNodeMetadataProxy::Description() const
       
   337     {
       
   338     DLTRACEIN(("Metadata: %X", this));
       
   339     DASSERT( iDescription );
       
   340     DLINFO(( _L("Description: %S, length: %d"), iDescription,
       
   341         iDescription->Length() ));
       
   342     return *iDescription;
       
   343     }
       
   344     
       
   345 MNcdQuery* CNcdNodeMetadataProxy::Disclaimer() const
       
   346     {
       
   347     DLTRACEIN(("TotalRefCount: %d", TotalRefCount()));
       
   348     if( iDisclaimer != NULL )
       
   349         {
       
   350         iDisclaimer->AddRef();
       
   351         }
       
   352         
       
   353     DLTRACEOUT((""));
       
   354     return iDisclaimer;        
       
   355     }
       
   356     
       
   357 MNcdQuery* CNcdNodeMetadataProxy::MoreInfo() const
       
   358     {
       
   359     DLTRACEIN(("TotalRefCount: %d", TotalRefCount()));
       
   360     if( iMoreInfo != NULL )
       
   361         {
       
   362         iMoreInfo->AddRef();
       
   363         }
       
   364         
       
   365     DLTRACEOUT((""));
       
   366     return iMoreInfo;        
       
   367     }
       
   368     
       
   369 const RPointerArray<CNcdKeyValuePair>&
       
   370     CNcdNodeMetadataProxy::Details() const
       
   371     {
       
   372     DLTRACEIN((""));
       
   373     return iDetails;
       
   374     }
       
   375     
       
   376 const TDesC& CNcdNodeMetadataProxy::ActionName() const
       
   377     {
       
   378     return *iActionName;    
       
   379     }
       
   380 
       
   381 
       
   382 TBool CNcdNodeMetadataProxy::IsAlwaysVisible() const
       
   383     {
       
   384     DLTRACEIN((("isAlwaysVisible: %d"), iIsAlwaysVisible ))
       
   385     return iIsAlwaysVisible;
       
   386     }
       
   387     
       
   388 const TDesC& CNcdNodeMetadataProxy::LayoutType() const 
       
   389     {
       
   390     return *iLayoutType;
       
   391     }
       
   392 
       
   393 
       
   394 void CNcdNodeMetadataProxy::InternalizeDataL( RReadStream& aStream )
       
   395     {
       
   396     DLTRACEIN(("Metadata: %X", this));
       
   397 
       
   398     CNcdNodeIdentifier* tmpIdentifier( NULL );
       
   399     HBufC* tmpName( NULL );
       
   400     HBufC* tmpDescription( NULL );
       
   401     HBufC* tmpActionName( NULL );
       
   402     HBufC* tmpLayoutType( NULL );
       
   403     TBool tmpAlwaysVisible( EFalse );
       
   404     RPointerArray<CNcdKeyValuePair> details;
       
   405     CleanupResetAndDestroyPushL( details );
       
   406 
       
   407     // Get the id for the metadata class 
       
   408     TInt classId = aStream.ReadInt32L();
       
   409 
       
   410     if( classId != NcdNodeClassIds::ENcdNullObjectClassId )
       
   411         {
       
   412         DLINFO(("Metadata exists"));
       
   413         
       
   414         tmpIdentifier = CNcdNodeIdentifier::NewLC( aStream );
       
   415         
       
   416         InternalizeDesL( tmpName, aStream );
       
   417         CleanupStack::PushL( tmpName );
       
   418 
       
   419         InternalizeDesL( tmpDescription, aStream );
       
   420         CleanupStack::PushL( tmpDescription );
       
   421         
       
   422         InternalizeDesL( tmpLayoutType, aStream );
       
   423         CleanupStack::PushL( tmpLayoutType );
       
   424         
       
   425         tmpAlwaysVisible = aStream.ReadInt8L();
       
   426         
       
   427         TInt32 detailCount = aStream.ReadInt32L();
       
   428         for( TInt i = 0 ; i < detailCount ; i++ )
       
   429             {
       
   430             CNcdKeyValuePair* detail = CNcdKeyValuePair::NewLC( aStream );
       
   431             DLTRACE(( _L("Detail id=%S, value=%S"),
       
   432                 &detail->Key() , &detail->Value() ));
       
   433             details.AppendL( detail );
       
   434             CleanupStack::Pop( detail );
       
   435             }
       
   436 
       
   437         // What is this?
       
   438         tmpActionName = KNullDesC().AllocLC();
       
   439 
       
   440         InternalizeDisclaimerL();
       
   441         InternalizeMoreInfoL();
       
   442         }
       
   443     else
       
   444         {
       
   445         DLINFO(("No meta data"));
       
   446 
       
   447         // Metadata has been created. But, during the internalization we found that it
       
   448         // does not actually exist in the server side. Maybe it has been removed.
       
   449         // Thus, leave here with KErrNotFound. So, metadata can be removed by the owner.
       
   450         User::Leave( KErrNotFound );
       
   451         }
       
   452 
       
   453     // Finally it is safe to insert data to the member variables
       
   454 
       
   455     delete iActionName;
       
   456     iActionName = tmpActionName;
       
   457     CleanupStack::Pop( tmpActionName );
       
   458 
       
   459     delete iLayoutType;
       
   460     iLayoutType = tmpLayoutType;
       
   461     CleanupStack::Pop( tmpLayoutType );
       
   462 
       
   463     delete iDescription;
       
   464     iDescription = tmpDescription;
       
   465     CleanupStack::Pop( tmpDescription );
       
   466         
       
   467     delete iName;
       
   468     iName = tmpName;
       
   469     CleanupStack::Pop( tmpName );
       
   470 
       
   471     delete iIdentifier;
       
   472     iIdentifier = tmpIdentifier;
       
   473     CleanupStack::Pop( tmpIdentifier );
       
   474     
       
   475     iIsAlwaysVisible = tmpAlwaysVisible;  
       
   476     
       
   477     CleanupStack::Pop( &details );
       
   478     iDetails.ResetAndDestroy();
       
   479     
       
   480     // Ownership of the array items is "transferred" to iDetails.
       
   481     iDetails = details;    
       
   482 
       
   483     DLTRACEOUT((""));
       
   484     }
       
   485 
       
   486 
       
   487 void CNcdNodeMetadataProxy::InternalizeUserDataL()
       
   488     {
       
   489     DLTRACEIN((""));
       
   490 
       
   491     // Get the handle for the link data
       
   492     if ( iUserData == NULL )
       
   493         {
       
   494         DLINFO(("User data was not set. Set it now."));
       
   495         TInt userDataHandle( 0 );
       
   496         
       
   497         User::LeaveIfError(
       
   498                 ClientServerSession().
       
   499                     SendSync( NcdNodeFunctionIds::ENcdUserDataHandle,
       
   500                               KNullDesC,
       
   501                               userDataHandle,
       
   502                               Handle() ) );    
       
   503         DLINFO(("Handle: %i", userDataHandle));
       
   504 
       
   505         // Now we can create the user data object
       
   506         // Notice that this object will add its own interfaces to the
       
   507         // querylist when the object is created.
       
   508         // Also, notice that if the proxy object leaves during the construction
       
   509         // the destructor automatically releases the handle from the server side.
       
   510         iUserData = CNcdNodeUserDataProxy::NewL( ClientServerSession(), 
       
   511                                                  userDataHandle,
       
   512                                                  *this );
       
   513         // Userdata ref counter is not increased here.
       
   514         // So, it will be zero until somebody asks for the userdata.
       
   515         // If the Release is called and
       
   516         // when the reference counter reaches zero, this node which
       
   517         // acts as parent will be deleted. The destructor of this
       
   518         // node will delete the userdata because this node owns it.
       
   519         }
       
   520 
       
   521     // Nothing else to do here, because user data will does not need
       
   522     // any other internalizing.
       
   523 
       
   524     DLTRACEOUT((""));
       
   525     }
       
   526 
       
   527 
       
   528 void CNcdNodeMetadataProxy::InternalizeDisclaimerL()
       
   529     {
       
   530     DLTRACEIN((""));
       
   531 
       
   532     // Also update disclaimer information
       
   533     if ( iDisclaimer == NULL )
       
   534         {
       
   535         // Because disclaimer does not exist. It has to be created.
       
   536         // Get the handle from the server side metadata
       
   537         
       
   538         // Check if the metadata exists in the server side and update the information
       
   539         TInt disclaimerHandle( 0 );
       
   540             
       
   541         TInt handleError =
       
   542             ClientServerSession().
       
   543                 SendSync( NcdNodeFunctionIds::ENcdDisclaimerHandle,
       
   544                           KNullDesC,
       
   545                           disclaimerHandle,
       
   546                           Handle() );
       
   547 
       
   548 
       
   549         if ( handleError == KErrNotFound )
       
   550             {
       
   551             DLINFO(("Disclaimer did not exist in server side"));
       
   552             
       
   553             // Because disclaimer did not exist in the server side
       
   554             // Nothing to do here.
       
   555             return;
       
   556             }
       
   557         else
       
   558             {
       
   559             // If error occurred then leave
       
   560             User::LeaveIfError( handleError );    
       
   561             }
       
   562 
       
   563         DLINFO(("Disclaimer existed"));
       
   564 
       
   565         // Now we can create the disclaimer object
       
   566         // Notice that this object will add its own interfaces to the
       
   567         // querylist when the object is created.
       
   568         iDisclaimer = CNcdNodeDisclaimerProxy::NewL( ClientServerSession(), 
       
   569                                                      disclaimerHandle,
       
   570                                                      this );
       
   571         }
       
   572     else       
       
   573         {
       
   574         // Notice that that if the proxy object was created above,
       
   575         // it internalizes itself during construction. So, call
       
   576         // the internalize here only if the object was not constructed
       
   577         // above.
       
   578         // Proxy object existed.
       
   579         // So, internalize it with new data.
       
   580         TRAPD( trapError, iDisclaimer->InternalizeL() );
       
   581         if ( trapError == KNcdErrorObsolete )
       
   582             {
       
   583             DLINFO(("Disclaimer was obsolete"));
       
   584             if ( iDisclaimer->MyTotalRefCount() == 0 )
       
   585                 {
       
   586                 DLINFO(("Total reference count is zero. So, delete object."))
       
   587                 // Because total reference count is zero and the object is obsolete,
       
   588                 // it should be deleted.
       
   589                 delete iDisclaimer;
       
   590                 }
       
   591 
       
   592             // Set disclaimer NULL because it has become obsolete.
       
   593             // It will be deleted automatically when the users release it
       
   594             // or it may have already been deleted above if nobody was using it.
       
   595             iDisclaimer = NULL;
       
   596             }
       
   597         else
       
   598             {
       
   599             // Let this function leave if there was another error.
       
   600             User::LeaveIfError( trapError );            
       
   601             }
       
   602         }    
       
   603         
       
   604     DLTRACEOUT((""));
       
   605     }
       
   606 
       
   607 void CNcdNodeMetadataProxy::InternalizeMoreInfoL()
       
   608     {
       
   609     DLTRACEIN((""));
       
   610 
       
   611     if ( iMoreInfo == NULL )
       
   612         {
       
   613         // Because more info does not exist. It has to be created.
       
   614         // Get the handle from the server side metadata
       
   615         
       
   616         // Check if the metadata exists in the server side and update the information
       
   617         TInt moreInfoHandle( 0 );
       
   618             
       
   619         TInt handleError =
       
   620             ClientServerSession().
       
   621                 SendSync( NcdNodeFunctionIds::ENcdMoreInfoHandle,
       
   622                           KNullDesC,
       
   623                           moreInfoHandle,
       
   624                           Handle() );
       
   625 
       
   626 
       
   627         if ( handleError == KErrNotFound )
       
   628             {
       
   629             DLINFO(("More info did not exist in server side"));
       
   630             
       
   631             // Because more info did not exist in the server side
       
   632             // Nothing to do here.
       
   633             return;
       
   634             }
       
   635         else
       
   636             {
       
   637             // If error occurred then leave
       
   638             User::LeaveIfError( handleError );    
       
   639             }
       
   640 
       
   641         DLINFO(("More info existed"));
       
   642 
       
   643         // Now we can create the disclaimer object
       
   644         // Notice that this object will add its own interfaces to the
       
   645         // querylist when the object is created.
       
   646         iMoreInfo = CNcdNodeDisclaimerProxy::NewL( ClientServerSession(), 
       
   647                                                    moreInfoHandle,
       
   648                                                    this );
       
   649         }
       
   650     else
       
   651         {
       
   652         // Notice that that if the proxy object was created above,
       
   653         // it internalizes itself during construction. So, call
       
   654         // the internalize here only if the object was not constructed
       
   655         // above.
       
   656         // Proxy object existed.
       
   657         // So, internalize it with new data.
       
   658         TRAPD( trapError, iMoreInfo->InternalizeL() );
       
   659         if ( trapError == KNcdErrorObsolete )
       
   660             {
       
   661             DLINFO(("More info was obsolete"));
       
   662             if ( iMoreInfo->MyTotalRefCount() == 0 )
       
   663                 {
       
   664                 DLINFO(("Total reference count is zero. So, delete object."))
       
   665                 // Because total reference count is zero and the object is obsolete,
       
   666                 // it should be deleted.
       
   667                 delete iMoreInfo;
       
   668                 }
       
   669 
       
   670             // Set object pointer to NULL because it has become obsolete.
       
   671             // It will be deleted automatically when the users release it
       
   672             // or it may have already been deleted above if nobody was using it.
       
   673             iMoreInfo = NULL;
       
   674             }
       
   675         else
       
   676             {
       
   677             // Let this function leave if there was another error.
       
   678             User::LeaveIfError( trapError );            
       
   679             }
       
   680         }    
       
   681         
       
   682     DLTRACEOUT((""));
       
   683     }
       
   684 
       
   685 void CNcdNodeMetadataProxy::InternalizeDownloadL()
       
   686     {
       
   687     DLTRACEIN(("this-ptr: %x", this));
       
   688     
       
   689     if ( iDownload == NULL )
       
   690         {
       
   691         DLINFO(("Download did not exist"));
       
   692 
       
   693         // Check if the download exists in the server side and update the information
       
   694         TInt downloadHandle( 0 );
       
   695             
       
   696         TInt handleError =
       
   697             ClientServerSession().
       
   698                 SendSync( NcdNodeFunctionIds::ENcdDownloadHandle,
       
   699                           KNullDesC,
       
   700                           downloadHandle,
       
   701                           Handle() );
       
   702 
       
   703         if ( handleError == KErrNotFound )
       
   704             {
       
   705             DLINFO(("Download did not exist in server side"));
       
   706             
       
   707             // Because download did not exist in the server side
       
   708             // Nothing to do here.
       
   709             return;
       
   710             }
       
   711         else
       
   712             {
       
   713             // If error occurred then leave
       
   714             User::LeaveIfError( handleError );    
       
   715             }
       
   716 
       
   717         DLINFO(("Download existed"));
       
   718                     
       
   719         // Now we can create the download object.
       
   720         // Notice that this object will add its own interfaces to the
       
   721         // querylist when the object is created.
       
   722         // Also, notice that if the proxy object leaves during the construction
       
   723         // the destructor automatically releases the handle from the server side.
       
   724         iDownload = CNcdNodeDownloadProxy::NewL( ClientServerSession(), 
       
   725                                                  downloadHandle,
       
   726                                                  *this );
       
   727         // Download ref counter is not increased here.
       
   728         // So, it will be zero until somebody asks for the download.
       
   729         // If the Release is called and
       
   730         // when the reference counter reaches zero, this object which
       
   731         // acts as parent will be deleted. The destructor of this
       
   732         // object will delete the download because this node owns it.
       
   733         }
       
   734     else
       
   735         {
       
   736         // Notice that that if the proxy object was created above,
       
   737         // it internalizes itself during construction. So, call
       
   738         // the internalize here only if the object was not constructed
       
   739         // above.
       
   740         // Proxy object existed.
       
   741         // So, internalize it with new data.
       
   742         iDownload->InternalizeL();
       
   743         }
       
   744         
       
   745     DLTRACEOUT((""));
       
   746     }
       
   747 
       
   748 
       
   749 void CNcdNodeMetadataProxy::InternalizeUpgradeL()
       
   750     {
       
   751     DLTRACEIN((""));
       
   752 
       
   753     if ( iUpgrade == NULL )
       
   754         {
       
   755         DLINFO(("Upgrade info did not exist"));
       
   756 
       
   757         // The upgrade info info is part of the metadata.
       
   758         // Update the information if it exists.
       
   759         TInt upgradeHandle( 0 );
       
   760             
       
   761         TInt handleError =
       
   762             ClientServerSession().
       
   763                 SendSync( NcdNodeFunctionIds::ENcdUpgradeHandle,
       
   764                           KNullDesC,
       
   765                           upgradeHandle,
       
   766                           Handle() );
       
   767 
       
   768         if ( handleError == KErrNotFound )
       
   769             {
       
   770             DLINFO(("Upgrade info did not exist in server side"));
       
   771             
       
   772             // Because upgrade did not exist in the server side
       
   773             // Nothing to do here.
       
   774             return;
       
   775             }
       
   776         else
       
   777             {
       
   778             // If error occurred then leave
       
   779             User::LeaveIfError( handleError );    
       
   780             }
       
   781 
       
   782         DLINFO(("Upgrade info existed in the server side"));
       
   783                     
       
   784         // Now we can create the upgrade info object.
       
   785         // Notice that this object will add its own interfaces to the
       
   786         // querylist when the object is created.
       
   787         // Also, notice that if the proxy object leaves during the construction
       
   788         // the destructor automatically releases the handle from the server side.
       
   789         iUpgrade = CNcdNodeUpgradeProxy::NewL( ClientServerSession(), 
       
   790                                                upgradeHandle,
       
   791                                                *this );
       
   792         // Upgrade ref counter is not increased here.
       
   793         // So, it will be zero until somebody asks for the upgrade info.
       
   794         // If the Release is called and
       
   795         // when the reference counter reaches zero, this object which
       
   796         // acts as parent will be deleted. The destructor of this
       
   797         // object will delete the upgrade info because this node owns it.
       
   798         }
       
   799     else       
       
   800         {
       
   801         // Notice that that if the proxy object was created above,
       
   802         // it internalizes itself during construction. So, call
       
   803         // the internalize here only if the object was not constructed
       
   804         // above.
       
   805         // Proxy object existed.
       
   806         // So, internalize it with new data.
       
   807         TRAPD( trapError, iUpgrade->InternalizeL() );
       
   808         if ( trapError == KNcdErrorObsolete )
       
   809             {
       
   810             DLINFO(("Upgrade was obsolete"));
       
   811             if ( iUpgrade->MyTotalRefCount() == 0 )
       
   812                 {
       
   813                 DLINFO(("Total reference count is zero. So, delete object."))
       
   814                 // Because total reference count is zero and the object is obsolete,
       
   815                 // it should be deleted.
       
   816                 delete iUpgrade;
       
   817                 }
       
   818 
       
   819             // Set object pointer to NULL because it has become obsolete.
       
   820             // It will be deleted automatically when the users release it
       
   821             // or it may have already been deleted above if nobody was using it.
       
   822             iUpgrade = NULL;
       
   823             }
       
   824         else
       
   825             {
       
   826             // Let this function leave if there was another error.
       
   827             User::LeaveIfError( trapError );            
       
   828             }
       
   829         }            
       
   830     DLTRACEOUT((""));    
       
   831     }
       
   832 
       
   833 
       
   834 void CNcdNodeMetadataProxy::InternalizeDependencyL()
       
   835     {
       
   836     DLTRACEIN((""));
       
   837 
       
   838     if ( iDependency == NULL )
       
   839         {
       
   840         DLINFO(("Dependency info did not exist"));
       
   841 
       
   842         // The dependency info info is part of the metadata.
       
   843         // Update the information if it exists.
       
   844         TInt dependencyHandle( 0 );
       
   845             
       
   846         TInt handleError =
       
   847             ClientServerSession().
       
   848                 SendSync( NcdNodeFunctionIds::ENcdDependencyHandle,
       
   849                           KNullDesC,
       
   850                           dependencyHandle,
       
   851                           Handle() );
       
   852 
       
   853         if ( handleError == KErrNotFound )
       
   854             {
       
   855             DLINFO(("Dependency info did not exist in server side"));
       
   856             
       
   857             // Because dependency did not exist in the server side
       
   858             // Nothing to do here.
       
   859             return;
       
   860             }
       
   861         else
       
   862             {
       
   863             // If error occurred then leave
       
   864             User::LeaveIfError( handleError );    
       
   865             }
       
   866 
       
   867         DLINFO(("Dependency info existed in the server side"));
       
   868                     
       
   869         // Now we can create the dependency info object.
       
   870         // Notice that this object will add its own interfaces to the
       
   871         // querylist when the object is created.
       
   872         // Also, notice that if the proxy object leaves during the construction
       
   873         // the destructor automatically releases the handle from the server side.
       
   874         iDependency = CNcdNodeDependencyProxy::NewL( ClientServerSession(), 
       
   875                                                      dependencyHandle,
       
   876                                                      *this );
       
   877         // Dependency ref counter is not increased here.
       
   878         // So, it will be zero until somebody asks for the dependency info.
       
   879         // If the Release is called and
       
   880         // when the reference counter reaches zero, this object which
       
   881         // acts as parent will be deleted. The destructor of this
       
   882         // object will delete the dependency info because this node owns it.
       
   883         }
       
   884     else       
       
   885         {
       
   886         // Notice that that if the proxy object was created above,
       
   887         // it internalizes itself during construction. So, call
       
   888         // the internalize here only if the object was not constructed
       
   889         // above.
       
   890         // Proxy object existed.
       
   891         // So, internalize it with new data.
       
   892         TRAPD( trapError, iDependency->InternalizeL() );
       
   893         if ( trapError == KNcdErrorObsolete )
       
   894             {
       
   895             DLINFO(("Dependency was obsolete"));
       
   896             if ( iDependency->MyTotalRefCount() == 0 )
       
   897                 {
       
   898                 DLINFO(("Total reference count is zero. So, delete object."))
       
   899                 // Because total reference count is zero and the object is obsolete,
       
   900                 // it should be deleted.
       
   901                 delete iDependency;
       
   902                 }
       
   903 
       
   904             // Set object pointer to NULL because it has become obsolete.
       
   905             // It will be deleted automatically when the users release it
       
   906             // or it may have already been deleted above if nobody was using it.
       
   907             iDependency = NULL;
       
   908             }
       
   909         else
       
   910             {
       
   911             // Let this function leave if there was another error.
       
   912             User::LeaveIfError( trapError );            
       
   913             }
       
   914         }            
       
   915     DLTRACEOUT((""));    
       
   916     }
       
   917 
       
   918 
       
   919 void CNcdNodeMetadataProxy::InternalizeIconL()
       
   920     {
       
   921     DLTRACEIN((""));
       
   922 
       
   923     if ( iIcon == NULL )
       
   924         {
       
   925         DLINFO(("Icon did not exist"));
       
   926 
       
   927         // The icon info is part of the metadata.
       
   928         // Update the information if it exists.
       
   929         TInt iconHandle( 0 );
       
   930             
       
   931         TInt handleError =
       
   932             ClientServerSession().
       
   933                 SendSync( NcdNodeFunctionIds::ENcdIconHandle,
       
   934                           KNullDesC,
       
   935                           iconHandle,
       
   936                           Handle() );
       
   937 
       
   938         if ( handleError == KErrNotFound )
       
   939             {
       
   940             DLINFO(("Icon did not exist in server side"));
       
   941             
       
   942             // Because icon did not exist in the server side
       
   943             // Nothing to do here.
       
   944             return;
       
   945             }
       
   946         else
       
   947             {
       
   948             // If error occurred then leave
       
   949             User::LeaveIfError( handleError );    
       
   950             }
       
   951 
       
   952         DLINFO(("Icon existed in the server side"));
       
   953                     
       
   954         // Now we can create the icon object.
       
   955         // Notice that this object will add its own interfaces to the
       
   956         // querylist when the object is created.
       
   957         // Also, notice that if the proxy object leaves during the construction
       
   958         // the destructor automatically releases the handle from the server side.
       
   959         iIcon = CNcdNodeIconProxy::NewL( ClientServerSession(), 
       
   960                                          iconHandle,
       
   961                                          *this );
       
   962         // Icon ref counter is not increased here.
       
   963         // So, it will be zero until somebody asks for the icon.
       
   964         // If the Release is called and
       
   965         // when the reference counter reaches zero, this object which
       
   966         // acts as parent will be deleted. The destructor of this
       
   967         // object will delete the icon because this object owns it.
       
   968         }
       
   969     else       
       
   970         {
       
   971         // Notice that that if the proxy object was created above,
       
   972         // it internalizes itself during construction. So, call
       
   973         // the internalize here only if the object was not constructed
       
   974         // above.
       
   975         // Proxy object existed.
       
   976         // So, internalize it with new data.
       
   977         TRAPD( trapError, iIcon->InternalizeL() );
       
   978         if ( trapError == KNcdErrorObsolete )
       
   979             {
       
   980             DLINFO(("Icon was obsolete"));
       
   981             if ( iIcon->MyTotalRefCount() == 0 )
       
   982                 {
       
   983                 DLINFO(("Total reference count is zero. So, delete object."))
       
   984                 // Because total reference count is zero and the object is obsolete,
       
   985                 // it should be deleted.
       
   986                 delete iIcon;
       
   987                 }
       
   988 
       
   989             // Set object pointer to NULL because it has become obsolete.
       
   990             // It will be deleted automatically when the users release it
       
   991             // or it may have already been deleted above if nobody was using it.
       
   992             iIcon = NULL;
       
   993             }
       
   994         else
       
   995             {
       
   996             // Let this function leave if there was another error.
       
   997             User::LeaveIfError( trapError );            
       
   998             }
       
   999         }            
       
  1000     DLTRACEOUT((""));
       
  1001     }
       
  1002 
       
  1003 void CNcdNodeMetadataProxy::InternalizeScreenshotL()
       
  1004     {
       
  1005     DLTRACEIN((""));
       
  1006 
       
  1007     if ( iScreenshot == NULL )
       
  1008         {
       
  1009         DLINFO(("Screenshot did not exist"));
       
  1010 
       
  1011         // Check if the metadata exists in the server side.
       
  1012         // The screenshot info is part of the metadata.
       
  1013         // Update the information if it exists.
       
  1014         TInt screenshotHandle( 0 );
       
  1015             
       
  1016         TInt handleError =
       
  1017             ClientServerSession().
       
  1018                 SendSync( NcdNodeFunctionIds::ENcdScreenshotHandle,
       
  1019                           KNullDesC,
       
  1020                           screenshotHandle,
       
  1021                           Handle() );
       
  1022 
       
  1023         if ( handleError == KErrNotFound )
       
  1024             {
       
  1025             DLINFO(("Screenshot did not exist in server side"));
       
  1026             
       
  1027             // Because screenshot did not exist in the server side.
       
  1028             // Nothing to do here.
       
  1029             return;
       
  1030             }
       
  1031         else
       
  1032             {
       
  1033             // If error occurred then leave
       
  1034             User::LeaveIfError( handleError );    
       
  1035             }
       
  1036 
       
  1037         DLINFO(("Screenshot existed in the server side"));
       
  1038                     
       
  1039         // Now we can create the screenshot object.
       
  1040         // Notice that this object will add its own interfaces to the
       
  1041         // querylist when the object is created.
       
  1042         // Also, notice that if the proxy object leaves during the construction
       
  1043         // the destructor automatically releases the handle from the server side.
       
  1044         iScreenshot = 
       
  1045             CNcdNodeScreenshotProxy::NewL( ClientServerSession(),
       
  1046                                            screenshotHandle,
       
  1047                                            *this );
       
  1048         // Screenshot ref counter is not increased here.
       
  1049         // So, it will be zero until somebody asks for the screenshot.
       
  1050         // If the Release is called and
       
  1051         // when the reference counter reaches zero, this object which
       
  1052         // acts as parent will be deleted. The destructor of this
       
  1053         // object will delete the screenshot because this node owns it.
       
  1054         }
       
  1055     else       
       
  1056         {
       
  1057         // Notice that that if the proxy object was created above,
       
  1058         // it internalizes itself during construction. So, call
       
  1059         // the internalize here only if the object was not constructed
       
  1060         // above.
       
  1061         // Proxy object existed.
       
  1062         // So, internalize it with new data.
       
  1063         TRAPD( trapError, iScreenshot->InternalizeL() );
       
  1064         if ( trapError == KNcdErrorObsolete )
       
  1065             {
       
  1066             DLINFO(("Screenshot was obsolete"));
       
  1067             if ( iScreenshot->MyTotalRefCount() == 0 )
       
  1068                 {
       
  1069                 DLINFO(("Total reference count is zero. So, delete object."))
       
  1070                 // Because total reference count is zero and the object is obsolete,
       
  1071                 // it should be deleted.
       
  1072                 delete iScreenshot;
       
  1073                 }
       
  1074 
       
  1075             // Set object pointer to NULL because it has become obsolete.
       
  1076             // It will be deleted automatically when the users release it
       
  1077             // or it may have already been deleted above if nobody was using it.
       
  1078             iScreenshot = NULL;
       
  1079             }
       
  1080         else
       
  1081             {
       
  1082             // Let this function leave if there was another error.
       
  1083             User::LeaveIfError( trapError );            
       
  1084             }
       
  1085         }            
       
  1086     DLTRACEOUT((""));
       
  1087     }
       
  1088 
       
  1089 void CNcdNodeMetadataProxy::InternalizePurchaseL()
       
  1090     {
       
  1091     DLTRACEIN((""));
       
  1092 
       
  1093     TBool isPurchaseSupported = EFalse;
       
  1094     // First check if this node should have purchase interface
       
  1095     User::LeaveIfError( 
       
  1096         ClientServerSession().
       
  1097             SendSync( NcdNodeFunctionIds::ENcdIsPurchaseSupported,
       
  1098                       KNullDesC,
       
  1099                       isPurchaseSupported,
       
  1100                       Handle() ) );
       
  1101     
       
  1102     if ( isPurchaseSupported && iPurchase == NULL )
       
  1103         {
       
  1104         DLINFO(("Purchase is supported -> create."));
       
  1105         
       
  1106         // Check if the metadata exists in the server side and update the information
       
  1107         TInt metadataHandle( 0 );
       
  1108             
       
  1109         TInt handleError =
       
  1110             ClientServerSession().
       
  1111                 SendSync( NcdNodeFunctionIds::ENcdMetadataHandle,
       
  1112                           KNullDesC,
       
  1113                           metadataHandle,
       
  1114                           Node().Handle() );
       
  1115 
       
  1116         if ( handleError == KErrNotFound )
       
  1117             {
       
  1118             DLINFO(("Metadata did not exist in server side"));
       
  1119             
       
  1120             // Because metadata did not exist in the server side
       
  1121             // Nothing to do here.
       
  1122             return;
       
  1123             }
       
  1124         else
       
  1125             {
       
  1126             // If error occurred then leave
       
  1127             User::LeaveIfError( handleError );    
       
  1128             }        
       
  1129         
       
  1130         // Now we can create the purchase object.
       
  1131         // Notice that if the proxy object leaves during the construction
       
  1132         // the destructor automatically releases the handle from the server side.
       
  1133         iPurchase = CNcdNodePurchaseProxy::NewL(
       
  1134                         ClientServerSession(), 
       
  1135                         metadataHandle,
       
  1136                         *this );
       
  1137         // Purchase ref counter is not increased here.
       
  1138         // And when someone asks for the Purchase, its parent's (this)
       
  1139         // ref-count is added.
       
  1140         // If the Release is called and
       
  1141         // when the reference counter reaches zero, this metadata which
       
  1142         // acts as parent will be deleted. The destructor of this
       
  1143         // metadata will delete the icon because this node owns it.
       
  1144         }
       
  1145     else if ( isPurchaseSupported && iPurchase )
       
  1146         {
       
  1147         DLINFO(("Purchase is supported -> internalize."));
       
  1148         // Notice that that if the proxy object was created above,
       
  1149         // it internalizes itself during construction. So, call
       
  1150         // the internalize here only if the object was not constructed
       
  1151         // above.
       
  1152         // Proxy object existed.
       
  1153         // So, internalize it with new data.
       
  1154         iPurchase->InternalizeL();
       
  1155         }
       
  1156     else if ( !isPurchaseSupported && iPurchase )
       
  1157         {
       
  1158         DLTRACE(("Purchase not supported -> remove."));
       
  1159         if ( iPurchase->MyTotalRefCount() == 0 )
       
  1160                 {
       
  1161                 DLINFO(("Total reference count is zero. So, delete object."))
       
  1162                 // Because total reference count is zero and the object is obsolete,
       
  1163                 // it should be deleted.
       
  1164                 delete iPurchase;
       
  1165                 }
       
  1166 
       
  1167             // Set object pointer to NULL because it has become obsolete.
       
  1168             // It will be deleted automatically when the users release it
       
  1169             // or it may have already been deleted above if nobody was using it.
       
  1170             iPurchase = NULL;
       
  1171         }
       
  1172         
       
  1173     DLTRACEOUT((""));
       
  1174     }
       
  1175 
       
  1176 void CNcdNodeMetadataProxy::InternalizeUriContentL()
       
  1177     {
       
  1178     DLTRACEIN((""));
       
  1179 
       
  1180     if ( iUriContent == NULL )
       
  1181         {
       
  1182         DLINFO(("uri content did not exist"));
       
  1183 
       
  1184         // Check if the metadata exists in the server side.
       
  1185         // The uri content is part of the metadata.
       
  1186         // Update the information if it exists.
       
  1187         TInt uriHandle( 0 );
       
  1188             
       
  1189         TInt handleError =
       
  1190             ClientServerSession().
       
  1191                 SendSync( NcdNodeFunctionIds::ENcdUriContentHandle,
       
  1192                           KNullDesC,
       
  1193                           uriHandle,
       
  1194                           Handle() );
       
  1195 
       
  1196         if ( handleError == KErrNotFound )
       
  1197             {
       
  1198             DLINFO(("uri content did not exist in server side"));
       
  1199             
       
  1200             // Because uri content did not exist in the server side
       
  1201             // Nothing to do here.
       
  1202             return;
       
  1203             }
       
  1204         else
       
  1205             {
       
  1206             // If error occurred then leave
       
  1207             User::LeaveIfError( handleError );    
       
  1208             }
       
  1209 
       
  1210         DLINFO(("Uri content existed in the server side"));
       
  1211                     
       
  1212         // Now we can create the uri content object.
       
  1213         // Notice that this object will add its own interfaces to the
       
  1214         // querylist when the object is created.
       
  1215         // Notice that if the proxy object leaves during the construction
       
  1216         // the destructor automatically releases the handle from the server side.
       
  1217         iUriContent = CNcdNodeUriContentProxy::NewL( ClientServerSession(), 
       
  1218                                                      uriHandle,
       
  1219                                                      *this );
       
  1220         }
       
  1221     else
       
  1222         {
       
  1223         // Notice that that if the proxy object was created above,
       
  1224         // it internalizes itself during construction. So, call
       
  1225         // the internalize here only if the object was not constructed
       
  1226         // above.
       
  1227         // Proxy object existed.
       
  1228         // So, internalize it with new data.
       
  1229         iUriContent->InternalizeL();
       
  1230         }
       
  1231         
       
  1232     DLTRACEOUT((""));
       
  1233     }
       
  1234 
       
  1235 void CNcdNodeMetadataProxy::InternalizeContentInfoL()
       
  1236     {
       
  1237     DLTRACEIN((""));
       
  1238 
       
  1239     if ( iContentInfo == NULL )
       
  1240         {
       
  1241         DLINFO(("content info did not exist"));
       
  1242 
       
  1243         // Check if the metadata exists in the server side.
       
  1244         // The content info is part of the metadata.
       
  1245         // Update the information if it exists.
       
  1246         TInt infoHandle( 0 );
       
  1247             
       
  1248         TInt handleError =
       
  1249             ClientServerSession().
       
  1250                 SendSync( NcdNodeFunctionIds::ENcdContentInfoHandle,
       
  1251                           KNullDesC,
       
  1252                           infoHandle,
       
  1253                           Handle() );
       
  1254 
       
  1255         if ( handleError == KErrNotFound )
       
  1256             {
       
  1257             DLINFO(("Content info did not exist in server side"));
       
  1258             
       
  1259             // Because content info did not exist in the server side
       
  1260             // Nothing to do here.
       
  1261             return;
       
  1262             }
       
  1263         else
       
  1264             {
       
  1265             // If error occurred then leave
       
  1266             User::LeaveIfError( handleError );    
       
  1267             }
       
  1268 
       
  1269         DLINFO(("Content info existed in the server side"));
       
  1270                     
       
  1271         // Now we can create the content info object.
       
  1272         // Notice that this object will add its own interfaces to the
       
  1273         // querylist when the object is created.
       
  1274         // Also, notice that if the proxy object leaves during the construction
       
  1275         // the destructor automatically releases the handle from the server side.
       
  1276         iContentInfo = CNcdNodeContentInfoProxy::NewL( ClientServerSession(),
       
  1277                                                        infoHandle,
       
  1278                                                        *this );
       
  1279         }
       
  1280     else       
       
  1281         {
       
  1282         // Notice that that if the proxy object was created above,
       
  1283         // it internalizes itself during construction. So, call
       
  1284         // the internalize here only if the object was not constructed
       
  1285         // above.
       
  1286         // Proxy object existed.
       
  1287         // So, internalize it with new data.
       
  1288         TRAPD( trapError, iContentInfo->InternalizeL() );
       
  1289         if ( trapError == KNcdErrorObsolete )
       
  1290             {
       
  1291             DLINFO(("Content info was obsolete"));
       
  1292             if ( iContentInfo->MyTotalRefCount() == 0 )
       
  1293                 {
       
  1294                 DLINFO(("Total reference count is zero. So, delete object."))
       
  1295                 // Because total reference count is zero and the object is obsolete,
       
  1296                 // it should be deleted.
       
  1297                 delete iContentInfo;
       
  1298                 }
       
  1299 
       
  1300             // Set object pointer to NULL because it has become obsolete.
       
  1301             // It will be deleted automatically when the users release it
       
  1302             // or it may have already been deleted above if nobody was using it.
       
  1303             iContentInfo = NULL;
       
  1304             }
       
  1305         else
       
  1306             {
       
  1307             // Let this function leave if there was another error.
       
  1308             User::LeaveIfError( trapError );            
       
  1309             }
       
  1310         }            
       
  1311     DLTRACEOUT((""));
       
  1312     }
       
  1313 
       
  1314 void CNcdNodeMetadataProxy::InternalizeInstallL()
       
  1315     {
       
  1316     DLTRACEIN((""));
       
  1317 
       
  1318     if ( iInstall == NULL )
       
  1319         {
       
  1320         DLINFO(("Node install was not set. Set it now."));
       
  1321         TInt installHandle( 0 );
       
  1322         
       
  1323         // Get the handle for the install.
       
  1324         TInt handleError =
       
  1325                 ClientServerSession().
       
  1326                     SendSync( NcdNodeFunctionIds::ENcdInstallHandle,
       
  1327                               KNullDesC,
       
  1328                               installHandle,
       
  1329                               Handle() );
       
  1330                               
       
  1331         if ( handleError == KErrNotFound )
       
  1332             {
       
  1333             DLINFO(("Install info did not exist in server side"));
       
  1334             
       
  1335             // Because content info did not exist in the server side
       
  1336             // Nothing to do here.
       
  1337             return;
       
  1338             }
       
  1339         else
       
  1340             {
       
  1341             // If error occurred then leave
       
  1342             User::LeaveIfError( handleError );    
       
  1343             }
       
  1344                                   
       
  1345         DLINFO(("Handle: %i", installHandle));
       
  1346 
       
  1347         // Now we can create the install object.
       
  1348         // Notice that this object will add its own interfaces to the
       
  1349         // querylist when the object is created.
       
  1350         // Also, notice that if the proxy object leaves during the construction
       
  1351         // the destructor automatically releases the handle from the server side.
       
  1352         iInstall = CNcdNodeInstallProxy::NewL( ClientServerSession(), 
       
  1353                                                installHandle,
       
  1354                                                *this );
       
  1355         }
       
  1356     else
       
  1357         {
       
  1358         // Notice that that if the proxy object was created above,
       
  1359         // it internalizes itself during construction. So, call
       
  1360         // the internalize here only if the object was not constructed
       
  1361         // above.
       
  1362         // Proxy object existed.
       
  1363         // So, internalize it with new data.
       
  1364         iInstall->InternalizeL();
       
  1365         }
       
  1366         
       
  1367     DLTRACEOUT((""));
       
  1368     }
       
  1369 
       
  1370 void CNcdNodeMetadataProxy::InternalizePreviewL()
       
  1371     {
       
  1372     DLTRACEIN((""));
       
  1373 
       
  1374     if ( iPreview == NULL )
       
  1375         {
       
  1376         DLINFO(("Preview did not exist"));
       
  1377 
       
  1378         TInt previewHandle( 0 );
       
  1379             
       
  1380         TInt handleError =
       
  1381             ClientServerSession().
       
  1382                 SendSync( NcdNodeFunctionIds::ENcdPreviewHandle,
       
  1383                           KNullDesC,
       
  1384                           previewHandle,
       
  1385                           Handle() );
       
  1386 
       
  1387         if ( handleError == KErrNotFound )
       
  1388             {
       
  1389             DLINFO(("Preview did not exist in server side"));
       
  1390             
       
  1391             // Because preview did not exist in the server side
       
  1392             // Nothing to do here.
       
  1393             return;
       
  1394             }
       
  1395         else
       
  1396             {
       
  1397             // If error occurred then leave
       
  1398             User::LeaveIfError( handleError );    
       
  1399             }
       
  1400 
       
  1401         DLINFO(("Preview existed in the server side"));
       
  1402                     
       
  1403         // Now we can create the preview object.
       
  1404         // Notice that this object will add its own interfaces to the
       
  1405         // querylist when the object is created.
       
  1406         // Also, notice that if the proxy object leaves during the construction
       
  1407         // the destructor automatically releases the handle from the server side.
       
  1408         iPreview = CNcdNodePreviewProxy::NewL( ClientServerSession(), 
       
  1409                                                previewHandle,
       
  1410                                                *this );
       
  1411         }
       
  1412     else       
       
  1413         {
       
  1414         // Notice that that if the proxy object was created above,
       
  1415         // it internalizes itself during construction. So, call
       
  1416         // the internalize here only if the object was not constructed
       
  1417         // above.
       
  1418         // Proxy object existed.
       
  1419         // So, internalize it with new data.
       
  1420         TRAPD( trapError, iPreview->InternalizeL() );
       
  1421         if ( trapError == KNcdErrorObsolete )
       
  1422             {
       
  1423             DLINFO(("Preview was obsolete"));
       
  1424             if ( iPreview->MyTotalRefCount() == 0 )
       
  1425                 {
       
  1426                 DLINFO(("Total reference count is zero. So, delete object."))
       
  1427                 // Because total reference count is zero and the object is obsolete,
       
  1428                 // it should be deleted.
       
  1429                 delete iPreview;
       
  1430                 }
       
  1431 
       
  1432             // Set object pointer to NULL because it has become obsolete.
       
  1433             // It will be deleted automatically when the users release it
       
  1434             // or it may have already been deleted above if nobody was using it.
       
  1435             iPreview = NULL;
       
  1436             }
       
  1437         else
       
  1438             {
       
  1439             // Let this function leave if there was another error.
       
  1440             User::LeaveIfError( trapError );            
       
  1441             }
       
  1442         }            
       
  1443     DLTRACEOUT((""));
       
  1444     }
       
  1445 
       
  1446 
       
  1447 void CNcdNodeMetadataProxy::InternalizeSkinL()
       
  1448     {
       
  1449     DLTRACEIN((""));
       
  1450 
       
  1451     if( iSkin == NULL )
       
  1452         {
       
  1453         DLTRACE(("Skin did not exist"));
       
  1454 
       
  1455         TInt skinHandle( 0 );
       
  1456             
       
  1457         TInt handleError =
       
  1458             ClientServerSession().
       
  1459                 SendSync( NcdNodeFunctionIds::ENcdSkinHandle,
       
  1460                           KNullDesC,
       
  1461                           skinHandle,
       
  1462                           Handle() );
       
  1463 
       
  1464         if ( handleError == KErrNotFound )
       
  1465             {
       
  1466             DLTRACE(("Skin did not exist in server side"));
       
  1467             
       
  1468             // Because skin did not exist in the server side
       
  1469             // Nothing to do here.
       
  1470             return;
       
  1471             }
       
  1472         else
       
  1473             {
       
  1474             // If error occurred then leave
       
  1475             User::LeaveIfError( handleError );    
       
  1476             }
       
  1477 
       
  1478         DLTRACE(("Skin existed in the server side"));
       
  1479                     
       
  1480         // Now we can create the skin object.
       
  1481         // Notice that this object will add its own interfaces to the
       
  1482         // querylist when the object is created.
       
  1483         iSkin = CNcdNodeSkinProxy::NewL( ClientServerSession(), 
       
  1484                                          skinHandle,
       
  1485                                          *this );
       
  1486         // Skin ref counter is not increased here.
       
  1487         // So, it will be zero until somebody asks for the skin.
       
  1488         // If the Release is called and
       
  1489         // when the reference counter reaches zero, this node which
       
  1490         // acts as parent will be deleted. The destructor of this
       
  1491         // node will delete the skin because this node owns it.
       
  1492         }
       
  1493     else       
       
  1494         {
       
  1495         // Notice that that if the proxy object was created above,
       
  1496         // it internalizes itself during construction. So, call
       
  1497         // the internalize here only if the object was not constructed
       
  1498         // above.
       
  1499         // Proxy object existed.
       
  1500         // So, internalize it with new data.
       
  1501         TRAPD( trapError, iSkin->InternalizeL() );
       
  1502         if ( trapError == KNcdErrorObsolete )
       
  1503             {
       
  1504             DLINFO(("Skin was obsolete"));
       
  1505             if ( iSkin->MyTotalRefCount() == 0 )
       
  1506                 {
       
  1507                 DLINFO(("Total reference count is zero. So, delete object."))
       
  1508                 // Because total reference count is zero and the object is obsolete,
       
  1509                 // it should be deleted.
       
  1510                 delete iSkin;
       
  1511                 }
       
  1512 
       
  1513             // Set object pointer to NULL because it has become obsolete.
       
  1514             // It will be deleted automatically when the users release it
       
  1515             // or it may have already been deleted above if nobody was using it.
       
  1516             iSkin = NULL;
       
  1517             }
       
  1518         else
       
  1519             {
       
  1520             // Let this function leave if there was another error.
       
  1521             User::LeaveIfError( trapError );            
       
  1522             }
       
  1523         }    
       
  1524     DLTRACEOUT((""));
       
  1525     }
       
  1526 
       
  1527 
       
  1528 void CNcdNodeMetadataProxy::InternalizeActivateL()
       
  1529     {
       
  1530     DLTRACEIN((""));
       
  1531 
       
  1532     if ( iInstall != NULL 
       
  1533          && iInstall->IsInstalledL()
       
  1534          && ( iInstall->IsPurpose( ENcdItemPurposeRingtone )
       
  1535               || iInstall->IsPurpose( ENcdItemPurposeWallpaper )
       
  1536               || iInstall->IsPurpose( ENcdItemPurposeTheme ) ) )
       
  1537         {
       
  1538         // Because install interface exists and something has been installed,
       
  1539         // there may be something to activate. Note that items should be installed
       
  1540         // before they can be activated.
       
  1541         if ( iActivate == NULL )
       
  1542             {
       
  1543             // Create activate interface object only if it does not already exist.
       
  1544             iActivate = CNcdNodeActivate::NewL( *this );        
       
  1545             }
       
  1546         }
       
  1547     else if ( iActivate != NULL )
       
  1548         {
       
  1549         // Because install information did not exist or the item does not have
       
  1550         // anything to activate, activate option should not exist either.
       
  1551         // Destructor takes care of the removing the interface 
       
  1552         // from the interface list.
       
  1553         delete iActivate;
       
  1554         iActivate = NULL;
       
  1555         }
       
  1556 
       
  1557     DLTRACEOUT((""));
       
  1558     }
       
  1559 
       
  1560 
       
  1561     
       
  1562