messagingapp/msgappfw/plugin/inc/ccsmsghandler.h
changeset 37 518b245aa84c
parent 25 84d9eb65b26f
child 38 4e4b6adb1024
equal deleted inserted replaced
25:84d9eb65b26f 37:518b245aa84c
     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:  Request Handler plugin
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef _C_CS_MSG_REQUEST_HANDLER_H_
       
    20 #define _C_CS_MSG_REQUEST_HANDLER_H_
       
    21 
       
    22 //SYSTEM INCLUDES
       
    23 #include <msvapi.h>
       
    24 
       
    25 //USER INCLUDES
       
    26 #include "ccsmsg.h"
       
    27 #include "ccsmsgpluginutility.h"
       
    28 
       
    29 
       
    30 // FORWARD DECLARATION
       
    31 class CCsPlugin;
       
    32 class CMsvSession;
       
    33 class MCsPluginEventObserver;
       
    34 class MMsvSessionObserver;
       
    35 class CCsConversationEntry;
       
    36 class CCsMsg;
       
    37 class CCsMsgPluginUtility;
       
    38 class CClientMtmRegistry;
       
    39 class CSmsClientMtm;
       
    40 class CMmsClientMtm;
       
    41 
       
    42 /**
       
    43  * Operation Type
       
    44  */  
       
    45 enum TEventType
       
    46     {
       
    47     ERead,
       
    48     EUpdate,
       
    49     EDelete
       
    50     };
       
    51 
       
    52 /**
       
    53  * States
       
    54  */
       
    55 enum TMsgHandlerState
       
    56     {
       
    57     EReadInbox,
       
    58     EReadSent,
       
    59     EProcessDraft,
       
    60     EReadOutbox,
       
    61     ESortEntries,
       
    62     EProcessEntries,
       
    63     EComplete
       
    64     };
       
    65 
       
    66 /**
       
    67  *  Message plugin Request Handler Class
       
    68  *  This class interacts with MsvServer to fetch message data
       
    69  */
       
    70 class CCsMsgHandler : public CBase, public MMsvSessionObserver
       
    71     {
       
    72 
       
    73 public: 
       
    74 
       
    75     /**
       
    76      * Two phase construction
       
    77      * @param aMsgObserver MCsMsgObserver interface
       
    78      */
       
    79     static CCsMsgHandler* NewL(MCsMsgObserver *aMsgObserver);
       
    80 
       
    81     /**
       
    82      * Destructor
       
    83      */
       
    84     virtual ~CCsMsgHandler();
       
    85 
       
    86     /**
       
    87      *  Start
       
    88      *  This function starts the state machine to fetch msg data from msvserver
       
    89      */        
       
    90     void StartL();
       
    91 
       
    92 public://MMsvSessionObserver
       
    93     /**
       
    94      * Handles the MsvServer updates. Implemented for MMsvSessionObserver
       
    95      */
       
    96     void HandleSessionEventL(TMsvSessionEvent aEvent, 
       
    97             TAny* aArg1, 
       
    98             TAny* aArg2, 
       
    99             TAny* aArg3);
       
   100 
       
   101 private:
       
   102 
       
   103     /**
       
   104      * CIdle callback
       
   105      */
       
   106     static TInt UploadMsg(TAny* arg);
       
   107 
       
   108     /**
       
   109      * State handler to read all messages 
       
   110      */
       
   111     TInt UploadMsgL();
       
   112 
       
   113     /**
       
   114      * Checks if the MTM type supported
       
   115      */
       
   116     TBool IsMtmSupported(long uid);
       
   117 
       
   118 private:
       
   119 
       
   120     /**
       
   121      * Constructor   
       
   122      */
       
   123     CCsMsgHandler();
       
   124 
       
   125     /**
       
   126      * 2nd phase construtor
       
   127      * @param aMsgPlugin The main message plugin object
       
   128      */
       
   129     void ConstructL(MCsMsgObserver *aMsgPlugin);
       
   130 
       
   131     /**
       
   132      * ProcessResultsL fetches results and updates the CCsServer
       
   133      * with the fetched data
       
   134      */    
       
   135     void ProcessResultsL(TMsvEntry aEntry);
       
   136 
       
   137     /**
       
   138      * Create CCsConversationEntry and adds to the list     
       
   139      * @param aContact, Contact details
       
   140      * @param aDescription, message body
       
   141      * @param aEntry, TMsvEntry
       
   142      */
       
   143     void CreateAndAddEntryL(const TDesC& aContact,
       
   144             const TDesC& aDescription,
       
   145             const TMsvEntry& aEntry);
       
   146 
       
   147     /**
       
   148      * Process each entry
       
   149      * @param aEvent Read, Update, Delete
       
   150      * @param aContact (From/To) Field
       
   151      * @param aDescription, message body
       
   152      * @param aEntry, Message entry
       
   153      */
       
   154     void ProcessEntryL(TEventType aEvent, 
       
   155             const TDesC& aContact,
       
   156             const TDesC& aDescription,
       
   157             const TMsvEntry& aEntry);
       
   158 
       
   159     /**
       
   160      * Process each entry
       
   161      *@param aSelection, CMsvEntrySelections
       
   162      *@param aParent, parent id if TMsvEntry
       
   163      */    
       
   164     void HandleEventL(CMsvEntrySelection* aSelection, TMsvId aParent);
       
   165 
       
   166     /**
       
   167      * Extracts the addresses in the to field and updates them to server
       
   168      *@param aEntry, TMsvEntry
       
   169      *@param aEvent Read, Update, Delete
       
   170      *@param aFromAddress, from address of the message
       
   171      */    
       
   172     void ExtractAddressesL( 
       
   173             TMsvEntry aEntry , 
       
   174             TEventType aEvent,
       
   175             RPointerArray<HBufC>& addressList);
       
   176 
       
   177     /**
       
   178      * Cleanup
       
   179      */
       
   180     void CleanupL();
       
   181 
       
   182     /**
       
   183      * Extracts the Message type based on the MTM value 
       
   184      * @param aEntry, TMsvEntry
       
   185      */
       
   186     TCsType ExtractCsType( const TMsvEntry& aEntry);
       
   187 
       
   188 	
       
   189 private: //Data
       
   190 
       
   191     /**
       
   192      * MsvServer session object
       
   193      */
       
   194     CMsvSession* iSession;
       
   195 
       
   196     /**
       
   197      * Utility object
       
   198      */
       
   199     CCsMsgPluginUtility* iMsgPluginUtility;
       
   200 
       
   201     /**
       
   202      * iConverstationEntryList
       
   203      * ConversationEntry list
       
   204      * Own.
       
   205      */    
       
   206     RPointerArray<CCsConversationEntry> *iConverstationEntryList;
       
   207 
       
   208     /**
       
   209      * iMsgObserver
       
   210      * The Observer interface
       
   211      * Not Own.
       
   212      */        
       
   213     MCsMsgObserver *iMsgObserver;
       
   214 
       
   215     /**
       
   216      * Mtm registry object
       
   217      */
       
   218     CClientMtmRegistry* iMtmRegistry;
       
   219 
       
   220     /**
       
   221      * SMS client mtm object
       
   222      */
       
   223     CSmsClientMtm* iSmsMtm;
       
   224 
       
   225     /**
       
   226      * Mms client mtm object
       
   227      */
       
   228     CMmsClientMtm* iMmsMtm;
       
   229 
       
   230     /**
       
   231      * Previous entry, used for comparing with new entry received    
       
   232      */
       
   233     TMsvEntry iPrevEntry;
       
   234 
       
   235     /**
       
   236      * Root entry
       
   237      */
       
   238     CMsvEntry* iRootEntry;
       
   239 
       
   240     /**
       
   241      * Mesage count
       
   242      */
       
   243     TInt iMessageCount;
       
   244 
       
   245     /**
       
   246      * Messages under root entry
       
   247      */
       
   248     CMsvEntrySelection* iMessages;
       
   249 
       
   250     /**
       
   251      * Master array for holding all the messages 
       
   252      */
       
   253    RArray<TMsvId>* iMessageArray;
       
   254 
       
   255     /**
       
   256      * State
       
   257      */
       
   258     TMsgHandlerState iState;
       
   259 
       
   260     /**
       
   261      * Active object
       
   262      */
       
   263     CIdle* iIdle;
       
   264     };
       
   265 
       
   266 #endif // _C_CS_MSG_REQUEST_HANDLER_H_