ncdengine/provider/client/src/ncdinstalledcontentimpl.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 CNcdInstalledContent class implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ncdinstalledcontentimpl.h"
       
    20 #include "catalogsinterfaceidentifier.h"
       
    21 #include "catalogsutils.h"
       
    22 #include "catalogsdebug.h"
       
    23 #include "ncdnodeinstallproxy.h"
       
    24 
       
    25 
       
    26 // ======== PUBLIC MEMBER FUNCTIONS ========
       
    27 
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // Constructor
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 CNcdInstalledContent::CNcdInstalledContent( 
       
    34     CNcdNodeInstallProxy& aParent,
       
    35     TInstalledContentType aType )
       
    36     : CCatalogsInterfaceBase( NULL ),
       
    37     iOwner( aParent ),
       
    38     iContentType( aType )
       
    39     {
       
    40     
       
    41     }
       
    42 
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // 2nd phase constructor
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 void CNcdInstalledContent::ConstructL()
       
    49     {
       
    50     DLTRACEIN((""));
       
    51     // Register the interface
       
    52     MNcdInstalledContent* interface( this );
       
    53     AddInterfaceL( 
       
    54         CCatalogsInterfaceIdentifier::NewL( interface, this, 
       
    55             MNcdInstalledContent::KInterfaceUid ) );
       
    56             
       
    57     }
       
    58 
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // Destructor
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 CNcdInstalledContent::~CNcdInstalledContent()
       
    65     {
       
    66     DLTRACEIN(("this-ptr: %x", this));
       
    67     // Remove interfaces implemented by this class from the interface list.
       
    68     // So, the interface list is up to date when this class object is deleted.
       
    69     RemoveInterface( MNcdInstalledContent::KInterfaceUid );    
       
    70     DLTRACEOUT(("this-ptr: %x", this));
       
    71     }
       
    72 
       
    73 
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // Is launchable
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 TBool CNcdInstalledContent::IsLaunchable() const
       
    80     {
       
    81     return iLaunchable;
       
    82     }
       
    83 
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // Content type getter
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 MNcdInstalledContent::TInstalledContentType 
       
    90     CNcdInstalledContent::ContentType() const
       
    91     {
       
    92     return iContentType;
       
    93     }
       
    94 
       
    95 
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // Set launchable
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 void CNcdInstalledContent::SetLaunchable( TBool aLaunchable )
       
   102     {
       
   103     DLTRACEIN(("Launchable: %d", aLaunchable));
       
   104     iLaunchable = aLaunchable;
       
   105     }
       
   106 
       
   107 
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // Set launchable
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 TInt CNcdInstalledContent::AddRef()
       
   114     {
       
   115     DLTRACEIN(("this-ptr: %x", this));
       
   116     
       
   117     TInt count = CCatalogsInterfaceBase::AddRef();
       
   118     
       
   119     // Ensure that NodeInstall-proxy stays alive as long as necessary
       
   120     // The owner should not be deleted before this class object's 
       
   121     // reference count is back to zero. The owner should
       
   122     // handle the deletion of this class object separately for example 
       
   123     // when its destructor is called.
       
   124     if ( count > 1 ) 
       
   125         {
       
   126         DLTRACE(("Adding a ref to NodeInstall, count: %d", count));
       
   127         ContentOwner().InternalAddRef();
       
   128         }
       
   129     DLTRACEOUT(("this-ptr: %x, count: %d", this, count));
       
   130     return count;
       
   131     }
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 // Set launchable
       
   135 // ---------------------------------------------------------------------------
       
   136 //
       
   137 TInt CNcdInstalledContent::Release()
       
   138     {
       
   139     DLTRACEIN(("this-ptr: %x", this));
       
   140     
       
   141     TInt count = CCatalogsInterfaceBase::Release();
       
   142 
       
   143     // The owner should not be deleted before this class object's 
       
   144     // reference count is back to zero. The owner should
       
   145     // handle the deletion of this class object separately for example 
       
   146     // when its destructor is called.
       
   147     if ( count >= 1 ) 
       
   148         {
       
   149         DLTRACE(("Releasing a ref from NodeInstall, count: %d", count));
       
   150         ContentOwner().InternalRelease();
       
   151         }
       
   152         
       
   153     return count;
       
   154     }
       
   155 
       
   156 
       
   157 // ---------------------------------------------------------------------------
       
   158 // Get the owner of this class object
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 CNcdNodeInstallProxy& CNcdInstalledContent::ContentOwner() const
       
   162     {
       
   163     return iOwner;
       
   164     }