upnpframework/upnpthumbnail/inc/upnpthumbnailcreator.h
branchIOP_Improvements
changeset 40 08b5eae9f9ff
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
       
     1 /*
       
     2 * Copyright (c) 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:      
       
    15 *
       
    16 */
       
    17 
       
    18 // This file defines the API for ThumbnailCreator.dll
       
    19 
       
    20 #ifndef __UPNPTHUMBNAILCREATOR_H__
       
    21 #define __UPNPTHUMBNAILCREATOR_H__
       
    22 
       
    23 //  Include Files
       
    24 
       
    25 #include <e32base.h>	// CBase
       
    26 #include <e32std.h>	 // TBuf
       
    27 #include <mdesession.h>
       
    28 #include <mdeconstants.h>
       
    29 #include <mdenamespacedef.h>
       
    30 #include <mdequery.h>
       
    31 #include <mdeobject.h>
       
    32 #include <thumbnailmanager.h>
       
    33 #include <thumbnailmanagerobserver.h>
       
    34 #include "upnpthumbnailcreatorobserver.h"
       
    35 
       
    36 class CMdeSession;
       
    37 class CMdEObjectQuery;
       
    38 class CFbsBitmap;
       
    39 class CImageEncoder;
       
    40 //  Constants
       
    41 
       
    42 enum TThumbnailDlnaSize
       
    43     {
       
    44     ESmall = 0,
       
    45     EMedium,
       
    46     ELarge,
       
    47     EThumbnail,
       
    48     ESmallIcon,
       
    49     ELargeIcon
       
    50     };
       
    51 
       
    52 //  Class Definitions
       
    53 
       
    54 NONSHARABLE_CLASS( CUpnpThumbnailCreator) : private CActive,
       
    55                                           private MMdESessionObserver,
       
    56                                           private MMdEQueryObserver,
       
    57                                           private MThumbnailManagerObserver
       
    58     {
       
    59 public:
       
    60     // states for this engine
       
    61     enum TThumbnailCreatorStates 
       
    62         {
       
    63         EIdle = 0,
       
    64         EInitializeMde,
       
    65         EQueryingImage,
       
    66         EFetchingThumbnail,
       
    67         EConvertingThumbnail
       
    68         };
       
    69         // new functions
       
    70     
       
    71     /**
       
    72      * static NewL
       
    73      *
       
    74      * @param MUpnpThumbnailCreatorObserver, thumbnail creator observer
       
    75      * @param aFilePath, file path of the source file
       
    76      * @return instance to CUpnpThumbnailCreator
       
    77      */
       
    78     IMPORT_C static CUpnpThumbnailCreator* NewL(
       
    79                     MUpnpThumbnailCreatorObserver& aMThumbnailCreatorObserver,
       
    80                     const TDesC& aFilePath,
       
    81                     TThumbnailDlnaSize aSize);
       
    82     
       
    83     /**
       
    84      * static NewLC
       
    85      *
       
    86      * @param MUpnpThumbnailCreatorObserver, thumbnail creator observer
       
    87      * @param aFilePath, file path of the source file 
       
    88      * @return instance to CUpnpThumbnailCreator
       
    89      */
       
    90     IMPORT_C static CUpnpThumbnailCreator* NewLC(
       
    91                     MUpnpThumbnailCreatorObserver& aMThumbnailCreatorObserver,
       
    92                     const TDesC& aFilePath,
       
    93                     TThumbnailDlnaSize aSize);
       
    94 
       
    95 
       
    96     /**
       
    97      * On completion of the ThumbnailCreatorReady callback with status KErrNone, 
       
    98      * this method MdeObjectId returns the MdE object Id for the image.
       
    99      * @return ObjectId for the object in MdE 
       
   100      */
       
   101     IMPORT_C TInt MdeObjectId() const;
       
   102     
       
   103     /**
       
   104      * On completion of the ThumbnailCreatorReady callback with status KErrNone, 
       
   105      * this method ThumbnailFilePath returns the thumbnail file path.
       
   106      * @return filepath of the thumbnail 
       
   107      */
       
   108     IMPORT_C const TDesC& ThumbnailFilePath() const;
       
   109     
       
   110     /**
       
   111      * On completion of the ThumbnailCreatorReady callback with status KErrNone, 
       
   112      * this method Thumbnail returns the thumbnail
       
   113      * @return reference to thumbnail created 
       
   114      */
       
   115     IMPORT_C CFbsBitmap& Thumbnail() const;
       
   116 
       
   117 public:
       
   118     
       
   119     /**
       
   120      *  Destructor
       
   121      */
       
   122      ~CUpnpThumbnailCreator();
       
   123     
       
   124 private:
       
   125     /********************************************************************
       
   126      * MMdESessionObserver  virtual methods
       
   127      ********************************************************************/
       
   128     void HandleSessionOpened(CMdESession& aSession, TInt aError);
       
   129     void HandleSessionError(CMdESession& aSession, TInt aError);
       
   130     
       
   131     /********************************************************************
       
   132      * MMdEQueryObserver virtual methods
       
   133      ********************************************************************/
       
   134     void HandleQueryNewResults(CMdEQuery& aQuery, TInt aFirstNewItemIndex,
       
   135                                            TInt aNewItemCount);
       
   136     void HandleQueryCompleted(CMdEQuery& aQuery, TInt aError);
       
   137     
       
   138     /********************************************************************
       
   139      * MThumbnailManagerObserver virtual methods
       
   140      ********************************************************************/
       
   141     // Callbacks from MThumbnailManagerObserver for getting thumbnails
       
   142     void ThumbnailPreviewReady(MThumbnailData& aThumbnail,
       
   143                                             TThumbnailRequestId aId );
       
   144     
       
   145     void ThumbnailReady(TInt aError, MThumbnailData& aThumbnail, 
       
   146                                             TThumbnailRequestId aId );    
       
   147     
       
   148 
       
   149 private:
       
   150     // CActive
       
   151      void DoCancel();
       
   152      void RunL();    
       
   153      TInt RunError (TInt aError);
       
   154     
       
   155 private:
       
   156     // new functions
       
   157     
       
   158     // CI: erkki missing doxygen comments @param ...
       
   159     
       
   160     /** CUpnpthumbnailCreator Constructor*/
       
   161     CUpnpThumbnailCreator(
       
   162             MUpnpThumbnailCreatorObserver& aMUpnpThumbnailCreatorObserver,
       
   163             TThumbnailDlnaSize aSize);
       
   164     
       
   165     /** Two Phase constructor -ConstructL method*/
       
   166     void ConstructL(const TDesC& aFilePath);
       
   167     
       
   168     TSize ConvertDlnaSizeToImageSize();
       
   169     
       
   170     /** Query to Metadata engine*/
       
   171     void QueryMdeL();
       
   172     
       
   173     /** GetThumbnail from Thumbnailmanager*/
       
   174     void GetThumbnail();
       
   175     
       
   176     /** Pepare the filepath for thumbnail storage*/
       
   177     void PrepareThumbnailFilePathL();
       
   178 
       
   179     /** Notifies observer*/
       
   180     void ThumbnailReady( TInt aErr );
       
   181     
       
   182     /** Uses ICL encoder to Encode and Save the thumbnail*/
       
   183     void EncodeAndSaveThumbnailL();
       
   184     
       
   185     /** Completes active object*/
       
   186     void CompleteRequest(TInt aError);
       
   187     
       
   188 
       
   189 
       
   190 private:
       
   191     // data
       
   192     CMdESession* iMdESession;  //owned
       
   193     CMdEQuery* iMdEQuery;      //owned
       
   194     CFbsBitmap* iThumbnail;    //owned
       
   195     HBufC* iImageFilePath;     //owned
       
   196     HBufC* iThumbnailFilePath; //owned
       
   197     TInt iObjectid;
       
   198     CThumbnailManager* iThmbManager; //owned
       
   199     MUpnpThumbnailCreatorObserver& iMUpnpThumbnailCreatorObserver;
       
   200     RFs iFsSession;    //owned
       
   201     CImageEncoder*         iImageEncoder; //owned, encoder from ICL API    
       
   202     TThumbnailCreatorStates iState;
       
   203     TThumbnailDlnaSize iThumbnailDlnaSize;
       
   204     };
       
   205 
       
   206 #endif  // __UPNPTHUMBNAILCREATOR_H__
       
   207