mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp
changeset 0 d0791faffa3f
child 2 4843bb5893b6
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalTechnology
       
    19 */
       
    20 
       
    21 #include <e32cmn.h>
       
    22 #include <centralrepository.h>
       
    23 #include <mtp/tmtptyperequest.h>
       
    24 #include <mtp/cmtpstoragemetadata.h>
       
    25 #include <mtp/cmtpobjectmetadata.h>
       
    26 #include <mtp/mmtpconnection.h>
       
    27 #include <mtp/mmtpdataproviderframework.h>
       
    28 #include <mtp/mtpdataproviderapitypes.h>
       
    29 #include <mtp/mtpprotocolconstants.h>
       
    30 #include <mtp/mmtpobjectmgr.h>
       
    31 #include <mtp/mmtpstoragemgr.h>
       
    32 #include <mtp/tmtptypeevent.h>
       
    33 
       
    34 #include "cmtpimagedp.h"
       
    35 #include "mtpimagedpconst.h"
       
    36 #include "mtpimagedppanic.h"
       
    37 #include "cmtprequestprocessor.h"
       
    38 #include "mtpimagedprequestprocessor.h"
       
    39 #include "cmtpimagedpthumbnailcreator.h"
       
    40 #include "mtpimagedputilits.h"
       
    41 #include "cmtpimagedpmdeobserver.h"
       
    42 #include "cmtpimagedprenameobject.h"
       
    43 
       
    44 __FLOG_STMT(_LIT8(KComponent,"CMTPImageDataProvider");)
       
    45 
       
    46 static const TInt KArrayGranularity = 3;
       
    47 static const TInt KDeleteObjectGranularity = 2;
       
    48 
       
    49 //used by hashmap & hashset class
       
    50 LOCAL_C TUint32 TBuf16Hash(const TBuf<KMaxExtNameLength>& aPtr)
       
    51     {
       
    52     return DefaultHash::Des16(aPtr);
       
    53     }
       
    54 
       
    55 LOCAL_C TBool TBuf16Ident(const TBuf<KMaxExtNameLength>& aL, const TBuf<KMaxExtNameLength>& aR)
       
    56     {
       
    57     return DefaultIdentity::Des16(aL, aR);
       
    58     }
       
    59 
       
    60 /**
       
    61  Image data provider factory method.
       
    62  @return A pointer to a Image data provider object. Ownership is transfered.
       
    63  @leave One of the system wide error codes, if a processing failure occurs.
       
    64 */
       
    65 TAny* CMTPImageDataProvider::NewL(TAny* aParams)
       
    66     {
       
    67     CMTPImageDataProvider* self = new (ELeave) CMTPImageDataProvider(aParams);
       
    68     CleanupStack::PushL(self);
       
    69     self->ConstructL();
       
    70     CleanupStack::Pop(self);
       
    71     return self;
       
    72     }
       
    73 
       
    74 /**
       
    75  Standard C++ constructor
       
    76  
       
    77  @param aParams  pointer to MMTPDataProviderFramework
       
    78 */
       
    79 CMTPImageDataProvider::CMTPImageDataProvider(TAny* aParams) :
       
    80     CMTPDataProviderPlugin(aParams),
       
    81     iActiveProcessors(KArrayGranularity),
       
    82     iFormatMappings(&TBuf16Hash, &TBuf16Ident),
       
    83     iActiveProcessor(-1),
       
    84     iEnumerated(EFalse),
       
    85 	iDeleteObjectsArray(KDeleteObjectGranularity)
       
    86     {
       
    87     }
       
    88 
       
    89 /**
       
    90 Second-phase construction
       
    91 */
       
    92 void CMTPImageDataProvider::ConstructL()
       
    93     {
       
    94     __FLOG_OPEN(KMTPSubsystem, KComponent);
       
    95     __FLOG(_L8(">> CMTPImageDataProvider::ConstructL"));
       
    96     
       
    97     iPropertyMgr = CMTPImageDpObjectPropertyMgr::NewL(Framework());
       
    98     iThumbnailManager = CMTPImageDpThumbnailCreator::NewL();
       
    99     iMdeObserver = CMTPImageDpMdeObserver::NewL(Framework(), *this);
       
   100     iMdeObserver->SubscribeForChangeNotificationL();
       
   101     
       
   102     //Setup central repository connection
       
   103     const TUint32 KUidMTPImageRepositoryValue(0x2001FCA2);
       
   104     const TUid KUidMTPImageRepository = {KUidMTPImageRepositoryValue};
       
   105     iRepository = CRepository::NewL(KUidMTPImageRepository);    
       
   106     
       
   107     //Initialize hash map of extention to format code
       
   108     TInt count(sizeof(KMTPValidCodeExtensionMappings) / sizeof(KMTPValidCodeExtensionMappings[0]));
       
   109     for(TInt i(0); i<count; i++)
       
   110         {
       
   111         iFormatMappings.Insert(KMTPValidCodeExtensionMappings[i].iExtension, KMTPValidCodeExtensionMappings[i].iFormatCode);
       
   112         }    
       
   113     
       
   114     //Define RProperty of new pictures for status data provider
       
   115     _LIT_SECURITY_POLICY_PASS(KAllowReadAll);
       
   116     TInt error = RProperty::Define(TUid::Uid(KMTPServerUID), KMTPNewPicKey, RProperty::EInt, KAllowReadAll, KAllowReadAll);
       
   117     if (error != KErrNone && error != KErrAlreadyExists)
       
   118         {
       
   119         __FLOG_1(_L8("CMTPImageDataProvider::ConstructL - RProperty define error:%d"), error);
       
   120         User::LeaveIfError(error);
       
   121         }    
       
   122     
       
   123     __FLOG(_L8("<< CMTPImageDataProvider::ConstructL"));
       
   124     }
       
   125 
       
   126 /**
       
   127  Destructor
       
   128 */
       
   129 CMTPImageDataProvider::~CMTPImageDataProvider()
       
   130     {
       
   131     __FLOG(_L8(">> ~CMTPImageDataProvider"));      
       
   132     
       
   133     // delete all processor instances
       
   134     TUint count(iActiveProcessors.Count());
       
   135     while (count--)
       
   136         {
       
   137         iActiveProcessors[count]->Release();
       
   138         }
       
   139     iActiveProcessors.Close();
       
   140      
       
   141     // image dp unsubscribe from MDS
       
   142     if(iMdeObserver)
       
   143         {
       
   144         TRAP_IGNORE(iMdeObserver->UnsubscribeForChangeNotificationL());
       
   145         delete iMdeObserver;
       
   146         }        
       
   147     delete iThumbnailManager;
       
   148     delete iPropertyMgr;       
       
   149     delete iRepository;   
       
   150     delete iRenameObject;
       
   151     
       
   152     iFormatMappings.Close();
       
   153     
       
   154     //Try to delete objects in array
       
   155     HandleDeleteObjectsArray();
       
   156     iDeleteObjectsArray.ResetAndDestroy();
       
   157     
       
   158     __FLOG(_L8("<< ~CMTPImageDataProvider"));
       
   159     __FLOG_CLOSE;
       
   160     }
       
   161 
       
   162 void CMTPImageDataProvider::Cancel()
       
   163     {
       
   164     __FLOG(_L8(">> Cancel"));
       
   165     __FLOG(_L8("<< Cancel"));
       
   166     }
       
   167 
       
   168 /**
       
   169  Process the event from initiator
       
   170  
       
   171  @param aEvent       The event to be processed
       
   172  @param aConnection  The connection from which the event comes
       
   173 */
       
   174 void CMTPImageDataProvider::ProcessEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection)
       
   175     {
       
   176     __FLOG(_L8(">> ProcessEventL"));
       
   177     
       
   178     //Try to delete objects in array
       
   179     HandleDeleteObjectsArray();
       
   180     
       
   181     TInt idx(LocateRequestProcessorL(aEvent, aConnection));
       
   182     
       
   183     if (idx != KErrNotFound)
       
   184         {
       
   185         iActiveProcessors[idx]->HandleEventL(aEvent);
       
   186         }
       
   187 
       
   188     __FLOG(_L8("<< ProcessEventL"));
       
   189     }
       
   190 
       
   191 /**
       
   192 Process the notification from framework
       
   193 @param aNotification  The notification to be processed
       
   194 @param aParams        Notification parmenter
       
   195 */
       
   196 void CMTPImageDataProvider::ProcessNotificationL(TMTPNotification aNotification, const TAny* aParams)
       
   197     {
       
   198     __FLOG(_L8(">> ProcessNotificationL"));
       
   199 
       
   200     switch (aNotification)
       
   201         {
       
   202     case EMTPSessionClosed:
       
   203         SessionClosedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams));
       
   204         break;
       
   205         
       
   206     case EMTPSessionOpened:
       
   207         SessionOpenedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams));
       
   208         break;
       
   209         
       
   210     case EMTPRenameObject:
       
   211         RenameObjectL(*reinterpret_cast<const TMTPNotificationParamsHandle*>(aParams));
       
   212         break;
       
   213         
       
   214     default:
       
   215         // Ignore all other notifications.
       
   216         break;
       
   217         }
       
   218  
       
   219     __FLOG(_L8("<< ProcessNotificationL"));
       
   220     }
       
   221 
       
   222 /**
       
   223  Process the request from initiator
       
   224  
       
   225  @param aPhase       The request transaction phase
       
   226  @param aRequest     The request to be processed
       
   227  @param aConnection  The connection from which the request comes
       
   228 */   
       
   229 void CMTPImageDataProvider::ProcessRequestPhaseL(TMTPTransactionPhase aPhase, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
       
   230     {    
       
   231     __FLOG(_L8(">> ProcessRequestPhaseL"));    
       
   232     
       
   233     //Try to handle objects which need to be deleted
       
   234     HandleDeleteObjectsArray();
       
   235     
       
   236     TInt idx(LocateRequestProcessorL(aRequest, aConnection));
       
   237     __ASSERT_DEBUG((idx != KErrNotFound), Panic(EMTPImageDpNoMatchingProcessor));
       
   238     MMTPRequestProcessor* processor(iActiveProcessors[idx]);
       
   239     iActiveProcessor = idx;
       
   240     iActiveProcessorRemoved = EFalse;    
       
   241     TBool result(processor->HandleRequestL(aRequest, aPhase));
       
   242     if (iActiveProcessorRemoved)
       
   243         {
       
   244         processor->Release(); // destroy the processor
       
   245         }    
       
   246     else if (result)    //destroy the processor
       
   247         {
       
   248         processor->Release();
       
   249         iActiveProcessors.Remove(idx);
       
   250         }
       
   251  
       
   252     iActiveProcessor = -1;
       
   253     __FLOG(_L8("<< ProcessRequestPhaseL"));
       
   254     }
       
   255 
       
   256 /**
       
   257  Starts the enumeration of the image dp
       
   258 */
       
   259 void CMTPImageDataProvider::StartObjectEnumerationL(TUint32 aStorageId, TBool /*aPersistentFullEnumeration*/)
       
   260     {
       
   261     __FLOG(_L8(">> StartObjectEnumerationL"));
       
   262     
       
   263     if (aStorageId == KMTPStorageAll)
       
   264         {
       
   265         /*
       
   266          * Query previous image object count for calculation of new pictures when MTP startup
       
   267          * 
       
   268          */
       
   269         iPrePictures = QueryImageObjectCountL();
       
   270         iEnumerated = ETrue;
       
   271         __FLOG_1(_L16("CMTPImageDpEnumerator::CompleteEnumeration - Previous Pics: %d"), iPrePictures);
       
   272         }
       
   273 
       
   274     NotifyEnumerationCompleteL(aStorageId, KErrNone);
       
   275     
       
   276     __FLOG(_L8("<< StartObjectEnumerationL"));
       
   277     }
       
   278 
       
   279 
       
   280 /**
       
   281 Starts enumerate imagedp storage, just declare complete
       
   282 */
       
   283 void CMTPImageDataProvider::StartStorageEnumerationL()
       
   284     {
       
   285     __FLOG(_L8(">> StartStorageEnumerationL"));   
       
   286     NotifyStorageEnumerationCompleteL();
       
   287     __FLOG(_L8("<< StartStorageEnumerationL"));        
       
   288     }
       
   289 
       
   290 /**
       
   291 Defines the supported operations and formats of the data provider
       
   292 
       
   293 @param aCategory Defines what MTP is quering the DP about
       
   294 @param aArray Supported() edits array to append supported features
       
   295 */
       
   296 void CMTPImageDataProvider::Supported(TMTPSupportCategory aCategory, RArray<TUint>& aArray) const
       
   297     {
       
   298     __FLOG(_L8(">> Supported"));
       
   299 
       
   300     switch (aCategory) 
       
   301         {        
       
   302     case EEvents:
       
   303         {
       
   304         TInt count(sizeof(KMTPImageDpSupportedEvents) / sizeof(KMTPImageDpSupportedEvents[0]));
       
   305         for (TInt i(0); (i < count); i++)
       
   306             {
       
   307             aArray.Append(KMTPImageDpSupportedEvents[i]);
       
   308             __FLOG_VA((_L("   CMTPImageDataProvider::Supported Events %d added"), KMTPImageDpSupportedEvents[i]));
       
   309             }  
       
   310         }
       
   311         break;
       
   312     case EObjectPlaybackFormats: // formats that can be placed on the device
       
   313 	/*intentional fall through*/ 
       
   314     case EObjectCaptureFormats: // formats the device generates
       
   315         {
       
   316         TInt count(sizeof(KMTPValidCodeExtensionMappings) / sizeof(KMTPValidCodeExtensionMappings[0]));
       
   317         for(TInt i(0); (i < count); i++)
       
   318             {
       
   319             __FLOG_VA((_L("   CMTPImageDataProvider::Supported we have formatCode %d"), KMTPValidCodeExtensionMappings[i].iFormatCode ));
       
   320             if(aArray.Find(KMTPValidCodeExtensionMappings[i].iFormatCode)==KErrNotFound) // KMTPValidCodeExtensionMappings may contain format code more than once
       
   321                 {
       
   322                 aArray.Append(KMTPValidCodeExtensionMappings[i].iFormatCode);
       
   323                 __FLOG_VA((_L("   CMTPImageDataProvider::Supported formatCode %d added"), KMTPValidCodeExtensionMappings[i].iFormatCode));
       
   324                 }
       
   325             }
       
   326         }
       
   327         break;
       
   328     case EObjectProperties:
       
   329         {
       
   330         TInt count(sizeof(KMTPImageDpSupportedProperties) / sizeof(KMTPImageDpSupportedProperties[0]));
       
   331         for (TInt i(0); (i < count); i++)
       
   332             {
       
   333             aArray.Append(KMTPImageDpSupportedProperties[i]);
       
   334             __FLOG_VA((_L("   CMTPImageDataProvider::Supported property %d added"), KMTPImageDpSupportedProperties[i]));
       
   335             }   
       
   336         }
       
   337         break; 
       
   338 
       
   339     case EOperations:
       
   340         {
       
   341         TInt count(sizeof(KMTPImageDpSupportedOperations) / sizeof(KMTPImageDpSupportedOperations[0]));
       
   342         for (TInt i(0); (i < count); i++)
       
   343             {
       
   344             aArray.Append(KMTPImageDpSupportedOperations[i]);
       
   345             __FLOG_VA((_L("   CMTPImageDataProvider::Supported operation %d added"), KMTPImageDpSupportedOperations[i]));
       
   346             }   
       
   347         }
       
   348         break;  
       
   349 
       
   350     case EStorageSystemTypes:
       
   351         aArray.Append(CMTPStorageMetaData::ESystemTypeDefaultFileSystem);
       
   352         break; 
       
   353 
       
   354     default:    
       
   355         // Unrecognised category, leave aArray unmodified.
       
   356         break;
       
   357         }
       
   358 
       
   359     __FLOG(_L8("<< Supported"));
       
   360     }
       
   361 
       
   362 /**
       
   363 Defines the supported vendor extension info of the data provider
       
   364 
       
   365 @param aCategory Defines what MTP is quering the DP about
       
   366 @param aStrings Supported() edits array to append supported vendor info
       
   367 */
       
   368 void CMTPImageDataProvider::SupportedL(TMTPSupportCategory aCategory, CDesCArray& aStrings) const
       
   369     {
       
   370     switch (aCategory) 
       
   371         {
       
   372     case EFolderExclusionSets:
       
   373         {
       
   374         //do nothing
       
   375         }
       
   376         break;
       
   377         
       
   378     case EFormatExtensionSets:
       
   379         {
       
   380         _LIT(KFormatExtensionJpg, "0x3801:jpg::3");//3 means file dp will enumerate all image files instead of image dp.
       
   381         aStrings.AppendL(KFormatExtensionJpg);
       
   382         _LIT(KFormatExtensionJpe, "0x3801:jpe::3");
       
   383         aStrings.AppendL(KFormatExtensionJpe);
       
   384         _LIT(KFormatExtensionJpeg, "0x3801:jpeg::3");
       
   385         aStrings.AppendL(KFormatExtensionJpeg);   
       
   386         }
       
   387         break;
       
   388         
       
   389     default:
       
   390         // Unrecognised category, leave aArray unmodified.
       
   391         break;
       
   392         }
       
   393     }
       
   394 
       
   395 /**
       
   396 Notify framework the image dp has completed enumeration
       
   397 */
       
   398 void CMTPImageDataProvider::NotifyStorageEnumerationCompleteL()
       
   399     {
       
   400     __FLOG(_L8(">> NotifyStorageEnumerationCompleteL"));    
       
   401     Framework().StorageEnumerationCompleteL();    
       
   402     __FLOG(_L8("<< NotifyStorageEnumerationCompleteL"));        
       
   403     }
       
   404 
       
   405 CMTPImageDpThumbnailCreator& CMTPImageDataProvider::ThumbnailManager() const
       
   406 	{
       
   407     __ASSERT_DEBUG(iThumbnailManager, User::Invariant());
       
   408 	return *iThumbnailManager;
       
   409 	}
       
   410 
       
   411 CMTPImageDpObjectPropertyMgr& CMTPImageDataProvider::PropertyMgr()const
       
   412 	{
       
   413 	__ASSERT_DEBUG(iPropertyMgr, User::Invariant());
       
   414 	return *iPropertyMgr;	
       
   415 	}
       
   416 
       
   417 CRepository& CMTPImageDataProvider::Repository() const
       
   418     {
       
   419     __ASSERT_DEBUG(iRepository, User::Invariant());
       
   420     return *iRepository;
       
   421     }
       
   422 
       
   423 // --------------------------------------------------------------------------
       
   424 // 
       
   425 // --------------------------------------------------------------------------
       
   426 //
       
   427 #ifdef __FLOG_ACTIVE  
       
   428 void CMTPImageDataProvider::NotifyEnumerationCompleteL(TUint32 aStorageId, TInt aError)
       
   429 #else
       
   430 void CMTPImageDataProvider::NotifyEnumerationCompleteL(TUint32 aStorageId, TInt /*aError*/)
       
   431 #endif // __FLOG_ACTIVE
       
   432     {
       
   433     __FLOG(_L8(">> NotifyEnumerationCompletedL"));
       
   434     __FLOG_VA((_L8("Enumeration of storage 0x%08X completed with error status %d"), aStorageId, aError));
       
   435         
       
   436     Framework().ObjectEnumerationCompleteL(aStorageId);
       
   437     
       
   438     __FLOG(_L8("<< HandleEnumerationCompletedL"));
       
   439     }
       
   440 
       
   441 /**
       
   442 Find or create a request processor that can process the request
       
   443 
       
   444 @param aRequest    The request to be processed
       
   445 @param aConnection The connection from which the request comes
       
   446 
       
   447 @return the index of the found/created request processor
       
   448 */
       
   449 TInt CMTPImageDataProvider::LocateRequestProcessorL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
       
   450     {
       
   451     __FLOG(_L8(">> LocateRequestProcessorL"));        
       
   452     
       
   453     TInt idx(KErrNotFound);
       
   454     TInt count(iActiveProcessors.Count());
       
   455     for (TInt i(0); (i < count); i++)
       
   456         {
       
   457         if (iActiveProcessors[i]->Match(aRequest, aConnection))
       
   458             {
       
   459             idx = i;
       
   460             break;
       
   461             }
       
   462         }
       
   463         
       
   464     if (idx == KErrNotFound)
       
   465         {
       
   466         MMTPRequestProcessor* processor = MTPImageDpProcessor::CreateL(Framework(), aRequest, aConnection,*this);
       
   467         CleanupReleasePushL(*processor);
       
   468         iActiveProcessors.AppendL(processor);
       
   469         CleanupStack::Pop();
       
   470         idx = count;
       
   471         }
       
   472  
       
   473     __FLOG(_L8("<< LocateRequestProcessorL"));
       
   474     return idx;
       
   475     }
       
   476 
       
   477 /**
       
   478 Find or create a request processor that can process the event
       
   479 
       
   480 @param aEvent    The event to be processed
       
   481 @param aConnection The connection from which the request comes
       
   482 
       
   483 @return the index of the found/created request processor
       
   484 */
       
   485 TInt CMTPImageDataProvider::LocateRequestProcessorL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection)
       
   486     {
       
   487     __FLOG(_L8(">> LocateRequestProcessorL"));
       
   488         
       
   489     TInt idx(KErrNotFound);
       
   490     TInt count(iActiveProcessors.Count());
       
   491     for (TInt i(0); (i < count); i++)
       
   492         {
       
   493         if (iActiveProcessors[i]->Match(aEvent, aConnection))
       
   494             {
       
   495             idx = i;
       
   496             break;
       
   497             }
       
   498         }    
       
   499 
       
   500     __FLOG(_L8("<< LocateRequestProcessorL"));
       
   501     return idx;
       
   502     }
       
   503 
       
   504 /**
       
   505  Notify the data provider that the session has been closed
       
   506 
       
   507  @param aSessionId    The session Id closed
       
   508  @param aConnection   The connection of the sesssion
       
   509 */
       
   510 void CMTPImageDataProvider::SessionClosedL(const TMTPNotificationParamsSessionChange& aSession)
       
   511     {
       
   512     __FLOG_VA((_L8(">> SessionClosedL SessionID = %d"), aSession.iMTPId));
       
   513     
       
   514     TInt count = iActiveProcessors.Count();
       
   515     while(count--)
       
   516         {
       
   517         MMTPRequestProcessor* processor = iActiveProcessors[count];
       
   518         TUint32 sessionId = processor->SessionId();
       
   519         if((sessionId == aSession.iMTPId) && (processor->Connection().ConnectionId() == aSession.iConnection.ConnectionId()))
       
   520             {
       
   521             iActiveProcessors.Remove(count);
       
   522             if (count == iActiveProcessor)
       
   523                 {
       
   524                 iActiveProcessorRemoved = ETrue;
       
   525                 }
       
   526             else
       
   527                 {
       
   528                 processor->Release();
       
   529                 }
       
   530             }
       
   531         }
       
   532     
       
   533     __FLOG(_L8("<< SessionClosedL"));
       
   534     }
       
   535 
       
   536 /**
       
   537  Notify the data provider that the session opened
       
   538  
       
   539  @param aSessionId    The session Id opened
       
   540  @param aConnection   The connection of the sesssion
       
   541 */
       
   542 #ifdef __FLOG_ACTIVE
       
   543 void CMTPImageDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& aSession)
       
   544 #else
       
   545 void CMTPImageDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& /*aSession*/)
       
   546 #endif
       
   547     {
       
   548     __FLOG_VA((_L8(">> SessionOpenedL SessionID = %d"), aSession.iMTPId));
       
   549     
       
   550     if (iEnumerated)
       
   551         {
       
   552         /**
       
   553          * Get image object count from framework and calculate the new pictures
       
   554          */
       
   555         TUint curPictures = QueryImageObjectCountL();
       
   556         TInt  newPictures = curPictures - iPrePictures;
       
   557         
       
   558         __FLOG_2(_L16("CMTPImageDpEnumerator::CompleteEnumeration - Previous Pics:%d, New Pics: %d"), iPrePictures, newPictures);
       
   559         if (newPictures >= 0)
       
   560             {
       
   561             MTPImageDpUtilits::UpdateNewPicturesValue(*this, newPictures, ETrue);  
       
   562             }
       
   563         else
       
   564             {
       
   565             MTPImageDpUtilits::UpdateNewPicturesValue(*this, 0, ETrue);  
       
   566             }
       
   567         
       
   568         iEnumerated = EFalse;
       
   569         }
       
   570     
       
   571     __FLOG(_L8("<< SessionOpenedL "));
       
   572     }
       
   573 
       
   574 /**
       
   575  Notify the data provider that the folder name has been changed
       
   576  
       
   577  @param aParam   The Rename notification
       
   578 */
       
   579 void CMTPImageDataProvider::RenameObjectL(const TMTPNotificationParamsHandle& aParam)
       
   580     {
       
   581     __FLOG_VA((_L16(">> RenameObjectL Handle: %u, Old name: %S"), aParam.iHandleId, &aParam.iFileName));
       
   582     
       
   583     if (!iRenameObject)
       
   584         {
       
   585         iRenameObject = CMTPImageDpRenameObject::NewL(Framework(), *this);
       
   586         }
       
   587 
       
   588     iRenameObject->StartL(aParam.iHandleId, aParam.iFileName);    
       
   589     
       
   590     __FLOG(_L8("<< RenameObjectL "));
       
   591     }
       
   592 
       
   593 /**
       
   594  Find format code according to its extension name 
       
   595 */
       
   596 TMTPFormatCode CMTPImageDataProvider::FindFormatL(const TDesC& aExtension)
       
   597     {
       
   598     TMTPFormatCode* ret = iFormatMappings.Find(aExtension);
       
   599     User::LeaveIfNull(ret);
       
   600     
       
   601     return *ret;
       
   602     }
       
   603 
       
   604 /**
       
   605  Query image object count from current framework 
       
   606 */
       
   607 TUint CMTPImageDataProvider::QueryImageObjectCountL()
       
   608     { 
       
   609     TMTPObjectMgrQueryParams params(KMTPStorageAll, EMTPFormatCodeEXIFJPEG, KMTPHandleNone);    
       
   610     return Framework().ObjectMgr().CountL(params);
       
   611     }
       
   612 
       
   613 TBool CMTPImageDataProvider::GetCacheParentHandle(const TDesC& aParentPath, TUint32& aParentHandle)
       
   614     {
       
   615     TBool ret = EFalse;
       
   616     
       
   617     if (iParentCache.iPath.Compare(aParentPath) == 0)
       
   618         {
       
   619         aParentHandle = iParentCache.iHandle;
       
   620         ret = ETrue;
       
   621         }
       
   622     else
       
   623         {
       
   624         aParentHandle = KMTPHandleNone;
       
   625         }
       
   626     
       
   627     return ret;
       
   628     }
       
   629 
       
   630 void CMTPImageDataProvider::SetCacheParentHandle(const TDesC& aParentPath, TUint32 aParentHandle)
       
   631     {
       
   632     iParentCache.iPath.Copy(aParentPath);
       
   633     iParentCache.iHandle = aParentHandle;
       
   634     }
       
   635 
       
   636 void CMTPImageDataProvider::AppendDeleteObjectsArrayL(const TDesC& aSuid)
       
   637     {
       
   638     iDeleteObjectsArray.AppendL(aSuid.AllocLC());
       
   639     CleanupStack::Pop();
       
   640     }
       
   641 
       
   642 void CMTPImageDataProvider::HandleDeleteObjectsArray()
       
   643     {
       
   644     for ( TInt i = 0; i < iDeleteObjectsArray.Count(); i++ )
       
   645         {
       
   646         HBufC* object = iDeleteObjectsArray[i];
       
   647         TInt err = Framework().Fs().Delete(object->Des());
       
   648         __FLOG_2(_L8("delete left objects %d error code is %d \n"), i, err );
       
   649         
       
   650         if ( err == KErrNone )
       
   651             {
       
   652             iDeleteObjectsArray.Remove(i);
       
   653             --i;
       
   654             delete object;
       
   655             object = NULL;
       
   656             }
       
   657         }
       
   658     }