PECengine/AttributeLibrary2/SrcWVAttributes/CPEngMyLogoConverter.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2005 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:  MyLogo converter.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CPENGMYLOGOCONVERTER_H_
       
    19 #define CPENGMYLOGOCONVERTER_H_
       
    20 
       
    21 //  INCLUDES
       
    22 #include <E32Base.h>
       
    23 #include <F32file.h>
       
    24 
       
    25 
       
    26 
       
    27 //FORWARD DECLARATION
       
    28 class CImageDecoder;
       
    29 class CImageEncoder;
       
    30 class CBitmapScaler;
       
    31 class CFbsBitmap;
       
    32 class MPEngMyLogoConversionObserver;
       
    33 
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 /**
       
    38  * MyLogo converter.
       
    39  *
       
    40  * @since 3.0
       
    41  */
       
    42 NONSHARABLE_CLASS( CPEngMyLogoConverter ) : public CActive
       
    43     {
       
    44 private:  // private enumerations
       
    45 
       
    46     /**
       
    47      * Logo converter states.
       
    48      */
       
    49     enum TLogoConverterState
       
    50         {
       
    51         EConverterIdle = 0,  //Idle state, no operation running
       
    52         EImageOpenToBitmap,
       
    53         EBitmapScaleDown,
       
    54         EBitmapStoreToImage,
       
    55         };
       
    56 
       
    57 
       
    58 public:  // Two-phased constructors and destructor
       
    59 
       
    60     /**
       
    61      * Two-phased constructor.
       
    62      * Constructs the converter for image file.
       
    63      */
       
    64     static CPEngMyLogoConverter* FileNewL( const TDesC& aFileName,
       
    65                                            MPEngMyLogoConversionObserver& aObserver );
       
    66 
       
    67     /**
       
    68      * Two-phased constructor.
       
    69      * Constructs the converter for image buffer.
       
    70      */
       
    71     static CPEngMyLogoConverter* DataNewL( const TDesC8& aImageData,
       
    72                                            MPEngMyLogoConversionObserver& aObserver );
       
    73 
       
    74 
       
    75     /**
       
    76      * Destructor.
       
    77      */
       
    78     virtual ~CPEngMyLogoConverter();
       
    79 
       
    80 
       
    81 private:
       
    82 
       
    83     /**
       
    84      * C++ default constructor.
       
    85      */
       
    86     CPEngMyLogoConverter( MPEngMyLogoConversionObserver& aObserver );
       
    87 
       
    88 
       
    89     /**
       
    90      * Symbian 2nd phase constructor.
       
    91      */
       
    92     void ConstructFromFileL( const TDesC& aImageFile );
       
    93     void ConstructFromDataL( const TDesC8& aImageData );
       
    94 
       
    95 
       
    96 
       
    97 public: // New functions
       
    98 
       
    99     /**
       
   100      * Conversion service.
       
   101      *
       
   102      * @since 3.0
       
   103      *
       
   104      * @param
       
   105      */
       
   106     void IssueConvert( TRequestStatus& aRequestStatus );
       
   107 
       
   108 
       
   109 
       
   110 protected:  // From CActive
       
   111 
       
   112 
       
   113     /**
       
   114      * RunL().
       
   115      *
       
   116      * Performs the conversion steps
       
   117      * according the states.
       
   118      *
       
   119      * @since 3.0
       
   120      */
       
   121     void RunL();
       
   122 
       
   123 
       
   124     /**
       
   125      * RunError().
       
   126      *
       
   127      * Completes the client request with reported error.
       
   128      *
       
   129      * @since 3.0
       
   130      * @param aError The leave code from RunL leave.
       
   131      * @return Always KErrNone.
       
   132      */
       
   133     TInt RunError( TInt aError );
       
   134 
       
   135 
       
   136     /**
       
   137      * DoCancel().
       
   138      *
       
   139      * cancels the currently active processing state.
       
   140      *
       
   141      * @since 3.0
       
   142      */
       
   143     void DoCancel();
       
   144 
       
   145 
       
   146 
       
   147 private: // Private helper methods
       
   148 
       
   149     /**
       
   150      * Sets the active object active and advances the
       
   151      * state to given one.
       
   152      *
       
   153      * @since 3.0
       
   154      * @param aNewState The new state.
       
   155      */
       
   156     void SetStateActive( TLogoConverterState aNewState );
       
   157 
       
   158 
       
   159     /**
       
   160      * Checks does the processed image fulfil MyLogo
       
   161      * requirements.
       
   162      *
       
   163      * @since 3.0
       
   164      * @return ETrue if source image satisfies MyLogo
       
   165      * requirements. Else EFalse.
       
   166      */
       
   167     TBool VerifyMyLogoRequirementsL();
       
   168 
       
   169 
       
   170     /**
       
   171      * Issues the image open to bitmap.
       
   172      *
       
   173      * @since 3.0
       
   174      */
       
   175     void IssueImageOpenToBitmapL();
       
   176 
       
   177 
       
   178     /**
       
   179      * Issues the image scale down.
       
   180      *
       
   181      * @since 3.0
       
   182      */
       
   183     void IssueBitmapScaleDownL();
       
   184 
       
   185 
       
   186     /**
       
   187      * Issues the bitmap store to destination image.
       
   188      *
       
   189      * @since 3.0
       
   190      */
       
   191     void IssueBitmapStoreToImageL();
       
   192 
       
   193 
       
   194     /**
       
   195      * Notifies registered observer from
       
   196      * new logo data.
       
   197      *
       
   198      * @since 3.0
       
   199      */
       
   200     void NotifyNewLogo();
       
   201 
       
   202 
       
   203     /**
       
   204      * Completes the original client request with
       
   205      * given status and deletes the object itself.
       
   206      *
       
   207      * @since 3.0
       
   208      * @param aStatus The completion code.
       
   209      */
       
   210     void ConversionCompletedD( TInt aStatus );
       
   211 
       
   212 
       
   213     /**
       
   214      * Panics the converter with given reason.
       
   215      *
       
   216      * @since 3.0
       
   217      * @param aPanicReason The reason code.
       
   218      */
       
   219     void PanicConverter( TInt aPanicReason ) const;
       
   220 
       
   221 
       
   222 
       
   223 
       
   224 private:    // Data
       
   225 
       
   226     //OWN: The file server session.
       
   227     RFs     iFs;
       
   228 
       
   229     //OWN: The converter state.
       
   230     TLogoConverterState     iState;
       
   231 
       
   232     //OWN: The convert observer.
       
   233     MPEngMyLogoConversionObserver&  iObserver;
       
   234 
       
   235     //REF: Request status from client
       
   236     TRequestStatus* iClientRequest;
       
   237 
       
   238     //OWN: The image data buffer
       
   239     HBufC8* iImageDataBuffer;
       
   240 
       
   241     //OWN: The image mime type buffer
       
   242     HBufC8* iImageMimeTypeBuffer;
       
   243 
       
   244     //OWN: The image filename buffer
       
   245     HBufC16*    iImageFileNameBuffer;
       
   246 
       
   247     //OWN: The image decoder. Lazy initialized.
       
   248     CImageDecoder*  iImageDecoder;
       
   249 
       
   250     //OWN: The image encoder. Lazy initialized.
       
   251     CImageEncoder*  iImageEncoder;
       
   252 
       
   253     //OWN: Image scaler. Lazy initialized.
       
   254     CBitmapScaler*  iBitmapScaler;
       
   255 
       
   256     //OWN: MyLogo fbs bitmap. Lazy initialized.
       
   257     CFbsBitmap* iMyLogoBitmap;
       
   258     };
       
   259 
       
   260 
       
   261 
       
   262 
       
   263 // CLASS DECLARATION
       
   264 
       
   265 /**
       
   266  * Logo converter observer interface.
       
   267  *
       
   268  * @since 3.0
       
   269  */
       
   270 class MPEngMyLogoConversionObserver
       
   271     {
       
   272     public: //Observation methods
       
   273 
       
   274 
       
   275         /**
       
   276          * Reports the observer new MyLogo contents.
       
   277          *
       
   278          * NOTE: Observer must take the ownership
       
   279          * of parameters in all cases.
       
   280          *
       
   281          * @since 3.0
       
   282          * @param aImageData The MyLogo image data.
       
   283          * @param aImageMimeType The MyLogo mime type.
       
   284          * @param aImageSoureFileName The source file name.
       
   285          */
       
   286         virtual void HandleNewMyLogo( HBufC8* aImageData,
       
   287                                       HBufC8* aImageMimeType,
       
   288                                       HBufC* aImageSoureFileName ) = 0;
       
   289 
       
   290 
       
   291         /**
       
   292          * Reports the converter complete.
       
   293          *
       
   294          * @since 3.0
       
   295          */
       
   296         virtual void HandleConverterDestroy() = 0;
       
   297 
       
   298 
       
   299 
       
   300 
       
   301     protected: //Prohibited destructor
       
   302 
       
   303         /**
       
   304          * Inline virtual destructor. Concrete
       
   305          * observer can't be destroyed using
       
   306          * this interface.
       
   307          *
       
   308          * @since 3.0
       
   309          */
       
   310         virtual ~MPEngMyLogoConversionObserver() {};
       
   311 
       
   312     };
       
   313 
       
   314 
       
   315 
       
   316 
       
   317 
       
   318 
       
   319 #endif      // CPENGMYLOGOCONVERTER_H_
       
   320 
       
   321 // End of File