filemanager/GFLM/src/CGflmDriveItem.cpp
changeset 0 6a9f87576119
equal deleted inserted replaced
-1:000000000000 0:6a9f87576119
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:  Drive item definitions
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CGflmDriveItem.h"
       
    22 #include "GflmUtils.h"
       
    23 
       
    24 
       
    25 // ============================ MEMBER FUNCTIONS ===============================
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // CGflmDriveItem::CGflmDriveItem
       
    29 // C++ default constructor can NOT contain any code, that
       
    30 // might leave.
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CGflmDriveItem::CGflmDriveItem(
       
    34         const TInt aDrive,
       
    35         const TVolumeInfo& aVolume,
       
    36         const TInt aVolumeStatus,
       
    37         const TUint aDriveStatus )
       
    38         : iVolume( aVolume ),
       
    39           iDrive( aDrive ),
       
    40           iVolumeStatus( aVolumeStatus ),
       
    41           iDriveStatus( aDriveStatus )
       
    42     {
       
    43     }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CGflmDriveItem::NewL
       
    47 // Two-phased constructor.
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 CGflmDriveItem* CGflmDriveItem::NewLC(
       
    51         const TInt aDrive,
       
    52         const TVolumeInfo& aVolume,
       
    53         const TInt aVolumeStatus,
       
    54         const TUint aDriveStatus )
       
    55     {
       
    56     CGflmDriveItem* self = new( ELeave ) CGflmDriveItem(
       
    57         aDrive,
       
    58         aVolume,
       
    59         aVolumeStatus,
       
    60         aDriveStatus );
       
    61 
       
    62     CleanupStack::PushL( self );
       
    63     self->ConstructL();
       
    64 
       
    65     return self;
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CGflmDriveItem::ConstructL
       
    70 //
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 void CGflmDriveItem::ConstructL()
       
    74     {
       
    75     SetRootDirectoryL( TDriveUnit( iDrive ).Name() );
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CGflmDriveItem::~CGflmDriveItem
       
    80 //
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 CGflmDriveItem::~CGflmDriveItem()
       
    84     {
       
    85     delete iLocalizedName;
       
    86     delete iRootDir;
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CGflmDriveItem::Type
       
    91 //
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 CGflmGroupItem::TGflmItemType CGflmDriveItem::Type() const
       
    95     {
       
    96     return EDrive;
       
    97     }
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // CGflmDriveItem::Name
       
   101 //
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 TPtrC CGflmDriveItem::Name() const
       
   105     {
       
   106     if ( iLocalizedName )
       
   107         {
       
   108         return iLocalizedName->Des();
       
   109         }
       
   110     return TPtrC( iVolume.iName );
       
   111     }
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CGflmDriveItem::Date
       
   115 //
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 TTime CGflmDriveItem::Date() const
       
   119     {
       
   120     return TTime( 0 );
       
   121     }
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // CGflmDriveItem::Size
       
   125 //
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 TInt64 CGflmDriveItem::Size() const
       
   129     {
       
   130     return 0;
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // CGflmDriveItem::Ext
       
   135 //
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 TPtrC CGflmDriveItem::Ext() const
       
   139     {
       
   140     return TPtrC( KNullDesC );
       
   141     }
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // CGflmDriveItem::SetLocalizedNameL
       
   145 //
       
   146 // -----------------------------------------------------------------------------
       
   147 //
       
   148 EXPORT_C void CGflmDriveItem::SetLocalizedNameL( const TDesC& aName )
       
   149     {
       
   150     HBufC* temp = aName.AllocL();
       
   151     delete iLocalizedName;
       
   152     iLocalizedName = temp;
       
   153     }
       
   154 
       
   155 // -----------------------------------------------------------------------------
       
   156 // CGflmDriveItem::SetRootDirectoryL
       
   157 //
       
   158 // -----------------------------------------------------------------------------
       
   159 //
       
   160 EXPORT_C void CGflmDriveItem::SetRootDirectoryL( const TDesC& aPath )
       
   161     {
       
   162     const TInt KFmgrBackslashSpace = 1;
       
   163     TInt len( aPath.Length() );
       
   164     HBufC* temp = HBufC::NewL( len + KFmgrBackslashSpace );
       
   165     TPtr ptr( temp->Des() );
       
   166     ptr.Copy( aPath );
       
   167     GflmUtils::EnsureFinalBackslash( ptr );
       
   168     delete iRootDir;
       
   169     iRootDir = temp;
       
   170     }
       
   171 
       
   172 // -----------------------------------------------------------------------------
       
   173 // CGflmDriveItem::RootDirectory
       
   174 //
       
   175 // -----------------------------------------------------------------------------
       
   176 //
       
   177 EXPORT_C TPtrC CGflmDriveItem::RootDirectory() const
       
   178     {
       
   179     return iRootDir->Des();
       
   180     }
       
   181 
       
   182 // -----------------------------------------------------------------------------
       
   183 // CGflmDriveItem::GetVolumeInfo
       
   184 //
       
   185 // -----------------------------------------------------------------------------
       
   186 //
       
   187 EXPORT_C const TVolumeInfo& CGflmDriveItem::VolumeInfo() const
       
   188     {
       
   189     return iVolume;
       
   190     }
       
   191 
       
   192 // -----------------------------------------------------------------------------
       
   193 // CGflmDriveItem::Drive
       
   194 //
       
   195 // -----------------------------------------------------------------------------
       
   196 //
       
   197 EXPORT_C TInt CGflmDriveItem::Drive() const
       
   198     {
       
   199     return iDrive;
       
   200     }
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // CGflmDriveItem::VolumeStatus
       
   204 //
       
   205 // -----------------------------------------------------------------------------
       
   206 //
       
   207 EXPORT_C TInt CGflmDriveItem::VolumeStatus() const
       
   208     {
       
   209     return iVolumeStatus;
       
   210     }
       
   211 
       
   212 // -----------------------------------------------------------------------------
       
   213 // CGflmDriveItem::DriveStatus
       
   214 //
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 EXPORT_C TUint CGflmDriveItem::DriveStatus() const
       
   218     {
       
   219     return iDriveStatus;
       
   220     }
       
   221 
       
   222 //  End of File