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 * prior written consent of Nokia Corporation. |
|
14 * ============================================================================== |
|
15 */ |
|
16 |
|
17 #ifndef CIMCVENGINECHATCONTAINER_H |
|
18 #define CIMCVENGINECHATCONTAINER_H |
|
19 |
|
20 #include "mimcvenginebuffermemoryhandler.h" |
|
21 #include "mimcvenginechatinterface.h" |
|
22 #include "mimcvenginenewmsgobserver.h" |
|
23 #include "mimcvenginechatlistobserver.h" |
|
24 |
|
25 |
|
26 // FORWARD CLASS DECLERATIONS |
|
27 class CIMCVEngineMessageContainer; |
|
28 |
|
29 |
|
30 // CLASS DECLARATION |
|
31 |
|
32 /** |
|
33 * Container for message containers |
|
34 * |
|
35 * @lib imcvengine.dll |
|
36 * @since 5.0 |
|
37 */ |
|
38 class CIMCVEngineChatContainer : public CBase, |
|
39 public MIMCVEngineChatInterface, |
|
40 public MIMCVEngineBufferMemoryHandler, |
|
41 public MIMCVEngineNewMsgObserver |
|
42 { |
|
43 public: // Construction |
|
44 |
|
45 /** |
|
46 * Construction |
|
47 */ |
|
48 static CIMCVEngineChatContainer* NewL(TInt aServiceId); |
|
49 |
|
50 /** |
|
51 * Destruction |
|
52 */ |
|
53 ~CIMCVEngineChatContainer(); |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 private: // Construction |
|
59 |
|
60 /** |
|
61 * Constructor |
|
62 */ |
|
63 CIMCVEngineChatContainer( TInt aServiceId ); |
|
64 |
|
65 private: // Methods from MIMCVEngineChatInterface |
|
66 |
|
67 |
|
68 /** |
|
69 * @see MIMCVEngineChatInterface |
|
70 */ |
|
71 MIMCVEngineBufferMemoryHandler& MemoryHandler(); |
|
72 |
|
73 |
|
74 /** |
|
75 * @see MIMCVEngineChatInterface |
|
76 */ |
|
77 MIMCVEngineMessageReadInterface& MessageReadInterfaceL( |
|
78 TInt aServiceId, |
|
79 const TDesC& aTargetId, |
|
80 const TDesC& aDisplayName, |
|
81 const TDesC8& aContactLink, |
|
82 MIMCVEngineMessageReadInterface::TContainerType aType ); |
|
83 |
|
84 /** |
|
85 * @see MIMCVEngineChatInterface |
|
86 */ |
|
87 MIMCVEngineMessageWriteInterface& MessageWriteInterfaceL( |
|
88 TInt aServiceId, |
|
89 const TDesC& aTargetId, |
|
90 const TDesC& aDisplayName, |
|
91 const TDesC8& aContactLink, |
|
92 MIMCVEngineMessageReadInterface::TContainerType aType ); |
|
93 |
|
94 /** |
|
95 * @see MIMCVEngineChatInterface |
|
96 */ |
|
97 void DeleteChatL( |
|
98 TInt aServiceId, |
|
99 const TDesC& aTargetId ); |
|
100 |
|
101 /** |
|
102 * @see MIMCVEngineChatInterface |
|
103 */ |
|
104 void CloseAllContainers(); |
|
105 |
|
106 |
|
107 |
|
108 /** |
|
109 * @see MIMCVEngineChatInterface |
|
110 */ |
|
111 TInt ChatCount() const; |
|
112 |
|
113 |
|
114 /** |
|
115 * @see MIMCVEngineChatInterface |
|
116 */ |
|
117 void RegisterNewMsgObserver( MIMCVEngineNewMsgObserver* aObserver ); |
|
118 |
|
119 /** |
|
120 * @see MIMCVEngineChatInterface |
|
121 */ |
|
122 void UnregisterNewMsgObserver(); |
|
123 |
|
124 |
|
125 /** |
|
126 * @see MIMCVEngineNewMsgObserver |
|
127 */ |
|
128 TInt RegisterChatListObserver( MIMCVEngineChatListObserver* aObserver ); |
|
129 |
|
130 /** |
|
131 * @see MIMCVEngineNewMsgObserver |
|
132 */ |
|
133 TInt UnregisterChatListObserver( MIMCVEngineChatListObserver* aObserver ); |
|
134 |
|
135 |
|
136 /** |
|
137 * @see MIMCVEngineNewMsgObserver |
|
138 */ |
|
139 TInt MessagesPendingCount( TInt& aCountOfChats, |
|
140 MIMCVEngineMessageReadInterface::TUnreadFilter aUnreadFilter = |
|
141 MIMCVEngineMessageReadInterface::EUnreadAll ) const; |
|
142 |
|
143 |
|
144 |
|
145 private: // Methods from MIMCVEngineBufferMemoryHandler |
|
146 |
|
147 /** |
|
148 * @see MIMCVEngineBufferMemoryHandler |
|
149 */ |
|
150 TBool FreeMemoryIfNeededL( TInt aSize ); |
|
151 |
|
152 |
|
153 |
|
154 /** |
|
155 * return the chat interface at given index |
|
156 */ |
|
157 MIMCVEngineMessageReadInterface& ChatAt( TInt aIndex ) const; |
|
158 |
|
159 private: // Methods from MIMCVEngineNewMsgObserver |
|
160 |
|
161 /** |
|
162 * @see MIMCVEngineNewMsgObserver |
|
163 */ |
|
164 void HandleChatEventL( TChatEventType aEvent, |
|
165 MIMCVEngineMessage* aMessage = NULL ); |
|
166 |
|
167 |
|
168 |
|
169 private: // New helper methods |
|
170 |
|
171 /** |
|
172 * Return index to chat. Try to create if does not exists. |
|
173 * Leave if not possible. e.g. KErrNoMemory. |
|
174 * @param aServiceId Part of identifier to identify container. |
|
175 * @param aTargetId Part of identifier to identify container. |
|
176 * @return Index of container. |
|
177 */ |
|
178 TInt ChatL( TInt aServiceId, |
|
179 const TDesC& aTargetId, |
|
180 const TDesC& aDisplayName, |
|
181 const TDesC8& aContactLink, |
|
182 MIMCVEngineMessageReadInterface::TContainerType aType = |
|
183 MIMCVEngineMessageReadInterface::ENoneContainer ); |
|
184 |
|
185 /** |
|
186 * Returns latest found item by index. |
|
187 * FindChat or ChatL( id, type ) must be called before this one. |
|
188 * @param aIndex, Index of needed item. |
|
189 * @param aResetLatest. Reset type of latest found container. |
|
190 * ETrue, Reset, EFalse, No reseting. |
|
191 * @return Pointer to right container. |
|
192 */ |
|
193 CIMCVEngineMessageContainer* ChatL( TInt aIndex, TBool aResetLatest = ETrue ); |
|
194 |
|
195 /** |
|
196 * FindChat or ChatL( id, type ) must be called before this one. |
|
197 * @param aIndex, Index of needed item. |
|
198 * @param aResetLatest. Reset type of latest found container. |
|
199 * ETrue, Reset, EFalse, No reset. |
|
200 */ |
|
201 void RemoveChat( TInt aIndex, TBool aResetLatest = ETrue ); |
|
202 |
|
203 /** |
|
204 * Finds if container exists and returns index. |
|
205 * @param aChat Reference chat. |
|
206 * @return Index of container. If container is not found, |
|
207 * KErrNotFound is returned. |
|
208 */ |
|
209 TInt FindChat( const CIMCVEngineMessageContainer& aChat ); |
|
210 |
|
211 /** |
|
212 * Create new container. userid |
|
213 * current ones, if KNullDesC used. |
|
214 * @see CIMCVEngineMessageContainer |
|
215 */ |
|
216 CIMCVEngineMessageContainer* CreateContainerLC( |
|
217 TInt aServiceId, |
|
218 const TDesC& aTargetId, |
|
219 const TDesC& aDisplayName, |
|
220 const TDesC8& aContactLink, |
|
221 MIMCVEngineBufferMemoryHandler& aMemoryHandler, |
|
222 MIMCVEngineMessageReadInterface::TContainerType aType ); |
|
223 |
|
224 private: |
|
225 /** |
|
226 * helper method |
|
227 */ |
|
228 void HandleChatListEvent( TChatListEventType aEvent, |
|
229 MIMCVEngineMessageReadInterface& aContainerInfo ); |
|
230 |
|
231 |
|
232 private: // Member data |
|
233 // service Id |
|
234 TInt iServiceId; |
|
235 /// Container of chats. Owns items. |
|
236 RPointerArray< CIMCVEngineMessageContainer > iChatContainer; |
|
237 |
|
238 // Container of send buffers. Owns items. |
|
239 RPointerArray< CIMCVEngineMessageContainer > iSendContainer; |
|
240 |
|
241 /// Container of observers. Does not own items. |
|
242 MIMCVEngineNewMsgObserver* iNewMsgObserver; |
|
243 |
|
244 /// External memory handler if set. |
|
245 MIMCVEngineBufferMemoryHandler* iExternalMemoryHandler; |
|
246 |
|
247 /// Last found item type |
|
248 MIMCVEngineMessageReadInterface::TContainerType iLatestType; |
|
249 |
|
250 /// Container of observers. Does not own items. |
|
251 RPointerArray< MIMCVEngineChatListObserver > iChatListObservers; |
|
252 |
|
253 }; |
|
254 |
|
255 |
|
256 #endif // CIMCVENGINECHATCONTAINER_H |
|
257 |
|
258 // End of File |
|