|
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 //INCLUDES |
|
20 |
|
21 #include "PublicEngineDefinitions.h" |
|
22 #include "CCAEngine.h" |
|
23 #include "CCAGroupUtilsPC.h" |
|
24 #include "ChatDebugPrint.h" |
|
25 #include "MCAGroupManagerInterface.h" |
|
26 #include "MCAGroupOperations.h" |
|
27 #include "MCAStoredGroups.h" |
|
28 #include "MCAExtendedStoredGroup.h" |
|
29 #include "CCAStorageManagerFactory.h" |
|
30 #include "CCAGroupPropertiesDialog.h" |
|
31 #include "ImpsCSPAllErrors.h" |
|
32 #include "MCASettings.h" |
|
33 #include "StringLoader.h" |
|
34 #include "CCAChatInfoArray.h" |
|
35 #include "CAArrayUtils.h" |
|
36 #include "IMUtils.h" |
|
37 #include "MCAInvite.h" |
|
38 #include "CAUtils.h" |
|
39 #include "MCAStoredContacts.h" |
|
40 #include "CCAStorageManagerFactory.h" |
|
41 #include "MCAConversationMessage.h" |
|
42 #include "MCAProcessManager.h" |
|
43 #include "CCAProcessManagerFactory.h" |
|
44 #include "CCAGroupPropertiesPC.h" |
|
45 #include "MCAChatInterface.h" |
|
46 |
|
47 |
|
48 #include <chatNG.rsg> |
|
49 #include <chatNG.mbg> |
|
50 #include <impsgroupprops.h> |
|
51 #include <aknnotewrappers.h> |
|
52 #include <aknlists.h> |
|
53 #include <bautils.h> |
|
54 #include "CCAPCUtils.h" |
|
55 #include "CCAUINGUtils.h" |
|
56 #include "ccagrouputilspc.h" |
|
57 #include <e32cmn.h> |
|
58 |
|
59 // The Settings have been moved to Cenrep (also retained in the Resource file), |
|
60 // so the enums for keys and central repository header is added here |
|
61 #include "VariantKeys.h" |
|
62 #include <CAVariationNG.rsg> |
|
63 |
|
64 const TInt KGranularity = 2; |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CCAGroupUtilsPC::CCAGroupUtilsPC |
|
68 // C++ default constructor can NOT contain any code, that |
|
69 // might leave. |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CCAGroupUtilsPC::CCAGroupUtilsPC( CCAEngine& aEngine ) |
|
73 : iEngine( aEngine ) |
|
74 |
|
75 |
|
76 { |
|
77 |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CCAGroupUtilsPC::NewLC |
|
82 // Two-phased constructor. |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 CCAGroupUtilsPC* CCAGroupUtilsPC::NewLC( CCAEngine& aEngine ) |
|
86 { |
|
87 CCAGroupUtilsPC* temp = new( ELeave )CCAGroupUtilsPC( aEngine ); |
|
88 CleanupStack::PushL( temp ); |
|
89 temp->ConstructL(); |
|
90 return temp; |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CCAGroupUtilsPC::NewL |
|
95 // Two-phased constructor. |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 CCAGroupUtilsPC* CCAGroupUtilsPC::NewL( CCAEngine& aEngine ) |
|
99 { |
|
100 CCAGroupUtilsPC* self = CCAGroupUtilsPC::NewLC( aEngine ); |
|
101 CleanupStack::Pop(); |
|
102 return self; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CCAGroupUtilsPC: ConstructL |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 void CCAGroupUtilsPC::ConstructL( ) |
|
110 { |
|
111 iStoredGroups = CCAStorageManagerFactory::GroupListInterfaceL(); |
|
112 iGroupManagerInterface = iEngine.GetGroupInterface(); |
|
113 } |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CCAGroupUtilsPC::~CCAGroupUtilsPC |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 CCAGroupUtilsPC::~ CCAGroupUtilsPC( ) |
|
119 { |
|
120 |
|
121 } |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CCAGroupUtilsPC::GetChatInfoArrayLC |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 CCAChatInfoArray* CCAGroupUtilsPC::GetChatInfoArrayL( const TDesC& aGroupId ) |
|
127 { |
|
128 |
|
129 // create listbox item array |
|
130 CCAChatInfoArray* itemArray = CCAChatInfoArray::NewL(); |
|
131 CleanupStack::PushL( itemArray ); |
|
132 |
|
133 //get the group |
|
134 MCAStoredGroup* group = iStoredGroups->FindGroup( aGroupId ); |
|
135 if ( !group ) |
|
136 { |
|
137 CleanupStack::PopAndDestroy(); //itemArray |
|
138 return NULL;// leave from here |
|
139 } |
|
140 |
|
141 |
|
142 CDesCArray* userList = new ( ELeave ) CDesCArrayFlat( KArrayGranularity ); |
|
143 CleanupStack::PushL( userList ); |
|
144 CDesCArray* screenNames = new ( ELeave ) CDesCArrayFlat( KArrayGranularity ); |
|
145 CleanupStack::PushL( screenNames ); |
|
146 CDesCArray* moders = new ( ELeave ) CDesCArrayFlat( KArrayGranularity ); |
|
147 CleanupStack::PushL( moders ); |
|
148 CDesCArray* admins = new ( ELeave ) CDesCArrayFlat( KArrayGranularity ); |
|
149 CleanupStack::PushL( admins ); |
|
150 |
|
151 //Getting group properties and members |
|
152 MCAGroupOperations* grOps = |
|
153 iGroupManagerInterface->GroupOperationsL( aGroupId ); |
|
154 CImpsCommonGroupProps* groupProps = NULL; |
|
155 CImpsPrivateGroupProps* privateProps = NULL; |
|
156 |
|
157 TInt err( grOps->GetPropertiesL( groupProps, privateProps ) ); |
|
158 if ( err == KErrNone && group->IsAdmin() ) |
|
159 { |
|
160 err = grOps->GetMembersL( *userList, *screenNames, *moders, *admins ); |
|
161 } |
|
162 |
|
163 if ( err != KErrNone ) |
|
164 { |
|
165 if ( err == ECSPInsufficientGroupPrivileges ) |
|
166 { |
|
167 // Show general server error note, if user has |
|
168 // insufficient privileges. |
|
169 err = ECSPInternalOrNetworkError; |
|
170 } |
|
171 CleanupStack::PopAndDestroy( 4, userList ); |
|
172 CleanupStack::PopAndDestroy(); //itemArray |
|
173 |
|
174 User::Leave( err ); |
|
175 |
|
176 return NULL; |
|
177 |
|
178 } |
|
179 |
|
180 CHAT_DP( D_CHAT_LIT( " %d users, %d screenNames, %d moders, %d admins" ), |
|
181 userList->Count(), screenNames->Count(), moders->Count(), |
|
182 admins->Count() ); |
|
183 |
|
184 |
|
185 |
|
186 // load participants text with correct numbers (two items in partiarray) |
|
187 CArrayFixFlat<TInt>* partiArray = new ( ELeave ) CArrayFixFlat<TInt>( KGranularity ); |
|
188 CleanupStack::PushL( partiArray ); |
|
189 partiArray->AppendL( group->NumParticipants() ); |
|
190 partiArray->AppendL( groupProps->MaxNbrOfUsers() ); |
|
191 HBufC* partiBuf = StringLoader::LoadLC( R_CHATLIST_VIEW_INFO_NUMB_PARTI, |
|
192 *partiArray ); |
|
193 |
|
194 // add items to item array |
|
195 TPtrC displayId( CCAPCUtils::DisplayId( aGroupId ) ); |
|
196 itemArray->AddLabelAndTextL( R_CHATLIST_VIEW_INFO_GID, displayId ); |
|
197 |
|
198 itemArray->AddLabelAndTextL( R_CHATLIST_VIEW_INFO_TOP, |
|
199 groupProps->Topic() ); |
|
200 |
|
201 itemArray->AddLabelAndTextL( R_CHATLIST_VIEW_INFO_NUMB, *partiBuf ); |
|
202 CleanupStack::PopAndDestroy( partiBuf ); |
|
203 CleanupStack::PopAndDestroy( partiArray ); |
|
204 |
|
205 // add admins |
|
206 HBufC* adminBuf = CCAPCUtils::CreateBufLC( *admins, ETrue ); |
|
207 itemArray->AddLabelAndTextL( R_CHATLIST_VIEW_INFO_ADMIN, *adminBuf ); |
|
208 CleanupStack::PopAndDestroy( adminBuf ); |
|
209 |
|
210 // add banned users |
|
211 if ( group->IsAdmin() || group->IsOwnGroup() ) |
|
212 { |
|
213 CHAT_DP_TXT( "displaying reject list" ); |
|
214 CDesCArray* rejectList = new ( ELeave ) CDesCArrayFlat( |
|
215 KArrayGranularity ); |
|
216 CleanupStack::PushL( rejectList ); |
|
217 |
|
218 err = grOps->GetRejectListL( *rejectList ); |
|
219 if ( err == KErrNone ) |
|
220 { |
|
221 HBufC* banBuf = CCAPCUtils::CreateBufLC( *rejectList, ETrue ); |
|
222 itemArray->AddLabelAndTextL( R_CHATLIST_VIEW_INFO_BANNED, *banBuf ); |
|
223 CleanupStack::PopAndDestroy( banBuf ); |
|
224 } |
|
225 |
|
226 CleanupStack::PopAndDestroy( rejectList ); |
|
227 } |
|
228 |
|
229 // load the whisper text |
|
230 HBufC* whispBuf = NULL; |
|
231 if ( groupProps->IsPrivateAllowed() == EImpsPropYes ) |
|
232 { |
|
233 whispBuf = CCoeEnv::Static()-> |
|
234 AllocReadResourceLC( R_CHATLIST_VIEW_INFO_WHIS_YES ); |
|
235 } |
|
236 else |
|
237 { |
|
238 whispBuf = CCoeEnv::Static()-> |
|
239 AllocReadResourceLC( R_CHATLIST_VIEW_INFO_WHIS_NO ); |
|
240 } |
|
241 |
|
242 // append to listbox |
|
243 itemArray->AddLabelAndTextL( R_CHATLIST_VIEW_INFO_WHIS, *whispBuf ); |
|
244 |
|
245 CleanupStack::PopAndDestroy( 5, userList ); // admins, moders, |
|
246 // screenNames, userList,whispBuf |
|
247 |
|
248 CleanupStack::Pop( itemArray ); |
|
249 return itemArray; |
|
250 } |
|
251 |
|
252 // ----------------------------------------------------------------------------- |
|
253 // CCAGroupUtilsPC::GetCreatedChatRoomListL |
|
254 // ----------------------------------------------------------------------------- |
|
255 // |
|
256 TInt CCAGroupUtilsPC::GetCreatedChatRoomListL( CDesCArray& aTempArray, CDesCArray& aGroupIds ) |
|
257 { |
|
258 TInt err = KErrNone; |
|
259 |
|
260 iGroupManagerInterface->PopulateCreatedGroupsL( aGroupIds ); |
|
261 |
|
262 |
|
263 HBufC* itemText = HBufC::NewLC( KMaxChatGroupLenght + KMaxTabLength ); |
|
264 TPtr itemTextPtr( itemText->Des() ); |
|
265 TInt count( aGroupIds.MdcaCount() ); |
|
266 for ( TInt i( 0 ); i < count; i++ ) |
|
267 { |
|
268 itemTextPtr.Append( KIconTabulator ); |
|
269 itemTextPtr.Append( |
|
270 CCAStorageManagerFactory::ContactListInterfaceL()->Identification( |
|
271 aGroupIds.MdcaPoint( i ) ) ); |
|
272 aTempArray.AppendL( *itemText ); |
|
273 itemTextPtr.Zero(); |
|
274 } |
|
275 CleanupStack::PopAndDestroy( itemText ); |
|
276 return err; |
|
277 } |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // CCAGroupUtilsPC::DeleteChatGroupFromNetworkL |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 TInt CCAGroupUtilsPC::DeleteChatGroupFromNetworkL( const TDesC& aGroupId, TBool aDeleteFromNetwork ) |
|
284 { |
|
285 MCAStoredGroups* groups = |
|
286 CCAStorageManagerFactory::GroupListInterfaceL(); |
|
287 MCAStoredGroup* group = groups->FindGroup( aGroupId ); |
|
288 if ( !group ) |
|
289 { |
|
290 // Because the groups that user selected are fetched from |
|
291 // network, and though they might not be in our local storage, |
|
292 // we need to create those groups to make sure that storage |
|
293 // does also network operations. |
|
294 group = groups->CreateGroupL(); |
|
295 static_cast<MCAExtendedStoredGroup*>( group )->SetVisible( |
|
296 EFalse ); |
|
297 static_cast<MCAExtendedStoredGroup*>( group )->SetGroupIdL( |
|
298 aGroupId ); |
|
299 } |
|
300 return iGroupManagerInterface->DeleteGroupL( aGroupId, aDeleteFromNetwork ); |
|
301 } |
|
302 |
|
303 // ----------------------------------------------------------------------------- |
|
304 // CCAGroupUtilsPC::DeleteGroupL |
|
305 // ----------------------------------------------------------------------------- |
|
306 // |
|
307 TInt CCAGroupUtilsPC::DeleteGroupL( const TDesC& aGroupId, |
|
308 TBool aDeleteFromNetwork ) |
|
309 { |
|
310 return iGroupManagerInterface->DeleteGroupL( aGroupId, |
|
311 aDeleteFromNetwork ); |
|
312 } |
|
313 |
|
314 // ----------------------------------------------------------------------------- |
|
315 // CCAGroupUtilsPC::SwitchToJoinedGroupL |
|
316 // ----------------------------------------------------------------------------- |
|
317 // |
|
318 TInt CCAGroupUtilsPC::SwitchToJoinedGroupL( const TDesC& aGroupID, |
|
319 TCADnlChatViewBuf& aViewDnl , |
|
320 const MCAConversationMessage* aFwdMessage, |
|
321 TBool aInviteQuery ) |
|
322 |
|
323 { |
|
324 |
|
325 if ( !iEngine.ChatInterface().ChatExistsL( KNullDesC, KNullDesC, aGroupID ) ) |
|
326 { |
|
327 return R_CHATLIST_VIEW_JOIN_ERROR; |
|
328 } |
|
329 |
|
330 TCADnlChatView viewDnl; |
|
331 if ( aFwdMessage ) |
|
332 { |
|
333 viewDnl.iIsForwarded = ETrue; |
|
334 viewDnl.iForwardedMessage = aFwdMessage; |
|
335 } |
|
336 else |
|
337 { |
|
338 viewDnl.iIsForwarded = EFalse; |
|
339 } |
|
340 |
|
341 viewDnl.iInviteQuery = aInviteQuery; |
|
342 viewDnl.iSwitchTab = EFalse; |
|
343 |
|
344 MCAStoredGroup* group = CCAStorageManagerFactory:: |
|
345 GroupListInterfaceL()->FindGroup( aGroupID ); |
|
346 viewDnl.iGroupId = aGroupID.Left( viewDnl.iGroupId.MaxLength() ); |
|
347 viewDnl.iGroupName = |
|
348 group->GroupName().Left( viewDnl.iGroupName.MaxLength() ); |
|
349 |
|
350 aViewDnl = viewDnl; |
|
351 |
|
352 return KErrNone; |
|
353 |
|
354 } |
|
355 |
|
356 // ----------------------------------------------------------------------------- |
|
357 // CCAGroupUtilsPC::GetDefaultGroupNameL |
|
358 // (other items were commented in a header). |
|
359 // ----------------------------------------------------------------------------- |
|
360 |
|
361 void CCAGroupUtilsPC::GetDefaultGroupNameL( TPtr& aChatGroupName, |
|
362 TEnumsPC::TListSelectionType aSelType ) |
|
363 { |
|
364 // Construct default group name for query |
|
365 |
|
366 switch ( aSelType ) |
|
367 { |
|
368 case TEnumsPC::ESingleListMultiSelect: |
|
369 { |
|
370 HBufC* listGroupName = StringLoader::LoadLC( |
|
371 RSC_CHAT_GROUP_DEFAULT_LIST, |
|
372 aChatGroupName |
|
373 ); |
|
374 aChatGroupName.Copy( listGroupName->Left( KMaxChatGroupLenght ) ); |
|
375 |
|
376 CleanupStack::PopAndDestroy( listGroupName ); |
|
377 break; |
|
378 } |
|
379 default: |
|
380 { |
|
381 TInt nbrOfChats = iGroupManagerInterface-> |
|
382 NumberOfCreatedGroupsDuringSession(); |
|
383 MCAStoredContacts* contactlist = |
|
384 CCAStorageManagerFactory::ContactListInterfaceL(); |
|
385 |
|
386 TPtrC ownId = contactlist->OwnStatus().Identification(); |
|
387 HBufC* groupName = StringLoader::LoadLC( RSC_CHAT_GROUP_DEFAULT, |
|
388 ownId, |
|
389 nbrOfChats + 1 ); |
|
390 aChatGroupName.Copy( groupName->Left( KMaxChatGroupLenght ) ); |
|
391 |
|
392 // convert numbers to local language. |
|
393 // Exclude indentification part of text. |
|
394 TInt pos = aChatGroupName.Find( ownId ); |
|
395 if ( pos != KErrNotFound ) |
|
396 { |
|
397 TInt end = pos + ownId.Length(); |
|
398 |
|
399 // after id part |
|
400 if ( end < aChatGroupName.Length() ) |
|
401 { |
|
402 TPtr nonIdPart = aChatGroupName.MidTPtr( end ); |
|
403 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( |
|
404 nonIdPart ); |
|
405 } |
|
406 |
|
407 // before id part |
|
408 if ( pos > 0 ) |
|
409 { |
|
410 TPtr nonIdPart = aChatGroupName.LeftTPtr( pos ); |
|
411 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( |
|
412 nonIdPart ); |
|
413 } |
|
414 } |
|
415 |
|
416 CleanupStack::PopAndDestroy( groupName ); |
|
417 break; |
|
418 } |
|
419 |
|
420 } |
|
421 |
|
422 } |
|
423 |
|
424 |
|
425 // ----------------------------------------------------------------------------- |
|
426 // CCAGroupUtilsPC::ScreenNameQueryL |
|
427 // (other items were commented in a header). |
|
428 // ----------------------------------------------------------------------------- |
|
429 |
|
430 void CCAGroupUtilsPC::ScreenNameQueryL( TDes& aScreenName ) |
|
431 { |
|
432 TInt askScreenName = IMUtils::IntResourceValueL( |
|
433 RSC_CHAT_VARIATION_SCREENNAME_QUERY ); |
|
434 TInt screenNameStrategy = IMUtils::IntResourceValueL( |
|
435 RSC_CHAT_VARIATION_SCREENNAME_DEFAULT ); |
|
436 TInt snSettings = IMUtils::IntResourceValueL( |
|
437 RSC_CHAT_VARIATION_SCREENNAME_SETTING ); |
|
438 TBool isSnSet = iEngine.GetInternalSettingsInterface()->Value( |
|
439 MCASettings::EDefaultScreenNameInUse ); |
|
440 TInt aliasEnabled = IMUtils::IntResourceValueL( |
|
441 RSC_CHAT_VARIATION_HAVE_ALIAS ); |
|
442 |
|
443 TInt snMaxLen = aScreenName.MaxLength(); |
|
444 TInt copyLen = snMaxLen < KScreenNameQueryMaxLength ? |
|
445 snMaxLen : KScreenNameQueryMaxLength; |
|
446 |
|
447 switch ( screenNameStrategy ) |
|
448 { |
|
449 case 0 : |
|
450 { |
|
451 // use empty screen name |
|
452 aScreenName.Copy( KNullDesC() ); |
|
453 break; |
|
454 } |
|
455 |
|
456 case 1 : |
|
457 { |
|
458 // userid, overwrite screen name buffer with userid |
|
459 HBufC* ownWVIDbuf = iEngine.GetInternalSettingsInterface()-> |
|
460 ValueL( MCASettings::EOwnWVUserID ); |
|
461 CleanupStack::PushL( ownWVIDbuf ); |
|
462 // make sure it can fit |
|
463 TPtrC displayId( CCAPCUtils::DisplayId( *ownWVIDbuf ) ); |
|
464 aScreenName.Copy( displayId.Left( copyLen ) ); |
|
465 CleanupStack::PopAndDestroy( ownWVIDbuf ); |
|
466 |
|
467 break; |
|
468 } |
|
469 |
|
470 case 2 : |
|
471 { |
|
472 // screen name, default behaviour |
|
473 if ( snSettings && isSnSet ) |
|
474 { |
|
475 HBufC* sn = iEngine.GetInternalSettingsInterface()->ValueL( |
|
476 MCASettings::EDefaultScreenName ); |
|
477 if ( sn->Length() > 0 ) |
|
478 { |
|
479 aScreenName.Copy( sn->Left( copyLen ) ); |
|
480 } |
|
481 delete sn; |
|
482 } |
|
483 |
|
484 break; |
|
485 } |
|
486 |
|
487 case 3 : |
|
488 { |
|
489 // alias |
|
490 if ( aliasEnabled ) |
|
491 { |
|
492 HBufC* alias = iEngine.GetInternalSettingsInterface()->OwnAliasL(); |
|
493 if ( alias && alias->Length() > 0 ) |
|
494 { |
|
495 aScreenName.Copy( alias->Left( copyLen ) ); |
|
496 } |
|
497 else |
|
498 { |
|
499 // If alias is not defined, we need to query screenname. |
|
500 askScreenName = ETrue; |
|
501 } |
|
502 delete alias; |
|
503 } |
|
504 |
|
505 break; |
|
506 } |
|
507 |
|
508 default : |
|
509 { |
|
510 break; |
|
511 } |
|
512 } |
|
513 } |
|
514 |
|
515 // pcside_complete |
|
516 // ----------------------------------------------------------------------------- |
|
517 // CCAGroupUtilsPC::MoveOwnIdToFirstL |
|
518 // (other items were commented in a header). |
|
519 // ----------------------------------------------------------------------------- |
|
520 // |
|
521 void CCAGroupUtilsPC::MoveOwnIdToFirstL( CDesCArray& aList ) |
|
522 { |
|
523 // find the own wvid from list and move it to the beginning |
|
524 HBufC* ownWVIDbuf = iEngine.GetInternalSettingsInterface()-> |
|
525 ValueL( MCASettings::EOwnWVUserID ); |
|
526 CleanupStack::PushL( ownWVIDbuf ); |
|
527 TInt listLen = aList.Count(); |
|
528 // must traverse list backwards |
|
529 for ( TInt i = listLen - 1; i >= 0; i-- ) |
|
530 { |
|
531 if ( 0 == CAUtils::NeutralCompare( aList.MdcaPoint( i ), *ownWVIDbuf ) ) |
|
532 { |
|
533 // found own id, delete it |
|
534 aList.Delete( i ); |
|
535 } |
|
536 } |
|
537 aList.InsertL( 0, *ownWVIDbuf ); |
|
538 CleanupStack::PopAndDestroy( ownWVIDbuf ); |
|
539 } |
|
540 |
|
541 // ----------------------------------------------------------------------------- |
|
542 // CCAGroupUtilsPC::UpdateGroupMembersL |
|
543 // (other items were commented in a header). |
|
544 // ----------------------------------------------------------------------------- |
|
545 // |
|
546 void CCAGroupUtilsPC::UpdateGroupMembersL( const TDesC& aGroupId, |
|
547 const CDesCArray& aOldAdmins, const CDesCArray& aAdmins, |
|
548 const CDesCArray& aOldUserList, const CDesCArray& aUserList, |
|
549 const CDesCArray& aOldRejected, const CDesCArray& aRejected ) |
|
550 { |
|
551 MCAGroupOperations* grOps = |
|
552 iGroupManagerInterface->GroupOperationsL( aGroupId ); |
|
553 |
|
554 if ( !grOps ) |
|
555 { |
|
556 return; |
|
557 } |
|
558 // added admins |
|
559 CHAT_DP_TXT( "**addedAdmins**" ); |
|
560 CDesCArray* addedAdmins = CAArrayUtils::CreateDiffLC( aAdmins, aOldAdmins ); |
|
561 // removed admins |
|
562 CHAT_DP_TXT( "**removedAdmins**" ); |
|
563 CDesCArray* removedAdmins = CAArrayUtils::CreateDiffLC( aOldAdmins, |
|
564 aAdmins ); |
|
565 |
|
566 // -- removed users -- |
|
567 CHAT_DP_TXT( "**removedUsers**" ); |
|
568 CDesCArray* removed = CAArrayUtils::CreateDiffLC( aOldUserList, aUserList ); |
|
569 // removed admins |
|
570 CAArrayUtils::AppendArrayL( *removedAdmins, *removed ); |
|
571 TInt err( KErrNone ); |
|
572 if ( removed->Count() > 0 ) |
|
573 { |
|
574 CHAT_DP_FUNC_DP( "EditChatGroupPropertiesL", "..removed users.." ); |
|
575 err = grOps->RemoveMembersL( *removed ); |
|
576 if ( err != KErrNone ) |
|
577 { |
|
578 CleanupStack::PopAndDestroy( 3, addedAdmins ); |
|
579 User::Leave( err );// leaves on errors |
|
580 } |
|
581 } |
|
582 CleanupStack::PopAndDestroy( removed ); |
|
583 |
|
584 // -- added users -- |
|
585 CHAT_DP_TXT( "**addedUsers**" ); |
|
586 CDesCArray* added = CAArrayUtils::CreateDiffLC( aUserList, aOldUserList ); |
|
587 CDesCArray* empty = new( ELeave )CDesCArrayFlat( 1 ); |
|
588 CleanupStack::PushL( empty ); |
|
589 // admins must be added first as ordinary users |
|
590 CDesCArray* addedUsers = CAArrayUtils::CloneArrayLC( *added ); |
|
591 CAArrayUtils::AppendArrayL( *addedAdmins, *addedUsers ); |
|
592 if ( addedUsers->Count() > 0 ) |
|
593 { |
|
594 CHAT_DP_FUNC_DP( "EditChatGroupPropertiesL", "..added users.." ); |
|
595 err = grOps->AddMembersL( *addedUsers, *empty ); |
|
596 if ( err != KErrNone ) |
|
597 { |
|
598 CleanupStack::PopAndDestroy( 5, addedAdmins ); |
|
599 User::Leave( err );// leaves on errors |
|
600 } |
|
601 } |
|
602 CleanupStack::PopAndDestroy( addedUsers ); |
|
603 CleanupStack::PopAndDestroy( empty ); |
|
604 |
|
605 // -- modify the rights for new admins -- |
|
606 if ( addedAdmins->Count() > 0 ) |
|
607 { |
|
608 CHAT_DP_FUNC_DP( "EditChatGroupPropertiesL", "..added admins.." ); |
|
609 err = grOps->ModifyMembersL( addedAdmins, NULL, NULL ); |
|
610 if ( err != KErrNone ) |
|
611 { |
|
612 CleanupStack::PopAndDestroy( 3, addedAdmins ); |
|
613 User::Leave( err );// leaves on errors |
|
614 } |
|
615 |
|
616 } |
|
617 |
|
618 CleanupStack::PopAndDestroy( 3, addedAdmins ); |
|
619 |
|
620 // -- added or removed banned users -- |
|
621 CHAT_DP_TXT( "**addedRejected**" ); |
|
622 CDesCArray* addedBan = CAArrayUtils::CreateDiffLC( aRejected, |
|
623 aOldRejected ); |
|
624 CHAT_DP_TXT( "**removedRejected**" ); |
|
625 CDesCArray* removedBan = CAArrayUtils::CreateDiffLC( aOldRejected, |
|
626 aRejected ); |
|
627 if ( ( addedBan->Count() > 0 ) || ( removedBan->Count() > 0 ) ) |
|
628 { |
|
629 CHAT_DP_FUNC_DP( "EditChatGroupPropertiesL", "..added/removed ban.." ); |
|
630 err = grOps->SetRejectListL( *addedBan, *removedBan ); |
|
631 if ( err != KErrNone ) |
|
632 { |
|
633 CleanupStack::PopAndDestroy( 2, addedBan ); |
|
634 User::Leave( err );// leaves on errors |
|
635 } |
|
636 } |
|
637 |
|
638 CleanupStack::PopAndDestroy( 2, addedBan ); |
|
639 |
|
640 } |
|
641 |
|
642 // ----------------------------------------------------------------------------- |
|
643 // CCAGroupUtilsPC::AddGroupMembersL |
|
644 // (other items were commented in a header). |
|
645 // ----------------------------------------------------------------------------- |
|
646 // |
|
647 void CCAGroupUtilsPC::AddGroupMembersL( const TDesC& aGroupId, |
|
648 CDesCArray& aAdmins, |
|
649 const CDesCArray& aUserList, |
|
650 const CDesCArray& aRejected ) |
|
651 { |
|
652 MCAGroupOperations* grOps = iGroupManagerInterface-> |
|
653 GroupOperationsL( aGroupId ); |
|
654 |
|
655 if ( !grOps ) |
|
656 { |
|
657 return; |
|
658 } |
|
659 if ( aAdmins.Count() > 0 ) |
|
660 { |
|
661 // remove own wvid from list |
|
662 aAdmins.Delete( 0 ); |
|
663 aAdmins.Compress(); |
|
664 } |
|
665 |
|
666 TInt err( KErrNone ); |
|
667 CDesCArray* empty = new( ELeave )CDesCArrayFlat( 1 ); |
|
668 CleanupStack::PushL( empty ); |
|
669 CDesCArray* added = CAArrayUtils::CloneArrayLC( aUserList ); |
|
670 CAArrayUtils::AppendArrayL( aAdmins, *added ); |
|
671 if ( added->MdcaCount() > 0 ) // added users |
|
672 { |
|
673 err = grOps->AddMembersL( *added, *empty ); |
|
674 if ( err != KErrNone ) |
|
675 { |
|
676 CleanupStack::PopAndDestroy( 2, empty ); |
|
677 User::Leave( err );// leaves on errors |
|
678 } |
|
679 } |
|
680 CleanupStack::PopAndDestroy( added ); |
|
681 |
|
682 // -- modify the rights for new admins (ignore own wvid) -- |
|
683 if ( aAdmins.Count() > 0 ) |
|
684 { |
|
685 err = grOps->ModifyMembersL( &aAdmins, NULL, NULL ); |
|
686 if ( err != KErrNone ) |
|
687 { |
|
688 CleanupStack::PopAndDestroy(); //empty |
|
689 User::Leave( err );// leaves on errors |
|
690 } |
|
691 |
|
692 } |
|
693 // -- added banned users -- |
|
694 if ( aRejected.Count() > 0 ) |
|
695 { |
|
696 err = grOps->SetRejectListL( aRejected, *empty ); |
|
697 if ( err != KErrNone ) |
|
698 { |
|
699 CleanupStack::PopAndDestroy(); //empty |
|
700 User::Leave( err );// leaves on errors |
|
701 } |
|
702 |
|
703 } |
|
704 CleanupStack::PopAndDestroy(); //empty |
|
705 } |
|
706 |
|
707 // ----------------------------------------------------------------------------- |
|
708 // CCAGroupUtilsPC::GetRejectListL |
|
709 // ----------------------------------------------------------------------------- |
|
710 // |
|
711 TInt CCAGroupUtilsPC::GetRejectListL( CDesCArray& aRejectList, |
|
712 const TDesC& aGroup ) |
|
713 { |
|
714 // populate lists and get the properties |
|
715 MCAGroupOperations* grOps = iGroupManagerInterface->GroupOperationsL( aGroup ); |
|
716 return grOps->GetRejectListL( aRejectList ); |
|
717 } |
|
718 |
|
719 // ----------------------------------------------------------------------------- |
|
720 // CCAGroupUtilsPC::GetMembersL |
|
721 // ----------------------------------------------------------------------------- |
|
722 // |
|
723 TInt CCAGroupUtilsPC::GetMembersL( CDesCArray& aUserList, |
|
724 CDesCArray& aScreenNames, |
|
725 CDesCArray& aModers, |
|
726 CDesCArray& aAdmins , const TDesC& aGroup ) |
|
727 { |
|
728 MCAGroupOperations* grOps = iGroupManagerInterface->GroupOperationsL( aGroup ); |
|
729 return grOps->GetMembersL( aUserList, |
|
730 aScreenNames, |
|
731 aModers, |
|
732 aAdmins ); |
|
733 } |
|
734 |
|
735 // ----------------------------------------------------------------------------- |
|
736 // CCAGroupUtilsPC::GetIdentificationL |
|
737 // ----------------------------------------------------------------------------- |
|
738 // |
|
739 const TPtrC CCAGroupUtilsPC::GetIdentificationL( const TDesC& aContactId ) |
|
740 { |
|
741 MCAStoredContacts* contacts = |
|
742 CCAStorageManagerFactory::ContactListInterfaceL(); |
|
743 return contacts->Identification( aContactId ) ; |
|
744 } |
|
745 |
|
746 // ----------------------------------------------------------------------------- |
|
747 // CCAGroupUtilsPC::CreateGroupSimpleL |
|
748 // ----------------------------------------------------------------------------- |
|
749 // |
|
750 HBufC* CCAGroupUtilsPC::CreateGroupSimpleL( const TDesC& aScreenName, |
|
751 TBool aJoinGroup, |
|
752 TBool aIsWhisperingEnabled, TInt& aErrorCode ) |
|
753 { |
|
754 CImpsPrivateGroupProps* newPrivateProps = CImpsPrivateGroupProps::NewL(); |
|
755 CleanupStack::PushL( newPrivateProps ); |
|
756 |
|
757 MCAProcessManager* processManager |
|
758 = CCAProcessManagerFactory::InstanceL()->GetProcessManager(); |
|
759 |
|
760 CCAGroupPropertiesPC* groupPropsDialogPC |
|
761 = dynamic_cast<CCAGroupPropertiesPC*>( processManager->GetGroupPropertiesPC() ); |
|
762 |
|
763 HBufC* groupID = iGroupManagerInterface->CreateGroupL( |
|
764 groupPropsDialogPC->GetEdittedProperties(), |
|
765 newPrivateProps, |
|
766 aScreenName, |
|
767 aJoinGroup, |
|
768 aIsWhisperingEnabled, |
|
769 aErrorCode ); |
|
770 |
|
771 CleanupStack::PopAndDestroy( newPrivateProps ); |
|
772 return groupID; |
|
773 } |
|
774 |
|
775 |
|
776 // ----------------------------------------------------------------------------- |
|
777 // CCAGroupUtilsPC::CreateGroupL |
|
778 // (other items were commented in a header). |
|
779 // ----------------------------------------------------------------------------- |
|
780 // |
|
781 HBufC* CCAGroupUtilsPC::CreateGroupL( const TDesC& aScreenName, const TDesC& aGroupName, |
|
782 TInt& aError ) |
|
783 { |
|
784 // finalize chat group creation and join it, then send all the |
|
785 // invitations |
|
786 // create chat group with default properties |
|
787 CImpsCommonGroupProps* groupProps = |
|
788 CImpsCommonGroupProps::NewL(); |
|
789 CleanupStack::PushL( groupProps ); |
|
790 CImpsPrivateGroupProps* privateProps = |
|
791 CImpsPrivateGroupProps::NewL(); |
|
792 CleanupStack::PushL( privateProps ); |
|
793 |
|
794 // set properties: |
|
795 // no search, open group, no whisper, empty topic and welcome |
|
796 groupProps->SetMaxNbrOfUsers( |
|
797 IMUtils::IntResourceValueL( RSC_CHAT_VARIATION_GROUP_SIZE ) ); |
|
798 groupProps->SetSearchable( |
|
799 IMUtils::IntResourceValueL( RSC_CHAT_VARIATION_GROUP_SEARCH ) == 1 ? |
|
800 EImpsPropYes : EImpsPropNo ); |
|
801 groupProps->SetOpen( |
|
802 IMUtils::IntResourceValueL( RSC_CHAT_VARIATION_GROUP_OPEN ) == 1 ? |
|
803 EImpsPropYes : EImpsPropNo ); |
|
804 groupProps->SetPrivateAllowed( |
|
805 IMUtils::IntResourceValueL( RSC_CHAT_VARIATION_GROUP_WHISPER ) == 1 ? |
|
806 EImpsPropYes : EImpsPropNo ); |
|
807 groupProps->SetGroupNameL( aGroupName ); |
|
808 |
|
809 HBufC* topic = StringLoader::LoadLC( RSC_CRRSS_CHAT_VARIATION_START_ID + |
|
810 RSC_CHAT_VARIATION_GROUP_TOPIC ); |
|
811 HBufC* welcome = StringLoader::LoadLC( RSC_CRRSS_CHAT_VARIATION_START_ID + |
|
812 RSC_CHAT_VARIATION_GROUP_WELCOME_NOTE ); |
|
813 groupProps->SetTopicL( *topic ); |
|
814 groupProps->SetWelcomeL( *welcome ); |
|
815 CleanupStack::PopAndDestroy( 2, topic ); // welcome, topic |
|
816 |
|
817 |
|
818 // check the autodeletion variation flag |
|
819 if ( IMUtils::IntResourceValueL( RSC_CHAT_VARIATION_GROUP_AUTODELETE ) ) |
|
820 { |
|
821 groupProps->SetAutoDelete( EImpsPropYes ); |
|
822 } |
|
823 |
|
824 CleanupStack::Pop( 2, groupProps ); // privateProps, groupProps |
|
825 |
|
826 // CreateGroupL takes ownership |
|
827 TBool whisperingAllowed = |
|
828 IMUtils::IntResourceValueL( |
|
829 RSC_CHAT_VARIATION_GROUP_WHISPER ) == 1; |
|
830 return iGroupManagerInterface->CreateGroupL( groupProps, |
|
831 privateProps, |
|
832 aScreenName, |
|
833 EFalse, |
|
834 whisperingAllowed, |
|
835 aError ) ; |
|
836 } |
|
837 |
|
838 // ----------------------------------------------------------------------------- |
|
839 // CCAGroupUtilsPC::JoinGroupL |
|
840 // (other items were commented in a header). |
|
841 // ----------------------------------------------------------------------------- |
|
842 // |
|
843 TInt CCAGroupUtilsPC::JoinGroupL( const TDesC& aGroupId, |
|
844 const TDesC& aScreenName, |
|
845 TBool aUsers, TBool aIsFavourite ) |
|
846 |
|
847 { |
|
848 |
|
849 TBool whisperingAllowed = IMUtils::IntResourceValueL( |
|
850 RSC_CHAT_VARIATION_GROUP_WHISPER ) == 1; |
|
851 return iGroupManagerInterface->JoinGroupL( |
|
852 aGroupId, aScreenName, aUsers, |
|
853 aIsFavourite, whisperingAllowed ); |
|
854 } |
|
855 |
|
856 // ----------------------------------------------------------------------------- |
|
857 // CCAGroupUtilsPC::GetGroupDataL |
|
858 // (other items were commented in a header). |
|
859 // ----------------------------------------------------------------------------- |
|
860 // |
|
861 TInt CCAGroupUtilsPC::GetGroupDataL( const TDesC& aGroupId, |
|
862 CDesCArray& aUserList, CDesCArray& aScreenNames, |
|
863 CDesCArray& aModerators, CDesCArray& aAdmins, |
|
864 CDesCArray& aRejected ) |
|
865 { |
|
866 |
|
867 // populate lists and get the properties |
|
868 MCAGroupOperations* grOps = |
|
869 iGroupManagerInterface->GroupOperationsL( aGroupId ); |
|
870 |
|
871 |
|
872 |
|
873 CImpsCommonGroupProps* groupProps = NULL; |
|
874 CImpsPrivateGroupProps* privateProps = NULL; |
|
875 |
|
876 TInt errMem = grOps->GetMembersL( aUserList, aScreenNames, aModerators, aAdmins ); |
|
877 TInt errRej = grOps->GetRejectListL( aRejected ); |
|
878 TInt errProp = grOps->GetPropertiesL( groupProps, privateProps ); |
|
879 |
|
880 CHAT_DP( D_CHAT_LIT( |
|
881 "CCAGroupUtilsPC::GetGroupDataL: GetMembers(%d), GetRejectList(%d), GetProperties(%d)" ), |
|
882 errMem, errRej, errProp ); |
|
883 |
|
884 if ( errProp != KErrNone ) |
|
885 { |
|
886 return ( errProp == ECSPInsufficientGroupPrivileges ) ? |
|
887 ECSPInternalOrNetworkError : errProp; |
|
888 } |
|
889 |
|
890 // Ignore other errors |
|
891 return KErrNone; |
|
892 } |
|
893 |
|
894 // ----------------------------------------------------------------------------- |
|
895 // CCAGroupUtilsPC::ProcessEditedGroupPropertiesL |
|
896 // (other items were commented in a header). |
|
897 // ----------------------------------------------------------------------------- |
|
898 // |
|
899 TInt CCAGroupUtilsPC::ProcessEditedGroupPropertiesL( const TDesC& aGroupId, |
|
900 CDesCArray& aOldAdmins, |
|
901 CDesCArray& aNewAdmins, |
|
902 CDesCArray& aOldUsers, |
|
903 CDesCArray& aNewUsers, |
|
904 CDesCArray& aOldRejected, |
|
905 CDesCArray& aNewRejected ) |
|
906 { |
|
907 |
|
908 // In the case of an open group, we must 1. update properties, 2. update members |
|
909 // In the case of a closed group, we must 1. update members, 2. update properties |
|
910 // Otherwise we end up kicking people out in one of the cases |
|
911 // populate lists and get the properties |
|
912 MCAGroupOperations* grOps = |
|
913 iGroupManagerInterface->GroupOperationsL( aGroupId ); |
|
914 MCAProcessManager* processManager |
|
915 = CCAProcessManagerFactory::InstanceL()->GetProcessManager(); |
|
916 CCAGroupPropertiesPC* groupPropsDialogPC = dynamic_cast<CCAGroupPropertiesPC*> |
|
917 ( processManager->GetGroupPropertiesPC() ); |
|
918 TInt err( KErrNone ); |
|
919 TBool isOpen = ( groupPropsDialogPC-> |
|
920 GetEdittedProperties()->IsOpen() == TEnumsPC::EImpsPropYes ); |
|
921 |
|
922 CImpsPrivateGroupProps* newPrivateProps = CImpsPrivateGroupProps::NewL(); |
|
923 CleanupStack::PushL( newPrivateProps ); |
|
924 |
|
925 |
|
926 if ( isOpen ) |
|
927 { |
|
928 // open group |
|
929 |
|
930 // Update properties |
|
931 err = grOps->UpdatePropertiesL( |
|
932 groupPropsDialogPC->GetEdittedProperties(), |
|
933 newPrivateProps ); |
|
934 if ( err != KErrNone ) |
|
935 { |
|
936 CleanupStack::PopAndDestroy(); //newPrivateProps |
|
937 return err; |
|
938 } |
|
939 |
|
940 // Update group members |
|
941 UpdateGroupMembersL( aGroupId, aOldAdmins, aNewAdmins, |
|
942 aOldUsers, aNewUsers, aOldRejected, aNewRejected ); |
|
943 } |
|
944 else |
|
945 { |
|
946 // closed group |
|
947 |
|
948 // Update group members |
|
949 UpdateGroupMembersL( aGroupId, aOldAdmins, aNewAdmins, |
|
950 aOldUsers, aNewUsers, aOldRejected, aNewRejected ); |
|
951 |
|
952 // Update properties |
|
953 err = grOps->UpdatePropertiesL( groupPropsDialogPC->GetEdittedProperties(), |
|
954 newPrivateProps ); |
|
955 if ( err != KErrNone ) |
|
956 { |
|
957 CleanupStack::PopAndDestroy(); //newPrivateProps |
|
958 return err; |
|
959 } |
|
960 } |
|
961 |
|
962 // update the group name |
|
963 MCAExtendedStoredGroup* group = static_cast<MCAExtendedStoredGroup*> |
|
964 ( iStoredGroups->FindGroup( aGroupId ) ); |
|
965 |
|
966 if ( group ) |
|
967 { |
|
968 group->SetGroupNameL( groupPropsDialogPC-> |
|
969 GetEdittedProperties()->GroupName() ); |
|
970 if ( group->StorageType() == TStorageManagerGlobals::EStoragePersistent ) |
|
971 { |
|
972 group->SaveChangesL(); |
|
973 } |
|
974 // signal the ui of changed group |
|
975 iStoredGroups->SignalGroupChangedL( aGroupId ); |
|
976 } |
|
977 |
|
978 CleanupStack::PopAndDestroy( 1, newPrivateProps ); |
|
979 |
|
980 return KErrNone; |
|
981 } |
|
982 // --------------------------------------------------------- |
|
983 // CCAGroupUtilsPC::SaveAsFavouriteL |
|
984 // (other items were commented in a header). |
|
985 // --------------------------------------------------------- |
|
986 // |
|
987 void CCAGroupUtilsPC::SaveAsFavouriteL( const TDesC& aGroupId ) |
|
988 { |
|
989 |
|
990 MCAStoredGroup* chatGroup = iStoredGroups->FindGroup( aGroupId ); |
|
991 if ( chatGroup ) |
|
992 { |
|
993 MCAExtendedStoredGroup* exGrp = static_cast < |
|
994 MCAExtendedStoredGroup* > ( chatGroup ); |
|
995 if ( exGrp ) |
|
996 { |
|
997 exGrp->SaveChangesL(); |
|
998 } |
|
999 } |
|
1000 } |
|
1001 |
|
1002 // ----------------------------------------------------------------------------- |
|
1003 // CCAGroupUtilsPC::CreateOrJoinGroupL |
|
1004 // ----------------------------------------------------------------------------- |
|
1005 // |
|
1006 void CCAGroupUtilsPC::CreateOrJoinGroupL( const TDesC& aGroupId, |
|
1007 TBool& aIsJoined, TBool& aIsFavourite ) |
|
1008 { |
|
1009 MCAStoredGroup* group = iStoredGroups->FindGroup( aGroupId ); |
|
1010 |
|
1011 if ( group ) |
|
1012 { |
|
1013 aIsJoined = group->IsJoined(); |
|
1014 |
|
1015 aIsFavourite = ( group->StorageType() == |
|
1016 TStorageManagerGlobals::EStoragePersistent ); |
|
1017 } |
|
1018 else |
|
1019 { |
|
1020 // if the group doesn't exist, create it |
|
1021 CHAT_DP_FUNC_DP( "JoinGroupL", "created new group" ); |
|
1022 // Ownership not transferred to caller |
|
1023 MCAExtendedStoredGroup* extGroup = iStoredGroups->CreateGroupL(); |
|
1024 // CSI: 35 # Comment above |
|
1025 |
|
1026 extGroup->SetGroupIdL( aGroupId ); |
|
1027 extGroup->SetGroupNameL( KNullDesC ); |
|
1028 |
|
1029 group = extGroup; |
|
1030 } |
|
1031 currentGroup = group; |
|
1032 |
|
1033 // set the group visible, just in case |
|
1034 static_cast<MCAExtendedStoredGroup*>( group )->SetVisible( ETrue ); |
|
1035 } |
|
1036 |
|
1037 // ----------------------------------------------------------------------------- |
|
1038 // CCAGroupUtilsPC::GetEngineDefaultGroupName |
|
1039 // ----------------------------------------------------------------------------- |
|
1040 // |
|
1041 TPtrC CCAGroupUtilsPC::GetEngineDefaultGroupName( const TDesC& aGroupId ) const |
|
1042 { |
|
1043 MCAStoredGroup* group = iStoredGroups->FindGroup( aGroupId ); |
|
1044 if ( group ) |
|
1045 { |
|
1046 return group->GroupName(); |
|
1047 } |
|
1048 else |
|
1049 { |
|
1050 |
|
1051 CImpsCommonGroupProps* commonProps = NULL; |
|
1052 |
|
1053 // if the group doesn't exist, create a temp one |
|
1054 CHAT_DP_FUNC_DP( "JoinGroupL", "created new group" ); |
|
1055 |
|
1056 TRAPD( error, |
|
1057 // Ownership not transferred to caller |
|
1058 MCAExtendedStoredGroup* extGroup = iStoredGroups->CreateGroupL(); |
|
1059 |
|
1060 extGroup->SetGroupIdL( aGroupId ); |
|
1061 extGroup->SetGroupNameL( KNullDesC ); |
|
1062 |
|
1063 // Set the group invisible |
|
1064 static_cast<MCAExtendedStoredGroup*>( extGroup )->SetVisible( EFalse ); |
|
1065 |
|
1066 MCAGroupOperations* grOps = iGroupManagerInterface->GroupOperationsL( aGroupId ); |
|
1067 |
|
1068 // if we created the group, fetch the name for it |
|
1069 CImpsPrivateGroupProps* privProps = NULL; |
|
1070 TInt err = grOps->GetPropertiesL( commonProps, privProps ); |
|
1071 ); |
|
1072 |
|
1073 if ( error == KErrNone && commonProps != NULL ) |
|
1074 { |
|
1075 return commonProps->GroupName(); |
|
1076 } |
|
1077 // If we can not get the group name return KNullDesC |
|
1078 else |
|
1079 { |
|
1080 return KNullDesC(); |
|
1081 } |
|
1082 } |
|
1083 } |
|
1084 |
|
1085 // ----------------------------------------------------------------------------- |
|
1086 // CCAGroupUtilsPC::SetGroupNameL |
|
1087 // ----------------------------------------------------------------------------- |
|
1088 // |
|
1089 void CCAGroupUtilsPC::SetGroupNameL( const TDesC& aGroupId ) |
|
1090 { |
|
1091 MCAGroupOperations* grOps = iGroupManagerInterface->GroupOperationsL( aGroupId ); |
|
1092 // if we created the group, fetch the name for it |
|
1093 CImpsCommonGroupProps* commonProps = NULL; |
|
1094 CImpsPrivateGroupProps* privProps = NULL; |
|
1095 TInt err = grOps->GetPropertiesL( commonProps, privProps ); |
|
1096 |
|
1097 MCAStoredGroup* group = iStoredGroups->FindGroup( aGroupId ); |
|
1098 |
|
1099 if ( err == KErrNone && commonProps ) |
|
1100 { |
|
1101 static_cast<MCAExtendedStoredGroup*>( currentGroup ) |
|
1102 ->SetGroupNameL( commonProps->GroupName() ); |
|
1103 } |
|
1104 |
|
1105 } |
|
1106 |
|
1107 // ----------------------------------------------------------------------------- |
|
1108 // CCAGroupUtilsPC::GetAliasL |
|
1109 // ----------------------------------------------------------------------------- |
|
1110 // |
|
1111 HBufC* CCAGroupUtilsPC::GetAliasL() |
|
1112 { |
|
1113 return iEngine.GetInternalSettingsInterface()->ValueL( MCASettings::EOwnAlias ); |
|
1114 } |
|
1115 |
|
1116 // ----------------------------------------------------------------------------- |
|
1117 // CCAGroupUtilsPC::GetGroupNameForJoinedGroupL |
|
1118 // ----------------------------------------------------------------------------- |
|
1119 // |
|
1120 TPtrC CCAGroupUtilsPC::GetGroupNameForJoinedGroupL( const TDesC& aGroupId ) |
|
1121 { |
|
1122 // update the group name |
|
1123 |
|
1124 MCAGroupOperations* grOps = iGroupManagerInterface->GroupOperationsL( aGroupId ); |
|
1125 |
|
1126 MCAStoredGroup* group = iStoredGroups->FindGroup( aGroupId ); |
|
1127 |
|
1128 // prefer showing the group name |
|
1129 if ( group->GroupName().Length() == 0 ) |
|
1130 { |
|
1131 // no group name, use Group ID |
|
1132 return CCAPCUtils::DisplayId( aGroupId ); |
|
1133 } |
|
1134 else |
|
1135 { |
|
1136 // group name exists |
|
1137 return group->GroupName(); |
|
1138 } |
|
1139 } |
|
1140 |
|
1141 // ----------------------------------------------------------------------------- |
|
1142 // CCAGroupUtilsPC::DeleteFailedGroupL |
|
1143 // ----------------------------------------------------------------------------- |
|
1144 // |
|
1145 void CCAGroupUtilsPC::DeleteFailedGroupL( const TDesC& aGroupId, |
|
1146 TBool aDeleteFromNetwork ) |
|
1147 { |
|
1148 |
|
1149 // update the group name |
|
1150 MCAStoredGroup* group = iStoredGroups->FindGroup( aGroupId ); |
|
1151 |
|
1152 if ( ( !group->IsOwnGroup() ) && |
|
1153 ( group->StorageType() != |
|
1154 TStorageManagerGlobals::EStoragePersistent ) && |
|
1155 ( !group->IsJoined() ) ) |
|
1156 { |
|
1157 |
|
1158 iStoredGroups->SetGroupDeleted( ETrue ); |
|
1159 // if join was not succesfull and group is not own nor saved, |
|
1160 // remove the group from manager |
|
1161 iGroupManagerInterface->DeleteGroupL( aGroupId, aDeleteFromNetwork ); |
|
1162 |
|
1163 iStoredGroups->SetGroupDeleted( EFalse ); |
|
1164 } |
|
1165 } |
|
1166 |
|
1167 // ----------------------------------------------------------------------------- |
|
1168 // CCAGroupUtilsPC::SendInvitationsL |
|
1169 // ----------------------------------------------------------------------------- |
|
1170 // |
|
1171 TInt CCAGroupUtilsPC::SendInvitationsL( const CDesCArray& aUserIDs, |
|
1172 const TDesC& aGroupID, |
|
1173 const TDesC& aMessage ) |
|
1174 { |
|
1175 TInt retVal = KErrNone; |
|
1176 // we have invitations, so send them |
|
1177 CCAInvitationRequest* invitation = |
|
1178 CCAInvitationRequest::NewL( aUserIDs, |
|
1179 aGroupID, |
|
1180 aMessage ); |
|
1181 |
|
1182 CleanupStack::PushL( invitation ); |
|
1183 |
|
1184 |
|
1185 MCAInvite* inviteAPI = iEngine.GetInvitationInterface(); |
|
1186 // Send invitation |
|
1187 inviteAPI->SendInvitationL( *invitation ); |
|
1188 CleanupStack::PopAndDestroy( invitation ); |
|
1189 return retVal; |
|
1190 } |
|
1191 |
|
1192 |
|
1193 // ----------------------------------------------------------------------------- |
|
1194 // CCAGroupUtilsPC: FindGroup |
|
1195 // ----------------------------------------------------------------------------- |
|
1196 // |
|
1197 TBool CCAGroupUtilsPC::FindGroup( const TDesC& aId ) |
|
1198 { |
|
1199 MCAStoredGroup* group = iStoredGroups->FindGroup( aId ); |
|
1200 if ( group ) |
|
1201 { |
|
1202 return ETrue; |
|
1203 } |
|
1204 return EFalse; |
|
1205 } |
|
1206 |
|
1207 // ----------------------------------------------------------------------------- |
|
1208 // CCAGroupUtilsPC: GetParticipantsL |
|
1209 // ----------------------------------------------------------------------------- |
|
1210 // |
|
1211 void CCAGroupUtilsPC::GetParticipantsL( CDesCArray& aParticipantList, |
|
1212 const TDesC& aGroupID ) const |
|
1213 { |
|
1214 MCAStoredGroup* group = iStoredGroups->FindGroup( aGroupID ); |
|
1215 if ( group ) |
|
1216 { |
|
1217 group->GetParticipantsL( aParticipantList ); |
|
1218 } |
|
1219 } |
|
1220 |
|
1221 |
|
1222 // --------------------------------------------------------- |
|
1223 // CCAGroupUtilsPC::LeaveGroupL |
|
1224 // (other items were commented in a header). |
|
1225 // --------------------------------------------------------- |
|
1226 // |
|
1227 TInt CCAGroupUtilsPC::LeaveGroupL( const TDesC& aGroupId ) |
|
1228 { |
|
1229 return iGroupManagerInterface->LeaveGroupL( aGroupId ) ; |
|
1230 } |
|
1231 |
|
1232 |
|
1233 // ----------------------------------------------------------------------------- |
|
1234 // CCAGroupUtilsPC::IsFavouriteChatGroup |
|
1235 // ----------------------------------------------------------------------------- |
|
1236 // |
|
1237 TBool CCAGroupUtilsPC::IsFavouriteChatGroup( const TDesC& aGroupId ) const |
|
1238 { |
|
1239 TBool isFavourite( EFalse ); |
|
1240 MCAStoredGroup* group = iStoredGroups->FindGroup( aGroupId ); |
|
1241 if ( group ) |
|
1242 { |
|
1243 isFavourite = ( group->StorageType() == |
|
1244 TStorageManagerGlobals::EStoragePersistent ); |
|
1245 } |
|
1246 return isFavourite; |
|
1247 } |
|
1248 |
|
1249 // --------------------------------------------------------- |
|
1250 // CCAGroupUtilsPC::IsOwnGroup |
|
1251 // --------------------------------------------------------- |
|
1252 // |
|
1253 TBool CCAGroupUtilsPC::IsOwnGroup( const TDesC& aGroupId ) const |
|
1254 { |
|
1255 MCAStoredGroup* group = iStoredGroups->FindGroup( aGroupId ); |
|
1256 |
|
1257 if ( group ) |
|
1258 { |
|
1259 return group->IsOwnGroup(); |
|
1260 } |
|
1261 else |
|
1262 { |
|
1263 return EFalse; |
|
1264 } |
|
1265 } |
|
1266 |
|
1267 |
|
1268 // --------------------------------------------------------- |
|
1269 // CCAGroupUtilsPC::IsJoined |
|
1270 // --------------------------------------------------------- |
|
1271 // |
|
1272 TBool CCAGroupUtilsPC::IsJoined( const TDesC& aGroupId ) const |
|
1273 { |
|
1274 MCAStoredGroup* group = iStoredGroups->FindGroup( aGroupId ); |
|
1275 |
|
1276 if ( group ) |
|
1277 { |
|
1278 return group->IsJoined(); |
|
1279 } |
|
1280 else |
|
1281 { |
|
1282 return EFalse; |
|
1283 } |
|
1284 } |
|
1285 |
|
1286 |
|
1287 // --------------------------------------------------------- |
|
1288 // CCAGroupUtilsPC::IsAdmin |
|
1289 // --------------------------------------------------------- |
|
1290 // |
|
1291 TBool CCAGroupUtilsPC::IsAdmin( const TDesC& aGroupId ) const |
|
1292 { |
|
1293 MCAStoredGroup* group = iStoredGroups->FindGroup( aGroupId ); |
|
1294 if ( group ) |
|
1295 { |
|
1296 return group->IsAdmin(); |
|
1297 } |
|
1298 else |
|
1299 { |
|
1300 return EFalse; |
|
1301 } |
|
1302 } |
|
1303 |
|
1304 // End of File |