omadrm/drmengine/dcfrepository/client/src/DcfEntry.cpp
changeset 0 95b198f216e5
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "DcfEntry.h"
       
    22 #include    <e32std.h>
       
    23 #include    <e32base.h>
       
    24 // EXTERNAL DATA STRUCTURES
       
    25 // EXTERNAL FUNCTION PROTOTYPES  
       
    26 // CONSTANTS
       
    27 // MACROS
       
    28 // LOCAL CONSTANTS AND MACROS
       
    29 // MODULE DATA STRUCTURES
       
    30 // LOCAL FUNCTION PROTOTYPES
       
    31 // FORWARD DECLARATIONS
       
    32 
       
    33 // ============================= LOCAL FUNCTIONS ===============================
       
    34 
       
    35 
       
    36 // ============================ MEMBER FUNCTIONS ===============================
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // CDcfEntry::CDcfEntry
       
    40 // C++ default constructor can NOT contain any code, that
       
    41 // might leave.
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 CDcfEntry::CDcfEntry():iCid(NULL),iFileName(NULL),iPosition(0),iGroupId(NULL)
       
    45     {
       
    46     }
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CDcfEntry::ConstructL
       
    50 // Symbian 2nd phase constructor can leave.
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 void CDcfEntry::ConstructL()
       
    54     {
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CDcfEntry::NewL
       
    59 // Two-phased constructor.
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 EXPORT_C CDcfEntry* CDcfEntry::NewL()
       
    63     {
       
    64     CDcfEntry* self = new( ELeave ) CDcfEntry;
       
    65     
       
    66     CleanupStack::PushL( self );
       
    67     self->ConstructL();
       
    68     CleanupStack::Pop(self);
       
    69     return self;
       
    70     }
       
    71 
       
    72     
       
    73 // Destructor
       
    74 EXPORT_C CDcfEntry::~CDcfEntry()
       
    75     {
       
    76     delete iGroupId;
       
    77     delete iCid;    
       
    78     delete iFileName;    
       
    79     }
       
    80 
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CDcfEntry::SetCidL
       
    84 // Set content ID
       
    85 // (other items were commented in a header).
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 EXPORT_C void CDcfEntry::SetCidL(const TDesC8& aCid)
       
    89     {
       
    90     if(iCid)
       
    91         {
       
    92         delete iCid; 
       
    93         iCid = NULL;   
       
    94         }
       
    95     iCid = HBufC8::NewL(aCid.Length());
       
    96     TPtr8 ptr(iCid->Des());
       
    97     ptr.Copy(aCid);
       
    98     }
       
    99 
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CDcfEntry::SetGroupIdL
       
   103 // Set group ID
       
   104 // (other items were commented in a header).
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 EXPORT_C void CDcfEntry::SetGroupIdL(const TDesC8& aGroupId)
       
   108     {
       
   109     if(iGroupId)
       
   110         {
       
   111         delete iGroupId;    
       
   112         iGroupId = NULL;
       
   113         }
       
   114     iGroupId = HBufC8::NewL(aGroupId.Length());
       
   115     TPtr8 ptr(iGroupId->Des());
       
   116     ptr.Copy(aGroupId);
       
   117     }
       
   118 
       
   119     
       
   120 // -----------------------------------------------------------------------------
       
   121 // CDcfEntry::SetLocationL
       
   122 // Set file name and position inside the file
       
   123 // (other items were commented in a header).
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 EXPORT_C void CDcfEntry::SetLocationL(const TDesC& aFile, const TUint16& aPos)
       
   127     {
       
   128     if(iFileName)
       
   129         {
       
   130         delete iFileName;    
       
   131         iFileName = NULL;
       
   132         }
       
   133     iFileName = HBufC::NewL(aFile.Length());
       
   134     TPtr ptr(iFileName->Des());
       
   135     ptr.Copy(aFile);
       
   136     iPosition = aPos;    
       
   137     }    
       
   138     
       
   139 // -----------------------------------------------------------------------------
       
   140 // CDcfEntry::FileName
       
   141 // return filename
       
   142 // (other items were commented in a header).
       
   143 // -----------------------------------------------------------------------------
       
   144 //
       
   145 EXPORT_C const TDesC16& CDcfEntry::FileName() const
       
   146     {
       
   147     if (iFileName)
       
   148         {
       
   149         return *iFileName;    
       
   150         }
       
   151     else
       
   152         {
       
   153         return KNullDesC;        
       
   154         }
       
   155     }   
       
   156     
       
   157 // -----------------------------------------------------------------------------
       
   158 // CDcfEntry::Position
       
   159 // return position inside the file
       
   160 // (other items were commented in a header).
       
   161 // -----------------------------------------------------------------------------
       
   162 //
       
   163 EXPORT_C TUint16 CDcfEntry::Position() const
       
   164     {
       
   165     return iPosition;
       
   166     }     
       
   167 
       
   168 // -----------------------------------------------------------------------------
       
   169 // CDcfEntry::Cid
       
   170 // return content ID
       
   171 // (other items were commented in a header).
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 EXPORT_C const TDesC8& CDcfEntry::Cid() const
       
   175     {
       
   176     if (iCid)
       
   177         {
       
   178         return *iCid;  
       
   179         }
       
   180     else
       
   181         {
       
   182         return KNullDesC8;        
       
   183         }
       
   184     
       
   185     } 
       
   186     
       
   187     
       
   188 // -----------------------------------------------------------------------------
       
   189 // CDcfEntry::GroupId
       
   190 // return group ID
       
   191 // (other items were commented in a header).
       
   192 // -----------------------------------------------------------------------------
       
   193 //
       
   194 EXPORT_C const TDesC8& CDcfEntry::GroupId() const
       
   195     {
       
   196     if (iGroupId)
       
   197         {
       
   198         return *iGroupId;  
       
   199         }
       
   200     else
       
   201         {
       
   202         return KNullDesC8;        
       
   203         }
       
   204     
       
   205     } 
       
   206 
       
   207 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   208 
       
   209 //  End of File