|
1 /* |
|
2 * Copyright (c) 2006 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: Group handling utilities |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CCAGROUPUTILSPC_H |
|
21 #define CCAGROUPUTILSPC_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "CCAChatInfoArray.h" |
|
25 #include "MCAGroupOperations.h" |
|
26 #include "MCAGroupUtilsPC.h" |
|
27 #include "MCAInviteConflictResolver.h" |
|
28 |
|
29 #include <e32base.h> |
|
30 #include <badesca.h> |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CCAEngine; |
|
34 class MCAGroupOperations; |
|
35 class CImpsCommonGroupProps; |
|
36 class CImpsPrivateGroupProps; |
|
37 class CCAServerContactsArray; |
|
38 class MCAConversationMessage; |
|
39 class MCAStoredGroups; |
|
40 |
|
41 |
|
42 |
|
43 // CLASS DECLARATION |
|
44 |
|
45 /** |
|
46 * Process component for Group editing and displaying utilities |
|
47 * |
|
48 * @lib chatng.app |
|
49 */ |
|
50 class CCAGroupUtilsPC : public CBase, |
|
51 public MCAGroupUtilsPC |
|
52 { |
|
53 public: // constructor |
|
54 /** |
|
55 * Static constructor. |
|
56 * @param aEngine Handle to application engine |
|
57 * @return Instance of this class |
|
58 */ |
|
59 static CCAGroupUtilsPC* NewLC( CCAEngine& aEngine ); |
|
60 |
|
61 /** |
|
62 * Static constructor. |
|
63 * @param aEngine Handle to application engine |
|
64 * @return Instance of this class |
|
65 */ |
|
66 static CCAGroupUtilsPC* NewL( CCAEngine& aEngine ); |
|
67 |
|
68 /** |
|
69 * Destructor |
|
70 */ |
|
71 ~CCAGroupUtilsPC(); |
|
72 |
|
73 public: |
|
74 |
|
75 // simple group generation ("SGC") FSM states |
|
76 enum TSGCState |
|
77 { |
|
78 ESGCInviteContacts = 0, // choose contacts to invite (Begin state) |
|
79 ESGCGroupName, // select group name |
|
80 ESGCInviteMessage, // invite message query |
|
81 ESGCScreenName, // screenname query or alias usage |
|
82 ESGCCreateGroup, // create the group |
|
83 ESGCDoSendInvite, // send the invitations, if any |
|
84 ESGCDoJoin, // actually join the group |
|
85 ESGCError, // error state |
|
86 ESGCQueryCancel, // ask for cancelling |
|
87 ESGCNone // no state |
|
88 }; |
|
89 |
|
90 // Chat group join mode |
|
91 enum TJoinMode |
|
92 { |
|
93 EStoredId = 0, // Group id received from some store |
|
94 EManualId // Group id entered manually by user |
|
95 }; |
|
96 |
|
97 |
|
98 /* |
|
99 *@see MCAGroupUtilsPC |
|
100 */ |
|
101 CCAChatInfoArray* GetChatInfoArrayL( const TDesC& aGroupId ); |
|
102 |
|
103 /* |
|
104 *@see MCAGroupUtilsPC |
|
105 */ |
|
106 TInt GetCreatedChatRoomListL( CDesCArray& aTempArray, CDesCArray& aGroupIds ); |
|
107 |
|
108 /* |
|
109 *@see MCAGroupUtilsPC |
|
110 */ |
|
111 TInt SwitchToJoinedGroupL( const TDesC& aGroupID, TCADnlChatViewBuf& aViewDnl , |
|
112 const MCAConversationMessage* aFwdMessage, |
|
113 TBool aInviteQuery ); |
|
114 |
|
115 |
|
116 /** |
|
117 * To show the screen name query with given group name |
|
118 * @param aScreenName: display name |
|
119 */ |
|
120 void ScreenNameQueryL( TDes& aScreenName ); |
|
121 |
|
122 /** |
|
123 * Helper function for EditChatGroupPropertiesL and CreateNewChat. |
|
124 * Moves own user id to first in list. |
|
125 * @param aList Reference to a list where own user id is removed and moved to |
|
126 * the first position. |
|
127 */ |
|
128 void MoveOwnIdToFirstL( CDesCArray& aList ); |
|
129 |
|
130 /** |
|
131 * Updates the group member status. Leaves on errors. |
|
132 * This method will calculate delta lists based on previous and new |
|
133 * lists |
|
134 * @param aGroupId GroupID |
|
135 * @param aOldAdmins List of previous admins |
|
136 * @param aAdmins List of new admins |
|
137 * @param aOldUserList List of previous users |
|
138 * @param aUserList List of new users |
|
139 * @param aOldRejected List of previous rejected users |
|
140 * @param aRejected List of new rejected users. |
|
141 */ |
|
142 void UpdateGroupMembersL( const TDesC& aGroupId, |
|
143 const CDesCArray& aOldAdmins, const CDesCArray& aAdmins, |
|
144 const CDesCArray& aOldUserList, const CDesCArray& aUserList, |
|
145 const CDesCArray& aOldRejected, const CDesCArray& aRejected ); |
|
146 |
|
147 /** |
|
148 * Adds members to the group. Leaves on errors |
|
149 * @param aGroupId GroupID |
|
150 * @param aAdmins Admins |
|
151 * @param aUserList Users |
|
152 * @param aRejected Rejected users |
|
153 */ |
|
154 void AddGroupMembersL( const TDesC& aGroupId, CDesCArray& aAdmins, |
|
155 const CDesCArray& aUserList, const CDesCArray& aRejected ); |
|
156 |
|
157 /** |
|
158 * Gets the banned users of group |
|
159 * @param aRejectList List of rejected users |
|
160 * @param aGroup: group id whose rejected lists ve to be fetched |
|
161 * @return CSP error code |
|
162 */ |
|
163 TInt GetRejectListL( CDesCArray& aRejectList , const TDesC& aGroupId ); |
|
164 |
|
165 /** |
|
166 * Gets the members of group |
|
167 * @param aUserList List of users |
|
168 * @param aScreenNames List of screen names |
|
169 * @param aModers List of moderators |
|
170 * @param aAdmins List of administrators |
|
171 * @return CSP error code |
|
172 */ |
|
173 TInt GetMembersL( CDesCArray& aUserList, |
|
174 CDesCArray& aScreenNames, |
|
175 CDesCArray& aModers, |
|
176 CDesCArray& aAdmins, const TDesC& aGroup ); |
|
177 |
|
178 /* |
|
179 *@see MCAGroupUtilsPC |
|
180 */ |
|
181 const TPtrC GetIdentificationL( const TDesC& aContactId ); |
|
182 |
|
183 |
|
184 /** |
|
185 * Creates new group to server |
|
186 * @param aScreenName screen name |
|
187 * @param aJoinGroup Should the group be joined after creation |
|
188 * @return CSP error code |
|
189 */ |
|
190 HBufC* CreateGroupL( const TDesC& aScreenName, const TDesC& aGroupName, TInt& aError ); |
|
191 |
|
192 /** |
|
193 * Join a group. |
|
194 * Leaves if out of memory before sending a message to the Symbian OS server. |
|
195 * @param aGroupId group id |
|
196 * @param aScreenName screen name for the user, optional (may be zero length) |
|
197 * @param aUsers ETrue if a user wants to get list of joined users in a reponse, |
|
198 * @param aIsFavourite : if the group is saved as favourite |
|
199 * @return operation-id (positive) |
|
200 */ |
|
201 TInt JoinGroupL( const TDesC& aGroupId, |
|
202 const TDesC& aScreenName, |
|
203 TBool aUsers, TBool aIsFavourite ); |
|
204 |
|
205 /** |
|
206 * To fetch the data of a group |
|
207 * @param aGroupId: id of the group whose data has to be fetched |
|
208 * @param aUserList: list of users allowed access to the group |
|
209 * @param aScreenNames: screen names of all the users joined to the group |
|
210 * @param aModerators: the users given moderator privileges to the group |
|
211 * @param aAdmins: the users who have been given admin privileges to the list |
|
212 * @param aRejected: list of users banned from entering the group |
|
213 * @return errorcode |
|
214 */ |
|
215 TInt GetGroupDataL( const TDesC& aGroupId, |
|
216 CDesCArray& aUserList, CDesCArray& aScreenNames, |
|
217 CDesCArray& aModerators, CDesCArray& aAdmins, |
|
218 CDesCArray& aRejected ); |
|
219 |
|
220 /* |
|
221 *@see MCAGroupUtilsPC |
|
222 */ |
|
223 virtual void GetDefaultGroupNameL( TPtr& aChatGroupName, |
|
224 TEnumsPC::TListSelectionType aSelType ); |
|
225 |
|
226 /* |
|
227 *@see MCAGroupUtilsPC |
|
228 */ |
|
229 TInt ProcessEditedGroupPropertiesL( const TDesC& aGroupId, |
|
230 CDesCArray& aOldAdmins, |
|
231 CDesCArray& aNewAdmins, |
|
232 CDesCArray& aOldUsers, |
|
233 CDesCArray& aNewUsers, |
|
234 CDesCArray& aOldRejected, |
|
235 CDesCArray& aNewRejected ); |
|
236 |
|
237 /* |
|
238 *@see MCAGroupUtilsPC |
|
239 */ |
|
240 HBufC* GetAliasL(); |
|
241 |
|
242 /* |
|
243 *@see MCAGroupUtilsPC |
|
244 */ |
|
245 void CreateOrJoinGroupL( const TDesC& aGroupId, |
|
246 TBool& aIsJoined, TBool& aIsFavourite ); |
|
247 |
|
248 |
|
249 /* |
|
250 *@see MCAGroupUtilsPC |
|
251 */ |
|
252 void SaveAsFavouriteL( const TDesC& aGroupId ); |
|
253 |
|
254 /** |
|
255 * Name of the group |
|
256 * @return name of the group |
|
257 */ |
|
258 TPtrC GetEngineDefaultGroupName( const TDesC& aGroupId ) const; |
|
259 |
|
260 /** |
|
261 * Set the group name property of the specified group |
|
262 * @param aGroupId: group id of the group whose name has to be changed |
|
263 */ |
|
264 void SetGroupNameL( const TDesC& aGroupId ); |
|
265 |
|
266 /* |
|
267 *@see MCAGroupUtilsPC |
|
268 */ |
|
269 TInt DeleteGroupL( const TDesC& aGroupId, TBool aDeleteFromNetwork ); |
|
270 |
|
271 /* |
|
272 *@see MCAGroupUtilsPC |
|
273 */ |
|
274 TInt DeleteChatGroupFromNetworkL( const TDesC& aGroupId, TBool aDeleteFromNetwork ); |
|
275 |
|
276 /* |
|
277 *@see MCAGroupUtilsPC |
|
278 */ |
|
279 void DeleteFailedGroupL( const TDesC& aGroupId, TBool aDeleteFromNetwork ); |
|
280 |
|
281 /* |
|
282 *@see MCAGroupUtilsPC |
|
283 */ |
|
284 TPtrC GetGroupNameForJoinedGroupL( const TDesC& aGroupId ); |
|
285 |
|
286 /* |
|
287 *@see MCAGroupUtilsPC |
|
288 */ |
|
289 HBufC* CreateGroupSimpleL( const TDesC& aScreenName, |
|
290 TBool aJoinGroup, |
|
291 TBool aIsWhisperingEnabled, |
|
292 TInt& aErrorCode ) ; |
|
293 |
|
294 |
|
295 /** |
|
296 * To send invitations from the group view to selected contacts |
|
297 * @param aUserIDs: list of users to whom the invites have to be sent |
|
298 * @param aGroupId: id of the group from which the invite is being sent |
|
299 * @param aMessage: the message that has to be sent to the invitees |
|
300 * @return int: error code |
|
301 */ |
|
302 TInt SendInvitationsL( const CDesCArray& aUserIDs, |
|
303 const TDesC& aGroupID, |
|
304 const TDesC& aMessage ); |
|
305 |
|
306 public: |
|
307 |
|
308 /** |
|
309 * Find a group from the store |
|
310 * @param aId the ID of the group to find |
|
311 * @return The group |
|
312 */ |
|
313 TBool FindGroup( const TDesC& aId ) ; |
|
314 |
|
315 /** |
|
316 * Get the User Ids of participants of the group (joined users) |
|
317 * Makes copies of the descriptors. |
|
318 * @param aParticipantList |
|
319 */ |
|
320 void GetParticipantsL( CDesCArray& aParticipantList, |
|
321 const TDesC& aGroupId ) const ; |
|
322 |
|
323 /** |
|
324 * Check if the user has joined this group |
|
325 * @return ETrue if the group has been joined |
|
326 */ |
|
327 TBool IsJoined( const TDesC& aGroupId ) const ; |
|
328 |
|
329 /** |
|
330 * See if this is the user's group |
|
331 * @return ETrue if this group is the user's group |
|
332 */ |
|
333 TBool IsOwnGroup( const TDesC& aGroupId ) const ; |
|
334 |
|
335 /** |
|
336 * Check if the user is administrator in this group |
|
337 * @return ETrue if the user is administrator |
|
338 */ |
|
339 TBool IsAdmin( const TDesC& aGroupId ) const ; |
|
340 |
|
341 /** |
|
342 * Leave the given group. Use this method instead of |
|
343 * calling the wrapper directly (to avoid race |
|
344 * conditions). This method also does cleanup and |
|
345 * removes the group wrapper, if necessary. |
|
346 * Wraps the LeaveL in MCAGroupOperations. |
|
347 * @param aGroupId The group to leave |
|
348 * @return IMPS error code from LeaveL |
|
349 */ |
|
350 TInt LeaveGroupL( const TDesC& aGroupId ) ; |
|
351 |
|
352 |
|
353 /** |
|
354 * Checks if chat group is favourite or not |
|
355 * @param aGroupId The id of group for which to know if user has saved has favorite |
|
356 * @return ETrue if favourite EFalse if not |
|
357 */ |
|
358 TBool IsFavouriteChatGroup( const TDesC& aGroupId ) const ; |
|
359 |
|
360 private: // constructors and destructors |
|
361 |
|
362 /** |
|
363 * constructor |
|
364 */ |
|
365 void ConstructL(); |
|
366 |
|
367 /** |
|
368 * Default constructor |
|
369 * @param aEngine Handle to engine |
|
370 * @param aViewSwitcher Handle to view switcher |
|
371 */ |
|
372 CCAGroupUtilsPC( CCAEngine& aEngine ); |
|
373 |
|
374 private: // Data |
|
375 |
|
376 // Handle to application engine. |
|
377 CCAEngine& iEngine; |
|
378 |
|
379 // Owns. Used temporarily in CreateNewChatL. |
|
380 HBufC* iGroupId; |
|
381 |
|
382 //Pointer to current group. Doesnt own |
|
383 MCAStoredGroup* currentGroup; |
|
384 |
|
385 //doesn't own,handle to groups interface |
|
386 MCAStoredGroups* iStoredGroups; |
|
387 |
|
388 //doesnt own. pointer to group manager interface |
|
389 MCAGroupManagerInterface* iGroupManagerInterface; |
|
390 }; |
|
391 |
|
392 #endif // CCAGROUPUTILSPC_H |
|
393 |
|
394 // End of File |