1 /* |
|
2 * Copyright (c) 2007-2008 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 handler class declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __CIMCVENGINEMESSAGEHANDLER_H__ |
|
20 #define __CIMCVENGINEMESSAGEHANDLER_H__ |
|
21 |
|
22 #include "mimcvenginemessage.h" |
|
23 #include "mimcvenginemessagecreator.h" // For SMessageData |
|
24 #include "mimcvenginemessagehandler.h" |
|
25 #include "mimcvenginenewmessagehandler.h" |
|
26 |
|
27 #include <mimcacheeventhandler.h> // im cache |
|
28 #include <cimcachefactory.h> |
|
29 #include <imcachedefs.h> |
|
30 |
|
31 #include <ximpcontext.h> |
|
32 #include <presencecachereadhandler2.h> // handling the presence cache events |
|
33 #include <mpresencebuddyinfo2.h> // buddy info class |
|
34 #include "cimcvenginestoragelistener.h" |
|
35 |
|
36 // FORWARD CLASS DECLERATIONS |
|
37 class MIMCVEngineChatInterface; |
|
38 class MIMCVEngineMessageUtils; |
|
39 class MIMCVEngineMessageReadInterface; |
|
40 class MIMCVEngineMessageHandler; |
|
41 class MIMCVEngineNewMessageHandler; |
|
42 class MIMCVEngineMessageHandlerObserver; |
|
43 |
|
44 // ximp im |
|
45 class MImFeatures; |
|
46 class MPresenceCacheReader2; |
|
47 class MXIMPIdentity; |
|
48 // im cache |
|
49 class MIMCacheUpdater; |
|
50 class CIMCacheFactory; |
|
51 |
|
52 class CIMCVEngineOpenChats; |
|
53 class CIMCVEngineStorageListener; |
|
54 class MIMCVEngineStorageObserver; |
|
55 // CLASS DECLARATION |
|
56 |
|
57 /** |
|
58 * Handler class for incoming and outgoing messages |
|
59 * |
|
60 * @lib imcvengine.dll |
|
61 * @since 5.0 |
|
62 */ |
|
63 |
|
64 class CIMCVEngineMessageHandler : public CBase, |
|
65 public MIMCVEngineMessageHandler, |
|
66 public MIMCVEngineServiceSessionHandler, |
|
67 public MIMCacheEventHandler, |
|
68 public MPresenceCacheReadHandler2, |
|
69 public MIMCVEngineStorageObserver |
|
70 { |
|
71 friend class CIMCVUiEngine_TestSendMessage; |
|
72 |
|
73 public: // Construction |
|
74 |
|
75 /** |
|
76 * Construction |
|
77 * @param aMessageUtils Access to message utils ( Message creator, |
|
78 * @param aContext, Access to Context |
|
79 * @param aServiceId , Service Id |
|
80 * @param aOwnId - OwnUserId |
|
81 * @return Pointer to new created instance of CIMCVEngineMessageCreator |
|
82 */ |
|
83 static CIMCVEngineMessageHandler* NewL( MIMCVEngineChatInterface& aChatInterface, |
|
84 MIMCVEngineMessageCreator& aMessageCreator, |
|
85 MXIMPContext* aContext, |
|
86 TInt aServiceId , |
|
87 const TDesC& aOwnId); |
|
88 |
|
89 /** |
|
90 * two phase Construction |
|
91 * @param aMessageUtils Access to message utils ( Message creator, |
|
92 * @param aContext, Access to Context |
|
93 * @param aServiceId , Service Id |
|
94 * @param aOwnId - OwnUserId |
|
95 * @return Pointer to new created instance of CIMCVEngineMessageCreator |
|
96 */ |
|
97 static CIMCVEngineMessageHandler* NewLC( MIMCVEngineChatInterface& aChatInterface, |
|
98 MIMCVEngineMessageCreator& aMessageCreator, |
|
99 MXIMPContext* aContext, |
|
100 TInt aServiceId , |
|
101 const TDesC& aOwnId); |
|
102 |
|
103 /** |
|
104 * Destruction |
|
105 */ |
|
106 ~CIMCVEngineMessageHandler(); |
|
107 |
|
108 |
|
109 /** |
|
110 * ResetContextL |
|
111 * @param aContext, new context |
|
112 */ |
|
113 void ResetContextL(MXIMPContext* aContext); |
|
114 |
|
115 |
|
116 private: // Construction |
|
117 |
|
118 /** |
|
119 * Constructor |
|
120 * @see CIMCVEngineMessageHandler::NewL |
|
121 * @param aChatInterface, reference to chat interface |
|
122 * @param aMessageUtils, reference to the message utils |
|
123 * @param aContext, reference to ximpfw context |
|
124 */ |
|
125 CIMCVEngineMessageHandler( MIMCVEngineChatInterface& aChatInterface, |
|
126 MIMCVEngineMessageCreator& aMessageCreator, |
|
127 MXIMPContext* aContext , |
|
128 TInt aServiceId); |
|
129 |
|
130 /** |
|
131 * Constructor |
|
132 */ |
|
133 void ConstructL(const TDesC& aOwnId ); |
|
134 |
|
135 /** |
|
136 * read service name from csp settings |
|
137 * @param aServiceId, service id. |
|
138 */ |
|
139 void ReadServiceNameL(TInt aServiceId ); |
|
140 |
|
141 |
|
142 /** |
|
143 * handle the failed messages |
|
144 * @param aMessage, message |
|
145 */ |
|
146 void HandleMessageSentFailedL( MIMCVEngineMessage& aMessage ) ; |
|
147 |
|
148 |
|
149 public: // From MIMCVEngineServiceSessionHandler |
|
150 |
|
151 |
|
152 /** |
|
153 * @see HandleDeliveryReportL |
|
154 * to handle the new message delivery report |
|
155 * @param aResultError, delivery report |
|
156 * @param aText, msg to send |
|
157 */ |
|
158 void HandleDeliveryReportL( TXIMPRequestId aOperatioCode, |
|
159 TInt aResultError ) ; |
|
160 |
|
161 |
|
162 |
|
163 /** |
|
164 * @see HandleConnectionTerminatedL |
|
165 * to handle the connection lost |
|
166 * @param aReason, reason report |
|
167 */ |
|
168 void HandleConnectionEventL( TIMCVConnectionState aState, TInt aReason ) ; |
|
169 |
|
170 public : //MIMCVEngineMessageHandler |
|
171 |
|
172 MIMCVEngineMessageCreator& MessageCreator() const ; |
|
173 |
|
174 /** SendMessageL |
|
175 * api to send the message to below layer |
|
176 * @param aMessage, message to be send |
|
177 */ |
|
178 void SendMessageL(MIMCVEngineMessage& message); |
|
179 |
|
180 /** append to cache |
|
181 * api to send the message to below layer |
|
182 * @param aBuddyId, a buddyId |
|
183 * @param aTextMessage, message to be saved |
|
184 */ |
|
185 void AppendToCacheL(const TDesC& aBuddyId, const TDesC& aTextMessage ); |
|
186 |
|
187 |
|
188 /** |
|
189 * @see MIMCVEngineMessageHandler |
|
190 */ |
|
191 void StartNewConversationL(const TDesC& aRecipientId ); |
|
192 |
|
193 |
|
194 /** |
|
195 * @see MIMCVEngineMessageHandler |
|
196 */ |
|
197 TInt CloseConversationL(const TDesC& aBuddyId); |
|
198 |
|
199 /** |
|
200 * @see MIMCVEngineMessageHandler |
|
201 */ |
|
202 void CloseAllConversationL(); |
|
203 |
|
204 /** |
|
205 * @see MIMCVEngineMessageHandler |
|
206 */ |
|
207 TInt DeactivateConversationL(); |
|
208 |
|
209 |
|
210 void UnSubscribePresenceL(const TDesC& aRecipientId); |
|
211 /** |
|
212 * @see MIMCVEngineMessageHandler |
|
213 */ |
|
214 void SubscribePresenceL(const TDesC& aWVID); |
|
215 |
|
216 /** |
|
217 * @see MIMCVEngineMessageHandler |
|
218 */ |
|
219 void SetObserver( MIMCVEngineMessageHandlerObserver* aObserver ) ; |
|
220 |
|
221 /** |
|
222 * @see MIMCVEngineMessageHandler |
|
223 */ |
|
224 void RemoveObserver(); |
|
225 |
|
226 /** |
|
227 * @see MIMCVEngineMessageHandler |
|
228 */ |
|
229 TIMCVOnlineStatus GetPresenceStatus(); |
|
230 |
|
231 /** |
|
232 * @see MIMCVEngineMessageHandler |
|
233 */ |
|
234 RArray<SIMCacheChatItem> GetChatListL( TInt aServiceId ); |
|
235 |
|
236 /** |
|
237 * @see MIMCVEngineMessageHandler |
|
238 */ |
|
239 CIMCVEngineOpenChats& OpenChats() ; |
|
240 |
|
241 TInt ServiceId() const ; |
|
242 |
|
243 |
|
244 public: // MIMCacheMessageChangeObserver |
|
245 |
|
246 /** |
|
247 * Gets called when data update is available. |
|
248 * Client can then decide wether to use the old one |
|
249 * or the updated one. |
|
250 * @param aNewMessage, new message details |
|
251 */ |
|
252 void HandleIMCacheEventL(TIMCacheEventType aEvent, TAny* aChatMessage = NULL ) ; |
|
253 |
|
254 public: // prescachereadhandler |
|
255 |
|
256 /** |
|
257 * Handler for Asynchronous methods of MPresenceCacheReader. |
|
258 * @param aErrorCode |
|
259 * @param aPresenceBuddyInfoList presence infos for all buddies requested. |
|
260 * Ownership to callee. Can be null if not found. |
|
261 */ |
|
262 void HandlePresenceReadL(TInt aErrorCode, |
|
263 RPointerArray<MPresenceBuddyInfo2>& aPresenceBuddyInfoList); |
|
264 |
|
265 /** |
|
266 * Handler for Buddy presence change notifications. |
|
267 * @param aErrorCode |
|
268 * @param aPresenceBuddyInfo presence info for buddy. |
|
269 * Ownership to callee. Can be NULL if aErrorCode exist. |
|
270 */ |
|
271 void HandlePresenceNotificationL(TInt aErrorCode, |
|
272 MPresenceBuddyInfo2* aPresenceBuddyInfo); |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 private : |
|
279 |
|
280 /** NotifyOperationCompletdL |
|
281 * @param aResult, aResult to be send |
|
282 */ |
|
283 void NotifyOperationCompletdL(MIMCVEngineMessage::TMessagerType aType , TInt aResult ); |
|
284 |
|
285 /** Helper Functions |
|
286 * |
|
287 */ |
|
288 MIMCVEngineMessage::TMessageType GetEngineMessageType(TIMCacheMessageType aType ); |
|
289 MIMCVEngineMessage::TMessagerType GetEngineMessagerType(TIMCacheMessagerType aType ); |
|
290 MIMCVEngineMessage::TContentType GetEngineContentType(TIMCacheContentType aType ); |
|
291 |
|
292 /** |
|
293 * ReadPresenceStatusL, |
|
294 * read the presence status and text from presence cache |
|
295 * @param aIdentity , identity in the XSP format |
|
296 **/ |
|
297 void ReadPresenceStatusL(const TDesC& aIdentity ); |
|
298 /** |
|
299 * ConvertStringToStatus,converts the string to enums for presence status |
|
300 * aAvailabilityEnum enum value indicating the presence status. |
|
301 * aAvailabilityText, availability text to support multiple presence. |
|
302 * @return staus. |
|
303 **/ |
|
304 TIMCVOnlineStatus ConvertPresenceCacheEnums(MPresenceBuddyInfo2::TAvailabilityValues aAvailabilityEnum, TPtrC aAvailabilityText); |
|
305 |
|
306 /** |
|
307 * Converts the presence cache extension keys |
|
308 * user for block and pending states to client supported presence status. |
|
309 * |
|
310 * @since 5.0 |
|
311 * @param aPresenceBuddyInfo presence buddy info class. |
|
312 */ |
|
313 void GetKeyFiledsAndValuesL(MPresenceBuddyInfo2& aPresenceBuddyInfo); |
|
314 |
|
315 /* |
|
316 * call back after fetching the display name and link |
|
317 */ |
|
318 void HandleServiceBuddyDetailsFetchedL(TInt aServiceId, |
|
319 const TDesC& aXspId, |
|
320 const TDesC8 & aContactLink, |
|
321 const TDesC & aDisplayName ) ; |
|
322 |
|
323 private: // Member data |
|
324 |
|
325 // Owns , reference to message creator |
|
326 MIMCVEngineMessageCreator& iMessageCreator; |
|
327 |
|
328 /// Does not own. Access to message containers |
|
329 MIMCVEngineChatInterface& iChatInterface; |
|
330 |
|
331 // owns : storage change listener |
|
332 CIMCVEngineStorageListener* iStorageListener; |
|
333 |
|
334 // not woned |
|
335 MXIMPContext* iContext; |
|
336 |
|
337 // woned ,delet it |
|
338 MImFeatures* iImFeatures; |
|
339 |
|
340 /// Messages which are send to the server |
|
341 // removed once delivered successfully to server |
|
342 RPointerArray< MIMCVEngineMessage > iHoldingMessages; |
|
343 |
|
344 // not owned , send observers |
|
345 MIMCVEngineMessageHandlerObserver* iObserver; |
|
346 |
|
347 // owned, access to accesss/update interface |
|
348 // call realease of factory |
|
349 CIMCacheFactory* iIMCacheFactory; |
|
350 |
|
351 // owned, access/update to imcache |
|
352 MIMCacheUpdater* iIMCacheUpdater; |
|
353 |
|
354 //owns |
|
355 MPresenceCacheReader2* iPresenceCacheReader; |
|
356 |
|
357 // owns , presence status |
|
358 TIMCVOnlineStatus iPresenceStatus; |
|
359 |
|
360 // owns , service name |
|
361 HBufC* iServiceName; |
|
362 |
|
363 // owns |
|
364 CIMCVEngineOpenChats* iOpenChats; |
|
365 |
|
366 TInt iServiceId; |
|
367 |
|
368 |
|
369 }; |
|
370 |
|
371 #endif // __CIMCVENGINEMESSAGEHANDLER_H__ |
|
372 |
|
373 // End of File |
|