00001 /* 00002 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 00003 * 00004 * Redistribution and use in source and binary forms, with or without 00005 * modification, are permitted provided that the following conditions are met: 00006 * 00007 * * Redistributions of source code must retain the above copyright notice, this 00008 * list of conditions and the following disclaimer. 00009 * * Redistributions in binary form must reproduce the above copyright notice, 00010 * this list of conditions and the following disclaimer in the documentation 00011 * and/or other materials provided with the distribution. 00012 * * Neither the name of Nokia Corporation nor the names of its contributors 00013 * may be used to endorse or promote products derived from this software 00014 * without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00017 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00018 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00019 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00020 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00021 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00022 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00023 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00024 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00025 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 * 00027 * Description: 00028 */ 00029 00030 00031 #ifndef INTERNETEMAILENGINE_H 00032 #define INTERNETEMAILENGINE_H 00033 00034 // INCLUDES 00035 #include <e32std.h> 00036 #include <e32base.h> 00037 #include <msvapi.h> //of MsvSession 00038 #include <imapset.h> 00039 #include <pop3set.h> 00040 00041 #include <msventry.h> 00042 #include <msvids.h> 00043 #include <mtclreg.h> // for CClientMtmRegistry 00044 #include <mtclbase.h> // for CBaseMtm 00045 #include <mtmuibas.h> // for CBaseMtmUi 00046 #include <mtuireg.h> // for CMtmUiRegistry 00047 #include <miutset.h> 00048 00049 #include <popcmtm.h> // for POP( commmands ) 00050 #include <impcmtm.h> // for IMAP( commands ) 00051 00052 #include "internetemail.hrh" 00053 00054 // FORWARD DECLARATIONS 00055 00056 // CONSTANTS 00057 00058 // not needed in one protocol implementation 00059 enum TProtocolType 00060 { 00061 EProtocolNULL, 00062 EProtocolPop3, 00063 EProtocolImap4 00064 }; 00065 00066 enum TInternetEmailEngineEvent 00067 { 00068 ERemoteCountChanged, 00069 }; 00070 00071 // CLASS DECLARATION 00072 00073 /* 00074 * ============================================================================ 00075 * Name : MInternetEmailEngineObserver from InternetEmailEngine.h 00076 * Part of : InternetEmail 00077 * Created : 09/11/2003 by Forum Nokia 00078 * Implementation notes: 00079 * Common observer which issues events to listening UI elements 00080 * 00081 * Version : 1.0 00082 * Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). 00083 * All rights reserved. 00084 * This component and the accompanying materials are made available 00085 * under the terms of "Eclipse Public License v1.0" 00086 * which accompanies this distribution, and is available 00087 * at the URL "http://www.eclipse.org/legal/epl-v10.html". 00088 * ============================================================================ 00089 */ 00090 00091 class MInternetEmailEngineObserver 00092 { 00093 public: 00094 virtual void HandleEngineChangedEventL(TInternetEmailEngineEvent aEvent)=0; 00095 }; 00096 /* 00097 * ============================================================================ 00098 * Name : CInternetEmailEngine from InternetEmailEngine.h 00099 * Part of : InternetEmail 00100 * Created : 09/11/2003 by Forum Nokia 00101 * Implementation notes: 00102 * Statemachine which handles events common for both 00103 * implemented protocols IMAP and POP. Note the selection 00104 * which protocol to use is one time only and load and store 00105 * functionality have been cutted off for maintaining focus 00106 * on basic receive-and-handle-with-mtm-generic-view functionality. 00107 * 00108 * Version : 1.0 00109 * Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). 00110 * All rights reserved. 00111 * This component and the accompanying materials are made available 00112 * under the terms of "Eclipse Public License v1.0" 00113 * which accompanies this distribution, and is available 00114 * at the URL "http://www.eclipse.org/legal/epl-v10.html". 00115 * ============================================================================ 00116 */ 00117 class CInternetEmailEngine : public CActive, public MMsvSessionObserver 00118 { 00119 public: // // Constructors and destructor 00120 static CInternetEmailEngine* NewL(MInternetEmailEngineObserver& aObserver); 00121 //static CInternetEmailEngine* NewLC(); 00122 ~CInternetEmailEngine(); 00123 00124 public: // New functions 00125 // MAIN USER API 00126 00127 /* 00128 * RemoteOpenEmailL(TInt aIndex) 00129 * 00130 * Uses generic messaging architecture and opens selected message entry. 00131 * May generate dial-up connection to fetch message body. 00132 * 00133 * @param TInt aIndex index to message entry to be opened 00134 * 00135 */ 00136 void RemoteOpenEmailL( const TInt aIndex); 00137 00138 /* 00139 * void RemoteFetchL() 00140 * 00141 * Initiates remote mailbox fetch process 00142 * 00143 */ 00144 void RemoteFetchL(); 00145 00146 /* 00147 * void SetProtocolL( const TInt aType ); 00148 * 00149 * @param TInt aType type enumeration of selected type 00150 */ 00151 void SetProtocolL( const TInt aType ); // not needed in one protocol implementation 00152 TBool IsProtocolSet(); // not needed in one protocol implementation 00153 00154 // For view handling( see InternetEmailContainer ) 00155 TPtrC RemoteEmailTextL( const TInt aIndex); 00156 TPtrC RemoteEmailSenderL( const TInt aIndex); 00157 TInt RemoteEmailCount(); 00158 00159 TBool IsEngineReady(); 00160 00161 /* 00162 * TBool CheckIfExistsL( const TInt typeenum ) 00163 * Checks if service entry( Email settings ) exists for 00164 * given internet email protocol type. 00165 * 00166 * @param const TInt aTypeEnum type enumeration of given protocol type 00167 * @return TBool ETrue if protocol of given type exists 00168 * 00169 */ 00170 TBool CheckIfExistsL( const TInt aTypeEnum ); 00171 00172 void CancelOperation(); 00173 void Queue(); 00174 00175 public: // Functions from base classes 00176 // from CActive 00177 void RunL(); 00178 void DoCancel(); 00179 TInt RunError( const TInt aError); 00180 00181 // from MMsvSessionObserver 00182 void HandleSessionEventL(TMsvSessionEvent aEvent,TAny* aArg1,TAny* aArg2,TAny* aArg3); 00183 00184 // private 00185 private: 00186 CInternetEmailEngine( MInternetEmailEngineObserver& aObserver ); 00187 void ConstructL(); 00188 void CompleteConstructL(); 00189 void DisplayMessageL( const TMsvId &aId ); 00190 TMsvId FindServiceL( const TUid aType ); 00191 TMsvId FindFolderThenServiceL( const TUid aType ); // not needed in one protocol implementation 00192 void MailCommandL( const TInt aCommand, TDes8& aParams ); 00193 void LoadMtmL(); 00194 CBaseMtm* InstantiateClientMtmL( TMsvId aService, const TUid aType ); 00195 00196 //for update 00197 CMsvEntrySelection* UpdateEntriesL(const TMsvId& aServiceId); 00198 void UpdateRemoteCountL(); 00199 00200 // private types 00201 private: 00202 00203 // internal state indication 00204 enum TInternalState 00205 { 00206 EInitialising, 00207 EReadyButNeedsProtocol, 00208 EReady, 00209 EConnecting, 00210 EFetching, 00211 EDisconnecting, 00212 EDone, 00213 ECanceling 00214 }; 00215 00216 private: //Data 00217 MInternetEmailEngineObserver& iObserver; //informs ui when to react to entry changes 00218 00219 CMsvSession* iMsvSession; //the server session itself, our highway to kernel space 00220 CClientMtmRegistry* iClientReg; //registry used to find client mtm of given protocol type 00221 CMtmUiRegistry* iUiReg; //registry used to instantiante views of given mtm 00222 CMsvOperation* iMsvOp; //long lasting email operation object, used e.g. for cancelling requests 00223 00224 TMsvId iServiceId; //service id of either protocol used e.g. as 00225 TMsvId iId; //id of the mailbox( POP ) or inbox( IMAP ) used as a root of messagelist 00226 TInternalState iState; //the state of the statemachine we implement by this engine 00227 00228 CMsvEntrySelection* iRemoteEntries; //array of entries used also as mailcommmand argument 00229 TInt iRemoteCount; //count of message entries in given folder or mailbox 00230 00231 CBaseMtm* iMtm; //abstract mtm for use of both pop and imap 00232 CMsvEntry* iEntry; //current selected entry 00233 00234 // next members not needed in one protocol implementation 00235 TBool iIsProtocolSet; //bool if protocol has been selected by user or not? 00236 TBool iHasImapInbox; //boot have we made folder sync and got inbox? 00237 TInt iProtocolType; //type of selected protocol, custom enumeration 00238 TUid iProtocolUid; //uid of selected protocol for easier abstraction 00239 00240 }; 00241 00242 #endif 00243 00244 // End of File