|
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 /** |
|
119 * Read all message Id in iMessageArray |
|
120 * @aFolderId - Folder Id whose message need to be sync. |
|
121 */ |
|
122 void UpdateMessageArrayL(const TMsvId& aFolderId); |
|
123 |
|
124 private: |
|
125 |
|
126 /** |
|
127 * Constructor |
|
128 */ |
|
129 CCsMsgHandler(); |
|
130 |
|
131 /** |
|
132 * 2nd phase construtor |
|
133 * @param aMsgPlugin The main message plugin object |
|
134 */ |
|
135 void ConstructL(MCsMsgObserver *aMsgPlugin); |
|
136 |
|
137 /** |
|
138 * ProcessResultsL fetches results and updates the CCsServer |
|
139 * with the fetched data |
|
140 */ |
|
141 void ProcessResultsL(TMsvEntry aEntry); |
|
142 |
|
143 /** |
|
144 * Create CCsConversationEntry and adds to the list |
|
145 * @param aContact, Contact details |
|
146 * @param aDescription, message body |
|
147 * @param aEntry, TMsvEntry |
|
148 */ |
|
149 void CreateAndAddEntryL(const TDesC& aContact, |
|
150 const TDesC& aDescription, |
|
151 const TMsvEntry& aEntry); |
|
152 |
|
153 /** |
|
154 * Process each entry |
|
155 * @param aEvent Read, Update, Delete |
|
156 * @param aContact (From/To) Field |
|
157 * @param aDescription, message body |
|
158 * @param aEntry, Message entry |
|
159 */ |
|
160 void ProcessEntryL(TEventType aEvent, |
|
161 const TDesC& aContact, |
|
162 const TDesC& aDescription, |
|
163 const TMsvEntry& aEntry); |
|
164 |
|
165 /** |
|
166 * Process each entry |
|
167 *@param aSelection, CMsvEntrySelections |
|
168 *@param aParent, parent id if TMsvEntry |
|
169 */ |
|
170 void HandleEventL(CMsvEntrySelection* aSelection, TMsvId aParent); |
|
171 |
|
172 /** |
|
173 * Extracts the addresses in the to field and updates them to server |
|
174 *@param aEntry, TMsvEntry |
|
175 *@param aEvent Read, Update, Delete |
|
176 *@param aFromAddress, from address of the message |
|
177 */ |
|
178 void ExtractAddressesL( |
|
179 TMsvEntry aEntry , |
|
180 TEventType aEvent, |
|
181 RPointerArray<HBufC>& addressList); |
|
182 |
|
183 /** |
|
184 * Extracts the Message type based on the MTM value |
|
185 * @param aEntry, TMsvEntry |
|
186 */ |
|
187 TCsType ExtractCsType( const TMsvEntry& aEntry); |
|
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 * Master array for holding all the messages |
|
237 */ |
|
238 RArray<TMsvId>* iMessageArray; |
|
239 |
|
240 /** |
|
241 * State |
|
242 */ |
|
243 TMsgHandlerState iState; |
|
244 |
|
245 /** |
|
246 * Active object |
|
247 */ |
|
248 CIdle* iIdle; |
|
249 }; |
|
250 |
|
251 #endif // _C_CS_MSG_REQUEST_HANDLER_H_ |