|
1 /* |
|
2 * Copyright (c) 2004-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: Container for message containers |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CCACHATCONTAINER_H |
|
20 #define CCACHATCONTAINER_H |
|
21 |
|
22 #include "impsbuilddefinitions.h" |
|
23 #include "MCABufferMemoryHandler.h" |
|
24 #include "MCAChatInterface.h" |
|
25 #include "MCAChatObserver.h" |
|
26 |
|
27 // FORWARD CLASS DECLERATIONS |
|
28 class CCAMessageContainer; |
|
29 class MCASettings; |
|
30 |
|
31 // CLASS DECLARATION |
|
32 |
|
33 /** |
|
34 * Container for message containers |
|
35 * |
|
36 * @lib CAEngine.dll |
|
37 * @since 3.0 |
|
38 */ |
|
39 class CCAChatContainer : public CBase, |
|
40 public MCAChatInterface, |
|
41 public MCABufferMemoryHandler, |
|
42 public MCAChatObserver |
|
43 { |
|
44 public: // Construction |
|
45 |
|
46 /** |
|
47 * Construction |
|
48 */ |
|
49 static CCAChatContainer* NewL( MCASettings& aSettingsInterface ); |
|
50 |
|
51 /** |
|
52 * Destruction |
|
53 */ |
|
54 ~CCAChatContainer(); |
|
55 |
|
56 private: // Construction |
|
57 |
|
58 /** |
|
59 * Constructor |
|
60 */ |
|
61 CCAChatContainer( MCASettings& aSettingsInterface ); |
|
62 |
|
63 private: // Methods from MCAChatInterface |
|
64 |
|
65 /** |
|
66 * @see MCAChatInterface |
|
67 */ |
|
68 MCAMessagesReadInterface& MessageReadInterfaceL( |
|
69 const TDesC& aServerAddress, |
|
70 const TDesC& aUserId, |
|
71 const TDesC& aTargetId, |
|
72 MCAMessagesReadInterface::TContainerType aType ); |
|
73 |
|
74 /** |
|
75 * @see MCAChatInterface |
|
76 */ |
|
77 MCAMessagesWriteInterface& MessageWriteInterfaceL( |
|
78 const TDesC& aServerAddress, |
|
79 const TDesC& aUserId, |
|
80 const TDesC& aTargetId, |
|
81 MCAMessagesReadInterface::TContainerType aType ); |
|
82 |
|
83 /** |
|
84 * @see MCAChatInterface |
|
85 */ |
|
86 void DeleteChatL( const TDesC& aServerAddress, |
|
87 const TDesC& aUserId, |
|
88 const TDesC& aTargetId ); |
|
89 |
|
90 /** |
|
91 * @see MCAChatInterface |
|
92 */ |
|
93 void CloseAllContainers(); |
|
94 |
|
95 /** |
|
96 * @see MCAChatInterface |
|
97 */ |
|
98 MCAMessagesReadInterface* ChatExistsL( const TDesC& aServerAddress, |
|
99 const TDesC& aUserId, |
|
100 const TDesC& aTargetId ); |
|
101 |
|
102 /** |
|
103 * @see MCAChatInterface |
|
104 */ |
|
105 MCAMessagesReadInterface& ChangeChatIdL( |
|
106 const TDesC& aOldServerAddress, |
|
107 const TDesC& aOldUserId, |
|
108 const TDesC& aOldTargetId, |
|
109 const TDesC& aNewServerAddress, |
|
110 const TDesC& aNewUserId, |
|
111 const TDesC& aNewTargetId, |
|
112 MCAMessagesReadInterface::TContainerType aType ); |
|
113 |
|
114 |
|
115 |
|
116 /** |
|
117 * @see MCAChatInterface |
|
118 */ |
|
119 TInt GroupCount() const; |
|
120 |
|
121 /** |
|
122 * @see MCAChatInterface |
|
123 */ |
|
124 TInt ChatCount() const; |
|
125 |
|
126 /** |
|
127 * @see MCAChatInterface |
|
128 */ |
|
129 MCAMessagesReadInterface& GroupAt( TInt aIndex ) const; |
|
130 |
|
131 /** |
|
132 * @see MCAChatInterface |
|
133 */ |
|
134 MCAMessagesReadInterface& ChatAt( TInt aIndex ) const; |
|
135 |
|
136 /** |
|
137 * @see MCAChatInterface |
|
138 */ |
|
139 TInt RegisterChatObserver( MCAChatObserver* aObserver ); |
|
140 |
|
141 /** |
|
142 * @see MCAChatInterface |
|
143 */ |
|
144 TInt UnregisterChatObserver( MCAChatObserver* aObserver ); |
|
145 |
|
146 /** |
|
147 * @see MCAChatInterface |
|
148 */ |
|
149 void ResetPendingCount(); |
|
150 |
|
151 /** |
|
152 * @see MCAChatInterface |
|
153 */ |
|
154 TInt MessagesPendingCount( TInt& aCountOfChats, |
|
155 MCAMessagesReadInterface::TUnreadFilter aUnreadFilter = |
|
156 MCAMessagesReadInterface::EUnreadAll ) const; |
|
157 |
|
158 /** |
|
159 * @see MCAChatInterface |
|
160 */ |
|
161 MCAMessageContainerInfo* PendingMessageInfo() const; |
|
162 |
|
163 #ifdef RD_CHAT_GROUP_MESSAGE_INDICATION_NEW |
|
164 /** |
|
165 * @see MCAChatInterface |
|
166 */ |
|
167 TInt ChatGroupMessagesPendingCount( TInt& aCountOfChats ) const; |
|
168 |
|
169 /** |
|
170 * @see MCAChatInterface |
|
171 */ |
|
172 MCAMessageContainerInfo* ChatGroupPendingMessageInfo() const; |
|
173 |
|
174 #endif // RD_CHAT_GROUP_MESSAGE_INDICATION_NEW |
|
175 |
|
176 private: // Methods from MCABufferMemoryHandler |
|
177 |
|
178 /** |
|
179 * @see MCABufferMemoryHandler |
|
180 */ |
|
181 TBool FreeMemoryIfNeededL( TInt aSize ); |
|
182 |
|
183 /** |
|
184 * @see MCABufferMemoryHandler |
|
185 */ |
|
186 void SetAccessInterface( MCAChatInterface* aAccess ); |
|
187 |
|
188 private: // Methods from MCAChatObserver |
|
189 |
|
190 /** |
|
191 * @see MCAChatObserver |
|
192 */ |
|
193 void HandleChatEvent( TChatEventType aEvent, |
|
194 MCAMessage* aMessage = NULL ); |
|
195 |
|
196 public: // New methods |
|
197 |
|
198 /** |
|
199 * Resolve recipient of message identified by operation code. |
|
200 * @param aOperationCode, Identifier for getting right message. |
|
201 * @param aStatus. Status of operation. KErrNone/KErrNotFound |
|
202 * @return Message recipient |
|
203 */ |
|
204 const TDesC& MessageRecipient( TInt aOperationCode, |
|
205 TInt& aStatus ) const; |
|
206 |
|
207 /** |
|
208 * Set external memoryhandler. Set with NULL, |
|
209 * if wanted to reset external handler. |
|
210 */ |
|
211 void SetExternalMemoryHandler( MCABufferMemoryHandler* aMemoryHandler ); |
|
212 |
|
213 private: // New helper methods |
|
214 |
|
215 /** |
|
216 * Return index to chat. Try to create if does not exists. |
|
217 * Leave if not possible. e.g. KErrNoMemory. |
|
218 * @param aServerAddress Part of identifier to identify container. |
|
219 * @param aUserId Part of identifier to identify container. |
|
220 * @param aTargetId Part of identifier to identify container. |
|
221 * @return Index of container. |
|
222 */ |
|
223 TInt ChatL( const TDesC& aServerAddress, |
|
224 const TDesC& aUserId, |
|
225 const TDesC& aTargetId, |
|
226 MCAMessagesReadInterface::TContainerType aType = |
|
227 MCAMessagesReadInterface::ENoneContainer ); |
|
228 |
|
229 /** |
|
230 * Returns latest found item by index. |
|
231 * FindChat or ChatL( id, type ) must be called before this one. |
|
232 * @param aIndex, Index of needed item. |
|
233 * @param aResetLatest. Reset type of latest found container. |
|
234 * ETrue, Reset, EFalse, No reseting. |
|
235 * @return Pointer to right container. |
|
236 */ |
|
237 CCAMessageContainer* ChatL( TInt aIndex, TBool aResetLatest = ETrue ); |
|
238 |
|
239 /** |
|
240 * FindChat or ChatL( id, type ) must be called before this one. |
|
241 * @param aIndex, Index of needed item. |
|
242 * @param aResetLatest. Reset type of latest found container. |
|
243 * ETrue, Reset, EFalse, No reset. |
|
244 */ |
|
245 void RemoveChat( TInt aIndex, TBool aResetLatest = ETrue ); |
|
246 |
|
247 /** |
|
248 * Finds if container exists and returns index. |
|
249 * @param aChat Reference chat. |
|
250 * @return Index of container. If container is not found, |
|
251 * KErrNotFound is returned. |
|
252 */ |
|
253 TInt FindChat( const CCAMessageContainer& aChat ); |
|
254 |
|
255 /** |
|
256 * Create new container. Change aServerAddress and userid to |
|
257 * current ones, if KNullDesC used. |
|
258 * @see CCAMessageContainer |
|
259 */ |
|
260 CCAMessageContainer* CreateContainerLC( |
|
261 const TDesC& aServerAddress, |
|
262 const TDesC& aUserId, |
|
263 const TDesC& aTargetId, |
|
264 MCABufferMemoryHandler& aMemoryHandler, |
|
265 MCAMessagesReadInterface::TContainerType aType ); |
|
266 private: // Member data |
|
267 |
|
268 /// Access to settings |
|
269 MCASettings& iSettingsInterface; |
|
270 |
|
271 /// Container of chats. Owns items. |
|
272 RPointerArray< CCAMessageContainer > iChatContainer; |
|
273 |
|
274 /// Container of groups. Owns items. |
|
275 RPointerArray< CCAMessageContainer > iGroupContainer; |
|
276 |
|
277 /// Container of send buffers. Owns items. |
|
278 RPointerArray< CCAMessageContainer > iSendContainer; |
|
279 |
|
280 /// Container of observers. Does not own items. |
|
281 RPointerArray< MCAChatObserver > iObservers; |
|
282 |
|
283 /// External memory handler if set. |
|
284 MCABufferMemoryHandler* iExternalMemoryHandler; |
|
285 |
|
286 /// Last found item type |
|
287 MCAMessagesReadInterface::TContainerType iLatestType; |
|
288 }; |
|
289 |
|
290 |
|
291 #endif // CCACHATCONTAINER_H |
|
292 |
|
293 // End of File |