imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailmanagerimpl.h
changeset 0 2014ca87e772
child 11 dea39715fc05
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:  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     /**
       
    83      * Get a thumbnail for an object file. If a thumbnail already exists, it
       
    84      * is loaded and if a thumbnail does not exist, it is created
       
    85      * transparently. ThumbnailReady() callback will be called when the
       
    86      * operation is complete. In addition, ThumbnailPreviewReady()
       
    87      * callback may be called if EOptimizeForQualityWithPreview mode was
       
    88      * defined.
       
    89      *
       
    90      * Current values for display mode, thumbnail size, flags and performance
       
    91      * preference are used.
       
    92      *
       
    93      * @since S60 v5.0
       
    94      * @param aObjectSource      Source object or file
       
    95      * @param aClientData        Pointer to arbitrary client data.
       
    96      *                           This pointer is not used by the API for
       
    97      *                           anything other than returning it in the
       
    98      *                           ThumbnailReady callback.
       
    99      * @param aPriority          Priority for this operation
       
   100      * @param aGeneratePersistentSizesOnly  Only persitent sizes generated
       
   101      * @return                   Thumbnail request ID
       
   102      */    
       
   103     TThumbnailRequestId GetThumbnailL( CThumbnailObjectSource& aObjectSource,
       
   104     	TAny* aClientData, const TInt aPriority, TBool aGeneratePersistentSizesOnly);    
       
   105    
       
   106     /**
       
   107      * Get a persistent thumbnail for an object file. If a thumbnail already
       
   108      *  exists, it is loaded and if a thumbnail does not exist, it is created
       
   109      * transparently. ThumbnailReady() callback will be called when the
       
   110      * operation is complete. In addition, ThumbnailPreviewReady()
       
   111      * callback may be called if EOptimizeForQualityWithPreview mode was
       
   112      * defined.
       
   113      *
       
   114      * Current values for display mode, thumbnail size, flags and performance
       
   115      * preference are used.
       
   116      *
       
   117      * @since S60 v5.0
       
   118      * @param aThumbnailId       Thumbnail ID
       
   119      * @param aThumbnailSizeType Thumbnail size enumeration
       
   120      * @param aClientData        Pointer to arbitrary client data.
       
   121      *                           This pointer is not used by the API for
       
   122      *                           anything other than returning it in the
       
   123      *                           ThumbnailReady callback.
       
   124      * @param aPriority          Priority for this operation
       
   125      * @return                   Thumbnail request ID. This can be used to
       
   126      *                           cancel the request or change priority.
       
   127      *                           The ID is specific to this CThumbnailManager
       
   128      *                           instance and may not be shared with other
       
   129      *                           instances.
       
   130      */        
       
   131     TThumbnailRequestId GetThumbnailL( const TThumbnailId,
       
   132         TAny* aClientData = NULL, TInt aPriority = CActive::EPriorityIdle );
       
   133     
       
   134     /**
       
   135      * Import an image to be used as thumbnail for an object. If a
       
   136      * thumbnail already exists, it is loaded and if a thumbnail does not
       
   137      * exist, it is created transparently. ThumbnailReady() callback will be
       
   138      * called when the operation is complete. In addition, ThumbnailPreviewReady()
       
   139      * callback may be called if EOptimizeForQualityWithPreview mode was
       
   140      * defined.
       
   141      * 
       
   142      * Current values for display mode, thumbnail size, flags and performance
       
   143      * preference are used.
       
   144      *
       
   145      * @since S60 v5.0
       
   146      * @param aObjectSource      Source object or file
       
   147      * @param aTargetUri         Target URI to which the imported thumbnail is linked.
       
   148      * @param aClientData        Pointer to arbitrary client data.
       
   149      *                           This pointer is not used by the API for
       
   150      *                           anything other than returning it in the
       
   151      *                           ThumbnailReady callback.
       
   152      * @param aPriority          Priority for this operation
       
   153      * @return                   Thumbnail request ID
       
   154      */
       
   155     TThumbnailRequestId ImportThumbnailL( CThumbnailObjectSource& aObjectSource,
       
   156         const TDesC& aTargetUri, TAny* aClientData = NULL,
       
   157         const TInt aPriority = CActive::EPriorityIdle );    
       
   158 
       
   159      /**
       
   160       * Set persistent size scaled thumbnails for an object. If a
       
   161       * thumbnail already exists, it is replaced and if a thumbnail does not
       
   162       * exist, it is created transparently.
       
   163       * 
       
   164       * Current values for display mode, thumbnail size, flags and performance
       
   165       * preference are used.
       
   166       *
       
   167       * @since S60 v5.0
       
   168       * @param aObjectSource      Source object or file
       
   169       * @param aClientData        Pointer to arbitrary client data.
       
   170       *                           This pointer is not used by the API for
       
   171       *                           anything other than returning it in the
       
   172       *                           ThumbnailReady callback.
       
   173       * @param aPriority          Priority for this operation
       
   174       * @return                   Thumbnail request ID. This can be used to
       
   175       *                           cancel the request or change priority.
       
   176       *                           The ID is specific to this CThumbnailManager
       
   177       *                           instance and may not be shared with other
       
   178       *                           instances.
       
   179       */     
       
   180     TThumbnailRequestId SetThumbnailL( CThumbnailObjectSource& source,
       
   181         TAny* aClientData = NULL, 
       
   182         TInt aPriority = CActive::EPriorityIdle);    
       
   183     
       
   184     /**
       
   185      * Get the current display mode for thumbnail bitmaps.
       
   186      *
       
   187      * @since S60 v5.0
       
   188      * @return Default display mode for the thumbnail bitmaps.
       
   189      */
       
   190     TDisplayMode DisplayMode()const;
       
   191 
       
   192     /**
       
   193      * Set the current display mode for thumbnail bitmaps.
       
   194      *
       
   195      * @since S60 v5.0
       
   196      * @param aDisplayMode New display mode value for the thumbnail bitmaps.
       
   197      */
       
   198     void SetDisplayModeL( const TDisplayMode aDisplayMode );
       
   199 
       
   200     /**
       
   201      * Get the current quality versus performance preference.
       
   202      *
       
   203      * @since S60 v5.0
       
   204      * @return Current quality versus performance preference.
       
   205      */
       
   206     TThumbnailQualityPreference QualityPreference()const;
       
   207 
       
   208     /**
       
   209      * Set quality versus performance preference.
       
   210      *
       
   211      * @since S60 v5.0
       
   212      * @param aQualityPreference New quality versus performance preference
       
   213      *                           value.
       
   214      */
       
   215     void SetQualityPreferenceL( const TThumbnailQualityPreference
       
   216         aQualityPreference );
       
   217 
       
   218     /**
       
   219      * Get the current desired size for thumbnail bitmaps.
       
   220      *
       
   221      * @since S60 v5.0
       
   222      * @return Current desired size for thumbnail bitmaps (in pixels).
       
   223      */
       
   224     const TSize& ThumbnailSize()const;
       
   225 
       
   226     /**
       
   227      * Set desired size for thumbnail bitmaps.
       
   228      *
       
   229      * @since S60 v5.0
       
   230      * @param aThumbnailSize New quality for the desired thumbnail size.
       
   231      */
       
   232     void SetThumbnailSizeL( const TSize& aThumbnailSize );
       
   233 
       
   234     /**
       
   235      * Set desired size for thumbnail bitmaps.
       
   236      *
       
   237      * @since S60 v5.0
       
   238      * @param aThumbnailSize New quality for the desired thumbnail size.
       
   239      */
       
   240     void SetThumbnailSizeL( const TThumbnailSize aThumbnailSize );
       
   241 
       
   242     /**
       
   243      * Get current flags for thumbnail generation.
       
   244      *
       
   245      * @since S60 v5.0
       
   246      * @return Current flags.
       
   247      */
       
   248     TThumbnailFlags Flags()const;
       
   249 
       
   250     /**
       
   251      * Set flags for thumbnail generation. Several flags may be enabled
       
   252      * by combining the values using bitwise or.
       
   253      *
       
   254      * @since S60 v5.0
       
   255      * @param aFlags New flags.
       
   256      */
       
   257     void SetFlagsL( const TThumbnailFlags aFlags );
       
   258 
       
   259     /**
       
   260      * Delete all thumbnails for a given object. This is an asynchronous
       
   261      * operation, which always returns immediately.
       
   262      *
       
   263      * @since S60 v5.0
       
   264      * @param aObjectSource Source object or file
       
   265      */
       
   266     void DeleteThumbnails( CThumbnailObjectSource& aObjectSource );
       
   267 
       
   268     /**
       
   269      * Delete thumbnails by TThumbnailId. This is an asynchronous
       
   270      * operation, which always returns immediately.
       
   271      *
       
   272      * @since S60 v5.0
       
   273      * @param aItemId     TThumbnailId
       
   274      */
       
   275     void DeleteThumbnails( const TThumbnailId aItemId );       
       
   276     
       
   277     /**
       
   278      * Create thumbnail for a given object. This is an asynchronous
       
   279      * operation, which always returns immediately. No callbacks are
       
   280      * emitted.
       
   281      *
       
   282      * @since S60 v5.0
       
   283      * @param aObjectSource      Source object or file
       
   284      * @param aPriority          Priority for this operation
       
   285      * @return                   Thumbnail creation request ID
       
   286      */
       
   287     TThumbnailRequestId CreateThumbnails( CThumbnailObjectSource& aObjectSource,
       
   288                                           TInt aPriority = CActive::EPriorityIdle );
       
   289 
       
   290     /**
       
   291      * Cancel a thumbnail operation.
       
   292      *
       
   293      * @since S60 v5.0
       
   294      * @param aId      Request ID for the operation to be cancelled.
       
   295      * @return         Symbian OS error code or KErrNone if cancelling was
       
   296      *                 successful.
       
   297      */
       
   298     TInt CancelRequest( const TThumbnailRequestId aId );
       
   299 
       
   300     /**
       
   301      * Change the priority of a queued thumbnail operation.
       
   302      *
       
   303      * @since S60 v5.0
       
   304      * @param aId           Request ID for the request which to assign a new
       
   305      *                      priority.
       
   306      * @param aNewPriority  New priority value
       
   307      * @return              Symbian OS error code or KErrNone if change was
       
   308      *                      successful.
       
   309      */
       
   310     TInt ChangePriority( const TThumbnailRequestId aId, const TInt aNewPriority
       
   311         );
       
   312 
       
   313     /**
       
   314      * Get a list of supported file formats for object files.
       
   315      * 
       
   316      * The return value is a reference to a list that contains each
       
   317      * supported MIME type. There may also be wildcards, such as "image/ *".
       
   318      * 
       
   319      * The returned reference is valid until CThumbnailManager is
       
   320      * destroyed or GetSupportedMimeTypesL() is called again.
       
   321      *
       
   322      * @since S60 v5.0
       
   323      * @return A list of supported MIME types. May contain wildcards.
       
   324      *         Ownership not transferred.
       
   325      */
       
   326     const CDesCArray& GetSupportedMimeTypesL();
       
   327     
       
   328     /**
       
   329      * Update Thumbnails by TThumbnailId. This is an asynchronous
       
   330      * operation, which always returns immediately.
       
   331      *
       
   332      * @since S60 v5.0
       
   333      * @param aItemId       TThumbnailId
       
   334      * @param aPath         (New) path for the Thumbnail
       
   335      * @param aOrientation  Thumbnail orientation
       
   336      * @param aModified     Last modified
       
   337      * @param aPriority     Priority for this operation
       
   338      */
       
   339      void UpdateThumbnailsL( const TThumbnailId aItemId, const TDesC& aPath,
       
   340                              const TInt aOrientation, const TInt64 aModified, TInt aPriority );
       
   341 
       
   342 private:
       
   343 
       
   344     /**
       
   345      * C++ default constructor
       
   346      *
       
   347      * @since S60 v5.0
       
   348      * @param  aObserver Observer to receive notifications about completed
       
   349      *                   operations.
       
   350      * @return           New CThumbnailManagerImpl instance.
       
   351      */
       
   352     CThumbnailManagerImpl( MThumbnailManagerObserver& aObserver );
       
   353 
       
   354     /**
       
   355      * Symbian 2nd phase constructor can leave.
       
   356      *
       
   357      * @since S60 v5.0
       
   358      */
       
   359     void ConstructL();
       
   360 
       
   361 
       
   362 private:
       
   363     // data
       
   364 
       
   365     /**
       
   366      * Default width of thumbnail.
       
   367      */
       
   368     TInt iDefaultWidth;
       
   369 
       
   370     /**
       
   371      * Default height of thumbnail
       
   372      */
       
   373     TInt iDefaultHeight;
       
   374 
       
   375     /**
       
   376      * Observer to receive notifications about completed operations.
       
   377      */
       
   378     MThumbnailManagerObserver& iObserver;
       
   379 
       
   380     /**
       
   381      * Session.
       
   382      */
       
   383     RThumbnailSession iSession;
       
   384 
       
   385     /**
       
   386      * Fileserver.
       
   387      */
       
   388     RFs iFs;
       
   389     
       
   390     /**
       
   391      * Request queue processor.
       
   392      */
       
   393     CThumbnailRequestQueue* iRequestQueue;
       
   394 
       
   395     /**
       
   396      * Display mode.
       
   397      */
       
   398     TDisplayMode iDisplayMode;
       
   399 
       
   400     /**
       
   401      * Flags.
       
   402      */
       
   403     TThumbnailFlags iFlags;
       
   404 
       
   405     /**
       
   406      * Quality preference.
       
   407      */
       
   408     TThumbnailQualityPreference iQualityPreference;
       
   409 
       
   410     /**
       
   411      * Requested size of thumbnail.
       
   412      */
       
   413     TSize iSize;
       
   414     
       
   415     TThumbnailSize iThumbnailSize;
       
   416 
       
   417     /**
       
   418      * Request ID for this thumbnail request, session specific.
       
   419      */
       
   420     TThumbnailRequestId iRequestId;
       
   421 
       
   422     /**
       
   423      * Font and Bitmap Server session. Only used unless the client
       
   424      * does not already have an open session.
       
   425      */
       
   426     RFbsSession iFbsSession;
       
   427 
       
   428     /**
       
   429      * Temporary buffer for filename handling
       
   430      */
       
   431     TFileName iFileNameBuf;
       
   432 
       
   433     /**
       
   434      * List of supported MIME-types.
       
   435      * Own.
       
   436      */
       
   437     CDesCArraySeg* iMimeTypeList;
       
   438 };
       
   439 
       
   440 #endif