ncdengine/provider/client/src/ncdinstalledfileimpl.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 CNcdInstalledFile class implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ncdinstalledfileimpl.h"
       
    20 
       
    21 #include <bautils.h>
       
    22 
       
    23 #include "ncdnodeinstallproxy.h"
       
    24 #include "ncdinstallationservice.h"
       
    25 #include "catalogsinterfaceidentifier.h"
       
    26 #include "catalogsutils.h"
       
    27 #include "ncdfileinfo.h"
       
    28 
       
    29 #include "catalogsdebug.h"
       
    30 
       
    31 // ======== PUBLIC MEMBER FUNCTIONS ========
       
    32 
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // Constructor
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 CNcdInstalledFile::CNcdInstalledFile( 
       
    39     CNcdNodeInstallProxy& aParent,
       
    40     CNcdFileInfo* aInfo,
       
    41     TInt aFileIndex )
       
    42         : CNcdInstalledContent( aParent ),
       
    43     iInfo( aInfo ),
       
    44     iFileIndex( aFileIndex )    
       
    45     {
       
    46     }
       
    47 
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // 2nd phase constructor
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 void CNcdInstalledFile::ConstructL()
       
    54     {
       
    55     DLTRACEIN(("this: %X", this));
       
    56     CNcdInstalledContent::ConstructL();
       
    57     
       
    58     // Info can't be NULL
       
    59     User::LeaveIfNull( iInfo );
       
    60     
       
    61     // Register the interface
       
    62     MNcdInstalledFile* interface( this );
       
    63     AddInterfaceL( 
       
    64         CCatalogsInterfaceIdentifier::NewL( interface, this,
       
    65             MNcdInstalledFile::KInterfaceUid ) );
       
    66     }
       
    67 
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // NewL
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 CNcdInstalledFile* CNcdInstalledFile::NewL(
       
    74     CNcdNodeInstallProxy& aParent,
       
    75     CNcdFileInfo* aInfo,
       
    76     TInt aFileIndex )
       
    77     {
       
    78     CNcdInstalledFile* self = 
       
    79         CNcdInstalledFile::NewLC( aParent, aInfo, aFileIndex );
       
    80     CleanupStack::Pop( self );
       
    81     return self;
       
    82     }
       
    83 
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // NewLC
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 CNcdInstalledFile* CNcdInstalledFile::NewLC(
       
    90     CNcdNodeInstallProxy& aParent,
       
    91     CNcdFileInfo* aInfo,
       
    92     TInt aFileIndex )
       
    93     {
       
    94     CNcdInstalledFile* self = 
       
    95         new( ELeave ) CNcdInstalledFile( aParent, aInfo, aFileIndex );
       
    96     // Using PushL because the object does not have references yet
       
    97     CleanupStack::PushL( self );
       
    98     self->ConstructL();
       
    99     return self;
       
   100     }
       
   101 
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // Destructor
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 CNcdInstalledFile::~CNcdInstalledFile()
       
   108     {
       
   109     DLTRACEIN(("this: %X", this));
       
   110 
       
   111     // Remove interfaces implemented by this class from the interface list.
       
   112     // So, the interface list is up to date when this class object is deleted.
       
   113     RemoveInterface( MNcdInstalledFile::KInterfaceUid );
       
   114     
       
   115     
       
   116     // Delete member variables here
       
   117     delete iInfo;
       
   118     }
       
   119 
       
   120 
       
   121 
       
   122 // ---------------------------------------------------------------------------
       
   123 // Is installed
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 TBool CNcdInstalledFile::IsInstalledL() const
       
   127     {    
       
   128     return iInfo->FilePath().Length() &&
       
   129         BaflUtils::FileExists( 
       
   130             ContentOwner().FileSession(), 
       
   131             iInfo->FilePath() );
       
   132     }
       
   133     
       
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 // Mime type getter
       
   137 // ---------------------------------------------------------------------------
       
   138 //
       
   139 const TDesC& CNcdInstalledFile::MimeType() const
       
   140     {
       
   141     return iInfo->MimeType();
       
   142     }
       
   143 
       
   144 
       
   145 // ---------------------------------------------------------------------------
       
   146 // File opener
       
   147 // ---------------------------------------------------------------------------
       
   148 //
       
   149 RFile CNcdInstalledFile::OpenFileL()
       
   150     {
       
   151     return ContentOwner().OpenFileL( iFileIndex );
       
   152     }
       
   153 
       
   154