|
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 * Adaptor to RecentModel, copies data from model listbox |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <eiklabel.h> |
|
22 #include <eikfrlbd.h> |
|
23 #include <eikfrlb.h> |
|
24 #include <Logs.rsg> |
|
25 #include <gulicon.h> |
|
26 #include <VPbkEng.rsg> |
|
27 #include <PbkFields.hrh> |
|
28 |
|
29 #include "CLogsRecentListAdapter.h" |
|
30 #include "CLogsRecentListView.h" |
|
31 #include "CLogsRecentListControlContainer.h" |
|
32 #include "CLogsEngine.h" |
|
33 #include "MLogsModel.h" |
|
34 #include "MLogsEventGetter.h" |
|
35 //For ring duation feature |
|
36 #include "MLogsSharedData.h" |
|
37 #include "MLogsUiControlExtension.h" |
|
38 #include "CPhoneNumberFormat.h" |
|
39 |
|
40 #include "LogsConstants.hrh" |
|
41 #include "LogsConsts.h" |
|
42 |
|
43 // EXTERNAL DATA STRUCTURES |
|
44 |
|
45 // EXTERNAL FUNCTION PROTOTYPES |
|
46 |
|
47 // CONSTANTS |
|
48 //const TInt KVtIconOffsetFromLastOwnIcon = 1; |
|
49 |
|
50 //For ring duation feature |
|
51 // One minute - 60 seconds |
|
52 const TInt KLogsOneMinute = 60; |
|
53 |
|
54 // String literal for zero |
|
55 _LIT( KLogsOneZero, "0" ); |
|
56 |
|
57 |
|
58 // MACROS |
|
59 |
|
60 // LOCAL CONSTANTS AND MACROS |
|
61 |
|
62 // MODULE DATA STRUCTURES |
|
63 |
|
64 // LOCAL FUNCTION PROTOTYPES |
|
65 |
|
66 // ================= MEMBER FUNCTIONS ======================= |
|
67 |
|
68 // ---------------------------------------------------------------------------- |
|
69 // CLogsRecentListAdapter::NewL |
|
70 // ---------------------------------------------------------------------------- |
|
71 // |
|
72 CLogsRecentListAdapter* CLogsRecentListAdapter::NewL( |
|
73 CLogsRecentListControlContainer* aContainer, |
|
74 TInt aLastOwnIconOffset ) |
|
75 { |
|
76 CLogsRecentListAdapter* self = new( ELeave ) CLogsRecentListAdapter( |
|
77 aContainer, |
|
78 aLastOwnIconOffset ); |
|
79 |
|
80 CleanupStack::PushL( self ); |
|
81 self->ConstructL(); |
|
82 CleanupStack::Pop(self); |
|
83 return self; |
|
84 } |
|
85 |
|
86 // ---------------------------------------------------------------------------- |
|
87 // CLogsRecentListAdapter::CLogsRecentListAdapter |
|
88 // ---------------------------------------------------------------------------- |
|
89 // |
|
90 CLogsRecentListAdapter::CLogsRecentListAdapter( |
|
91 CLogsRecentListControlContainer* aContainer, |
|
92 TInt aLastOwnIconOffset ) : |
|
93 iModel( aContainer->View()->CurrentModel() ), |
|
94 iSharedData( *( aContainer->View()->Engine()->SharedDataL() )), |
|
95 iControlExtension( aContainer->ControlExtension() ), |
|
96 iListBox( aContainer->ListBox() ), |
|
97 iLastOwnIconOffset( aLastOwnIconOffset ), |
|
98 iEngine( aContainer->View()->Engine() ) |
|
99 { |
|
100 } |
|
101 |
|
102 // ---------------------------------------------------------------------------- |
|
103 // CLogsRecentListAdapter::ConstructL |
|
104 // ---------------------------------------------------------------------------- |
|
105 // |
|
106 void CLogsRecentListAdapter::ConstructL() |
|
107 { |
|
108 CEikonEnv* env = CEikonEnv::Static(); |
|
109 iDateResource = env->AllocReadResourceL( R_QTN_DATE_USUAL ); |
|
110 iTimeResource = env->AllocReadResourceL( R_QTN_TIME_USUAL ); |
|
111 |
|
112 iPrivateNumber = env->AllocReadResourceL(R_DLOGS_DETAILS_PRIVATE_NUMBER); |
|
113 iUnknownNumber = env->AllocReadResourceL(R_DLOGS_DETAILS_UNKNOWN_NUMBER); |
|
114 iPayphoneNumber = env->AllocReadResourceL(R_DLOGS_DETAILS_PAYPHONE_NUMBER); |
|
115 |
|
116 iSATNumber = env->AllocReadResourceL( R_LOGS_CON_OPER_SERV ); |
|
117 iGroupCall = env->AllocReadResourceL( R_LOGS_CON_GROUP_CALL ); |
|
118 iEmergencyCall = env->AllocReadResourceL( R_LOGS_EMERG_CALL ); |
|
119 |
|
120 iBuffer = HBufC::NewL( KLogsBuff128 ); |
|
121 iListboxFont = LineFont(); |
|
122 |
|
123 iPhoneNumber = CPhoneNumberFormat::NewL(); |
|
124 |
|
125 // Array for text widths for different resolutions. Initialize to zero |
|
126 iTextWidth = new (ELeave) TInt[KMaxNbrOfRecentTrailIcons + 1]; |
|
127 for(TInt trailIcons = 0; trailIcons <= KMaxNbrOfRecentTrailIcons; trailIcons++) |
|
128 { |
|
129 iTextWidth[trailIcons] = 0; |
|
130 } |
|
131 |
|
132 //For ring duation feature |
|
133 iShowRingDuration = iSharedData.ShowRingDuration(); |
|
134 } |
|
135 |
|
136 // ---------------------------------------------------------------------------- |
|
137 // CLogsRecentListAdapter::~CLogsRecentListAdapter |
|
138 // ---------------------------------------------------------------------------- |
|
139 // |
|
140 CLogsRecentListAdapter::~CLogsRecentListAdapter() |
|
141 { |
|
142 delete[] iTextWidth; |
|
143 delete iBuffer; |
|
144 delete iDateResource; |
|
145 delete iTimeResource; |
|
146 delete iPrivateNumber; |
|
147 delete iUnknownNumber; |
|
148 delete iPayphoneNumber; |
|
149 delete iEmergencyCall; |
|
150 delete iSATNumber; |
|
151 delete iGroupCall; |
|
152 delete iPhoneNumber; |
|
153 } |
|
154 |
|
155 |
|
156 // ---------------------------------------------------------------------------- |
|
157 // CLogsRecentListAdapter::DateTimeLocalizationL |
|
158 // ---------------------------------------------------------------------------- |
|
159 // |
|
160 void CLogsRecentListAdapter::DateTimeLocalizationL( |
|
161 const MLogsEventGetter* aEvent, |
|
162 TPtr& aPtr ) const |
|
163 { |
|
164 TTime time( aEvent->Time() ); |
|
165 |
|
166 HBufC* dateOrTimeTextBuf = HBufC::NewLC( KLogsBuff128 ); |
|
167 TPtr dateOrTimeText = dateOrTimeTextBuf->Des(); |
|
168 |
|
169 // Date |
|
170 time.FormatL( dateOrTimeText, *iDateResource ); |
|
171 |
|
172 // Arabic & Hebrew conversion if needed. |
|
173 AknTextUtils::LanguageSpecificNumberConversion(dateOrTimeText); |
|
174 aPtr.Append( dateOrTimeText ); |
|
175 aPtr.Append(KSpace); |
|
176 |
|
177 // Time |
|
178 time.FormatL( dateOrTimeText, *iTimeResource); |
|
179 |
|
180 // Arabic & Hebrew conversion if needed. |
|
181 AknTextUtils::LanguageSpecificNumberConversion(dateOrTimeText); |
|
182 aPtr.Append( dateOrTimeText ); |
|
183 CleanupStack::PopAndDestroy( dateOrTimeTextBuf ); |
|
184 } |
|
185 |
|
186 |
|
187 // ---------------------------------------------------------------------------- |
|
188 // CLogsRecentListAdapter::MdcaCount |
|
189 // ---------------------------------------------------------------------------- |
|
190 // |
|
191 TInt CLogsRecentListAdapter::MdcaCount () const |
|
192 { |
|
193 return iModel->Count(); |
|
194 } |
|
195 |
|
196 // ---------------------------------------------------------------------------- |
|
197 // CLogsRecentListAdapter::MdcaPoint |
|
198 // ---------------------------------------------------------------------------- |
|
199 // |
|
200 TPtrC16 CLogsRecentListAdapter::MdcaPoint( TInt aIndex ) const |
|
201 { |
|
202 TBuf<KNonClipDuplBufferLength> duplBuffer( KNullDesC ); |
|
203 TInt duplBufferPixels( 0 ); |
|
204 |
|
205 // double graphic style "0\tText\tText2\t1 |
|
206 TPtr ptr( iBuffer->Des() ); |
|
207 const MLogsEventGetter* event = iModel->At( aIndex ); |
|
208 |
|
209 |
|
210 /******************************************************************************** |
|
211 //Show corresponding icon for this type of phonenumber. FieldId is in the |
|
212 //event data, iIconIdArray contains corresponding iconId for this phonebook field. |
|
213 TInt iconIndex( KErrNotFound ); |
|
214 |
|
215 TInt fldId = event->FieldId(); |
|
216 if( fldId >= 0 && fldId <= iIconIdArray->Count() ) |
|
217 { |
|
218 iconIndex = iIconIdArray->At( fldId ); |
|
219 } |
|
220 |
|
221 //Default icon for phone number type. If no icon available for this field type, we use the |
|
222 //second icon (offset 1) as default icon (offset 0 is empty icon). |
|
223 if( iconIndex == KErrNotFound && iIconIdArray->Count() >= 1 ) |
|
224 { |
|
225 iconIndex = 1; //Offset 1 icon used as default icon (offset 0 is empty icon) |
|
226 } |
|
227 ********************************************************************************/ |
|
228 |
|
229 //Trailing icons need to be loaded now that we know to leave enough room to them. |
|
230 //Max KMaxNbrOfRecentTrailIcons icons can be shown simultaneously |
|
231 //on a line. Presence icon is always most right. Video telephony/ALS icon |
|
232 //on the left side of presence icon. VT cannot be received to |
|
233 //alt line so VT and ALS are mutually exclusive |
|
234 TBuf<KRecentMaxTextLength> iconBuff(0); //Initial size 0 |
|
235 TInt numIcons(0); |
|
236 |
|
237 // ALS2 icon is last own icon in icon array |
|
238 if( ( numIcons <= KMaxNbrOfRecentTrailIcons ) && // Append only if room for trailing icons |
|
239 ( iLastOwnIconOffset > 0 ) && // |
|
240 ( event->ALS() ) ) // and the ALS event flag is set |
|
241 |
|
242 { |
|
243 iconBuff.Append( KTab ); |
|
244 iconBuff.AppendNum( EIconAls ); |
|
245 numIcons++; |
|
246 } |
|
247 |
|
248 |
|
249 // Show new missed call icon if the event is unread |
|
250 // (set to read for received and dialed calls - see CLogsEvent.cpp) |
|
251 if (!event->Event()->IsRead()) |
|
252 { |
|
253 if( ( numIcons <= KMaxNbrOfRecentTrailIcons) && //append only if room for trailing icons |
|
254 iLastOwnIconOffset > 0 ) |
|
255 { |
|
256 iconBuff.Append( KTab ); |
|
257 iconBuff.AppendNum( EIconNewMissed ); // |
|
258 numIcons++; |
|
259 } |
|
260 } |
|
261 |
|
262 |
|
263 /******************************************************************************** |
|
264 Presence is not part of 3.x anymore |
|
265 //Presence icon |
|
266 TInt pecIconIndex( KErrNotFound ); |
|
267 TBool pecRc( EFalse ); |
|
268 TRAPD( pecErr, ( pecRc = iControlExtension->GetIconIndexL( |
|
269 event->Contact(), pecIconIndex ) ) ); |
|
270 |
|
271 if( ( numIcons <= KMaxNbrOfRecentTrailIcons) && //append only if room for trailing icons |
|
272 pecErr == KErrNone && pecRc && pecIconIndex > 0 ) |
|
273 { |
|
274 iconBuff.Append( KTab ); |
|
275 iconBuff.AppendNum( pecIconIndex ); |
|
276 numIcons++; |
|
277 } |
|
278 ********************************************************************************/ |
|
279 |
|
280 // First part: Show icon corresponding the phone number type |
|
281 if( event->LogsEventData()->PoC() ) |
|
282 { |
|
283 ptr.Num( EIconPoc ); |
|
284 } |
|
285 else if( event->LogsEventData()->VoIP() ) |
|
286 { |
|
287 ptr.Num( EIconVoip ); |
|
288 } |
|
289 else if( event->LogsEventData()->VT() ) |
|
290 { |
|
291 ptr.Num( EIconVideo ); |
|
292 } |
|
293 else |
|
294 { |
|
295 ptr.Num( NumberIconTypeFromPbkField( event->NumberFieldType() ) ); |
|
296 } |
|
297 |
|
298 //Second part: Show name, number... |
|
299 ptr.Append( KTab ); |
|
300 |
|
301 //Duplicate count "(n)" is added to end of contact, if duplicates |
|
302 // and event is unread (new missed call) |
|
303 if( event->Duplicates() > 0 && !event->Event()->IsRead()) |
|
304 { |
|
305 duplBuffer.Append( KOpenBracket ); |
|
306 duplBuffer.AppendNum( event->Duplicates() ); |
|
307 duplBuffer.Append( KCloseBracket ); |
|
308 AknTextUtils::LanguageSpecificNumberConversion( duplBuffer ); |
|
309 duplBufferPixels = iListboxFont->TextWidthInPixels( duplBuffer ); |
|
310 } |
|
311 else |
|
312 { |
|
313 duplBufferPixels = 0; |
|
314 } |
|
315 |
|
316 // For emergency calls, we prefer showing predefined string instead of possible |
|
317 // remoteparty (EJYU-79BCJY). |
|
318 if ( event->EventType() == ETypeEmerg ) |
|
319 { |
|
320 BuildDisplayString( ptr, duplBufferPixels, duplBuffer, numIcons, |
|
321 iEmergencyCall->Des() ); |
|
322 } |
|
323 else if( event->RemoteParty() ) |
|
324 { |
|
325 BuildDisplayString( ptr, duplBufferPixels, duplBuffer, numIcons, |
|
326 *(event->RemoteParty()) ); |
|
327 } |
|
328 else if( event->EventType() == ETypePrivate ) |
|
329 { |
|
330 BuildDisplayString( ptr, duplBufferPixels, duplBuffer, numIcons, |
|
331 iPrivateNumber->Des() ); |
|
332 } |
|
333 else if( event->EventType() == ETypePayphone ) |
|
334 { |
|
335 BuildDisplayString( ptr, duplBufferPixels, duplBuffer, numIcons, |
|
336 iPayphoneNumber->Des() ); |
|
337 } |
|
338 else if ( event->EventType() == ETypeSAT ) |
|
339 { |
|
340 BuildDisplayString( ptr, duplBufferPixels, duplBuffer, numIcons, |
|
341 iSATNumber->Des() ); |
|
342 } |
|
343 else if ( event->EventType() == ETypePoCGroupCall ) //Nothing in remote party and is PoC group call, |
|
344 { //so show "Group call" |
|
345 BuildDisplayString( ptr, duplBufferPixels, duplBuffer, numIcons, |
|
346 iGroupCall->Des() ); |
|
347 } |
|
348 else if( event->Number() ) |
|
349 { |
|
350 //We prefer showing phone number over sip uri although for making calls uri is preferred (if both |
|
351 //available, Poc has made a "best guess" for corresponding msisdn for subsequent cs calls). |
|
352 TBuf<KRecentMaxTextLength> formattedNbr(KNullDesC); |
|
353 iPhoneNumber->PhoneNumberFormat( *(event->Number()), formattedNbr ); |
|
354 BuildDisplayString( ptr, duplBufferPixels, duplBuffer, numIcons, |
|
355 formattedNbr, |
|
356 AknTextUtils::EClipFromBeginning ); |
|
357 } |
|
358 else if( event->LogsEventData()->Url().Length() > 0 ) |
|
359 { |
|
360 TBuf<KRecentMaxTextLength> buf; |
|
361 iEngine->ConvertToUnicode( event->LogsEventData()->Url(), buf ); |
|
362 BuildDisplayString( ptr, duplBufferPixels, duplBuffer, numIcons, |
|
363 buf ); |
|
364 } |
|
365 else //Nothing to show. Display "Unknown" |
|
366 { |
|
367 BuildDisplayString( ptr, duplBufferPixels, duplBuffer, numIcons, |
|
368 iUnknownNumber->Des() ); |
|
369 } |
|
370 |
|
371 //Third part: Show date & time (displayed on the second double graphic style row) |
|
372 ptr.Append( KTab ); |
|
373 TRAPD( err, DateTimeLocalizationL( event, ptr) ); |
|
374 |
|
375 if( err == KErrOverflow || err == KErrGeneral ) |
|
376 { |
|
377 ptr.Append(KSpace); |
|
378 } |
|
379 else if (err) |
|
380 { |
|
381 CCoeEnv::Static()->HandleError( err ); |
|
382 } |
|
383 |
|
384 //Fourth part: Show trailing icons, if any. |
|
385 ptr.Append( iconBuff ); |
|
386 |
|
387 //For ring duation feature |
|
388 //Fifth part: Show ring duration for missed call |
|
389 TLogsDirection dir = event->Direction(); |
|
390 |
|
391 if (( iShowRingDuration ) && ( dir == EDirMissed )) |
|
392 { |
|
393 AppendRingDuration( *event, ptr ); |
|
394 } |
|
395 |
|
396 // Sawfish VoIP changes >>>> |
|
397 // Modify the string so, that the correct icon indices appear in the string |
|
398 // Details: This function creates an icon string (e.g. '0\tLabel1\tLabel2') |
|
399 // whereas '0' refers to the icon index in the listbox's icon array. A possible |
|
400 // modified icon string for the example icon string given above would be: |
|
401 // '6\tLabel1\tLabel2\t\t\t8' ('6' is the index of an icon in the A-column, '8' |
|
402 // the index of an icon in the D-column of a listbox-entry) |
|
403 if ( iControlExtension && event ) |
|
404 { |
|
405 iControlExtension->ModifyIconString( |
|
406 ptr, |
|
407 *event ); |
|
408 } |
|
409 // <<<< Sawfish VoIP changes |
|
410 |
|
411 return *iBuffer; |
|
412 } |
|
413 |
|
414 // ---------------------------------------------------------------------------- |
|
415 // CLogsRecentListAdapter::BuildDisplayString |
|
416 // ---------------------------------------------------------------------------- |
|
417 // |
|
418 void CLogsRecentListAdapter::BuildDisplayString( |
|
419 TDes& aDest, |
|
420 TInt aDuplBufPixels, |
|
421 TDesC& aDuplBuffer, |
|
422 TInt aNumIcons, |
|
423 TPtrC aOriginal, |
|
424 AknTextUtils::TClipDirection aClipDirection //Beginning=>Treat this as phonenumber, |
|
425 ) const //End=>Treat as 'normal' string |
|
426 { |
|
427 TBuf<KRecentMaxTextLength> clippedText; |
|
428 |
|
429 //If the original text is longer than KRecentMaxTextLength, cut it first |
|
430 TInt origLen = aOriginal.Length(); |
|
431 clippedText.Append( aOriginal.Ptr(), |
|
432 ( origLen < KRecentMaxTextLength ) ? origLen : |
|
433 KRecentMaxTextLength ); |
|
434 |
|
435 // Lets replace paragraph delimiters with single white space, fix for EBWG-6ZPCMZ |
|
436 TBuf<1> charsToRemove; |
|
437 charsToRemove.Append(TChar(TInt(CEditableText::EParagraphDelimiter))); |
|
438 AknTextUtils::ReplaceCharacters(clippedText, charsToRemove, TChar(TInt(CEditableText::ESpace))); |
|
439 // Lets strip control chars like tabulator marks which would break the listbox descriptor, see OJON-7CA9SU |
|
440 AknTextUtils::StripCharacters(clippedText, KAknStripListControlChars); |
|
441 |
|
442 TInt widthToClip = iTextWidth[aNumIcons] - aDuplBufPixels; |
|
443 /* FIXME: These rows should not be needed anymore and can be removed later. Replaced by row above |
|
444 //TInt widthToClip = iTextWidth[aNumIcons] - aDuplBufPixels -1; //We need -1 pixels when there's trailing icon in mirrored layout |
|
445 // The row above did not work properly in other resolutions than 176*208, therefore temporarily replaced by the row below because we |
|
446 // need to leave enough room for text in all layout combinations. For this reason we additionally narrow the width by |
|
447 // amount needed by one trailing icon: (iTextWidth[1] - iTextWidth[2]). |
|
448 TInt widthToClip = iTextWidth[aNumIcons] - aDuplBufPixels - (iTextWidth[1] - iTextWidth[2]); |
|
449 */ |
|
450 |
|
451 AknTextUtils::ClipToFit |
|
452 ( clippedText |
|
453 , *iListboxFont //current font used for rendering listbox row |
|
454 , widthToClip |
|
455 , aClipDirection //Clip from beginning or from end |
|
456 , KDefaultClipWidth |
|
457 , KThreeDots //three dots to end or beginning of number string |
|
458 ); |
|
459 |
|
460 //Append first part of string |
|
461 if( AknLayoutUtils::LayoutMirrored() && aClipDirection == AknTextUtils::EClipFromBeginning ) //We have phone number |
|
462 { |
|
463 //There has to be some additional room for directionality marks |
|
464 aDest.Append( 0x202A ); //LRE: Treat the following text as embedded left-to-right |
|
465 aDest.Append( clippedText ); //Show phone number completely left to right also in A&H |
|
466 aDest.Append( 0x202C ); //PDF: Restore the bidirectional state to what it was before the last LRE, RLE, RLO, LRO |
|
467 } |
|
468 else |
|
469 { |
|
470 aDest.Append( clippedText ); |
|
471 } |
|
472 |
|
473 //Append second part of string (if exists) |
|
474 if (AknLayoutUtils::LayoutMirrored()) |
|
475 { |
|
476 aDest.Append( 0x200F ); //This puts the following stuff to the left when mirrored layout |
|
477 aDest.Append( 0x202A ); //This keeps the brackets correctly on both sides of the duplicate number |
|
478 //We need this if there are western characters to be displayed with arabic layout |
|
479 } |
|
480 |
|
481 aDest.Append( aDuplBuffer ); //Finally append duplicates. We should have enough room to append the duplicate string without |
|
482 //another clipping (and another string of three dots) by listbox row. |
|
483 } |
|
484 |
|
485 |
|
486 |
|
487 // ---------------------------------------------------------------------------- |
|
488 // CLogsRecentListAdapter::SetLineWidth |
|
489 // |
|
490 // Sets the maximum width in pixels for the detail line. This needs to be called from controller's |
|
491 // SizeChanged() method. |
|
492 // ---------------------------------------------------------------------------- |
|
493 // |
|
494 void CLogsRecentListAdapter::SetLineWidth( |
|
495 TInt aTextWidth, |
|
496 TInt aNumOfTrailingIcons ) |
|
497 { |
|
498 iTextWidth[aNumOfTrailingIcons] = aTextWidth; |
|
499 iListboxFont = LineFont(); //Update font too as probably it has also changed. |
|
500 } |
|
501 |
|
502 |
|
503 // ---------------------------------------------------------------------------- |
|
504 // CLogsRecentListAdapter::LineFont |
|
505 // ---------------------------------------------------------------------------- |
|
506 // |
|
507 const CFont* CLogsRecentListAdapter::LineFont() |
|
508 { |
|
509 TAknTextLineLayout line = AknLayout::List_pane_texts__double_graphic__Line_1( 0 ); |
|
510 TAknLayoutText text; |
|
511 text.LayoutText( iListBox->Rect(), line ); |
|
512 return text.Font(); // text.Font() not owned |
|
513 } |
|
514 |
|
515 // ---------------------------------------------------------------------------- |
|
516 // CLogsRecentListAdapter::AppendRingDuration |
|
517 // |
|
518 // For ring duation feature |
|
519 // Append ring duration for missed calls |
|
520 // ---------------------------------------------------------------------------- |
|
521 // |
|
522 void CLogsRecentListAdapter::AppendRingDuration( |
|
523 const MLogsEventGetter& aEvent, |
|
524 TPtr& aPtr ) const |
|
525 { |
|
526 //Add duration if it is missed call |
|
527 TLogDuration ringDuration = aEvent.RingDuration(); |
|
528 aPtr.Append( KSpace ); |
|
529 |
|
530 // Format ring duration |
|
531 TBuf<10> ringDurationTxt( KNullDesC ); |
|
532 FormatRingDuration( ringDurationTxt, (TInt)ringDuration ); |
|
533 AknTextUtils::LanguageSpecificNumberConversion( ringDurationTxt ); |
|
534 aPtr.Append( ringDurationTxt ); |
|
535 } |
|
536 |
|
537 // ---------------------------------------------------------------------------- |
|
538 // CLogsRecentListAdapter::FormatRingDuration |
|
539 // |
|
540 // Format ring duation as 00:00 |
|
541 // ---------------------------------------------------------------------------- |
|
542 // |
|
543 void CLogsRecentListAdapter::FormatRingDuration( |
|
544 TDes& aDesc, |
|
545 TInt aSeconds ) const |
|
546 { |
|
547 aDesc.Zero(); |
|
548 TLocale locale; |
|
549 |
|
550 TInt minutes = aSeconds / KLogsOneMinute; |
|
551 AppendNum( aDesc, minutes ); |
|
552 |
|
553 AppendChar( aDesc, locale.TimeSeparator( 2 ) ); // minute seperator |
|
554 |
|
555 TInt seconds2 = aSeconds - minutes * KLogsOneMinute; |
|
556 AppendNum( aDesc, seconds2 ); |
|
557 |
|
558 } |
|
559 |
|
560 // ---------------------------------------------------------------------------- |
|
561 // CLogsRecentListAdapter::AppendNum |
|
562 // |
|
563 // Append 2 digit number, if it is one digit number, insert zero before the number |
|
564 // ---------------------------------------------------------------------------- |
|
565 // |
|
566 void CLogsRecentListAdapter::AppendNum( |
|
567 TDes& aDesc, |
|
568 TInt aNum ) const |
|
569 { |
|
570 if ( aNum < 0 ) // Negative value not accepted - make it zero |
|
571 { |
|
572 aNum = 0; |
|
573 } |
|
574 |
|
575 if ( aNum >= KLogsOneMinute ) // Too large values are not accepted |
|
576 { |
|
577 aNum = KLogsOneMinute; |
|
578 aNum--; |
|
579 } |
|
580 |
|
581 if ( aNum < 10 ) // Two digits |
|
582 { |
|
583 aDesc.Append( KLogsOneZero ); |
|
584 } |
|
585 aDesc.AppendNum( aNum ); |
|
586 } |
|
587 |
|
588 // ---------------------------------------------------------------------------- |
|
589 // CLogsRecentListAdapter::AppendChar |
|
590 // |
|
591 // Append char if it is valid |
|
592 // ---------------------------------------------------------------------------- |
|
593 // |
|
594 inline void CLogsRecentListAdapter::AppendChar( |
|
595 TDes& aDesc, |
|
596 TChar aCh ) const |
|
597 { |
|
598 if ( aCh ) // 0 -> no character defined |
|
599 { |
|
600 aDesc.Append( aCh ); |
|
601 } |
|
602 } |
|
603 |
|
604 // ---------------------------------------------------------------------------- |
|
605 // CLogsRecentListAdapter::NumberIconTypeFromVPbk |
|
606 // |
|
607 // Get the icon type mapped to vpbk field type |
|
608 // ---------------------------------------------------------------------------- |
|
609 // no use currently, use it just incase the Phone's implementation changes |
|
610 RecentListIconArrayIcons CLogsRecentListAdapter::NumberIconTypeFromVPbk( TInt aNumberFieldType ) const |
|
611 { |
|
612 RecentListIconArrayIcons iconType = EIconDefault; |
|
613 |
|
614 switch ( aNumberFieldType ) |
|
615 { |
|
616 case R_VPBK_FIELD_TYPE_MOBILEPHONEGEN: |
|
617 case R_VPBK_FIELD_TYPE_MOBILEPHONEWORK: |
|
618 case R_VPBK_FIELD_TYPE_MOBILEPHONEHOME: |
|
619 iconType = EIconMobile; |
|
620 break; |
|
621 |
|
622 case R_VPBK_FIELD_TYPE_LANDPHONEHOME: |
|
623 case R_VPBK_FIELD_TYPE_LANDPHONEWORK: |
|
624 case R_VPBK_FIELD_TYPE_LANDPHONEGEN: |
|
625 iconType = EIconlandphone; |
|
626 break; |
|
627 |
|
628 case R_VPBK_FIELD_TYPE_PAGERNUMBER: |
|
629 iconType = EIconPager; |
|
630 break; |
|
631 |
|
632 case R_VPBK_FIELD_TYPE_FAXNUMBERGEN: |
|
633 case R_VPBK_FIELD_TYPE_FAXNUMBERHOME: |
|
634 case R_VPBK_FIELD_TYPE_FAXNUMBERWORK: |
|
635 iconType = EIconFax; |
|
636 break; |
|
637 |
|
638 case R_VPBK_FIELD_TYPE_ASSTPHONE: |
|
639 iconType = EIconAsstPhone; |
|
640 break; |
|
641 |
|
642 case R_VPBK_FIELD_TYPE_CARPHONE: |
|
643 iconType = EIconCarPhone; |
|
644 break; |
|
645 |
|
646 default: |
|
647 break; |
|
648 } |
|
649 |
|
650 return iconType; |
|
651 } |
|
652 |
|
653 // ---------------------------------------------------------------------------- |
|
654 // CLogsRecentListAdapter::NumberIconTypeFromPbkField |
|
655 // |
|
656 // Get the icon type mapped to phonebook field type |
|
657 // ---------------------------------------------------------------------------- |
|
658 // |
|
659 RecentListIconArrayIcons CLogsRecentListAdapter::NumberIconTypeFromPbkField( TInt aNumberFieldType ) const |
|
660 { |
|
661 RecentListIconArrayIcons iconType = EIconDefault; |
|
662 |
|
663 switch( aNumberFieldType ) |
|
664 { |
|
665 case EPbkFieldIdPhoneNumberMobile: |
|
666 iconType = EIconMobile; |
|
667 break; |
|
668 |
|
669 case EPbkFieldIdPhoneNumberGeneral: |
|
670 iconType = EIconlandphone; |
|
671 break; |
|
672 |
|
673 case EPbkFieldIdPagerNumber: |
|
674 iconType = EIconPager; |
|
675 break; |
|
676 |
|
677 case EPbkFieldIdFaxNumber: |
|
678 iconType = EIconFax; |
|
679 break; |
|
680 |
|
681 case EPbkFieldIdAssistantNumber: |
|
682 iconType = EIconAsstPhone; |
|
683 break; |
|
684 |
|
685 case EPbkFieldIdCarNumber: |
|
686 iconType = EIconCarPhone; |
|
687 break; |
|
688 |
|
689 default: |
|
690 break; |
|
691 } |
|
692 |
|
693 return iconType; |
|
694 } |
|
695 |
|
696 |
|
697 // End of File |