Fixed crash during search operation in email app. The crash happens only if there...
[apps/native/preloaded/Email.git] / src / EmSearchPresentationModel.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file        EmSearchPresentationModel.cpp
19  * @brief       Keeps the implementation of SearchPresentationModel class
20  */
21
22 #include <cstdlib>
23 #include <FBase.h>
24 #include "EmNativeMailboxManager.h"
25 #include "EmSearchPresentationModel.h"
26 #include "EmTypes.h"
27
28 using namespace Tizen::App;
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Collection;
31 using namespace Tizen::Graphics;
32 using namespace Tizen::Locales;
33 using namespace Tizen::System;
34 using namespace Tizen::Ui;
35 using namespace Tizen::Ui::Controls;
36 using namespace Tizen::Ui::Scenes;
37
38
39 SearchPresentationModel* SearchPresentationModel::__pInstance = null;
40
41 SearchPresentationModel*
42 SearchPresentationModel::GetInstance()
43 {
44         AppLogDebug("ENTER");
45
46         if (__pInstance == null)
47         {
48                 __pInstance = new (std::nothrow) SearchPresentationModel();
49                 __pInstance->Construct();
50         }
51
52         AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
53         return __pInstance;
54 }
55
56 SearchPresentationModel::SearchPresentationModel()
57         : __searchFilter(SEARCH_ALL)
58         , __pModel(null)
59         , __pSearchFromData(null)
60 {
61         // Empty implementation
62 }
63
64 SearchPresentationModel::~SearchPresentationModel()
65 {
66         // Empty implementation
67 }
68
69 result
70 SearchPresentationModel::Construct(void)
71 {
72         AppLogDebug("ENTER");
73
74         result r = E_SUCCESS;
75
76         BasePresentationModel::Construct();
77
78         _pMailList = new (std::nothrow) ArrayList();
79         r = _pMailList->Construct();
80         TryCatch(r == E_SUCCESS, r = E_FAILURE, "Failed to construct result arraylist");
81
82 CATCH:
83         AppLogDebug("EXIT");
84         return r;
85 }
86
87 void
88 SearchPresentationModel::DestroyInstance(void)
89 {
90         AppLogDebug("ENTER");
91
92         if (__pInstance != null)
93         {
94                 __pInstance->CleanupInstance();
95                 delete __pInstance;
96                 __pInstance = null;
97         }
98
99         AppLogDebug("EXIT");
100         return;
101 }
102
103 void
104 SearchPresentationModel::CreateInstance(void)
105 {
106         AppLogDebug("ENTER");
107
108         result r = E_SUCCESS;
109
110         __pInstance = new (std::nothrow) SearchPresentationModel();
111         r = __pInstance->Construct();
112
113         if(IsFailed(r))
114         {
115                 delete __pInstance;
116                 __pInstance = null;
117                 return;
118         }
119
120         std::atexit(DestroyInstance);
121
122         AppLogDebug("EXIT");
123         return;
124 }
125
126 void
127 SearchPresentationModel::CleanupInstance(void)
128 {
129         AppLogDebug("ENTER");
130
131         _pMailList->RemoveAll();
132         delete _pMailList;
133
134         AppLogDebug("EXIT");
135         return;
136 }
137
138 void
139 SearchPresentationModel::FetchData(int accountId, bool forceUpdate)
140 {
141         // Empty Implementation
142 }
143
144 result
145 SearchPresentationModel::Initialize(BasePresentationModel* pModel)
146 {
147         AppLogDebug("ENTER");
148
149         result r = E_SUCCESS;
150
151         __pModel = pModel;
152         __pSearchFromData = __pModel->GetData();
153
154         _sortType = __pModel->GetSortType();
155
156         AppLogDebug("EXIT");
157         return r;
158 }
159
160 void
161 SearchPresentationModel::PerformSearch(const Tizen::Base::String& searchKey, bool fullDataSearch)
162 {
163         AppLogDebug("ENTER, searchKey:(%ls), fullDataSearch:(%d)", searchKey.GetPointer(), fullDataSearch);
164
165         EmailMessageListItem* pMsgItem;
166         String tmpSearchKey;
167         String tmpSearchInp;
168
169         __searchKey.Clear();
170         __searchKey.Append(searchKey);
171
172         searchKey.ToUpperCase(tmpSearchKey);
173
174         if (tmpSearchKey.IsEmpty() == true)
175         {
176                 ClearSearchData();
177                 
178                 if (_pMailList != null && __pSearchFromData != null)
179                 {
180                         _pMailList->AddItems(*__pSearchFromData);
181                         SortBy(_sortType);
182                 }
183         }
184         else if (fullDataSearch == true && __pSearchFromData != null)
185         {
186                 ClearSearchData();
187
188                 for (int i = 0; i < __pSearchFromData->GetCount(); i++)
189                 {
190                         pMsgItem = static_cast<EmailMessageListItem*>(__pSearchFromData->GetAt(i));
191
192                         if (pMsgItem != null)
193                         {
194                                 if (__searchFilter == SEARCH_ALL)
195                                 {
196                                         pMsgItem->GetFromEmailAddress().ToUpperCase(tmpSearchInp);
197                                         if (tmpSearchInp.Contains(tmpSearchKey))
198                                         {
199                                                 _pMailList->Add(pMsgItem);
200                                                 continue;
201                                         }
202
203                                         pMsgItem->GetSubject().ToUpperCase(tmpSearchInp);
204                                         if (tmpSearchInp.Contains(tmpSearchKey))
205                                         {
206                                                 _pMailList->Add(pMsgItem);
207                                                 continue;
208                                         }
209
210                                         pMsgItem->GetRecipients().ToUpperCase(tmpSearchInp);
211                                         if (tmpSearchInp.Contains(tmpSearchKey))
212                                         {
213                                                 _pMailList->Add(pMsgItem);
214                                                 continue;
215                                         }
216
217                                         pMsgItem->GetPreviewBodyText().ToUpperCase(tmpSearchInp);
218                                         if (tmpSearchInp.Contains(tmpSearchKey))
219                                         {
220                                                 _pMailList->Add(pMsgItem);
221                                                 continue;
222                                         }
223                                 }
224                                 else if (__searchFilter == SEARCH_SENDER)
225                                 {
226                                         pMsgItem->GetFromEmailAddress().ToUpperCase(tmpSearchInp);
227                                         if (tmpSearchInp.Contains(tmpSearchKey))
228                                         {
229                                                 _pMailList->Add(pMsgItem);
230                                         }
231                                 }
232                                 else if (__searchFilter == SEARCH_TITLE)
233                                 {
234                                         pMsgItem->GetSubject().ToUpperCase(tmpSearchInp);
235                                         if (tmpSearchInp.Contains(tmpSearchKey))
236                                         {
237                                                 _pMailList->Add(pMsgItem);
238                                         }
239                                 }
240                                 else if (__searchFilter == SEARCH_DATE)
241                                 {
242                                         // TODO Needs to be implemented
243                                 }
244                                 else if (__searchFilter == SEARCH_ADVANCED)
245                                 {
246                                         // TODO Needs to be implemented
247                                 }
248                         }
249                 }
250
251                 SortBy(_sortType);
252         }
253
254         AppLogDebug("EXIT");
255 }
256
257 void
258 SearchPresentationModel::SetSearchFilter(SearchFilter filter)
259 {
260         AppLogDebug("ENTER");
261         __searchFilter = filter;
262         AppLogDebug("EXIT");
263 }
264
265 void
266 SearchPresentationModel::ClearSearchData(void)
267 {
268         AppLogDebug("Enter");
269
270         if (_pMailList != null)
271         {
272                 _pMailList->RemoveAll();
273         }
274
275         AppLogDebug("Exit");
276 }
277
278 BasePresentationModel*
279 SearchPresentationModel::GetPresentationModel(void)
280 {
281         return __pModel;
282 }
283
284 const String&
285 SearchPresentationModel::GetSearchKey(void)
286 {
287         return __searchKey;
288 }
289
290
291 SearchFilter
292 SearchPresentationModel::GetSearchFilter(void)
293 {
294         return __searchFilter;
295 }
296
297 SearchResultProvider::SearchResultProvider()
298         : EmailBaseListViewItemProvider(SearchPresentationModel::GetInstance(), true)
299 {
300         __pSearchModel = SearchPresentationModel::GetInstance();
301 }
302
303 SearchResultProvider::~SearchResultProvider()
304 {
305         // Empty implementation
306 }
307
308 void
309 SearchResultProvider::CreateSubjectText(CustomItem* pItem, const EmailMessageListItem* pMail, const int& itemWidth)
310 {
311         AppLogDebug("ENTER");
312         int offset = 86;
313         int subjectWidth;
314
315         if (pMail->GetHasAttachment() > 0)
316         {
317                 subjectWidth = itemWidth - LIST_ITEM_OFFSET - X_ITEM_BITMAP - W_GENERIC_32;
318         }
319         else
320         {
321                 subjectWidth = itemWidth - LIST_ITEM_OFFSET;
322         }
323
324         EnrichedTextCustomListElement* pCustomListElement = new (std::nothrow) EnrichedTextCustomListElement(__pSearchModel->GetSearchFilter(), SUBJECT_TEXT, pMail, __pSearchModel->GetSearchKey());
325         pItem->AddElement(Rectangle(X_LIST_ITEM + offset, Y_LIST_ITEM_TYPE1, subjectWidth, _itemHeight-(H_LIST_SUB_ITEM_3_LINE+H_LIST_PREVIEW_ITEM_1_LINE)), IDA_BASE_LISTVIEW_ITEM_PROVIDER_SUBJECT_ELEMENT, *(static_cast<ICustomElement *>(pCustomListElement)));
326         AppLogDebug("listheight %d", _itemHeight-(H_LIST_SUB_ITEM_3_LINE+H_LIST_PREVIEW_ITEM_1_LINE));
327         AppLogDebug("rect bounds %d %d %d %d", X_LIST_ITEM + offset, Y_LIST_ITEM_TYPE1, subjectWidth, _itemHeight-(H_LIST_SUB_ITEM_3_LINE+H_LIST_PREVIEW_ITEM_1_LINE));
328 //      int offset = 86;
329 //
330 //      result r;
331 //      Font font;
332 //      int subjectWidth;
333 //      String pSearchKey;
334 //      String subjectText;
335 //      String originalSubjectText;
336 //      String  firstSubString, secondSubString, thirdSubString;
337 //
338 //      originalSubjectText = pMail->GetSubject();
339 //
340 //      if (originalSubjectText.IsEmpty() == false)
341 //      {
342 //              originalSubjectText.Trim();
343 //      }
344 //
345 //      if (originalSubjectText.GetLength() == 0)
346 //      {
347 //              originalSubjectText.Append(IDS_NO_SUBJECT);
348 //      }
349 //
350 //      originalSubjectText.ToLowerCase(subjectText);
351 //
352 //      if (pMail->GetHasAttachment() > 0)
353 //      {
354 //              subjectWidth = itemWidth - LIST_ITEM_OFFSET - X_ITEM_BITMAP - W_GENERIC_32;
355 //      }
356 //      else
357 //      {
358 //              subjectWidth = itemWidth - LIST_ITEM_OFFSET;
359 //      }
360 //
361 //      if (__pSearchModel->GetSearchFilter() == SEARCH_TITLE || __pSearchModel->GetSearchFilter() == SEARCH_ALL)
362 //      {
363 //              int index = -1;
364 //
365 //              TextElement* first = null;
366 //              TextElement* second = null;
367 //              TextElement* third = null;
368 //              EnrichedText* pSubject = new (std::nothrow) EnrichedText();
369 //
370 //              r = pSubject->Construct(Dimension(itemWidth, H_SUBJECT_MAIN_TEXT));
371 //              pSubject->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
372 //              pSubject->SetVerticalAlignment(TEXT_ALIGNMENT_MIDDLE);
373 //              pSubject->SetTextAbbreviationEnabled(true);
374 //
375 //              pSearchKey.Append(__pSearchModel->GetSearchKey());
376 //              pSearchKey.ToLowerCase();
377 //
378 //              r = subjectText.IndexOf(pSearchKey, 0, index);
379 //
380 //              if (r == E_SUCCESS)
381 //              {
382 //                      originalSubjectText.SubString(0, index, firstSubString);
383 //                      originalSubjectText.SubString(index, pSearchKey.GetLength(), secondSubString);
384 //                      originalSubjectText.SubString(pSearchKey.GetLength()+index, subjectText.GetLength()-(firstSubString.GetLength()+secondSubString.GetLength()), thirdSubString);
385 //
386 //                      font.Construct(FONT_STYLE_PLAIN, _fontSize);
387 //
388 //                      if (firstSubString.GetLength() > 0)
389 //                      {
390 //                              first = new (std::nothrow) TextElement();
391 //                              first->Construct(firstSubString);
392 //                              first->SetFont(font);
393 //
394 //                              if (pMail->isFlagsSeenField())
395 //                              {
396 //
397 //                                      first->SetTextColor(COLOR_READ_MAILS);
398 //                              }
399 //                              else
400 //                              {
401 //
402 //                                      first->SetTextColor(COLOR_UNREAD_MAILS);
403 //                              }
404 //
405 //                              pSubject->Add(*first);
406 //                      }
407 //
408 //                      if (secondSubString.GetLength() > 0)
409 //                      {
410 //                              second = new (std::nothrow) TextElement();
411 //                              second->Construct(secondSubString);
412 //                              second->SetTextColor(Color::GetColor(COLOR_ID_RED));
413 //                              second->SetFont(font);
414 //                              pSubject->Add(*second);
415 //                      }
416 //
417 //                      if (thirdSubString.GetLength() > 0)
418 //                      {
419 //                              third = new (std::nothrow) TextElement();
420 //                              third->Construct(thirdSubString);
421 //                              third->SetFont(font);
422 //
423 //                              if (pMail->isFlagsSeenField())
424 //                              {
425 //                                      third->SetTextColor(COLOR_READ_MAILS);
426 //                              }
427 //                              else
428 //                              {
429 //
430 //                                      third->SetTextColor(COLOR_UNREAD_MAILS);
431 //                              }
432 //
433 //                              pSubject->Add(*third);
434 //                      }
435 //
436 //                      pItem->AddElement(Rectangle(X_LIST_ITEM + offset, Y_LIST_ITEM_TYPE1, subjectWidth, _itemHeight-(H_LIST_SUB_ITEM_3_LINE+H_LIST_PREVIEW_ITEM_1_LINE)), IDA_BASE_LISTVIEW_ITEM_PROVIDER_SUBJECT_ELEMENT, *pSubject);
437 //                      delete pSubject;
438 //                      pSubject = null;
439 //              }
440 //              else
441 //              {
442 //                      if (pMail->isFlagsSeenField())
443 //                      {
444 //                              pItem->AddElement(Rectangle(X_LIST_ITEM + offset, Y_LIST_ITEM_TYPE1, subjectWidth, _itemHeight-(H_LIST_SUB_ITEM_3_LINE+H_LIST_PREVIEW_ITEM_1_LINE)), IDA_BASE_LISTVIEW_ITEM_PROVIDER_SUBJECT_ELEMENT, originalSubjectText, _fontSize, COLOR_READ_MAILS, Color::GetColor(COLOR_ID_WHITE), Color::GetColor(COLOR_ID_WHITE), true);
445 //                      }
446 //                      else
447 //                      {
448 //                              pItem->AddElement(Rectangle(X_LIST_ITEM + offset, Y_LIST_ITEM_TYPE1, subjectWidth, _itemHeight-(H_LIST_SUB_ITEM_3_LINE+H_LIST_PREVIEW_ITEM_1_LINE)), IDA_BASE_LISTVIEW_ITEM_PROVIDER_SUBJECT_ELEMENT, originalSubjectText, _fontSize, COLOR_UNREAD_MAILS, Color::GetColor(COLOR_ID_WHITE), Color::GetColor(COLOR_ID_WHITE), true);
449 //                      }
450 //              }
451 //      }
452 //      else
453 //      {
454 //              if (pMail->isFlagsSeenField())
455 //              {
456 //                      pItem->AddElement(Rectangle(X_LIST_ITEM + offset, Y_LIST_ITEM_TYPE1, subjectWidth, _itemHeight-(H_LIST_SUB_ITEM_3_LINE+H_LIST_PREVIEW_ITEM_1_LINE)), IDA_BASE_LISTVIEW_ITEM_PROVIDER_SUBJECT_ELEMENT, originalSubjectText, _fontSize, COLOR_READ_MAILS, Color::GetColor(COLOR_ID_WHITE), Color::GetColor(COLOR_ID_WHITE), true);
457 //              }
458 //              else
459 //              {
460 //                      pItem->AddElement(Rectangle(X_LIST_ITEM + offset, Y_LIST_ITEM_TYPE1, subjectWidth, _itemHeight-(H_LIST_SUB_ITEM_3_LINE+H_LIST_PREVIEW_ITEM_1_LINE)), IDA_BASE_LISTVIEW_ITEM_PROVIDER_SUBJECT_ELEMENT, originalSubjectText, _fontSize, COLOR_UNREAD_MAILS, Color::GetColor(COLOR_ID_WHITE), Color::GetColor(COLOR_ID_WHITE), true);
461 //              }
462 //      }
463
464         AppLogDebug("EXIT");
465         return;
466 }
467
468 void
469 SearchResultProvider::CreateRecipientText(CustomItem* pItem, const EmailMessageListItem* pMail, const int& itemWidth, const FloatDimension& dim)
470 {
471         AppLogDebug("ENTER");
472
473         int offset = 86;
474
475         EnrichedTextCustomListElement* pCustomListElement = new (std::nothrow) EnrichedTextCustomListElement(__pSearchModel->GetSearchFilter(), RECIPIENT_TEXT, pMail, __pSearchModel->GetSearchKey());
476         pItem->AddElement(Rectangle(X_LIST_ITEM + offset, Y_LIST_ITEM_TYPE1 + _itemHeight-(H_LIST_SUB_ITEM_3_LINE+H_LIST_PREVIEW_ITEM_1_LINE), itemWidth - LIST_ITEM_OFFSET - 10 - dim.width, H_LIST_SUB_ITEM_3_LINE), IDA_BASE_LISTVIEW_ITEM_PROVIDER_RECIPIENT_ELEMENT, *(static_cast<ICustomElement *>(pCustomListElement)));
477
478 //      result r = E_SUCCESS;
479 //      Font font;
480 //      String pSearchKey;
481 //      String recipientText;
482 //      String  firstSubString, secondSubString, thirdSubString;
483 //      email_mailbox_type_e mailboxType;
484 //
485 //      if (pMail != null)
486 //      {
487 //              mailboxType = _pModel->GetMailboxType(pMail->GetMailboxId());
488 //
489 //              if (mailboxType == EMAIL_MAILBOX_TYPE_DRAFT || mailboxType == EMAIL_MAILBOX_TYPE_SENTBOX)
490 //              {
491 //                      String emailAddress;
492 //                      Utility::StringTokenizer emailIdTokenizer(pMail->GetRecipients(), IDS_DELIM_SEMICOLON);
493 //
494 //                      if (emailIdTokenizer.HasMoreTokens() == true)
495 //                      {
496 //                              emailIdTokenizer.GetNextToken(emailAddress);
497 //
498 //                              if (emailAddress.GetLength() <= 1 && emailIdTokenizer.HasMoreTokens() == true)
499 //                              {
500 //                                      emailIdTokenizer.GetNextToken(emailAddress);
501 //                              }
502 //                      }
503 //
504 //                      Utils::ExtractEmailIdFromFullAddress(emailAddress, recipientText);
505 //              }
506 //              else
507 //              {
508 //                      Utils::ExtractAliasFromFullAddress(pMail->GetFromEmailAddress(), recipientText);
509 //              }
510 //      }
511 //
512 //      recipientText.Trim();
513 //
514 //      if (recipientText.GetLength() == 0)
515 //      {
516 //              recipientText.Append(IDS_NO_RECIPIENTS);
517 //      }
518 //
519 //      recipientText.ToLowerCase();
520 //
521 //      if (__pSearchModel->GetSearchFilter() == SEARCH_SENDER || __pSearchModel->GetSearchFilter() == SEARCH_ALL)
522 //      {
523 //              int index = -1;
524 //              TextElement* first = null;
525 //              TextElement* second = null;
526 //              TextElement* third = null;
527 //              EnrichedText* pRecipient = new (std::nothrow) EnrichedText();
528 //
529 //              r = pRecipient->Construct(Dimension(itemWidth, H_LIST_SUB_ITEM_3_LINE));
530 //              pRecipient->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
531 //              pRecipient->SetVerticalAlignment(TEXT_ALIGNMENT_MIDDLE);
532 //              pRecipient->SetTextAbbreviationEnabled(true);
533 //
534 //              pSearchKey.Append(__pSearchModel->GetSearchKey());
535 //              pSearchKey.ToLowerCase(pSearchKey);
536 //
537 //              r = recipientText.IndexOf(pSearchKey, 0, index);
538 //
539 //              if (r == E_SUCCESS)
540 //              {
541 //                      recipientText.SubString(0, index, firstSubString);
542 //                      recipientText.SubString(index, pSearchKey.GetLength(), secondSubString);
543 //                      recipientText.SubString(pSearchKey.GetLength()+index, recipientText.GetLength()-(firstSubString.GetLength()+secondSubString.GetLength()), thirdSubString);
544 //
545 //                      font.Construct(FONT_STYLE_PLAIN, FONT_SIZE_LIST_NAME_ITEM);
546 //
547 //                      if (firstSubString.GetLength() > 0)
548 //                      {
549 //                              first = new (std::nothrow) TextElement();
550 //                              first->Construct(firstSubString);
551 //                              first->SetFont(font);
552 //                              first->SetTextColor(COLOR_NAME_TEXT);
553 //                              pRecipient->Add(*first);
554 //                      }
555 //
556 //                      if (secondSubString.GetLength() > 0)
557 //                      {
558 //                              second = new (std::nothrow) TextElement();
559 //                              second->Construct(secondSubString);
560 //                              second->SetTextColor(Color::GetColor(COLOR_ID_RED));
561 //                              second->SetFont(font);
562 //                              pRecipient->Add(*second);
563 //                      }
564 //
565 //                      if (thirdSubString.GetLength() > 0)
566 //                      {
567 //                              third = new (std::nothrow) TextElement();
568 //                              third->Construct(thirdSubString);
569 //                              third->SetFont(font);
570 //                              third->SetTextColor(COLOR_NAME_TEXT);
571 //                              pRecipient->Add(*third);
572 //                      }
573 //
574 //                      pItem->AddElement(FloatRectangle(X_LIST_ITEM + offset, Y_LIST_ITEM_TYPE1 + _itemHeight-(H_LIST_SUB_ITEM_3_LINE+H_LIST_PREVIEW_ITEM_1_LINE), itemWidth - LIST_ITEM_OFFSET - 10 - dim.width, H_LIST_SUB_ITEM_3_LINE), IDA_BASE_LISTVIEW_ITEM_PROVIDER_RECIPIENT_ELEMENT, *pRecipient);
575 //                      delete pRecipient;
576 //                      pRecipient = null;
577 //              }
578 //              else
579 //              {
580 //                      if (recipientText.GetLength() != 0)
581 //                      {
582 //                              if (recipientText.StartsWith(L";", 0) == true)
583 //                              {
584 //                                      recipientText.Remove(0,1);
585 //                              }
586 //                      }
587 //
588 //                      pItem->AddElement(FloatRectangle(X_LIST_ITEM + offset, Y_LIST_ITEM_TYPE1 + _itemHeight-(H_LIST_SUB_ITEM_3_LINE+H_LIST_PREVIEW_ITEM_1_LINE), itemWidth - LIST_ITEM_OFFSET - 10 - dim.width, H_LIST_SUB_ITEM_3_LINE), IDA_BASE_LISTVIEW_ITEM_PROVIDER_RECIPIENT_ELEMENT, recipientText, FONT_SIZE_LIST_NAME_ITEM, COLOR_NAME_TEXT, Color::GetColor(COLOR_ID_WHITE), Color::GetColor(COLOR_ID_WHITE), false);
589 //              }
590 //      }
591 //      else
592 //      {
593 //              if (recipientText.GetLength() != 0)
594 //              {
595 //                      if (recipientText.StartsWith(L";", 0) == true)
596 //                      {
597 //                              recipientText.Remove(0,1);
598 //                      }
599 //              }
600 //
601 //              pItem->AddElement(FloatRectangle(X_LIST_ITEM + offset, Y_LIST_ITEM_TYPE1 + _itemHeight-(H_LIST_SUB_ITEM_3_LINE+H_LIST_PREVIEW_ITEM_1_LINE), itemWidth - LIST_ITEM_OFFSET - 10 - dim.width, H_LIST_SUB_ITEM_3_LINE), IDA_BASE_LISTVIEW_ITEM_PROVIDER_RECIPIENT_ELEMENT, recipientText, FONT_SIZE_LIST_NAME_ITEM, COLOR_NAME_TEXT, Color::GetColor(COLOR_ID_WHITE), Color::GetColor(COLOR_ID_WHITE), false);
602 //      }
603
604         AppLogDebug("EXIT");
605         return;
606 }
607
608 void
609 SearchResultProvider::CreateMessageText(CustomItem* pItem, const EmailMessageListItem* pMail, const int& itemWidth)
610 {
611         AppLogDebug("ENTER");
612
613         int offset = 86;
614
615         EnrichedTextCustomListElement* pCustomListElement = new (std::nothrow) EnrichedTextCustomListElement(__pSearchModel->GetSearchFilter(), MESSAGE_TEXT, pMail, __pSearchModel->GetSearchKey());
616         pItem->AddElement(Rectangle(X_LIST_ITEM + offset, _itemHeight-(H_LIST_SUB_ITEM_3_LINE+H_LIST_PREVIEW_ITEM_1_LINE) + H_LIST_SUB_ITEM_3_LINE, itemWidth - LIST_ITEM_OFFSET, H_LIST_SUB_ITEM_3_LINE), IDA_BASE_LISTVIEW_ITEM_PROVIDER_MESSAGE_ELEMENT, *(static_cast<ICustomElement *>(pCustomListElement)));
617
618 //      int offset = 86;
619 //
620 //      Font font;
621 //      result r;
622 //      String searchKey;
623 //      String messageText;
624 //      String originalMessageText;
625 //      String firstSubString, secondSubString, thirdSubString;
626 //
627 //      if (pMail != null)
628 //      {
629 //              originalMessageText = pMail->GetPreviewBodyText();
630 //              originalMessageText.Trim();
631 //
632 //              if (originalMessageText.GetLength() == 0)
633 //              {
634 //                      originalMessageText.Append(IDS_NO_PREVIEW_TEXT);
635 //              }
636 //
637 //              originalMessageText.ToLowerCase(messageText);
638 //
639 //              if (__pSearchModel->GetSearchFilter() == SEARCH_ALL)
640 //              {
641 //                      int index = -1;
642 //                      TextElement* first = null;
643 //                      TextElement* second = null;
644 //                      TextElement* third = null;
645 //                      EnrichedText* pMessage = new (std::nothrow) EnrichedText();
646 //
647 //                      r = pMessage->Construct(Dimension(itemWidth, H_LIST_SUB_ITEM_3_LINE));
648 //                      pMessage->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
649 //                      pMessage->SetVerticalAlignment(TEXT_ALIGNMENT_MIDDLE);
650 //                      pMessage->SetTextAbbreviationEnabled(true);
651 //
652 //                      searchKey.Append(__pSearchModel->GetSearchKey());
653 //                      searchKey.ToLowerCase(searchKey);
654 //
655 //                      r = messageText.IndexOf(searchKey, 0, index);
656 //
657 //                      if (r == E_SUCCESS)
658 //                      {
659 //                              originalMessageText.SubString(0, index, firstSubString);
660 //                              originalMessageText.SubString(index, searchKey.GetLength(), secondSubString);
661 //                              originalMessageText.SubString(searchKey.GetLength()+index, messageText.GetLength()-(firstSubString.GetLength()+secondSubString.GetLength()), thirdSubString);
662 //
663 //                              font.Construct(FONT_STYLE_PLAIN, FONT_SIZE_LIST_CONTENTS_ITEM);
664 //
665 //                              if (firstSubString.GetLength() > 0)
666 //                              {
667 //                                      first = new (std::nothrow) TextElement();
668 //                                      first->Construct(firstSubString);
669 //                                      first->SetFont(font);
670 //                                      first->SetTextColor(COLOR_CONTENTS_TEXT);
671 //                                      pMessage->Add(*first);
672 //                              }
673 //
674 //                              if (secondSubString.GetLength() > 0)
675 //                              {
676 //                                      second = new (std::nothrow) TextElement();
677 //                                      second->Construct(secondSubString);
678 //                                      second->SetTextColor(Color::GetColor(COLOR_ID_RED));
679 //                                      second->SetFont(font);
680 //                                      pMessage->Add(*second);
681 //                              }
682 //
683 //                              if (thirdSubString.GetLength() > 0)
684 //                              {
685 //                                      third = new (std::nothrow) TextElement();
686 //                                      third->Construct(thirdSubString);
687 //                                      third->SetFont(font);
688 //                                      third->SetTextColor(COLOR_CONTENTS_TEXT);
689 //                                      pMessage->Add(*third);
690 //                              }
691 //
692 //                              pItem->AddElement(Rectangle(X_LIST_ITEM + offset, _itemHeight-(H_LIST_SUB_ITEM_3_LINE+H_LIST_PREVIEW_ITEM_1_LINE) + H_LIST_SUB_ITEM_3_LINE, itemWidth - LIST_ITEM_OFFSET, H_LIST_SUB_ITEM_3_LINE), IDA_BASE_LISTVIEW_ITEM_PROVIDER_MESSAGE_ELEMENT, *pMessage);
693 //                      }
694 //                      else
695 //                      {
696 //                              messageText.Append(pMail->GetPreviewBodyText());
697 //
698 //                              pItem->AddElement(Rectangle(X_LIST_ITEM + offset, _itemHeight-(H_LIST_SUB_ITEM_3_LINE+H_LIST_PREVIEW_ITEM_1_LINE) + H_LIST_SUB_ITEM_3_LINE, itemWidth - LIST_ITEM_OFFSET, H_LIST_SUB_ITEM_3_LINE), IDA_BASE_LISTVIEW_ITEM_PROVIDER_MESSAGE_ELEMENT, originalMessageText, FONT_SIZE_LIST_CONTENTS_ITEM, COLOR_CONTENTS_TEXT, Color::GetColor(COLOR_ID_WHITE), Color::GetColor(COLOR_ID_WHITE), false);
699 //                      }
700 //              }
701 //              else
702 //              {
703 //                      messageText.Append(pMail->GetPreviewBodyText());
704 //
705 //                      pItem->AddElement(Rectangle(X_LIST_ITEM + offset, _itemHeight-(H_LIST_SUB_ITEM_3_LINE+H_LIST_PREVIEW_ITEM_1_LINE) + H_LIST_SUB_ITEM_3_LINE, itemWidth - LIST_ITEM_OFFSET, H_LIST_SUB_ITEM_3_LINE), IDA_BASE_LISTVIEW_ITEM_PROVIDER_MESSAGE_ELEMENT, originalMessageText, FONT_SIZE_LIST_CONTENTS_ITEM, COLOR_CONTENTS_TEXT, Color::GetColor(COLOR_ID_WHITE), Color::GetColor(COLOR_ID_WHITE), false);
706 //              }
707 //      }
708
709         AppLogDebug("EXIT");
710         return;
711 }
712
713 EnrichedTextCustomListElement::EnrichedTextCustomListElement(SearchFilter searchFilter, TextType textType, const EmailMessageListItem* pMail, String searchText)
714 {
715         AppLogDebug("ENTER");
716
717         __searchFilter = searchFilter;
718         __textType = textType;
719         __pMail = pMail;
720         __searchText = searchText;
721
722         AppLogDebug("EXIT");
723 }
724
725 bool
726 EnrichedTextCustomListElement::OnDraw(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& rect, Tizen::Ui::Controls::ListItemDrawingStatus itemStatus)
727 {
728         AppLogDebug("ENTER");
729
730         if (__textType == SUBJECT_TEXT)
731         {
732                 AppLogDebug("subject text");
733 //              int offset = 86;
734
735                 result r;
736                 Font font;
737 //              int subjectWidth;
738                 String pSearchKey;
739                 String subjectText;
740                 String originalSubjectText;
741                 String  firstSubString, secondSubString, thirdSubString;
742                 EnrichedText* pSubject = new (std::nothrow) EnrichedText();
743
744                 r = pSubject->Construct(Dimension(rect.width, Utils::GetItemHeight()-(H_LIST_SUB_ITEM_3_LINE+H_LIST_PREVIEW_ITEM_1_LINE)));
745                 pSubject->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
746                 pSubject->SetVerticalAlignment(TEXT_ALIGNMENT_MIDDLE);
747                 pSubject->SetTextAbbreviationEnabled(true);
748
749                 font.Construct(FONT_STYLE_PLAIN, Utils::GetFontSize());
750                 originalSubjectText = __pMail->GetSubject();
751
752                 if (originalSubjectText.IsEmpty() == false)
753                 {
754                         originalSubjectText.Trim();
755                 }
756
757                 if (originalSubjectText.GetLength() == 0)
758                 {
759                         originalSubjectText.Append(IDS_NO_SUBJECT);
760                 }
761
762                 originalSubjectText.ToLowerCase(subjectText);
763
764 //              if (__pMail->GetHasAttachment() > 0)
765 //              {
766 //                      subjectWidth = rect.width - LIST_ITEM_OFFSET - X_ITEM_BITMAP - W_GENERIC_32;
767 //              }
768 //              else
769 //              {
770 //                      subjectWidth = rect.width - LIST_ITEM_OFFSET;
771 //              }
772
773                 if (__searchFilter == SEARCH_TITLE || __searchFilter == SEARCH_ALL)
774                 {
775                         int index = -1;
776
777                         TextElement* first = null;
778                         TextElement* second = null;
779                         TextElement* third = null;
780
781
782                         pSearchKey.Append(__searchText);
783                         pSearchKey.ToLowerCase();
784
785                         r = subjectText.IndexOf(pSearchKey, 0, index);
786
787                         if (r == E_SUCCESS)
788                         {
789                                 originalSubjectText.SubString(0, index, firstSubString);
790                                 originalSubjectText.SubString(index, pSearchKey.GetLength(), secondSubString);
791                                 originalSubjectText.SubString(pSearchKey.GetLength()+index, subjectText.GetLength()-(firstSubString.GetLength()+secondSubString.GetLength()), thirdSubString);
792
793                                 if (firstSubString.GetLength() > 0)
794                                 {
795                                         first = new (std::nothrow) TextElement();
796                                         first->Construct(firstSubString);
797                                         first->SetFont(font);
798
799                                         if (itemStatus == LIST_ITEM_DRAWING_STATUS_NORMAL)
800                                         {
801                                                 if (__pMail->isFlagsSeenField())
802                                                 {
803
804                                                         first->SetTextColor(COLOR_READ_MAILS);
805                                                 }
806                                                 else
807                                                 {
808
809                                                         first->SetTextColor(COLOR_UNREAD_MAILS);
810                                                 }
811                                         }
812                                         else
813                                         {
814                                                 first->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
815                                         }
816
817                                         pSubject->Add(*first);
818                                 }
819
820                                 if (secondSubString.GetLength() > 0)
821                                 {
822                                         second = new (std::nothrow) TextElement();
823                                         second->Construct(secondSubString);
824                                         second->SetTextColor(Color::GetColor(COLOR_ID_RED));
825                                         second->SetFont(font);
826                                         pSubject->Add(*second);
827                                 }
828
829                                 if (thirdSubString.GetLength() > 0)
830                                 {
831                                         third = new (std::nothrow) TextElement();
832                                         third->Construct(thirdSubString);
833                                         third->SetFont(font);
834
835                                         if (itemStatus == LIST_ITEM_DRAWING_STATUS_NORMAL)
836                                         {
837                                                 if (__pMail->isFlagsSeenField())
838                                                 {
839                                                         third->SetTextColor(COLOR_READ_MAILS);
840                                                 }
841                                                 else
842                                                 {
843
844                                                         third->SetTextColor(COLOR_UNREAD_MAILS);
845                                                 }
846                                         }
847                                         else
848                                         {
849                                                 third->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
850                                         }
851
852                                         pSubject->Add(*third);
853                                 }
854                         }
855                         else
856                         {
857                                 first = new (std::nothrow) TextElement();
858                                 first->Construct(originalSubjectText);
859                                 first->SetFont(font);
860
861                                 if (itemStatus == LIST_ITEM_DRAWING_STATUS_NORMAL)
862                                 {
863                                         if (__pMail->isFlagsSeenField())
864                                         {
865                                                 first->SetTextColor(COLOR_READ_MAILS);
866                                         }
867                                         else
868                                         {
869                                                 first->SetTextColor(COLOR_UNREAD_MAILS);
870                                         }
871                                 }
872                                 else
873                                 {
874                                         first->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
875                                 }
876
877                                 pSubject->Add(*first);
878                         }
879                 }
880                 else
881                 {
882                         TextElement* first = null;
883                         first = new (std::nothrow) TextElement();
884                         first->Construct(originalSubjectText);
885                         first->SetFont(font);
886
887                         if (itemStatus == LIST_ITEM_DRAWING_STATUS_NORMAL)
888                         {
889                                 if (__pMail->isFlagsSeenField())
890                                 {
891                                         first->SetTextColor(COLOR_READ_MAILS);
892                                 }
893                                 else
894                                 {
895                                         first->SetTextColor(COLOR_UNREAD_MAILS);
896                                 }
897                         }
898                         else
899                         {
900                                 first->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
901                         }
902
903                         pSubject->Add(*first);
904                 }
905
906                 canvas.DrawText(Point(rect.x, rect.y), *pSubject);
907                 delete pSubject;
908                 pSubject = null;
909         }
910         else if (__textType == RECIPIENT_TEXT)
911         {
912 //              int offset = 86;
913                 AppLogDebug("recipient text");
914
915                 result r = E_SUCCESS;
916                 Font font;
917                 String pSearchKey;
918                 String recipientText;
919                 String  firstSubString, secondSubString, thirdSubString;
920                 email_mailbox_type_e mailboxType;
921
922                 EnrichedText* pRecipient = new (std::nothrow) EnrichedText();
923                 r = pRecipient->Construct(Dimension(rect.width, H_LIST_SUB_ITEM_3_LINE));
924                 pRecipient->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
925                 pRecipient->SetVerticalAlignment(TEXT_ALIGNMENT_MIDDLE);
926                 pRecipient->SetTextAbbreviationEnabled(true);
927
928                 font.Construct(FONT_STYLE_PLAIN, FONT_SIZE_LIST_NAME_ITEM);
929
930 //              if (__pMail != null)
931                 {
932                         BasePresentationModel* pModel = SearchPresentationModel::GetInstance()->GetPresentationModel();
933                         mailboxType = pModel->GetMailboxType(__pMail->GetMailboxId());
934
935                         if (mailboxType == EMAIL_MAILBOX_TYPE_DRAFT || mailboxType == EMAIL_MAILBOX_TYPE_SENTBOX)
936                         {
937                                 String emailAddress;
938                                 Utility::StringTokenizer emailIdTokenizer(__pMail->GetRecipients(), IDS_DELIM_SEMICOLON);
939
940                                 if (emailIdTokenizer.HasMoreTokens() == true)
941                                 {
942                                         emailIdTokenizer.GetNextToken(emailAddress);
943
944                                         if (emailAddress.GetLength() <= 1 && emailIdTokenizer.HasMoreTokens() == true)
945                                         {
946                                                 emailIdTokenizer.GetNextToken(emailAddress);
947                                         }
948                                 }
949
950                                 Utils::ExtractEmailIdFromFullAddress(emailAddress, recipientText);
951                         }
952                         else
953                         {
954                                 Utils::ExtractAliasFromFullAddress(__pMail->GetFromEmailAddress(), recipientText);
955                         }
956                 }
957
958                 recipientText.Trim();
959
960                 if (recipientText.GetLength() == 0)
961                 {
962                         recipientText.Append(IDS_NO_RECIPIENTS);
963                 }
964
965                 recipientText.ToLowerCase();
966
967                 if (__searchFilter == SEARCH_SENDER || __searchFilter == SEARCH_ALL)
968                 {
969                         int index = -1;
970                         TextElement* first = null;
971                         TextElement* second = null;
972                         TextElement* third = null;
973
974                         pSearchKey.Append(__searchText);
975                         pSearchKey.ToLowerCase(pSearchKey);
976
977                         r = recipientText.IndexOf(pSearchKey, 0, index);
978
979                         if (r == E_SUCCESS)
980                         {
981                                 recipientText.SubString(0, index, firstSubString);
982                                 recipientText.SubString(index, pSearchKey.GetLength(), secondSubString);
983                                 recipientText.SubString(pSearchKey.GetLength()+index, recipientText.GetLength()-(firstSubString.GetLength()+secondSubString.GetLength()), thirdSubString);
984
985                                 if (firstSubString.GetLength() > 0)
986                                 {
987                                         first = new (std::nothrow) TextElement();
988                                         first->Construct(firstSubString);
989                                         first->SetFont(font);
990
991                                         if (itemStatus == LIST_ITEM_DRAWING_STATUS_NORMAL)
992                                         {
993                                                 first->SetTextColor(COLOR_NAME_TEXT);
994                                         }
995                                         else
996                                         {
997                                                 first->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
998                                         }
999
1000                                         pRecipient->Add(*first);
1001                                 }
1002
1003                                 if (secondSubString.GetLength() > 0)
1004                                 {
1005                                         second = new (std::nothrow) TextElement();
1006                                         second->Construct(secondSubString);
1007                                         second->SetTextColor(Color::GetColor(COLOR_ID_RED));
1008                                         second->SetFont(font);
1009                                         pRecipient->Add(*second);
1010                                 }
1011
1012                                 if (thirdSubString.GetLength() > 0)
1013                                 {
1014                                         third = new (std::nothrow) TextElement();
1015                                         third->Construct(thirdSubString);
1016                                         third->SetFont(font);
1017
1018                                         if (itemStatus == LIST_ITEM_DRAWING_STATUS_NORMAL)
1019                                         {
1020                                                 third->SetTextColor(COLOR_NAME_TEXT);
1021                                         }
1022                                         else
1023                                         {
1024                                                 third->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
1025                                         }
1026
1027                                         pRecipient->Add(*third);
1028                                 }
1029                         }
1030                         else
1031                         {
1032                                 first = new (std::nothrow) TextElement();
1033
1034                                 if (recipientText.GetLength() != 0)
1035                                 {
1036                                         if (recipientText.StartsWith(L";", 0) == true)
1037                                         {
1038                                                 recipientText.Remove(0,1);
1039                                         }
1040                                 }
1041
1042                                 first->Construct(recipientText);
1043                                 first->SetFont(font);
1044
1045                                 if (itemStatus == LIST_ITEM_DRAWING_STATUS_NORMAL)
1046                                 {
1047                                         first->SetTextColor(COLOR_NAME_TEXT);
1048                                 }
1049                                 else
1050                                 {
1051                                         first->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
1052                                 }
1053
1054                                 pRecipient->Add(*first);
1055                         }
1056                 }
1057                 else
1058                 {
1059                         TextElement* first = null;
1060                         first = new (std::nothrow) TextElement();
1061
1062                         if (recipientText.GetLength() != 0)
1063                         {
1064                                 if (recipientText.StartsWith(L";", 0) == true)
1065                                 {
1066                                         recipientText.Remove(0,1);
1067                                 }
1068                         }
1069
1070                         first->Construct(recipientText);
1071                         first->SetFont(font);
1072
1073                         if (itemStatus == LIST_ITEM_DRAWING_STATUS_NORMAL)
1074                         {
1075                                 first->SetTextColor(COLOR_NAME_TEXT);
1076                         }
1077                         else
1078                         {
1079                                 first->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
1080                         }
1081
1082                         pRecipient->Add(*first);
1083
1084                 }
1085
1086                 canvas.DrawText(Point(rect.x, rect.y), *pRecipient);
1087                 delete pRecipient;
1088                 pRecipient = null;
1089         }
1090         else if (__textType == MESSAGE_TEXT)
1091         {
1092 //              int offset = 86;
1093
1094                 Font font;
1095                 result r = E_SUCCESS;
1096                 String searchKey;
1097                 String messageText;
1098                 String originalMessageText;
1099                 String firstSubString, secondSubString, thirdSubString;
1100
1101                 EnrichedText* pMessage = new (std::nothrow) EnrichedText();
1102
1103                 r = pMessage->Construct(Dimension(rect.width, H_LIST_SUB_ITEM_3_LINE));
1104                 pMessage->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
1105                 pMessage->SetVerticalAlignment(TEXT_ALIGNMENT_MIDDLE);
1106                 pMessage->SetTextAbbreviationEnabled(true);
1107
1108                 font.Construct(FONT_STYLE_PLAIN, FONT_SIZE_LIST_CONTENTS_ITEM);
1109
1110                 if (__pMail != null)
1111                 {
1112                         originalMessageText = __pMail->GetPreviewBodyText();
1113                         originalMessageText.Trim();
1114
1115                         if (originalMessageText.GetLength() == 0)
1116                         {
1117                                 originalMessageText.Append(IDS_NO_PREVIEW_TEXT);
1118                         }
1119
1120                         originalMessageText.ToLowerCase(messageText);
1121
1122                         if (__searchFilter == SEARCH_ALL)
1123                         {
1124                                 int index = -1;
1125                                 TextElement* first = null;
1126                                 TextElement* second = null;
1127                                 TextElement* third = null;
1128
1129                                 searchKey.Append(__searchText);
1130                                 searchKey.ToLowerCase(searchKey);
1131
1132                                 r = messageText.IndexOf(searchKey, 0, index);
1133
1134                                 if (r == E_SUCCESS)
1135                                 {
1136                                         originalMessageText.SubString(0, index, firstSubString);
1137                                         originalMessageText.SubString(index, searchKey.GetLength(), secondSubString);
1138                                         originalMessageText.SubString(searchKey.GetLength()+index, messageText.GetLength()-(firstSubString.GetLength()+secondSubString.GetLength()), thirdSubString);
1139
1140                                         if (firstSubString.GetLength() > 0)
1141                                         {
1142                                                 first = new (std::nothrow) TextElement();
1143                                                 first->Construct(firstSubString);
1144                                                 first->SetFont(font);
1145
1146                                                 if (itemStatus == LIST_ITEM_DRAWING_STATUS_NORMAL)
1147                                                 {
1148                                                         first->SetTextColor(COLOR_CONTENTS_TEXT);
1149                                                 }
1150                                                 else
1151                                                 {
1152                                                         first->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
1153                                                 }
1154
1155                                                 pMessage->Add(*first);
1156                                         }
1157
1158                                         if (secondSubString.GetLength() > 0)
1159                                         {
1160                                                 second = new (std::nothrow) TextElement();
1161                                                 second->Construct(secondSubString);
1162                                                 second->SetTextColor(Color::GetColor(COLOR_ID_RED));
1163                                                 second->SetFont(font);
1164                                                 pMessage->Add(*second);
1165                                         }
1166
1167                                         if (thirdSubString.GetLength() > 0)
1168                                         {
1169                                                 third = new (std::nothrow) TextElement();
1170                                                 third->Construct(thirdSubString);
1171                                                 third->SetFont(font);
1172
1173                                                 if (itemStatus == LIST_ITEM_DRAWING_STATUS_NORMAL)
1174                                                 {
1175                                                         third->SetTextColor(COLOR_CONTENTS_TEXT);
1176                                                 }
1177                                                 else
1178                                                 {
1179                                                         third->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
1180                                                 }
1181
1182                                                 pMessage->Add(*third);
1183                                         }
1184                                 }
1185                                 else
1186                                 {
1187                                         first = new (std::nothrow) TextElement();
1188                                         first->Construct(originalMessageText);
1189                                         first->SetFont(font);
1190
1191                                         if (itemStatus == LIST_ITEM_DRAWING_STATUS_NORMAL)
1192                                         {
1193                                                 first->SetTextColor(COLOR_CONTENTS_TEXT);
1194                                         }
1195                                         else
1196                                         {
1197                                                 first->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
1198                                         }
1199
1200                                         pMessage->Add(*first);
1201                                 }
1202                         }
1203                         else
1204                         {
1205                                 TextElement* first = null;
1206                                 first = new (std::nothrow) TextElement();
1207                                 first->Construct(originalMessageText);
1208                                 first->SetFont(font);
1209
1210                                 if (itemStatus == LIST_ITEM_DRAWING_STATUS_NORMAL)
1211                                 {
1212                                         first->SetTextColor(COLOR_CONTENTS_TEXT);
1213                                 }
1214                                 else
1215                                 {
1216                                         first->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
1217                                 }
1218
1219                                 pMessage->Add(*first);
1220                         }
1221                 }
1222
1223                 canvas.DrawText(Point(rect.x, rect.y), *pMessage);
1224                 delete pMessage;
1225                 pMessage = null;
1226         }
1227
1228         return true;
1229 }