messagingapp/msgappfw/plugins/previewplugin/inc/ccspreviewpluginhandler.h
changeset 27 e4592d119491
child 34 84197e66a4bd
equal deleted inserted replaced
25:84d9eb65b26f 27:e4592d119491
       
     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 "ccspreviewplugin.h"
       
    31 #include "UniDataModel.h"
       
    32 
       
    33 // FORWARD DECLARATION
       
    34 class CCsPlugin;
       
    35 class CMsvSession;
       
    36 class MCsPluginEventObserver;
       
    37 class MMsvSessionObserver;
       
    38 class CCsConversationEntry;
       
    39 class CCsPreviewPlugin;
       
    40 class CClientMtmRegistry;
       
    41 class CMmsClientMtm;
       
    42 
       
    43 /*
       
    44  * Thumbnail Request Data
       
    45  */
       
    46 struct ThumbnailRequestData
       
    47     {
       
    48     /*
       
    49      * Request Id
       
    50      */
       
    51     TThumbnailRequestId iRequestId;
       
    52 
       
    53     /*
       
    54      * Message Id
       
    55      */
       
    56     TMsvId iMsgId;
       
    57     };
       
    58 
       
    59 /**
       
    60  *  This class interacts with MsvServer to fetch message data
       
    61  */
       
    62 class CCsPreviewPluginHandler : public CBase,
       
    63         public MMsvSessionObserver,
       
    64         public MUniDataModelObserver,
       
    65         public MThumbnailManagerObserver
       
    66     {
       
    67 
       
    68 public:
       
    69 
       
    70     /**
       
    71      * Two phase construction
       
    72      */
       
    73     static CCsPreviewPluginHandler* NewL(CCsPreviewPlugin *aMsgObserver);
       
    74 
       
    75     /**
       
    76      * Destructor
       
    77      */
       
    78     virtual ~CCsPreviewPluginHandler();
       
    79 
       
    80 public:
       
    81     //MMsvSessionObserver
       
    82     /**
       
    83      * Handles the MsvServer updates. Implemented for MMsvSessionObserver
       
    84      */
       
    85     void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1,
       
    86             TAny* aArg2, TAny* aArg3);
       
    87 
       
    88 public:
       
    89     //MUniDataModelObserver
       
    90     /**
       
    91      */
       
    92     void RestoreReady(TInt aParseResult, TInt aError);
       
    93 
       
    94 public:
       
    95     // Callbacks from MThumbnailManagerObserver for getting thumbnails
       
    96     void ThumbnailPreviewReady(MThumbnailData& aThumbnail,
       
    97             TThumbnailRequestId aId);
       
    98 
       
    99     void ThumbnailReady(TInt aError, MThumbnailData& aThumbnail,
       
   100             TThumbnailRequestId aId);
       
   101 
       
   102 public:
       
   103 
       
   104     /*
       
   105      * Compare by request Id.
       
   106      */
       
   107     static TBool CompareByRequestId(const ThumbnailRequestData& aFirst,
       
   108             const ThumbnailRequestData& aSecond);
       
   109 
       
   110 private:
       
   111 
       
   112     /**
       
   113      * Constructor   
       
   114      */
       
   115     CCsPreviewPluginHandler();
       
   116 
       
   117     /**
       
   118      * 2nd phase construtor
       
   119      */
       
   120     void ConstructL(CCsPreviewPlugin *aMsgPlugin);
       
   121 
       
   122     /**
       
   123      * Process each entry
       
   124      *@param aSelection, CMsvEntrySelections
       
   125      */
       
   126     void HandleEventL(CMsvEntrySelection* aSelection);
       
   127 
       
   128     /**
       
   129      * Bind bodytext to sql statement.
       
   130      *@param sqlStmt, RSqlStatement
       
   131      *@param attachmentId, TMsvAttachmentId
       
   132      */
       
   133     void BindBodyText(RSqlStatement& sqlStmt, TMsvAttachmentId attachmentId);
       
   134 
       
   135     /**
       
   136      * Get Thumbnail data from attachment
       
   137      *@param attachmentId, TMsvAttachmentId
       
   138      *@param mimeType, 
       
   139      *@param msgId, message id
       
   140      */
       
   141     void GetThumbNailL(TMsvAttachmentId attachmentId, TDesC8& mimeType,
       
   142             TMsvId msgId);
       
   143 
       
   144     /*
       
   145      * Process Thumbnail data
       
   146      * @param aThumbnail MThumbnailData
       
   147      * @param aId TThumbnailRequestId
       
   148      */
       
   149     void HandleThumbnailReadyL(MThumbnailData& aThumbnail,
       
   150             TThumbnailRequestId aId);
       
   151 
       
   152 private:
       
   153     //Data
       
   154 
       
   155     /**
       
   156      * MsvServer session object
       
   157      * Own
       
   158      */
       
   159     CMsvSession* iSession;
       
   160 
       
   161     /**
       
   162      * iMsgObserver
       
   163      * The Observer interface
       
   164      * Not Own.
       
   165      */
       
   166     CCsPreviewPlugin *iMsgObserver;
       
   167 
       
   168     /**
       
   169      * Mtm registry object
       
   170      * Own
       
   171      */
       
   172     CClientMtmRegistry* iMtmRegistry;
       
   173 
       
   174     /**
       
   175      * Mms client mtm object
       
   176      * Own.
       
   177      */
       
   178     CMmsClientMtm* iMmsMtm;
       
   179 
       
   180     /*
       
   181      * File session
       
   182      */
       
   183     RFs ifsSession;
       
   184 
       
   185     /*
       
   186      * Thumbnail request array.
       
   187      * Own
       
   188      */
       
   189     RArray<ThumbnailRequestData> iThumbnailRequestArray;
       
   190 
       
   191     /*
       
   192      * Thumbnail manager.
       
   193      * Own
       
   194      */
       
   195     CThumbnailManager* iThumbnailManager;
       
   196 
       
   197     /*
       
   198      * Sqlite DB Handle
       
   199      */
       
   200     RSqlDatabase iSqlDb;
       
   201     };
       
   202 
       
   203 #endif // _C_CS_PREVIEW_PLUGIN_HANDLER_H_