harvester/harvesterplugins/WMVPlugin/src/harvesterwmvplugin.cpp
branchRCL_3
changeset 63 e538444823de
parent 47 b73252188534
equal deleted inserted replaced
57:2872ae438bf7 63:e538444823de
    29 #include <mdeobjectdef.h>
    29 #include <mdeobjectdef.h>
    30 #include "mdeobject.h"
    30 #include "mdeobject.h"
    31 #include "mdetextproperty.h"
    31 #include "mdetextproperty.h"
    32 #include "mdeobjectwrapper.h"
    32 #include "mdeobjectwrapper.h"
    33 
    33 
    34 CHarvesterWmvPluginPropertyDefs::CHarvesterWmvPluginPropertyDefs() : CBase(),
    34 CHarvesterWmvPluginPropertyDefs::CHarvesterWmvPluginPropertyDefs() : CBase()
    35     iCreationDatePropertyDef( NULL )
       
    36 	{
    35 	{
    37 	}
    36 	}
    38 
    37 
    39 void CHarvesterWmvPluginPropertyDefs::ConstructL( CMdEObjectDef& aObjectDef )
    38 void CHarvesterWmvPluginPropertyDefs::ConstructL(CMdEObjectDef& aObjectDef)
    40     {
       
    41     SetByObjectDefL( aObjectDef );
       
    42     }
       
    43 
       
    44 CHarvesterWmvPluginPropertyDefs* CHarvesterWmvPluginPropertyDefs::NewL()
       
    45     {
       
    46     CHarvesterWmvPluginPropertyDefs* self = 
       
    47         new (ELeave) CHarvesterWmvPluginPropertyDefs();
       
    48     return self;
       
    49     }
       
    50 
       
    51 void CHarvesterWmvPluginPropertyDefs::SetByObjectDefL( CMdEObjectDef& aObjectDef )
       
    52 	{
    39 	{
    53 	CMdENamespaceDef& nsDef = aObjectDef.NamespaceDef();
    40 	CMdENamespaceDef& nsDef = aObjectDef.NamespaceDef();
    54 	
    41 	
    55 	// Common property definitions
    42 	// Common property definitions
    56 	CMdEObjectDef& objectDef = nsDef.GetObjectDefL( MdeConstants::Object::KBaseObject );
    43 	CMdEObjectDef& objectDef = nsDef.GetObjectDefL( MdeConstants::Object::KBaseObject );
    66     iDescriptionPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDescriptionProperty );
    53     iDescriptionPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDescriptionProperty );
    67     iAuthorPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KAuthorProperty );
    54     iAuthorPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KAuthorProperty );
    68     iGenrePropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KGenreProperty );
    55     iGenrePropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KGenreProperty );
    69 	}
    56 	}
    70 
    57 
       
    58 CHarvesterWmvPluginPropertyDefs* CHarvesterWmvPluginPropertyDefs::NewL(CMdEObjectDef& aObjectDef)
       
    59 	{
       
    60 	CHarvesterWmvPluginPropertyDefs* self = 
       
    61 		new (ELeave) CHarvesterWmvPluginPropertyDefs();
       
    62 	CleanupStack::PushL( self );
       
    63 	self->ConstructL( aObjectDef );
       
    64 	CleanupStack::Pop( self );
       
    65 	return self;
       
    66 	}
       
    67 
    71 // ======== MEMBER FUNCTIONS ========
    68 // ======== MEMBER FUNCTIONS ========
    72 
    69 
    73 // ---------------------------------------------------------------------------
    70 // ---------------------------------------------------------------------------
    74 // Constructor
    71 // Constructor
    75 // ---------------------------------------------------------------------------
    72 // ---------------------------------------------------------------------------
    90 //
    87 //
    91 CHarvesterWMVPlugin::~CHarvesterWMVPlugin()
    88 CHarvesterWMVPlugin::~CHarvesterWMVPlugin()
    92     {
    89     {
    93     WRITELOG( "CHarvesterWMVPlugin::~CHarvesterWMVPlugin()" );
    90     WRITELOG( "CHarvesterWMVPlugin::~CHarvesterWMVPlugin()" );
    94     delete iPropDefs;
    91     delete iPropDefs;
    95     iPropDefs = NULL;
       
    96     
    92     
    97     delete iPhoneVideosPath;
    93     delete iPhoneVideosPath;
    98     iPhoneVideosPath = NULL;
       
    99     delete iMmcVideosPath;
    94     delete iMmcVideosPath;
   100     iMmcVideosPath = NULL;
       
   101     }
    95     }
   102 
    96 
   103 // ---------------------------------------------------------------------------
    97 // ---------------------------------------------------------------------------
   104 // Harvest file
    98 // Harvest file
   105 // ---------------------------------------------------------------------------
    99 // ---------------------------------------------------------------------------
   155     TRAPD( err, content = ContentAccess::CContent::NewL( aUri ) );
   149     TRAPD( err, content = ContentAccess::CContent::NewL( aUri ) );
   156     if (err == KErrNone) 
   150     if (err == KErrNone) 
   157         {
   151         {
   158         err = content->GetStringAttribute( ContentAccess::EMimeType, aMimeType );
   152         err = content->GetStringAttribute( ContentAccess::EMimeType, aMimeType );
   159         delete content;
   153         delete content;
   160         content = NULL;
       
   161         }
   154         }
   162     }
   155     }
   163 
   156 
   164 // ---------------------------------------------------------------------------
   157 // ---------------------------------------------------------------------------
   165 // Default constructor
   158 // Default constructor
   174 // ---------------------------------------------------------------------------
   167 // ---------------------------------------------------------------------------
   175 //
   168 //
   176 void CHarvesterWMVPlugin::ConstructL()
   169 void CHarvesterWMVPlugin::ConstructL()
   177     {
   170     {
   178     WRITELOG( "CHarvesterWMVPlugin::ConstructL()" );
   171     WRITELOG( "CHarvesterWMVPlugin::ConstructL()" );
   179     
       
   180     iPropDefs = CHarvesterWmvPluginPropertyDefs::NewL();
       
   181     
   172     
   182     TFileName videos = PathInfo::VideosPath();
   173     TFileName videos = PathInfo::VideosPath();
   183     
   174     
   184     TFileName phonePath = PathInfo::PhoneMemoryRootPath();
   175     TFileName phonePath = PathInfo::PhoneMemoryRootPath();
   185     phonePath.Append( videos );
   176     phonePath.Append( videos );
   301     {
   292     {
   302     WRITELOG( "CHarvesterWMVPlugin::HandleObjectPropertiesL()" );
   293     WRITELOG( "CHarvesterWMVPlugin::HandleObjectPropertiesL()" );
   303     
   294     
   304     CMdEObject& mdeObject = aHD.MdeObject();
   295     CMdEObject& mdeObject = aHD.MdeObject();
   305     
   296     
   306     InitPropDefsL( mdeObject.Def() );
   297     if( !iPropDefs )
       
   298 		{
       
   299 		CMdEObjectDef& objectDef = mdeObject.Def();
       
   300 		iPropDefs = CHarvesterWmvPluginPropertyDefs::NewL( objectDef );
       
   301 		// Prefetch max text lengt for validity checking
       
   302 		iMaxTextLength = iPropDefs->iGenrePropertyDef->MaxTextLengthL();
       
   303 		}
   307     
   304     
   308     if( ! mdeObject.Placeholder() )
   305     if( ! mdeObject.Placeholder() )
   309     	{
   306     	{
   310         // Creation date
   307         // Creation date
   311     	TTimeIntervalSeconds timeOffset = User::UTCOffset();
   308     	TTimeIntervalSeconds timeOffset = User::UTCOffset();
   367         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   364         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   368                 *iPropDefs->iGenrePropertyDef, &aClipDetails.iGenre, aIsAdd );
   365                 *iPropDefs->iGenrePropertyDef, &aClipDetails.iGenre, aIsAdd );
   369         }   
   366         }   
   370     }
   367     }
   371 
   368 
   372 void CHarvesterWMVPlugin::InitPropDefsL(CMdEObjectDef& aObjectDef)
       
   373     {
       
   374     if( !iPropDefs->iCreationDatePropertyDef )
       
   375         {
       
   376         iPropDefs->SetByObjectDefL( aObjectDef );
       
   377         // Prefetch max text lengt for validity checking
       
   378         iMaxTextLength = iPropDefs->iGenrePropertyDef->MaxTextLengthL();
       
   379         }
       
   380     }
       
   381