imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailmanagerimpl.h
changeset 54 48dd0f169f0d
parent 42 2e2a89493e2b
equal deleted inserted replaced
42:2e2a89493e2b 54:48dd0f169f0d
     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:  Implementation class of Thumbnail Manager
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef THUMBNAILMANAGERIMPL_H
       
    20 #define THUMBNAILMANAGERIMPL_H
       
    21 
       
    22 #include <fbs.h>
       
    23 
       
    24 #include "thumbnailmanager.h"
       
    25 #include "thumbnailsession.h"
       
    26 #include "thumbnailrequestqueue.h"
       
    27 #include "thumbnaildata.h"
       
    28 
       
    29 
       
    30 class CThumbnailRequestActive;
       
    31 
       
    32 /**
       
    33  *  Implementation class of thumbnail engine.
       
    34  *
       
    35  *  @since S60 v5.0
       
    36  */
       
    37 NONSHARABLE_CLASS( CThumbnailManagerImpl ): public CThumbnailManager
       
    38     {
       
    39 public:
       
    40 
       
    41     /**
       
    42      * Destructor
       
    43      *
       
    44      * @since S60 v5.0
       
    45      */
       
    46     virtual ~CThumbnailManagerImpl();
       
    47 
       
    48     /**
       
    49      * Two-phased constructor
       
    50      *
       
    51      * @since S60 v5.0
       
    52      * @param  aObserver Observer to receive notifications about completed
       
    53      *                   operations.
       
    54      * @return           New CThumbnailManagerImpl instance.
       
    55      */
       
    56     static CThumbnailManagerImpl* NewLC( MThumbnailManagerObserver& aObserver );
       
    57 
       
    58     /**
       
    59      * Get a thumbnail for an object file. If a thumbnail already exists, it
       
    60      * is loaded and if a thumbnail does not exist, it is created
       
    61      * transparently. ThumbnailReady() callback will be called when the
       
    62      * operation is complete. In addition, ThumbnailPreviewReady()
       
    63      * callback may be called if EOptimizeForQualityWithPreview mode was
       
    64      * defined.
       
    65      *
       
    66      * Current values for display mode, thumbnail size, flags and performance
       
    67      * preference are used.
       
    68      *
       
    69      * @since S60 v5.0
       
    70      * @param aObjectSource      Source object or file
       
    71      * @param aClientData        Pointer to arbitrary client data.
       
    72      *                           This pointer is not used by the API for
       
    73      *                           anything other than returning it in the
       
    74      *                           ThumbnailReady callback.
       
    75      * @param aPriority          Priority for this operation
       
    76      * @return                   Thumbnail request ID
       
    77      */
       
    78     TThumbnailRequestId GetThumbnailL( CThumbnailObjectSource& aObjectSource,
       
    79         TAny* aClientData = NULL, const TInt aPriority = CActive::EPriorityIdle );
       
    80     
       
    81     /**
       
    82      * Get a thumbnail for an object file. If a thumbnail already exists, it
       
    83      * is loaded and if a thumbnail does not exist, it is created
       
    84      * transparently. ThumbnailReady() callback will be called when the
       
    85      * operation is complete. In addition, ThumbnailPreviewReady()
       
    86      * callback may be called if EOptimizeForQualityWithPreview mode was
       
    87      * defined.
       
    88      *
       
    89      * Current values for display mode, thumbnail size, flags and performance
       
    90      * preference are used.
       
    91      *
       
    92      * @since S60 v5.0
       
    93      * @param aObjectSource      Source object or file
       
    94      * @param aClientData        Pointer to arbitrary client data.
       
    95      *                           This pointer is not used by the API for
       
    96      *                           anything other than returning it in the
       
    97      *                           ThumbnailReady callback.
       
    98      * @param aPriority          Priority for this operation
       
    99      * @param aGeneratePersistentSizesOnly  Only persitent sizes generated
       
   100      * @return                   Thumbnail request ID
       
   101      */    
       
   102     TThumbnailRequestId GetThumbnailL( CThumbnailObjectSource& aObjectSource,
       
   103     	TAny* aClientData, const TInt aPriority, TBool aGeneratePersistentSizesOnly );    
       
   104    
       
   105     /**
       
   106      * Get a persistent thumbnail for an object file. If a thumbnail already
       
   107      *  exists, it is loaded and if a thumbnail does not exist, it is created
       
   108      * transparently. ThumbnailReady() callback will be called when the
       
   109      * operation is complete. In addition, ThumbnailPreviewReady()
       
   110      * callback may be called if EOptimizeForQualityWithPreview mode was
       
   111      * defined.
       
   112      *
       
   113      * Current values for display mode, thumbnail size, flags and performance
       
   114      * preference are used.
       
   115      *
       
   116      * @since S60 v5.0
       
   117      * @param aThumbnailId       Thumbnail ID
       
   118      * @param aThumbnailSizeType Thumbnail size enumeration
       
   119      * @param aClientData        Pointer to arbitrary client data.
       
   120      *                           This pointer is not used by the API for
       
   121      *                           anything other than returning it in the
       
   122      *                           ThumbnailReady callback.
       
   123      * @param aPriority          Priority for this operation
       
   124      * @return                   Thumbnail request ID. This can be used to
       
   125      *                           cancel the request or change priority.
       
   126      *                           The ID is specific to this CThumbnailManager
       
   127      *                           instance and may not be shared with other
       
   128      *                           instances.
       
   129      */        
       
   130     TThumbnailRequestId GetThumbnailL( const TThumbnailId,
       
   131         TAny* aClientData = NULL, TInt aPriority = CActive::EPriorityIdle );
       
   132     
       
   133     /**
       
   134      * Import an image to be used as thumbnail for an object. If a
       
   135      * thumbnail already exists, it is loaded and if a thumbnail does not
       
   136      * exist, it is created transparently. ThumbnailReady() callback will be
       
   137      * called when the operation is complete. In addition, ThumbnailPreviewReady()
       
   138      * callback may be called if EOptimizeForQualityWithPreview mode was
       
   139      * defined.
       
   140      * 
       
   141      * Current values for display mode, thumbnail size, flags and performance
       
   142      * preference are used.
       
   143      *
       
   144      * @since S60 v5.0
       
   145      * @param aObjectSource      Source object or file
       
   146      * @param aTargetUri         Target URI to which the imported thumbnail is linked.
       
   147      * @param aClientData        Pointer to arbitrary client data.
       
   148      *                           This pointer is not used by the API for
       
   149      *                           anything other than returning it in the
       
   150      *                           ThumbnailReady callback.
       
   151      * @param aPriority          Priority for this operation
       
   152      * @return                   Thumbnail request ID
       
   153      */
       
   154     TThumbnailRequestId ImportThumbnailL( CThumbnailObjectSource& aObjectSource,
       
   155         const TDesC& aTargetUri, TAny* aClientData = NULL,
       
   156         const TInt aPriority = CActive::EPriorityIdle );    
       
   157 
       
   158      /**
       
   159       * Set persistent size scaled thumbnails for an object. If a
       
   160       * thumbnail already exists, it is replaced and if a thumbnail does not
       
   161       * exist, it is created transparently.
       
   162       * 
       
   163       * Current values for display mode, thumbnail size, flags and performance
       
   164       * preference are used.
       
   165       *
       
   166       * @since S60 v5.0
       
   167       * @param aObjectSource      Source object or file
       
   168       * @param aClientData        Pointer to arbitrary client data.
       
   169       *                           This pointer is not used by the API for
       
   170       *                           anything other than returning it in the
       
   171       *                           ThumbnailReady callback.
       
   172       * @param aPriority          Priority for this operation
       
   173       * @return                   Thumbnail request ID. This can be used to
       
   174       *                           cancel the request or change priority.
       
   175       *                           The ID is specific to this CThumbnailManager
       
   176       *                           instance and may not be shared with other
       
   177       *                           instances.
       
   178       */     
       
   179     TThumbnailRequestId SetThumbnailL( CThumbnailObjectSource& source,
       
   180         TAny* aClientData = NULL, 
       
   181         TInt aPriority = CActive::EPriorityIdle );    
       
   182     
       
   183     /**
       
   184      * Get the current display mode for thumbnail bitmaps.
       
   185      *
       
   186      * @since S60 v5.0
       
   187      * @return Default display mode for the thumbnail bitmaps.
       
   188      */
       
   189     TDisplayMode DisplayMode()const;
       
   190 
       
   191     /**
       
   192      * Set the current display mode for thumbnail bitmaps.
       
   193      *
       
   194      * @since S60 v5.0
       
   195      * @param aDisplayMode New display mode value for the thumbnail bitmaps.
       
   196      */
       
   197     void SetDisplayModeL( const TDisplayMode aDisplayMode );
       
   198 
       
   199     /**
       
   200      * Get the current quality versus performance preference.
       
   201      *
       
   202      * @since S60 v5.0
       
   203      * @return Current quality versus performance preference.
       
   204      */
       
   205     TThumbnailQualityPreference QualityPreference()const;
       
   206 
       
   207     /**
       
   208      * Set quality versus performance preference.
       
   209      *
       
   210      * @since S60 v5.0
       
   211      * @param aQualityPreference New quality versus performance preference
       
   212      *                           value.
       
   213      */
       
   214     void SetQualityPreferenceL( const TThumbnailQualityPreference
       
   215         aQualityPreference );
       
   216 
       
   217     /**
       
   218      * Get the current desired size for thumbnail bitmaps.
       
   219      *
       
   220      * @since S60 v5.0
       
   221      * @return Current desired size for thumbnail bitmaps (in pixels).
       
   222      */
       
   223     const TSize& ThumbnailSize()const;
       
   224 
       
   225     /**
       
   226      * Set desired size for thumbnail bitmaps.
       
   227      *
       
   228      * @since S60 v5.0
       
   229      * @param aThumbnailSize New quality for the desired thumbnail size.
       
   230      */
       
   231     void SetThumbnailSizeL( const TSize& aThumbnailSize );
       
   232 
       
   233     /**
       
   234      * Set desired size for thumbnail bitmaps.
       
   235      *
       
   236      * @since S60 v5.0
       
   237      * @param aThumbnailSize New quality for the desired thumbnail size.
       
   238      */
       
   239     void SetThumbnailSizeL( const TThumbnailSize aThumbnailSize );
       
   240 
       
   241     /**
       
   242      * Get current flags for thumbnail generation.
       
   243      *
       
   244      * @since S60 v5.0
       
   245      * @return Current flags.
       
   246      */
       
   247     TThumbnailFlags Flags()const;
       
   248 
       
   249     /**
       
   250      * Set flags for thumbnail generation. Several flags may be enabled
       
   251      * by combining the values using bitwise or.
       
   252      *
       
   253      * @since S60 v5.0
       
   254      * @param aFlags New flags.
       
   255      */
       
   256     void SetFlagsL( const TThumbnailFlags aFlags );
       
   257 
       
   258     /**
       
   259      * Delete all thumbnails for a given object. This is an asynchronous
       
   260      * operation, which always returns immediately.
       
   261      *
       
   262      * @since S60 v5.0
       
   263      * @param aObjectSource Source object or file
       
   264      */
       
   265     void DeleteThumbnails( CThumbnailObjectSource& aObjectSource );
       
   266 
       
   267     /**
       
   268      * Delete thumbnails by TThumbnailId. This is an asynchronous
       
   269      * operation, which always returns immediately.
       
   270      *
       
   271      * @since S60 v5.0
       
   272      * @param aItemId     TThumbnailId
       
   273      */
       
   274     void DeleteThumbnails( const TThumbnailId aItemId );       
       
   275     
       
   276     /**
       
   277      * Create thumbnail for a given object. This is an asynchronous
       
   278      * operation, which always returns immediately. No callbacks are
       
   279      * emitted.
       
   280      *
       
   281      * @since S60 v5.0
       
   282      * @param aObjectSource      Source object or file
       
   283      * @param aPriority          Priority for this operation
       
   284      * @return                   Thumbnail creation request ID
       
   285      */
       
   286     TThumbnailRequestId CreateThumbnails( CThumbnailObjectSource& aObjectSource,
       
   287                                           TInt aPriority = CActive::EPriorityIdle );
       
   288 
       
   289     /**
       
   290      * Cancel a thumbnail operation.
       
   291      *
       
   292      * @since S60 v5.0
       
   293      * @param aId      Request ID for the operation to be cancelled.
       
   294      * @return         Symbian OS error code or KErrNone if cancelling was
       
   295      *                 successful.
       
   296      */
       
   297     TInt CancelRequest( const TThumbnailRequestId aId );
       
   298 
       
   299     /**
       
   300      * Change the priority of a queued thumbnail operation.
       
   301      *
       
   302      * @since S60 v5.0
       
   303      * @param aId           Request ID for the request which to assign a new
       
   304      *                      priority.
       
   305      * @param aNewPriority  New priority value
       
   306      * @return              Symbian OS error code or KErrNone if change was
       
   307      *                      successful.
       
   308      */
       
   309     TInt ChangePriority( const TThumbnailRequestId aId, const TInt aNewPriority );
       
   310 
       
   311     /**
       
   312      * Get a list of supported file formats for object files.
       
   313      * 
       
   314      * The return value is a reference to a list that contains each
       
   315      * supported MIME type. There may also be wildcards, such as "image/ *".
       
   316      * 
       
   317      * The returned reference is valid until CThumbnailManager is
       
   318      * destroyed or GetSupportedMimeTypesL() is called again.
       
   319      *
       
   320      * @since S60 v5.0
       
   321      * @return A list of supported MIME types. May contain wildcards.
       
   322      *         Ownership not transferred.
       
   323      */
       
   324     const CDesCArray& GetSupportedMimeTypesL();
       
   325     
       
   326     /**
       
   327      * Update Thumbnails by TThumbnailId. This is an asynchronous
       
   328      * operation, which always returns immediately.
       
   329      *
       
   330      * @since S60 v5.0
       
   331      * @param aItemId       TThumbnailId
       
   332      * @param aPath         (New) path for the Thumbnail
       
   333      * @param aOrientation  Thumbnail orientation
       
   334      * @param aModified     Last modified
       
   335      * @param aPriority     Priority for this operation
       
   336      */
       
   337      void UpdateThumbnailsL( const TThumbnailId aItemId, const TDesC& aPath,
       
   338                              const TInt aOrientation, const TInt64 aModified, TInt aPriority );
       
   339 
       
   340      /**
       
   341       * Rename Thumbnails. This is an asynchronous
       
   342       * operation, which always returns immediately.
       
   343       *
       
   344       * @since S60 v5.0
       
   345       * @param aCurrentPath     Current path of the Thumbnail
       
   346       * @param aNewPath         New path for the Thumbnail
       
   347       * @param aPriority        Priority for this operation
       
   348       * @return                 Thumbnail request ID. This can be used to
       
   349       *                         cancel the request or change priority.
       
   350       *                         The ID is specific to this CThumbnailManager
       
   351       *                         instance and may not be shared with other
       
   352       *                         instances.
       
   353       */
       
   354      TThumbnailRequestId RenameThumbnailsL( const TDesC& aCurrentPath, 
       
   355              const TDesC& aNewPath, TInt aPriority = CActive::EPriorityIdle );
       
   356 
       
   357      /**
       
   358       * Set optional request observer for getting information about completed 
       
   359       * requests that don't include a thumbnail.
       
   360       *
       
   361       * @since Symbian^3
       
   362       * @param aObserver Observer to receive notifications.
       
   363       */
       
   364      void SetRequestObserver( MThumbnailManagerRequestObserver& aObserver );
       
   365      
       
   366      /**
       
   367       * Remove optional request observer.
       
   368       *
       
   369       * @since Symbian^3
       
   370       */
       
   371      void RemoveRequestObserver();
       
   372      
       
   373 private:
       
   374 
       
   375     /**
       
   376      * C++ default constructor
       
   377      *
       
   378      * @since S60 v5.0
       
   379      * @param  aObserver Observer to receive notifications about completed
       
   380      *                   operations.
       
   381      * @return           New CThumbnailManagerImpl instance.
       
   382      */
       
   383     CThumbnailManagerImpl( MThumbnailManagerObserver& aObserver );
       
   384 
       
   385     /**
       
   386      * Symbian 2nd phase constructor can leave.
       
   387      *
       
   388      * @since S60 v5.0
       
   389      */
       
   390     void ConstructL();
       
   391     
       
   392     /**
       
   393      * Check that given priority is in range of CActive::TPriority
       
   394      *
       
   395      * @since S60 v5.0
       
   396      * @param aPriority Priority
       
   397      * @return Valid priority.
       
   398      */
       
   399     TInt ValidatePriority( const TInt aPriority );
       
   400 
       
   401 
       
   402 private:
       
   403     // data
       
   404 
       
   405     /**
       
   406      * Default width of thumbnail.
       
   407      */
       
   408     TInt iDefaultWidth;
       
   409 
       
   410     /**
       
   411      * Default height of thumbnail
       
   412      */
       
   413     TInt iDefaultHeight;
       
   414 
       
   415     /**
       
   416      * Observer to receive notifications about completed operations.
       
   417      */
       
   418     MThumbnailManagerObserver& iObserver;
       
   419     
       
   420     /**
       
   421      * Observer to receive notifications about completed requests.
       
   422      */
       
   423     MThumbnailManagerRequestObserver* iRequestObserver;
       
   424 
       
   425     /**
       
   426      * Session.
       
   427      */
       
   428     RThumbnailSession iSession;
       
   429 
       
   430     /**
       
   431      * Fileserver.
       
   432      */
       
   433     RFs iFs;
       
   434     
       
   435     /**
       
   436      * Request queue processor.
       
   437      */
       
   438     CThumbnailRequestQueue* iRequestQueue;
       
   439 
       
   440     /**
       
   441      * Display mode.
       
   442      */
       
   443     TDisplayMode iDisplayMode;
       
   444 
       
   445     /**
       
   446      * Flags.
       
   447      */
       
   448     TThumbnailFlags iFlags;
       
   449 
       
   450     /**
       
   451      * Quality preference.
       
   452      */
       
   453     TThumbnailQualityPreference iQualityPreference;
       
   454 
       
   455     /**
       
   456      * Requested size of thumbnail.
       
   457      */
       
   458     TSize iSize;
       
   459     
       
   460     TThumbnailSize iThumbnailSize;
       
   461 
       
   462     /**
       
   463      * Request ID for this thumbnail request, session specific.
       
   464      */
       
   465     TThumbnailRequestId iRequestId;
       
   466 
       
   467     /**
       
   468      * Font and Bitmap Server session. Only used unless the client
       
   469      * does not already have an open session.
       
   470      */
       
   471     RFbsSession iFbsSession;
       
   472 
       
   473     /**
       
   474      * Temporary buffer for filename handling
       
   475      */
       
   476     TFileName iFileNameBuf;
       
   477 
       
   478     /**
       
   479      * List of supported MIME-types.
       
   480      * Own.
       
   481      */
       
   482     CDesCArraySeg* iMimeTypeList;
       
   483 };
       
   484 
       
   485 #endif