|
1 /* |
|
2 * Copyright (c) 2008 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: Implementation of the class CFscPocPluginImpl. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "emailtrace.h" |
|
20 #include <ecom/implementationproxy.h> |
|
21 #include <bautils.h> |
|
22 #include <RPbkViewResourceFile.h> |
|
23 #include <AiwPoCParameters.h> |
|
24 #include <AiwPoCParameters.hrh> |
|
25 #include <AiwServiceHandler.h> |
|
26 #include <coemain.h> |
|
27 #include <AknsConstants.h> |
|
28 #include <fscpocplugin.rsg> |
|
29 #include <fscpocplugin.mbg> |
|
30 //<cmail> |
|
31 #include "fscactionpluginactionuids.h" |
|
32 #include "cfsccontactaction.h" |
|
33 #include "mfsccontactset.h" |
|
34 #include "mfscactionutils.h" |
|
35 #include "mfsccontactactionpluginobserver.h" |
|
36 //</cmail> |
|
37 #include <MVPbkContactGroup.h> |
|
38 #include <MVPbkContactLinkArray.h> |
|
39 |
|
40 #include "fscactionplugincrkeys.h" |
|
41 #include "cfscpocpluginimpl.h" |
|
42 // <cmail> |
|
43 #include "FscActionPluginUtils.h" |
|
44 // </cmail> |
|
45 |
|
46 // CONSTANTS DECLARATIONS |
|
47 const TInt KMaxLenghtOfAddressData = 255; |
|
48 const TInt KActionCount = 1; |
|
49 const TInt KInvalidReasonId = 0; |
|
50 const TInt KContactListGranularity = 2; |
|
51 |
|
52 _LIT( KPocPluginIconPath, "\\resource\\apps\\fscpocplugin.mif" ); |
|
53 _LIT( KResourceFilePath, "\\resource\\apps\\fscpocplugin.rsc" ); |
|
54 |
|
55 // typedef declarations |
|
56 typedef TBuf<KMaxLenghtOfAddressData> TAddressData; |
|
57 |
|
58 const TImplementationProxy ImplementationTable[] = |
|
59 { |
|
60 IMPLEMENTATION_PROXY_ENTRY( KFscPocPluginImplImpUid, |
|
61 CFscPocPluginImpl::NewL ) |
|
62 }; |
|
63 |
|
64 // ======== MEMBER FUNCTIONS ======== |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CFscPocPluginImpl::NewL |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 CFscPocPluginImpl* CFscPocPluginImpl::NewL(TAny* aParams) |
|
71 { |
|
72 FUNC_LOG; |
|
73 |
|
74 TFscContactActionPluginParams* params = |
|
75 reinterpret_cast< TFscContactActionPluginParams* >(aParams ); |
|
76 |
|
77 CFscPocPluginImpl* self = new( ELeave ) CFscPocPluginImpl( *params ); |
|
78 CleanupStack::PushL(self); |
|
79 self->ConstructL(); |
|
80 CleanupStack::Pop(self); |
|
81 return self; |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // CFscPocPluginImpl::~CFscPocPluginImpl |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 CFscPocPluginImpl::~CFscPocPluginImpl() |
|
89 { |
|
90 FUNC_LOG; |
|
91 delete iSelectedPhNumArray; |
|
92 delete iContactPttAction; |
|
93 delete iActionList; |
|
94 delete iAiwServiceHandler; |
|
95 CCoeEnv::Static()->DeleteResourceFile(iResourceHandle); |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // CFscPocPluginImpl::Uid |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 TUid CFscPocPluginImpl::Uid() const |
|
103 { |
|
104 FUNC_LOG; |
|
105 TUid uid = |
|
106 { |
|
107 KFscPocPluginImplImpUid |
|
108 }; |
|
109 return uid; |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // CFscPocPluginImpl::ActionList |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 const CArrayFix<TUid>* CFscPocPluginImpl::ActionList() const |
|
117 { |
|
118 return iActionList; |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // CFscPocPluginImpl::GetActionL |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 const MFscContactAction& CFscPocPluginImpl::GetActionL(TUid aActionUid) const |
|
126 { |
|
127 FUNC_LOG; |
|
128 |
|
129 const MFscContactAction* action= NULL; |
|
130 |
|
131 if (aActionUid == KFscActionUidCallPtt) |
|
132 { |
|
133 action = iContactPttAction; |
|
134 } |
|
135 else |
|
136 { |
|
137 User::Leave(KErrNotFound); |
|
138 } |
|
139 |
|
140 return *action; |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // CFscPocPluginImpl::PriorityForContactSetL |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 void CFscPocPluginImpl::PriorityForContactSetL(TUid aActionUid, |
|
148 MFscContactSet& aContactSet, |
|
149 TFscContactActionVisibility& aActionMenuVisibility, |
|
150 TFscContactActionVisibility& aOptionsMenuVisibility, |
|
151 MFscContactActionPluginObserver* aObserver) |
|
152 { |
|
153 FUNC_LOG; |
|
154 |
|
155 if (iLastEvent == EActionEventIdle) |
|
156 { |
|
157 // We are here for the first time, function called from client |
|
158 iExecute = EFalse; |
|
159 iActionUid = aActionUid; |
|
160 iContactSet = &aContactSet; |
|
161 iActionMenuVisibility = &aActionMenuVisibility; |
|
162 iOptionsMenuVisibility = &aOptionsMenuVisibility; |
|
163 iPluginObserver = aObserver; |
|
164 iLastEvent = EActionEventCanExecuteLaunched; |
|
165 CanExecuteL(aActionUid, *iContactSet); |
|
166 } |
|
167 else |
|
168 // function called by this class |
|
169 if (iLastEvent == EActionEventCanExecuteLaunched) |
|
170 { |
|
171 TInt actionPriority = KFscActionPriorityNotAvailable; |
|
172 if (iIsNmbAvailable) |
|
173 { |
|
174 actionPriority = iParams.iUtils->ActionPriority( |
|
175 KFscCrUidCallPtt, KFscActionPriorityCallPtt); |
|
176 aActionMenuVisibility.iVisibility |
|
177 = TFscContactActionVisibility::EFscActionVisible; |
|
178 aOptionsMenuVisibility.iVisibility |
|
179 = TFscContactActionVisibility::EFscActionVisible; |
|
180 } |
|
181 else |
|
182 { |
|
183 aActionMenuVisibility.iVisibility |
|
184 = TFscContactActionVisibility::EFscActionHidden; |
|
185 aActionMenuVisibility.iReasonId = KInvalidReasonId; |
|
186 aOptionsMenuVisibility.iVisibility |
|
187 = TFscContactActionVisibility::EFscActionHidden; |
|
188 aOptionsMenuVisibility.iReasonId = KInvalidReasonId; |
|
189 } |
|
190 if (actionPriority> 0) |
|
191 { |
|
192 // ignore any leave while updating action icons |
|
193 TRAP_IGNORE( UpdateActionIconL( aActionUid ) ); |
|
194 } |
|
195 ResetData(); |
|
196 iLastEvent = EActionEventIdle; |
|
197 iPluginObserver->PriorityForContactSetComplete(actionPriority); |
|
198 } |
|
199 |
|
200 } |
|
201 // --------------------------------------------------------------------------- |
|
202 // CFscPocPluginImpl::CancelPriorityForContactSet |
|
203 // --------------------------------------------------------------------------- |
|
204 // |
|
205 void CFscPocPluginImpl::CancelPriorityForContactSet() |
|
206 { |
|
207 FUNC_LOG; |
|
208 iLastEvent = EActionEventCanceled; |
|
209 ResetData(); |
|
210 } |
|
211 |
|
212 // --------------------------------------------------------------------------- |
|
213 // CFscPocPluginImpl::ExecuteL |
|
214 // --------------------------------------------------------------------------- |
|
215 // |
|
216 void CFscPocPluginImpl::ExecuteL(TUid aActionUid, |
|
217 MFscContactSet& aContactSet, |
|
218 MFscContactActionPluginObserver* aObserver) |
|
219 { |
|
220 FUNC_LOG; |
|
221 // No need to call CanExecuteL() |
|
222 // some cases like phone goes to offline mode |
|
223 // after opening the action menu, user shall be indicated |
|
224 if (aActionUid != KFscActionUidCallPtt) |
|
225 { |
|
226 ResetData(); |
|
227 aObserver->ExecuteFailed(KErrArgument); |
|
228 } |
|
229 else |
|
230 { |
|
231 iContactSet = &aContactSet; |
|
232 // We will switch to execution mode |
|
233 iExecute = ETrue; |
|
234 |
|
235 if (iLastEvent == EActionEventIdle) |
|
236 { |
|
237 iLastEvent = EActionEventExecuteLaunched; |
|
238 if (iContactSet) |
|
239 { |
|
240 iContactSet->SetToFirstContact(); |
|
241 iContactSet->SetToFirstGroup(); |
|
242 } |
|
243 if ( (iContactSet->ContactCount()> 0) |
|
244 && iContactSet->HasNextContact() ) |
|
245 { |
|
246 // First we will check if any contacts (not in groups) has POC nmb |
|
247 iContactSet->NextContactL(this); |
|
248 } |
|
249 else // Empty contact set is catched by CanExecuteL |
|
250 { |
|
251 iContactSet->NextGroupL(this); |
|
252 } |
|
253 } |
|
254 else |
|
255 { |
|
256 TInt executionStatus = KErrNone; |
|
257 // Checks should be in same order |
|
258 if ((iMissingCount > 0) && (iSelectedPhNumArray->Count() == 0 |
|
259 || !iParams.iUtils->ShowNumberMissingNoteL(iMissingCount, |
|
260 iSelectedPhNumArray->Count() + iMissingCount, |
|
261 R_FS_NOTE_NUMBER_MISSING, |
|
262 R_FS_NUMBER_MISSING_QUERY_DIALOG) )) |
|
263 { |
|
264 // user cancelled dialog |
|
265 executionStatus = KErrCancel; |
|
266 } |
|
267 else |
|
268 if (iSelectedPhNumArray->Count()> 0) |
|
269 { |
|
270 MakeAiwCallL(); |
|
271 } |
|
272 ResetData(); |
|
273 if ( executionStatus == KErrCancel ) |
|
274 { |
|
275 aObserver->ExecuteFailed( executionStatus ); |
|
276 } |
|
277 else |
|
278 { |
|
279 aObserver->ExecuteComplete(); |
|
280 } |
|
281 } |
|
282 } |
|
283 } |
|
284 |
|
285 // --------------------------------------------------------------------------- |
|
286 // CFscPocPluginImpl::CancelExecute |
|
287 // --------------------------------------------------------------------------- |
|
288 // |
|
289 void CFscPocPluginImpl::CancelExecute() |
|
290 { |
|
291 FUNC_LOG; |
|
292 // close popup window for selecting number if opened |
|
293 TRAPD( err, iParams.iUtils->CloseSelectDialogL() ); |
|
294 |
|
295 if ( err != KErrNone ) |
|
296 { |
|
297 CCoeEnv::Static()->HandleError( err ); |
|
298 } |
|
299 |
|
300 iLastEvent = EActionEventCanceled; |
|
301 ResetData(); |
|
302 } |
|
303 |
|
304 // --------------------------------------------------------------------------- |
|
305 // CFscPocPluginImpl::GetReasonL |
|
306 // --------------------------------------------------------------------------- |
|
307 // |
|
308 void CFscPocPluginImpl::GetReasonL(TUid /* aActionUid */, |
|
309 TInt /* aReasonId */, HBufC*& /* aReason */) const |
|
310 { |
|
311 FUNC_LOG; |
|
312 } |
|
313 |
|
314 // --------------------------------------------------------------------------- |
|
315 // CFscPocPluginImpl::MakeAiwCallL |
|
316 // --------------------------------------------------------------------------- |
|
317 // |
|
318 void CFscPocPluginImpl::MakeAiwCallL() |
|
319 { |
|
320 FUNC_LOG; |
|
321 |
|
322 TAiwPocParameterData pocParameter; |
|
323 TUid uid = |
|
324 { |
|
325 KFscPocPluginImplImpUid |
|
326 }; |
|
327 pocParameter.iConsumerAppUid = uid; |
|
328 pocParameter.iConsumerWindowGroup = CCoeEnv::Static()->RootWin().Identifier(); |
|
329 |
|
330 if (iSelectedPhNumArray->Count() == 1) |
|
331 { |
|
332 pocParameter.iCommandId = EAiwPoCCmdTalk1to1; |
|
333 } |
|
334 else |
|
335 { |
|
336 pocParameter.iCommandId = EAiwPoCCmdTalkMany; |
|
337 } |
|
338 |
|
339 TAiwGenericParam param = TAiwGenericParam(EGenericParamPoCData, |
|
340 TAiwVariant(TAiwPocParameterDataPckg(pocParameter) ) ); |
|
341 |
|
342 CAiwGenericParamList* inParamList = CAiwGenericParamList::NewLC(); |
|
343 inParamList->AppendL(param); |
|
344 |
|
345 // Address params packing as phone number |
|
346 for (TInt i = 0; i < iSelectedPhNumArray->Count(); ++i) |
|
347 { |
|
348 TAiwGenericParam phNum = TAiwGenericParam(EGenericParamPhoneNumber, |
|
349 TAiwVariant(( *iSelectedPhNumArray )[i]) ); |
|
350 inParamList->AppendL(phNum); |
|
351 } |
|
352 |
|
353 iAiwServiceHandler->ExecuteServiceCmdL(KAiwCmdPoC, *inParamList, |
|
354 iAiwServiceHandler->OutParamListL() ); |
|
355 |
|
356 CleanupStack::PopAndDestroy(inParamList); |
|
357 |
|
358 } |
|
359 |
|
360 // --------------------------------------------------------------------------- |
|
361 // CFscPocPluginImpl::CanExecuteL |
|
362 // --------------------------------------------------------------------------- |
|
363 // |
|
364 void CFscPocPluginImpl::CanExecuteL(TUid aActionUid, |
|
365 MFscContactSet& aContactSet) |
|
366 { |
|
367 FUNC_LOG; |
|
368 if (aActionUid != KFscActionUidCallPtt) |
|
369 { |
|
370 ResetData(); |
|
371 iPluginObserver->PriorityForContactSetFailed(KErrArgument); |
|
372 } |
|
373 else |
|
374 { |
|
375 iContactSet = &aContactSet; |
|
376 if (iParams.iUtils->IsOfflineModeL() |
|
377 || !iParams.iUtils->IsPttConfiguredL() ) |
|
378 { |
|
379 // Call PriorityForContactSetL to set ActionMenuPriority and call the client |
|
380 if (iLastEvent == EActionEventCanExecuteLaunched) |
|
381 { |
|
382 PriorityForContactSetL(aActionUid, *iContactSet, |
|
383 *iActionMenuVisibility, *iOptionsMenuVisibility, |
|
384 iPluginObserver); |
|
385 return; |
|
386 } |
|
387 } |
|
388 |
|
389 if (iContactSet) |
|
390 { |
|
391 iContactSet->SetToFirstContact(); |
|
392 iContactSet->SetToFirstGroup(); |
|
393 } |
|
394 |
|
395 // Check if any contacts exists (also in groups) |
|
396 if ( (iContactSet->ContactCount() > 0) |
|
397 && iContactSet->HasNextContact() ) |
|
398 { |
|
399 // First we will check if any contacts (not in groups) has POC nmb |
|
400 iContactSet->NextContactL(this); |
|
401 } |
|
402 else |
|
403 if ( (iContactSet->GroupCount()> 0) |
|
404 && iContactSet->HasNextGroup() ) |
|
405 { |
|
406 iContactSet->NextGroupL(this); |
|
407 } |
|
408 else |
|
409 { |
|
410 //no contacts, no groups => empty contact set, no actions available |
|
411 PriorityForContactSetL(aActionUid, *iContactSet, |
|
412 *iActionMenuVisibility, *iOptionsMenuVisibility, |
|
413 iPluginObserver); |
|
414 } |
|
415 } |
|
416 } |
|
417 |
|
418 // --------------------------------------------------------------------------- |
|
419 // void CFscPocPluginImpl::UpdateActionIconL |
|
420 // --------------------------------------------------------------------------- |
|
421 // |
|
422 void CFscPocPluginImpl::UpdateActionIconL(TUid aActionUid) |
|
423 { |
|
424 FUNC_LOG; |
|
425 |
|
426 TFileName dllFileName; |
|
427 Dll::FileName(dllFileName); |
|
428 TParse parse; |
|
429 User::LeaveIfError(parse.Set(KPocPluginIconPath, &dllFileName, NULL) ); |
|
430 |
|
431 if (aActionUid == KFscActionUidCallPtt) |
|
432 { |
|
433 // <cmail> icons changed |
|
434 iContactPttAction->SetIcon(iParams.iUtils->SkinIconL( |
|
435 KAknsIIDQgnFsActionPtt, parse.FullName(), |
|
436 EMbmFscpocpluginQgn_prop_cmail_action_ptt, |
|
437 EMbmFscpocpluginQgn_prop_cmail_action_ptt_mask) ); |
|
438 // </cmail> |
|
439 } |
|
440 |
|
441 } |
|
442 |
|
443 // --------------------------------------------------------------------------- |
|
444 // CFscPocPluginImpl::CFscPocPluginImpl |
|
445 // --------------------------------------------------------------------------- |
|
446 // |
|
447 CFscPocPluginImpl::CFscPocPluginImpl( |
|
448 const TFscContactActionPluginParams& aParams) : |
|
449 CFscContactActionPlugin(), iParams(aParams), iResourceHandle( 0), |
|
450 iMissingCount( 0), iExecute(EFalse), |
|
451 iLastEvent(EActionEventIdle), iSCInGroup( 0), |
|
452 iIsNmbAvailable(EFalse), iGroupIndex(0) |
|
453 { |
|
454 FUNC_LOG; |
|
455 } |
|
456 |
|
457 // --------------------------------------------------------------------------- |
|
458 // CFscPocPluginImpl::ConstructL |
|
459 // --------------------------------------------------------------------------- |
|
460 // |
|
461 void CFscPocPluginImpl::ConstructL() |
|
462 { |
|
463 FUNC_LOG; |
|
464 TFileName dllFileName; |
|
465 Dll::FileName(dllFileName); |
|
466 TParse parse; |
|
467 User::LeaveIfError(parse.Set(KResourceFilePath, &dllFileName, NULL) ); |
|
468 TFileName resourceFileName(parse.FullName() ); |
|
469 BaflUtils::NearestLanguageFile(CCoeEnv::Static()->FsSession(), resourceFileName); |
|
470 |
|
471 iResourceHandle = ( CCoeEnv::Static() )->AddResourceFileL(resourceFileName); |
|
472 |
|
473 iActionList = new( ELeave ) CArrayFixFlat<TUid>( KActionCount ); |
|
474 iActionList->AppendL(KFscActionUidCallPtt); |
|
475 |
|
476 User::LeaveIfError(parse.Set(KPocPluginIconPath, &dllFileName, NULL) ); |
|
477 iContactPttAction = iParams.iUtils->CreateActionL( *this, |
|
478 KFscActionUidCallPtt, KFscAtComCallPoc, R_FS_ACTION_PTT, |
|
479 iParams.iUtils->SkinIconL(KAknsIIDQgnFsActionPtt, |
|
480 parse.FullName(), EMbmFscpocpluginQgn_prop_cmail_action_ptt, |
|
481 EMbmFscpocpluginQgn_prop_cmail_action_ptt_mask) ); |
|
482 |
|
483 iAiwServiceHandler = CAiwServiceHandler::NewL(); |
|
484 iAiwServiceHandler->AttachL(R_POC_AIW_INTEREST); |
|
485 iSelectedPhNumArray = new ( ELeave ) CDesCArraySeg( KContactListGranularity ); |
|
486 |
|
487 } |
|
488 |
|
489 // --------------------------------------------------------------------------- |
|
490 // CFscPocPluginImpl::NextContactComplete |
|
491 // --------------------------------------------------------------------------- |
|
492 // |
|
493 void CFscPocPluginImpl::NextContactComplete(MVPbkStoreContact* aContact) |
|
494 { |
|
495 FUNC_LOG; |
|
496 |
|
497 TRAPD( err, ProcessContactL( aContact ) ); |
|
498 if ( err != KErrNone ) |
|
499 { |
|
500 CCoeEnv::Static()->HandleError( err ); |
|
501 } |
|
502 |
|
503 } |
|
504 |
|
505 // --------------------------------------------------------------------------- |
|
506 // CFscPocPluginImpl::NextContactFailed |
|
507 // --------------------------------------------------------------------------- |
|
508 // |
|
509 void CFscPocPluginImpl::NextContactFailed(TInt aError) |
|
510 { |
|
511 FUNC_LOG; |
|
512 ResetData(); |
|
513 if (iExecute) |
|
514 { |
|
515 iPluginObserver->ExecuteFailed(aError); |
|
516 } |
|
517 else |
|
518 { |
|
519 iPluginObserver->PriorityForContactSetFailed(aError); |
|
520 } |
|
521 } |
|
522 |
|
523 // --------------------------------------------------------------------------- |
|
524 // CFscPocPluginImpl::NextGroupComplete |
|
525 // --------------------------------------------------------------------------- |
|
526 // |
|
527 void CFscPocPluginImpl::NextGroupComplete(MVPbkStoreContact* aContact) |
|
528 { |
|
529 FUNC_LOG; |
|
530 |
|
531 TRAPD( err, ProcessGroupL( aContact ) ); |
|
532 if ( err != KErrNone ) |
|
533 { |
|
534 CCoeEnv::Static()->HandleError( err ); |
|
535 } |
|
536 } |
|
537 |
|
538 // --------------------------------------------------------------------------- |
|
539 // CFscPocPluginImpl::NextGroupFailed |
|
540 // --------------------------------------------------------------------------- |
|
541 // |
|
542 void CFscPocPluginImpl::NextGroupFailed(TInt aError) |
|
543 { |
|
544 FUNC_LOG; |
|
545 ResetData(); |
|
546 if (iExecute) |
|
547 { |
|
548 iPluginObserver->ExecuteFailed(aError); |
|
549 } |
|
550 else |
|
551 { |
|
552 iPluginObserver->PriorityForContactSetFailed(aError); |
|
553 } |
|
554 } |
|
555 // --------------------------------------------------------------------------- |
|
556 // CFscPocPluginImpl::GetGroupContactComplete |
|
557 // --------------------------------------------------------------------------- |
|
558 // |
|
559 void CFscPocPluginImpl::GetGroupContactComplete(MVPbkStoreContact* aContact) |
|
560 { |
|
561 FUNC_LOG; |
|
562 TRAPD( err, ProcessGroupContactL( aContact ) ); |
|
563 if ( err != KErrNone ) |
|
564 { |
|
565 CCoeEnv::Static()->HandleError( err ); |
|
566 } |
|
567 } |
|
568 |
|
569 // --------------------------------------------------------------------------- |
|
570 // CFscPocPluginImpl::GetGroupContactFailed |
|
571 // --------------------------------------------------------------------------- |
|
572 // |
|
573 void CFscPocPluginImpl::GetGroupContactFailed(TInt aError) |
|
574 { |
|
575 FUNC_LOG; |
|
576 ResetData(); |
|
577 if (iExecute) |
|
578 { |
|
579 iPluginObserver->ExecuteFailed(aError); |
|
580 } |
|
581 else |
|
582 { |
|
583 iPluginObserver->PriorityForContactSetFailed(aError); |
|
584 } |
|
585 } |
|
586 |
|
587 // --------------------------------------------------------------------------- |
|
588 // CFscPocPluginImpl::ResetData() |
|
589 // --------------------------------------------------------------------------- |
|
590 // |
|
591 void CFscPocPluginImpl::ResetData() |
|
592 { |
|
593 FUNC_LOG; |
|
594 if (iSelectedPhNumArray->Count()) |
|
595 { |
|
596 iSelectedPhNumArray->Reset(); |
|
597 } |
|
598 if ( iContactSet ) |
|
599 { |
|
600 iContactSet->SetToFirstContact(); |
|
601 iContactSet->SetToFirstGroup(); |
|
602 TRAP_IGNORE( iContactSet->CancelNextContactL() ); |
|
603 TRAP_IGNORE( iContactSet->CancelNextGroupL() ); |
|
604 iContactSet = NULL; |
|
605 } |
|
606 iLastEvent = EActionEventIdle; |
|
607 iMissingCount = 0; |
|
608 iSCInGroup = 0; |
|
609 iGroup = NULL; |
|
610 iIsNmbAvailable = EFalse; |
|
611 iGroupIndex = 0; |
|
612 } |
|
613 |
|
614 // --------------------------------------------------------------------------- |
|
615 // CFscPocPluginImpl::ProcessContactL() |
|
616 // --------------------------------------------------------------------------- |
|
617 // |
|
618 void CFscPocPluginImpl::ProcessContactL( MVPbkStoreContact* aContact ) |
|
619 { |
|
620 FUNC_LOG; |
|
621 TAddressData addressData; |
|
622 addressData.Zero(); |
|
623 TInt ret = KErrNone; |
|
624 |
|
625 if (iExecute) |
|
626 { |
|
627 MVPbkContactLinkArray* linkArray = aContact->GroupsJoinedLC(); |
|
628 TBool found = EFalse; |
|
629 |
|
630 if (linkArray->Count() > 0 && iContactSet->HasNextGroup() ) |
|
631 { |
|
632 while (iContactSet->HasNextGroup() && !found) |
|
633 { |
|
634 if (linkArray->Find( *iContactSet->NextGroupLinkL() ) |
|
635 != KErrNotFound) |
|
636 { |
|
637 found = ETrue; |
|
638 } |
|
639 } |
|
640 |
|
641 iContactSet->SetToFirstGroup(); |
|
642 } |
|
643 |
|
644 CleanupStack::PopAndDestroy(); // linkArray |
|
645 |
|
646 if (!found) |
|
647 { |
|
648 iIsNmbAvailable = iParams.iUtils->IsContactNumberAvailableL(*aContact, |
|
649 ETypePttNumber); |
|
650 if (iIsNmbAvailable) |
|
651 { |
|
652 ret = iParams.iUtils->GetPocAddressL( *aContact, addressData); |
|
653 if ((ret == KErrNone) && (addressData.Length()> 0 )) |
|
654 { |
|
655 iSelectedPhNumArray->AppendL(addressData); |
|
656 } |
|
657 else |
|
658 { |
|
659 iSelectedPhNumArray->Reset(); |
|
660 ExecuteL(iActionUid, *iContactSet, iPluginObserver); |
|
661 } |
|
662 } |
|
663 else |
|
664 { |
|
665 iMissingCount++; |
|
666 } |
|
667 } |
|
668 // Check next contact if everything went ok earlier |
|
669 if(ret == KErrNone) |
|
670 { |
|
671 if (iContactSet->HasNextContact() ) |
|
672 { |
|
673 iContactSet->NextContactL(this); |
|
674 } |
|
675 else // Check if there is another group with store contacts |
|
676 { |
|
677 if (iContactSet->HasNextGroup() ) |
|
678 { |
|
679 iContactSet->NextGroupL(this); |
|
680 } |
|
681 else //no more contacts with POC number |
|
682 { |
|
683 ExecuteL(iActionUid, *iContactSet, iPluginObserver); |
|
684 } |
|
685 } |
|
686 } |
|
687 } |
|
688 else // iExecute == EFalse |
|
689 { |
|
690 iIsNmbAvailable = iParams.iUtils->IsContactNumberAvailableL(*aContact, |
|
691 ETypePttNumber); |
|
692 if (iIsNmbAvailable) |
|
693 { |
|
694 PriorityForContactSetL(iActionUid, *iContactSet, |
|
695 *iActionMenuVisibility, *iOptionsMenuVisibility, |
|
696 iPluginObserver); |
|
697 } |
|
698 else |
|
699 { |
|
700 // Check if another contact from that group has a POC address |
|
701 if (iContactSet->HasNextContact() ) |
|
702 { |
|
703 iContactSet->NextContactL(this); |
|
704 } |
|
705 else // Check if there is another group with store contacts |
|
706 { |
|
707 if (iContactSet->HasNextGroup() ) |
|
708 { |
|
709 iContactSet->NextGroupL(this); |
|
710 } |
|
711 else //no more contacts with POC number |
|
712 { |
|
713 PriorityForContactSetL(iActionUid, *iContactSet, |
|
714 *iActionMenuVisibility, *iOptionsMenuVisibility, |
|
715 iPluginObserver); |
|
716 } |
|
717 } |
|
718 } |
|
719 } |
|
720 } |
|
721 |
|
722 // --------------------------------------------------------------------------- |
|
723 // CFscPocPluginImpl::ProcessGroupL() |
|
724 // --------------------------------------------------------------------------- |
|
725 // |
|
726 void CFscPocPluginImpl::ProcessGroupL( MVPbkStoreContact* aContact ) |
|
727 { |
|
728 FUNC_LOG; |
|
729 // just in case |
|
730 iSCInGroup = 0; |
|
731 iGroupIndex++; |
|
732 iGroup = aContact; |
|
733 |
|
734 if ( iContactSet->GroupContactCountL( *iGroup )> 0 ) |
|
735 { |
|
736 iContactSet->GetGroupContactL( *iGroup, iSCInGroup++, this ); |
|
737 } |
|
738 else |
|
739 { |
|
740 // in case that we have group without contacts |
|
741 if ( iContactSet->HasNextGroup() ) |
|
742 { |
|
743 iContactSet->NextGroupL(this); |
|
744 } |
|
745 else |
|
746 { |
|
747 if ( iExecute ) |
|
748 { |
|
749 ExecuteL( iActionUid, *iContactSet, iPluginObserver ); |
|
750 } |
|
751 else |
|
752 { |
|
753 PriorityForContactSetL( iActionUid, *iContactSet, |
|
754 *iActionMenuVisibility, *iOptionsMenuVisibility, |
|
755 iPluginObserver ); |
|
756 } |
|
757 } |
|
758 } |
|
759 } |
|
760 |
|
761 // --------------------------------------------------------------------------- |
|
762 // CFscPocPluginImpl::ProcessGroupContactL() |
|
763 // --------------------------------------------------------------------------- |
|
764 // |
|
765 void CFscPocPluginImpl::ProcessGroupContactL( MVPbkStoreContact* aContact ) |
|
766 { |
|
767 FUNC_LOG; |
|
768 TAddressData addressData; |
|
769 aContact->PushL(); |
|
770 addressData.Zero(); |
|
771 TInt ret = KErrNone; |
|
772 |
|
773 if ( iExecute ) |
|
774 { |
|
775 // Check if contact belongs to other gruops, if yes -> ignore it |
|
776 MVPbkContactLinkArray* linkArray = aContact->GroupsJoinedLC(); |
|
777 TInt linkArrayCount = linkArray->Count(); |
|
778 |
|
779 TBool found = EFalse; |
|
780 TBool isChanged = EFalse; |
|
781 if ( linkArrayCount > 0 && iContactSet->HasNextGroup() ) |
|
782 { |
|
783 while ( iContactSet->HasNextGroup() && !found ) |
|
784 { |
|
785 isChanged = ETrue; |
|
786 if ( linkArray->Find( *iContactSet->NextGroupLinkL() ) |
|
787 != KErrNotFound) |
|
788 { |
|
789 found = ETrue; |
|
790 } |
|
791 } |
|
792 |
|
793 if ( isChanged ) |
|
794 { |
|
795 //if iterator moved |
|
796 TInt aIndex = iGroupIndex-1; |
|
797 iContactSet->SetToFirstGroup(); |
|
798 //move iterator to specified index |
|
799 while ( iContactSet->HasNextGroup() && aIndex-- > 0 ) |
|
800 { |
|
801 iContactSet->NextGroupLinkL(); |
|
802 } |
|
803 } |
|
804 } |
|
805 CleanupStack::PopAndDestroy(); //linkArray |
|
806 if ( !found ) |
|
807 { |
|
808 iIsNmbAvailable = iParams.iUtils->IsContactNumberAvailableL( |
|
809 *aContact, ETypePttNumber ); |
|
810 if ( iIsNmbAvailable ) |
|
811 { |
|
812 ret = iParams.iUtils->GetPocAddressL( *aContact, addressData); |
|
813 if ( ( ret == KErrNone ) && ( addressData.Length() > 0 ) ) |
|
814 { |
|
815 iSelectedPhNumArray->AppendL( addressData ); |
|
816 } |
|
817 else |
|
818 { |
|
819 iSelectedPhNumArray->Reset(); |
|
820 ExecuteL( iActionUid, *iContactSet, iPluginObserver ); |
|
821 } |
|
822 } |
|
823 else |
|
824 { |
|
825 iMissingCount++; |
|
826 } |
|
827 } |
|
828 // Check if another contact from that group has a POC address |
|
829 if( ret == KErrNone ) |
|
830 { |
|
831 if ( iContactSet->GroupContactCountL(*iGroup) > iSCInGroup ) |
|
832 { |
|
833 iContactSet->GetGroupContactL( *iGroup, iSCInGroup++, this ); |
|
834 } |
|
835 else |
|
836 { |
|
837 // Check if there is another group with store contacts |
|
838 if ( iContactSet->HasNextGroup() ) |
|
839 { |
|
840 iContactSet->NextGroupL( this ); |
|
841 } |
|
842 else //no more contacts with POC number |
|
843 { |
|
844 ExecuteL( iActionUid, *iContactSet, iPluginObserver ); |
|
845 } |
|
846 } |
|
847 } |
|
848 } |
|
849 else // iExecute == EFalse |
|
850 { |
|
851 iIsNmbAvailable = iParams.iUtils->IsContactNumberAvailableL( |
|
852 *aContact, |
|
853 ETypePttNumber ); |
|
854 if ( iIsNmbAvailable ) |
|
855 { |
|
856 PriorityForContactSetL( iActionUid, *iContactSet, |
|
857 *iActionMenuVisibility, *iOptionsMenuVisibility, |
|
858 iPluginObserver ); |
|
859 } |
|
860 else |
|
861 { |
|
862 // Check if another contact from that group has a POC address |
|
863 if ( iContactSet->GroupContactCountL(*iGroup) > iSCInGroup ) |
|
864 { |
|
865 iContactSet->GetGroupContactL( *iGroup, iSCInGroup++, this ); |
|
866 } |
|
867 else // Check if there is another group with store contacts |
|
868 { |
|
869 if ( iContactSet->HasNextGroup() ) |
|
870 { |
|
871 iContactSet->NextGroupL( this ); |
|
872 } |
|
873 else //no more contacts with POC number |
|
874 { |
|
875 PriorityForContactSetL( iActionUid, *iContactSet, |
|
876 *iActionMenuVisibility, *iOptionsMenuVisibility, |
|
877 iPluginObserver ); |
|
878 } |
|
879 } |
|
880 } |
|
881 } |
|
882 CleanupStack::PopAndDestroy(); //aContact |
|
883 } |
|
884 |
|
885 // ======== GLOBAL FUNCTIONS ======== |
|
886 |
|
887 // --------------------------------------------------------------------------- |
|
888 // ImplementationGroupProxy |
|
889 // --------------------------------------------------------------------------- |
|
890 // |
|
891 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( |
|
892 TInt& aTableCount ) |
|
893 { |
|
894 aTableCount = |
|
895 sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); |
|
896 return ImplementationTable; |
|
897 } |
|
898 |