|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Phonebook 2 USIM UI Extension plug-in. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CPsu2UIExtensionPlugin.h" |
|
21 |
|
22 // Phonebook 2 |
|
23 #include "CPsu2CopyToSimCmd.h" |
|
24 #include "CPsu2CopyFromPbkCmd.h" |
|
25 #include "CPsu2LaunchViewCmd.h" |
|
26 #include "Pbk2USimUI.hrh" |
|
27 #include "CPsu2ViewManager.h" |
|
28 #include "CPsu2OwnNumbersView.h" |
|
29 #include "CPsu2ServiceDialingView.h" |
|
30 #include "CPsu2FixedDialingView.h" |
|
31 #include "CPsu2ServiceDialingInfoView.h" |
|
32 #include "CPsu2FixedDialingInfoView.h" |
|
33 #include "CPsu2ContactEditorExtension.h" |
|
34 #include <MPbk2ContactUiControl.h> |
|
35 #include <CPbk2StorePropertyArray.h> |
|
36 #include <CPbk2AppViewBase.h> |
|
37 #include <CPbk2StoreProperty.h> |
|
38 #include <CPbk2StoreViewDefinition.h> |
|
39 #include <CPbk2ApplicationServices.h> |
|
40 #include <MPbk2AppUi.h> |
|
41 #include <MPbk2StoreValidityInformer.h> |
|
42 #include <Pbk2ViewId.hrh> |
|
43 |
|
44 // Virtual Phonebook |
|
45 #include <VPbkContactStoreUris.h> |
|
46 #include <TVPbkContactStoreUriPtr.h> |
|
47 #include <CVPbkContactManager.h> |
|
48 #include <MVPbkContactStoreList.h> |
|
49 #include <MVPbkContactStore.h> |
|
50 #include <MVPbkBaseContact.h> |
|
51 #include <CVPbkContactStoreUriArray.h> |
|
52 #include <CVPbkContactViewDefinition.h> |
|
53 |
|
54 // System includes |
|
55 #include <barsread.h> |
|
56 #include <coemain.h> |
|
57 #include <vwsdef.h> |
|
58 #include <csxhelp/phob.hlp.hrh> |
|
59 #include <avkon.hrh> |
|
60 |
|
61 // -------------------------------------------------------------------------- |
|
62 // CPsu2UIExtensionPlugin::CPsu2UIExtensionPlugin |
|
63 // -------------------------------------------------------------------------- |
|
64 // |
|
65 CPsu2UIExtensionPlugin::CPsu2UIExtensionPlugin() |
|
66 :iEndKeyPressed( EFalse ) |
|
67 { |
|
68 } |
|
69 |
|
70 // -------------------------------------------------------------------------- |
|
71 // CPsu2UIExtensionPlugin::~CPsu2UIExtensionPlugin |
|
72 // -------------------------------------------------------------------------- |
|
73 // |
|
74 CPsu2UIExtensionPlugin::~CPsu2UIExtensionPlugin() |
|
75 { |
|
76 delete iViewManager; |
|
77 Release( iAppServices ); |
|
78 } |
|
79 |
|
80 // -------------------------------------------------------------------------- |
|
81 // CPsu2UIExtensionPlugin::ConstructL |
|
82 // -------------------------------------------------------------------------- |
|
83 // |
|
84 inline void CPsu2UIExtensionPlugin::ConstructL() |
|
85 { |
|
86 iAppServices = CPbk2ApplicationServices::InstanceL(); |
|
87 |
|
88 iViewManager = CPsu2ViewManager::NewL(); |
|
89 } |
|
90 |
|
91 // -------------------------------------------------------------------------- |
|
92 // CPsu2UIExtensionPlugin::NewL |
|
93 // -------------------------------------------------------------------------- |
|
94 // |
|
95 CPsu2UIExtensionPlugin* CPsu2UIExtensionPlugin::NewL() |
|
96 { |
|
97 CPsu2UIExtensionPlugin* self = new( ELeave ) CPsu2UIExtensionPlugin(); |
|
98 CleanupStack::PushL( self ); |
|
99 self->ConstructL(); |
|
100 CleanupStack::Pop( self ); |
|
101 return self; |
|
102 } |
|
103 |
|
104 // -------------------------------------------------------------------------- |
|
105 // CPsu2UIExtensionPlugin::CreateExtensionViewL |
|
106 // -------------------------------------------------------------------------- |
|
107 // |
|
108 MPbk2UIExtensionView* CPsu2UIExtensionPlugin::CreateExtensionViewL |
|
109 ( TUid aViewId, CPbk2UIExtensionView& aView ) |
|
110 { |
|
111 MPbk2UIExtensionView* ret = NULL; |
|
112 |
|
113 if ( aViewId == TUid::Uid( EPsu2OwnNumberViewId ) ) |
|
114 { |
|
115 ret = CPsu2OwnNumbersView::NewL( aView, *iViewManager ); |
|
116 } |
|
117 else if ( aViewId == TUid::Uid( EPsu2ServiceDialingViewId ) ) |
|
118 { |
|
119 ret = CPsu2ServiceDialingView::NewL( aView, *iViewManager ); |
|
120 } |
|
121 else if ( aViewId == TUid::Uid( EPsu2FixedDialingViewId ) ) |
|
122 { |
|
123 ret = CPsu2FixedDialingView::NewL( aView, *iViewManager ); |
|
124 } |
|
125 else if ( aViewId == TUid::Uid( EPsu2ServiceDialingInfoViewId ) ) |
|
126 { |
|
127 ret = CPsu2ServiceDialingInfoView::NewL( aView, *iViewManager ); |
|
128 } |
|
129 else if ( aViewId == TUid::Uid( EPsu2FixedDialingInfoViewId ) ) |
|
130 { |
|
131 ret = CPsu2FixedDialingInfoView::NewL( aView, *iViewManager ); |
|
132 } |
|
133 |
|
134 return ret; |
|
135 } |
|
136 |
|
137 // -------------------------------------------------------------------------- |
|
138 // CPsu2UIExtensionPlugin::DynInitMenuPaneL |
|
139 // -------------------------------------------------------------------------- |
|
140 // |
|
141 void CPsu2UIExtensionPlugin::DynInitMenuPaneL |
|
142 ( TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/, |
|
143 MPbk2ContactUiControl& /*aControl*/ ) |
|
144 { |
|
145 // Do nothing |
|
146 } |
|
147 |
|
148 // -------------------------------------------------------------------------- |
|
149 // CPsu2UIExtensionPlugin::UpdateStorePropertiesL |
|
150 // -------------------------------------------------------------------------- |
|
151 // |
|
152 void CPsu2UIExtensionPlugin::UpdateStorePropertiesL |
|
153 ( CPbk2StorePropertyArray& /*aPropertyArray*/ ) |
|
154 { |
|
155 // Do nothing |
|
156 } |
|
157 |
|
158 // -------------------------------------------------------------------------- |
|
159 // CPsu2UIExtensionPlugin::CreatePbk2ContactEditorExtensionL |
|
160 // -------------------------------------------------------------------------- |
|
161 // |
|
162 MPbk2ContactEditorExtension* |
|
163 CPsu2UIExtensionPlugin::CreatePbk2ContactEditorExtensionL |
|
164 ( CVPbkContactManager& aContactManager, |
|
165 MVPbkStoreContact& aContact, |
|
166 MPbk2ContactEditorControl& aEditorControl ) |
|
167 { |
|
168 return CPsu2ContactEditorExtension::NewL |
|
169 ( aContactManager, aContact, aEditorControl ); |
|
170 } |
|
171 |
|
172 // -------------------------------------------------------------------------- |
|
173 // CPsu2UIExtensionPlugin::CreatePbk2UiControlExtensionL |
|
174 // -------------------------------------------------------------------------- |
|
175 // |
|
176 MPbk2ContactUiControlExtension* |
|
177 CPsu2UIExtensionPlugin::CreatePbk2UiControlExtensionL |
|
178 ( CVPbkContactManager& /*aContactManager*/ ) |
|
179 { |
|
180 return NULL; |
|
181 } |
|
182 |
|
183 // -------------------------------------------------------------------------- |
|
184 // CPmuUIExtensionPlugin::CreatePbk2SettingsViewExtensionL |
|
185 // -------------------------------------------------------------------------- |
|
186 // |
|
187 MPbk2SettingsViewExtension* CPsu2UIExtensionPlugin:: |
|
188 CreatePbk2SettingsViewExtensionL |
|
189 ( CVPbkContactManager& /*aContactManager*/ ) |
|
190 { |
|
191 return NULL; |
|
192 } |
|
193 |
|
194 // -------------------------------------------------------------------------- |
|
195 // CPsu2UIExtensionPlugin::CreatePbk2AppUiExtensionL |
|
196 // -------------------------------------------------------------------------- |
|
197 // |
|
198 MPbk2AppUiExtension* CPsu2UIExtensionPlugin::CreatePbk2AppUiExtensionL |
|
199 ( CVPbkContactManager& /*aContactManager*/ ) |
|
200 { |
|
201 return NULL; |
|
202 } |
|
203 |
|
204 // -------------------------------------------------------------------------- |
|
205 // CPsu2UIExtensionPlugin::CreatePbk2CommandForIdL |
|
206 // -------------------------------------------------------------------------- |
|
207 // |
|
208 MPbk2Command* CPsu2UIExtensionPlugin::CreatePbk2CommandForIdL |
|
209 ( TInt aCommandId, MPbk2ContactUiControl& aUiControl) const |
|
210 { |
|
211 MPbk2Command* result = NULL; |
|
212 switch (aCommandId) |
|
213 { |
|
214 case EPbk2CmdCopyContacts: // Pbk2 copy query uses this |
|
215 { |
|
216 MVPbkContactStore* target = |
|
217 GetTargetForCopyOrNullL( aUiControl ); |
|
218 if (target) |
|
219 { |
|
220 result = CPsu2CopyToSimCmd::NewL( aUiControl,*target ); |
|
221 } |
|
222 break; |
|
223 } |
|
224 case EPsu2CmdLaunchOwnNumberView: |
|
225 { |
|
226 result = CPsu2LaunchViewCmd::NewL(*iViewManager, |
|
227 EPsu2OwnNumberViewId); |
|
228 break; |
|
229 } |
|
230 case EPsu2CmdLaunchServiceDialingView: |
|
231 { |
|
232 result = CPsu2LaunchViewCmd::NewL(*iViewManager, |
|
233 EPsu2ServiceDialingViewId); |
|
234 break; |
|
235 } |
|
236 case EPsu2CmdLaunchFixedDialingView: |
|
237 { |
|
238 result = CPsu2LaunchViewCmd::NewL(*iViewManager, |
|
239 EPsu2FixedDialingViewId); |
|
240 break; |
|
241 } |
|
242 case EPsu2CmdCopyFromContacts: |
|
243 { |
|
244 MVPbkContactStore* target = iAppServices->ContactManager(). |
|
245 ContactStoresL().Find(VPbkContactStoreUris::SimGlobalFdnUri()); |
|
246 result = CPsu2CopyFromPbkCmd::NewL( *target, aUiControl, const_cast<CPsu2UIExtensionPlugin*>( this ) ); |
|
247 break; |
|
248 } |
|
249 } |
|
250 |
|
251 return result; |
|
252 } |
|
253 |
|
254 // -------------------------------------------------------------------------- |
|
255 // CPsu2UIExtensionPlugin::CreatePbk2AiwInterestForIdL |
|
256 // -------------------------------------------------------------------------- |
|
257 // |
|
258 MPbk2AiwInterestItem* CPsu2UIExtensionPlugin::CreatePbk2AiwInterestForIdL |
|
259 ( TInt /*aInterestId*/, |
|
260 CAiwServiceHandler& /*aServiceHandler*/ ) const |
|
261 { |
|
262 // Do nothing |
|
263 return NULL; |
|
264 } |
|
265 |
|
266 // -------------------------------------------------------------------------- |
|
267 // CPsu2UIExtensionPlugin::GetHelpContextL |
|
268 // -------------------------------------------------------------------------- |
|
269 // |
|
270 TBool CPsu2UIExtensionPlugin::GetHelpContextL |
|
271 ( TCoeHelpContext& aContext, const CPbk2AppViewBase& aView, |
|
272 MPbk2ContactUiControl& /*aUiControl*/ ) |
|
273 { |
|
274 |
|
275 TBool helpFound( EFalse ); |
|
276 switch ( aView.ViewId().iViewUid.iUid ) |
|
277 { |
|
278 case EPsu2ServiceDialingViewId: // FALLTHROUGH |
|
279 case EPsu2ServiceDialingInfoViewId: |
|
280 { |
|
281 aContext.iContext = KSDN_HLP_APP; |
|
282 helpFound = ETrue; |
|
283 break; |
|
284 } |
|
285 case EPsu2FixedDialingViewId: |
|
286 { |
|
287 aContext.iContext = KFDN_HLP_FDN_VIEW; |
|
288 helpFound = ETrue; |
|
289 break; |
|
290 } |
|
291 case EPsu2FixedDialingInfoViewId: |
|
292 { |
|
293 aContext.iContext = KFDN_HLP_FDN_NUMBER_VIEW; |
|
294 helpFound = ETrue; |
|
295 break; |
|
296 } |
|
297 case EPbk2NamesListViewId: |
|
298 { |
|
299 if ( OnlyStoreShownL |
|
300 ( VPbkContactStoreUris::SimGlobalAdnUri() ) ) |
|
301 { |
|
302 aContext.iContext = KPHOB_HLP_SIM_LIST; |
|
303 helpFound = ETrue; |
|
304 } |
|
305 else if ( OnlyStoreShownL |
|
306 ( VPbkContactStoreUris::SimGlobalSdnUri() ) ) |
|
307 { |
|
308 aContext.iContext = KSDN_HLP_APP; |
|
309 helpFound = ETrue; |
|
310 } |
|
311 break; |
|
312 } |
|
313 case EPbk2ContactInfoViewId: |
|
314 { |
|
315 if ( OnlyStoreShownL |
|
316 ( VPbkContactStoreUris::SimGlobalAdnUri() ) ) |
|
317 { |
|
318 aContext.iContext = KHLP_CCA_DETAILS; |
|
319 helpFound = ETrue; |
|
320 } |
|
321 else if ( OnlyStoreShownL |
|
322 ( VPbkContactStoreUris::SimGlobalSdnUri() ) ) |
|
323 { |
|
324 aContext.iContext = KSDN_HLP_APP; |
|
325 helpFound = ETrue; |
|
326 } |
|
327 break; |
|
328 } |
|
329 default: |
|
330 { |
|
331 // Unknown view, no help |
|
332 break; |
|
333 } |
|
334 } |
|
335 |
|
336 if ( helpFound ) |
|
337 { |
|
338 // set uid to phonebook uid because |
|
339 // that is used in all phonebook helps |
|
340 aContext.iMajor = aView.ApplicationUid(); |
|
341 } |
|
342 |
|
343 return helpFound; |
|
344 } |
|
345 |
|
346 // -------------------------------------------------------------------------- |
|
347 // CPsu2UIExtensionPlugin::ApplyDynamicViewGraphChangesL |
|
348 // -------------------------------------------------------------------------- |
|
349 // |
|
350 void CPsu2UIExtensionPlugin::ApplyDynamicViewGraphChangesL |
|
351 ( CPbk2ViewGraph& /*aViewGraph*/ ) |
|
352 { |
|
353 // Do nothing |
|
354 } |
|
355 |
|
356 // -------------------------------------------------------------------------- |
|
357 // CPsu2UIExtensionPlugin::ApplyDynamicPluginInformationDataL |
|
358 // -------------------------------------------------------------------------- |
|
359 // |
|
360 void CPsu2UIExtensionPlugin::ApplyDynamicPluginInformationDataL |
|
361 ( CPbk2UIExtensionInformation& /*aUiExtensionInformation*/ ) |
|
362 { |
|
363 // Do nothing |
|
364 } |
|
365 |
|
366 // -------------------------------------------------------------------------- |
|
367 // CPsu2UIExtensionPlugin::GetTargetForCopyOrNullL |
|
368 // -------------------------------------------------------------------------- |
|
369 // |
|
370 MVPbkContactStore* CPsu2UIExtensionPlugin::GetTargetForCopyOrNullL( |
|
371 MPbk2ContactUiControl& aUiControl) const |
|
372 { |
|
373 MVPbkContactStore* target = NULL; |
|
374 CArrayPtr<MVPbkContactStore>* stores = |
|
375 aUiControl.SelectedContactStoresL(); |
|
376 const TInt oneSelectedStore = 1; |
|
377 if (stores && stores->Count() == oneSelectedStore) |
|
378 { |
|
379 // Allow copying only to global ADN store |
|
380 CleanupStack::PushL(stores); |
|
381 MVPbkContactStore* temp = iAppServices->ContactManager(). |
|
382 ContactStoresL().Find( |
|
383 VPbkContactStoreUris::SimGlobalAdnUri() ); |
|
384 if ((*stores)[0] == temp) |
|
385 { |
|
386 target = temp; |
|
387 } |
|
388 CleanupStack::PopAndDestroy(stores); |
|
389 } |
|
390 else |
|
391 { |
|
392 delete stores; |
|
393 } |
|
394 return target; |
|
395 } |
|
396 |
|
397 // -------------------------------------------------------------------------- |
|
398 // CPsu2UIExtensionPlugin::OnlyStoreShownL |
|
399 // -------------------------------------------------------------------------- |
|
400 // |
|
401 TBool CPsu2UIExtensionPlugin::OnlyStoreShownL( const TDesC& aStoreUri ) |
|
402 { |
|
403 TBool ret( EFalse ); |
|
404 CVPbkContactStoreUriArray* uriArray = iAppServices-> |
|
405 StoreValidityInformer().CurrentlyValidShownStoresL(); |
|
406 if ( uriArray && uriArray->Count() == 1 ) |
|
407 { |
|
408 TVPbkContactStoreUriPtr shownUriPtr = (*uriArray)[0]; |
|
409 TVPbkContactStoreUriPtr uriPtr( aStoreUri ); |
|
410 if ( uriPtr.Compare( shownUriPtr, |
|
411 TVPbkContactStoreUriPtr::EContactStoreUriAllComponents ) |
|
412 == 0 ) |
|
413 { |
|
414 ret = ETrue; |
|
415 } |
|
416 } |
|
417 delete uriArray; |
|
418 |
|
419 return ret; |
|
420 } |
|
421 |
|
422 // -------------------------------------------------------------------------- |
|
423 // CPsu2UIExtensionPlugin::UIExtensionPluginExtension |
|
424 // -------------------------------------------------------------------------- |
|
425 // |
|
426 TAny* CPsu2UIExtensionPlugin::UIExtensionPluginExtension( TUid aExtensionUid ) |
|
427 { |
|
428 TAny* ret = NULL; |
|
429 if (aExtensionUid == ImplementationUid()) |
|
430 { |
|
431 ret = static_cast<MPbk2PluginCommandListerner*>( this ); |
|
432 } |
|
433 return ret; |
|
434 } |
|
435 |
|
436 // -------------------------------------------------------------------------- |
|
437 // CPsu2UIExtensionPlugin::HandlePbk2Command |
|
438 // -------------------------------------------------------------------------- |
|
439 // |
|
440 void CPsu2UIExtensionPlugin::HandlePbk2Command( TInt aCommand ) |
|
441 { |
|
442 switch( aCommand ) |
|
443 { |
|
444 // Pbk2 goes to the backgound |
|
445 case EAknCmdHideInBackground: |
|
446 { |
|
447 iEndKeyPressed = ETrue; |
|
448 } |
|
449 break; |
|
450 |
|
451 default: |
|
452 break; |
|
453 } |
|
454 } |
|
455 |
|
456 // -------------------------------------------------------------------------- |
|
457 // CPsu2UIExtensionPlugin::IsEndKeyPressed |
|
458 // -------------------------------------------------------------------------- |
|
459 // |
|
460 TBool CPsu2UIExtensionPlugin::IsEndKeyPressed() |
|
461 { |
|
462 return iEndKeyPressed; |
|
463 } |
|
464 |
|
465 // -------------------------------------------------------------------------- |
|
466 // CPsu2UIExtensionPlugin::ClearEndKeyPressedFlag |
|
467 // -------------------------------------------------------------------------- |
|
468 // |
|
469 void CPsu2UIExtensionPlugin::ClearEndKeyPressedFlag() |
|
470 { |
|
471 iEndKeyPressed = EFalse; |
|
472 } |
|
473 |
|
474 // End of File |