mobilemessaging/postcard/postcardinc/PostcardOperationOpen.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     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:  
       
    15 *       CPostcardOperationOpen, asynchronous operation for postcard opening
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 #ifndef __POSTCARDOPERATIONOPEN_H
       
    23 #define __POSTCARDOPERATIONOPEN_H
       
    24 
       
    25 // INCLUDES
       
    26 
       
    27 #include <e32base.h>
       
    28 #include <e32std.h>
       
    29 
       
    30 #include <uniimageprocessor.h>
       
    31 
       
    32 #include <MIHLViewerObserver.h>
       
    33 
       
    34 #include "PostcardOperation.h"
       
    35 #include "PostcardContact.h"
       
    36 
       
    37 // CONSTANTS
       
    38 
       
    39 // MACROS
       
    40 
       
    41 // FORWARD DECLARATIONS
       
    42 class MIHLFileImage;
       
    43 class MIHLBitmap;
       
    44 class MIHLImageViewer;
       
    45 class CContactCard;
       
    46 class CFbsBitmap;
       
    47 class CMsgMediaInfo;
       
    48 class CMsvAttachment;
       
    49 class CPlainText;
       
    50 
       
    51 // DATA TYPES
       
    52 
       
    53 // FUNCTION PROTOTYPES
       
    54 
       
    55 // CLASS DECLARATION
       
    56 
       
    57 /**
       
    58 * CPostcardOperationOpen 
       
    59 *
       
    60 * @lib postcardeditor.exe
       
    61 * @since 3.0
       
    62 */
       
    63 class CPostcardOperationOpen : public CPostcardOperation,
       
    64                                public MUniImageProcessorCallback,
       
    65                                public MIHLViewerObserver
       
    66 
       
    67     {
       
    68     public:  // New methods
       
    69 
       
    70         /**
       
    71         * Factory method that creates this object.
       
    72         * @since    3.0
       
    73         * @return   Pointer to instance
       
    74         */
       
    75         static CPostcardOperationOpen* NewL(
       
    76             MPostcardOperationObserver& aObserver,
       
    77             CPostcardDocument& aDocument,
       
    78             CPostcardAppUi& aAppUi,
       
    79             RFs& aFs );
       
    80 
       
    81         /**
       
    82         * Destructor
       
    83         */
       
    84         virtual ~CPostcardOperationOpen( );
       
    85 
       
    86         /**
       
    87         * Just initializes the iLaunchStep and completes
       
    88         */
       
    89 		void Start( TInt aArgument );
       
    90 
       
    91     private: // Constants
       
    92 
       
    93         enum TPostcardOpenState
       
    94             {
       
    95             EPostcardOpenInitializing = 0,
       
    96             EPostcardOpenCheckAttas,
       
    97             EPostcardOpenHandleImage,
       
    98             EPostcardOpenProcessImage,
       
    99 			EPostcardOpenUpdateSendasImageFile,
       
   100             EPostcardOpenScaleImage,
       
   101             EPostcardOpenHandleText,
       
   102             EPostcardOpenHandleRecipient,
       
   103             EPostcardOpenFinished,
       
   104             EPostcardOpenError
       
   105             };
       
   106 
       
   107         enum TPostcardOpenFlags
       
   108             {
       
   109             EPostcardOpenRequestActive = 1,
       
   110             EPostcardOpenConvertingPNG = 2
       
   111             };
       
   112 
       
   113     private: // Methods
       
   114 
       
   115         /**
       
   116         * Called by RunL.
       
   117         * Calls different functions according to iLaunchStep
       
   118         */
       
   119         void DoLaunchStepL( );
       
   120 
       
   121         /**
       
   122         * If image is present and postcard type is sendui 
       
   123         * -> creates a media info object and checks the validity
       
   124         * If image needs compressing -> starts to create a new attachment
       
   125         * Otherwise starts scaling the image to bitmaps
       
   126         */
       
   127         void DoHandleImageL( );
       
   128 
       
   129         /**
       
   130         * This functions starts the image process
       
   131         */
       
   132 		void DoStartProcessImageL( );
       
   133 
       
   134         /**
       
   135         * In case of image, adds CMsvHeaders to the attachment
       
   136         */
       
   137         void DoUpdateSendasAttachmentL( const TDataType& aMimeType );
       
   138 
       
   139         /*
       
   140         * Parse address and greeting out of special format text
       
   141         */
       
   142         void ParseSpecialFormatTextL( CPlainText& aText, CContactCard& aCard, CPlainText& aGreeting );
       
   143 
       
   144         /**
       
   145         * Reads the possible text from the message store.
       
   146         * Check if this is special phonebook created text where the contact id is stored
       
   147         * If it is, DoHandlePhonebookSendAsL is called.
       
   148         * Otherwise if this is SendUi originated file, just passes the text into AppUi object.
       
   149         * If opened for example from Drafts or Sent folder check if special text format is used
       
   150         * If it is, DoHandleSpecialFormatOpenL is called.
       
   151         * Otherwise just passes the text to AppUi object.
       
   152         */
       
   153         void DoHandleTextL( );
       
   154 
       
   155         /**
       
   156         * Reads the VCard from the message store. If this is forward, it deletes the VCard.
       
   157         * Otherwise creates new CContactCard from the store and passes it to AppUi object.
       
   158         */
       
   159         void DoHandleRecipientL( );
       
   160 
       
   161         /**
       
   162         * Parses recipient information from the store and adds to contact card
       
   163         */
       
   164         void ParseRecipientL( CContactCard& aContactCard );
       
   165 
       
   166         /**
       
   167         * Creates a CContactCard from a contact. CPostcardRecipientWrapper is
       
   168         * used to decide which address location should be used. If there is
       
   169         * more than one location available CPostcardRecipientWrapper shows
       
   170         * a dialog to user. New CContactCard is passed to AppUi object.
       
   171         * @param aContact Contact to create a contact card from
       
   172         */
       
   173 		void DoHandlePhonebookSendAsL( CPostcardContact& aContact );
       
   174 
       
   175         /**
       
   176         * Updates contact card with name and address information from the contact.
       
   177         * @param aCard Contact card to update
       
   178         * @param aContact Contact to get information from
       
   179         * @param aLocation Address location to update contact card with
       
   180         */
       
   181         void UpdateContactCardL( CContactCard& aCard,
       
   182             CPostcardContact& aContact, CPostcardContact::TLocation aLocation );
       
   183 
       
   184         /**
       
   185         * Add text field to a contact card
       
   186         * @param aCard Contact card to update
       
   187         * @param aText Field text
       
   188         * @param aFieldSelect Field to update
       
   189         */
       
   190         static void AddContactCardFieldL( CContactCard& aCard,
       
   191             const TPtrC& aText, TInt aFieldSelect );
       
   192 
       
   193         /**
       
   194         * Text is read from the message store. Special format syntax is read from the ini resource file.
       
   195         * The text is checked field by field and new text and CContactCard objects are created out of it.
       
   196         * The new objects are passes to AppUi object.
       
   197         * When this function is called, DoHandleRecipientL is not used at all as the recipient
       
   198         * information was externalized from the greeting text.
       
   199         */
       
   200 		void DoHandleSpecialFormatOpenL( CPlainText& aText );
       
   201 
       
   202         /**
       
   203         * Move operation to a new state
       
   204         */
       
   205         void ToState( TPostcardOpenState aState );
       
   206 
       
   207         /**
       
   208         * Move operation to error state
       
   209         */
       
   210         void ToErrorState( TInt aResourceId );
       
   211 
       
   212         /**
       
   213         * Leaving version of ScalingReady()
       
   214         */    
       
   215         void ScalingReadyL();
       
   216 		
       
   217         /**
       
   218         * From CActive
       
   219         */
       
   220         void DoCancel( );
       
   221 
       
   222         /**
       
   223         * From CActive
       
   224         * Calls DoLaunchStepL
       
   225         */
       
   226         void RunL( );
       
   227 
       
   228 	public: // From ImageProcessor
       
   229 	
       
   230 		/*
       
   231 		* If process was not succesfull -> sets error and completes with it,
       
   232 		* Otherwise calls DoProcessImageFinishedL to start scaling to screen
       
   233 		*/ 
       
   234 	    void ImageProcessingReady( TSize aBitmapSize, TInt aFileSize, TBool aCompressed );
       
   235 
       
   236 
       
   237     private: // called by the two functions above
       
   238     
       
   239         /**
       
   240         * Removes the original RFile because either compressor or converter created a new one.
       
   241         * Creates ImageHandler and starts scaling the new image to screen (to bitmap)
       
   242         * 
       
   243         * Creates ImageHandler and starts scaling the image to bitmap to be displayed on the screen
       
   244         */    
       
   245         void StartScalingToScreenL( );
       
   246 
       
   247 	
       
   248    protected: // From MIHLViewerObserver
       
   249         
       
   250 		/**
       
   251         * From MIHLViewerObserver Notifies client when image handler content has changed.
       
   252 		* Leave situation is handled in ViewerError() callback.
       
   253 		*
       
   254 		* Creates a duplicate of iDestinationBitmap, creates a CGulIcon of it and
       
   255 		* passes it to AppUi class
       
   256         * @return void
       
   257 		*/
       
   258 		void ViewerBitmapChangedL();
       
   259 
       
   260         /**
       
   261         * From MIHLViewerObserver Notifies client if error occurs in viewer.
       
   262         * 
       
   263         * @param aError     IN  System wide error code.
       
   264         *
       
   265         * @return void
       
   266 		*/
       
   267 		void ViewerError( TInt aError );
       
   268 
       
   269     protected:
       
   270 
       
   271         /**
       
   272         * From CActive
       
   273         */
       
   274         TInt RunError( TInt aError );
       
   275 
       
   276         /**
       
   277         * Constructor.
       
   278         */
       
   279         CPostcardOperationOpen(
       
   280             MPostcardOperationObserver& aObserver,
       
   281             CPostcardDocument& aDocument,
       
   282             CPostcardAppUi& aAppUi,
       
   283             RFs& aFs );
       
   284 
       
   285         /**
       
   286         * 2nd phase constructor.
       
   287         */
       
   288         void ConstructL( );
       
   289 
       
   290     protected: // data
       
   291 
       
   292         CMsgMediaInfo*      iImageInfo;
       
   293 		CUniImageProcessor*	iImageProcessor;		// Image processor
       
   294 
       
   295         const TDesC&        iSpecialFormat;
       
   296         const TDesC&        iSeparatorChar;
       
   297 
       
   298         RFile*				iEditFile;
       
   299         CMsvAttachment*     iEditAtta;
       
   300         CFbsBitmap*			iBitmap;
       
   301         CFbsBitmap*			iBitmapMask;
       
   302 
       
   303         MIHLFileImage*      iSourceImage;       // source image for scaling to bitmap
       
   304         MIHLBitmap*         iDestinationBitmap; // scaled MIHL bitmap
       
   305         MIHLImageViewer*    iImageHandler;      // image handler for scaling
       
   306 
       
   307         TInt                iFlags;
       
   308     };
       
   309 
       
   310 #endif // __PostcardOperationOpen_H