|
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 * Adapts data from logsmodel to logs ui component (listbox) format |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
22 #include <logfilterandeventconstants.hrh> |
|
23 #endif |
|
24 #include <logcli.h> // clogclient |
|
25 #include <eiklabel.h> // ceiklabel |
|
26 #include <AknUtils.h> |
|
27 #include <aknlists.h> //caknsingleheadingstylelistbox |
|
28 |
|
29 #include <Logs.rsg> // detail view's event type texts. |
|
30 |
|
31 #include "CLogsDetailAdapter.h" |
|
32 #include "CLogsDetailView.h" |
|
33 #include "MLogsEventGetter.h" |
|
34 #include "MLogsGetEvent.h" |
|
35 #include "CPhoneNumberFormat.h" |
|
36 |
|
37 #include "LogsConstants.hrh" |
|
38 #include "LogsConsts.h" |
|
39 #include "CLogsEngine.h" |
|
40 #include <LogsApiConsts.h> //additional event uids |
|
41 |
|
42 // CONSTANTS |
|
43 //_LIT(KPanic,"LogsDetailAdapter"); |
|
44 |
|
45 // ================= MEMBER FUNCTIONS ======================= |
|
46 |
|
47 |
|
48 // ---------------------------------------------------------------------------- |
|
49 // CLogsDetailAdapter::CLogsDetailAdapter |
|
50 // ---------------------------------------------------------------------------- |
|
51 // |
|
52 CLogsDetailAdapter::CLogsDetailAdapter( |
|
53 CAknSingleHeadingStyleListBox* aListBox, |
|
54 CLogsDetailView* aView ) : |
|
55 iEngine( aView->Engine()), |
|
56 iGetter( aView->Engine()->GetEventL()), |
|
57 iListBox( aListBox ), |
|
58 iView( aView ) |
|
59 { |
|
60 } |
|
61 |
|
62 // ---------------------------------------------------------------------------- |
|
63 // CLogsDetailAdapter::ConstructL |
|
64 // ---------------------------------------------------------------------------- |
|
65 // |
|
66 void CLogsDetailAdapter::ConstructL() |
|
67 { |
|
68 CEikonEnv* env = CEikonEnv::Static(); |
|
69 iDirection = env->AllocReadResourceL(R_LOGS_DETAIL_DIRECTION_TEXT); |
|
70 iType = env->AllocReadResourceL(R_LOGS_DETAIL_TYPE_TEXT); |
|
71 iStatus = env->AllocReadResourceL(R_LOGS_DETAIL_STATUS_TEXT); |
|
72 iDuration = env->AllocReadResourceL(R_LOGS_DETAIL_DURATION_TEXT); |
|
73 iAmount = env->AllocReadResourceL(R_LOGS_DETAIL_NUMBER_TEXT); |
|
74 |
|
75 iSentAmount = env->AllocReadResourceL(R_LOGS_DETAIL_SENT_TEXT); |
|
76 iReceivedAmount = env->AllocReadResourceL(R_LOGS_DETAIL_RECEIVED_TEXT); |
|
77 |
|
78 iAmountKB = env->AllocReadResourceL(R_LOGS_DETAIL_VIEW_KB_TEXT); |
|
79 iNbr = env->AllocReadResourceL(R_LOGS_DETAIL_TELNO_TEXT); |
|
80 iUnknownNumber = env->AllocReadResourceL(R_DLOGS_DETAILS_UNKNOWN_NUMBER); |
|
81 |
|
82 iDirectionIn = env->AllocReadResourceL(R_LOGS_DIR_IN_TEXT); |
|
83 iDirectionOut = env->AllocReadResourceL(R_LOGS_DIR_OUT_TEXT); |
|
84 iDirectionMissed = env->AllocReadResourceL(R_LOGS_DIR_MISSED_TEXT); |
|
85 iEventTypeVoice = env->AllocReadResourceL(R_LOGS_ET_CALL_TEXT); |
|
86 iEventTypeSMS = env->AllocReadResourceL(R_LOGS_ET_SMS_TEXT); |
|
87 iEventTypeMMS = env->AllocReadResourceL(R_LOGS_ET_MMS_TEXT); |
|
88 iEventTypeData = env->AllocReadResourceL(R_LOGS_ET_DATA_TEXT); |
|
89 iEventTypeGPRS = env->AllocReadResourceL(R_LOGS_ET_PACKET_TEXT); |
|
90 iEventTypeWLAN = env->AllocReadResourceL(R_LOGS_ET_WLAN_TEXT); |
|
91 iEventTypeFax = env->AllocReadResourceL(R_LOGS_ET_FAX_TEXT); |
|
92 iEventTypeVideo = env->AllocReadResourceL(R_LOGS_ET_VIDEO_TEXT); |
|
93 |
|
94 iEventTypePoC = env->AllocReadResourceL(R_LOGS_ET_POC_TEXT); |
|
95 iEventTypePoCInfo = env->AllocReadResourceL(R_LOGS_ET_POC_INFO_TEXT); |
|
96 |
|
97 iEventTypeVoIP = env->AllocReadResourceL(R_LOGS_ET_VOIP_TEXT); |
|
98 |
|
99 iPoCAddr = env->AllocReadResourceL(R_LOGS_ET_POC_ADDR); |
|
100 iVoIPCallFrom = env->AllocReadResourceL(R_LOGS_ET_VOIP_CALL_FROM); |
|
101 iVoIPCallTo = env->AllocReadResourceL(R_LOGS_ET_VOIP_CALL_TO); |
|
102 |
|
103 //Read strings from Symbian Log engine |
|
104 CLogClient* logClient = iEngine->CLogClientRef(); |
|
105 logClient->GetString( iEventStatusPendingTxt, R_LOG_DEL_PENDING ); |
|
106 logClient->GetString( iEventStatusSentTxt, R_LOG_DEL_SENT ); |
|
107 logClient->GetString( iEventStatusFailedTxt, R_LOG_DEL_FAILED ); |
|
108 logClient->GetString( iEventStatusNoDeliveryTxt, R_LOG_DEL_NONE ); |
|
109 logClient->GetString( iEventStatusDeliveredTxt, R_LOG_DEL_DONE ); |
|
110 logClient->GetString( iEventStatusNotSentTxt, R_LOG_DEL_NOT_SENT ); |
|
111 |
|
112 iEventStatusDelivered = env->AllocReadResourceL( |
|
113 R_LOGS_STATUS_DELIVERED_TEXT); |
|
114 iEventStatusPending = env->AllocReadResourceL(R_LOGS_STATUS_PENDING_TEXT); |
|
115 iEventStatusFailed = env->AllocReadResourceL(R_LOGS_STATUS_FAILURE_TEXT); |
|
116 iEventStatusSent = env->AllocReadResourceL(R_LOGS_STATUS_SENT_TEXT); |
|
117 iDurationFormat = env->AllocReadResourceL(R_QTN_TIME_DURAT_LONG_WITH_ZERO); |
|
118 |
|
119 iNumberFirstRow = HBufC::NewL( KLogsSipUriMaxLen ); |
|
120 iNumberSecondRow = HBufC::NewL( KLogsSipUriMaxLen ); |
|
121 |
|
122 iPhoneNbrFormatter = CPhoneNumberFormat::NewL(); |
|
123 LineFont(); |
|
124 iTextWidth = 0; |
|
125 } |
|
126 |
|
127 // ---------------------------------------------------------------------------- |
|
128 // CLogsDetailAdapter::NewL |
|
129 // ---------------------------------------------------------------------------- |
|
130 // |
|
131 CLogsDetailAdapter* CLogsDetailAdapter::NewL( |
|
132 CAknSingleHeadingStyleListBox* aListBox, |
|
133 CLogsDetailView* aView ) |
|
134 { |
|
135 CLogsDetailAdapter* self = new (ELeave) CLogsDetailAdapter( aListBox, aView ); |
|
136 CleanupStack::PushL( self ); |
|
137 self->ConstructL(); |
|
138 CleanupStack::Pop(); |
|
139 return self; |
|
140 } |
|
141 |
|
142 // ---------------------------------------------------------------------------- |
|
143 // CLogsDetailAdapter::~CLogsDetailAdapter |
|
144 // ---------------------------------------------------------------------------- |
|
145 // |
|
146 CLogsDetailAdapter::~CLogsDetailAdapter() |
|
147 { |
|
148 delete iDirection; |
|
149 delete iType; |
|
150 delete iStatus; |
|
151 delete iDuration; |
|
152 delete iAmount; |
|
153 delete iAmountKB; |
|
154 delete iNbr; |
|
155 delete iUnknownNumber; |
|
156 delete iDirectionIn; |
|
157 delete iDirectionOut; |
|
158 delete iDirectionMissed; |
|
159 |
|
160 delete iEventTypeVoice; |
|
161 delete iEventTypeSMS; |
|
162 delete iEventTypeMMS; |
|
163 delete iEventTypeData; |
|
164 delete iEventTypeGPRS; |
|
165 delete iEventTypeWLAN; |
|
166 delete iEventTypeFax; |
|
167 delete iEventTypeVideo; |
|
168 |
|
169 delete iEventTypePoC; |
|
170 delete iEventTypePoCInfo; |
|
171 delete iEventTypeVoIP; |
|
172 delete iPoCAddr; |
|
173 delete iVoIPCallFrom; |
|
174 delete iVoIPCallTo; |
|
175 |
|
176 delete iEventStatusDelivered; |
|
177 delete iEventStatusPending; |
|
178 delete iEventStatusFailed; |
|
179 delete iEventStatusSent; |
|
180 |
|
181 delete iDurationFormat; |
|
182 |
|
183 delete iNumberFirstRow; |
|
184 delete iNumberSecondRow; |
|
185 delete iSentAmount; |
|
186 delete iReceivedAmount; |
|
187 delete iPhoneNbrFormatter; |
|
188 |
|
189 delete iDisplayRows; |
|
190 } |
|
191 |
|
192 // ---------------------------------------------------------------------------- |
|
193 // CLogsDetailAdapter::UpdateL |
|
194 // ---------------------------------------------------------------------------- |
|
195 // |
|
196 void CLogsDetailAdapter::UpdateL() |
|
197 { |
|
198 iDisplayRowNumber = 0; |
|
199 |
|
200 const MLogsEventGetter* event = iEngine->GetEventL()->Event(); |
|
201 const CLogEvent* logDbEvent = iEngine->GetEventL()->LogEvent(); |
|
202 |
|
203 CDesCArrayFlat* newDisplayRows = new ( ELeave ) CDesCArrayFlat( 10 ); |
|
204 CleanupStack::PushL( newDisplayRows ); |
|
205 |
|
206 //1) Rows 1 and 2 show always direction and type of event |
|
207 DirectionRow( event ); |
|
208 newDisplayRows->AppendL( iBuffer ); |
|
209 iDisplayRowNumber++; |
|
210 |
|
211 TypeRow( event ); |
|
212 newDisplayRows->AppendL( iBuffer ); |
|
213 iDisplayRowNumber++; |
|
214 |
|
215 //2) Contents of rows 3-> depend on event type (and available data) |
|
216 //Status row of message from CLogEvent (only for sms/mms) |
|
217 if( StatusRow( logDbEvent, event ) ) |
|
218 { |
|
219 newDisplayRows->AppendL( iBuffer ); |
|
220 iDisplayRowNumber++; |
|
221 } |
|
222 |
|
223 //Duration. For missed and Poc calls shouldn't exist (=0), for other calls and wlan+gprs |
|
224 //duration shown if non-zero in the event (e.g. for gprs, duration is not updated |
|
225 //until context is closed, so first we don't show duration). For MO calls show even if zero. |
|
226 TBool showDuration( EFalse ); |
|
227 |
|
228 if( (( event->EventUid().iUid == KLogCallEventType || //For MO voip and MO cs |
|
229 event->LogsEventData()->VoIP() ) && //show duration even when |
|
230 event->Direction() == EDirOut )) //it is zero |
|
231 { |
|
232 showDuration = ETrue; |
|
233 } |
|
234 else if( logDbEvent->Duration() > 0 ) //For other show if available |
|
235 { |
|
236 showDuration = ETrue; |
|
237 } |
|
238 |
|
239 if( showDuration && |
|
240 !event->LogsEventData()->PoC() && //Exclude Poc, missed calls, messages just in case would |
|
241 event->Direction() != EDirMissed && //wrongly contain garbage in duration (should never happen) |
|
242 event->EventUid().iUid != KLogShortMessageEventType && |
|
243 event->EventUid().iUid != KLogsEngMmsEventType ) |
|
244 { |
|
245 DurationRow( logDbEvent ); |
|
246 newDisplayRows->AppendL( iBuffer ); |
|
247 iDisplayRowNumber++; |
|
248 } |
|
249 |
|
250 //Size. Number of message pdu's from CLogEvent (only for sms/mms) |
|
251 if( AmountRow( event )) //logDbEvent ) ) |
|
252 { |
|
253 newDisplayRows->AppendL( iBuffer ); |
|
254 iDisplayRowNumber++; |
|
255 } |
|
256 |
|
257 //Sent data (gprs, wlan, poc, voip) |
|
258 if( event->LogsEventData()->DataSent() > 0 || //voip, poc, only if > 0 |
|
259 event->EventUid().iUid == KLogsEngWlanEventType || //for wlan & gprs show also zero |
|
260 event->EventUid().iUid == KLogPacketDataEventType ) |
|
261 { |
|
262 SentAmountRow( event ); |
|
263 newDisplayRows->AppendL( iBuffer ); |
|
264 iDisplayRowNumber++; |
|
265 } |
|
266 |
|
267 //Received data (gprs, wlan, poc, voip) |
|
268 if( event->LogsEventData()->DataReceived() > 0 || |
|
269 event->EventUid().iUid == KLogsEngWlanEventType || |
|
270 event->EventUid().iUid == KLogPacketDataEventType ) |
|
271 { |
|
272 ReceivedAmountRow( event ); |
|
273 newDisplayRows->AppendL( iBuffer ); |
|
274 iDisplayRowNumber++; |
|
275 } |
|
276 |
|
277 //Number. Show if available, however for emergency calls not shown |
|
278 if( iView->PhoneNumberAvailable( event ) && event->EventType() != ETypeEmerg) |
|
279 { |
|
280 TBool split = SplitNumber( event, *iListboxFont, iTextWidth ); |
|
281 TelRow( event ); |
|
282 newDisplayRows->AppendL( iBuffer ); |
|
283 iDisplayRowNumber++; |
|
284 |
|
285 if( split ) |
|
286 { |
|
287 TelRow( event, ESecondRow ); |
|
288 newDisplayRows->AppendL( iBuffer ); |
|
289 iDisplayRowNumber++; |
|
290 } |
|
291 } |
|
292 |
|
293 //Uri. Show if available |
|
294 if( iView->SipUriAvailable( event )) |
|
295 { |
|
296 if( event->Direction() == EDirIn || event->Direction() == EDirMissed ) |
|
297 { |
|
298 event->LogsEventData()->VoIP() ? iBuffer.Copy( iVoIPCallFrom->Des() ) : |
|
299 iBuffer.Copy( iPoCAddr->Des() ); |
|
300 } |
|
301 else |
|
302 { |
|
303 event->LogsEventData()->VoIP() ? iBuffer.Copy( iVoIPCallTo->Des() ) : |
|
304 iBuffer.Copy( iPoCAddr->Des() ); |
|
305 } |
|
306 iBuffer.Append( KTab ); |
|
307 |
|
308 TBool split = SplitNumber( event, *iListboxFont, iTextWidth, ETrue ); |
|
309 iBuffer.Append( *iNumberFirstRow ); |
|
310 newDisplayRows->AppendL( iBuffer ); |
|
311 iDisplayRowNumber++; |
|
312 |
|
313 if( split ) |
|
314 { |
|
315 iBuffer.Copy( KTab ); |
|
316 iBuffer.Append( *iNumberSecondRow ); |
|
317 newDisplayRows->AppendL( iBuffer ); |
|
318 iDisplayRowNumber++; |
|
319 } |
|
320 } |
|
321 |
|
322 //Update display array |
|
323 CleanupStack::Pop( newDisplayRows ); |
|
324 delete iDisplayRows; |
|
325 iDisplayRows = newDisplayRows; |
|
326 } |
|
327 |
|
328 |
|
329 // ---------------------------------------------------------------------------- |
|
330 // CLogsDetailAdapter::MdcaCount |
|
331 // ---------------------------------------------------------------------------- |
|
332 // |
|
333 TInt CLogsDetailAdapter::MdcaCount() const |
|
334 { |
|
335 return iDisplayRowNumber; |
|
336 } |
|
337 |
|
338 // ---------------------------------------------------------------------------- |
|
339 // CLogsDetailAdapter::MdcaPoint |
|
340 // ---------------------------------------------------------------------------- |
|
341 // |
|
342 TPtrC16 CLogsDetailAdapter::MdcaPoint( TInt aIndex ) const |
|
343 { |
|
344 return iDisplayRows->MdcaPoint( aIndex ); |
|
345 } |
|
346 |
|
347 // ---------------------------------------------------------------------------- |
|
348 // CLogsDetailAdapter::StatusRow |
|
349 // ---------------------------------------------------------------------------- |
|
350 // |
|
351 TBool CLogsDetailAdapter::StatusRow( const CLogEvent* aCLogEvent, |
|
352 const MLogsEventGetter* aEvent ) const |
|
353 { |
|
354 TBool rc( EFalse ); |
|
355 |
|
356 //Skip events that are not MO originated |
|
357 if( aEvent->Direction() != EDirOut && |
|
358 aEvent->Direction() != EDirOutAlt ) |
|
359 { |
|
360 return rc; |
|
361 } |
|
362 |
|
363 TDes& des = MUTABLE_CAST( TBuf<KLogsDetailsListAdaptorArrayLen>&, |
|
364 iBuffer ); |
|
365 |
|
366 des.Copy( iStatus->Des() ); |
|
367 des.Append( KTab ); |
|
368 |
|
369 switch( aCLogEvent->EventType().iUid ) |
|
370 { |
|
371 case KLogShortMessageEventType: |
|
372 case KLogsEngMmsEventType: |
|
373 { |
|
374 if( aCLogEvent->Status() == iEventStatusFailedTxt || |
|
375 aCLogEvent->Status() == iEventStatusNotSentTxt ) |
|
376 { |
|
377 des.Append( iEventStatusFailed->Des() ); |
|
378 } |
|
379 else if( aCLogEvent->Status() == iEventStatusSentTxt ) |
|
380 { |
|
381 des.Append( iEventStatusSent->Des() ); |
|
382 } |
|
383 else if( aCLogEvent->Status() == iEventStatusDeliveredTxt ) |
|
384 { |
|
385 des.Append( iEventStatusDelivered->Des() ); |
|
386 } |
|
387 else |
|
388 { |
|
389 // Show "Pending" for other statuses: iEventStatusPendingTxt, |
|
390 // iEventStatusNoDeliveryTxt, ... |
|
391 des.Append( iEventStatusPending->Des() ); |
|
392 } |
|
393 rc = ETrue; |
|
394 |
|
395 break; |
|
396 } |
|
397 default: |
|
398 break; |
|
399 } // switch |
|
400 |
|
401 return rc; |
|
402 } |
|
403 |
|
404 // ---------------------------------------------------------------------------- |
|
405 // CLogsDetailAdapter::DurationRow |
|
406 // ---------------------------------------------------------------------------- |
|
407 // |
|
408 TBool CLogsDetailAdapter::DurationRow( const CLogEvent* aEvent ) const |
|
409 { |
|
410 TDes& des = MUTABLE_CAST( TBuf<KLogsDetailsListAdaptorArrayLen>&, |
|
411 iBuffer ); |
|
412 des.Copy( iDuration->Des() ); |
|
413 des.Append( KTab ); |
|
414 |
|
415 TInt32 duration( aEvent->Duration() ); |
|
416 TInt64 seconds = MAKE_TINT64( 0, duration ); //TInt64 seconds( 0, duration ); |
|
417 TTime time = seconds * 1000000; |
|
418 |
|
419 TDateTime dateTime = time.DateTime(); |
|
420 |
|
421 if ( dateTime.Day() > 99 ) |
|
422 { |
|
423 return EFalse; |
|
424 } |
|
425 |
|
426 if ( dateTime.Day() > 0 ) |
|
427 { |
|
428 TBuf<KLogsDetailsListAdaptorArrayLen> buf; |
|
429 buf.AppendNum( dateTime.Day() ); |
|
430 AknTextUtils::LanguageSpecificNumberConversion( buf ); |
|
431 des.Append( buf ); |
|
432 des.Append(KSpace); |
|
433 } |
|
434 |
|
435 TRAPD( err, TimeFormattingL( time ) ); |
|
436 |
|
437 if( err ) |
|
438 { |
|
439 des.Append( KSpace ); |
|
440 } |
|
441 |
|
442 return ETrue; |
|
443 } |
|
444 |
|
445 // ---------------------------------------------------------------------------- |
|
446 // CLogsDetailAdapter::TimeFormattingL |
|
447 // ---------------------------------------------------------------------------- |
|
448 // |
|
449 void CLogsDetailAdapter::TimeFormattingL( TTime& aTime ) const |
|
450 { |
|
451 TDes& des = MUTABLE_CAST( TBuf<KLogsDetailsListAdaptorArrayLen>&, |
|
452 iBuffer ); |
|
453 TBuf<KLogsPhoneNumberMaxLen> buffer; |
|
454 aTime.FormatL( buffer, *iDurationFormat ); |
|
455 AknTextUtils::LanguageSpecificNumberConversion( buffer ); |
|
456 des.Append( buffer ); |
|
457 } |
|
458 |
|
459 // ---------------------------------------------------------------------------- |
|
460 // CLogsDetailAdapter::AmountRow |
|
461 // |
|
462 // Size row for SMS and MMS events |
|
463 // ---------------------------------------------------------------------------- |
|
464 // |
|
465 TBool CLogsDetailAdapter::AmountRow( const MLogsEventGetter* aEvent ) const |
|
466 { |
|
467 TBool rc( EFalse ); |
|
468 TDes& des = MUTABLE_CAST( TBuf<KLogsDetailsListAdaptorArrayLen>&, |
|
469 iBuffer ); |
|
470 des.Copy( iAmount->Des() ); |
|
471 des.Append( KTab ); |
|
472 |
|
473 TBuf<KLogsPhoneNumberMaxLen> buf; |
|
474 buf.Zero(); |
|
475 |
|
476 switch( aEvent->EventUid().iUid ) |
|
477 { |
|
478 case KLogShortMessageEventType: |
|
479 case KLogsEngMmsEventType: |
|
480 { |
|
481 buf.AppendNum( aEvent->LogsEventData()->MsgPartsNumber() ); |
|
482 AknTextUtils::LanguageSpecificNumberConversion(buf); |
|
483 des.Append( buf ); |
|
484 rc = ETrue; |
|
485 break; |
|
486 } |
|
487 default: |
|
488 break; |
|
489 } // switch |
|
490 |
|
491 return rc; |
|
492 } |
|
493 |
|
494 // ---------------------------------------------------------------------------- |
|
495 // CLogsDetailAdapter::TelRow |
|
496 // |
|
497 // Tel no for certain types of rows |
|
498 // ---------------------------------------------------------------------------- |
|
499 // |
|
500 TBool CLogsDetailAdapter::TelRow( const MLogsEventGetter* aEvent, |
|
501 TRowNumber aRowNumber ) const |
|
502 { |
|
503 TDes& des = MUTABLE_CAST( TBuf<KLogsDetailsListAdaptorArrayLen>&, |
|
504 iBuffer ); |
|
505 |
|
506 if( aRowNumber == EFirstRow ) |
|
507 { |
|
508 des.Copy( iNbr->Des() ); |
|
509 des.Append( KTab ); |
|
510 switch( aEvent->EventType() ) |
|
511 { |
|
512 //For unknown numbers we show "Tel no Unknown" row. |
|
513 case ETypeUnknown: |
|
514 des.Append( *iUnknownNumber ); |
|
515 break; |
|
516 |
|
517 //For Private and Payphone numbers we don't show the "Tel no" row at all.. |
|
518 |
|
519 case ETypeUsual: |
|
520 des.Append( *iNumberFirstRow ); |
|
521 break; |
|
522 |
|
523 default: |
|
524 break; |
|
525 } |
|
526 } |
|
527 else |
|
528 { |
|
529 des.Copy( KTab ); |
|
530 des.Append( *iNumberSecondRow ); |
|
531 } |
|
532 |
|
533 return ETrue; |
|
534 } |
|
535 |
|
536 // ---------------------------------------------------------------------------- |
|
537 // CLogsDetailAdapter::SplitNumber |
|
538 // |
|
539 // If number is too long to fit to one row, we split it to two rows |
|
540 // Sets iNumberSplitted to ETrue (+Returns true) if number was splitted |
|
541 // ---------------------------------------------------------------------------- |
|
542 // |
|
543 TBool CLogsDetailAdapter::SplitNumber( |
|
544 const MLogsEventGetter* aEvent, |
|
545 const CFont& aFont, |
|
546 TInt aMaxWidthInPixels, |
|
547 TBool aPreferUri ) const |
|
548 { |
|
549 MUTABLE_CAST( CLogsDetailAdapter*, this )->iNumberSplitted = EFalse; |
|
550 TPtr firstRow( iNumberFirstRow->Des() ); |
|
551 TPtr secondRow( iNumberSecondRow->Des() ); |
|
552 firstRow.Zero(); |
|
553 secondRow.Zero(); |
|
554 |
|
555 TBuf<KLogsSipUriMaxLen> clippedText; |
|
556 |
|
557 if( iView->PhoneNumberAvailable( aEvent ) && !aPreferUri ) |
|
558 { |
|
559 TBuf<KLogsPhoneNumberMaxLen> tmp; |
|
560 iPhoneNbrFormatter->DTMFStrip( *(aEvent->Number()), tmp ); |
|
561 iPhoneNbrFormatter->PhoneNumberFormat( tmp, clippedText ); |
|
562 } |
|
563 else if( iView->SipUriAvailable( aEvent ) && aPreferUri ) //If no number, show instead url if available |
|
564 { |
|
565 iEngine->ConvertToUnicode( aEvent->LogsEventData()->Url(), clippedText ); |
|
566 } |
|
567 else |
|
568 { |
|
569 clippedText.Zero(); |
|
570 } |
|
571 |
|
572 TInt textPixels( aFont.TextWidthInPixels( clippedText ) ); |
|
573 |
|
574 if ( textPixels <= aMaxWidthInPixels ) //Fits to one row |
|
575 { |
|
576 firstRow.Copy( clippedText ); |
|
577 return EFalse; |
|
578 } |
|
579 |
|
580 //Two rows needed |
|
581 MUTABLE_CAST( CLogsDetailAdapter*, this )->iNumberSplitted = ETrue; |
|
582 TInt excessPixels; |
|
583 TInt cutOff( aFont.TextCount( clippedText, aMaxWidthInPixels, excessPixels ) ); |
|
584 |
|
585 //Does the remaining fit fully to two rows |
|
586 if ( textPixels + excessPixels <= aMaxWidthInPixels * 2 || //Phone number fits to two rows |
|
587 aPreferUri ) //or we use sip-uri (can be right-clipped on 2nd row) |
|
588 { |
|
589 secondRow.Copy( clippedText.Mid( cutOff ) ); // second row |
|
590 firstRow.Copy( clippedText.Left( cutOff ) ); // first row |
|
591 return ETrue; |
|
592 } |
|
593 |
|
594 //Phone number did not fit to two rows, so we need cut the first row from the beginning |
|
595 //We have to first reverse the string because we are interested in length of characters *after* |
|
596 //cutoff point (non-monospaced font, so chars are not necessarily equally wide on both sides of cutoff) |
|
597 Reverse( clippedText ); |
|
598 secondRow.Copy( clippedText.Left( cutOff ) ); // second row |
|
599 Reverse( secondRow ); //convert back to normal order |
|
600 TPtrC remainingChars(clippedText.Mid(cutOff) );//first row |
|
601 |
|
602 _LIT(KDots, "..."); |
|
603 TInt acceptedWidth = aMaxWidthInPixels - aFont.TextWidthInPixels( KDots ); |
|
604 |
|
605 //Create the first row in reversed order and then convert it back to normal order |
|
606 TInt cutOff2( aFont.TextCount( remainingChars, acceptedWidth )); |
|
607 firstRow.Append( remainingChars.Left( cutOff2 ) ); |
|
608 if( firstRow.Length() + 4 < firstRow.MaxLength() ) //Magic number 4=length of KDots + length of Directionality Marker |
|
609 { |
|
610 firstRow.Append( 0x202A ); //A&H: In mirrored layout we need this Directionality Marker to render the three dots |
|
611 // correctly on left side of the number string. Similar issue as in SAKA-6689Q4. |
|
612 firstRow.Append( KDots ); |
|
613 } |
|
614 Reverse( firstRow );//convert back to normal order |
|
615 |
|
616 return ETrue; |
|
617 } |
|
618 |
|
619 |
|
620 // ---------------------------------------------------------------------------- |
|
621 // CLogsDetailAdapter::DirectionRow |
|
622 // ---------------------------------------------------------------------------- |
|
623 // |
|
624 TBool CLogsDetailAdapter::DirectionRow( const MLogsEventGetter* aEvent ) const |
|
625 { |
|
626 TDes& des = MUTABLE_CAST( TBuf<KLogsDetailsListAdaptorArrayLen>&, |
|
627 iBuffer ); |
|
628 |
|
629 des.Copy( iDirection->Des() ); |
|
630 des.Append( KTab ); |
|
631 |
|
632 switch( aEvent->Direction() ) |
|
633 { |
|
634 case EDirIn: |
|
635 des.Append( iDirectionIn->Des() ); |
|
636 break; |
|
637 case EDirOut: |
|
638 des.Append( iDirectionOut->Des() ); |
|
639 break; |
|
640 case EDirMissed: |
|
641 des.Append( iDirectionMissed->Des() ); |
|
642 break; |
|
643 default: |
|
644 break; |
|
645 } |
|
646 |
|
647 return ETrue; |
|
648 } |
|
649 |
|
650 // ---------------------------------------------------------------------------- |
|
651 // CLogsDetailAdapter::TypeRow |
|
652 // ---------------------------------------------------------------------------- |
|
653 // |
|
654 TBool CLogsDetailAdapter::TypeRow( const MLogsEventGetter* aEvent ) const |
|
655 { |
|
656 TDes& des = MUTABLE_CAST( TBuf<KLogsDetailsListAdaptorArrayLen>&, |
|
657 iBuffer ); |
|
658 |
|
659 des.Copy( iType->Des() ); |
|
660 des.Append( KTab ); |
|
661 |
|
662 switch( aEvent->EventUid().iUid ) |
|
663 { |
|
664 case KLogCallEventType: |
|
665 //Currently Voice, VT, PoC and VoIP are shown as mutually exclusive. This may change in the future, e.g. |
|
666 //VoIP and VT types may be both in the same event |
|
667 if( aEvent->LogsEventData()->VT() ) |
|
668 { |
|
669 des.Append( iEventTypeVideo->Des() ); |
|
670 } |
|
671 else if( aEvent->LogsEventData()->PoC() ) |
|
672 { |
|
673 des.Append( iEventTypePoC->Des() ); |
|
674 } |
|
675 else if( aEvent->LogsEventData()->VoIP() ) |
|
676 { |
|
677 des.Append( iEventTypeVoIP->Des() ); |
|
678 } |
|
679 else |
|
680 { |
|
681 des.Append( iEventTypeVoice->Des() ); |
|
682 } |
|
683 |
|
684 break; |
|
685 |
|
686 case KLogsEngPocInfoEventType: |
|
687 des.Append( iEventTypePoCInfo->Des() ); |
|
688 break; |
|
689 |
|
690 case KLogDataEventType: |
|
691 des.Append( iEventTypeData->Des() ); |
|
692 break; |
|
693 |
|
694 case KLogFaxEventType: |
|
695 des.Append( iEventTypeFax->Des() ); |
|
696 break; |
|
697 |
|
698 case KLogShortMessageEventType: |
|
699 des.Append( iEventTypeSMS->Des() ); |
|
700 break; |
|
701 |
|
702 case KLogsEngMmsEventType: |
|
703 des.Append( iEventTypeMMS->Des() ); |
|
704 break; |
|
705 |
|
706 case KLogPacketDataEventType: |
|
707 des.Append( iEventTypeGPRS->Des() ); |
|
708 break; |
|
709 |
|
710 case KLogsEngWlanEventType: |
|
711 des.Append( iEventTypeWLAN->Des() ); |
|
712 break; |
|
713 |
|
714 default: |
|
715 break; |
|
716 } |
|
717 |
|
718 return ETrue; |
|
719 } |
|
720 |
|
721 // ---------------------------------------------------------------------------- |
|
722 // CLogsDetailAdapter::SentAmountRow |
|
723 // ---------------------------------------------------------------------------- |
|
724 // |
|
725 TBool CLogsDetailAdapter::SentAmountRow( const MLogsEventGetter* aEvent ) const |
|
726 { |
|
727 TDes& des = MUTABLE_CAST( TBuf<KLogsDetailsListAdaptorArrayLen>&, iBuffer ); |
|
728 |
|
729 des.Copy( iSentAmount->Des() ); |
|
730 des.Append( KTab ); |
|
731 |
|
732 TBuf<KLogsPhoneNumberMaxLen> buf; |
|
733 buf.Zero(); |
|
734 |
|
735 buf.Format( *iAmountKB, I64INT(aEvent->LogsEventData()->DataSent() / 1024) ); //iAmountKB: R_LOGS_DETAIL_VIEW_KB_TEXT |
|
736 AknTextUtils::LanguageSpecificNumberConversion( buf ); |
|
737 des.Append( buf ); |
|
738 return ETrue; |
|
739 } |
|
740 |
|
741 // ---------------------------------------------------------------------------- |
|
742 // CLogsDetailAdapter::ReceivedAmountRow |
|
743 // ---------------------------------------------------------------------------- |
|
744 // |
|
745 TBool CLogsDetailAdapter::ReceivedAmountRow( const MLogsEventGetter* aEvent ) const |
|
746 { |
|
747 TDes& des = MUTABLE_CAST( TBuf<KLogsDetailsListAdaptorArrayLen>&, iBuffer ); |
|
748 |
|
749 des.Copy( iReceivedAmount->Des() ); |
|
750 des.Append( KTab ); |
|
751 |
|
752 TBuf<KLogsPhoneNumberMaxLen> buf; |
|
753 buf.Zero(); |
|
754 |
|
755 buf.Format( *iAmountKB, aEvent->LogsEventData()->DataReceived() / 1024 ); //iAmountKB: R_LOGS_DETAIL_VIEW_KB_TEXT |
|
756 AknTextUtils::LanguageSpecificNumberConversion( buf ); |
|
757 des.Append( buf ); |
|
758 return ETrue; |
|
759 } |
|
760 |
|
761 // ---------------------------------------------------------------------------- |
|
762 // CLogsDetailAdapter::SetLineWidth |
|
763 // |
|
764 // Sets the maximum width in pixels for the detail line. This needs to be called from controller's |
|
765 // SizeChanged() method. |
|
766 // ---------------------------------------------------------------------------- |
|
767 // |
|
768 void CLogsDetailAdapter::SetLineWidth(TInt aTextWidth) |
|
769 { |
|
770 iTextWidth = aTextWidth; |
|
771 iListboxFont = LineFont(); //Update font too as probably it has also changed. |
|
772 } |
|
773 |
|
774 // ---------------------------------------------------------------------------- |
|
775 // CLogsDetailAdapter::LineFont |
|
776 // ---------------------------------------------------------------------------- |
|
777 // |
|
778 const CFont* CLogsDetailAdapter::LineFont() |
|
779 { |
|
780 TAknTextLineLayout line = AknLayout::List_pane_texts__single_heading__Line_2(0 ); //Same in CLogsDetailControlContainer::SizeChanged |
|
781 TAknLayoutText text; |
|
782 text.LayoutText( iListBox->Rect(), line ); |
|
783 return text.Font(); // text.Font() not owned |
|
784 } |
|
785 |
|
786 // ---------------------------------------------------------------------------- |
|
787 // CLogsDetailAdapter::Reverse |
|
788 // ---------------------------------------------------------------------------- |
|
789 // |
|
790 void CLogsDetailAdapter::Reverse(TDes& aText ) const |
|
791 { |
|
792 for(int i=0,j=aText.Length() - 1; i < j ; i++, j--) |
|
793 { |
|
794 TUint16 tmp = aText[i]; |
|
795 aText[i] = aText[j]; |
|
796 aText[j] = tmp; |
|
797 } |
|
798 } |
|
799 |
|
800 // End of File |