|
1 /* |
|
2 * Copyright (c) 2005 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: Handler class for incoming and outgoing messages |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __CCAMESSAGEHANDLER_H__ |
|
20 #define __CCAMESSAGEHANDLER_H__ |
|
21 |
|
22 |
|
23 #include "ImpsImCli.h" // MImpsImHandler2 |
|
24 #include "MCAMessageObserver.h" |
|
25 #include "MCAMessageErrorInformer.h" |
|
26 #include "MCAContentProcessObserver.h" |
|
27 #include "MCAMessageCreator.h" // For SMessageData |
|
28 |
|
29 // FORWARD CLASS DECLERATIONS |
|
30 class MCAChatInterface; |
|
31 class MCAMessageUtils; |
|
32 class MCAMessagesReadInterface; |
|
33 class MCAImpsFactory; |
|
34 class MCAImpsImClient; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 /** |
|
39 * Handler class for incoming and outgoing messages |
|
40 * |
|
41 * @lib CAEngine.dll |
|
42 * @since 3.0 |
|
43 */ |
|
44 |
|
45 class CCAMessageHandler : public CBase, |
|
46 public MImpsImHandler2, |
|
47 public MCAMessageObserver, |
|
48 public MCAMessageErrorInformer, |
|
49 public MCAContentProcessObserver |
|
50 { |
|
51 public: // Construction |
|
52 |
|
53 /** |
|
54 * Construction |
|
55 * @param aChatInterface Access to message read and write interfaces |
|
56 * @param aMessageUtils Access to message utils ( Message creator, |
|
57 * processors ) |
|
58 * @param aImpsFactory Factory for IMPS interface wrappers |
|
59 * @return Pointer to new created instance of CCAMessageCreator |
|
60 */ |
|
61 static CCAMessageHandler* NewL( MCAChatInterface& aChatInterface, |
|
62 MCAMessageUtils& aMessageUtils, |
|
63 MCAImpsFactory* aIMPSFactory ); |
|
64 |
|
65 /** |
|
66 * Construction |
|
67 * @see CCAMessageHandler::NewL |
|
68 */ |
|
69 static CCAMessageHandler* NewLC( MCAChatInterface& aChatInterface, |
|
70 MCAMessageUtils& aMessageUtils, |
|
71 MCAImpsFactory* aIMPSFactory ); |
|
72 |
|
73 /** |
|
74 * Destruction |
|
75 */ |
|
76 ~CCAMessageHandler(); |
|
77 |
|
78 private: // Construction |
|
79 |
|
80 /** |
|
81 * Constructor |
|
82 * @see CCAMessageHandler::NewL |
|
83 */ |
|
84 CCAMessageHandler( MCAChatInterface& aChatInterface, |
|
85 MCAMessageUtils& aMessageUtils, |
|
86 MCAImpsFactory* aIMPSFactory ); |
|
87 |
|
88 /** |
|
89 * Constructor |
|
90 */ |
|
91 void ConstructL(); |
|
92 |
|
93 private: // From MImpsImHandler |
|
94 |
|
95 /** |
|
96 * @see MImpsImHandler2 |
|
97 */ |
|
98 void HandleNewTextMessageL( TInt aOpId, |
|
99 const TDesC& aMessageId, |
|
100 const TDesC& aSender, |
|
101 const TDesC& aGroupId, |
|
102 const MDesCArray& aRecipients, |
|
103 const MDesCArray& aScreenNames, |
|
104 const TDesC& aText, |
|
105 TImpsCspIdentifier& aCspId ); |
|
106 /** |
|
107 * @see MImpsImHandler2 |
|
108 */ |
|
109 void HandleNewContentMessageL( TInt aOpId, |
|
110 const TDesC& aMessageId, |
|
111 const TDesC& aSender, |
|
112 const TDesC& aGroupId, |
|
113 const MDesCArray& aRecipients, |
|
114 const MDesCArray& aScreenNames, |
|
115 const TDesC& aContentType, |
|
116 const TDesC8& aContent, |
|
117 TImpsCspIdentifier& aCspId ); |
|
118 /** |
|
119 * @see MImpsImHandler2 |
|
120 */ |
|
121 void HandleSendCompleteL( TInt aOpId, |
|
122 TBool aDeliveryReportOrdered, |
|
123 TImpsCspIdentifier& aCspId ); |
|
124 /** |
|
125 * @see MImpsImHandler2 |
|
126 */ |
|
127 void HandleDeliveryReportL( const TDesC& aMessageId, |
|
128 TInt aResult, |
|
129 const TDesC* aDescription, |
|
130 TImpsCspIdentifier& aCspId ); |
|
131 |
|
132 private: // From MCAMessageObserver |
|
133 |
|
134 /** |
|
135 * @see MCAMessageObserver |
|
136 */ |
|
137 void HandleMessageEvent( TMessageEventType aEvent, TInt aIndex ); |
|
138 |
|
139 private: // From MCAMessageErrorInformer |
|
140 |
|
141 /** |
|
142 * @see MCAMessageErrorInformer |
|
143 */ |
|
144 void RegisterObserver( MCAMessageErrorObserver* aObserver ); |
|
145 |
|
146 /** |
|
147 * @see MCAMessageErrorInformer |
|
148 */ |
|
149 void UnregisterObserver( MCAMessageErrorObserver* aObserver ); |
|
150 |
|
151 private: // From MCAContentProcessObserver |
|
152 |
|
153 /** |
|
154 * @see MCAContentProcessObserver |
|
155 */ |
|
156 void HandleProcessingComplete( MCAContentProcessor& aProcessor, |
|
157 MCAMessage& aMessage, |
|
158 TInt aStatus ); |
|
159 |
|
160 public: // New methods |
|
161 |
|
162 /** |
|
163 * Handle sent message. |
|
164 * @param aStatus, Status of operation |
|
165 * @param aOperationCode. Operation code to identify message. |
|
166 * @param aSuccess ETrue, if message sent ok. EFalse if not. |
|
167 */ |
|
168 void HandleMessageSentL( TInt aStatus, TInt aOperationCode, |
|
169 TBool aSuccess ); |
|
170 |
|
171 /** |
|
172 * Set state of local echo in group. |
|
173 */ |
|
174 void SetLocalEchoInGroup( TBool aLocalEchoInGroup ); |
|
175 |
|
176 private: // New helper methods |
|
177 |
|
178 /** |
|
179 * Callback method for CIdle |
|
180 * @param aInstance Instance of CCAMessageHandler |
|
181 * @return ETrue, if more messages, EFalse if last one. |
|
182 */ |
|
183 static TInt SendMessage( TAny *aInstance ); |
|
184 |
|
185 /** |
|
186 * Send one message |
|
187 * @return ETrue, if more messages, EFalse if last one. |
|
188 */ |
|
189 TInt DoSendMessage(); |
|
190 |
|
191 /** |
|
192 * Handle new message. |
|
193 * @param aData. Data of message. |
|
194 */ |
|
195 void HandleNewMessageL( MCAMessageCreator::SMessageData& aData ); |
|
196 |
|
197 /** |
|
198 * Notify observers about |
|
199 * @param aStatus, Error code |
|
200 * @param aMessage, Message that failed. |
|
201 */ |
|
202 void NotifyMessageError( TInt aStatus, MCAMessage* aMessage ); |
|
203 |
|
204 /** |
|
205 * Get next holding message if exists. |
|
206 * @return Next holding message if exists. NULL if not. |
|
207 */ |
|
208 MCAMessage* NextHoldingMessage(); |
|
209 |
|
210 /** |
|
211 * Is holding needed for message. If it is, appended to holding. |
|
212 * @param aMessage. Checked message |
|
213 * @return ETrue, if appended to holding EFalse if not. |
|
214 */ |
|
215 TBool AppendedToHoldingL( MCAMessage& aMessage ); |
|
216 |
|
217 /** |
|
218 * Send message to server |
|
219 * @param aMessage. Message to sent. |
|
220 * @return Operation code. |
|
221 */ |
|
222 TInt SendMessageToServerL( MCAMessage& aMessage ); |
|
223 |
|
224 /** |
|
225 * Handle message sent failed. Create failed message and notify user. |
|
226 * @param aMessage. Failed message |
|
227 * @param aError, Error code for fail. |
|
228 */ |
|
229 void HandleMessageSentFailedL( MCAMessage& aMessage, TInt aError ); |
|
230 |
|
231 /** |
|
232 * Show message to user who sent it. |
|
233 * @param aMessage. Sent message to echo. |
|
234 */ |
|
235 void LocalEchoMessageL( MCAMessage& aMessage ); |
|
236 |
|
237 private: // Member data |
|
238 |
|
239 /// does not own. This is used for example to get message creator |
|
240 MCAMessageUtils& iMessageUtils; |
|
241 |
|
242 /// Does not own. Access to message containers |
|
243 MCAChatInterface& iChatInterface; |
|
244 |
|
245 /// Does not own. Access to messages in send buffer |
|
246 MCAMessagesReadInterface* iSendBuffer; |
|
247 |
|
248 // not owned |
|
249 MCAImpsFactory* iImpsFactory; |
|
250 |
|
251 // not owned |
|
252 MCAImpsImClient* iImpsImClient; |
|
253 |
|
254 /// Idle for message sending purposes. Owns. |
|
255 CIdle* iIdle; |
|
256 |
|
257 /// Message error observers |
|
258 RPointerArray< MCAMessageErrorObserver > iErrorObservers; |
|
259 |
|
260 /// Messages which are processed before sending. |
|
261 RPointerArray< MCAMessage > iHoldingMessages; |
|
262 |
|
263 /// Is local echo in groups used. |
|
264 TBool iLocalEchoInGroup; |
|
265 |
|
266 /// If send is active, do not start it again. |
|
267 TBool iSendLaunchLock; |
|
268 }; |
|
269 |
|
270 #endif // CCAMESSAGEHANDLER_H |
|
271 |
|
272 // End of File |