imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailrequestactive.h
changeset 0 2014ca87e772
child 1 235a7fc86938
equal deleted inserted replaced
-1:000000000000 0:2014ca87e772
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:  Active object for an asynchronous thumbnail request
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef THUMBNAILREQUESTACTIVE_H
       
    20 #define THUMBNAILREQUESTACTIVE_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 #include "thumbnailpanic.h"
       
    25 #include "thumbnailmanager.h"
       
    26 #include "thumbnailmanagerconstants.h"
       
    27 #include "thumbnaillog.h"
       
    28 
       
    29 class RFs;
       
    30 class CFbsBitmap;
       
    31 class RThumbnailSession;
       
    32 class CThumbnailDataImpl;
       
    33 class CThumbnailRequestQueue;
       
    34 
       
    35 enum TThumbnailRequestType
       
    36     {
       
    37     EReqGetThumbnailHandle = 0, 
       
    38     EReqGetThumbnailPath = 1,
       
    39     EReqSetThumbnailBuffer = 2,
       
    40     EReqSetThumbnailBitmap = 3,
       
    41     EReqUpdateThumbnails = 4,
       
    42     EReqGetThumbnailHandleLater = 5,
       
    43     EReqDeleteThumbnails = 6
       
    44 };
       
    45 
       
    46 /**
       
    47  *  Active object for an asynchronous thumbnail request.
       
    48  *
       
    49  *  @since S60 v5.0
       
    50  */
       
    51 NONSHARABLE_CLASS( CThumbnailRequestActive ): public CActive
       
    52     {
       
    53 public:
       
    54 
       
    55     /**
       
    56      * Destructor
       
    57      *
       
    58      * @since S60 v5.0
       
    59      */
       
    60     virtual ~CThumbnailRequestActive();
       
    61 
       
    62     /**
       
    63      * Two-phased constructor
       
    64      *
       
    65      * @since S60 v5.0
       
    66      * @param aFs Fileserver used.
       
    67      * @param aThumbnailSession Session used.
       
    68      * @param aObserver Observer to receive notifications about completed
       
    69      *                  operations.
       
    70      * @param aId Assigned ID of the request, session specific.
       
    71      * @param aPriority assigned processing priority
       
    72      * @param aQueue request processor
       
    73      * @return New CThumbnailRequestActive object.
       
    74      */
       
    75     static CThumbnailRequestActive* NewL( RFs& aFs, RThumbnailSession&
       
    76         aThumbnailSession, MThumbnailManagerObserver& aObserver,
       
    77         TThumbnailRequestId aId, TInt aPriority, CThumbnailRequestQueue* aQueue );
       
    78 
       
    79     /**
       
    80      * Get a thumbnail created from file object.
       
    81      *
       
    82      * @since S60 v5.0
       
    83      * @param aFile File from which the thumbnail is to be created.
       
    84      * @param aFlags Flags that control the creation of thumbnail.
       
    85      * @param aQualityPreference Quality preference value
       
    86      * @param aSize Requested size of the thumbnail.
       
    87      * @param aDisplayMode Display mode.
       
    88      * @param aPriority Priority of the request.
       
    89      * @param aClientData Pointer to arbitrary client data.
       
    90      *                    This pointer is not used by the API for
       
    91      *                    anything other than returning it in the
       
    92      *                    ThumbnailReady callback.
       
    93      * @param aTargetUri         Target URI to which the imported thumbnail is linked.
       
    94      */
       
    95     void GetThumbnailL( const RFile64& aFile, TThumbnailId aThumbnailId,
       
    96         CThumbnailManager::TThumbnailFlags aFlags, CThumbnailManager::TThumbnailQualityPreference
       
    97         aQualityPreference, const TSize& aSize, const TDisplayMode aDisplayMode,
       
    98         const TInt aPriority, TAny* aClientData, TBool aGeneratePersistentSizesOnly, const TDesC& aTargetUri = KNullDesC,
       
    99         TThumbnailSize aThumbnailSize = EUnknownThumbnailSize );
       
   100 
       
   101     /**
       
   102      * Get a thumbnail opening file object later.
       
   103      *
       
   104      * @since S60 v5.0
       
   105      * @param aPath Path to file from which the thumbnail is to be created.
       
   106      * @param aFlags Flags that control the creation of thumbnail.
       
   107      * @param aQualityPreference Quality preference value
       
   108      * @param aSize Requested size of the thumbnail.
       
   109      * @param aDisplayMode Display mode.
       
   110      * @param aPriority Priority of the request.
       
   111      * @param aClientData Pointer to arbitrary client data.
       
   112      *                    This pointer is not used by the API for
       
   113      *                    anything other than returning it in the
       
   114      *                    ThumbnailReady callback.
       
   115      * @param aTargetUri         Target URI to which the imported thumbnail is linked.
       
   116      */
       
   117     void GetThumbnailL( TThumbnailId aThumbnailId, const TDesC& aPath,
       
   118         CThumbnailManager::TThumbnailFlags aFlags, CThumbnailManager::TThumbnailQualityPreference
       
   119         aQualityPreference, const TSize& aSize, const TDisplayMode aDisplayMode,
       
   120         const TInt aPriority, TAny* aClientData, TBool aGeneratePersistentSizesOnly, const TDesC& aTargetUri = KNullDesC,
       
   121         TThumbnailSize aThumbnailSize = EUnknownThumbnailSize );
       
   122     
       
   123     /**
       
   124      * Get a thumbnail created from file path.
       
   125      *
       
   126      * @since S60 v5.0
       
   127      * @param aPath Path to file from which the thumbnail is to be created.
       
   128      * @param aFlags Flags that control the creation of thumbnail.
       
   129      * @param aQualityPreference Quality preference value
       
   130      * @param aSize Requested size of the thumbnail.
       
   131      * @param aDisplayMode Display mode.
       
   132      * @param aPriority Priority of the request.
       
   133      * @param aClientData Pointer to arbitrary client data.
       
   134      *                    This pointer is not used by the API for
       
   135      *                    anything other than returning it in the
       
   136      *                    ThumbnailReady callback.
       
   137      * @param aGeneratePersistentSizesOnly 
       
   138      * @param aTargetUri         Target URI to which the imported thumbnail is linked.
       
   139      * @param aThumbnailSize Relative thumbnail size
       
   140      */
       
   141     void GetThumbnailL( const TDesC& aPath, TThumbnailId aThumbnailId,
       
   142         CThumbnailManager::TThumbnailFlags aFlags, 
       
   143         CThumbnailManager::TThumbnailQualityPreference aQualityPreference, 
       
   144         const TSize& aSize, const TDisplayMode aDisplayMode, const TInt aPriority, 
       
   145         TAny* aClientData, TBool aGeneratePersistentSizesOnly, 
       
   146         const TDesC& aTargetUri = KNullDesC, TThumbnailSize aThumbnailSize = EUnknownThumbnailSize );  
       
   147     
       
   148     /**
       
   149      * Set a thumbnail
       
   150      *
       
   151      * @since S60 v5.0
       
   152      * @param aBuffer Buffer containing image where the thumbnail is to be created.
       
   153      * @param aFlags Flags that control the creation of thumbnail.
       
   154      * @param aQualityPreference Quality preference value
       
   155      * @param aSize Requested size of the thumbnail.
       
   156      * @param aDisplayMode Display mode.
       
   157      * @param aPriority Priority of the request.
       
   158      * @param aClientData Pointer to arbitrary client data.
       
   159      *                    This pointer is not used by the API for
       
   160      *                    anything other than returning it in the
       
   161      *                    ThumbnailReady callback.
       
   162      * @param aGeneratePersistentSizesOnly
       
   163      * @param aTargetUri         Target URI to which the imported thumbnail is linked.
       
   164      * @param aThumbnailSize Requested thumbnail size 
       
   165      */    
       
   166     void SetThumbnailL( TDesC8* aBuffer, TThumbnailId aThumbnailId, const TDesC8& aMimeType,
       
   167         CThumbnailManager::TThumbnailFlags aFlags, CThumbnailManager
       
   168         ::TThumbnailQualityPreference aQualityPreference, const TSize& aSize, const
       
   169         TDisplayMode aDisplayMode, const TInt aPriority, TAny* aClientData, TBool aGeneratePersistentSizesOnly,
       
   170         const TDesC& aTargetUri, TThumbnailSize aThumbnailSize );
       
   171     
       
   172     /**
       
   173      * Set a thumbnail
       
   174      *
       
   175      * @since S60 v5.0
       
   176      * @param aBitmap Bitmap
       
   177      * @param aFlags Flags that control the creation of thumbnail.
       
   178      * @param aQualityPreference Quality preference value
       
   179      * @param aSize Requested size of the thumbnail.
       
   180      * @param aDisplayMode Display mode.
       
   181      * @param aPriority Priority of the request.
       
   182      * @param aClientData Pointer to arbitrary client data.
       
   183      *                    This pointer is not used by the API for
       
   184      *                    anything other than returning it in the
       
   185      *                    ThumbnailReady callback.
       
   186      * @param aGeneratePersistentSizesOnly
       
   187      * @param aTargetUri         Target URI to which the imported thumbnail is linked.
       
   188      * @param aThumbnailSize Requested thumbnail size 
       
   189      */    
       
   190     void SetThumbnailL( CFbsBitmap* aBitmap, TThumbnailId aThumbnailId, const TDesC8& aMimeType,
       
   191         CThumbnailManager::TThumbnailFlags aFlags, CThumbnailManager
       
   192         ::TThumbnailQualityPreference aQualityPreference, const TSize& aSize, const
       
   193         TDisplayMode aDisplayMode, const TInt aPriority, TAny* aClientData, TBool aGeneratePersistentSizesOnly,
       
   194         const TDesC& aTargetUri, TThumbnailSize aThumbnailSize );    
       
   195     
       
   196     /**
       
   197      * Update thumbnails by Id.
       
   198      *
       
   199      * @since S60 v5.0
       
   200      * @param aPath Path to file from which the thumbnail is to be created.
       
   201      * @param aFlags Flags that control the creation of thumbnail.
       
   202      * @param aQualityPreference Quality preference value
       
   203      * @param aSize Requested size of the thumbnail.
       
   204      * @param aDisplayMode Display mode.
       
   205      * @param aPriority Priority of the request.
       
   206      * @param aOrientation  Thumbnail orientation
       
   207      * @param aModified     Last modified
       
   208      */
       
   209     void UpdateThumbnailsL( const TDesC& aPath, const TThumbnailId aThumbnailId,
       
   210         CThumbnailManager::TThumbnailFlags aFlags, 
       
   211         CThumbnailManager::TThumbnailQualityPreference aQualityPreference, 
       
   212         const TDisplayMode aDisplayMode, const TInt aPriority, const TInt aOrientation,
       
   213         const TInt64 aModified );   
       
   214     
       
   215     /**
       
   216      * Delete thumbnails.
       
   217      *
       
   218      * @since S60 v5.0
       
   219      * @param aPath Path to file from which the thumbnail is to be created.
       
   220      * @param aPriority Priority of the request.
       
   221      */
       
   222     void DeleteThumbnails( const TDesC& aPath, const TThumbnailId aThumbnailId,
       
   223         const TInt aPriority );   
       
   224     
       
   225     /**
       
   226      * Start active request.
       
   227      *
       
   228      * @since S60 v5.0
       
   229      */
       
   230     void StartL();
       
   231     
       
   232     /**
       
   233      * Change priority of a request.
       
   234      *
       
   235      * @since S60 v5.0
       
   236      * @param aNewPriority New priority.
       
   237      * @return Error code.
       
   238      */
       
   239     void ChangePriority( const TInt aNewPriority );
       
   240     
       
   241     /**
       
   242      * Returns ID of thumbnail request.
       
   243      *
       
   244      * @since S60 v5.0
       
   245      * @return Request ID
       
   246      */
       
   247     TThumbnailRequestId RequestId()const;
       
   248 
       
   249     /**
       
   250      * Is thumbnail request completed
       
   251      *
       
   252      * @since S60 v5.0
       
   253      */
       
   254     TBool RequestCompleted()const;
       
   255     
       
   256 	 /**
       
   257      * Is thumbnail request active
       
   258      *
       
   259      * @since S60 v5.0
       
   260      */
       
   261     TBool IsRequestActive()const;
       
   262     
       
   263 private:
       
   264 
       
   265     /**
       
   266      * C++ default constructor
       
   267      *
       
   268      * @since S60 v5.0
       
   269      * @param aFs Fileserver used.
       
   270      * @param aThumbnailSession Session used.
       
   271      * @param aObserver Observer to receive notifications about completed
       
   272      *                  operations.
       
   273      * @param aId Assigned ID of the request, session specific.
       
   274      * @param aPriority assigned processing priority
       
   275      * @param aQueue request processor
       
   276      * @return New CThumbnailRequestActive object.
       
   277      */
       
   278     CThumbnailRequestActive( RFs& aFs, RThumbnailSession& aThumbnailSession,
       
   279         MThumbnailManagerObserver& aObserver, TThumbnailRequestId aId, TInt aPriority,
       
   280         CThumbnailRequestQueue* aQueue);
       
   281 
       
   282     /**
       
   283      * Symbian 2nd phase constructor can leave.
       
   284      *
       
   285      * @since S60 v5.0
       
   286      */
       
   287     void ConstructL();
       
   288 
       
   289     /**
       
   290      * Handles an active object's request completion event.
       
   291      *
       
   292      * @since S60 v5.0
       
   293      */
       
   294     void RunL();
       
   295 
       
   296     /**
       
   297      * Handles a leave occurring in the request completion event handler
       
   298      * RunL().
       
   299      *
       
   300      * @since S60 v5.0
       
   301      * @param aError The leave code.
       
   302      * @return Error code.
       
   303      */
       
   304     TInt RunError( TInt aError );
       
   305 
       
   306     /**
       
   307      * Implements cancellation of an outstanding request.
       
   308      *
       
   309      * @since S60 v5.0
       
   310      */
       
   311     void DoCancel();
       
   312 
       
   313     /**
       
   314      * Release bitmap instance kept by server process.
       
   315      *
       
   316      * @since S60 v5.0
       
   317      */
       
   318     void ReleaseServerBitmap();
       
   319 
       
   320     /**
       
   321      * Error handling function.
       
   322      *
       
   323      * @since S60 v5.0
       
   324      */
       
   325     void HandleError();
       
   326 
       
   327     /**
       
   328      * Request 2nd phase thumbnail
       
   329      *
       
   330      * @since S60 v5.0
       
   331      */
       
   332     void Get2ndPhaseThumbnailL();
       
   333 
       
   334     /**
       
   335      * Callback for timeout timer
       
   336      *
       
   337      * @since S60 v5.0
       
   338      */
       
   339     static TInt TimerCallBack(TAny* aAny);
       
   340 
       
   341 private:
       
   342     // data
       
   343 
       
   344     /**
       
   345      * Session.
       
   346      */
       
   347     RThumbnailSession& iSession;
       
   348     
       
   349     /**
       
   350      * Request parameters.
       
   351      */
       
   352     TThumbnailRequestParams iParams;
       
   353 
       
   354     /**
       
   355      * Package for request parameters.
       
   356      */
       
   357     TThumbnailRequestParamsPckg iParamsPckg;
       
   358 
       
   359     /**
       
   360      * Observer to receive notifications about completed operations.
       
   361      */
       
   362     MThumbnailManagerObserver& iObserver;
       
   363 
       
   364     /**
       
   365      * Fileserver, not own
       
   366      */
       
   367     RFs& iFs;
       
   368 
       
   369     /**
       
   370      * Client data.
       
   371      */
       
   372     TAny* iClientData;
       
   373 
       
   374     /**
       
   375      * Callback, own.
       
   376      */
       
   377     CThumbnailDataImpl* iCallbackThumbnail;
       
   378 
       
   379     /**
       
   380      * Handle to bitmap, own.
       
   381      */
       
   382     TInt iBitmapHandle;
       
   383 
       
   384     /**
       
   385      * Error code.
       
   386      */
       
   387     TInt iError;
       
   388 
       
   389     /**
       
   390      * Request id of thumbnail request, session specific.
       
   391      */
       
   392     TThumbnailRequestId iRequestId;
       
   393 
       
   394     /**
       
   395      * Duplicated file handle for two phase operation
       
   396      */
       
   397     RFile64 iMyFileHandle;
       
   398 
       
   399     /**
       
   400      * If set, we are currently processing the preview thumbnail
       
   401      * of a two phase operation. If an error occurs, we can skip
       
   402      * directly to 2nd phase.
       
   403      */
       
   404     TBool iProcessingPreview;
       
   405 
       
   406     /**
       
   407      * If set, this request object can be deleted.
       
   408      */
       
   409     TBool iRequestCompleted;
       
   410     
       
   411 	 /**
       
   412      * If set, this request object is under processing
       
   413      */
       
   414     TBool iRequestActive;
       
   415     
       
   416     /**
       
   417      * Bitmap that is passed to server
       
   418      */
       
   419     CFbsBitmap* iBitmap;
       
   420     
       
   421     // for activating requests
       
   422     RFile64 iFile;
       
   423     TFileName iPath;
       
   424     TFileName iTargetUri;
       
   425     TInt iOrientation;
       
   426     TInt64 iModified;
       
   427     
       
   428     // not own
       
   429     CThumbnailRequestQueue* iRequestQueue;
       
   430     
       
   431     TThumbnailRequestType iRequestType;
       
   432     
       
   433     // request timeout timer
       
   434     CPeriodic* iTimer;
       
   435     
       
   436 #ifdef _DEBUG
       
   437     TTime iStartExecTime;
       
   438 #endif
       
   439 };
       
   440 
       
   441 #endif // THUMBNAILREQUESTACTIVE_H
       
   442 
       
   443 
       
   444 
       
   445 // INLINE FUNCTIONS
       
   446 
       
   447 inline TBool CThumbnailRequestActive::RequestCompleted()const
       
   448     {
       
   449     return iRequestCompleted;
       
   450     }
       
   451 
       
   452 inline TBool CThumbnailRequestActive::IsRequestActive()const
       
   453     {
       
   454     if(IsActive())
       
   455         {
       
   456         return ETrue;
       
   457         }
       
   458     return iRequestActive;
       
   459     }
       
   460 
       
   461 inline TThumbnailRequestId CThumbnailRequestActive::RequestId()const
       
   462     {
       
   463     __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId ));
       
   464 
       
   465     return iRequestId;
       
   466     }