|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * Provides Contact List app views class methods. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CPbkContactListAppView.h" |
|
22 |
|
23 #include "CPbkAppUi.h" |
|
24 #include "CPbkAppGlobals.h" |
|
25 |
|
26 #include <PbkUID.h> |
|
27 #include <CPbkContactEngine.h> |
|
28 #include <CPbkContactItem.h> |
|
29 #include <PbkCommandHandler.h> |
|
30 #include <MPbkCommand.h> |
|
31 #include <MPbkCommandObserver.h> |
|
32 #include <MPbkCommandFactory.h> |
|
33 #include <CPbkContactViewListControl.h> |
|
34 #include <CPbkPhoneNumberSelect.h> |
|
35 #include <CPbkGroupBelongings.h> |
|
36 #include <CPbkConstants.h> |
|
37 #include <Phonebook.rsg> // Phonebook resources |
|
38 #include <MenuFilteringFlags.h> |
|
39 #include <CPbkAiwInterestArray.h> |
|
40 |
|
41 #include <eikmenup.h> |
|
42 #include <sendui.h> // Send UI API |
|
43 #include <SenduiMtmUids.h> // Send UI MTM uids |
|
44 #include <CMessageData.h> |
|
45 #include <MsgBioUids.h> // Bio message uids |
|
46 #include <AiwServiceHandler.h> // AIW |
|
47 #include <AiwCommon.hrh> // AIW |
|
48 #include <SendUiConsts.h> // Postcard Uid |
|
49 #include <FeatMgr.h> // Feature manager |
|
50 |
|
51 // Debugging headers |
|
52 #include <pbkdebug.h> |
|
53 #include "PbkProfiling.h" |
|
54 |
|
55 // Local declarations |
|
56 /* |
|
57 * Local helper class to clear marked list if command is succesfull |
|
58 * Can only be used if command is not using the default command observer |
|
59 */ |
|
60 class TClearMarks : public MPbkCommandObserver |
|
61 { |
|
62 public: |
|
63 TClearMarks( CPbkContactViewListControl& aControl ); |
|
64 |
|
65 public: // MPbkCommandObserver |
|
66 void CommandFinished(const MPbkCommand& aCommand); |
|
67 |
|
68 private: |
|
69 CPbkContactViewListControl& iControl; |
|
70 }; |
|
71 |
|
72 TClearMarks::TClearMarks( CPbkContactViewListControl& aControl ) : |
|
73 iControl( aControl ) |
|
74 { |
|
75 |
|
76 } |
|
77 |
|
78 void TClearMarks::CommandFinished(const MPbkCommand& /*aCommand*/) |
|
79 { |
|
80 iControl.HandleMarkableListUpdateAfterCommandExecution(); |
|
81 } |
|
82 |
|
83 // ================= MEMBER FUNCTIONS ======================= |
|
84 |
|
85 CPbkContactListAppView::CPbkContactListAppView() |
|
86 { |
|
87 } |
|
88 |
|
89 CPbkContactListAppView::~CPbkContactListAppView() |
|
90 { |
|
91 } |
|
92 |
|
93 void CPbkContactListAppView::BaseConstructL(TInt aResId) |
|
94 { |
|
95 __PBK_PROFILE_START(PbkProfiling::EViewBaseConstruct); |
|
96 CPbkAppView::BaseConstructL(aResId); |
|
97 __PBK_PROFILE_END(PbkProfiling::EViewBaseConstruct); |
|
98 |
|
99 // Create AIW interest array for call |
|
100 CreateInterestItemAndAttachL(KAiwCmdCall, |
|
101 R_PHONEBOOK_CALL_MENU, R_PHONEBOOK_CALLUI_AIW_INTEREST, ETrue); |
|
102 |
|
103 // Create AIW interest array for PoC |
|
104 CreateInterestItemAndAttachL(KAiwCmdPoC, |
|
105 R_PHONEBOOK_POC_MENU, R_PHONEBOOK_POCUI_AIW_INTEREST, ETrue); |
|
106 // The last parameter is false, since KAiwCmdPoC is already attached |
|
107 // to base services above |
|
108 CreateInterestItemAndAttachL(KAiwCmdPoC, |
|
109 R_PHONEBOOK_POC_CONTEXT_MENU, R_PHONEBOOK_POCUI_AIW_INTEREST, EFalse); |
|
110 |
|
111 // Create AIW interest array for synchronization |
|
112 CreateInterestItemAndAttachL(KAiwCmdSynchronize, |
|
113 R_PHONEBOOK_SYNCML_MENU, R_PHONEBOOK_SYNCML_AIW_INTEREST, ETrue); |
|
114 } |
|
115 |
|
116 void CPbkContactListAppView::CmdOpenMeViewsL() |
|
117 { |
|
118 if (!Control().ItemsMarked()) |
|
119 { |
|
120 CPbkViewState* state = Control().GetStateLC(); |
|
121 PbkAppUi()->ActivatePhonebookViewL(CPbkAppUi::KPbkContactInfoViewUid, state); |
|
122 CleanupStack::PopAndDestroy(); // state |
|
123 Control().HandleMarkableListUpdateAfterCommandExecution(); |
|
124 } |
|
125 } |
|
126 |
|
127 void CPbkContactListAppView::CmdWriteToContactsL( |
|
128 TPbkSendingParams aParams ) |
|
129 { |
|
130 const CContactIdArray& array = Control().MarkedItemsL(); |
|
131 if ( array.Count() > 0 ) |
|
132 { |
|
133 // Create the write message command object |
|
134 MPbkCommand* cmd = CPbkAppGlobalsBase::InstanceL()-> |
|
135 CommandFactory().CreateSendMultipleMessageCmdL( |
|
136 *Engine(), |
|
137 aParams, |
|
138 array, |
|
139 NULL, |
|
140 ETrue); |
|
141 TClearMarks clearMarks( Control() ); |
|
142 cmd->AddObserver( clearMarks ); |
|
143 // Execute the command |
|
144 cmd->ExecuteLD(); |
|
145 |
|
146 Control().ResetFindL(); |
|
147 TInt idx = Control().FindContactIdL(array[0]); |
|
148 if (idx >= 0) |
|
149 { |
|
150 Control().SetCurrentItemIndexAndDraw(idx); |
|
151 } |
|
152 } |
|
153 } |
|
154 |
|
155 void CPbkContactListAppView::CmdSendContactsL( |
|
156 TPbkSendingParams aParams ) |
|
157 { |
|
158 CPbkContactViewListControl& control = Control(); |
|
159 |
|
160 const TContactItemId focusedContactId = control.FocusedContactIdL(); |
|
161 TInt focusedContactIndex( control.FindContactIdL(focusedContactId) ); |
|
162 |
|
163 if (control.ItemsMarked()) |
|
164 { |
|
165 // Get the contact ids in an array |
|
166 const CContactIdArray& array = control.MarkedItemsL(); |
|
167 // Create the send contacts command object |
|
168 MPbkCommand* cmd = CPbkAppGlobalsBase::InstanceL()-> |
|
169 CommandFactory().CreateSendContactsCmdL( |
|
170 aParams, *Engine(), |
|
171 CPbkAppGlobals::InstanceL()->BCardEngL(*Engine()), array); |
|
172 TClearMarks clearMarks( control ); |
|
173 cmd->AddObserver( clearMarks ); |
|
174 // Execute the command |
|
175 cmd->ExecuteLD(); |
|
176 } |
|
177 else |
|
178 { |
|
179 if (focusedContactId != KNullContactId) |
|
180 { |
|
181 // Create the send contact command object |
|
182 MPbkCommand* cmd = CPbkAppGlobalsBase::InstanceL()-> |
|
183 CommandFactory().CreateSendContactCmdL( |
|
184 aParams, *Engine(), |
|
185 CPbkAppGlobals::InstanceL()->BCardEngL(*Engine()), |
|
186 focusedContactId, NULL); |
|
187 // Execute the command |
|
188 cmd->ExecuteLD(); |
|
189 } |
|
190 } |
|
191 |
|
192 // reset find filter and focus to (first) sent contact |
|
193 |
|
194 if ( control.FindTextL() != KNullDesC ) |
|
195 { |
|
196 control.ResetFindL(); |
|
197 focusedContactIndex = control.FindContactIdL(focusedContactId); |
|
198 } |
|
199 |
|
200 if (focusedContactIndex >= 0) |
|
201 { |
|
202 control.SetCurrentItemIndexAndDraw(focusedContactIndex); |
|
203 } |
|
204 } |
|
205 |
|
206 void CPbkContactListAppView::CmdBelongsToGroupsL() |
|
207 { |
|
208 if (!Control().ItemsMarked()) |
|
209 { |
|
210 const TContactItemId contactId = Control().FocusedContactIdL(); |
|
211 CPbkGroupBelongings* dlg = CPbkGroupBelongings::NewL(); |
|
212 dlg->ExecuteLD(*Engine(), contactId); |
|
213 Control().HandleMarkableListUpdateAfterCommandExecution(); |
|
214 } |
|
215 } |
|
216 |
|
217 void CPbkContactListAppView::HandleCommandL |
|
218 (TInt aCommandId) |
|
219 { |
|
220 // MarkedItemsL() might leave on low-mem situation |
|
221 const CContactIdArray* items = NULL; |
|
222 TRAPD(err, items = &Control().MarkedItemsL()); |
|
223 if (!err && items) |
|
224 { |
|
225 // Offer the command first to AIW |
|
226 TInt serviceCmdId = KNullHandle; |
|
227 if (!Control().ItemsMarked()) |
|
228 { |
|
229 if (aCommandId == EPbkCmdCall) |
|
230 { |
|
231 serviceCmdId = KAiwCmdCall; |
|
232 } |
|
233 else if ( aCommandId == EPbkCmdPoc ) |
|
234 { |
|
235 serviceCmdId = KAiwCmdPoC; |
|
236 } |
|
237 } |
|
238 |
|
239 if(iAiwInterestArray->HandleCommandL( |
|
240 aCommandId, |
|
241 *items, |
|
242 NULL, // no field level focus |
|
243 serviceCmdId, |
|
244 this)) |
|
245 { |
|
246 return; |
|
247 } |
|
248 } |
|
249 |
|
250 // Try as normal command |
|
251 switch (aCommandId) |
|
252 { |
|
253 case EPbkCmdOpenMeViews: |
|
254 { |
|
255 CmdOpenMeViewsL(); |
|
256 break; |
|
257 } |
|
258 |
|
259 case EPbkCmdBelongsToGroups: |
|
260 { |
|
261 CmdBelongsToGroupsL(); |
|
262 break; |
|
263 } |
|
264 case EPbkCmdWrite: |
|
265 { |
|
266 TPbkSendingParams params = CreateWriteParamsLC(); |
|
267 |
|
268 PbkAppUi()->FFSClCheckL(PbkCommandHandler(this, |
|
269 &CPbkContactListAppView::CmdWriteToContactsL, |
|
270 params )); |
|
271 |
|
272 CleanupStack::PopAndDestroy(); //mtmFilter |
|
273 break; |
|
274 } |
|
275 default: |
|
276 { |
|
277 Control().HandleMarkableListProcessCommandL(aCommandId); |
|
278 CPbkAppView::HandleCommandL(aCommandId); |
|
279 break; |
|
280 } |
|
281 |
|
282 } |
|
283 } |
|
284 |
|
285 /** |
|
286 * Returns ETrue if shift is depressed in aKeyEvent. |
|
287 */ |
|
288 inline TBool ShiftDown |
|
289 (const TKeyEvent& aKeyEvent) |
|
290 { |
|
291 return (aKeyEvent.iModifiers & (EModifierShift|EModifierLeftShift|EModifierRightShift)) != 0; |
|
292 } |
|
293 |
|
294 /** |
|
295 * Returns ETrue if shift is depressed in aKeyEvent. |
|
296 */ |
|
297 inline TBool CtrlDown |
|
298 (const TKeyEvent& aKeyEvent) |
|
299 { |
|
300 return (aKeyEvent.iModifiers & (EModifierCtrl|EModifierLeftCtrl|EModifierRightCtrl)) != 0; |
|
301 } |
|
302 |
|
303 TBool CPbkContactListAppView::HandleCommandKeyL |
|
304 (const TKeyEvent& aKeyEvent, |
|
305 TEventCode aType) |
|
306 { |
|
307 TBool result = EFalse; |
|
308 |
|
309 if (aType == EEventKey && Control().IsReady()) |
|
310 { |
|
311 switch (aKeyEvent.iCode) |
|
312 { |
|
313 case EKeyPhoneSend: |
|
314 { |
|
315 // Use the EPbkCmdCall id to identify that |
|
316 // call is being launched with send key |
|
317 if ( Control().NumberOfItems() > 0 ) |
|
318 { |
|
319 HandleCommandL(EPbkCmdCall); |
|
320 result = ETrue; |
|
321 } |
|
322 break; |
|
323 } |
|
324 case EKeyPoC: |
|
325 { |
|
326 HandleCommandL(EPbkCmdPoc); |
|
327 break; |
|
328 } |
|
329 case EKeyBackspace: |
|
330 { |
|
331 if (aKeyEvent.iCode == EKeyBackspace) |
|
332 { |
|
333 if ((Control().NumberOfItems() > 0) && |
|
334 (Control().FindTextL() == KNullDesC)) |
|
335 { |
|
336 // check that there are names and that find window is empty |
|
337 DeleteFocusedEntryL(); |
|
338 result = ETrue; |
|
339 } |
|
340 } |
|
341 break; |
|
342 } |
|
343 |
|
344 case EKeyOK: |
|
345 { |
|
346 if (!ShiftDown(aKeyEvent) && !CtrlDown( aKeyEvent )) // pure OK key |
|
347 { |
|
348 CPbkContactViewListControl& control = Control(); |
|
349 if (control.NumberOfItems() > 0 && !control.ItemsMarked()) |
|
350 { |
|
351 // Select key is mapped to "Open Contact" command |
|
352 HandleCommandL(EPbkCmdOpenMeViews); |
|
353 } |
|
354 else |
|
355 { |
|
356 // select key mapped to context sensitive menu if list is empty |
|
357 HandleCommandL(EPbkCmdContextMenu); |
|
358 } |
|
359 result = ETrue; |
|
360 } |
|
361 break; |
|
362 } |
|
363 |
|
364 default: |
|
365 { |
|
366 break; |
|
367 } |
|
368 } |
|
369 } |
|
370 |
|
371 |
|
372 return result; |
|
373 } |
|
374 |
|
375 |
|
376 void CPbkContactListAppView::DynInitMenuPaneL |
|
377 (TInt aResourceId, |
|
378 CEikMenuPane* aMenuPane) |
|
379 { |
|
380 Control().HandleMarkableListDynInitMenuPane(aResourceId, aMenuPane); |
|
381 CPbkAppView::DynInitMenuPaneL(aResourceId,aMenuPane); |
|
382 } |
|
383 |
|
384 void CPbkContactListAppView::HandleSendContactsL( TUint aFlags ) |
|
385 { |
|
386 TPbkSendingParams params = CreateSendParamsLC(aFlags); |
|
387 PbkAppUi()->FFSClCheckL(PbkCommandHandler(this, |
|
388 &CPbkContactListAppView::CmdSendContactsL, |
|
389 params)); |
|
390 CleanupStack::PopAndDestroy(); //mtmFilter |
|
391 } |
|
392 |
|
393 TPbkSendingParams CPbkContactListAppView::CreateWriteParamsLC() |
|
394 { |
|
395 // Construct the MTM filter |
|
396 CArrayFixFlat<TUid>* mtmFilter = |
|
397 new(ELeave) CArrayFixFlat<TUid>(4); |
|
398 CleanupStack::PushL(mtmFilter); |
|
399 |
|
400 const CContactIdArray& array = Control().MarkedItemsL(); |
|
401 if( array.Count() > 1 ) |
|
402 { |
|
403 const TUid KPostcardMtmUid = { KSenduiMtmPostcardUidValue }; |
|
404 mtmFilter->AppendL(KPostcardMtmUid); // hide postcard |
|
405 } |
|
406 |
|
407 TSendingCapabilities capabilities = TSendingCapabilities(); |
|
408 capabilities.iFlags = TSendingCapabilities::ESupportsEditor; |
|
409 return TPbkSendingParams( mtmFilter, capabilities ); |
|
410 } |
|
411 |
|
412 TPbkSendingParams CPbkContactListAppView::CreateSendParamsLC(TUint aFlags) |
|
413 { |
|
414 // Construct the MTM filter |
|
415 CArrayFixFlat<TUid>* mtmFilter = |
|
416 new(ELeave) CArrayFixFlat<TUid>(4); |
|
417 CleanupStack::PushL(mtmFilter); |
|
418 |
|
419 const TUid KPostcardMtmUid = { KSenduiMtmPostcardUidValue }; |
|
420 |
|
421 mtmFilter->AppendL(KPostcardMtmUid); // hide postcard |
|
422 mtmFilter->AppendL(KSenduiMtmAudioMessageUid); // hide audio message |
|
423 |
|
424 // Check must we disable SMS menuitem |
|
425 if (!CPbkAppGlobals::InstanceL()->SendUiL() |
|
426 ->CanSendBioMessage(KMsgBioUidVCard)) |
|
427 { |
|
428 mtmFilter->AppendL(KSenduiMtmSmsUid); // hide SMS |
|
429 } |
|
430 |
|
431 // If there are items marked, hide items |
|
432 if (aFlags & KPbkItemsMarked) |
|
433 { |
|
434 |
|
435 mtmFilter->AppendL(KSenduiMtmSmsUid); // hide SMS |
|
436 |
|
437 // If multiple vCard over BT/IR is not supported hide also BT and IR |
|
438 if (!Engine()->Constants()->LocallyVariatedFeatureEnabled |
|
439 (EPbkLVMultipleVCardOverBTAndIR)) |
|
440 { |
|
441 mtmFilter->AppendL(KSenduiMtmBtUid); // hide Bluetooth |
|
442 mtmFilter->AppendL(KSenduiMtmIrUid); // hide Infrared |
|
443 } |
|
444 } |
|
445 |
|
446 // Hide MMS if not supported |
|
447 if (!FeatureManager::FeatureSupported(KFeatureIdMMS)) |
|
448 { |
|
449 mtmFilter->AppendL(KSenduiMtmMmsUid); |
|
450 } |
|
451 |
|
452 // Hide Email if not supported |
|
453 if (!FeatureManager::FeatureSupported(KFeatureIdEmailUi)) |
|
454 { |
|
455 mtmFilter->AppendL(KSenduiMtmSmtpUid); |
|
456 mtmFilter->AppendL(KSenduiMtmImap4Uid); |
|
457 mtmFilter->AppendL(KSenduiMtmPop3Uid); |
|
458 mtmFilter->AppendL(KSenduiMtmSyncMLEmailUid); |
|
459 } |
|
460 |
|
461 TSendingCapabilities capabilities = TSendingCapabilities(); |
|
462 capabilities.iFlags = TSendingCapabilities::ESupportsBioSending; |
|
463 capabilities.iFlags |= TSendingCapabilities::ESupportsAttachments; |
|
464 return TPbkSendingParams( mtmFilter, capabilities ); |
|
465 } |
|
466 |
|
467 void CPbkContactListAppView::AiwCommandHandledL(TInt /*aMenuCommandId*/, |
|
468 TInt aServiceCommandId, |
|
469 TInt /*aErrorCode*/) |
|
470 { |
|
471 if (aServiceCommandId == KAiwCmdCall || |
|
472 aServiceCommandId == KAiwCmdPoC) |
|
473 { |
|
474 // Reset find and focus the selected contact |
|
475 const TInt selIndex = Control().CurrentItemIndex(); |
|
476 if (selIndex >= 0) |
|
477 { |
|
478 TContactItemId cid = Control().ContactIdAtL(selIndex); |
|
479 Control().ResetFindL(); |
|
480 TInt idx = Control().FindContactIdL(cid); |
|
481 if (idx >= 0) |
|
482 { |
|
483 Control().SetCurrentItemIndexAndDraw(idx); |
|
484 } |
|
485 } |
|
486 Control().HandleMarkableListUpdateAfterCommandExecution(); |
|
487 } |
|
488 } |
|
489 |
|
490 // End of File |