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