examples/ForumNokia/InternetEmail/inc/InternetEmailEngine.h

00001 /*
00002  * Copyright � 2008 Nokia Corporation.
00003  */
00004 
00005 
00006 #ifndef INTERNETEMAILENGINE_H
00007 #define INTERNETEMAILENGINE_H
00008 
00009 // INCLUDES
00010 #include <e32std.h>
00011 #include <e32base.h>
00012 #include <msvapi.h>     //of MsvSession
00013 #include <imapset.h>
00014 #include <pop3set.h>
00015 
00016 #include <msventry.h>
00017 #include <msvids.h>
00018 #include <mtclreg.h>    // for CClientMtmRegistry
00019 #include <mtclbase.h>   // for CBaseMtm
00020 #include <mtmuibas.h>   // for CBaseMtmUi
00021 #include <mtuireg.h>        // for CMtmUiRegistry
00022 #include <miutset.h>
00023 
00024 #include <popcmtm.h>    // for POP( commmands )
00025 #include <impcmtm.h>    // for IMAP( commands )
00026 
00027 #include "internetemail.hrh"
00028 
00029 // FORWARD DECLARATIONS
00030 
00031 // CONSTANTS
00032 
00033 // not needed in one protocol implementation
00034 enum TProtocolType
00035     {
00036     EProtocolNULL,
00037     EProtocolPop3,
00038     EProtocolImap4
00039     };
00040 
00041 enum TInternetEmailEngineEvent
00042     {
00043     ERemoteCountChanged,
00044     };
00045 
00046 // CLASS DECLARATION
00047 
00048 /*
00049 * ============================================================================
00050 *  Name     : MInternetEmailEngineObserver from InternetEmailEngine.h
00051 *  Part of  : InternetEmail
00052 *  Created  : 09/11/2003 by Forum Nokia
00053 *  Implementation notes:
00054 *       Common observer which issues events to listening UI elements
00055 *
00056 *  Version  : 1.0
00057 *  Copyright: Nokia Corporation
00058 * ============================================================================
00059 */
00060 
00061 class MInternetEmailEngineObserver
00062     {
00063 public:
00064     virtual void HandleEngineChangedEventL(TInternetEmailEngineEvent aEvent)=0;
00065     };
00066 /*
00067 * ============================================================================
00068 *  Name     : CInternetEmailEngine from InternetEmailEngine.h
00069 *  Part of  : InternetEmail
00070 *  Created  : 09/11/2003 by Forum Nokia
00071 *  Implementation notes:
00072 *       Statemachine which handles events common for both
00073 *       implemented protocols IMAP and POP. Note the selection
00074 *       which protocol to use is one time only and load and store
00075 *       functionality have been cutted off for maintaining focus
00076 *       on basic receive-and-handle-with-mtm-generic-view functionality.
00077 *
00078 *  Version  : 1.0
00079 *  Copyright: Nokia Corporation
00080 * ============================================================================
00081 */
00082 class CInternetEmailEngine : public CActive, public MMsvSessionObserver
00083     {
00084     public: // // Constructors and destructor
00085         static CInternetEmailEngine* NewL(MInternetEmailEngineObserver& aObserver);
00086         //static CInternetEmailEngine* NewLC();
00087         ~CInternetEmailEngine();
00088 
00089     public: // New functions
00090         // MAIN USER API
00091 
00092         /*
00093         * RemoteOpenEmailL(TInt aIndex)
00094         *
00095         * Uses generic messaging architecture and opens selected message entry.
00096         * May generate dial-up connection to fetch message body.
00097         *
00098         * @param TInt aIndex        index to message entry to be opened
00099         *
00100         */
00101         void  RemoteOpenEmailL( const TInt aIndex);
00102 
00103         /*
00104         * void  RemoteFetchL()
00105         *
00106         * Initiates remote mailbox fetch process
00107         *
00108         */
00109         void  RemoteFetchL();
00110 
00111         /*
00112         * void  SetProtocolL( const TInt aType );
00113         *
00114         * @param TInt aType type enumeration of selected type
00115         */
00116         void  SetProtocolL( const TInt aType ); // not needed in one protocol implementation
00117         TBool IsProtocolSet();                  // not needed in one protocol implementation
00118 
00119         // For view handling( see InternetEmailContainer )
00120         TPtrC RemoteEmailTextL( const TInt aIndex);
00121         TPtrC RemoteEmailSenderL( const TInt aIndex);
00122         TInt  RemoteEmailCount();
00123 
00124         TBool IsEngineReady();
00125 
00126         /*
00127         * TBool CheckIfExistsL( const TInt typeenum )
00128         *   Checks if service entry( Email settings ) exists for
00129         *   given internet email protocol type.
00130         *
00131         * @param const TInt aTypeEnum   type enumeration of given protocol type
00132         * @return TBool ETrue           if protocol of given type exists
00133         *
00134         */
00135         TBool CheckIfExistsL( const TInt aTypeEnum );
00136 
00137         void CancelOperation();
00138         void Queue();
00139 
00140     public: // Functions from base classes
00141         // from CActive
00142         void RunL();
00143         void DoCancel();
00144         TInt RunError( const TInt aError);
00145 
00146         // from MMsvSessionObserver
00147         void HandleSessionEventL(TMsvSessionEvent aEvent,TAny* aArg1,TAny* aArg2,TAny* aArg3);
00148 
00149     // private
00150     private:
00151         CInternetEmailEngine( MInternetEmailEngineObserver& aObserver );
00152         void ConstructL();
00153         void CompleteConstructL();
00154         void DisplayMessageL( const TMsvId &aId );
00155         TMsvId FindServiceL( const TUid aType );
00156         TMsvId FindFolderThenServiceL( const TUid aType ); // not needed in one protocol implementation
00157         void MailCommandL( const TInt aCommand, TDes8& aParams );
00158         void LoadMtmL();
00159         CBaseMtm* InstantiateClientMtmL( TMsvId aService, const TUid aType );
00160 
00161         //for update
00162         CMsvEntrySelection* UpdateEntriesL(const TMsvId& aServiceId);
00163         void UpdateRemoteCountL();
00164 
00165     // private types
00166     private:
00167 
00168     // internal state indication
00169     enum TInternalState
00170         {
00171         EInitialising,
00172         EReadyButNeedsProtocol,
00173         EReady,
00174         EConnecting,
00175         EFetching,      
00176         EDisconnecting,
00177         EDone,
00178         ECanceling
00179         };
00180 
00181     private: //Data
00182     MInternetEmailEngineObserver& iObserver; //informs ui when to react to entry changes
00183 
00184     CMsvSession* iMsvSession; //the server session itself, our highway to kernel space 
00185     CClientMtmRegistry* iClientReg; //registry used to find client mtm of given protocol type
00186     CMtmUiRegistry* iUiReg; //registry used to instantiante views of given mtm
00187     CMsvOperation* iMsvOp;  //long lasting email operation object, used e.g. for cancelling requests
00188 
00189     TMsvId iServiceId;      //service id of either protocol used e.g. as 
00190     TMsvId iId;             //id of the mailbox( POP ) or inbox( IMAP ) used as a root of messagelist
00191     TInternalState iState;  //the state of the statemachine we implement by this engine
00192 
00193     CMsvEntrySelection* iRemoteEntries; //array of entries used also as mailcommmand argument
00194     TInt iRemoteCount;      //count of message entries in given folder or mailbox
00195 
00196     CBaseMtm* iMtm;         //abstract mtm for use of both pop and imap 
00197     CMsvEntry* iEntry;      //current selected entry 
00198 
00199     // next members not needed in one protocol implementation
00200     TBool iIsProtocolSet;   //bool if protocol has been selected by user or not?
00201     TBool iHasImapInbox;    //boot have we made folder sync and got inbox?
00202     TInt iProtocolType;     //type of selected protocol, custom enumeration
00203     TUid iProtocolUid;      //uid of selected protocol for easier abstraction
00204 
00205     };
00206 
00207 #endif
00208 
00209 // End of File

Generated by  doxygen 1.6.2