|
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 CCAGROUPUTILS_H |
|
21 #define CCAGROUPUTILS_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "MCAInviteConflictResolver.h" |
|
25 #include "TEnumsPC.h" |
|
26 |
|
27 #include <e32base.h> |
|
28 #include <badesca.h> |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class MCAViewSwitcher; |
|
32 class CCAAppUi; |
|
33 class MCAConversationMessage; |
|
34 class MCAServerContactsArrayPC; |
|
35 class MCAGroupPC; |
|
36 class MCAGroupUtilsPC; |
|
37 // CLASS DECLARATION |
|
38 |
|
39 /** |
|
40 * Group properties editing and displaying utilities |
|
41 * |
|
42 * @lib chatng.app |
|
43 */ |
|
44 class CCAGroupUtils : public CBase, |
|
45 public MCAInviteConflictResolver |
|
46 { |
|
47 public: // constructor |
|
48 |
|
49 /** |
|
50 * Static constructor. |
|
51 * @param aEngine Handle to application engine |
|
52 * @param aViewSwitcher General interface for switching chat-client views |
|
53 * @return Instance of this class |
|
54 */ |
|
55 static CCAGroupUtils* NewLC( MCAViewSwitcher& aViewSwitcher ); |
|
56 |
|
57 /** |
|
58 * Destructor |
|
59 */ |
|
60 ~CCAGroupUtils(); |
|
61 |
|
62 public: |
|
63 |
|
64 // simple group generation ("SGC") FSM states |
|
65 enum TSGCState |
|
66 { |
|
67 ESGCInviteContacts = 0, // choose contacts to invite (Begin state) |
|
68 ESGCGroupName, // select group name |
|
69 ESGCInviteMessage, // invite message query |
|
70 ESGCScreenName, // screenname query or alias usage |
|
71 ESGCCreateGroup, // create the group |
|
72 ESGCDoSendInvite, // send the invitations, if any |
|
73 ESGCDoJoin, // actually join the group |
|
74 ESGCError, // error state |
|
75 ESGCQueryCancel, // ask for cancelling |
|
76 ESGCNone // no state |
|
77 }; |
|
78 |
|
79 // Chat group join mode |
|
80 enum TJoinMode |
|
81 { |
|
82 EStoredId = 0, // Group id received from some store |
|
83 EManualId // Group id entered manually by user |
|
84 }; |
|
85 |
|
86 public: //from MCAInviteConflictResolver |
|
87 |
|
88 /** |
|
89 * @see MCAInviteConflictResolver for details |
|
90 */ |
|
91 void ResolveInviteConflictL( const TDesC& aGroup, |
|
92 CDesCArray& aArray ); |
|
93 |
|
94 public: // new methods |
|
95 |
|
96 /** |
|
97 * This method checks if user is admin of the group |
|
98 * @param aGroupId: id of the group whose admin status has to be checked |
|
99 * @return ETrue if favourite else EFalse |
|
100 */ |
|
101 TBool IsAdmin( const TDesC& aGroupId ) const; |
|
102 |
|
103 /** |
|
104 * Get the User Ids of participants of the group (joined users) |
|
105 * Makes copies of the descriptors. |
|
106 * @param aParticipantList - list of all the participants in a group |
|
107 * @param aGroupID - groupid for which participantlist is required |
|
108 */ |
|
109 void GetParticipantsL( CDesCArray& aParticipantList, |
|
110 const TDesC& aGroupID ) const ; |
|
111 |
|
112 /** |
|
113 * Leave the given group. |
|
114 * @param aGroupId The group to leave |
|
115 * @return IMPS error code from LeaveL |
|
116 */ |
|
117 TInt LeaveGroupL( const TDesC& aGroupId ); |
|
118 |
|
119 /** |
|
120 * This method displays pop-up list containing joined members |
|
121 * @param aGroupId The group whose members have to be displayed |
|
122 */ |
|
123 void DisplayJoinedMembersL( const TDesC& aGroupId ); |
|
124 |
|
125 /** |
|
126 * Delete the given group |
|
127 * @param aGroupId The group id of the group to delete |
|
128 * @return The errorcode |
|
129 */ |
|
130 TInt DeleteGroupL( const TDesC& aGroupId ); |
|
131 |
|
132 /** |
|
133 * Find the group name of group with given group id |
|
134 * @Param aGroupId: group id |
|
135 * @return : name of the group |
|
136 */ |
|
137 TPtrC GetGroupName( const TDesC& aGroupId ) const; |
|
138 |
|
139 /** |
|
140 * Find a group from the store |
|
141 * @param aGroupId the ID of the group to find |
|
142 * @return true if group has been found else return false |
|
143 */ |
|
144 TBool FindGroup( const TDesC& aGroupId ) const; |
|
145 |
|
146 /** |
|
147 * Saves the focused general chat group as favourite |
|
148 * @param aGroupId: id of the group which has to be saved |
|
149 */ |
|
150 void SaveAsFavouriteL( const TDesC& aGroupId ); |
|
151 |
|
152 /** |
|
153 * This method checks if group is favourite |
|
154 * @param aGroupId: id of the group whose favorite status has to be checked |
|
155 * @return ETrue if favourite else EFalse |
|
156 */ |
|
157 TBool IsFavouriteChatGroup( const TDesC& aGroupId ); |
|
158 |
|
159 /** |
|
160 * This method checks if the user has joined to the group |
|
161 * @param aGroupId: id of the group whose joined status has to be checked |
|
162 * @return ETrue if joined else EFalse |
|
163 */ |
|
164 TBool IsJoinedToGroup( const TDesC& aGroupId ); |
|
165 |
|
166 /** |
|
167 * This method checks if group owned(created) by the user |
|
168 * @param aGroupId: id of the group whose owner status has to be checked |
|
169 * @return ETrue if owned else EFalse |
|
170 */ |
|
171 TBool IsOwnGroup( const TDesC& aGroupId ) const; |
|
172 |
|
173 /** |
|
174 * Launch chat group properties editor |
|
175 * @param aGroupId GroupID for target group |
|
176 */ |
|
177 TInt EditChatGroupPropertiesL( const TDesC& aGroupId ); |
|
178 |
|
179 /** |
|
180 * Launch chat group properties editor and create new chat |
|
181 * @param aResourceId Resource id for title text |
|
182 * @param aViewId ViewId of current view |
|
183 * @param aContactListID - invitation should be sent to all |
|
184 * online contacts of this list. aContactListID should be null |
|
185 * if focus was not on a contact list in singlelist view |
|
186 * @return WVID of newly created group or NULL if not successful |
|
187 * The ownership is passed to calling function! |
|
188 */ |
|
189 HBufC* CreateNewChatL( TInt aResourceId, const TUid aViewId, |
|
190 TBool aContactFound, |
|
191 TEnumsPC::TListSelectionType aSelType = TEnumsPC::EMultiSelect, |
|
192 TInt aSelectedListIndex = 0 ); |
|
193 |
|
194 /** |
|
195 * Joins the specified chat group and switches the view |
|
196 * @param aGroupId GroupID |
|
197 * @param aScreenName Default screenname for query |
|
198 * @param aFwdMessage Forwarded message. |
|
199 * @param aJoinMode Is group id entered manually by user |
|
200 * or received from some storage. |
|
201 * @return Return value of real join-request |
|
202 */ |
|
203 TInt JoinGroupL( const TBool aFromFwd, |
|
204 const TDesC& aGroupId, |
|
205 const TDesC& aScreenName = KNullDesC, |
|
206 const MCAConversationMessage* aFwdMessage = NULL, |
|
207 TJoinMode aJoinMode = EStoredId ); |
|
208 |
|
209 /** |
|
210 * Switches to joined group |
|
211 * @param aGroupID GroupID |
|
212 * @param aFwdMessage forwarded message |
|
213 * @param aInviteQuery If ETrue, launch the invite query |
|
214 */ |
|
215 void SwitchToJoinedGroupL( const TBool aFromFwd, |
|
216 const TDesC& aGroupID, |
|
217 const MCAConversationMessage* aFwdMessage = NULL, |
|
218 TBool aInviteQuery = EFalse ); |
|
219 |
|
220 /** |
|
221 * Displays a delete query of user created chat rooms |
|
222 */ |
|
223 TInt DisplayCreatedChatRoomsListL(); |
|
224 |
|
225 /** |
|
226 * Displays chat room info dialog |
|
227 * @param aGroupId GroupID |
|
228 */ |
|
229 void DisplayChatInfoL( const TDesC& aGroupId ); |
|
230 |
|
231 /** |
|
232 * Do the asynchronous joining process via CAsyncCallBack. |
|
233 * Uses iErr, iAsync* variables. |
|
234 */ |
|
235 TInt DoAsyncJoin(); |
|
236 |
|
237 /** |
|
238 * Helper method for querying the screen name or alias. |
|
239 * Uses variation to determine the default value. |
|
240 * @param aScreenName Pointer to the screen name buffer |
|
241 */ |
|
242 TInt ScreenNameQueryL( TDes& aScreenName ); |
|
243 |
|
244 /** |
|
245 * Helper method for switching back to the view again |
|
246 * @param aGroupID |
|
247 * @param aPrevView View where to switch when pressing back |
|
248 * @param aNextView View which is switched to next |
|
249 */ |
|
250 void PrepareToSwitchBackL( const TDesC& aGroupID, |
|
251 TUid aPrevView, |
|
252 TUid aNextView ); |
|
253 TPtrC GetJoinGroupID(); |
|
254 |
|
255 private: // new methods |
|
256 |
|
257 /** |
|
258 * Helper Asks screen name |
|
259 * @param aScreenName Reference to a descriptor where |
|
260 * screen name will be stored. |
|
261 * @return EAknSoftkey enumeration |
|
262 */ |
|
263 TInt AskScreenNameL( TDes& aScreenName ); |
|
264 |
|
265 /** |
|
266 * Launch chat group properties editor and create new chat, |
|
267 * the normal style (with access and editor lists, etc.) |
|
268 * @param aResourceId Resource id for title text |
|
269 * @param aViewId ViewId of current view |
|
270 * @return WVID of newly created group or NULL if not successful |
|
271 * The ownership is passed to calling function! |
|
272 */ |
|
273 HBufC* CreateNewChatNormalL( TInt aResourceId, const TUid aViewId ); |
|
274 |
|
275 /** |
|
276 * Launch chat group properties editor and create new chat, |
|
277 * simplified version. |
|
278 * @param aResourceId Resource id for title text |
|
279 * @param aViewId ViewId of current view |
|
280 * @param aContactListID listid for which the list of online contacts is required |
|
281 * for sending invitations |
|
282 * @return WVID of newly created group or NULL if not successful |
|
283 * The ownership is passed to calling function! |
|
284 */ |
|
285 HBufC* CreateNewChatSimpleL( TInt aResourceId, const TUid aViewId, |
|
286 TBool aContactFound, |
|
287 TEnumsPC::TListSelectionType aSelType, |
|
288 /*MCAServerContactsArrayPC* aOnlineContacts = NULL*/ |
|
289 TInt aSelectedListIndex = 0 ); |
|
290 |
|
291 /** |
|
292 * FSM state change logic wrapper. |
|
293 * @param aAknResult The result from user query (Avkon enum), |
|
294 * to handle Cancels |
|
295 * @param aErrorCode The network error code from previous operation, if |
|
296 * any. Use KErrNone to force skipping of error state transition. |
|
297 * @param aNewState The new state to change to when successful |
|
298 */ |
|
299 void StateChange( TInt aAknResult, TInt aErrorCode, |
|
300 TSGCState aNewState ); |
|
301 |
|
302 private: // constructors and destructors |
|
303 |
|
304 /** |
|
305 * constructor |
|
306 */ |
|
307 void ConstructL(); |
|
308 |
|
309 /** |
|
310 * Default constructor |
|
311 * @param aEngine Handle to engine |
|
312 * @param aViewSwitcher Handle to view switcher |
|
313 */ |
|
314 CCAGroupUtils( MCAViewSwitcher& aViewSwitcher ); |
|
315 |
|
316 private: // Data |
|
317 |
|
318 // Doesn't own. Handle to appui |
|
319 CCAAppUi* iAppUi; |
|
320 |
|
321 // Handle to view switcher |
|
322 MCAViewSwitcher& iViewSwitcher; |
|
323 |
|
324 // Owns. Used temporarily in CreateNewChatL. |
|
325 HBufC* iGroupId; |
|
326 HBufC* iJoinGroupId; |
|
327 // error for asynchronous group joining |
|
328 TInt iErr; |
|
329 |
|
330 // leave error for asynchronous group joining |
|
331 TInt iAsyncLeave; |
|
332 |
|
333 // parameters used with asynchronous group joining: group id and group name |
|
334 HBufC* iAsyncGroupId; |
|
335 HBufC* iAsyncScreenName; |
|
336 |
|
337 // Not owned. ref to forwarded message. |
|
338 const MCAConversationMessage* iAsyncFwdMessage; |
|
339 |
|
340 // Members are required for asynchronous call call backs |
|
341 CAsyncCallBack* iAsyncCb; |
|
342 CActiveSchedulerWait iWait; |
|
343 |
|
344 // simplified group creation FSM stuff |
|
345 TSGCState iCurrState; // current state for FSM |
|
346 TSGCState iPrevState; // previous state for FSM |
|
347 TInt iNwError; // error from network |
|
348 |
|
349 // Screen name |
|
350 TPtr iScreenNamePtr; |
|
351 |
|
352 //Doesnt own. Pointer to group process component. |
|
353 MCAGroupPC* iGroupPC; |
|
354 |
|
355 //Doesnt Own. Pointer to group utils process component |
|
356 MCAGroupUtilsPC* iGroupUtilsPC; |
|
357 }; |
|
358 |
|
359 #endif // CCAGROUPUTILS_H |
|
360 |
|
361 // End of File |