|
1 /* |
|
2 * Copyright (c) 2003-2005 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 one chat group handling |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "MCAImpsGroupClient.h" |
|
22 #include "MCASettings.h" |
|
23 #include "MCAExtendedStoredGroup.h" |
|
24 #include "MCAGroupEventObserver.h" |
|
25 |
|
26 #include "ImpsCSPAllErrors.h" |
|
27 #include "CCAGroupWrapper.h" |
|
28 #include "CCARequest.h" |
|
29 #include "CCARequestMapper.h" |
|
30 #include "ChatDebugPrint.h" |
|
31 |
|
32 #include <ImpsErrors.h> |
|
33 #include <coemain.h> // For CCoeEnv |
|
34 |
|
35 // ============================ MEMBER FUNCTIONS =============================== |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CCAGroupWrapper::CCAGroupWrapper |
|
39 // C++ default constructor can NOT contain any code, that |
|
40 // might leave. |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CCAGroupWrapper::CCAGroupWrapper( MCASettings& aSettingsAPI, |
|
44 MCAExtendedStoredGroup& aGroup, |
|
45 CCARequestMapper& aRequestMapper, |
|
46 MCAImpsGroupClient* aClient ) |
|
47 : iSettingsAPI( aSettingsAPI ), |
|
48 iGroup( aGroup ), |
|
49 iConeEnv( CCoeEnv::Static() ), |
|
50 iRequestMapper( aRequestMapper ), |
|
51 iImpsGroupClient( aClient ), |
|
52 iOperationError( KErrNone ) |
|
53 { |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CCAGroupWrapper::NewL |
|
58 // Two-phased constructor. |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 CCAGroupWrapper* CCAGroupWrapper::NewL( MCASettings& aSettingsAPI, |
|
62 MCAExtendedStoredGroup& aGroup, |
|
63 CCARequestMapper& aRequestMapper, |
|
64 MCAImpsGroupClient* aClient ) |
|
65 { |
|
66 CCAGroupWrapper* self = new( ELeave ) CCAGroupWrapper( aSettingsAPI, aGroup, |
|
67 aRequestMapper, aClient ); |
|
68 |
|
69 return self; |
|
70 } |
|
71 |
|
72 |
|
73 // Destructor |
|
74 CCAGroupWrapper::~CCAGroupWrapper() |
|
75 { |
|
76 // signal observer to keep UI state in sync |
|
77 if ( iObserver ) |
|
78 { |
|
79 iObserver->HandleGroupLeft( KErrNone ); |
|
80 } |
|
81 |
|
82 delete iCommonProperties; |
|
83 delete iPrivateProperties; |
|
84 |
|
85 if ( iOldTopic ) |
|
86 { |
|
87 delete iOldTopic; |
|
88 iOldTopic = NULL; |
|
89 } |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------- |
|
93 // CCAGroupWrapper::Group |
|
94 // --------------------------------------------------------- |
|
95 // |
|
96 MCAStoredGroup& CCAGroupWrapper::Group() |
|
97 { |
|
98 return iGroup; |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------- |
|
102 // CCAGroupWrapper::RegisterEventObserverL |
|
103 // --------------------------------------------------------- |
|
104 // |
|
105 void CCAGroupWrapper::RegisterEventObserver( MCAGroupEventObserver* aObserver ) |
|
106 { |
|
107 iObserver = aObserver; |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------- |
|
111 // CCAGroupWrapper::LocalPropertiesL |
|
112 // --------------------------------------------------------- |
|
113 // |
|
114 void CCAGroupWrapper::LocalProperties( CImpsCommonGroupProps*& aCommonProps, |
|
115 CImpsPrivateGroupProps*& aPrivateProps ) |
|
116 { |
|
117 aCommonProps = iCommonProperties; |
|
118 aPrivateProps = iPrivateProperties; |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------- |
|
122 // CCAGroupWrapper::SetLocalPropertiesL |
|
123 // --------------------------------------------------------- |
|
124 // |
|
125 void CCAGroupWrapper::SetLocalProperties( CImpsCommonGroupProps* aCommonProps, |
|
126 CImpsPrivateGroupProps* aPrivateProps ) |
|
127 { |
|
128 // since we own these, we must get rid of these |
|
129 delete iCommonProperties; |
|
130 iCommonProperties = aCommonProps; |
|
131 |
|
132 delete iPrivateProperties; |
|
133 iPrivateProperties = aPrivateProps; |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------- |
|
137 // CCAGroupWrapper::Requet |
|
138 // --------------------------------------------------------- |
|
139 // |
|
140 CCARequest* CCAGroupWrapper::Request() |
|
141 { |
|
142 return iRequest; |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------- |
|
146 // CCAGroupManager::LastImpsError |
|
147 // --------------------------------------------------------- |
|
148 // |
|
149 void CCAGroupWrapper::LastImpsError( TInt aError ) |
|
150 { |
|
151 iLastImpsError = aError; |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------- |
|
155 // CCAGroupManager::SetTopicShown |
|
156 // --------------------------------------------------------- |
|
157 // |
|
158 void CCAGroupWrapper::SetTopicShown( TBool aIsShown ) |
|
159 { |
|
160 iTopicShown = aIsShown; |
|
161 } |
|
162 |
|
163 // --------------------------------------------------------- |
|
164 // CCAGroupManager::IsTopicShown |
|
165 // --------------------------------------------------------- |
|
166 // |
|
167 TBool CCAGroupWrapper::IsTopicShown() const |
|
168 { |
|
169 return iTopicShown; |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------- |
|
173 // CCAGroupWrapper::OperationId |
|
174 // --------------------------------------------------------- |
|
175 // |
|
176 TInt CCAGroupWrapper::OperationId() |
|
177 { |
|
178 return iOperationId; |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------- |
|
182 // CCAGroupWrapper::JoinL |
|
183 // --------------------------------------------------------- |
|
184 // |
|
185 TInt CCAGroupWrapper::JoinL( const TDesC& aScreenName, TBool aUsers, |
|
186 TBool aIsFavourite ) |
|
187 { |
|
188 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::JoinGroupL to group %S" ), |
|
189 &iGroup.GroupId() ); |
|
190 |
|
191 // JOIN PHASE////////////////////////////////////////////////////////////// |
|
192 iOperationId = iImpsGroupClient->JoinGroupL( iGroup.GroupId(), aScreenName, |
|
193 aUsers, ETrue ); |
|
194 |
|
195 |
|
196 // We need additional data e.g. group ID and the screen name |
|
197 // Granularity of two because there will 2 items |
|
198 CDesCArrayFlat* dataArray = new ( ELeave ) CDesCArrayFlat( 2 ); |
|
199 CleanupStack::PushL( dataArray ); |
|
200 dataArray->AppendL( iGroup.GroupId() ); |
|
201 dataArray->AppendL( aScreenName ); |
|
202 |
|
203 if ( aIsFavourite ) |
|
204 { |
|
205 iOperationError = ExecuteRequestL( iOperationId, EJoinGroup, |
|
206 dataArray ); |
|
207 } |
|
208 else |
|
209 { |
|
210 iOperationError = ExecuteRequestL( iOperationId, |
|
211 EJoinToNonFavouriteGroup, |
|
212 dataArray ); |
|
213 } |
|
214 |
|
215 CleanupStack::PopAndDestroy( dataArray ); |
|
216 |
|
217 return iOperationError; |
|
218 } |
|
219 |
|
220 // --------------------------------------------------------- |
|
221 // CCAGroupWrapper::CreateGroupL |
|
222 // --------------------------------------------------------- |
|
223 // |
|
224 TInt CCAGroupWrapper::CreateGroupL( const TDesC& aScreenName, TBool aJoinGroup ) |
|
225 { |
|
226 CHAT_DP_TXT( "CCAGroupWrapper::CreateGroupL...starts" ); |
|
227 |
|
228 if ( !iCommonProperties ) |
|
229 { |
|
230 User::Leave( KErrNotReady ); |
|
231 } |
|
232 |
|
233 CDesCArrayFlat* dataArray = |
|
234 new ( ELeave ) CDesCArrayFlat( KArrayGranularity ); |
|
235 CleanupStack::PushL( dataArray ); |
|
236 |
|
237 iOperationId = iImpsGroupClient->CreateGroupL( iGroup.GroupId(), |
|
238 iCommonProperties, |
|
239 aScreenName, |
|
240 aJoinGroup, |
|
241 ETrue ); |
|
242 |
|
243 dataArray->AppendL( iGroup.GroupId() ); |
|
244 dataArray->AppendL( iCommonProperties->GroupName() ); |
|
245 |
|
246 if ( aJoinGroup ) |
|
247 { |
|
248 dataArray->AppendL( aScreenName ); |
|
249 dataArray->AppendL( iCommonProperties->Welcome() ); |
|
250 dataArray->AppendL( iCommonProperties->Topic() ); |
|
251 iOperationError = ExecuteRequestL( iOperationId, |
|
252 ECreateAndJoinGroup, |
|
253 dataArray ); |
|
254 } |
|
255 else |
|
256 { |
|
257 iOperationError = ExecuteRequestL( iOperationId, |
|
258 ECreateGroup, |
|
259 dataArray ); |
|
260 } |
|
261 |
|
262 CleanupStack::PopAndDestroy( dataArray ); |
|
263 |
|
264 return iOperationError; |
|
265 } |
|
266 |
|
267 // --------------------------------------------------------- |
|
268 // CCAGroupWrapper::LeaveL |
|
269 // --------------------------------------------------------- |
|
270 // |
|
271 TInt CCAGroupWrapper::LeaveL() |
|
272 { |
|
273 CHAT_DP_TXT( "CCAGroupWrapper::LeaveGroupL...starts" ); |
|
274 |
|
275 iOperationId = iImpsGroupClient->LeaveGroupL( iGroup.GroupId() ); |
|
276 |
|
277 // In client initiated Leave we must store the group id because it |
|
278 // doesn't exist in the callback. Adding only 1 --> granularity 1 |
|
279 CDesCArrayFlat* dataArray = new ( ELeave ) CDesCArrayFlat( 1 ); |
|
280 CleanupStack::PushL( dataArray ); |
|
281 dataArray->AppendL( iGroup.GroupId() ); |
|
282 |
|
283 iOperationError = ExecuteRequestL( iOperationId, ELeaveGroup, dataArray ); |
|
284 |
|
285 CleanupStack::PopAndDestroy( dataArray ); |
|
286 |
|
287 CHAT_DP_TXT( "CCAGroupWrapper::LeaveGroupL...over" ); |
|
288 |
|
289 return iOperationError; |
|
290 } |
|
291 |
|
292 // --------------------------------------------------------- |
|
293 // CCAGroupWrapper::DeleteFromNetworkL |
|
294 // --------------------------------------------------------- |
|
295 // |
|
296 TInt CCAGroupWrapper::DeleteFromNetworkL() |
|
297 { |
|
298 CHAT_DP_TXT( "CCAGroupWrapper::DeleteGroupL...starts" ); |
|
299 |
|
300 iOperationId = iImpsGroupClient->DeleteGroupL( iGroup.GroupId() ); |
|
301 |
|
302 CDesCArrayFlat* dataArray = |
|
303 new ( ELeave ) CDesCArrayFlat( KArrayGranularity ); |
|
304 CleanupStack::PushL( dataArray ); |
|
305 dataArray->AppendL( iGroup.GroupId() ); |
|
306 |
|
307 iOperationError = ExecuteRequestL( iOperationId, EDeleteGroup, dataArray ); |
|
308 |
|
309 CleanupStack::PopAndDestroy( dataArray ); |
|
310 |
|
311 CHAT_DP_TXT( "CCAGroupWrapper::DeleteGroupL...over" ); |
|
312 |
|
313 return iOperationError; |
|
314 } |
|
315 |
|
316 // --------------------------------------------------------- |
|
317 // CCAGroupWrapper::UpdatePropertiesL |
|
318 // --------------------------------------------------------- |
|
319 // |
|
320 TInt CCAGroupWrapper::UpdatePropertiesL( CImpsCommonGroupProps* aCommonProps, |
|
321 CImpsPrivateGroupProps* aPrivateProps ) |
|
322 { |
|
323 CHAT_DP_TXT( "CCAGroupWrapper::UpdatePropertiesL...starts" ); |
|
324 |
|
325 iOperationId = iImpsGroupClient->SetGroupPropertiesL( iGroup.GroupId(), |
|
326 aCommonProps, |
|
327 aPrivateProps ); |
|
328 |
|
329 CDesCArrayFlat* dataArray = |
|
330 new ( ELeave ) CDesCArrayFlat( KArrayGranularity ); |
|
331 CleanupStack::PushL( dataArray ); |
|
332 dataArray->AppendL( iGroup.GroupId() ); |
|
333 |
|
334 iOperationError = ExecuteRequestL( iOperationId, |
|
335 ESetGroupProperties, dataArray ); |
|
336 |
|
337 CleanupStack::PopAndDestroy( dataArray ); |
|
338 |
|
339 if ( iOperationError == KErrNone || iOperationError == ECSPSuccessful ) |
|
340 { |
|
341 if ( aCommonProps ) |
|
342 { |
|
343 if ( aCommonProps->Topic().Length() > 0 && |
|
344 iOldTopic != NULL && |
|
345 0 != aCommonProps->Topic().CompareC( *iOldTopic ) ) |
|
346 { |
|
347 // Set new topic not shown, this happens when user |
|
348 // changes topic |
|
349 iTopicShown = EFalse; |
|
350 } |
|
351 } |
|
352 |
|
353 // updating was successful, update the local properties |
|
354 CopyPropertiesL( aCommonProps, iCommonProperties, |
|
355 aPrivateProps, iPrivateProperties ); |
|
356 } |
|
357 |
|
358 if ( iOldTopic ) |
|
359 { |
|
360 delete iOldTopic; |
|
361 iOldTopic = NULL; |
|
362 } |
|
363 iOldTopic = iCommonProperties->Topic().AllocL(); |
|
364 |
|
365 CHAT_DP_TXT( "CCAGroupWrapper::UpdatePropertiesL...over" ); |
|
366 |
|
367 return iOperationError; |
|
368 } |
|
369 |
|
370 // --------------------------------------------------------- |
|
371 // CCAGroupWrapper::AddMembersL |
|
372 // --------------------------------------------------------- |
|
373 // |
|
374 TInt CCAGroupWrapper::AddMembersL( const CDesCArray& aUserList, |
|
375 const CDesCArray& aScreenNameList ) |
|
376 { |
|
377 CHAT_DP_TXT( "CCAGroupWrapper::AddMembersL...starts" ); |
|
378 |
|
379 if ( ( aUserList.MdcaCount() == 0 ) && |
|
380 ( aScreenNameList.MdcaCount() == 0 ) ) |
|
381 { |
|
382 // Both lists are empty, it's time to leave |
|
383 User::Leave( KErrArgument ); |
|
384 } |
|
385 |
|
386 iOperationId = iImpsGroupClient->AddMembersL( iGroup.GroupId(), |
|
387 aUserList, aScreenNameList ); |
|
388 |
|
389 // We need additional data for group ID |
|
390 CDesCArrayFlat* dataArray = |
|
391 new ( ELeave ) CDesCArrayFlat( KArrayGranularity ); |
|
392 CleanupStack::PushL( dataArray ); |
|
393 dataArray->AppendL( iGroup.GroupId() ); |
|
394 |
|
395 iOperationError = ExecuteRequestL( iOperationId, EAddMembers, dataArray ); |
|
396 |
|
397 CleanupStack::PopAndDestroy( dataArray ); |
|
398 |
|
399 CHAT_DP_TXT( "CCAGroupWrapper::AddMembersL...over" ); |
|
400 |
|
401 return iOperationError; |
|
402 } |
|
403 |
|
404 // --------------------------------------------------------- |
|
405 // CCAGroupWrapper::RemoveMembersL |
|
406 // --------------------------------------------------------- |
|
407 // |
|
408 TInt CCAGroupWrapper::RemoveMembersL( const CDesCArray& aUserList ) |
|
409 { |
|
410 CHAT_DP_TXT( "CCAGroupWrapper::RemoveMembersL" ); |
|
411 |
|
412 iOperationId = |
|
413 iImpsGroupClient->RemoveMembersL( iGroup.GroupId(), aUserList ); |
|
414 |
|
415 iOperationError = ExecuteRequestL( iOperationId, ERemoveMembers ); |
|
416 |
|
417 return iOperationError; |
|
418 } |
|
419 |
|
420 // --------------------------------------------------------- |
|
421 // CCAGroupWrapper::ModifyMembersL |
|
422 // --------------------------------------------------------- |
|
423 // |
|
424 TInt CCAGroupWrapper::ModifyMembersL( const CDesCArray* aAdminList, |
|
425 const CDesCArray* aModerList, |
|
426 const CDesCArray* aOrdinaryList ) |
|
427 { |
|
428 CHAT_DP_TXT( "CCAGroupWrapper::ModifyMembersAccessL()...starts" ); |
|
429 |
|
430 iOperationId = iImpsGroupClient->ModifyMembersAccessL( |
|
431 iGroup.GroupId(), |
|
432 aAdminList, |
|
433 aModerList, |
|
434 aOrdinaryList ); |
|
435 |
|
436 iOperationError = ExecuteRequestL( iOperationId, EModifyMembersAccess ); |
|
437 |
|
438 CHAT_DP_TXT( "CCAGroupWrapper::ModifyMembersAccessL()...over" ); |
|
439 |
|
440 return iOperationError; |
|
441 } |
|
442 |
|
443 // --------------------------------------------------------- |
|
444 // CCAGroupWrapper::GetPropertiesL |
|
445 // --------------------------------------------------------- |
|
446 // |
|
447 TInt CCAGroupWrapper::GetPropertiesL( CImpsCommonGroupProps*& aCommonProps, |
|
448 CImpsPrivateGroupProps*& aPrivateProps ) |
|
449 { |
|
450 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::PropertiesL to group %S" ), |
|
451 &iGroup.GroupId() ); |
|
452 |
|
453 if ( ( iCommonProperties ) || ( iPrivateProperties ) ) |
|
454 { |
|
455 aCommonProps = iCommonProperties; |
|
456 aPrivateProps = iPrivateProperties; |
|
457 return KErrNone; |
|
458 } |
|
459 |
|
460 iOperationId = iImpsGroupClient->GroupPropertiesL( iGroup.GroupId() ); |
|
461 |
|
462 iOperationError = ExecuteRequestL( iOperationId, EGroupProperties ); |
|
463 |
|
464 aCommonProps = iCommonProperties; |
|
465 aPrivateProps = iPrivateProperties; |
|
466 // if new operation id is created , then set it to zero. |
|
467 iOperationId = KErrNone; |
|
468 return iOperationError; |
|
469 } |
|
470 |
|
471 // --------------------------------------------------------- |
|
472 // CCAGroupWrapper::GetMembersL |
|
473 // --------------------------------------------------------- |
|
474 // |
|
475 TInt CCAGroupWrapper::GetMembersL( CDesCArray& aUserList, |
|
476 CDesCArray& aScreenNames, |
|
477 CDesCArray& aModers, |
|
478 CDesCArray& aAdmins ) |
|
479 { |
|
480 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::MembersL to group %S" ), |
|
481 &iGroup.GroupId() ); |
|
482 |
|
483 iMembers = &aUserList; |
|
484 iScreenNames = &aScreenNames; |
|
485 iModers = &aModers; |
|
486 iAdmins = &aAdmins; |
|
487 |
|
488 iOperationId = iImpsGroupClient->GroupMembersL( iGroup.GroupId() ); |
|
489 |
|
490 iOperationError = ExecuteRequestL( iOperationId, EGroupMembers ); |
|
491 |
|
492 iMembers = NULL; |
|
493 iScreenNames = NULL; |
|
494 iModers = NULL; |
|
495 iAdmins = NULL; |
|
496 |
|
497 return iOperationError; |
|
498 } |
|
499 |
|
500 // --------------------------------------------------------- |
|
501 // CCAGroupWrapper::GetRejectListL |
|
502 // --------------------------------------------------------- |
|
503 // |
|
504 TInt CCAGroupWrapper::GetRejectListL( CDesCArray& aRejectList ) |
|
505 { |
|
506 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::RejectListL to group %S" ), |
|
507 &iGroup.GroupId() ); |
|
508 iRejectedList = &aRejectList; |
|
509 |
|
510 iOperationId = iImpsGroupClient->SetRejectListL( iGroup.GroupId(), |
|
511 NULL, NULL ); |
|
512 |
|
513 iOperationError = ExecuteRequestL( iOperationId, ESetRejectList ); |
|
514 |
|
515 iRejectedList = NULL; |
|
516 |
|
517 return iOperationError; |
|
518 } |
|
519 |
|
520 // --------------------------------------------------------- |
|
521 // CCAGroupWrapper::SetRejectListL |
|
522 // --------------------------------------------------------- |
|
523 // |
|
524 TInt CCAGroupWrapper::SetRejectListL( const CDesCArray& aRejectedList, |
|
525 const CDesCArray& aEnabledList ) |
|
526 { |
|
527 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::SetRejectListL to group %S" ), |
|
528 &iGroup.GroupId() ); |
|
529 |
|
530 iOperationId = iImpsGroupClient->SetRejectListL( iGroup.GroupId(), |
|
531 &aRejectedList, &aEnabledList ); |
|
532 |
|
533 iOperationError = ExecuteRequestL( iOperationId, ESetRejectList ); |
|
534 |
|
535 return iOperationError; |
|
536 } |
|
537 |
|
538 // --------------------------------------------------------- |
|
539 // CCAGroupWrapper::HandleCompleteL |
|
540 // --------------------------------------------------------- |
|
541 // |
|
542 void CCAGroupWrapper::HandleCompleteL( TInt aOpId, |
|
543 TImpsCspIdentifier& /* aCspId */ ) |
|
544 { |
|
545 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::HandleCompleteL OpId = %d" ), aOpId ); |
|
546 // If code added before HandleRequest, then make sure that |
|
547 // code does not Leave before HandleRequest, because request |
|
548 // response waiting does not stop (and waitnote) before calling |
|
549 // HandleRequest |
|
550 if ( aOpId != 0 ) |
|
551 { |
|
552 iRequestMapper.HandleRequest( aOpId, KErrNone ); |
|
553 } |
|
554 } |
|
555 |
|
556 // --------------------------------------------------------- |
|
557 // CCAGroupWrapper::HandleJoinL |
|
558 // --------------------------------------------------------- |
|
559 // |
|
560 void CCAGroupWrapper::HandleJoinL( TInt aOpId, |
|
561 const MDesCArray& /* aUserList */, |
|
562 const MDesCArray& aScreenNames, |
|
563 const TDesC& /* aWelcomeText */, |
|
564 TImpsCspIdentifier& /* aCspId */ ) |
|
565 { |
|
566 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::HandleJoinL OpId = %d" ), aOpId ); |
|
567 if ( aOpId != 0 ) |
|
568 { |
|
569 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::JoinGroupL" ) ); |
|
570 |
|
571 TInt status( KErrNone ); |
|
572 |
|
573 TRAPD( err, iGroup.AddParticipantL( aScreenNames ) ); |
|
574 |
|
575 if ( err ) |
|
576 { |
|
577 status = err; |
|
578 } |
|
579 |
|
580 iRequestMapper.HandleRequest( aOpId, status ); |
|
581 User::LeaveIfError( err ); |
|
582 } |
|
583 } |
|
584 |
|
585 // --------------------------------------------------------- |
|
586 // CCAGroupWrapper::HandleGroupMembersL |
|
587 // --------------------------------------------------------- |
|
588 // |
|
589 void CCAGroupWrapper::HandleGroupMembersL( TInt aOpId, |
|
590 const MDesCArray& aUserList, |
|
591 const MDesCArray& aScreenNames, |
|
592 const MDesCArray& aModers, |
|
593 const MDesCArray& aAdmins, |
|
594 TImpsCspIdentifier& /* aCspId */ ) |
|
595 { |
|
596 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::HandleGroupMembersL OpId = %d" ), |
|
597 aOpId ); |
|
598 |
|
599 if ( aOpId != 0 ) |
|
600 { |
|
601 TInt status( KErrNone ); |
|
602 TRAPD( err, |
|
603 CopyArrayL( aUserList, iMembers ); |
|
604 CopyArrayL( aScreenNames, iScreenNames ); |
|
605 CopyArrayL( aModers, iModers ); |
|
606 CopyArrayL( aAdmins, iAdmins ); |
|
607 ) |
|
608 if ( err ) |
|
609 { |
|
610 status = err; |
|
611 } |
|
612 |
|
613 iRequestMapper.HandleRequest( aOpId, status ); |
|
614 User::LeaveIfError( err ); |
|
615 } |
|
616 } |
|
617 |
|
618 // --------------------------------------------------------- |
|
619 // CCAGroupWrapper::HandleGroupPropertiesL |
|
620 // --------------------------------------------------------- |
|
621 // |
|
622 void CCAGroupWrapper::HandleGroupPropertiesL( TInt aOpId, |
|
623 const TDesC& /*aGroupId*/, |
|
624 const CImpsCommonGroupProps& aGroupProps, |
|
625 const CImpsPrivateGroupProps& aOwnProps, |
|
626 TImpsCspIdentifier& /* aCspId */ ) |
|
627 { |
|
628 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::HandleGroupPropertiesL OpId = %d" ), |
|
629 aOpId ); |
|
630 // If code added before HandleRequest, then make sure that |
|
631 // code does not Leave before HandleRequest, because request |
|
632 // response waiting does not stop (and waitnote) before calling |
|
633 // HandleRequest |
|
634 if ( aOpId != 0 ) |
|
635 { |
|
636 iRequestMapper.HandleRequest( aOpId, KErrNone ); |
|
637 } |
|
638 |
|
639 // Copy relevant data to properties which are |
|
640 // stored in wrapper. This can be done always, as the properties contain |
|
641 // all fields in every case. |
|
642 CopyPropertiesL( &aGroupProps, iCommonProperties, &aOwnProps, |
|
643 iPrivateProperties ); |
|
644 |
|
645 // push event from the network |
|
646 // signal observer |
|
647 if ( iObserver ) |
|
648 { |
|
649 iObserver->HandleGroupPropertiesChanged(); |
|
650 } |
|
651 |
|
652 } |
|
653 |
|
654 // --------------------------------------------------------- |
|
655 // CCAGroupWrapper::HandleRejectListL |
|
656 // --------------------------------------------------------- |
|
657 // |
|
658 void CCAGroupWrapper::HandleRejectListL( TInt aOpId, |
|
659 const MDesCArray& aUserList, |
|
660 TImpsCspIdentifier& /* aCspId */ ) |
|
661 { |
|
662 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::HandleRejectListL OpId = %d" ), |
|
663 aOpId ); |
|
664 |
|
665 if ( aOpId != 0 ) |
|
666 { |
|
667 CHAT_DP( D_CHAT_LIT( " --RejectList count %d -- " ), |
|
668 aUserList.MdcaCount() ); |
|
669 TInt status( KErrNone ); |
|
670 TRAPD( err, CopyArrayL( aUserList, iRejectedList ) ); |
|
671 if ( err ) |
|
672 { |
|
673 status = err; |
|
674 } |
|
675 iRequestMapper.HandleRequest( aOpId, status ); |
|
676 User::LeaveIfError( err ); |
|
677 } |
|
678 } |
|
679 |
|
680 // --------------------------------------------------------- |
|
681 // CCAGroupWrapper::HandleSubscriptionL |
|
682 // --------------------------------------------------------- |
|
683 // |
|
684 void CCAGroupWrapper::HandleSubscriptionL( TInt aOpId, TBool /*aIsSubscribed*/, |
|
685 TImpsCspIdentifier& /* aCspId */ ) |
|
686 { |
|
687 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::HandleSubscriptionL OpId = %d" ), |
|
688 aOpId ); |
|
689 // If code added before HandleRequest, then make sure that |
|
690 // code does not Leave before HandleRequest, because request |
|
691 // response waiting does not stop (and waitnote) before calling |
|
692 // HandleRequest |
|
693 if ( aOpId != 0 ) |
|
694 { |
|
695 iRequestMapper.HandleRequest( aOpId, KErrNone ); |
|
696 } |
|
697 } |
|
698 |
|
699 // --------------------------------------------------------- |
|
700 // CCAGroupWrapper::HandleNewUsersL |
|
701 // --------------------------------------------------------- |
|
702 // |
|
703 void CCAGroupWrapper::HandleNewUsersL( const TDesC& /* aGroupId */, |
|
704 const MDesCArray& /* aUserList */, |
|
705 const MDesCArray& aScreenNames, |
|
706 TImpsCspIdentifier& /* aCspId */ ) |
|
707 { |
|
708 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::HandleNewUsersL" ) ); |
|
709 // always push event, so no need to stop request |
|
710 iGroup.AddParticipantL( aScreenNames ); |
|
711 } |
|
712 |
|
713 // --------------------------------------------------------- |
|
714 // CCAGroupWrapper::HandleLeftUsersL |
|
715 // --------------------------------------------------------- |
|
716 // |
|
717 void CCAGroupWrapper::HandleLeftUsersL( const TDesC& /* aGroupId */, |
|
718 const MDesCArray& aUserList, |
|
719 const MDesCArray& aScreenNames, |
|
720 TImpsCspIdentifier& /* aCspId */ ) |
|
721 { |
|
722 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::HandleLeftUsersL" ) ); |
|
723 |
|
724 // always push event, so no need to stop request |
|
725 |
|
726 CHAT_DP( D_CHAT_LIT( "aUserListCount: %d aScreenNamesCount %d" ), |
|
727 aUserList.MdcaCount(), aScreenNames.MdcaCount() ); |
|
728 |
|
729 iGroup.RemoveParticipantL( aScreenNames ); |
|
730 } |
|
731 |
|
732 // --------------------------------------------------------- |
|
733 // CCAGroupWrapper::HandleLeaveL |
|
734 // --------------------------------------------------------- |
|
735 // |
|
736 void CCAGroupWrapper::HandleLeaveL( TInt aOpId, const TDesC& /* aGroupId */, |
|
737 const TDesC& /*aDescription*/, |
|
738 TImpsCspIdentifier& /* aCspId */ ) |
|
739 { |
|
740 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::HandleLeaveL OpId = %d" ), aOpId ); |
|
741 |
|
742 // If code added before HandleRequest, then make sure that |
|
743 // code does not Leave before HandleRequest, because request |
|
744 // response waiting does not stop (and waitnote) before calling |
|
745 // HandleRequest |
|
746 if ( aOpId != 0 ) |
|
747 { |
|
748 iRequestMapper.HandleRequest( aOpId, KErrNone ); |
|
749 } |
|
750 else |
|
751 { |
|
752 // push event from the network |
|
753 // signal observer |
|
754 if ( iObserver ) |
|
755 { |
|
756 iObserver->HandleGroupLeft( iLastImpsError ); |
|
757 //consume error |
|
758 iLastImpsError = KErrNone; |
|
759 } |
|
760 } |
|
761 } |
|
762 |
|
763 // --------------------------------------------------------- |
|
764 // CCAGroupWrapper::CopyArrayL |
|
765 // --------------------------------------------------------- |
|
766 // |
|
767 void CCAGroupWrapper::CopyArrayL( const MDesCArray& aSource, CDesCArray* aDest ) |
|
768 { |
|
769 if ( !aDest ) |
|
770 { |
|
771 return; |
|
772 } |
|
773 |
|
774 aDest->Reset(); |
|
775 TInt count( aSource.MdcaCount() ); |
|
776 for ( TInt i( 0 ); i < count; i++ ) |
|
777 { |
|
778 TPtrC src( aSource.MdcaPoint( i ) ); |
|
779 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::CopyArrayL [%d] %S" ), i, &src ); |
|
780 aDest->AppendL( src ); |
|
781 } |
|
782 } |
|
783 |
|
784 // --------------------------------------------------------- |
|
785 // CCAGroupWrapper::ExecuteRequest |
|
786 // --------------------------------------------------------- |
|
787 // |
|
788 TInt CCAGroupWrapper::ExecuteRequestL( TInt aOperationId, |
|
789 TOperationRequests aRequestType, |
|
790 MDesCArray* aAdditionalData ) |
|
791 { |
|
792 // creating request |
|
793 iRequest = iRequestMapper.CreateRequestL( aOperationId, EFalse ); |
|
794 CCARequestMapper& requestMapper = iRequestMapper; |
|
795 CCARequest* request = iRequest; |
|
796 |
|
797 // setting type |
|
798 iRequest->SetRequestType( aRequestType ); |
|
799 |
|
800 // setting additional data if exists |
|
801 if ( aAdditionalData ) |
|
802 { |
|
803 iRequest->SetAdditionalData( *aAdditionalData ); |
|
804 } |
|
805 |
|
806 // Now when the request type and additional data is set we can |
|
807 // activate the synchronous wait |
|
808 iRequest->StartWait(); |
|
809 |
|
810 TInt retVal( request->ErrorCode() ); |
|
811 requestMapper.RemoveRequest( request ); |
|
812 iRequest = NULL; |
|
813 request = NULL; |
|
814 |
|
815 return retVal; |
|
816 } |
|
817 |
|
818 |
|
819 // --------------------------------------------------------- |
|
820 // CCAGroupWrapper::CopyPropertiesL |
|
821 // --------------------------------------------------------- |
|
822 // |
|
823 void CCAGroupWrapper::CopyPropertiesL( |
|
824 const CImpsCommonGroupProps* aFromCommonProps, |
|
825 CImpsCommonGroupProps* aToCommonProps, |
|
826 const CImpsPrivateGroupProps* aFromPrivateProps, |
|
827 CImpsPrivateGroupProps* aToPrivateProps |
|
828 ) |
|
829 { |
|
830 CHAT_DP_FUNC_ENTER( "CopyPropertiesL" ); |
|
831 |
|
832 if ( aToCommonProps && aFromCommonProps ) |
|
833 { |
|
834 // copy all relevant fields, ignoring empty fields |
|
835 if ( aFromCommonProps->GroupName().Length() > 0 ) |
|
836 { |
|
837 aToCommonProps->SetGroupNameL( aFromCommonProps->GroupName() ); |
|
838 } |
|
839 |
|
840 if ( aFromCommonProps->Welcome().Length() > 0 ) |
|
841 { |
|
842 aToCommonProps->SetWelcomeL( aFromCommonProps->Welcome() ); |
|
843 } |
|
844 |
|
845 if ( aFromCommonProps->Topic().Length() > 0 ) |
|
846 { |
|
847 aToCommonProps->SetTopicL( aFromCommonProps->Topic() ); |
|
848 } |
|
849 |
|
850 if ( aFromCommonProps->IsPrivateAllowed() != EImpsPropUndef ) |
|
851 { |
|
852 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::CopyPropertiesL - \ |
|
853 Whispering: %d" ), |
|
854 aFromCommonProps->IsPrivateAllowed() ); |
|
855 aToCommonProps->SetPrivateAllowed( |
|
856 aFromCommonProps->IsPrivateAllowed() ); |
|
857 } |
|
858 |
|
859 if ( aFromCommonProps->IsSearchable() != EImpsPropUndef ) |
|
860 { |
|
861 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::CopyPropertiesL - \ |
|
862 Searchable: %d" ), |
|
863 aFromCommonProps->IsSearchable() ); |
|
864 aToCommonProps->SetSearchable( aFromCommonProps->IsSearchable() ); |
|
865 } |
|
866 |
|
867 if ( aFromCommonProps->MaxNbrOfUsers() >= 0 ) |
|
868 { |
|
869 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::CopyPropertiesL - \ |
|
870 Max users: %d" ), |
|
871 aFromCommonProps->MaxNbrOfUsers() ); |
|
872 aToCommonProps->SetMaxNbrOfUsers( |
|
873 aFromCommonProps->MaxNbrOfUsers() ); |
|
874 } |
|
875 |
|
876 if ( aFromCommonProps->IsOpen() != EImpsPropUndef ) |
|
877 { |
|
878 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::CopyPropertiesL - Open: %d" ), |
|
879 aFromCommonProps->IsOpen() ); |
|
880 aToCommonProps->SetOpen( aFromCommonProps->IsOpen() ); |
|
881 } |
|
882 } |
|
883 |
|
884 if ( aToPrivateProps && aToPrivateProps ) |
|
885 { |
|
886 if ( aFromPrivateProps->IsPrivateAllowed() != EImpsPropUndef ) |
|
887 { |
|
888 CHAT_DP( D_CHAT_LIT( "CCAGroupWrapper::CopyPropertiesL - (Private) \ |
|
889 Allowed: %d" ), |
|
890 aFromPrivateProps->IsPrivateAllowed() ); |
|
891 aToPrivateProps->SetPrivateAllowed( |
|
892 aFromPrivateProps->IsPrivateAllowed() ); |
|
893 } |
|
894 } |
|
895 |
|
896 CHAT_DP_FUNC_DONE( "CopyPropertiesL" ); |
|
897 } |
|
898 |
|
899 |
|
900 // End of File |