imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumbagprocessor.h
changeset 29 4bdfb6b5c9b4
parent 22 a67f74060682
child 30 b67379558a75
equal deleted inserted replaced
25:cb86b71cae0a 29:4bdfb6b5c9b4
    30 #include <e32property.h>
    30 #include <e32property.h>
    31 #include <mpxcollectionobserver.h>
    31 #include <mpxcollectionobserver.h>
    32 #include "tmactivitymanager.h"
    32 #include "tmactivitymanager.h"
    33 #include "tmformatobserver.h"
    33 #include "tmformatobserver.h"
    34 #include "tmrpropertyobserver.h"
    34 #include "tmrpropertyobserver.h"
       
    35 #include "thumbnailmanagerconstants.h"
    35 
    36 
    36 //FORWARD DECLARATIONS
    37 //FORWARD DECLARATIONS
    37 class MMPXCollectionUtility;
    38 class MMPXCollectionUtility;
       
    39 
       
    40 
       
    41 enum TThumbnailGenerationItemType
       
    42       {
       
    43       EGenerationItemTypeUnknown,
       
    44       EGenerationItemTypeNotFound,
       
    45       EGenerationItemTypeCamera,
       
    46       EGenerationItemTypeAny,
       
    47       EGenerationItemTypeAudio,
       
    48       EGenerationItemTypeVideo,
       
    49       EGenerationItemTypeImage,
       
    50       EGenerationItemTypeItemCount
       
    51       };
       
    52 
       
    53   enum TThumbnailGenerationItemAction
       
    54       {
       
    55       EGenerationItemActionAdd,
       
    56       EGenerationItemActionDelete,
       
    57       EGenerationItemActionModify,
       
    58       EGenerationItemAction2ndAdd,
       
    59       EGenerationItemActionResolveType,
       
    60       EGenerationItemActionCount
       
    61       };
       
    62 
       
    63   struct TThumbnailGenerationItem
       
    64       {
       
    65       inline TThumbnailGenerationItem(): iItemId( KErrNotFound ), iItemType(EGenerationItemTypeUnknown), iItemAction(EGenerationItemActionAdd), iPlaceholder(EFalse), iUri(NULL){}
       
    66       inline ~TThumbnailGenerationItem(){delete iUri; iUri = NULL;}
       
    67       
       
    68       TItemId iItemId;
       
    69       TThumbnailGenerationItemType iItemType;
       
    70       TThumbnailGenerationItemAction iItemAction;
       
    71       TBool iPlaceholder;
       
    72       HBufC* iUri;
       
    73       };
    38 
    74 
    39 /**
    75 /**
    40  *  Processor object for handling thumb generation
    76  *  Processor object for handling thumb generation
    41  *
    77  *
    42  *  @since S60 v5.0
    78  *  @since S60 v5.0
   117      * Sets MdE Session
   153      * Sets MdE Session
   118      *
   154      *
   119      * @since S60 v5.0
   155      * @since S60 v5.0
   120      * @param aMdESession MdE Session
   156      * @param aMdESession MdE Session
   121      */
   157      */
   122     void SetMdESession( CMdESession* aMdESession );    
   158     void SetMdESessionL( CMdESession* aMdESession );    
   123     
   159     
   124     /**
   160     /**
   125      * Adds new IDs to queue
   161      * Adds new IDs to queue
   126      *
   162      *
   127      * @since S60 v5.0
   163      * @since S60 v5.0
   128      * @param aType TObserverNotificationType
   164      * @param aType TObserverNotificationType
       
   165 	 * @param TThumbnailGenerationItemType
   129      * @param aIDArray IDs for thumbnail creation
   166      * @param aIDArray IDs for thumbnail creation
   130      * @param aForce pass ETrue if processor is forced to run without waiting harvesting complete
   167      * @param aForce pass ETrue if processor is forced to run without waiting harvesting complete
   131      */
   168      */
   132     void AddToQueueL( TObserverNotificationType aType, const RArray<TItemId>& aIDArray, const RPointerArray<HBufC>& aObjectUriArray, TBool aPresent );
   169     void AddToQueueL( TObserverNotificationType aType, TThumbnailGenerationItemType aItemType, const RArray<TItemId>& aIDArray, const RPointerArray<HBufC>& aObjectUriArray, TBool aPresent );
   133     
   170     
   134     /**
   171     /**
   135      * Calls Thumbnail Manager to create thumbnails
   172      * Calls Thumbnail Manager to create thumbnails
   136      *
   173      *
   137      * @since S60 v5.0
   174      * @since S60 v5.0
   146      * @param aIDArray IDs for thumbnail creation
   183      * @param aIDArray IDs for thumbnail creation
   147      */
   184      */
   148     void RemoveFromQueues( const RArray<TItemId>& aIDArray, const TBool aRemoveFromDelete = EFalse);
   185     void RemoveFromQueues( const RArray<TItemId>& aIDArray, const TBool aRemoveFromDelete = EFalse);
   149     
   186     
   150     void SetForceRun( const TBool aForceRun );
   187     void SetForceRun( const TBool aForceRun );
       
   188 	
       
   189 	//prepare processor for shutdown
       
   190 	void Shutdown();
   151     
   191     
   152 protected:
   192 protected:
   153     
   193     
   154     void QueryAllItemsL();
   194     void QueryAllItemsL();
   155     
   195     
   156     /**
   196     /**
   157      * QueryL
   197      * QueryL
   158      *
   198      *
   159      * @since S60 v5.0
   199      * @since S60 v5.0
   160      * @param aIDArray Item IDs to query
   200      * @param TThumbnailGenerationItemAction
   161      */
   201      */
   162     void QueryL( RArray<TItemId>& aIDArray );
   202     void QueryL( TThumbnailGenerationItemAction aType);
   163     
   203     
   164 	 /**
   204 	 /**
   165      * QueryPlaceholdersL
   205      * QueryPlaceholdersL
   166      *
   206      *
   167      * @since S60 v5.0
   207      * @since S60 v5.0
   255      * Update KItemsLeft PS value
   295      * Update KItemsLeft PS value
   256      * 
   296      * 
   257      * @since S60 v5.0
   297      * @since S60 v5.0
   258  	 * @param aDefine (re)define PS key before setting value
   298  	 * @param aDefine (re)define PS key before setting value
   259      */
   299      */
   260     void UpdatePSValues(const TBool aDefine = EFalse);
   300     void UpdatePSValues(const TBool aDefine, const TBool aForce);
   261        
   301        
   262     /**
   302     /**
   263      * Comparison function for logaritmic use of queue arrays
   303      * Comparison function for logaritmic use of queue arrays
   264      * 
   304      * 
   265      * @since S60 v5.0
   305      * @since S60 S^3
   266      */
   306      */
   267     static TInt Compare(const TItemId& aLeft, const TItemId& aRight);
   307     static TInt Compare(const TThumbnailGenerationItem& aLeft, const TThumbnailGenerationItem& aRight);
       
   308 	
       
   309 	 /**
       
   310      * Comparison function for logaritmic use of queue arrays
       
   311      * 
       
   312      * @since S60 S^3
       
   313      */
       
   314     static TInt CompareId(const TItemId& aLeft, const TItemId& aRight);
       
   315     
       
   316 	/**
       
   317      * Recalculate item counts
       
   318      * 
       
   319      * @since S60 S^3
       
   320      */
       
   321     void UpdateItemCounts();
       
   322 	
       
   323     /**
       
   324      * Callback for mount timeout
       
   325      *
       
   326      * @since S60 v5.0
       
   327      */
       
   328     static TInt MountTimerCallBack(TAny* aAny);
       
   329     
       
   330 	 /**
       
   331      * Set item's action from type
       
   332      *
       
   333      * @since S^3
       
   334      */
       
   335     void SetGenerationItemAction( TThumbnailGenerationItem& aGenerationItem, const TThumbnailGenerationItemType aItemType );
       
   336 	
       
   337      /**
       
   338      * Set item type property from TDedIf
       
   339      * @param aGenerationItem TThumbnailGenerationItem
       
   340      * @param aItemType TThumbnailGenerationItemType
       
   341      * @since S^3
       
   342      */
       
   343     void SetGenerationItemType( TThumbnailGenerationItem& aGenerationItem, const TDefId aDefId );
       
   344  
       
   345      /**
       
   346      * Append item to processing queue or update existing
       
   347      * @param aGenerationItem modified TThumbnailGenerationItem
       
   348      * @param aDefId items MDS object definition ID
       
   349      * @since S^3
       
   350      */
       
   351     void AppendProcessingQueue(TThumbnailGenerationItem& item );
   268         
   352         
   269 private:
   353 private:
   270     
   354     
   271     // not own
   355     // not own
   272     CMdESession* iMdESession;
   356     CMdESession* iMdESession;
   276     CThumbnailManager* iTMSession;
   360     CThumbnailManager* iTMSession;
   277     CMdEObjectQuery* iQuery;
   361     CMdEObjectQuery* iQuery;
   278     CMdEObjectQuery* iQueryAllItems;
   362     CMdEObjectQuery* iQueryAllItems;
   279     CMdEObjectQuery* iQueryPlaceholders;
   363     CMdEObjectQuery* iQueryPlaceholders;
   280     
   364     
   281     RArray<TItemId> iAddQueue;
   365     RArray<TThumbnailGenerationItem> iGenerationQueue;
   282     RArray<TItemId> iModifyQueue;
   366     //RPointerArray<HBufC> iRemoveQueue;
   283     RPointerArray<HBufC> iRemoveQueue;
       
   284     RArray<TItemId> iQueryQueue;
   367     RArray<TItemId> iQueryQueue;
   285     RArray<TItemId> iPlaceholderQueue;
       
   286     //not processing queue, used to keep KItemsLeft PS correct
       
   287     RArray<TItemId> i2ndRoundGenerateQueue;
       
   288 	//reference to current processing queue
       
   289     RArray<TItemId>* iLastQueue;
       
   290     
   368     
   291 	//background generation state
   369 	//background generation state
   292 	// EFalse = 1st round, create only grid size thumbnail for images and videos
   370 	// EFalse = 1st round, create only grid size thumbnail for images and videos
   293 	// ETrue = 2nds round, create all missing sizes for all media items
   371 	// ETrue = 2nds round, create all missing sizes for all media items
   294     TBool i2ndRound;    
   372     TBool i2ndRound;    
       
   373 	
       
   374 	// query state
       
   375 	// EFalse = normal mode
       
   376 	// ETrue = querying unknown items
       
   377     TBool iUnknown;
   295     
   378     
   296 	//MDS query issues
   379 	//MDS query issues
   297     TBool iQueryActive;
   380     TBool iQueryActive;
   298 	//MDS query complete
   381 	//MDS query complete
   299     TBool iQueryReady;
   382     TBool iQueryReady;
   300     
   383     
   301 	//Processing MDS itens which are modified
   384 	//Processing MDS itens which are modified
   302     TBool iModify;
   385     TBool iModify;
   303     TInt iProcessingCount;
   386     TUint iProcessingCount;
   304 
   387 
   305     //MDS harvester's overall state
   388     //MDS harvester's overall state
   306     TBool iHarvesting;
   389     TBool iHarvesting;
   307     TBool iHarvestingTemp;
   390     TBool iHarvestingTemp;
   308 
   391 
   313     //MDS Harvester's SD card harvesting state
   396     //MDS Harvester's SD card harvesting state
   314     TBool iMMCHarvesting;
   397     TBool iMMCHarvesting;
   315     TBool iMMCHarvestingTemp;
   398     TBool iMMCHarvestingTemp;
   316     
   399     
   317     CPeriodic* iPeriodicTimer;
   400     CPeriodic* iPeriodicTimer;
       
   401     CPeriodic* iMountTimer;
   318 
   402 
   319 	//MDS Harvester client
   403 	//MDS Harvester client
   320     RHarvesterClient iHarvesterClient;
   404     RHarvesterClient iHarvesterClient;
   321 
   405 
   322     //Set when running RunL() first time
   406     //Set when running RunL() first time
   323     TBool iInit;
   407     TBool iInit;
   324     
   408     
   325     //2nd phase init after MDE session is open
   409     //2nd phase init after MDE session is open
   326     TBool iInit2;
   410     TBool iInit2;
   327     
   411     
   328     // auto create
   412     // auto create values from centrep
   329     TBool iAutoImage;
   413     TBool iAutoImage;
   330     TBool iAutoVideo;
   414     TBool iAutoVideo;
   331     TBool iAutoAudio;
   415     TBool iAutoAudio;
   332     
   416     
   333     // in case of modified files force TN update
   417     // in case of modified files force TN update
   334     TBool iForceRun; 
   418     TBool iForceRun; 
   335     // controlled by Photos application to run TN generation on foreground
   419     // controlled by Photos application to run TN generation on foreground
   336     TBool iForegroundRun;
   420     TBool iForegroundRun;
   337 	//request pending in TNM side
   421 	//request pending in TNM side
   338     TBool iActive;
       
   339    
   422    
   340     CTMFormatObserver* iFormatObserver;
   423     CTMFormatObserver* iFormatObserver;
   341    
   424    
       
   425    //formating started
   342     TBool iFormatting;
   426     TBool iFormatting;
       
   427 	//TNM server session died
   343     TBool iSessionDied;
   428     TBool iSessionDied;
   344    
   429    
   345     TInt iActiveCount;
   430    //pending request count
       
   431     TUint iActiveCount;
   346     
   432     
   347     MMPXCollectionUtility* iCollectionUtility; // own
   433     MMPXCollectionUtility* iCollectionUtility; // own
   348     
   434     
   349 	//Flag is MPX harvesting or MTP synchronisation in progress
   435 	//Flag is MPX harvesting or MTP synchronisation in progress
   350     TBool iMPXHarvesting;
   436     TBool iMPXHarvesting;
   351 
   437 
   352     //overall status of device
   438     //overall status of device
   353     TBool iIdle;
   439     TBool iIdle;
   354     
   440     
       
   441 	//monitors device activity
   355     CTMActivityManager* iActivityManager;
   442     CTMActivityManager* iActivityManager;
   356     
   443     
   357 	//Observer foreground generation 
   444 	//Observer foreground generation 
   358     CTMRPropertyObserver* iForegroundGenerationObserver;
   445     CTMRPropertyObserver* iForegroundGenerationObserver;
   359     
   446     
   360 	//Previously notified amount of items in processing queues (add/modify)
   447 	//Previously notified amount of items in processing queues (add/modify)
   361     TInt iPreviousItemsLeft;
   448     TInt iPreviousItemsLeft;
   362     TBool iPreviousDaemonProcessing; 
   449     TBool iPreviousDaemonProcessing; 
   363 	//set ETrue when QueryAllItems needs to be run after placeholder query
   450 	//set ETrue when QueryAllItems needs to be run after placeholder query
   364     TBool iDoQueryAllItems;
   451     TBool iDoQueryAllItems;
   365 };
   452     
       
   453     TBool iShutdown;
       
   454 	
       
   455 	//item counts
       
   456     TUint32 iModifyItemCount;
       
   457     TUint32 iImageItemCount;
       
   458     TUint32 iVideoItemCount;
       
   459     TUint32 iAudioItemCount;
       
   460     TUint32 iDeleteItemCount;
       
   461     TUint32 iAddItemCount;
       
   462     TUint32 iCameraItemCount;
       
   463     TUint32 iUnknownItemCount;
       
   464     TUint32 i2ndAddItemCount;
       
   465     TUint32 iPlaceholderItemCount;
       
   466     
       
   467     //for book keeping previous items left count got from MDS harvester
       
   468     TUint32 iMMCHarvestingItemsLeftTemp;
       
   469     TUint32 iPHHarvestingItemsLeftTemp;
       
   470     
       
   471 	//MdE object definitons used in query
       
   472     CMdEObjectDef* iImageObjectDef;
       
   473     CMdEObjectDef* iVideoObjectDef;
       
   474     CMdEObjectDef* iAudioObjectDef;
       
   475     TBool iHarvesterActivated;
       
   476   };
   366 
   477 
   367 #endif // THUMBAGPROCESSOR_H
   478 #endif // THUMBAGPROCESSOR_H