serviceproviders/sapi_mediamanagement/src/mgmediaitem.cpp
author Pat Downey <patrick.downey@nokia.com>
Fri, 03 Jul 2009 15:51:24 +0100
changeset 5 989d2f495d90
child 10 fc9cf246af83
permissions -rw-r--r--
Revision: 200923 Kit: 200925

/*
* Copyright (c) 2007-2007 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Holds information common to all media types
*
*/


#include <mclfitem.h>
#include <pathinfo.h>
#include <liwvariant.h>


#include "mgmediaitem.h"

// Keys // used by service class and iterator
_LIT8( KMgFileName, "FileName" );
_LIT8( KMgFileExtension, "FileExtension" );
_LIT8( KMgDrive, "Drive" );
_LIT8( KMgFileSize, "FileSize" );
_LIT8( KMgFileDate, "FileDate" );
_LIT8( KMgMediaType, "MediaType" );
_LIT8( KMgMimeType, "MimeType" ); 
_LIT8( KType, "Type");

_LIT( EMgPhoneMemory,"C:" );
_LIT( EMgMmc,"E:" );
_LIT( KMediaType, "Media");
const TInt KMemoryNameLength = 2;

// ---------------------------------------------------------------------------
// CMgMediaItem::FillCommonAttributesL
// Fills the attributes common to all media types
// ---------------------------------------------------------------------------
//

void CMgMediaItem::FillCommonAttributesL(CLiwDefaultMap* aOutputMap, const MCLFItem& aClfItem) 
    {
    
    TPtrC fullName; 
    TPtrC name;
    TPtrC ext;
    TTime time;
    TBuf<KMemoryNameLength> memory;
    TInt32 size;
    TPtrC mimeType;
    TInt32 mediaType;
    
    if( KErrNone == aClfItem.GetField( ECLFFieldIdFileNameAndPath, fullName ) )
                                                        
        {
        name.Set( TParsePtrC( fullName ).Name() );
        ext.Set( TParsePtrC( fullName ).Ext() ); 
        if( fullName.Length() > 0 )
            {
            TCharF mmcMemory( PathInfo::MemoryCardRootPath()[0] );
            TCharF itemPath( fullName[0] );
            if( mmcMemory == itemPath )
                { // by default phone memory
                memory = EMgMmc; 
                }
            else
                {
            	memory = EMgPhoneMemory;
                }
            }
        }
        
    aClfItem.GetField( ECLFFieldIdMimeType, mimeType );
    aClfItem.GetField( ECLFFieldIdFileSize, size );
    aClfItem.GetField( ECLFFieldIdFileDate, time );
    aClfItem.GetField( ECLFFieldIdMediaType, mediaType );
     
    // insert all above attribute in map 
    aOutputMap->InsertL( KType, TLiwVariant( KMediaType ) );
    aOutputMap->InsertL( KMgFileName, TLiwVariant( name ) );
    aOutputMap->InsertL( KMgFileExtension, TLiwVariant( ext ) );
    aOutputMap->InsertL( KMgDrive,TLiwVariant( memory ) );
    aOutputMap->InsertL( KMgMimeType,TLiwVariant( mimeType ) );
    aOutputMap->InsertL( KMgMediaType,TLiwVariant( mediaType ) );
    aOutputMap->InsertL( KMgFileDate,TLiwVariant( time ) );
    aOutputMap->InsertL( KMgFileSize,TLiwVariant( size ) );
    
    }