|
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 * Logs "Detail" view container control class implementation |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <aknnavide.h> |
|
22 #include <akntabgrp.h> |
|
23 #include <applayout.cdl.h> //Dynamic layout functions |
|
24 #include <Logs.rsg> |
|
25 #include <AknUtils.h> |
|
26 |
|
27 #include "CLogsDetailControlContainer.h" |
|
28 #include "CLogsAppUi.h" |
|
29 #include "CLogsDetailAdapter.h" |
|
30 #include "CLogsDetailView.h" |
|
31 #include "CLogsEngine.h" |
|
32 #include "MLogsGetEvent.h" |
|
33 #include "MLogsEventGetter.h" |
|
34 #include "MLogsModel.h" |
|
35 #include "MLogsSharedData.h" |
|
36 #include "CPhoneNumberFormat.h" |
|
37 |
|
38 #include "LogsConstants.hrh" |
|
39 |
|
40 #include "LogsUID.h" |
|
41 #include <csxhelp/log.hlp.hrh> |
|
42 |
|
43 // EXTERNAL DATA STRUCTURES |
|
44 |
|
45 // EXTERNAL FUNCTION PROTOTYPES |
|
46 |
|
47 // CONSTANTS |
|
48 |
|
49 // MACROS |
|
50 |
|
51 // LOCAL CONSTANTS AND MACROS |
|
52 |
|
53 // MODULE DATA STRUCTURES |
|
54 |
|
55 // LOCAL FUNCTION PROTOTYPES |
|
56 |
|
57 // ==================== LOCAL FUNCTIONS ==================== |
|
58 |
|
59 // ================= MEMBER FUNCTIONS ======================= |
|
60 |
|
61 // ---------------------------------------------------------------------------- |
|
62 // CLogsDetailControlContainer::NewL |
|
63 // ---------------------------------------------------------------------------- |
|
64 // |
|
65 CLogsDetailControlContainer* CLogsDetailControlContainer::NewL |
|
66 ( CLogsDetailView* aView, const TRect& aRect ) |
|
67 { |
|
68 CLogsDetailControlContainer* self = new( ELeave ) |
|
69 CLogsDetailControlContainer( aView ); |
|
70 self->SetMopParent( aView ); |
|
71 CleanupStack::PushL( self ); |
|
72 self->ConstructL( aRect ); |
|
73 CleanupStack::Pop(); // self |
|
74 return self; |
|
75 } |
|
76 |
|
77 // ---------------------------------------------------------------------------- |
|
78 // CLogsDetailControlContainer::~CLogsDetailControlContainer |
|
79 // ---------------------------------------------------------------------------- |
|
80 // |
|
81 CLogsDetailControlContainer::~CLogsDetailControlContainer() |
|
82 { |
|
83 delete iListBox; |
|
84 delete iDecoratedTabGroup; |
|
85 delete iPrivateNumber; |
|
86 delete iUnknownNumber; |
|
87 delete iPayphoneNumber; |
|
88 delete iEmergencyCall; |
|
89 delete iTitleLabel; |
|
90 delete iCsdNumber; |
|
91 delete iOperServNumber; |
|
92 delete iGroupCall; |
|
93 delete iPhoneNumber; |
|
94 } |
|
95 |
|
96 // ---------------------------------------------------------------------------- |
|
97 // CLogsDetailControlContainer::CLogsDetailControlContainer |
|
98 // ---------------------------------------------------------------------------- |
|
99 // |
|
100 CLogsDetailControlContainer::CLogsDetailControlContainer |
|
101 ( CLogsDetailView* aView |
|
102 ) |
|
103 : CLogsBaseControlContainer( aView ) |
|
104 , iView( aView ) |
|
105 { |
|
106 } |
|
107 |
|
108 // ---------------------------------------------------------------------------- |
|
109 // CLogsDetailControlContainer::ConstructL |
|
110 // ---------------------------------------------------------------------------- |
|
111 // |
|
112 void CLogsDetailControlContainer::ConstructL( const TRect& aRect ) |
|
113 { |
|
114 BaseConstructL(); |
|
115 |
|
116 //FIXME: this can be removed as Phone takes care of leavin csd numbers unlogged if preferred |
|
117 // iShowCsd = iView->Engine()->SharedDataL()->ShowCsdNumber(); |
|
118 |
|
119 iListBox = new( ELeave ) CAknSingleHeadingStyleListBox; |
|
120 iListBox->ConstructL( this, EEikListBoxMultipleSelection |
|
121 | EAknListBoxViewerFlags ); |
|
122 |
|
123 iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); //Ownership of iAdapter to iListBox |
|
124 |
|
125 iAdapter = CLogsDetailAdapter::NewL( iListBox, iView ); |
|
126 |
|
127 iListBox->Model()->SetItemTextArray( iAdapter ); //Ownership of iAdapter transferred to iListBox |
|
128 |
|
129 MakeEmptyTextListBoxL( iListBox, R_LOGS_EVENTVIEW_FETCHING_TEXT ); |
|
130 |
|
131 iPrivateNumber = iCoeEnv->AllocReadResourceL( |
|
132 R_DLOGS_DETAILS_PRIVATE_NUMBER ); |
|
133 iUnknownNumber = iCoeEnv->AllocReadResourceL( |
|
134 R_DLOGS_DETAILS_UNKNOWN_NUMBER ); |
|
135 iPayphoneNumber = iCoeEnv->AllocReadResourceL( |
|
136 R_DLOGS_DETAILS_PAYPHONE_NUMBER ); |
|
137 |
|
138 iEmergencyCall = iCoeEnv->AllocReadResourceL( |
|
139 R_LOGS_EMERG_CALL ); |
|
140 iCsdNumber = iCoeEnv->AllocReadResourceL( |
|
141 R_LOGS_DETAILS_CSD_NUMBER ); |
|
142 iOperServNumber = iCoeEnv->AllocReadResourceL( |
|
143 R_LOGS_DETAILS_OPER_SERV ); |
|
144 iGroupCall = iCoeEnv->AllocReadResourceL( |
|
145 R_LOGS_CON_GROUP_CALL ); |
|
146 iTitleLabel = new (ELeave) CEikLabel(); |
|
147 |
|
148 iPhoneNumber = CPhoneNumberFormat::NewL(); |
|
149 |
|
150 iDecoratedTabGroup = NaviPaneL()->CreateTabGroupL(); |
|
151 |
|
152 iDecoratedTabGroup->SetNaviDecoratorObserver(iView); |
|
153 |
|
154 CAknTabGroup* tabGroup = static_cast<CAknTabGroup*>( |
|
155 iDecoratedTabGroup->DecoratedControl() ); |
|
156 tabGroup->SetTabFixedWidthL( KTabWidthWithOneTab ); |
|
157 tabGroup->AddTabL( 0, KSpace ); |
|
158 |
|
159 SetRect( aRect ); |
|
160 ActivateL(); |
|
161 } |
|
162 |
|
163 |
|
164 // ---------------------------------------------------------------------------- |
|
165 // CLogsDetailControlContainer::InitNaviPaneL |
|
166 // ---------------------------------------------------------------------------- |
|
167 // |
|
168 void CLogsDetailControlContainer::InitNaviPaneL() |
|
169 { |
|
170 const MLogsEventGetter* event = iView->Engine()->GetEventL()->Event(); |
|
171 |
|
172 TLogsDirection dir = event->Direction(); |
|
173 TUid uid; |
|
174 uid.iUid = event->EventUid().iUid; |
|
175 |
|
176 //if( ! iShowCsd && //FIXME: this can be removed as Phone takes care of leavin csd numbers unlogged if preferred |
|
177 // (replaced by row below) |
|
178 if( !event->Number() && !event->RemoteParty() && |
|
179 uid.iUid == KLogDataEventType && |
|
180 ( dir == EDirOutAlt || dir == EDirOut ) ) |
|
181 { |
|
182 //CSD-numbers: some operators don't want to show csd-number. In those cases Phone does not log the phone number |
|
183 //and may not even log access point to RemoteParty, i.e. the entry is ETypeUnknown. However, for those entries |
|
184 //show iCsdNumber instad of iUnknownNumber. |
|
185 MakeTitleL( *iCsdNumber ); |
|
186 } |
|
187 else |
|
188 { |
|
189 switch( event->EventType() ) |
|
190 { |
|
191 case ETypeUsual: |
|
192 if( event->RemoteParty() ) //If remote party provided. Title pane shows |
|
193 { //on two rows if does not fit to one row |
|
194 // lets replace paragraph delimiters with single white space, fix for EBWG-6ZPCMZ |
|
195 TPtr titleText = event->RemoteParty()->Des(); |
|
196 TBuf<1> charsToRemove; |
|
197 charsToRemove.Append(TChar(TInt(CEditableText::EParagraphDelimiter))); |
|
198 AknTextUtils::ReplaceCharacters(titleText, charsToRemove, TChar(TInt(CEditableText::ESpace))); |
|
199 MakeTitleL(titleText); |
|
200 } |
|
201 else if( event->Number() ) //Phone number. Shown on one line only, |
|
202 { //so needs to be clipped if does not fit |
|
203 //We prefer showing phone number over sip uri. If this order is changed, change it |
|
204 //also to CLogsBaseView::CmdSaveToVirtualPhonebookL and other views too |
|
205 |
|
206 //First calculate max width in pixels available in title pane |
|
207 TAknTextLineLayout line = AknLayout::Title_pane_texts_Line_1(0, 0); |
|
208 TRect titlePane; |
|
209 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::ETitlePane, titlePane); |
|
210 TAknLayoutText text; |
|
211 text.LayoutText( titlePane, line); |
|
212 TInt maxTextWidthPixels = text.TextRect().Width(); |
|
213 //Then format the phone number to fit in available space |
|
214 TBuf<KLogsPhoneNumberMaxLen> tmp; |
|
215 TBuf<KLogsPhoneNumberMaxLen> clippedNumber; |
|
216 iPhoneNumber->DTMFStrip( *(event->Number()), tmp ); |
|
217 iPhoneNumber->PhoneNumberFormat |
|
218 ( tmp |
|
219 , clippedNumber |
|
220 , iTitleLabel->Font() |
|
221 , maxTextWidthPixels // text.iW |
|
222 ); |
|
223 MakeTitleL( clippedNumber ); |
|
224 } |
|
225 else if( event->LogsEventData()->Url().Length() > 0 ) |
|
226 { |
|
227 TBuf<KLogsSipUriMaxLen> buf; |
|
228 |
|
229 if ( iView->Engine()->ConvertToUnicode( event->LogsEventData()->Url(), buf ) ) |
|
230 { |
|
231 MakeTitleL( KNullDesC ); //Converting failed |
|
232 } |
|
233 else |
|
234 { |
|
235 MakeTitleL( buf ); |
|
236 } |
|
237 } |
|
238 break; |
|
239 |
|
240 case ETypePoCGroupCall: |
|
241 if( event->RemoteParty() ) //If remote party provided. Title pane shows |
|
242 { //on two rows if does not fit to one row |
|
243 MakeTitleL( *(event->RemoteParty()) ); |
|
244 } |
|
245 else //if no remote party data available, show |
|
246 { //localised text "group call" |
|
247 MakeTitleL( *iGroupCall ); |
|
248 } |
|
249 break; |
|
250 |
|
251 case ETypePrivate: |
|
252 MakeTitleL( *iPrivateNumber ); |
|
253 break; |
|
254 |
|
255 case ETypeUnknown: |
|
256 MakeTitleL( *iUnknownNumber ); |
|
257 break; |
|
258 |
|
259 case ETypePayphone: |
|
260 MakeTitleL( *iPayphoneNumber ); |
|
261 break; |
|
262 |
|
263 case ETypeEmerg: |
|
264 MakeTitleL( *iEmergencyCall ); |
|
265 break; |
|
266 |
|
267 case ETypeSAT: |
|
268 if( event->RemoteParty() ) |
|
269 { |
|
270 // sat event with contact |
|
271 MakeTitleL( *(event->RemoteParty()) ); |
|
272 } |
|
273 else |
|
274 { |
|
275 MakeTitleL( *iOperServNumber ); |
|
276 } |
|
277 break; |
|
278 |
|
279 default: |
|
280 __ASSERT_DEBUG( EFalse, User::Panic( KPanicText_DetailsCC, KErrCorrupt )); |
|
281 break; |
|
282 } |
|
283 } |
|
284 |
|
285 TTime time( event->Time() ); |
|
286 |
|
287 HBufC* dateTextBuf = HBufC::NewLC( KLogsBuff128 ); |
|
288 TPtr dateText( dateTextBuf->Des() ); |
|
289 // Get date string in the format that current localisation requires. |
|
290 // Date "12/12" |
|
291 HBufC* textFromResourceFile = iCoeEnv->AllocReadResourceLC( |
|
292 R_QTN_DATE_WITHOUT_YEAR_WITH_ZERO ); |
|
293 |
|
294 time.FormatL( dateText, *textFromResourceFile ); |
|
295 CleanupStack::PopAndDestroy(); // textFromResourceFile |
|
296 |
|
297 HBufC* timeTextBuf = HBufC::NewLC( KLogsBuff128 ); |
|
298 TPtr timeText( timeTextBuf->Des() ); |
|
299 // Get time string in the format that current localisation requires. |
|
300 // Time "hh:mm" +PM/AM if needed |
|
301 textFromResourceFile = iCoeEnv->AllocReadResourceLC( |
|
302 R_QTN_TIME_USUAL_WITH_ZERO ); |
|
303 |
|
304 time.FormatL( timeText, *textFromResourceFile ); |
|
305 CleanupStack::PopAndDestroy(); // textFromResourceFile |
|
306 |
|
307 TBuf<KLogsBuff256> wholeTextBuf; |
|
308 wholeTextBuf.Append( dateText ); |
|
309 wholeTextBuf.Append( KSpace ); |
|
310 wholeTextBuf.Append( timeText ); |
|
311 |
|
312 AknTextUtils::LanguageSpecificNumberConversion( wholeTextBuf ); |
|
313 |
|
314 CAknTabGroup* tabGroup = static_cast<CAknTabGroup*>( |
|
315 iDecoratedTabGroup-> |
|
316 DecoratedControl() ); |
|
317 |
|
318 tabGroup->ReplaceTabL( 0, wholeTextBuf ); |
|
319 |
|
320 // timeTextBuf, dateTextBuf |
|
321 CleanupStack::PopAndDestroy( 2 ); |
|
322 tabGroup->SetActiveTabByIndex( 0 ); /// Activating the tab to show |
|
323 |
|
324 //If mirrored display right and left arrow dimmed vice versa to western display |
|
325 enum CAknNavigationDecorator::TScrollButton fwrd = |
|
326 AknLayoutUtils::LayoutMirrored() ? CAknNavigationDecorator::ELeftButton : |
|
327 CAknNavigationDecorator::ERightButton; |
|
328 enum CAknNavigationDecorator::TScrollButton back = |
|
329 AknLayoutUtils::LayoutMirrored() ? CAknNavigationDecorator::ERightButton : |
|
330 CAknNavigationDecorator::ELeftButton; |
|
331 |
|
332 //Fix for ESZG-6SYDD6. In 3.1 the platfrom seems wrongly to undim scroll buttons |
|
333 //when only one entry and navigating left/right. |
|
334 if ( iView->Engine()->Model( ELogsMainModel )->Count() == 1 ) |
|
335 { |
|
336 iDecoratedTabGroup->MakeScrollButtonVisible( EFalse ); |
|
337 } |
|
338 else |
|
339 { |
|
340 iDecoratedTabGroup->MakeScrollButtonVisible( ETrue ); |
|
341 } |
|
342 |
|
343 //Set scroll arrows |
|
344 if ( iView->LogsAppUi()->EventListViewCurrent() == 0 ) |
|
345 { |
|
346 iDecoratedTabGroup->SetScrollButtonDimmed(back, ETrue); |
|
347 } |
|
348 else |
|
349 { |
|
350 iDecoratedTabGroup->SetScrollButtonDimmed(back, EFalse); |
|
351 } |
|
352 |
|
353 if ( iView->LogsAppUi()->EventListViewCurrent() == |
|
354 iView->Engine()->Model( ELogsMainModel )->Count() - 1 ) |
|
355 { |
|
356 iDecoratedTabGroup->SetScrollButtonDimmed(fwrd, ETrue); |
|
357 } |
|
358 else |
|
359 { |
|
360 iDecoratedTabGroup->SetScrollButtonDimmed(fwrd, EFalse); |
|
361 } |
|
362 |
|
363 /// Makes the whole thing visible |
|
364 NaviPaneL()->PushL( *( iDecoratedTabGroup ) ); |
|
365 } |
|
366 |
|
367 // ---------------------------------------------------------------------------- |
|
368 // CLogsDetailControlContainer::ComponentControl |
|
369 // ---------------------------------------------------------------------------- |
|
370 // |
|
371 CCoeControl* CLogsDetailControlContainer::ComponentControl |
|
372 ( TInt /*aIndex*/ ) const |
|
373 { |
|
374 return iListBox; |
|
375 } |
|
376 |
|
377 |
|
378 // ---------------------------------------------------------------------------- |
|
379 // CLogsDetailControlContainer::SizeChanged |
|
380 // ---------------------------------------------------------------------------- |
|
381 // |
|
382 void CLogsDetailControlContainer::SizeChanged() |
|
383 { |
|
384 if( iListBox ) |
|
385 { |
|
386 TInt textWidth = 0; |
|
387 |
|
388 //parent rectangle |
|
389 iListBox->SetRect( Rect() ); |
|
390 |
|
391 //calculate max width in pixels available for a row |
|
392 TRect main_pane = iListBox->Rect(); |
|
393 TAknWindowLineLayout line3 = AknLayout::list_gen_pane(0); |
|
394 TAknLayoutRect rect2; |
|
395 rect2.LayoutRect(main_pane, line3); |
|
396 TRect list_gen_pane = rect2.Rect(); |
|
397 TAknWindowLineLayout line2 = AknLayout::list_single_heading_pane(0); |
|
398 TAknLayoutRect rect; |
|
399 rect.LayoutRect(list_gen_pane, line2); |
|
400 TRect list_single_heading_pane = rect.Rect(); |
|
401 |
|
402 TAknTextLineLayout line = AknLayout::List_pane_texts__single_heading__Line_2(0); //Same in CLogsDetailAdapter::LineFont |
|
403 TAknLayoutText text; |
|
404 text.LayoutText(list_single_heading_pane, line); |
|
405 textWidth = text.TextRect().Width(); |
|
406 |
|
407 // Then update this value to adapter as it needs to truncate shown data if necessary |
|
408 iAdapter->SetLineWidth(textWidth); |
|
409 } |
|
410 } |
|
411 |
|
412 // ---------------------------------------------------------------------------- |
|
413 // CLogsDetailControlContainer::ListBox |
|
414 // ---------------------------------------------------------------------------- |
|
415 // |
|
416 CAknSingleHeadingStyleListBox* CLogsDetailControlContainer::ListBox() |
|
417 { |
|
418 return iListBox; |
|
419 } |
|
420 |
|
421 // ---------------------------------------------------------------------------- |
|
422 // CLogsDetailControlContainer::UpdateL |
|
423 // ---------------------------------------------------------------------------- |
|
424 // |
|
425 void CLogsDetailControlContainer::UpdateL() |
|
426 { |
|
427 iAdapter->UpdateL(); |
|
428 InitNaviPaneL(); |
|
429 iListBox->HandleItemAdditionL(); //...MdcaPoint will be called later... |
|
430 } |
|
431 |
|
432 // ---------------------------------------------------------------------------- |
|
433 // CLogsDetailControlContainer::GetHelpContext |
|
434 // ---------------------------------------------------------------------------- |
|
435 // |
|
436 void CLogsDetailControlContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
437 { |
|
438 aContext.iMajor = TUid::Uid( KLogsAppUID3 ); |
|
439 aContext.iContext = KLOGS_HLP_DETAIL; |
|
440 } |
|
441 |
|
442 // ---------------------------------------------------------------------------- |
|
443 // CLogsDetailControlContainer::FocusChanged |
|
444 // |
|
445 // This is needed to hand focus changes to list. Otherwise animations are not displayed. |
|
446 // ---------------------------------------------------------------------------- |
|
447 // |
|
448 void CLogsDetailControlContainer::FocusChanged(TDrawNow /* aDrawNow */ ) |
|
449 { |
|
450 if( iListBox) |
|
451 { |
|
452 iListBox->SetFocus( IsFocused() ); |
|
453 } |
|
454 } |
|
455 |
|
456 // End of File |