|
1 /* |
|
2 * Copyright (c) 2005-2006 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: MmsMtmDeliveryPopup implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <aknmessagequerydialog.h> |
|
23 #include <MmsUi.rsg> |
|
24 #include <eikenv.h> |
|
25 |
|
26 #include <commonphoneparser.h> |
|
27 #include "CMsgDeliveryItem.h" |
|
28 #include "MmsMtmDeliveryPopup.h" |
|
29 #include "MmsMtmUi.h" // ConvertUtcToLocalTime() |
|
30 |
|
31 |
|
32 // CONSTANTS |
|
33 _LIT( KLineWrap, "\n" ); |
|
34 _LIT( KOpen, "<"); |
|
35 _LIT( KClose, ">"); |
|
36 _LIT( KComma, ","); |
|
37 _LIT (KSpace, " "); |
|
38 |
|
39 // MACROS |
|
40 |
|
41 // LOCAL CONSTANTS AND MACROS |
|
42 |
|
43 // MODULE DATA STRUCTURES |
|
44 |
|
45 // LOCAL FUNCTION PROTOTYPES |
|
46 |
|
47 // ==================== LOCAL FUNCTIONS ==================== |
|
48 |
|
49 |
|
50 // ================= MEMBER FUNCTIONS ======================= |
|
51 |
|
52 |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CMsgInfoDeliveryStatusPopup::CMsgInfoDeliveryStatusPopup |
|
56 // C++ default constructor can NOT contain any code, that |
|
57 // might leave. |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CMsgInfoDeliveryStatusPopup::CMsgInfoDeliveryStatusPopup() |
|
61 { |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CMsgInfoDeliveryStatusPopup::ConstructL |
|
66 // Symbian 2nd phase constructor can leave. |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 void CMsgInfoDeliveryStatusPopup::ConstructL() |
|
70 { |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CMsgInfoDeliveryStatusPopup::~CMsgInfoDeliveryStatusPopup |
|
75 // Destructor |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 CMsgInfoDeliveryStatusPopup::~CMsgInfoDeliveryStatusPopup() |
|
79 { |
|
80 if (iDataArray) |
|
81 { |
|
82 iDataArray->ResetAndDestroy(); |
|
83 delete iDataArray; |
|
84 } |
|
85 |
|
86 delete iFailedText; |
|
87 delete iPendingText; |
|
88 delete iDeliveredText; |
|
89 delete iReadText; |
|
90 delete iUnavailableText; |
|
91 delete iText; |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CMsgInfoDeliveryStatusPopup::NewL |
|
96 // Two-phased constructor. |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 CMsgInfoDeliveryStatusPopup* CMsgInfoDeliveryStatusPopup::NewL(/* CFileManagerItemProperties& aProperties */) |
|
100 { |
|
101 CMsgInfoDeliveryStatusPopup* self = new( ELeave ) CMsgInfoDeliveryStatusPopup( /*aProperties */); |
|
102 |
|
103 CleanupStack::PushL( self ); |
|
104 self->ConstructL(); |
|
105 CleanupStack::Pop(); |
|
106 |
|
107 return self; |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CMsgInfoDeliveryStatusPopup::ExecuteL |
|
112 // Gathers the data and lauches the dialog |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 TInt CMsgInfoDeliveryStatusPopup::ExecuteL() |
|
116 { |
|
117 HBufC* headerText = CEikonEnv::Static()->AllocReadResourceLC(R_MMS_DELIVERY_STATUS_HEADER); |
|
118 ParseTextL(); |
|
119 |
|
120 CAknMessageQueryDialog* dialog = CAknMessageQueryDialog::NewL(*iText); |
|
121 dialog->SetHeaderTextL(*headerText); |
|
122 |
|
123 TInt answer = dialog->ExecuteLD(R_PROPERTIES_MESSAGE_QUERY); |
|
124 CleanupStack::PopAndDestroy(); |
|
125 |
|
126 return answer; |
|
127 } |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 //CMsgInfoDeliveryStatusPopup::SetDataArray |
|
131 // Sets data array containing CMsgDeliveryItem's |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void CMsgInfoDeliveryStatusPopup::SetDataArray(CArrayPtrFlat< CMsgDeliveryItem >* aArray) |
|
135 { |
|
136 iDataArray = aArray; |
|
137 } |
|
138 |
|
139 // ----------------------------------------------------------------------------- |
|
140 //CMsgInfoDeliveryStatusPopup::ParseText |
|
141 // Loops through the msg items in data array and adds their contents to the strings |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void CMsgInfoDeliveryStatusPopup::ParseTextL() |
|
145 { |
|
146 TInt itemCount(iDataArray->Count()); |
|
147 TInt deliveredCount(0); |
|
148 TInt readCount(0); |
|
149 TInt failedCount(0); |
|
150 TInt pendingCount(0); |
|
151 TInt unavailableCount(0); |
|
152 |
|
153 for (TInt i = 0; i < itemCount; i++) |
|
154 { |
|
155 CMsgDeliveryItem* item = iDataArray->At(i); |
|
156 TInt status = item->GetStatus(); |
|
157 |
|
158 // TODO This section can be used to test read status on the emulator |
|
159 // until read reports are supported in the real world |
|
160 /* if ( item |
|
161 && item->GetNumber( ) == _L("04544187897") |
|
162 || item->GetNumber( ) == _L("+3584544187897" ) ) |
|
163 { |
|
164 status = CMsgDeliveryItem::ERead ; |
|
165 } |
|
166 if ( item |
|
167 && item->GetNumber( ) == _L("04544187898") |
|
168 || item->GetNumber( ) == _L("+3584544187898" ) ) |
|
169 { |
|
170 status = CMsgDeliveryItem::ERead ; |
|
171 } |
|
172 if ( item |
|
173 && item->GetNumber( ) == _L("0408200523") |
|
174 || item->GetNumber( ) == _L("+358408200523" ) ) |
|
175 { |
|
176 status = CMsgDeliveryItem::EDelivered ; |
|
177 } |
|
178 if ( item |
|
179 && item->GetNumber( ) == _L("0408200524") |
|
180 || item->GetNumber( ) == _L("+358408200524" ) ) |
|
181 { |
|
182 status = CMsgDeliveryItem::EDelivered ; |
|
183 } |
|
184 */ |
|
185 switch (status) |
|
186 { |
|
187 case CMsgDeliveryItem::EPending: |
|
188 iPendingSize += ParseStringL(item, NULL); |
|
189 pendingCount++; |
|
190 break; |
|
191 case CMsgDeliveryItem::EFailed: |
|
192 iFailedSize += ParseStringL(item, NULL); |
|
193 failedCount++; |
|
194 break; |
|
195 case CMsgDeliveryItem::EDelivered: |
|
196 iDeliveredSize += ParseStringL(item, NULL); |
|
197 deliveredCount++; |
|
198 break; |
|
199 case CMsgDeliveryItem::ERead: |
|
200 iReadSize += ParseStringL(item, NULL); |
|
201 readCount++; |
|
202 break; |
|
203 default: // for ENone (unavailable) |
|
204 iUnavailableSize += ParseStringL(item, NULL); |
|
205 unavailableCount++; |
|
206 break; |
|
207 } |
|
208 } |
|
209 |
|
210 CalculateLabelSizesL(failedCount, pendingCount, deliveredCount, readCount, unavailableCount); |
|
211 iMessageSize += iPendingSize; |
|
212 iMessageSize += iFailedSize; |
|
213 iMessageSize += iDeliveredSize; |
|
214 iMessageSize += iReadSize; |
|
215 iMessageSize += iUnavailableSize; |
|
216 |
|
217 TDesC linewrapDes(KLineWrap); |
|
218 iMessageSize += 2* linewrapDes.Length(); // because there's two linewraps at the bottom |
|
219 |
|
220 iFailedText = HBufC::NewL(iFailedSize); |
|
221 iPendingText = HBufC::NewL(iPendingSize); |
|
222 iDeliveredText = HBufC::NewL(iDeliveredSize); |
|
223 iReadText = HBufC::NewL(iReadSize); |
|
224 iUnavailableText = HBufC::NewL(iUnavailableSize); |
|
225 |
|
226 iText = HBufC::NewL(iMessageSize); |
|
227 pendingCount = 0; |
|
228 failedCount = 0; |
|
229 deliveredCount = 0; |
|
230 readCount = 0; |
|
231 unavailableCount = 0; |
|
232 |
|
233 for (TInt i = 0; i < itemCount; i++) |
|
234 { |
|
235 CMsgDeliveryItem* item = iDataArray->At(i); |
|
236 TInt status = item->GetStatus(); |
|
237 |
|
238 // TODO This section can be used to test read status on the emulator |
|
239 // until read reports are supported in the real world |
|
240 /* if ( item |
|
241 && item->GetNumber( ) == _L("04544187897") |
|
242 || item->GetNumber( ) == _L("+3584544187897" ) ) |
|
243 { |
|
244 status = CMsgDeliveryItem::ERead ; |
|
245 } |
|
246 if ( item |
|
247 && item->GetNumber( ) == _L("04544187898") |
|
248 || item->GetNumber( ) == _L("+3584544187898" ) ) |
|
249 { |
|
250 status = CMsgDeliveryItem::ERead ; |
|
251 } |
|
252 if ( item |
|
253 && item->GetNumber( ) == _L("0408200523") |
|
254 || item->GetNumber( ) == _L("+358408200523" ) ) |
|
255 { |
|
256 status = CMsgDeliveryItem::EDelivered ; |
|
257 } |
|
258 if ( item |
|
259 && item->GetNumber( ) == _L("0408200524") |
|
260 || item->GetNumber( ) == _L("+358408200524" ) ) |
|
261 { |
|
262 status = CMsgDeliveryItem::EDelivered ; |
|
263 } |
|
264 */ |
|
265 |
|
266 switch (status) |
|
267 { |
|
268 case CMsgDeliveryItem::EPending: |
|
269 { |
|
270 TPtr str = iPendingText->Des(); |
|
271 ParseStringL(item, &str); |
|
272 pendingCount++; |
|
273 break; |
|
274 } |
|
275 case CMsgDeliveryItem::EFailed: |
|
276 { |
|
277 TPtr str = iFailedText->Des(); |
|
278 ParseStringL(item, &str ); |
|
279 failedCount++; |
|
280 break; |
|
281 } |
|
282 case CMsgDeliveryItem::EDelivered: |
|
283 { |
|
284 TPtr str = iDeliveredText->Des(); |
|
285 ParseStringL(item, &str ); |
|
286 deliveredCount++; |
|
287 break; |
|
288 } |
|
289 case CMsgDeliveryItem::ERead: |
|
290 { |
|
291 TPtr str = iReadText->Des(); |
|
292 ParseStringL(item, &str ); |
|
293 readCount++; |
|
294 break; |
|
295 } |
|
296 default: // for ENone (unavailable) |
|
297 { |
|
298 TPtr str = iUnavailableText->Des(); |
|
299 ParseStringL(item, &str ); |
|
300 unavailableCount++; |
|
301 break; |
|
302 } |
|
303 } |
|
304 } |
|
305 |
|
306 // add the |
|
307 AddLabelsL(failedCount, pendingCount, deliveredCount, readCount, unavailableCount); |
|
308 |
|
309 // add the parsed strings to their places and |
|
310 // insert line breaks in between if necessary |
|
311 if ( failedCount > 0 ) |
|
312 { |
|
313 iText->Des().Append(*iFailedText); |
|
314 } |
|
315 TInt countsSoFar = failedCount; |
|
316 if ( pendingCount > 0 ) |
|
317 { |
|
318 if ( countsSoFar > 0 ) // if theres text before this, add a line break |
|
319 { |
|
320 iText->Des().Append(KLineWrap); |
|
321 iText->Des().Append(KLineWrap); |
|
322 } |
|
323 iText->Des().Append(*iPendingText); |
|
324 } |
|
325 countsSoFar += pendingCount; |
|
326 if ( deliveredCount > 0 ) |
|
327 { |
|
328 if ( countsSoFar > 0 ) // if theres text before this, add a line break |
|
329 { |
|
330 iText->Des().Append(KLineWrap); |
|
331 iText->Des().Append(KLineWrap); |
|
332 } |
|
333 iText->Des().Append(*iDeliveredText); |
|
334 } |
|
335 countsSoFar += deliveredCount; |
|
336 if ( readCount > 0 ) |
|
337 { |
|
338 if ( countsSoFar > 0 ) // if theres text before this, add a line break |
|
339 { |
|
340 iText->Des().Append(KLineWrap); |
|
341 iText->Des().Append(KLineWrap); |
|
342 } |
|
343 iText->Des().Append(*iReadText); |
|
344 } |
|
345 countsSoFar += readCount; |
|
346 if ( unavailableCount > 0 ) |
|
347 { |
|
348 if ( countsSoFar > 0 ) // if theres text before this, add a line break |
|
349 { |
|
350 iText->Des().Append(KLineWrap); |
|
351 iText->Des().Append(KLineWrap); |
|
352 } |
|
353 iText->Des().Append(*iUnavailableText); |
|
354 } |
|
355 } |
|
356 // ----------------------------------------------------------------------------- |
|
357 // CMsgInfoDeliveryStatusPopup::AddLabels |
|
358 // Adds the labels ("failed", "pending", "delivered", "read", "unavailable") |
|
359 // in front of the each string. |
|
360 // ----------------------------------------------------------------------------- |
|
361 // |
|
362 void CMsgInfoDeliveryStatusPopup::AddLabelsL( TInt aFailed, |
|
363 TInt aPending, |
|
364 TInt aDelivered, |
|
365 TInt aRead, |
|
366 TInt aUnavailable ) |
|
367 { |
|
368 TInt resourceId( 0 ); |
|
369 if (aFailed > 0) |
|
370 { |
|
371 if ( aFailed > 1 ) |
|
372 { |
|
373 resourceId = R_MMS_DELIVERY_STATUS_FAILED_PLURAL; |
|
374 } |
|
375 else |
|
376 { |
|
377 resourceId = R_MMS_DELIVERY_STATUS_FAILED; |
|
378 } |
|
379 HBufC* failedText = CEikonEnv::Static()->AllocReadResourceLC( resourceId ); |
|
380 iFailedText->Des().Insert( 0, *failedText ); |
|
381 CleanupStack::PopAndDestroy(); |
|
382 } |
|
383 |
|
384 if (aPending > 0) |
|
385 { |
|
386 if ( aPending > 1 ) |
|
387 { |
|
388 resourceId = R_MMS_DELIVERY_STATUS_PENDING_PLURAL; |
|
389 } |
|
390 else |
|
391 { |
|
392 resourceId = R_MMS_DELIVERY_STATUS_PENDING; |
|
393 } |
|
394 HBufC* pendingText = CEikonEnv::Static()->AllocReadResourceLC( resourceId ); |
|
395 iPendingText->Des().Insert( 0, *pendingText ); |
|
396 CleanupStack::PopAndDestroy(); |
|
397 } |
|
398 |
|
399 if (aDelivered > 0) |
|
400 { |
|
401 if ( aDelivered > 1 ) |
|
402 { |
|
403 resourceId = R_MMS_DELIVERY_STATUS_DELIVERED_PLURAL; |
|
404 } |
|
405 else |
|
406 { |
|
407 resourceId = R_MMS_DELIVERY_STATUS_DELIVERED; |
|
408 } |
|
409 HBufC* deliveredText = CEikonEnv::Static()->AllocReadResourceLC( resourceId ); |
|
410 iDeliveredText->Des().Insert( 0, *deliveredText ); |
|
411 CleanupStack::PopAndDestroy(); |
|
412 } |
|
413 |
|
414 if (aRead > 0) |
|
415 { |
|
416 if ( aRead > 1 ) |
|
417 { |
|
418 resourceId = R_MMS_DELIVERY_STATUS_READ_PLURAL; |
|
419 } |
|
420 else |
|
421 { |
|
422 resourceId = R_MMS_DELIVERY_STATUS_READ; |
|
423 } |
|
424 HBufC* readText = CEikonEnv::Static()->AllocReadResourceLC( resourceId ); |
|
425 iReadText->Des().Insert( 0, *readText ); |
|
426 CleanupStack::PopAndDestroy(); |
|
427 } |
|
428 |
|
429 if (aUnavailable > 0) |
|
430 { |
|
431 if ( aUnavailable > 1 ) |
|
432 { |
|
433 resourceId = R_MMS_DELIVERY_STATUS_UNAVAILABLE_PLURAL; |
|
434 } |
|
435 else |
|
436 { |
|
437 resourceId = R_MMS_DELIVERY_STATUS_UNAVAILABLE; |
|
438 } |
|
439 HBufC* unavailableText = CEikonEnv::Static()->AllocReadResourceLC( resourceId ); |
|
440 iUnavailableText->Des().Insert( 0, *unavailableText ); |
|
441 CleanupStack::PopAndDestroy(); |
|
442 } |
|
443 } |
|
444 |
|
445 // ----------------------------------------------------------------------------- |
|
446 // CMsgInfoDeliveryStatusPopup::CalculateLabelSizesL |
|
447 // Calculate the labels' lengths and add them to string sizes for allocation |
|
448 // ----------------------------------------------------------------------------- |
|
449 // |
|
450 void CMsgInfoDeliveryStatusPopup::CalculateLabelSizesL( TInt aFailed, |
|
451 TInt aPending, |
|
452 TInt aDelivered, |
|
453 TInt aRead, |
|
454 TInt aUnavailable ) |
|
455 { |
|
456 TInt resourceId( 0 ); |
|
457 if ( aFailed > 0 ) |
|
458 { |
|
459 if ( aFailed > 1 ) |
|
460 { |
|
461 resourceId = R_MMS_DELIVERY_STATUS_FAILED_PLURAL; |
|
462 } |
|
463 else |
|
464 { |
|
465 resourceId = R_MMS_DELIVERY_STATUS_FAILED; |
|
466 } |
|
467 HBufC* failedText = CEikonEnv::Static()->AllocReadResourceLC( resourceId ); |
|
468 iFailedSize += failedText->Length(); |
|
469 CleanupStack::PopAndDestroy(); |
|
470 } |
|
471 |
|
472 if ( aPending > 0 ) |
|
473 { |
|
474 if ( aPending > 1 ) |
|
475 { |
|
476 resourceId = R_MMS_DELIVERY_STATUS_PENDING_PLURAL; |
|
477 } |
|
478 else |
|
479 { |
|
480 resourceId = R_MMS_DELIVERY_STATUS_PENDING; |
|
481 } |
|
482 HBufC* pendingText = CEikonEnv::Static()->AllocReadResourceLC( resourceId ); |
|
483 iPendingSize += pendingText->Length(); |
|
484 CleanupStack::PopAndDestroy(); |
|
485 } |
|
486 |
|
487 if ( aDelivered > 0 ) |
|
488 { |
|
489 if ( aDelivered > 1 ) |
|
490 { |
|
491 resourceId = R_MMS_DELIVERY_STATUS_DELIVERED_PLURAL; |
|
492 } |
|
493 else |
|
494 { |
|
495 resourceId = R_MMS_DELIVERY_STATUS_DELIVERED; |
|
496 } |
|
497 HBufC* deliveredText = CEikonEnv::Static()->AllocReadResourceLC( resourceId ); |
|
498 iDeliveredSize += deliveredText->Length(); |
|
499 CleanupStack::PopAndDestroy(); |
|
500 } |
|
501 |
|
502 if ( aRead > 0 ) |
|
503 { |
|
504 if ( aRead > 1 ) |
|
505 { |
|
506 resourceId = R_MMS_DELIVERY_STATUS_READ_PLURAL; |
|
507 } |
|
508 else |
|
509 { |
|
510 resourceId = R_MMS_DELIVERY_STATUS_READ; |
|
511 } |
|
512 HBufC* readText = CEikonEnv::Static()->AllocReadResourceLC( resourceId ); |
|
513 iReadSize += readText->Length(); |
|
514 CleanupStack::PopAndDestroy(); |
|
515 } |
|
516 |
|
517 if ( aUnavailable > 0 ) |
|
518 { |
|
519 if ( aUnavailable > 1 ) |
|
520 { |
|
521 resourceId = R_MMS_DELIVERY_STATUS_UNAVAILABLE_PLURAL; |
|
522 } |
|
523 else |
|
524 { |
|
525 resourceId = R_MMS_DELIVERY_STATUS_UNAVAILABLE; |
|
526 } |
|
527 HBufC* unavailableText = CEikonEnv::Static()->AllocReadResourceLC( resourceId ); |
|
528 iUnavailableSize += unavailableText->Length(); |
|
529 CleanupStack::PopAndDestroy(); |
|
530 } |
|
531 } |
|
532 |
|
533 // ----------------------------------------------------------------------------- |
|
534 // CMsgInfoDeliveryStatusPopup::ParseStringL |
|
535 // Parse data from delivery item into the strings and return the length of |
|
536 // the current items string. Give aDest as NULL and it only counts the length. |
|
537 // ----------------------------------------------------------------------------- |
|
538 // |
|
539 TInt CMsgInfoDeliveryStatusPopup::ParseStringL(CMsgDeliveryItem* aItem, TPtr* aDest) |
|
540 { |
|
541 // Check for NULL. If NULL, return zero length |
|
542 if (!aItem) |
|
543 { |
|
544 return 0; |
|
545 } |
|
546 |
|
547 TInt size(0); |
|
548 |
|
549 TDesC commaDes(KComma); |
|
550 TDesC spaceDes(KSpace); |
|
551 TDesC openDes(KOpen); |
|
552 TDesC closeDes(KClose); |
|
553 TDesC linewrapDes(KLineWrap); |
|
554 |
|
555 // 1) linefeed |
|
556 if (aDest) // just calculating the length, aDest is NULL so DONT use it |
|
557 { |
|
558 aDest->Append(KLineWrap); |
|
559 } |
|
560 size += linewrapDes.Length(); |
|
561 |
|
562 // 2) time & date |
|
563 if ( aItem->GetStatus() != CMsgDeliveryItem::ENone ) |
|
564 { |
|
565 TTime date = aItem->GetTime(); // message time |
|
566 CMmsMtmUi::ConvertUtcToLocalTime( date ); |
|
567 TDateTime messageTime = date.DateTime(); |
|
568 |
|
569 if (MessageSentToday(messageTime)) // event happened today, use the time string |
|
570 { |
|
571 HBufC* timeFormat = |
|
572 CEikonEnv::Static()->AllocReadResourceLC(R_QTN_TIME_USUAL_WITH_ZERO);//from avkon resources |
|
573 TBuf<32> timeString; |
|
574 date.FormatL(timeString, *timeFormat); |
|
575 CleanupStack::PopAndDestroy();//timeFormat |
|
576 if (aDest) // just calculating the length, aDest is NULL so DONT use it |
|
577 { |
|
578 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( timeString ); |
|
579 aDest->Append(timeString); |
|
580 } |
|
581 size += timeString.Length(); |
|
582 } |
|
583 |
|
584 else // event was not today, so use the date string |
|
585 { |
|
586 HBufC* dateFormat = |
|
587 CEikonEnv::Static()->AllocReadResourceLC(R_QTN_DATE_USUAL_WITH_ZERO);//from avkonresources |
|
588 TBuf<32> dateString; |
|
589 date.FormatL(dateString, *dateFormat); |
|
590 CleanupStack::PopAndDestroy();//dateFormat |
|
591 if (aDest) // just calculating the length, aDest is NULL so DONT use it |
|
592 { |
|
593 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( dateString ); |
|
594 aDest->Append(dateString); |
|
595 } |
|
596 size +=dateString.Length(); |
|
597 } |
|
598 if ( aDest ) // just calculating the length, aDest is NULL so DONT use it |
|
599 { |
|
600 aDest->Append(KComma); |
|
601 aDest->Append(KSpace); |
|
602 } |
|
603 size += commaDes.Length(); |
|
604 size += spaceDes.Length(); |
|
605 } |
|
606 |
|
607 // 3: ", <recipient alias>" |
|
608 TDesC &recip = aItem->GetRecipient(); |
|
609 if ( aDest ) // just calculating the length, aDest is NULL so DONT use it |
|
610 { |
|
611 if ( CommonPhoneParser::IsValidPhoneNumber( recip, CommonPhoneParser::ESMSNumber ) ) |
|
612 { |
|
613 HBufC* tempBuf = recip.AllocLC(); |
|
614 TPtr number = tempBuf->Des(); |
|
615 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( number ); |
|
616 aDest->Append(number); |
|
617 CleanupStack::PopAndDestroy( tempBuf ); |
|
618 } |
|
619 else |
|
620 { |
|
621 aDest->Append(recip); |
|
622 } |
|
623 } |
|
624 size += recip.Length(); |
|
625 |
|
626 TDesC &temp = aItem->GetNumber(); |
|
627 if ( temp.Length() > 0 ) |
|
628 { |
|
629 HBufC* tempBuf = temp.AllocLC(); |
|
630 TPtr number = tempBuf->Des(); |
|
631 |
|
632 // 4: phone number. Value may be same as recipient for messages sent to |
|
633 // is not alias found ( set in the mms engine ) |
|
634 if ( number.Length() > 0 |
|
635 && number.CompareF( recip ) ) |
|
636 { |
|
637 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( number ); |
|
638 if (aDest) // just calculating the length, aDest is NULL so DONT use it |
|
639 { |
|
640 aDest->Append(KLineWrap); |
|
641 aDest->Append(KOpen); |
|
642 aDest->Append(number); // FIXME , internationalisointi |
|
643 aDest->Append(KClose); |
|
644 } |
|
645 |
|
646 size += linewrapDes.Length(); |
|
647 size += openDes.Length(); |
|
648 size += number.Length(); |
|
649 size += closeDes.Length(); |
|
650 } |
|
651 CleanupStack::PopAndDestroy( tempBuf ); |
|
652 } |
|
653 // 5: No copy. Causes some extra characters to allocate, because |
|
654 // line feeds are appended only after paragraph change |
|
655 size += linewrapDes.Length(); |
|
656 |
|
657 return size; |
|
658 } |
|
659 |
|
660 // ----------------------------------------------------------------------------- |
|
661 // CMsgInfoDeliveryStatusPopup::MessageSentToday |
|
662 // Check whether the msg is sent today. |
|
663 // ----------------------------------------------------------------------------- |
|
664 // |
|
665 TBool CMsgInfoDeliveryStatusPopup::MessageSentToday(const TDateTime& messageTime) |
|
666 { |
|
667 TBool sentToday(EFalse); // return value |
|
668 // current date and time |
|
669 TTime time; |
|
670 time.UniversalTime(); // current time |
|
671 CMmsMtmUi::ConvertUtcToLocalTime( time ); |
|
672 TDateTime currentTime = time.DateTime(); |
|
673 |
|
674 |
|
675 TInt currentYear(currentTime.Year()); |
|
676 TInt currentMonth(currentTime.Month()); |
|
677 TInt currentDay(currentTime.Day()); |
|
678 |
|
679 |
|
680 TInt messageYear(messageTime.Year()); |
|
681 TInt messageMonth(messageTime.Month()); |
|
682 TInt messageDay(messageTime.Day()); |
|
683 |
|
684 if (messageYear == currentYear) // the year is current, check month |
|
685 { |
|
686 if (messageMonth == currentMonth) // the month is current, check day |
|
687 { |
|
688 if (messageDay == currentDay) // the year, month and the day are the same as current, so message was sent today |
|
689 { |
|
690 sentToday = ETrue; |
|
691 } |
|
692 } |
|
693 } |
|
694 |
|
695 return sentToday; |
|
696 } |
|
697 // End of file |