|
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 service dialing info view. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CPsu2ServiceDialingInfoView.h" |
|
20 |
|
21 // Phonebook 2 |
|
22 #include <CPbk2UIExtensionView.h> |
|
23 #include <MPbk2ViewActivationTransaction.h> |
|
24 #include <CPbk2AppUiBase.h> |
|
25 #include <MPbk2ViewExplorer.h> |
|
26 #include <Pbk2USimUIRes.rsg> |
|
27 #include <Pbk2UIControls.rsg> |
|
28 #include <MPbk2ContactUiControl.h> |
|
29 #include <TPbk2StoreContactAnalyzer.h> |
|
30 #include <Pbk2Commands.hrh> |
|
31 #include <MPbk2ApplicationServices.h> |
|
32 #include <MPbk2PointerEventInspector.h> |
|
33 |
|
34 // System includes |
|
35 #include <AknUtils.h> |
|
36 #include <eikmenub.h> |
|
37 |
|
38 /// Unnamed namespace for local definitions |
|
39 namespace { |
|
40 |
|
41 #ifdef _DEBUG |
|
42 |
|
43 enum TPanicCode |
|
44 { |
|
45 EPanicLogic_HasContactPhoneNumberL = 1 |
|
46 }; |
|
47 |
|
48 void Panic( TPanicCode aPanic ) |
|
49 { |
|
50 _LIT( KPanicCat, "CPsu2ServiceDialingInfoView" ); |
|
51 User::Panic( KPanicCat, aPanic ); |
|
52 } |
|
53 |
|
54 #endif // _DEBUG |
|
55 |
|
56 } /// namespace |
|
57 |
|
58 // -------------------------------------------------------------------------- |
|
59 // CPsu2ServiceDialingInfoView::CPsu2ServiceDialingInfoView |
|
60 // -------------------------------------------------------------------------- |
|
61 // |
|
62 CPsu2ServiceDialingInfoView::CPsu2ServiceDialingInfoView |
|
63 ( CPbk2UIExtensionView& aExtensionView, |
|
64 CPsu2ViewManager& aViewManager ): |
|
65 CPsu2InfoViewBase( aExtensionView, aViewManager ) |
|
66 { |
|
67 } |
|
68 |
|
69 // -------------------------------------------------------------------------- |
|
70 // CPsu2ServiceDialingInfoView::~CPsu2ServiceDialingInfoView |
|
71 // -------------------------------------------------------------------------- |
|
72 // |
|
73 CPsu2ServiceDialingInfoView::~CPsu2ServiceDialingInfoView() |
|
74 { |
|
75 } |
|
76 |
|
77 // -------------------------------------------------------------------------- |
|
78 // CPsu2ServiceDialingInfoView::NewL |
|
79 // -------------------------------------------------------------------------- |
|
80 // |
|
81 CPsu2ServiceDialingInfoView* CPsu2ServiceDialingInfoView::NewL |
|
82 ( CPbk2UIExtensionView& aExtensionView, |
|
83 CPsu2ViewManager& aViewManager ) |
|
84 { |
|
85 CPsu2ServiceDialingInfoView* self = |
|
86 new( ELeave ) CPsu2ServiceDialingInfoView |
|
87 ( aExtensionView, aViewManager ); |
|
88 CleanupStack::PushL( self ); |
|
89 self->ConstructL(); |
|
90 CleanupStack::Pop( self ); |
|
91 return self; |
|
92 } |
|
93 |
|
94 // -------------------------------------------------------------------------- |
|
95 // CPsu2ServiceDialingInfoView::ConstructL |
|
96 // -------------------------------------------------------------------------- |
|
97 // |
|
98 void CPsu2ServiceDialingInfoView::ConstructL() |
|
99 { |
|
100 BaseConstructL(); |
|
101 } |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // CPsu2ServiceDialingInfoView::HandleCommandKeyL |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 TBool CPsu2ServiceDialingInfoView::HandleCommandKeyL |
|
108 ( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
109 { |
|
110 TBool ret = EFalse; |
|
111 |
|
112 if ( aKeyEvent.iCode == EKeyPhoneSend && aType == EEventKey ) |
|
113 { |
|
114 HandleCommandL( EPbk2CmdCall ); |
|
115 ret = ETrue; |
|
116 } |
|
117 else if ( aKeyEvent.iCode == EKeyOK && aType == EEventKey ) |
|
118 { |
|
119 iExtensionView.LaunchPopupMenuL |
|
120 ( R_PSU2_SERVICE_DIALING_INFO_CONTEXT_MENUBAR ); |
|
121 ret = ETrue; |
|
122 } |
|
123 else |
|
124 { |
|
125 ret = CPsu2InfoViewBase::HandleCommandKeyL( aKeyEvent, aType ); |
|
126 } |
|
127 |
|
128 return ret; |
|
129 } |
|
130 |
|
131 // -------------------------------------------------------------------------- |
|
132 // CPsu2ServiceDialingInfoView::DoActivateL |
|
133 // -------------------------------------------------------------------------- |
|
134 // |
|
135 void CPsu2ServiceDialingInfoView::DoActivateL( const TVwsViewId& aPrevViewId, |
|
136 TUid aCustomMessageId, const TDesC8& aCustomMessage ) |
|
137 { |
|
138 delete iViewActivationTransaction; |
|
139 iViewActivationTransaction = NULL; |
|
140 iViewActivationTransaction = |
|
141 Phonebook2::Pbk2AppUi()->Pbk2ViewExplorer()->HandleViewActivationLC |
|
142 ( iExtensionView.Id(), aPrevViewId, NULL, NULL, |
|
143 Phonebook2::EUpdateNaviPane ); |
|
144 CleanupStack::Pop(); // iViewActivationTransaction |
|
145 |
|
146 // Call base class constructor |
|
147 CPsu2InfoViewBase::DoActivateL( |
|
148 aPrevViewId, aCustomMessageId, aCustomMessage); |
|
149 } |
|
150 |
|
151 // -------------------------------------------------------------------------- |
|
152 // CPsu2ServiceDialingInfoView::DoDeactivate |
|
153 // -------------------------------------------------------------------------- |
|
154 // |
|
155 void CPsu2ServiceDialingInfoView::DoDeactivate() |
|
156 { |
|
157 CPsu2InfoViewBase::DoDeactivate(); |
|
158 } |
|
159 |
|
160 // -------------------------------------------------------------------------- |
|
161 // CPsu2ServiceDialingInfoView::HandleCommandL |
|
162 // -------------------------------------------------------------------------- |
|
163 // |
|
164 void CPsu2ServiceDialingInfoView::HandleCommandL( TInt aCommand ) |
|
165 { |
|
166 CPsu2InfoViewBase::HandleCommandL( aCommand ); |
|
167 UpdateCbasL(); |
|
168 } |
|
169 |
|
170 // -------------------------------------------------------------------------- |
|
171 // CPsu2ServiceDialingInfoView::DynInitMenuPaneL |
|
172 // -------------------------------------------------------------------------- |
|
173 // |
|
174 void CPsu2ServiceDialingInfoView::DynInitMenuPaneL(TInt aResourceId, |
|
175 CEikMenuPane* aMenuPane) |
|
176 { |
|
177 switch( aResourceId ) |
|
178 { |
|
179 case R_PSU2_SERVICE_DIALING_INFO_VIEW_COPY_MENUPANE: |
|
180 { |
|
181 // Do nothing |
|
182 break; |
|
183 } |
|
184 default: |
|
185 { |
|
186 CPsu2InfoViewBase::DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
187 break; |
|
188 } |
|
189 } |
|
190 } |
|
191 |
|
192 // -------------------------------------------------------------------------- |
|
193 // CPsu2ServiceDialingInfoView::NameListControlResourceId |
|
194 // -------------------------------------------------------------------------- |
|
195 // |
|
196 TInt CPsu2ServiceDialingInfoView::NameListControlResourceId() const |
|
197 { |
|
198 return 0; |
|
199 } |
|
200 |
|
201 // -------------------------------------------------------------------------- |
|
202 // CPsu2ServiceDialingInfoView::NaviPaneLabelL |
|
203 // -------------------------------------------------------------------------- |
|
204 // |
|
205 HBufC* CPsu2ServiceDialingInfoView::NaviPaneLabelL() const |
|
206 { |
|
207 return NULL; |
|
208 } |
|
209 |
|
210 // ----------------------------------------------------------------------------- |
|
211 // CPsu2ServiceDialingInfoView::UpdateCbasL |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 void CPsu2ServiceDialingInfoView::UpdateCbasL() |
|
215 { |
|
216 TInt resId( KErrNotFound ); |
|
217 if ( ContactHasPhoneNumberL( iControl->FocusedStoreContact() ) ) |
|
218 { |
|
219 resId = R_PBK2_SOFTKEYS_OPTIONS_BACK_CONTEXT; |
|
220 } |
|
221 else |
|
222 { |
|
223 resId = R_PBK2_SOFTKEYS_OPTIONS_BACK_EMPTY; |
|
224 } |
|
225 // Set cba command set "Options - Context Menu - Back" |
|
226 iExtensionView.Cba()->SetCommandSetL( resId ); |
|
227 iExtensionView.Cba()->DrawDeferred(); |
|
228 // Set context menu |
|
229 iExtensionView.MenuBar()->SetContextMenuTitleResourceId |
|
230 ( R_PSU2_SERVICE_DIALING_INFO_CONTEXT_MENUBAR ); |
|
231 } |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // CPsu2ServiceDialingInfoView::ContactHasPhoneNumberL |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 TBool CPsu2ServiceDialingInfoView::ContactHasPhoneNumberL |
|
238 ( const MVPbkStoreContact* aContact ) |
|
239 { |
|
240 __ASSERT_DEBUG( aContact, Panic( EPanicLogic_HasContactPhoneNumberL ) ); |
|
241 |
|
242 TBool result = EFalse; |
|
243 |
|
244 TPbk2StoreContactAnalyzer analyzer |
|
245 ( Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
246 ContactManager(), aContact ); |
|
247 if ( analyzer.HasFieldL |
|
248 ( R_PHONEBOOK2_PHONENUMBER_SELECTOR ) != KErrNotFound ) |
|
249 { |
|
250 result = ETrue; |
|
251 } |
|
252 |
|
253 return result; |
|
254 } |
|
255 |
|
256 // -------------------------------------------------------------------------- |
|
257 // CPsu2ServiceDialingInfoView::HandleControlEventL |
|
258 // -------------------------------------------------------------------------- |
|
259 // |
|
260 void CPsu2ServiceDialingInfoView::HandleControlEventL( |
|
261 MPbk2ContactUiControl& aControl, |
|
262 const TPbk2ControlEvent& aEvent ) |
|
263 { |
|
264 switch ( aEvent.iEventType ) |
|
265 { |
|
266 case TPbk2ControlEvent::EContactDoubleTapped: |
|
267 { |
|
268 // launch context menu if user tapped a focused detail |
|
269 iExtensionView.LaunchPopupMenuL |
|
270 ( R_PSU2_SERVICE_DIALING_INFO_CONTEXT_MENUBAR ); |
|
271 break; |
|
272 } |
|
273 |
|
274 default: |
|
275 { |
|
276 CPsu2InfoViewBase::HandleControlEventL( aControl, aEvent ); |
|
277 break; |
|
278 } |
|
279 } |
|
280 } |
|
281 // End of File |