messagingapp/msgappfw/plugins/previewplugin/inc/ccspreviewpluginhandler.h
branchRCL_3
changeset 57 ebe688cedc25
equal deleted inserted replaced
54:fa1df4b99609 57:ebe688cedc25
       
     1 /*
       
     2  * Copyright (c) 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:  Message Preview Handler
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef _C_CS_PREVIEW_PLUGIN_HANDLER_H_
       
    19 #define _C_CS_PREVIEW_PLUGIN_HANDLER_H_
       
    20 
       
    21 //SYSTEM INCLUDES
       
    22 #include <msvapi.h>
       
    23 #include <f32file.h>
       
    24 #include <thumbnailmanager.h>
       
    25 #include <thumbnailmanagerobserver.h>
       
    26 #include <thumbnaildata.h>
       
    27 #include <sqldb.h>
       
    28 
       
    29 //USER INCLUDES
       
    30 #include <ccsdefs.h>
       
    31 #include "ccspreviewplugin.h"
       
    32 #include "UniDataModel.h"
       
    33 
       
    34 // FORWARD DECLARATION
       
    35 class CCsPlugin;
       
    36 class CMsvSession;
       
    37 class MCsPluginEventObserver;
       
    38 class MMsvSessionObserver;
       
    39 class CCsConversationEntry;
       
    40 class CCsPreviewPlugin;
       
    41 class CClientMtmRegistry;
       
    42 class CMmsClientMtm;
       
    43 class CBIOClientMtm;
       
    44 class CUniDataModel;
       
    45 class MMsvAttachmentManager;
       
    46 
       
    47 enum MmsConformanceCheckErrors
       
    48 {
       
    49     EInsertSuccess = 0, EInsertQueryAbort, EInsertNotSupported
       
    50 };
       
    51 
       
    52 /*
       
    53  * Thumbnail Request Data
       
    54  */
       
    55 struct ThumbnailRequestData
       
    56     {
       
    57     /*
       
    58      * Request Id
       
    59      */
       
    60     TThumbnailRequestId iRequestId;
       
    61 
       
    62     /*
       
    63      * Message Id
       
    64      */
       
    65     TMsvId iMsgId;
       
    66     };
       
    67 
       
    68 /**
       
    69  *  This class interacts with MsvServer to fetch message data
       
    70  */
       
    71 class CCsPreviewPluginHandler : public CBase,
       
    72         public MMsvSessionObserver,
       
    73         public MUniDataModelObserver,
       
    74         public MThumbnailManagerObserver
       
    75     {
       
    76 
       
    77 public:
       
    78 
       
    79     /**
       
    80      * Two phase construction
       
    81      */
       
    82     static CCsPreviewPluginHandler* NewL(CCsPreviewPlugin *aMsgObserver);
       
    83 
       
    84     /**
       
    85      * Destructor
       
    86      */
       
    87     virtual ~CCsPreviewPluginHandler();
       
    88 
       
    89 public:
       
    90     //MMsvSessionObserver
       
    91     /**
       
    92      * Handles the MsvServer updates. Implemented for MMsvSessionObserver
       
    93      */
       
    94     void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1,
       
    95             TAny* aArg2, TAny* aArg3);
       
    96 
       
    97 public:
       
    98     //MUniDataModelObserver
       
    99     /**
       
   100      */
       
   101     void RestoreReady(TInt aParseResult, TInt aError);
       
   102 
       
   103 public:
       
   104     // Callbacks from MThumbnailManagerObserver for getting thumbnails
       
   105     void ThumbnailPreviewReady(MThumbnailData& aThumbnail,
       
   106             TThumbnailRequestId aId);
       
   107 
       
   108     void ThumbnailReady(TInt aError, MThumbnailData& aThumbnail,
       
   109             TThumbnailRequestId aId);
       
   110 
       
   111 public:
       
   112 
       
   113     /*
       
   114      * Compare by request Id.
       
   115      */
       
   116     static TBool CompareByRequestId(const ThumbnailRequestData& aFirst,
       
   117             const ThumbnailRequestData& aSecond);
       
   118 
       
   119 private:
       
   120 
       
   121     /**
       
   122      * Constructor   
       
   123      */
       
   124     CCsPreviewPluginHandler();
       
   125 
       
   126     /**
       
   127      * 2nd phase construtor
       
   128      */
       
   129     void ConstructL(CCsPreviewPlugin *aMsgPlugin);
       
   130 
       
   131     /**
       
   132      * Process each entry
       
   133      *@param aSelection, CMsvEntrySelections
       
   134      */
       
   135     void HandleEventL(CMsvEntrySelection* aSelection);
       
   136     
       
   137     /**
       
   138      * Process MMS entry
       
   139      *@param aEntry, TMsvEntry
       
   140      */
       
   141     void HandleMMSEntryL(const TMsvEntry& aEntry);
       
   142 
       
   143     /**
       
   144      * Process VCard enry
       
   145      *@param aEntry, TMsvEntry
       
   146      */
       
   147     void HandleVCardEntryL(const TMsvEntry& aEntry);
       
   148 
       
   149     /**
       
   150      * Bind bodytext to sql statement.
       
   151      *@param sqlStmt, RSqlStatement
       
   152      *@param attachmentId, TMsvAttachmentId
       
   153      */
       
   154     void BindBodyText(RSqlStatement& sqlStmt, TMsvAttachmentId attachmentId);
       
   155 
       
   156     /**
       
   157      * Get Thumbnail data from attachment
       
   158      *@param attachmentId, TMsvAttachmentId
       
   159      *@param mimeType, 
       
   160      *@param msgId, message id
       
   161      */
       
   162     void GetThumbNailL(TMsvAttachmentId attachmentId, TDesC8& mimeType,
       
   163             TMsvId msgId);
       
   164 
       
   165     /*
       
   166      * Process Thumbnail data
       
   167      * @param aThumbnail MThumbnailData
       
   168      * @param aId TThumbnailRequestId
       
   169      */
       
   170     void HandleThumbnailReadyL(MThumbnailData& aThumbnail,
       
   171             TThumbnailRequestId aId);
       
   172 
       
   173     /**
       
   174      * Validates if message can be forwarded
       
   175      * The validation checks include slide count check,MMS size check and
       
   176      * media conformance checks and this fucntion should be called only for mms
       
   177      * @param aUniDataModel, instance of unidatamodel
       
   178      * @return true if message can be forwarded
       
   179      *         false if message cant be forwarded
       
   180      */
       
   181     TBool ValidateMsgForForward(CUniDataModel* aUniDataModel);
       
   182 
       
   183     /**
       
   184      * This shall return the particular slide attachments ids
       
   185      * @param aSlideNum slide count
       
   186      * @param aUniDataModel instance of unidatamodel
       
   187      * @return array of attachment id's
       
   188      */
       
   189     RArray<TMsvAttachmentId>* GetSlideAttachmentIds(
       
   190             TInt aSlideNum,
       
   191             CUniDataModel* aUniDataModel);
       
   192 
       
   193     /**
       
   194      * This shall return list of attachment id's
       
   195      * @param aUniDataModel instance of unidatamodel
       
   196      * @return array of attachment id's
       
   197      */
       
   198     RArray<TMsvAttachmentId>* GetAttachmentIdList(
       
   199             CUniDataModel* aUniDataModel);
       
   200 
       
   201     /**
       
   202      * This shall check the insert mode for the attachment file
       
   203      * @param aFileHandle instance of file handle
       
   204      * @return enum MmsConformanceCheckErrors
       
   205      */
       
   206     TInt CheckModeForInsertL(RFile aFileHandle);
       
   207     
       
   208     /**
       
   209      * Finds the message's processing state
       
   210      * @param aMsgId, message id
       
   211      * @return, TInt from TCsPreviewMsgProcessingState enum
       
   212      */
       
   213     TInt msgProcessingState(TMsvId aMsgId);
       
   214     
       
   215     /**
       
   216      * Sets message under processing to true
       
   217      * @param aMsgId, message id
       
   218      * @param aState, TInt from TCsPreviewMsgProcessingState enum
       
   219      */
       
   220     void setMsgProcessingState(TMsvId aMsgId, TInt aState);
       
   221 
       
   222 private:
       
   223     //Data
       
   224 
       
   225     /**
       
   226      * MsvServer session object
       
   227      * Own
       
   228      */
       
   229     CMsvSession* iSession;
       
   230 
       
   231     /**
       
   232      * iMsgObserver
       
   233      * The Observer interface
       
   234      * Not Own.
       
   235      */
       
   236     CCsPreviewPlugin *iMsgObserver;
       
   237 
       
   238     /**
       
   239      * Mtm registry object
       
   240      * Own
       
   241      */
       
   242     CClientMtmRegistry* iMtmRegistry;
       
   243 
       
   244     /**
       
   245      * Mms client mtm object
       
   246      * Own.
       
   247      */
       
   248     CMmsClientMtm* iMmsMtm;
       
   249     
       
   250     /**
       
   251      * BioMsg client mtm object
       
   252      * Own.
       
   253      */
       
   254     CBIOClientMtm* iBioClientMtm;
       
   255 
       
   256     /*
       
   257      * File session
       
   258      */
       
   259     RFs ifsSession;
       
   260 
       
   261     /*
       
   262      * Thumbnail request array.
       
   263      * Own
       
   264      */
       
   265     RArray<ThumbnailRequestData> iThumbnailRequestArray;
       
   266 
       
   267     /*
       
   268      * Thumbnail manager.
       
   269      * Own
       
   270      */
       
   271     CThumbnailManager* iThumbnailManager;
       
   272 
       
   273     /*
       
   274      * Sqlite DB Handle
       
   275      */
       
   276     RSqlDatabase iSqlDb;
       
   277 
       
   278     /**
       
   279      * Max MMS Size
       
   280     */
       
   281     TInt iMaxMmsSize;
       
   282 
       
   283     /*
       
   284      * Mms creation mode
       
   285      */
       
   286     TInt iCreationMode;
       
   287 
       
   288     /**
       
   289      * Conformance status
       
   290      */
       
   291     TUint32 iConfStatus;
       
   292 
       
   293 };
       
   294 
       
   295 #endif // _C_CS_PREVIEW_PLUGIN_HANDLER_H_