serviceproviders/sapi_mediamanagement/src/mgmediaitem.cpp
changeset 19 989d2f495d90
child 22 fc9cf246af83
equal deleted inserted replaced
14:a36b1e19a461 19:989d2f495d90
       
     1 /*
       
     2 * Copyright (c) 2007-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 the License "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:  Holds information common to all media types
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <mclfitem.h>
       
    20 #include <pathinfo.h>
       
    21 #include <liwvariant.h>
       
    22 
       
    23 
       
    24 #include "mgmediaitem.h"
       
    25 
       
    26 // Keys // used by service class and iterator
       
    27 _LIT8( KMgFileName, "FileName" );
       
    28 _LIT8( KMgFileExtension, "FileExtension" );
       
    29 _LIT8( KMgDrive, "Drive" );
       
    30 _LIT8( KMgFileSize, "FileSize" );
       
    31 _LIT8( KMgFileDate, "FileDate" );
       
    32 _LIT8( KMgMediaType, "MediaType" );
       
    33 _LIT8( KMgMimeType, "MimeType" ); 
       
    34 _LIT8( KType, "Type");
       
    35 
       
    36 _LIT( EMgPhoneMemory,"C:" );
       
    37 _LIT( EMgMmc,"E:" );
       
    38 _LIT( KMediaType, "Media");
       
    39 const TInt KMemoryNameLength = 2;
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 // CMgMediaItem::FillCommonAttributesL
       
    43 // Fills the attributes common to all media types
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 
       
    47 void CMgMediaItem::FillCommonAttributesL(CLiwDefaultMap* aOutputMap, const MCLFItem& aClfItem) 
       
    48     {
       
    49     
       
    50     TPtrC fullName; 
       
    51     TPtrC name;
       
    52     TPtrC ext;
       
    53     TTime time;
       
    54     TBuf<KMemoryNameLength> memory;
       
    55     TInt32 size;
       
    56     TPtrC mimeType;
       
    57     TInt32 mediaType;
       
    58     
       
    59     if( KErrNone == aClfItem.GetField( ECLFFieldIdFileNameAndPath, fullName ) )
       
    60                                                         
       
    61         {
       
    62         name.Set( TParsePtrC( fullName ).Name() );
       
    63         ext.Set( TParsePtrC( fullName ).Ext() ); 
       
    64         if( fullName.Length() > 0 )
       
    65             {
       
    66             TCharF mmcMemory( PathInfo::MemoryCardRootPath()[0] );
       
    67             TCharF itemPath( fullName[0] );
       
    68             if( mmcMemory == itemPath )
       
    69                 { // by default phone memory
       
    70                 memory = EMgMmc; 
       
    71                 }
       
    72             else
       
    73                 {
       
    74             	memory = EMgPhoneMemory;
       
    75                 }
       
    76             }
       
    77         }
       
    78         
       
    79     aClfItem.GetField( ECLFFieldIdMimeType, mimeType );
       
    80     aClfItem.GetField( ECLFFieldIdFileSize, size );
       
    81     aClfItem.GetField( ECLFFieldIdFileDate, time );
       
    82     aClfItem.GetField( ECLFFieldIdMediaType, mediaType );
       
    83      
       
    84     // insert all above attribute in map 
       
    85     aOutputMap->InsertL( KType, TLiwVariant( KMediaType ) );
       
    86     aOutputMap->InsertL( KMgFileName, TLiwVariant( name ) );
       
    87     aOutputMap->InsertL( KMgFileExtension, TLiwVariant( ext ) );
       
    88     aOutputMap->InsertL( KMgDrive,TLiwVariant( memory ) );
       
    89     aOutputMap->InsertL( KMgMimeType,TLiwVariant( mimeType ) );
       
    90     aOutputMap->InsertL( KMgMediaType,TLiwVariant( mediaType ) );
       
    91     aOutputMap->InsertL( KMgFileDate,TLiwVariant( time ) );
       
    92     aOutputMap->InsertL( KMgFileSize,TLiwVariant( size ) );
       
    93     
       
    94     }
       
    95 
       
    96 
       
    97 
       
    98 
       
    99