filemanager/bkupengine/src/CMMCScBkupFileInfo.cpp
changeset 0 6a9f87576119
equal deleted inserted replaced
-1:000000000000 0:6a9f87576119
       
     1 /*
       
     2 * Copyright (c) 2005 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: CMMCScBkupFileInfo implementation
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 #include "CMMCScBkupFileInfo.h"
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 // ========================= MEMBER FUNCTIONS ================================
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // CMMCScBkupFileInfo::CMMCScBkupFileInfo()
       
    28 // 
       
    29 // C++ constructor.
       
    30 // ---------------------------------------------------------------------------
       
    31 CMMCScBkupFileInfo::CMMCScBkupFileInfo()
       
    32     {
       
    33     }
       
    34 
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // CMMCScBkupFileInfo::CMMCScBkupFileInfo()
       
    38 // 
       
    39 // C++ constructor.
       
    40 // ---------------------------------------------------------------------------
       
    41 CMMCScBkupFileInfo::CMMCScBkupFileInfo( const TEntry& aEntry, TSecureId aAssociatedSID )
       
    42 :   iSecureId(aAssociatedSID)
       
    43     {
       
    44     iSize = aEntry.iSize;
       
    45     iDateTime = aEntry.iModified;
       
    46     iAttributes = aEntry.iAtt;
       
    47     }
       
    48 
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // CMMCScBkupFileInfo::~CMMCScBkupFileInfo()
       
    52 // 
       
    53 // Destructor.
       
    54 // ---------------------------------------------------------------------------
       
    55 CMMCScBkupFileInfo::~CMMCScBkupFileInfo()
       
    56     {
       
    57     delete iFileName;
       
    58     }
       
    59 
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // CMMCScBkupFileInfo::ConstructL()
       
    63 // 
       
    64 // 
       
    65 // ---------------------------------------------------------------------------
       
    66 void CMMCScBkupFileInfo::ConstructL( const TEntry& aEntry )
       
    67     {
       
    68     iFileName = aEntry.iName.AllocL();
       
    69     }
       
    70 
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CMMCScBkupFileInfo::NewL()
       
    74 // 
       
    75 // 
       
    76 // ---------------------------------------------------------------------------
       
    77 CMMCScBkupFileInfo* CMMCScBkupFileInfo::NewL( const TEntry& aEntry, TSecureId aAssociatedSID )
       
    78     {
       
    79     CMMCScBkupFileInfo* self = NewLC( aEntry, aAssociatedSID );
       
    80     CleanupStack::Pop(self);
       
    81     return self;
       
    82     }
       
    83 
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // CMMCScBkupFileInfo::NewLC()
       
    87 // 
       
    88 // 
       
    89 // ---------------------------------------------------------------------------
       
    90 CMMCScBkupFileInfo* CMMCScBkupFileInfo::NewLC( const TEntry& aEntry, TSecureId aAssociatedSID )
       
    91     {
       
    92     CMMCScBkupFileInfo* self = new(ELeave) CMMCScBkupFileInfo( aEntry, aAssociatedSID );
       
    93     CleanupStack::PushL(self);
       
    94     self->ConstructL(aEntry);
       
    95     return self;
       
    96     }
       
    97 
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // CMMCScBkupFileInfo::NewLC()
       
   101 // 
       
   102 // 
       
   103 // ---------------------------------------------------------------------------
       
   104 CMMCScBkupFileInfo* CMMCScBkupFileInfo::NewLC( RReadStream& aStream )
       
   105     {
       
   106     CMMCScBkupFileInfo* self = new(ELeave) CMMCScBkupFileInfo();
       
   107     CleanupStack::PushL(self);
       
   108     aStream >> *self;
       
   109     return self;
       
   110     }
       
   111 
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // CMMCScBkupFileInfo::Drive()
       
   115 // 
       
   116 // 
       
   117 // ---------------------------------------------------------------------------
       
   118 TDriveNumber CMMCScBkupFileInfo::Drive() const
       
   119     {
       
   120     const TDriveUnit driveUnit( FileName() );
       
   121     const TDriveNumber drive = static_cast< TDriveNumber > ( driveUnit.operator TInt() );
       
   122     //
       
   123     return drive;
       
   124     }
       
   125 
       
   126 
       
   127 // ---------------------------------------------------------------------------
       
   128 // CMMCScBkupFileInfo::InternalizeL()
       
   129 // 
       
   130 // 
       
   131 // ---------------------------------------------------------------------------
       
   132 void CMMCScBkupFileInfo::InternalizeL(RReadStream& aStream)
       
   133     {
       
   134     aStream.ReadInt32L(); // EStreamFormatVersion1 
       
   135     aStream.ReadInt32L(); // spare1
       
   136     aStream.ReadInt32L(); // spare2
       
   137     aStream.ReadInt32L(); // spare3
       
   138     //
       
   139     HBufC* fileName = HBufC::NewL(aStream, KMaxFileName);
       
   140     delete iFileName;
       
   141     iFileName = fileName;
       
   142     //
       
   143     TInt64 intermediateDateTime;
       
   144     aStream >> intermediateDateTime;
       
   145     iDateTime = TTime(intermediateDateTime);
       
   146     //
       
   147     TUid intermediateSID;
       
   148     aStream >> intermediateSID;
       
   149     iSecureId = intermediateSID;
       
   150     //
       
   151     iSize = aStream.ReadInt32L();
       
   152     iAttributes = aStream.ReadUint32L();
       
   153     }
       
   154 
       
   155 
       
   156 // ---------------------------------------------------------------------------
       
   157 // CMMCScBkupFileInfo::ExternalizeL()
       
   158 // 
       
   159 // 
       
   160 // ---------------------------------------------------------------------------
       
   161 void CMMCScBkupFileInfo::ExternalizeL(RWriteStream& aStream) const
       
   162     {
       
   163     aStream.WriteInt32L( EStreamFormatVersion1 );
       
   164     aStream.WriteInt32L( 0 ); // spare1
       
   165     aStream.WriteInt32L( 0 ); // spare2
       
   166     aStream.WriteInt32L( 0 ); // spare3
       
   167     //
       
   168     aStream << *iFileName;
       
   169     aStream << iDateTime.Int64();
       
   170     aStream << iSecureId.operator TUid();
       
   171     aStream.WriteInt32L(iSize);
       
   172     aStream.WriteUint32L(iAttributes);
       
   173     }
       
   174 
       
   175 
       
   176 // ---------------------------------------------------------------------------
       
   177 // CMMCScBkupFileInfo::OrderByFileName()
       
   178 // 
       
   179 // 
       
   180 // ---------------------------------------------------------------------------
       
   181 TInt CMMCScBkupFileInfo::OrderByFileName(const CMMCScBkupFileInfo& aLeft, const CMMCScBkupFileInfo& aRight)
       
   182     {
       
   183     const TPtrC pLeft(aLeft.FileName());
       
   184     const TPtrC pRight(aRight.FileName());
       
   185     //
       
   186     const TInt ret = pLeft.Compare(pRight);
       
   187     //
       
   188     return ret;
       
   189     }
       
   190 
       
   191 
       
   192 // ---------------------------------------------------------------------------
       
   193 // CMMCScBkupFileInfo::CompareByFileName()
       
   194 // 
       
   195 // 
       
   196 // ---------------------------------------------------------------------------
       
   197 TBool CMMCScBkupFileInfo::CompareByFileName(const CMMCScBkupFileInfo& aLeft, const CMMCScBkupFileInfo& aRight)
       
   198     {
       
   199     const TPtrC pLeft(aLeft.FileName());
       
   200     const TPtrC pRight(aRight.FileName());
       
   201     //
       
   202     const TBool same = (pLeft.Compare(pRight) == 0);
       
   203     return same;
       
   204     }
       
   205