engine/collectionframework/thumbnailcreator/thumbnailcomposerplugin/glxthumbnailcomposerplugin.h
changeset 71 27f2d7aec52a
parent 69 45459746d5e8
child 72 0a8e959402e5
equal deleted inserted replaced
69:45459746d5e8 71:27f2d7aec52a
     1 /*
       
     2 * Copyright (c) 2008-2009 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 "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:   Thumbnail Composer  plugin
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  * @internal reviewed 12/07/2007 by Simon Brooks
       
    22  */
       
    23 
       
    24 #ifndef __CTHUMBNAILCOMPOSERPLUGIN_H__
       
    25 #define __CTHUMBNAILCOMPOSERPLUGIN_H__
       
    26 
       
    27 #include <composerplugin.h>
       
    28 #include <mdeobject.h>
       
    29 #include <mpxcollectionobserver.h>
       
    30 class MMPXCollectionUtility;
       
    31 class CMPXCollectionPath;
       
    32 class CGlxThumbnailComposerPlugin;
       
    33 
       
    34 /**
       
    35  * Timer to allow inactivity delay if background generation task is cancelled
       
    36  */
       
    37 class CGlxThumbnailCompeserInactivityTimer : public CTimer
       
    38     {
       
    39     public:
       
    40         ~CGlxThumbnailCompeserInactivityTimer();
       
    41         static CGlxThumbnailCompeserInactivityTimer* NewL(TInt aPriority, CGlxThumbnailComposerPlugin& aCallback);
       
    42         void After(TTimeIntervalMicroSeconds32 aInterval);
       
    43     private:
       
    44         CGlxThumbnailCompeserInactivityTimer(TInt aPriority, CGlxThumbnailComposerPlugin& aCallback);
       
    45     private: // from CActive
       
    46         void RunL();
       
    47         void DoCancel();
       
    48         TInt RunError(TInt aError);
       
    49     private:
       
    50         CGlxThumbnailComposerPlugin& iCallback;
       
    51     };
       
    52 
       
    53 
       
    54 /**
       
    55  * Composer plugin to initiate background generation when new items are
       
    56  * harvested by the MDS harvester.
       
    57  *
       
    58  * @author David Holland
       
    59  */
       
    60 NONSHARABLE_CLASS( CGlxThumbnailComposerPlugin ) :
       
    61                   public CComposerPlugin, MMPXCollectionObserver 
       
    62     {
       
    63     public:
       
    64         /**
       
    65         * Construction
       
    66         */
       
    67         static CGlxThumbnailComposerPlugin* NewL();
       
    68 
       
    69         /**
       
    70         * Destruction
       
    71         */
       
    72         ~CGlxThumbnailComposerPlugin();
       
    73 
       
    74     private:    // From CComposerPlugin
       
    75 
       
    76         TBool IsComposingComplete();
       
    77         void SetObservers();
       
    78         void RemoveObservers();
       
    79 
       
    80     private:    // From MMdEObjectObserver
       
    81 
       
    82 #ifdef GLX_USE_MDS_2_0
       
    83         void HandleObjectAdded(CMdESession& aSession,
       
    84                                 const RArray<TItemId>& aObjectIdArray);
       
    85         void HandleObjectModified(CMdESession& aSession,
       
    86                                 const RArray<TItemId>& aObjectIdArray);
       
    87         void HandleObjectRemoved(CMdESession& aSession,
       
    88                                 const RArray<TItemId>& aObjectIdArray);
       
    89 #else
       
    90         /**
       
    91          * See @ref MMdEObjectObserver::HandleObjectNotification
       
    92          */
       
    93         void HandleObjectNotification(CMdESession& aSession, 
       
    94 		    				TObserverNotificationType aType,
       
    95 				    		const RArray<TItemId>& aObjectIdArray);
       
    96 #endif
       
    97 
       
    98     private:    // From MMPXCollectionObserver
       
    99 
       
   100         void HandleCollectionMediaL( const CMPXMedia& aMedia, TInt aError );
       
   101         void HandleCollectionMessage( CMPXMessage* aMsg, TInt aErr );
       
   102         void HandleOpenL( const CMPXMedia& aEntries,
       
   103                             TInt aIndex, TBool aComplete, TInt aError );
       
   104         void HandleOpenL( const CMPXCollectionPlaylist& aPlaylist,
       
   105                             TInt aError );
       
   106         void HandleCommandComplete( CMPXCommand* aCommandResult,
       
   107                                     TInt aError );
       
   108 
       
   109     private:
       
   110 
       
   111         /**
       
   112         * Private constructor
       
   113         */	
       
   114         CGlxThumbnailComposerPlugin();
       
   115 
       
   116         /**
       
   117         * 2nd phase construction
       
   118         */	
       
   119         void ConstructL();
       
   120 
       
   121         /**
       
   122         * Add observers to MdE session.
       
   123         */
       
   124         void SetObserversL();
       
   125 
       
   126         void DoHandleCollectionMessageL( const CMPXMessage& aMsg );
       
   127 
       
   128         /**
       
   129         * Send next media request to the collection.
       
   130         */
       
   131         void RequestItemL();
       
   132 
       
   133     public:
       
   134         /**
       
   135         * Open "all" collection with thumbnail loadability filter.
       
   136         */
       
   137         void DoOpenCollectionL();
       
   138 
       
   139         /**
       
   140         * Send next media request to the collection.
       
   141         */
       
   142         void DoRequestItemL();
       
   143 
       
   144         /**
       
   145         * Free resources and go to idle state.
       
   146         */
       
   147         void ReturnToIdle();
       
   148 
       
   149         /**
       
   150         * Callback for iCollectionCloser
       
   151         */
       
   152         void CloseCollection();
       
   153 
       
   154     public:
       
   155         /**
       
   156         * Enumeration of states for the plugin.
       
   157         */
       
   158         enum TComposerState
       
   159             {
       
   160             EStateIdle,
       
   161             EStateFirstOpening,
       
   162             EStateOpening,
       
   163             EStateActiveLarge,
       
   164             EStateActiveSmall,
       
   165             EStateCleanup,
       
   166             EStateClosing
       
   167             };
       
   168 
       
   169         /** Current state of the plugin */
       
   170         TComposerState iState;
       
   171 
       
   172     private:
       
   173         /** Isolated collection utility (owned) */
       
   174         MMPXCollectionUtility* iCollectionUtility;
       
   175 
       
   176         /** Path from collection (owned) */
       
   177         CMPXCollectionPath* iPath;
       
   178 
       
   179         /** Index of item to thumbnail */
       
   180         TInt iCurrentIndex;
       
   181 
       
   182         /** Timer to restart Background Harvesting once inactive */
       
   183         CGlxThumbnailCompeserInactivityTimer* iInactivityTimer;
       
   184         
       
   185         TInt iLastError;
       
   186     };
       
   187 
       
   188 #endif // __CTHUMBNAILCOMPOSERPLUGIN_H__