|
1 /* |
|
2 * Copyright (c) 2004 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: Container class for messages. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __CCAMESSAGECONTAINER_H__ |
|
20 #define __CCAMESSAGECONTAINER_H__ |
|
21 |
|
22 #include "MCAMessagesReadInterface.h" |
|
23 #include "MCAMessagesWriteInterface.h" |
|
24 #include "MCAMessageContainerInfo.h" |
|
25 #include "MCAContentProcessObserver.h" |
|
26 |
|
27 // FORWARD CLASS DECLERATIONS |
|
28 class MCABufferMemoryHandler; |
|
29 class MCAChatObserver; |
|
30 class MCALoggerWriteInterface; |
|
31 class MCALoggerMessage; |
|
32 |
|
33 // CLASS DECLARATION |
|
34 |
|
35 /** |
|
36 * Container class for messages. |
|
37 * |
|
38 * @lib CAEngine.dll |
|
39 * @since 3.0 |
|
40 */ |
|
41 |
|
42 class CCAMessageContainer : public CBase, |
|
43 public MCAMessagesReadInterface, |
|
44 public MCAMessagesWriteInterface, |
|
45 public MCAMessageContainerInfo, |
|
46 public MCAContentProcessObserver |
|
47 { |
|
48 public: // Construction |
|
49 |
|
50 /** |
|
51 * Construction |
|
52 * @param aIdentifier, Identifier of container |
|
53 * @param aMemoryHandler Handles memory |
|
54 * @param aType Type of container. EGroupContainer, EChatContainer |
|
55 * @return Pointer to new created instance of CCAMessageContainer |
|
56 */ |
|
57 static CCAMessageContainer* NewL( const TDesC& aServerAddress, |
|
58 const TDesC& aUserId, |
|
59 const TDesC& aTargetId, |
|
60 MCABufferMemoryHandler& aMemoryHandler, |
|
61 TContainerType aType ); |
|
62 |
|
63 /** |
|
64 * Construction |
|
65 * @param aIdentifier, Identifier of container |
|
66 * @param aMemoryHandler Handles memory |
|
67 * @param aType Type of container. EGroupContainer, EChatContainer |
|
68 * @return Pointer to new created instance of CCAMessageContainer |
|
69 */ |
|
70 static CCAMessageContainer* NewLC( const TDesC& aServerAddress, |
|
71 const TDesC& aUserId, |
|
72 const TDesC& aTargetId, |
|
73 MCABufferMemoryHandler& aMemoryHandler, |
|
74 TContainerType aType ); |
|
75 |
|
76 /** |
|
77 * Destruction |
|
78 */ |
|
79 ~CCAMessageContainer(); |
|
80 |
|
81 private: // Construction |
|
82 |
|
83 /** |
|
84 * Constructor |
|
85 * @param aMemoryHandler Handles memory |
|
86 */ |
|
87 CCAMessageContainer( MCABufferMemoryHandler& aMemoryHandler ); |
|
88 |
|
89 /** |
|
90 * Constructor |
|
91 * @param aIdentifier, Identifier of container |
|
92 * @param aType Type of container. EGroupContainer, EChatContainer |
|
93 */ |
|
94 void ConstructL( const TDesC& aServerAddress, |
|
95 const TDesC& aUserId, |
|
96 const TDesC& aTargetId, |
|
97 TContainerType aType ); |
|
98 |
|
99 private: // Methods from MCAMessagesReadInterface |
|
100 |
|
101 /** |
|
102 * @see MCAMessagesReadInterface |
|
103 */ |
|
104 TInt UnreadCount( TUnreadFilter aUnreadFilter = EUnreadAll ) const; |
|
105 |
|
106 /** |
|
107 * @see MCAMessagesReadInterface |
|
108 */ |
|
109 TInt MessageCount() const; |
|
110 |
|
111 /** |
|
112 * @see MCAMessagesReadInterface |
|
113 */ |
|
114 void Read( TReadType aReadType, TInt aReadAmount = 0 ); |
|
115 |
|
116 /** |
|
117 * @see MCAMessagesReadInterface |
|
118 */ |
|
119 MCAMessage& Message( TInt aIndex ) const; |
|
120 |
|
121 /** |
|
122 * @see MCAMessagesReadInterface |
|
123 */ |
|
124 MCAMessage& ReadNextUnread(); |
|
125 |
|
126 /** |
|
127 * @see MCAMessagesReadInterface |
|
128 */ |
|
129 MCAMessage& ReadUnreadFromIndex( TInt aIndex ); |
|
130 |
|
131 /** |
|
132 * @see MCAMessagesReadInterface |
|
133 */ |
|
134 void SetObserver( MCAMessageObserver* aObserver ); |
|
135 |
|
136 /** |
|
137 * @see MCAMessagesReadInterface |
|
138 */ |
|
139 TPtrC Name() const; |
|
140 |
|
141 /** |
|
142 * @see MCAMessagesReadInterface |
|
143 */ |
|
144 void DeleteMessage( TInt aIndex ); |
|
145 |
|
146 /** |
|
147 * @see MCAMessagesReadInterface |
|
148 */ |
|
149 void StartLoggingL( const TDesC& aLogFilename ); |
|
150 |
|
151 /** |
|
152 * @see MCAMessagesReadInterface |
|
153 */ |
|
154 void EndLoggingL(); |
|
155 |
|
156 /** |
|
157 * @see MCAMessagesReadInterface |
|
158 */ |
|
159 TBool IsLoggingOn() const; |
|
160 |
|
161 /** |
|
162 * @see MCAMessagesReadInterface |
|
163 */ |
|
164 TInt FindIndex( TInt aOperationCode ) const; |
|
165 |
|
166 /** |
|
167 * @see MCAMessagesReadInterface |
|
168 */ |
|
169 TInt FindIndex( MCAMessage& aMessage ) const; |
|
170 |
|
171 /** |
|
172 * @see MCAMessagesReadInterface |
|
173 */ |
|
174 MCAMessageContainerInfo& TargetId(); |
|
175 |
|
176 /** |
|
177 * @see MCAMessagesReadInterface |
|
178 */ |
|
179 void Lock( TBool aLocked ); |
|
180 |
|
181 //fix - refer Ui Spec Approved Version 1.0 |
|
182 //(Instant Messaging NG 001 151006.pdf) |
|
183 //Section 10.2.10 Pg 131 - |
|
184 //"In case user has saved the image already or sent it |
|
185 //by himself, this option(save) is not available." |
|
186 |
|
187 /** |
|
188 * Added newly - Plz dont remove while merging |
|
189 * @see MCAMessagesReadInterface |
|
190 */ |
|
191 void ReLoggingL( MCALoggerMessageHeader& aFile ); |
|
192 |
|
193 /** |
|
194 * Added newly - Plz dont remove while merging |
|
195 * @see MCAMessagesReadInterface |
|
196 */ |
|
197 void EndReLoggingL(); |
|
198 |
|
199 private: // Methods from MCAMessagesWriteInterface |
|
200 |
|
201 /** |
|
202 * @see MCAMessagesWriteInterface |
|
203 */ |
|
204 void AppendL( MCAMessage* aMessage, TBool aSharedOwnership ); |
|
205 |
|
206 /** |
|
207 * @see MCAMessagesWriteInterface |
|
208 */ |
|
209 void SetScreenNameL( const TDesC& aScreenName ); |
|
210 |
|
211 /** |
|
212 * @see MCAMessagesWriteInterface |
|
213 */ |
|
214 const TDesC& OwnScreenName() const; |
|
215 |
|
216 /** |
|
217 * @see MCAMessagesWriteInterface |
|
218 */ |
|
219 void LockBufferMemoryHandling( TBool aLocked ); |
|
220 |
|
221 /** |
|
222 * @see MCAMessagesWriteInterface |
|
223 */ |
|
224 TTime Time(); |
|
225 |
|
226 private: // From MCAMessageContainerInfo |
|
227 |
|
228 /** |
|
229 * @see MCAMessageContainerInfo |
|
230 */ |
|
231 const TDesC& ServerAddress() const; |
|
232 |
|
233 /** |
|
234 * @see MCAMessageContainerInfo |
|
235 */ |
|
236 const TDesC& UserId() const; |
|
237 |
|
238 /** |
|
239 * @see MCAMessageContainerInfo |
|
240 */ |
|
241 const TDesC& Target() const; |
|
242 |
|
243 /** |
|
244 * @see MCAMessageContainerInfo |
|
245 */ |
|
246 const TDesC& ScreenName() const; |
|
247 |
|
248 /** |
|
249 * @see MCAMessageContainerInfo |
|
250 */ |
|
251 void SetAddToContactAsked( TBool aIsAsked ); |
|
252 |
|
253 /** |
|
254 * @see MCAMessageContainerInfo |
|
255 */ |
|
256 TBool IsAddToContactAsked() const; |
|
257 |
|
258 private: // From MCAContentProcessObserver |
|
259 |
|
260 /** |
|
261 * @see MCAContentProcessObserver |
|
262 */ |
|
263 void HandleProcessingComplete( MCAContentProcessor& aProcessor, |
|
264 MCAMessage& aMessage, TInt aStatus ); |
|
265 |
|
266 public: // New methods |
|
267 |
|
268 /** |
|
269 * Ordering function for ordering Message containers |
|
270 * @param aSourceA First compare item. |
|
271 * @param aSourceB Second compare item. |
|
272 * @return -1, 0 or +1, like CompareC. |
|
273 */ |
|
274 static TInt OrderUid( const CCAMessageContainer& aSourceA, |
|
275 const CCAMessageContainer& aSourceB ); |
|
276 |
|
277 /** |
|
278 * Type of container |
|
279 * @return Type of container. EGroupContainer, EChatContainer |
|
280 */ |
|
281 TContainerType ContainerType() const; |
|
282 |
|
283 /** |
|
284 * Change identifier |
|
285 * @param aNewId, new identifier |
|
286 * @param aType, new type. If ENoneContainer, Resolved automaticly. |
|
287 */ |
|
288 void ChangeIdL( const TDesC& aServerAddress, |
|
289 const TDesC& aUserId, |
|
290 const TDesC& aTargetId, |
|
291 MCAMessagesReadInterface::TContainerType aType ); |
|
292 |
|
293 /** |
|
294 * Get recipient of message identified by operation code. |
|
295 * aStatus updated to KErrNone if success. KErrNotFound if not. |
|
296 * @param aOperationCode, Identifier for getting right message. |
|
297 * @param aStatus. Status of operation. KErrNone/KErrNotFound |
|
298 * @return Message recipient |
|
299 */ |
|
300 const TDesC& MessageRecipient( TInt aOperationCode, TInt& aStatus ) const; |
|
301 |
|
302 /** |
|
303 * Set chat observer. |
|
304 * @param aObserver. Observer to set. |
|
305 */ |
|
306 void SetChatObserver( MCAChatObserver* aObserver ); |
|
307 |
|
308 private: // New helper methods |
|
309 |
|
310 /** |
|
311 * Resolve type of container by identifier. |
|
312 * @param aType, new type. If ENoneContainer, Resolved automaticly. |
|
313 */ |
|
314 void ResolveType( TContainerType aType ); |
|
315 |
|
316 /** |
|
317 * Make log. |
|
318 * @param aMessage Message to log. |
|
319 */ |
|
320 void MakeLogL( MCALoggerMessage& aMessage ); |
|
321 |
|
322 /** |
|
323 * Notify contact for pending count change. |
|
324 */ |
|
325 void NotifyContactForPending() const; |
|
326 |
|
327 /** |
|
328 * Returns target id to be used for |
|
329 * comparisons. |
|
330 * @since S60 v3.1 |
|
331 * @return Target id. |
|
332 */ |
|
333 const TDesC& ComparableTarget() const; |
|
334 |
|
335 public: |
|
336 |
|
337 /** |
|
338 * Get count of all messages. Unread and read. |
|
339 * @return Count of messages |
|
340 */ |
|
341 TInt AllMessagesCount() const; |
|
342 |
|
343 /** |
|
344 * Access to any message. Also unread. |
|
345 * @param aIndex Index of message |
|
346 * @return Reference to message. |
|
347 */ |
|
348 MCAMessage& MessageFromAll( TInt aIndex ) const; |
|
349 |
|
350 /** |
|
351 * Delete from all messages. Unread and read messages available. |
|
352 * @param aIndex. Index of message. |
|
353 */ |
|
354 void DeleteMessageFromAll( TInt aIndex ); |
|
355 |
|
356 /** |
|
357 * Is container locked or not. ETrue locked, EFalse not. |
|
358 * @return Locked status. |
|
359 */ |
|
360 TBool IsLocked() const; |
|
361 |
|
362 /** |
|
363 * Sizes of messages in container in bytes. |
|
364 * @since S60 v3.1 |
|
365 * @return Size in bytes. |
|
366 */ |
|
367 TInt ContainerSizeInBytes() const; |
|
368 |
|
369 private: // Member data |
|
370 |
|
371 /// Chat group id / conversation party id |
|
372 HBufC* iServerAddress; |
|
373 HBufC* iUserId; |
|
374 HBufC* iTargetId; |
|
375 HBufC* iDecodedTargetId; |
|
376 |
|
377 /// Screen name of user corresponding the container. |
|
378 HBufC* iScreenName; |
|
379 |
|
380 /// Offset to last unread message |
|
381 TInt iUnreadOffset; |
|
382 |
|
383 /// Array of messages. |
|
384 RPointerArray< MCAMessage > iMessageContainer; |
|
385 |
|
386 /// Reference to memory handler |
|
387 MCABufferMemoryHandler& iMemoryHandler; |
|
388 |
|
389 /// Observer class |
|
390 MCAMessageObserver* iObserver; |
|
391 |
|
392 /// Type of container |
|
393 TContainerType iContainerType; |
|
394 |
|
395 /// Not own. Chat observer |
|
396 MCAChatObserver* iChatObserver; |
|
397 |
|
398 // Owns. Write interface for logging. |
|
399 MCALoggerWriteInterface* iLogger; |
|
400 |
|
401 // Tells if add to contacts is asked |
|
402 TBool iAddToContactAsked; |
|
403 |
|
404 // Locked status |
|
405 TBool iLocked; |
|
406 |
|
407 // Buffer memory handling locked |
|
408 TBool iMemoryHandlingLocked; |
|
409 |
|
410 // Size of contained messages in bytes |
|
411 TInt iContainerSizeInBytes; |
|
412 }; |
|
413 |
|
414 #endif // __CCAMESSAGECONTAINER_H__ |
|
415 |
|
416 // End of File |