|
1 /* |
|
2 * Copyright (c) 2003 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: Network operations for chat group handling. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CCAGROUPMANAGER_H |
|
20 #define CCAGROUPMANAGER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include "MCAImpsGroupClient.h" |
|
24 #include "MCAGroupManagerInterface.h" |
|
25 #include "PublicEngineDefinitions.h" |
|
26 #include <ImpsGroupCli.h> |
|
27 #include <ImpsClient.h> |
|
28 |
|
29 #include <e32base.h> |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class MCAStoredGroups; |
|
33 class MCAStoredContact; |
|
34 class MCAStoredContacts; |
|
35 class MCASettings; |
|
36 class CCARequestMapper; |
|
37 class MCASearchInterface; |
|
38 class MCAGroupObserver; |
|
39 class CCAGroupWrapper; |
|
40 class MCAImpsFactory; |
|
41 class MCAChatInterface; |
|
42 class MCAMessageUtils; |
|
43 class MCAMessagesWriteInterface; |
|
44 |
|
45 // CLASS DECLARATION |
|
46 |
|
47 /** |
|
48 * Network operations for chat group handling. |
|
49 * |
|
50 * @lib CAEngine.lib |
|
51 * @since 2.1 |
|
52 */ |
|
53 class CCAGroupManager : public CBase, |
|
54 public MImpsErrorHandler2, |
|
55 public MImpsGroupHandler2, |
|
56 public MCAGroupManagerInterface |
|
57 { |
|
58 public: // Constructors and destructor |
|
59 |
|
60 /** |
|
61 * Two-phased constructor. |
|
62 * @param aSearchAPI is the API to the search manager. |
|
63 * @param aSettingsAPI is the API to the settings side. |
|
64 * @param aRequestMapper is the API to the request mapper. |
|
65 * Used to provide synchronous waiting. |
|
66 * @param aIMPSFactory The factory which can create IMPS interfaces |
|
67 * when demanded |
|
68 * @param aChatInterface is the API to the chat containers. |
|
69 */ |
|
70 static CCAGroupManager* NewL( |
|
71 MCASearchInterface& aSearchAPI, |
|
72 MCASettings& aSettingsAPI, |
|
73 CCARequestMapper& aRequestMapper, |
|
74 MCAImpsFactory* aIMPSFactory, |
|
75 MCAChatInterface& aChatInterface, |
|
76 MCAMessageUtils& aMessageUtils ); |
|
77 |
|
78 /** |
|
79 * Destructor. |
|
80 */ |
|
81 virtual ~CCAGroupManager(); |
|
82 |
|
83 public: // from MCAGroupManagerInterface |
|
84 |
|
85 /** |
|
86 * From MCAGroupManagerInterface |
|
87 * @see MCAGroupManagerInterface::NumberOfCreatedGroupsDuringSession |
|
88 */ |
|
89 TInt NumberOfCreatedGroupsDuringSession() const; |
|
90 |
|
91 /** |
|
92 * From MCAGroupManagerInterface |
|
93 * @see MCAGroupManagerInterface::PopulateCreatedGroupsL |
|
94 */ |
|
95 TInt PopulateCreatedGroupsL( CDesCArray& aGroupList ) const; |
|
96 |
|
97 /** |
|
98 * From MCAGroupManagerInterface |
|
99 * @see MCAGroupManagerInterface::JoinedGroups |
|
100 */ |
|
101 TInt JoinedGroups(); |
|
102 |
|
103 /** |
|
104 * From MCAGroupManagerInterface |
|
105 * @see MCAGroupManagerInterface::GroupOperationsL |
|
106 */ |
|
107 MCAGroupOperations* GroupOperationsL( const TDesC& aId ); |
|
108 |
|
109 /** |
|
110 * From MCAGroupManagerInterface |
|
111 * @see MCAGroupManagerInterface::SetGroupEventObserverL |
|
112 */ |
|
113 void SetGroupEventObserverL( const TDesC& aId, MCAGroupEventObserver* aObserver ); |
|
114 |
|
115 /** |
|
116 * From MCAGroupManagerInterface |
|
117 * @see MCAGroupManagerInterface::CreateGroupL |
|
118 */ |
|
119 HBufC* CreateGroupL( |
|
120 CImpsCommonGroupProps* aProperties, |
|
121 CImpsPrivateGroupProps* aPrivProperties, |
|
122 const TDesC& aScreenName, |
|
123 TBool aJoinGroup, |
|
124 TBool aIsWhisperingEnabled, |
|
125 TInt& aErrorCode |
|
126 ); |
|
127 |
|
128 /** |
|
129 * From MCAGroupManagerInterface |
|
130 * @see MCAGroupManagerInterface::JoinGroupL |
|
131 */ |
|
132 TInt JoinGroupL( const TDesC& aGroupId, const TDesC& aScreenName, |
|
133 TBool aUsers, TBool aIsFavourite, TBool aIsWhisperingEnabled ); |
|
134 |
|
135 /** |
|
136 * From MCAGroupManagerInterface |
|
137 * @see MCAGroupManagerInterface::LeaveJoinedGroupsL |
|
138 */ |
|
139 void LeaveJoinedGroupsL(); |
|
140 |
|
141 /** |
|
142 * From MCAGroupManagerInterface |
|
143 * @see MCAGroupManagerInterface::LeaveGroupL |
|
144 */ |
|
145 TInt LeaveGroupL( const TDesC& aGroupId ); |
|
146 |
|
147 /** |
|
148 * From MCAGroupManagerInterface |
|
149 * @see MCAGroupManagerInterface::GenerateGroupIdLC |
|
150 */ |
|
151 HBufC* GenerateGroupIdLC( const TDesC& aResourcePart ); |
|
152 |
|
153 /** |
|
154 * From MCAGroupManagerInterface |
|
155 * @see MCAGroupManagerInterface::DeleteGroupL |
|
156 */ |
|
157 TInt DeleteGroupL( const TDesC& aGroupId, TBool aDeleteFromNetwork ); |
|
158 |
|
159 /** |
|
160 * From MCAGroupManagerInterface |
|
161 * @see MCAGroupManagerInterface::IsAllowedAccessL |
|
162 */ |
|
163 TBool IsAllowedAccessL( const TDesC& aGroupId, |
|
164 const CDesCArray& aCheckUsers, |
|
165 CDesCArray& aNotInList ); |
|
166 |
|
167 /** |
|
168 * From MCAGroupManagerInterface |
|
169 * @see MCAGroupManagerInterface::IsGroupOpenL |
|
170 */ |
|
171 TBool IsGroupOpenL( const TDesC& aGroupId ); |
|
172 |
|
173 /** |
|
174 * From MCAGroupManagerInterface |
|
175 * @see MCAGroupManagerInterface::GroupNameL |
|
176 */ |
|
177 HBufC* GroupNameL( const TDesC& aGroupId ); |
|
178 |
|
179 public: // new methods |
|
180 |
|
181 /** |
|
182 * Handles network state changes |
|
183 * @param aState network state |
|
184 */ |
|
185 void HandleNetworkStateChangeL( TNetworkState aState ); |
|
186 |
|
187 /** |
|
188 * Propagates IMPS error code. |
|
189 * @param aError last IMPS error. |
|
190 */ |
|
191 void LastImpsError( TInt aError ); |
|
192 void CancelGroupOperationL(const TDesC& aGroupId); |
|
193 |
|
194 protected: // From MImpsErrorHandler |
|
195 |
|
196 /** |
|
197 * From MImpsErrorHandler |
|
198 * @see MImpsErrorHandler::HandleErrorL |
|
199 */ |
|
200 void HandleErrorL( |
|
201 TInt aStatus, |
|
202 TInt aOpId, |
|
203 const TDesC* aDescription, |
|
204 const CImpsDetailed* aDetailedRes, |
|
205 TImpsCspIdentifier& aCspId ); |
|
206 |
|
207 protected: // From MImpsGroupHandler |
|
208 |
|
209 /** |
|
210 * From MImpsGroupHandler, Handles a response of CreateGroupL, DeleteGroupL, |
|
211 * AddMembersL, |
|
212 * RemoveMembersL, ModifyMembersAccessL, SubscribeL, UnsubscribeL. |
|
213 * @see MImpsGroupHandler::HandleCompleteL |
|
214 */ |
|
215 void HandleCompleteL( |
|
216 TInt aOpId, |
|
217 TImpsCspIdentifier& aCspId ); |
|
218 |
|
219 /** |
|
220 * From MImpsGroupHandler, Handles JoinGroupL response. |
|
221 * @see MImpsGroupHandler::HandleJoinL |
|
222 */ |
|
223 void HandleJoinL( |
|
224 TInt aOpId, |
|
225 const MDesCArray& aUserList, |
|
226 const MDesCArray& aScreenNames, |
|
227 const TDesC& aWelcomeText, |
|
228 TImpsCspIdentifier& aCspId ); |
|
229 |
|
230 /** |
|
231 * From MImpsGroupHandler, Handles GroupMembersL response. |
|
232 * @see MImpsGroupHandler::HandleGroupMembersL |
|
233 */ |
|
234 void HandleGroupMembersL( |
|
235 TInt aOpId, |
|
236 const MDesCArray& aUserList, |
|
237 const MDesCArray& aScreenNames, |
|
238 const MDesCArray& aModers, |
|
239 const MDesCArray& aAdmins, |
|
240 TImpsCspIdentifier& aCspId ); |
|
241 |
|
242 /** |
|
243 * From MImpsGroupHandler, Handles GroupPropertiesL response and subscribed notification. |
|
244 * @see MImpsGroupHandler::HandleGroupPropertiesL |
|
245 */ |
|
246 void HandleGroupPropertiesL( |
|
247 TInt aOpId, |
|
248 const TDesC& aGroupId, |
|
249 const CImpsCommonGroupProps& aGroupProps, |
|
250 const CImpsPrivateGroupProps& aOwnProps, |
|
251 TImpsCspIdentifier& aCspId ); |
|
252 |
|
253 /** |
|
254 * From MImpsGroupHandler, Handles SetRejectListL response. |
|
255 * @see MImpsGroupHandler::HandleRejectListL |
|
256 */ |
|
257 void HandleRejectListL( |
|
258 TInt aOpId, |
|
259 const MDesCArray& aUserList, |
|
260 TImpsCspIdentifier& aCspId ); |
|
261 |
|
262 /** |
|
263 * From MImpsGroupHandler, Handles CheckSubscriptionL response. |
|
264 * MImpsGroupHandler::HandleSubscriptionL |
|
265 */ |
|
266 void HandleSubscriptionL( |
|
267 TInt aOpId, |
|
268 TBool aIsSubscribed, |
|
269 TImpsCspIdentifier& aCspId ); |
|
270 |
|
271 /** |
|
272 * From MImpsGroupHandler, Handles group change notification about new users. |
|
273 * @see MImpsGroupHandler::HandleNewUsersL |
|
274 */ |
|
275 void HandleNewUsersL( |
|
276 const TDesC& aGroupId, |
|
277 const MDesCArray& aUserList, |
|
278 const MDesCArray& aScreenNames, |
|
279 TImpsCspIdentifier& aCspId ); |
|
280 |
|
281 /** |
|
282 * From MImpsGroupHandler, Handles group change notification about users left. |
|
283 * @see MImpsGroupHandler::HandleLeftUsersL |
|
284 */ |
|
285 void HandleLeftUsersL( |
|
286 const TDesC& aGroupId, |
|
287 const MDesCArray& aUserList, |
|
288 const MDesCArray& aScreenNames, |
|
289 TImpsCspIdentifier& aCspId ); |
|
290 |
|
291 /** |
|
292 * From MImpsGroupHandler, Handles both LeaveGroupL response and a service |
|
293 * initiated group leave situation. |
|
294 * @see MImpsGroupHandler::HandleLeaveL |
|
295 */ |
|
296 void HandleLeaveL( |
|
297 TInt aOpId, |
|
298 const TDesC& aGroupId, |
|
299 const TDesC& aDescription, |
|
300 TImpsCspIdentifier& aCspId ); |
|
301 |
|
302 private: // new methods |
|
303 |
|
304 /** |
|
305 * Find the group wrapper class based on the operation id. |
|
306 * @param aOpId The operation id |
|
307 * @return The group wrapper if found, NULL otherwise |
|
308 */ |
|
309 CCAGroupWrapper* FindGroupWrapper( TInt aOpId ); |
|
310 |
|
311 /** |
|
312 * Overloaded version. |
|
313 * @param aGroupId The group id |
|
314 * @see FindGroupWrapper |
|
315 */ |
|
316 CCAGroupWrapper* FindGroupWrapper( const TDesC& aGroupId ); |
|
317 |
|
318 /** |
|
319 * Get the properties for the given group. |
|
320 * Replaces the given parameters with new properties. |
|
321 * Used internally. |
|
322 * @param aGroupId The group id |
|
323 * @param aCommonProps The group common properties |
|
324 * @param aPrivProps The group private properties |
|
325 */ |
|
326 void GetPropertiesL( const TDesC& aGroupId, |
|
327 CImpsCommonGroupProps*& aCommonProps, |
|
328 CImpsPrivateGroupProps*& aPrivProps ); |
|
329 |
|
330 /** |
|
331 * Delete a group wrapper based on the group id. |
|
332 * Doesn't do anything if no such group id could be found. |
|
333 * @param aGroupId The group id |
|
334 */ |
|
335 void DeleteGroupWrapper( const TDesC& aGroupId ); |
|
336 |
|
337 /** |
|
338 * Create a new group wrapper and add it to the internal list. |
|
339 * Leaves if the group could not be found. |
|
340 * @param aGroupId The group id |
|
341 * @return The created wrapper |
|
342 */ |
|
343 CCAGroupWrapper* CreateWrapperL( const TDesC& aGroupId ); |
|
344 |
|
345 /** |
|
346 * Cleanup things after leaving group |
|
347 * @param aWrapper The group wrapper |
|
348 */ |
|
349 void CleanupLeaveGroupL( const TDesC& aGroupId ); |
|
350 |
|
351 /** |
|
352 * Force the setting of private allowed flag |
|
353 * @param aWrapper Group wrapper |
|
354 * @param aPrivProps Private properties |
|
355 */ |
|
356 TInt SetPrivateAllowedL( CCAGroupWrapper& aWrapper, |
|
357 CImpsPrivateGroupProps& aPrivProps ); |
|
358 |
|
359 /** |
|
360 * Remove the chat data for the given group id. |
|
361 * If the chat data does not exist, it is not removed, |
|
362 * and there will be no error. |
|
363 * @param aGroupId The group id |
|
364 */ |
|
365 void RemoveChatDataL( const TDesC& aGroupId ); |
|
366 |
|
367 |
|
368 /** |
|
369 * Writes welcome message to messageinterface according to parameters. |
|
370 * If custom welcome message don't exist, the default one with |
|
371 * screen name is shown. Topic string is shown only if it is defined. |
|
372 * @param aWelcomeMessage Custom welcome message |
|
373 * @param aGroup Group name or id. |
|
374 * @param aTopic Topic |
|
375 * @param aMessages Iterface for writing constructed messages |
|
376 * @return None |
|
377 */ |
|
378 void WriteWelcomeMessageL( const TDesC& aWelcomeMessage, |
|
379 const TDesC& aGroup, |
|
380 const TDesC& aTopic, |
|
381 MCAMessagesWriteInterface& aMessages ); |
|
382 |
|
383 private: |
|
384 |
|
385 /** |
|
386 * By default Symbian OS constructor is private. |
|
387 */ |
|
388 void ConstructL(); |
|
389 |
|
390 /** |
|
391 * C++ default constructor. |
|
392 * @see CCAGroupManager::NewL. |
|
393 */ |
|
394 CCAGroupManager( |
|
395 MCASearchInterface& aSearchAPI, |
|
396 MCASettings& aSettingsAPI, |
|
397 CCARequestMapper& aRequestMapper, |
|
398 MCAImpsFactory* aIMPSFactory, |
|
399 MCAChatInterface& aChatInterface, |
|
400 MCAMessageUtils& aMessageUtils ); |
|
401 |
|
402 private: // Data |
|
403 |
|
404 CCARequestMapper& iRequestMapper; // not owned |
|
405 MCASettings& iSettingsAPI; // not owned |
|
406 MCASearchInterface& iSearchAPI; // not owned |
|
407 |
|
408 MCAStoredGroups* iStoredGroups; // not owned |
|
409 MCAStoredContacts* iStoredContacts; // not owned |
|
410 |
|
411 // not owned |
|
412 MCAImpsFactory* iImpsFactory; |
|
413 |
|
414 MCAChatInterface& iChatInterface; // not owned |
|
415 MCAMessageUtils& iMessageUtils; // not owned |
|
416 |
|
417 RPointerArray< CCAGroupWrapper > iGroupWrappers; // owned |
|
418 |
|
419 // These are used temporarily to store group properties |
|
420 // during CreateGroupL method before passing ownership |
|
421 // to group wrapper. Set at the start of CreateGroupL |
|
422 // method (after deleting previous values just in case that |
|
423 // previous CreateGroupL has failed) and set to NULL after |
|
424 // owner ship of properties is transferred to group wrapper. |
|
425 //If something fails (Leaves ) between these two phases, then variables |
|
426 // are not NULL and should be deleted in destructor or in next |
|
427 // time calling CreateGroupL. |
|
428 CImpsCommonGroupProps* iProperties; |
|
429 CImpsPrivateGroupProps* iPrivProperties; |
|
430 |
|
431 TInt iNumCreatedGroups; |
|
432 TInt iGroupIdOrdinal; |
|
433 TInt iNumJoinedGroups; |
|
434 |
|
435 // last IMPS error from CCAEngine |
|
436 TInt iLastImpsError; |
|
437 |
|
438 // Operation id of group props request when joining |
|
439 // to group |
|
440 TInt iPropsOpIdWhileJoining; |
|
441 }; |
|
442 |
|
443 #endif // CCAGROUPMANAGER_H |
|
444 |
|
445 // End of File |