Fixed Nabi Issues
[apps/osp/Internet.git] / src / IntHistoryListForm.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 //!Internet HistoryListForm class
18 /*@file: HistoryListForm.cpp
19  *@brief:       This class defines HistoryListForm used define history
20  *
21  */
22
23 #include <FApp.h>
24 #include <FUi.h>
25 #include "IntBookmarkData.h"
26 #include "IntBookmarkPresentationModel.h"
27 #include "IntCommonLib.h"
28 #include "IntFaviconManager.h"
29 #include "IntHistoryListForm.h"
30 #include "IntHistoryPresentationModel.h"
31 #include "IntMultipleWindowPresentationModel.h"
32 #include "IntSceneRegister.h"
33 #include "IntTypes.h"
34
35 using namespace Tizen::App;
36 using namespace Tizen::Base;
37 using namespace Tizen::Base::Collection;
38 using namespace Tizen::Base::Runtime;
39 using namespace Tizen::Graphics;
40 using namespace Tizen::Locales;
41 using namespace Tizen::Ui;
42 using namespace Tizen::Ui::Controls;
43 using namespace Tizen::Ui::Scenes;
44 using namespace Tizen::System;
45
46 static const wchar_t* IDB_TAB_ICON_BOOKMARKS = L"I01_tab_icon_bookmarks.png";
47 static const wchar_t* IDB_TAB_ICON_HISTORY = L"I01_tab_icon_history.png";
48 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
49 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
50
51
52 const int HistoryListForm::IDA_TABBAR_ITEM_1 = 101;
53 const int HistoryListForm::IDA_TABBAR_ITEM_2 = 102;
54 const int HistoryListForm::IDA_EDIT_HISTORY_LIST_FORM = 103;
55 const int HistoryListForm::IDA_FORMAT_ICON = 104;
56 const int HistoryListForm::IDA_FORMAT_TITLE = 105;
57 const int HistoryListForm::IDA_FORMAT_URL = 106;
58 const int HistoryListForm::IDA_FORMAT_BOOKMARK = 107;
59
60
61 HistoryListForm::HistoryListForm(void)
62 {
63         __pBookmarkList = null;
64         __pGroupedListView =null;
65         __pSearchListView = null;
66         __pSearchBar = null;
67         __pGroupData = null;
68         __pSearchedData = null ;
69         __searchHistory = false;
70         __isNoHistoryPresent = true;
71         __searchText = L"";
72         __previousSceneId = L"";
73 }
74
75 HistoryListForm::~HistoryListForm(void)
76 {
77         if (__pGroupData != null)
78         {
79                 __pGroupData->RemoveAll(false);
80                 delete __pGroupData;
81         }
82         if(__pBookmarkList != null)
83         {
84                 __pBookmarkList->RemoveAll(false);
85                 delete __pBookmarkList;
86         }
87 }
88
89 bool
90 HistoryListForm::Initialize(void)
91 {
92         Construct(L"IDL_HISTORY_LIST");
93
94         return true;
95 }
96
97 result
98 HistoryListForm::OnInitializing(void)
99 {
100         AppLog("HistoryListForm::OnInitializing");
101         result r = E_SUCCESS;
102         SceneManager* pSceneManager = null;
103         HeaderItem bookmark;
104         HeaderItem history;
105         Header *pHeader = GetHeader();
106         Bitmap *pIconBitmap = null;
107         AppResource* pAppResource = UiApp::GetInstance()->GetAppResource();
108         const Color brown = Color(32, 32, 32, 0xFF);
109
110         // Setup back event listener
111         SetFormBackEventListener(this);
112
113         GetHeader()->AddActionEventListener(*this);
114         GetFooter()->AddActionEventListener(*this);
115
116         AddOrientationEventListener(*this);
117         SettingInfo::AddSettingEventListener(*this);
118
119         pSceneManager = SceneManager::GetInstance();
120         if (pSceneManager != null)
121         {
122                 pSceneManager->AddSceneEventListener(IDSCN_HISTORY_LIST, *this);
123         }
124
125         if (pAppResource == null)
126         {
127                 return E_FAILURE;
128         }
129
130         __pGroupedListView = static_cast< GroupedListView* >(GetControl(L"IDC_GROUPEDLISTVIEW1"));
131         if (__pGroupedListView == null)
132         {
133                 return E_FAILURE;
134         }
135
136         r = __pGroupedListView->SetItemProvider(*this);
137         if (IsFailed(r))
138         {
139                 return r;
140         }
141
142
143         __pSearchBar = static_cast< SearchBar* >(GetControl(L"IDC_SEARCHBAR1"));
144         if (__pSearchBar == null)
145         {
146                 return E_FAILURE;
147         }
148         __pSearchListView = new(std::nothrow) GroupedListView();
149         if (__pSearchListView == null)
150         {
151                 return E_FAILURE;
152         }
153
154         __pGroupedListView->AddGroupedListViewItemEventListener(*this);
155         r = __pGroupedListView->SetBounds(Rectangle(0,__pGroupedListView->GetY(),GetClientAreaBounds().width,GetClientAreaBounds().height  - __pSearchBar->GetHeight() - __pSearchBar->GetY()));
156         if (IsFailed(r))
157         {
158                 return r;
159         }
160         r = __pSearchListView->Construct(Rectangle(0,0, GetClientAreaBounds().width, GetClientAreaBounds().height -__pSearchBar->GetHeight() - __pSearchBar->GetY()), GROUPED_LIST_VIEW_STYLE_INDEXED, true, false);
161         if (IsFailed(r))
162         {
163                 return r;
164         }
165         r = __pSearchListView->SetItemProvider(*this);
166         if (IsFailed(r))
167         {
168                 return r;
169         }
170         r = __pSearchListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RESULTS_FOUND"));
171
172         if (IsFailed(r))
173         {
174                 return r;
175         }
176
177         __pSearchListView->SetBackgroundColor(GetBackgroundColor());
178         __pSearchListView->SetTextColorOfEmptyList(Color::GetColor(COLOR_ID_BLACK));
179         __pSearchListView->AddGroupedListViewItemEventListener(*this);
180         r = __pSearchListView->SetShowState(false);
181         if (IsFailed(r))
182         {
183                 return r;
184         }
185
186
187         __pSearchBar->AddSearchBarEventListener(*this);
188         __pSearchBar->AddKeypadEventListener(*this);
189         r = __pSearchBar->SetContent(__pSearchListView);
190
191         if (pHeader != null)
192         {
193                 pHeader->SetStyle(HEADER_STYLE_TAB);
194                 bookmark.Construct(IDA_TABBAR_ITEM_1);
195                 String strbookmark;
196                 pAppResource->GetString(L"IDS_BR_TAB_BOOKMARKS", strbookmark);
197                 bookmark.SetText(strbookmark);
198                 pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_BOOKMARKS);
199                 bookmark.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
200                 bookmark.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
201                 pHeader->AddItem(bookmark);
202
203                 if (pIconBitmap)
204                 {
205                         delete pIconBitmap;
206                 }
207
208
209                 history.Construct(IDA_TABBAR_ITEM_2);
210                 String strhistory;
211                 pAppResource->GetString(L"IDS_BR_TAB_HISTORY", strhistory);
212                 history.SetText(strhistory);
213                 pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_HISTORY);
214                 history.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
215                 history.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
216                 pHeader->AddItem(history);
217                 pHeader->SetItemSelected(1);
218                 pHeader->SetTabEditModeEnabled(false);
219
220                 if (pIconBitmap != NULL)
221                 {
222                         delete pIconBitmap;
223                 }
224         }
225
226         __pBookmarkList = new(std::nothrow) Collection::ArrayList();
227         __pBookmarkList->Construct();
228         BookmarkPresentationModel::GetInstance()->GetBookmarkForHistory(0,*__pBookmarkList);
229         return r;
230 }
231
232 result
233 HistoryListForm::OnTerminating(void)
234 {
235         result r = E_SUCCESS;
236
237         SettingInfo::RemoveSettingEventListener(*this);
238         return r;
239 }
240
241 void
242 HistoryListForm::OnActionPerformed(const Control& source, int actionId)
243 {
244         AppLog("HistoryListForm::OnActionPerformed");
245         result r = E_FAILURE;
246         SceneManager* pSceneManager = SceneManager::GetInstance();
247         if (pSceneManager == null)
248         {
249                 return;
250         }
251         switch (actionId)
252         {
253         case IDA_EDIT_HISTORY_LIST_FORM:
254         {
255                 AppLog("ID_EDIT_HISTORY_LIST_FORM entered");
256                 r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_EDIT_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
257                 if (IsFailed(r))
258                 {
259                         return;
260                 }
261         }
262         break;
263         case IDA_TABBAR_ITEM_1:
264         {
265                 result r = GetHeader()->SetItemSelected(1);
266                 AppLog("SetItemSelected result %s",GetErrorMessage(r));
267                 GetHeader()->Invalidate(true);
268
269                 if (pSceneManager != null)
270                 {
271                         if(__previousSceneId.CompareTo(IDSCN_BOOKMARK_VIEW) != 0)
272                         {
273                                 if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_LEFT)) != E_SUCCESS)
274                                 {
275                                         AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
276                                         return;
277                                 }
278                         }
279                         else
280                         {
281
282                                 if(pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT))!= E_SUCCESS)
283                                 {
284                                         AppLogDebug("BookmarkListForm::OnActionPerformed GoBackward failed");
285                                         return;
286                                 }
287
288                         }
289                 }
290 //              r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
291                 if (IsFailed(r))
292                 {
293                         return;
294                 }
295         }
296         break;
297         default:
298                 break;
299         }
300 }
301
302 void
303 HistoryListForm::OnFormBackRequested(Form& source)
304 {
305         SceneManager* pSceneManager = SceneManager::GetInstance();
306         if (pSceneManager == null)
307         {
308                 return;
309         }
310         result r = E_FAILURE;
311         if(__previousSceneId.CompareTo(IDSCN_BOOKMARK_VIEW) != 0)
312         {
313                         r = pSceneManager->GoBackward(BackwardSceneTransition());
314         }
315         else
316         {
317                 r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
318         }
319         if(IsFailed(r))
320         {
321                 AppLogDebug("HistoryListForm::OnFormBackRequested GoForward failed %s",GetErrorMessage(r));
322         }
323 }
324
325 GroupItem*
326 HistoryListForm::CreateGroupItem(int groupIndex, int itemWidth)
327 {
328         result r = E_FAILURE;
329         int strMonth = 0;
330         String text(L"");
331         DateTime endTime;
332         DateTime startTime;
333         int count = 0;
334         GroupItem* pItem = null;
335         GroupItemClass* pGroupItemClass = null;
336
337         String weeksAgo2 = L"";
338         weeksAgo2.Format(25,CommonUtil::GetString(L"IDS_BR_BODY_PD_WEEKS_AGO").GetPointer(),2);
339
340         String weeksAgo3 = L"";
341         weeksAgo3.Format(25,CommonUtil::GetString(L"IDS_BR_BODY_PD_WEEKS_AGO").GetPointer(),3);
342
343         String weeksAgo4 = L"";
344         weeksAgo4.Format(25,CommonUtil::GetString(L"IDS_BR_BODY_PD_WEEKS_AGO").GetPointer(),4);
345
346         pItem = new(std::nothrow) GroupItem();
347         if (pItem == null)
348         {
349                 return null;
350         }
351         pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
352
353         if (pGroupItemClass == null || pGroupItemClass->GetHistoryData() == null || pGroupItemClass->GetHistoryData()->GetCount() == 0)
354         {
355                 AppLog("CreateGroupItem :: if history is null");
356                 r = pItem->Construct(Dimension(itemWidth, 0));
357                 return pItem;
358         }
359         else
360         {
361                 r = pItem->Construct(Dimension(itemWidth, 48));
362         }
363         text = pGroupItemClass->GetTitleText();
364
365         if (__searchHistory == false)
366         {
367                 String month = L"";
368                 text.Append(L" (");
369                 if (pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_COM_BODY_TODAY") || pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY"))
370                 {
371                         int dayOfWeek = 0;
372                         Calendar* pGregorianCalendar = Calendar::CreateInstanceN(CALENDAR_GREGORIAN);
373                         if ( pGregorianCalendar != NULL)
374                         {
375                                 r = pGregorianCalendar->SetTimeField(TIME_FIELD_YEAR, pGroupItemClass->GetStartTime().GetYear());
376                                 if (IsFailed(r))
377                                 {
378                                         if( pItem != null)
379                                         {
380                                                 delete pItem;
381                                         }
382                                         delete pGregorianCalendar;
383                                         return null;
384                                 }
385                                 r = pGregorianCalendar->SetTimeField(TIME_FIELD_MONTH, pGroupItemClass->GetStartTime().GetMonth());
386                                 if (IsFailed(r))
387                                 {
388                                         if( pItem != null)
389                                         {
390                                                 delete pItem;
391                                         }
392                                         delete pGregorianCalendar;
393                                         return null;
394                                 }
395                                 r = pGregorianCalendar->SetTimeField(TIME_FIELD_DAY_OF_MONTH, pGroupItemClass->GetStartTime().GetDay());
396                                 if (IsFailed(r))
397                                 {
398                                         if( pItem != null)
399                                         {
400                                                 delete pItem;
401                                         }
402                                         delete pGregorianCalendar;
403                                         return null;
404                                 }
405                                 dayOfWeek = pGregorianCalendar->GetTimeField(TIME_FIELD_DAY_OF_WEEK);
406
407                                 delete pGregorianCalendar;
408
409                         }
410                         switch(dayOfWeek)
411                         {
412                         case SUNDAY:
413                                 text.Append(CommonUtil::GetString(L"IDS_COM_BODY_SUN"));
414                                 break;
415                         case MONDAY:
416                                 text.Append(CommonUtil::GetString(L"IDS_COM_BODY_MON"));
417                                 break;
418                         case TUESDAY:
419                                 text.Append(CommonUtil::GetString(L"IDS_COM_BODY_TUE"));
420                                 break;
421                         case WEDNESDAY:
422                                 text.Append(CommonUtil::GetString(L"IDS_COM_BODY_WED"));
423                                 break;
424                         case THURSDAY:
425                                 text.Append(CommonUtil::GetString(L"IDS_COM_BODY_THU"));
426                                 break;
427                         case FRIDAY:
428                                 text.Append(CommonUtil::GetString(L"IDS_COM_BODY_FRI"));
429                                 break;
430                         case SATURDAY:
431                                 text.Append(CommonUtil::GetString(L"IDS_COM_BODY_SAT"));
432                                 break;
433                         default:
434                                 break;
435                         }
436                         text.Append(L", ");
437                 }
438
439                 if (pGroupItemClass->GetTitleText() != CommonUtil::GetString(L"IDS_BR_BODY_OLDER"))
440                 {
441                         text.Append(pGroupItemClass->GetStartTime().GetDay());
442                         text.Append(L". ");
443                         strMonth = pGroupItemClass->GetStartTime().GetMonth();
444                         month = GetMonth(strMonth);
445                         text.Append(month);
446                 }
447                 else
448                 {
449                         text.Append(L"~ ");
450                 }
451
452
453
454                 if (pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK") || pGroupItemClass->GetTitleText() == weeksAgo2
455                                 || pGroupItemClass->GetTitleText() == weeksAgo3 || pGroupItemClass->GetTitleText() == weeksAgo4 || pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_BR_EARLIER_THIS_MONTH") || pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_MONTH") || pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_BR_BODY_OLDER"))
456                 {
457                         text.Append(L" - ");
458                         text.Append(pGroupItemClass->GetEndTime().GetDay());
459                         text.Append(L". ");
460                         strMonth = pGroupItemClass->GetEndTime().GetMonth();
461                         month = GetMonth(strMonth);
462                         text.Append(month);
463                 }
464                 text.Append(L")");
465         }
466
467         r = pItem->SetElement(text, null);
468         if (IsFailed(r))
469         {
470                 delete pItem;
471                 AppLogDebug("Failed with %s", GetErrorMessage(r));
472                 return null;
473         }
474         r = pItem->SetTextSize(32);
475         if (IsFailed(r))
476         {
477                 delete pItem;
478                 return null;
479         }
480
481         return pItem;
482 }
483
484 ListItemBase*
485 HistoryListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
486 {
487         AppLog("HistoryListForm::CreateItem");
488         result r = E_FAILURE;
489         History* pHistory = null;
490         Bitmap* pBitmap = null;
491         Bitmap* pBookmarkBitmap = null;
492         GroupItemClass* pGroupItemClass = null;
493         CustomItem* pItem = new(std::nothrow) CustomItem();
494         int bookmarkBtnWidth = 0;
495         String bitmapId;
496
497         if(__pGroupData == null)
498         {
499                 delete pItem;
500                 return null;
501         }
502
503         if (pItem == null)
504         {
505                 return null;
506         }
507         pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
508         if (pGroupItemClass == null)
509         {
510                 delete pItem;
511                 return null;
512         }
513         if (pGroupItemClass->GetHistoryData() == null)
514         {
515                 delete pItem;
516                 return null;
517         }
518         pHistory = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(itemIndex));
519         if (pHistory == null)
520         {
521                 delete pItem;
522                 return null;
523         }
524         r = pItem->Construct(Dimension(itemWidth, 128), LIST_ANNEX_STYLE_NORMAL);
525         if (IsFailed(r))
526         {
527                 delete pItem;
528                 return null;
529         }
530
531         bitmapId = pHistory->GetFaviconId() ;
532
533         pBitmap = pHistory->GetFavIconBitmap();
534
535         if (pBitmap == null)
536         {
537                 pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
538         }
539         if (pBitmap != null)
540         {
541                 r = pItem->AddElement(Rectangle(16, 28, 72, 72), IDA_FORMAT_ICON, *pBitmap, null);
542                 delete pBitmap;
543                 if (IsFailed(r))
544                 {
545                         delete pItem;
546                         AppLogException("CreateItem failed with %s", GetErrorMessage(r));
547                         return null;
548                 }
549         }
550         bool urlFoundInBookmark = false;
551
552         if(__pBookmarkList != null)
553         {
554                 for (int i = 0; i < __pBookmarkList->GetCount();i++)
555                 {
556                         BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pBookmarkList->GetAt(i));
557                         if(pBookMark != null && pHistory->GetHistoryUrl().CompareTo(pBookMark->GetUrl()) == 0)
558                         {
559                                 urlFoundInBookmark = true;
560                                 break;
561                         }
562                 }
563         }
564         if (urlFoundInBookmark == true)
565         {
566                 pBookmarkBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
567         }
568         else
569         {
570                 pBookmarkBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
571         }
572         bookmarkBtnWidth = 64;
573
574
575         r = pItem->AddElement(Rectangle(104, 10, GetClientAreaBounds().width - 108 - 32 - bookmarkBtnWidth - 32, 60), IDA_FORMAT_TITLE, pHistory->GetHistoryTitle(), 44,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
576         TryCatch(!IsFailed(r), "CreateItem failed with %s",GetErrorMessage(r));
577
578         if(__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
579                 r = pItem->AddElement(Rectangle(104, 70, GetClientAreaBounds().width - 108 - 32 - bookmarkBtnWidth - 32, 48), IDA_FORMAT_URL, pHistory->GetHistoryUrl(),32,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
580         else
581                 r = pItem->AddElement(Rectangle(104, 70, GetClientAreaBounds().width - 108 - 32 - bookmarkBtnWidth - 32, 48), IDA_FORMAT_URL, pHistory->GetHistoryUrl(),32,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,true);
582         TryCatch(!IsFailed(r), "CreateItem failed with %s",GetErrorMessage(r));
583         if ( pBookmarkBitmap != null)
584         {
585                 r = pItem->AddElement(Rectangle(GetClientAreaBounds().width - bookmarkBtnWidth - 16, (128 - pBookmarkBitmap->GetHeight())/2, bookmarkBtnWidth, bookmarkBtnWidth), IDA_FORMAT_BOOKMARK, *pBookmarkBitmap);
586                 TryCatch(!IsFailed(r), "CreateItem failed with %s",GetErrorMessage(r));
587                 delete pBookmarkBitmap;
588         }
589         return pItem;
590
591         CATCH:
592         delete pItem;
593         return null;
594 }
595
596 bool
597 HistoryListForm::DeleteGroupItem(int groupIndex, GroupItem* pItem, int itemWidth)
598 {
599
600         //      delete pItem;
601         //      pItem = null;
602         return false;
603 }
604
605 bool
606 HistoryListForm::DeleteItem(int groupIndex, int itemIndex, ListItemBase* pItem, int itemWidth)
607 {
608         AppLog("HistoryListForm::DeleteItem");
609         result r = E_FAILURE;
610         GroupItemClass* pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
611         if (pGroupItemClass == null)
612         {
613                 return false;
614         }
615
616         //      if (pGroupItemClass->__pData != null)
617         //      {
618         //              r = pGroupItemClass->__pData->RemoveAt(itemIndex);
619         //              if (IsFailed(r))
620         //              {
621         //                      return false;
622         //              }
623         //      }
624
625         delete pItem;
626         pItem = null;
627         return true;
628 }
629
630 int
631 HistoryListForm::GetGroupCount(void)
632 {
633         __isNoHistoryPresent = true;
634         CreateGroupItems();
635         if (__pGroupData != null)
636         {
637                 if (__searchHistory == false)
638                 {
639                         int count = 0;
640                         HistoryPresentationModel::GetInstance()->GetHistoryCount(count);
641                         if (count == 0)
642                         {
643                                 return 0;
644                         }
645                         return __pGroupData->GetCount();
646                 }
647                 else
648                 {
649                         int count = 0;
650                 //      String searchText = __pSearchBar->GetText();
651                         result r = HistoryPresentationModel::GetInstance()->GetSearchHistoryCount(count, __searchText);
652                         if(count)
653                                 return 1;
654                         else
655                                 return 0;
656                 }
657         }
658         else
659         {
660                 return 0;
661         }
662 }
663
664 int
665 HistoryListForm::GetItemCount(int groupIndex)
666 {
667         result r = E_FAILURE;
668         int count = 0;
669         DateTime endTime;
670         DateTime startTime;
671         String text;
672
673         GroupItemClass* pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
674         if (pGroupItemClass == null)
675         {
676                 return null;
677         }
678         if (__searchHistory == false)
679         {
680                 startTime = pGroupItemClass->GetStartTime();
681                 endTime = pGroupItemClass->GetEndTime();
682                 r = HistoryPresentationModel::GetInstance()->GetHistoryCountWithTimeRange(startTime,endTime,count);
683         }
684         else
685         {
686                 //text =  __pSearchBar->GetText();
687                 r = HistoryPresentationModel::GetInstance()->GetSearchHistoryCount(count,__searchText);
688                 if(count == 0)
689                 {
690                         return count;
691                 }
692         }
693         if (IsFailed(r))
694         {
695                 return 0;
696         }
697
698         ArrayList* pData = new(std::nothrow) ArrayList();
699         if (pData == null)
700         {
701                 return 0;
702         }
703         r = pData->Construct();
704
705         if (IsFailed(r))
706         {
707                 delete pData;
708                 return 0;
709         }
710
711         if (__searchHistory == false)
712         {
713                 startTime = pGroupItemClass->GetStartTime();
714                 endTime = pGroupItemClass->GetEndTime();
715                 AppLog("Starttime %ls endtime %ls",startTime.ToString().GetPointer(),endTime.ToString().GetPointer());
716                 r = HistoryPresentationModel::GetInstance()->GetHistoryWithTimeRange(startTime,endTime, 0, count, *pData);
717         }
718         else
719         {
720                 //text = __pSearchBar->GetText() ;
721                 r = HistoryPresentationModel::GetInstance()->GetSearchHistory(0, count, *pData,__searchText );
722         }
723         if (IsFailed(r))
724         {
725                 delete pData;
726                 return 0;
727         }
728         pGroupItemClass->SetHistoryData(pData);
729
730
731         if (__isNoHistoryPresent == true && count == 0)
732         {
733                 __isNoHistoryPresent = true;
734                 GetFooter()->SetItemEnabled(0, false);
735         }
736         else
737         {
738                 __isNoHistoryPresent = false;
739                 GetFooter()->SetItemEnabled(0, true);
740         }
741         //       pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
742         if (pGroupItemClass == null || pGroupItemClass->GetHistoryData() == null)
743         {
744                 delete pData;
745                 return 0;
746         }
747         else
748         {
749                 AppLogDebug("HistoryListForm::GetItemCount returning %d for %d title %ls",pGroupItemClass->GetHistoryData()->GetCount(),groupIndex,pGroupItemClass->GetTitleText().GetPointer());
750                 return pGroupItemClass->GetHistoryData()->GetCount();
751         }
752 }
753
754 void
755 HistoryListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
756 {
757
758         GetHeader()->SetItemSelected(1);
759 //      __previousSceneId = previousSceneId;
760         ArrayListT<String> * pList = dynamic_cast<ArrayListT<String>* >(SceneManager::GetInstance()->GetSceneHistoryN());
761         if(pList != null)
762         {
763                 pList->GetAt(pList->GetCount()-1,__previousSceneId);
764         }
765
766         if(__pBookmarkList != null)
767         {
768                 __pBookmarkList->RemoveAll(false);
769         }
770
771         BookmarkPresentationModel::GetInstance()->GetBookmarkForHistory(0,*__pBookmarkList);
772
773         AppLog("HistoryListForm::OnSceneActivatedN called");
774         //GetHeader()->Invalidate(true);
775         if (__pGroupData == null)
776         {
777                 __pGroupData = new(std::nothrow) ArrayList();
778                 __pGroupData->Construct();
779         }
780         if (__pGroupedListView != null)
781         {
782                 __pGroupedListView->UpdateList();
783         }
784         if (__isNoHistoryPresent == true)
785         {
786                 GetFooter()->SetItemEnabled(0, false);
787         }
788         else
789         {
790                 GetFooter()->SetItemEnabled(0, true);
791         }
792
793         int count = 0;
794         HistoryPresentationModel::GetInstance()->GetHistoryCount(count);
795         if (count == 0)
796         {
797                 __pSearchBar->SetShowState(false);
798                 __pSearchBar->Invalidate(true);
799         }
800         else
801         {
802                 __pSearchBar->SetShowState(true);
803                 __pSearchBar->Invalidate(true);
804         }
805
806         //      if (__isNoHistoryPresent == true)
807         //      {
808         //              //      __pGroupedListView->SetBitmapOfEmptyList(AppResource::GetInstance()->GetBitmapN(L"I01_Nocontents_Bookmarks.png"));
809         //              __pGroupedListView->UpdateList();
810         //      }
811
812         result r = GetHeader()->SetItemSelected(2);
813         if (IsFailed(r))
814         {
815                 AppLog("HistoryListForm::OnSceneActivatedN header failed %ls", GetErrorMessage(r));
816                 return;
817         }
818
819
820
821         Invalidate(true);
822
823 }
824
825 void
826 HistoryListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
827 {
828         AppLog("HistoryListForm::OnSceneDeactivated");
829         __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
830 }
831
832 void
833 HistoryListForm::OnGroupedListViewContextItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListContextItemStatus status)
834 {
835
836 }
837
838 void
839 HistoryListForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListItemStatus status)
840 {
841         GroupItemClass* pGroupItemClass = null;
842         History* pHistory = null;
843         AppLog("int groupIndex %d, int itemIndex %d, int elementId %d, ListItemStatus status %d",groupIndex,itemIndex,elementId,status);
844         if (elementId == IDA_FORMAT_BOOKMARK)
845         {
846                 String toggledUrl = L"";
847                 AppLog("BookMarkStatusChanged ID_FORMAT_BOOKMARK");
848                 pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
849                 if (pGroupItemClass == null)
850                 {
851                         return;
852                 }
853                 pHistory = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(itemIndex));
854                 if (pHistory == null)
855                 {
856                         return;
857                 }
858                 toggledUrl = pHistory->GetHistoryUrl();
859
860                 AppLog("History's Bookmark ID %ls ToggledUrl %ls",pHistory->GetBookmarkId().GetPointer(),toggledUrl.GetPointer());
861
862                 bool bookmarkFound = false;
863                 BookmarkData* pBookMark = null;
864                 if(__pBookmarkList != null)
865                 {
866                         for (int i = 0; i < __pBookmarkList->GetCount(); i++)
867                         {
868                                 pBookMark = dynamic_cast< BookmarkData* >(__pBookmarkList->GetAt(i));
869                                 if (pBookMark != null && toggledUrl.CompareTo(pBookMark->GetUrl()) == 0)
870                                 {
871                                         bookmarkFound = true;
872                                         break;
873                                 }
874                         }
875                 }
876                 if(bookmarkFound == false)
877                 {
878                         // Add the history in bookmark database
879                         result r = E_FAILURE;
880                         BookmarkData pBookmark;
881
882                         String bookmarkTitle = pHistory->GetHistoryTitle();
883
884                         pBookmark.SetBookmarkTitle(bookmarkTitle);
885                         pBookmark.SetUrl(pHistory->GetHistoryUrl());
886                         pBookmark.SetFaviconId(pHistory->GetFaviconId());
887
888                         r = BookmarkPresentationModel::GetInstance()->SaveBookmark(pBookmark);
889                 }
890                 else
891                 {
892                         // remove the history from bookmark database
893                         BookmarkPresentationModel::GetInstance()->DeleteBookmark(toggledUrl);
894                 }
895
896                 if(__pBookmarkList != null)
897                 {
898                         __pBookmarkList->RemoveAll(false);
899                         BookmarkPresentationModel::GetInstance()->GetBookmarkForHistory(0,*__pBookmarkList);
900                 }
901                 listView.RefreshList(groupIndex,itemIndex,LIST_REFRESH_TYPE_ITEM_MODIFY);
902                 listView.UpdateList();
903         }
904         else
905         {
906                 pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
907                 if (pGroupItemClass == null)
908                 {
909                         return;
910                 }
911
912                 History* pHistory1 = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(itemIndex));
913                 if (pHistory1 == null)
914                 {
915                         return;
916                 }
917                 SceneManager* pSceneManager = SceneManager::GetInstance();
918                 ArrayList *pArgList = null;
919                 result r = E_SUCCESS;
920                 pArgList = new(std::nothrow) ArrayList();
921                 if (pArgList != null)
922                 {
923                         r = pArgList->Construct();
924                         if (IsFailed(r))
925                         {
926                                 delete pArgList;
927                                 return;
928                         }
929
930                         r = pArgList->Add(*MultipleWindowPresentationModel::GetInstance()->GetActiveWindowInfo());
931                         r = pArgList->Add(*new(std::nothrow) String(pHistory1->GetHistoryUrl()));
932                         if (IsFailed(r))
933                         {
934                                 delete pArgList;
935                                 return;
936                         }
937
938
939                 }
940
941                 String scneId = L"";
942                 MultipleWindowPresentationModel::GetInstance()->GetCurrentSceneId(scneId);
943
944                 if (pSceneManager != null)
945                 {
946                         AppLog("pSceneManager exists");
947                         r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(scneId), pArgList);
948                         if(pArgList)
949                         {
950                                 pArgList->RemoveAll(false);
951                                 delete pArgList;
952                         }
953                         if (IsFailed(r))
954                         {
955                                 return;
956                         }
957                 }
958         }
959
960 }
961
962 void
963 HistoryListForm::OnGroupedListViewItemSwept(GroupedListView& listView, int groupIndex, int itemIndex, SweepDirection direction)
964 {
965
966 }
967
968 void
969 HistoryListForm::OnSearchBarModeChanged(SearchBar& source, SearchBarMode mode)
970 {
971         result r = E_FAILURE;
972         if (mode == SEARCH_BAR_MODE_NORMAL)
973         {
974                 if ( Clipboard::GetInstance()->IsPopupVisible() == false && __searchHistory == false)
975                 {
976                         __pSearchListView->SetEnabled(true);
977                 }
978
979                 r = __pSearchListView->SetShowState(false);
980                 if (IsFailed(r))
981                 {
982                         return;
983                 }
984                 r = __pGroupedListView->SetShowState(true);
985                 if (IsFailed(r))
986                 {
987                         return;
988                 }
989                 __pSearchListView->SetEnabled(true);
990                 if(__pSearchBar != null)
991                         __pGroupedListView->SetBounds(0, __pSearchBar->GetY() + __pSearchBar->GetHeight(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
992                 Invalidate(true);
993                 __searchHistory = false;
994                 r = __pGroupedListView->UpdateList();
995                 if (__isNoHistoryPresent == true)
996                 {
997                         GetFooter()->SetItemEnabled(0, false);
998                 }
999                 else
1000                 {
1001                         GetFooter()->SetItemEnabled(0, true);
1002                 }
1003                 if(__pSearchBar != null)
1004                 {
1005                         __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1006                 }
1007                 if (IsFailed(r))
1008                 {
1009                         return;
1010                 }
1011         }
1012         else
1013         {
1014                 // added
1015                 GetFooter()->SetShowState(false);
1016                 //              __pSearchListView->SetEnabled(false);
1017                 r = __pSearchListView->SetShowState(true);
1018                 if (IsFailed(r))
1019                 {
1020                         return;
1021                 }
1022                 __pSearchListView->SetEnabled(false);
1023                 r = __pSearchListView->UpdateList();
1024                 if (IsFailed(r))
1025                 {
1026                         return;
1027                 }
1028                 r = __pGroupedListView->SetShowState(false);
1029                 if (IsFailed(r))
1030                 {
1031                         return;
1032                 }
1033                 if(__pSearchBar != null)
1034                 {
1035                         __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1036                 }
1037         }
1038 }
1039
1040 String
1041 HistoryListForm::GetMonth(int month)
1042 {
1043         String monthValue = L"";
1044         switch (month)
1045         {
1046         case JANUARY:
1047                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JAN"));
1048                 break;
1049         case FEBRUARY:
1050                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_FEB"));
1051                 break;
1052         case MARCH:
1053                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_MAR"));
1054                 break;
1055         case APRIL:
1056                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_APR"));
1057                 break;
1058         case MAY:
1059                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_MAY"));
1060                 break;
1061         case JUNE:
1062                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JUN"));
1063                 break;
1064         case JULY:
1065                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JUL"));
1066                 break;
1067         case AUGUST:
1068                 monthValue.Append(CommonUtil::GetString(L"DS_COM_BODY_AUG"));
1069                 break;
1070         case SEPTEMBER:
1071                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_SEP"));
1072                 break;
1073         case OCTOBER:
1074                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_OCT"));
1075                 break;
1076         case NOVEMBER:
1077                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_NOV"));
1078                 break;
1079         case DECEMBER:
1080                 monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_DEC"));
1081                 break;
1082         default:
1083                 break;
1084         }
1085
1086
1087         return monthValue;
1088 }
1089
1090 void
1091 HistoryListForm::OnKeypadActionPerformed(Control &source, KeypadAction keypadAction)
1092 {
1093         result r = E_FAILURE;
1094         if (__pSearchBar != null)
1095         {
1096                 __pSearchBar->HideKeypad();
1097         }
1098
1099         if (__pSearchBar != null && keypadAction == KEYPAD_ACTION_SEARCH)
1100         {
1101                 __pSearchListView->SetEnabled(true);
1102                 __searchHistory = true;
1103                 __searchText =__pSearchBar->GetText();
1104
1105                 r = __pGroupedListView->SetShowState(false);
1106                 if (IsFailed(r))
1107                 {
1108                         return;
1109                 }
1110                 r = __pSearchListView->SetShowState(true);
1111                 if (IsFailed(r))
1112                 {
1113                         return;
1114                 }
1115                 r= __pSearchListView->UpdateList();
1116                 if (__isNoHistoryPresent == true)
1117                 {
1118                         GetFooter()->SetItemEnabled(0, false);
1119                 }
1120                 else
1121                 {
1122                         GetFooter()->SetItemEnabled(0, true);
1123                 }
1124                 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1125
1126                 if (IsFailed(r))
1127                 {
1128                         return;
1129                 }
1130         }
1131         else
1132         {
1133                 __searchHistory = false;
1134         }
1135         Invalidate(true);
1136 }
1137
1138 void
1139 HistoryListForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1140 {
1141         result r = E_FAILURE;
1142         if (__pGroupedListView != null)
1143         {
1144                 if(__pSearchBar != null &&__pSearchBar->GetShowState())
1145                         r = __pGroupedListView->SetBounds(Rectangle(0,__pSearchBar->GetY() + __pSearchBar->GetHeight()/*72 + 30*/,GetClientAreaBounds().width,GetClientAreaBounds().height - __pSearchBar->GetHeight() - __pSearchBar->GetY()));
1146                 else if(__pSearchBar != null)
1147                         r = __pGroupedListView->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pSearchBar->GetHeight() - __pSearchBar->GetY()));
1148                 if (IsFailed(r))
1149                 {
1150                         return;
1151                 }
1152                 __pGroupedListView->UpdateList();
1153
1154                 if (__pSearchListView != null)
1155                 {
1156                         r = __pSearchListView->SetBounds(Rectangle(0,  0, GetClientAreaBounds().width, __pGroupedListView->GetHeight()));
1157                         if (IsFailed(r))
1158                         {
1159                                 return;
1160                         }
1161
1162                         __pSearchListView->UpdateList();
1163
1164                         if(__pSearchBar != null)
1165                                 __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1166                 }
1167
1168         }
1169
1170         if (__isNoHistoryPresent == true)
1171         {
1172                 GetFooter()->SetItemEnabled(0, false);
1173         }
1174         else
1175         {
1176                 GetFooter()->SetItemEnabled(0, true);
1177         }
1178 }
1179
1180 void
1181 HistoryListForm::OnKeypadWillOpen(Control& source)
1182 {
1183         GetFooter()->SetShowState(false);
1184         __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
1185         __pSearchListView->SetEnabled(false);
1186         __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
1187         Invalidate(true);
1188
1189 }
1190
1191 void
1192 HistoryListForm::OnKeypadOpened(Control& source)
1193 {
1194         __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1195 }
1196
1197 void
1198 HistoryListForm::OnKeypadClosed(Control& source)
1199 {
1200         
1201         GetFooter()->SetShowState(true);
1202         __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
1203         __pSearchListView->Invalidate(false);
1204         __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
1205         __pGroupedListView->SetBounds(0, __pSearchBar->GetY() + __pSearchBar->GetHeight(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
1206         Invalidate(true);
1207 }
1208
1209 void
1210 HistoryListForm::CreateGroupItems()
1211 {
1212         result r = E_FAILURE;
1213         DateTime currentTime;
1214         DateTime dateTime;
1215         GroupItemClass* pGroupItemClass = null;
1216         String titleText;
1217
1218         String weeksAgo2 = L"";
1219         weeksAgo2.Format(25,CommonUtil::GetString(L"IDS_BR_BODY_PD_WEEKS_AGO").GetPointer(),2);
1220
1221         String weeksAgo3 = L"";
1222         weeksAgo3.Format(25,CommonUtil::GetString(L"IDS_BR_BODY_PD_WEEKS_AGO").GetPointer(),3);
1223
1224         if (__pGroupData != null)
1225         {
1226                 __pGroupData->RemoveAll(false);
1227                 delete __pGroupData;
1228                 __pGroupData = null;
1229         }
1230         __pGroupData = new(std::nothrow) ArrayList();
1231         if (__pGroupData == null)
1232         {
1233                 return;
1234         }
1235         r = __pGroupData->Construct();
1236         if (IsFailed(r))
1237         {
1238                 delete __pGroupData;
1239                 __pGroupData = null;
1240                 return;
1241         }
1242         if (__searchHistory == true)
1243         {
1244                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1245                 if (pGroupItemClass == null)
1246                 {
1247                         return;
1248                 }
1249                 titleText = CommonUtil::GetString(L"IDS_BR_BODY_SEARCHED_ITEMS");
1250                 pGroupItemClass->SetTitleText(titleText);
1251                 r = __pGroupData->Add(*pGroupItemClass);
1252                 if (IsFailed(r))
1253                 {
1254                         return;
1255                 }
1256         }
1257         else
1258         {
1259                 Calendar* pGregorianCalendar = null;
1260                 int dayOfWeek = 0;
1261                 int day = 0;
1262                 HistoryPresentationModel::GetCurrentDateTime(currentTime);
1263                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1264                 if (pGroupItemClass == null)
1265                 {
1266                         return;
1267                 }
1268                 titleText = CommonUtil::GetString(L"IDS_COM_BODY_TODAY");
1269                 pGroupItemClass->SetTitleText(titleText);
1270                 pGroupItemClass->SetEndTime(currentTime);
1271                 dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1272                 pGroupItemClass->SetStartTime(dateTime);
1273                 __pGroupData->Add(*pGroupItemClass);
1274
1275
1276                 pGregorianCalendar = Calendar::CreateInstanceN(CALENDAR_GREGORIAN);
1277                 if ( pGregorianCalendar != NULL )
1278                 {
1279                         pGregorianCalendar->SetTimeField(TIME_FIELD_YEAR, currentTime.GetYear());
1280                         pGregorianCalendar->SetTimeField(TIME_FIELD_MONTH, currentTime.GetMonth());
1281                         pGregorianCalendar->SetTimeField(TIME_FIELD_DAY_OF_MONTH, currentTime.GetDay());
1282                         dayOfWeek = pGregorianCalendar->GetTimeField(TIME_FIELD_DAY_OF_WEEK);
1283                         delete pGregorianCalendar;
1284                 }
1285                 switch(dayOfWeek)
1286                 {
1287                 case SUNDAY:
1288                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1289                         if (pGroupItemClass == null)
1290                         {
1291                                 return;
1292                         }
1293                         titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
1294                         pGroupItemClass->SetTitleText(titleText);
1295                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1296                         pGroupItemClass->SetEndTime(dateTime);
1297                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1298                         dateTime.AddDays(currentTime.GetDay() - 6 - 1);
1299                         pGroupItemClass->SetStartTime(dateTime);
1300                         __pGroupData->Add(*pGroupItemClass);
1301                         break;
1302                 case MONDAY:
1303                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1304                         if (pGroupItemClass == null)
1305                         {
1306                                 return;
1307                         }
1308                         titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
1309                         pGroupItemClass->SetTitleText(titleText);
1310                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1311                         pGroupItemClass->SetEndTime(dateTime);
1312                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1313                         dateTime.AddDays(currentTime.GetDay() - 7 - 1);
1314                         pGroupItemClass->SetStartTime(dateTime);
1315                         __pGroupData->Add(*pGroupItemClass);
1316                         break;
1317                 case TUESDAY:
1318                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1319                         if (pGroupItemClass == null)
1320                         {
1321                                 return;
1322                         }
1323                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
1324                         pGroupItemClass->SetTitleText(titleText);
1325                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1326                         pGroupItemClass->SetEndTime(dateTime);
1327                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1328                         dateTime.AddDays(currentTime.GetDay() - 1 - 1);
1329                         pGroupItemClass->SetStartTime(dateTime);
1330                         __pGroupData->Add(*pGroupItemClass);
1331
1332                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1333                         if (pGroupItemClass == null)
1334                         {
1335                                 return;
1336                         }
1337                         titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
1338                         pGroupItemClass->SetTitleText(titleText);
1339                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1340                         dateTime.AddDays(currentTime.GetDay() - 1 - 1);
1341                         pGroupItemClass->SetEndTime(dateTime);
1342                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1343                         dateTime.AddDays(currentTime.GetDay() - 8 - 1);
1344                         pGroupItemClass->SetStartTime(dateTime);
1345                         __pGroupData->Add(*pGroupItemClass);
1346                         break;
1347                 case WEDNESDAY:
1348                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1349                         if (pGroupItemClass == null)
1350                         {
1351                                 return;
1352                         }
1353                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
1354                         pGroupItemClass->SetTitleText(titleText);
1355                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1356                         pGroupItemClass->SetEndTime(dateTime);
1357                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1358                         dateTime.AddDays(currentTime.GetDay() - 1 - 1);
1359                         pGroupItemClass->SetStartTime(dateTime);
1360                         __pGroupData->Add(*pGroupItemClass);
1361
1362                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1363                         if (pGroupItemClass == null)
1364                         {
1365                                 return;
1366                         }
1367                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");
1368                         pGroupItemClass->SetTitleText(titleText);
1369                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1370                         dateTime.AddDays(currentTime.GetDay() - 1 - 1);
1371                         pGroupItemClass->SetEndTime(dateTime);
1372                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1373                         dateTime.AddDays(currentTime.GetDay() - 2 - 1);
1374                         pGroupItemClass->SetStartTime(dateTime);
1375                         __pGroupData->Add(*pGroupItemClass);
1376
1377                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1378                         if (pGroupItemClass == null)
1379                         {
1380                                 return;
1381                         }
1382                         titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
1383                         pGroupItemClass->SetTitleText(titleText);
1384                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1385                         dateTime.AddDays(currentTime.GetDay() - 2 - 1);
1386                         pGroupItemClass->SetEndTime(dateTime);
1387                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1388                         dateTime.AddDays(currentTime.GetDay() - 9 - 1);
1389                         pGroupItemClass->SetStartTime(dateTime);
1390                         __pGroupData->Add(*pGroupItemClass);
1391                         break;
1392                 case THURSDAY:
1393                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1394                         if (pGroupItemClass == null)
1395                         {
1396                                 return;
1397                         }
1398                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
1399                         pGroupItemClass->SetTitleText(titleText);
1400                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1401                         pGroupItemClass->SetEndTime(dateTime);
1402                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1403                         dateTime.AddDays(currentTime.GetDay() - 1 - 1);
1404                         pGroupItemClass->SetStartTime(dateTime);
1405                         __pGroupData->Add(*pGroupItemClass);
1406
1407                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1408                         if (pGroupItemClass == null)
1409                         {
1410                                 return;
1411                         }
1412                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_TUE");
1413                         pGroupItemClass->SetTitleText(titleText);
1414                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1415                         dateTime.AddDays(currentTime.GetDay() - 1 - 1);
1416                         pGroupItemClass->SetEndTime(dateTime);
1417                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1418                         dateTime.AddDays(currentTime.GetDay() - 2 - 1);
1419                         pGroupItemClass->SetStartTime(dateTime);
1420                         __pGroupData->Add(*pGroupItemClass);
1421
1422                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1423                         if (pGroupItemClass == null)
1424                         {
1425                                 return;
1426                         }
1427                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");
1428                         pGroupItemClass->SetTitleText(titleText);
1429                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1430                         dateTime.AddDays(currentTime.GetDay() - 2 - 1);
1431                         pGroupItemClass->SetEndTime(dateTime);
1432                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1433                         dateTime.AddDays(currentTime.GetDay() - 3 - 1);
1434                         pGroupItemClass->SetStartTime(dateTime);
1435                         __pGroupData->Add(*pGroupItemClass);
1436
1437                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1438                         if (pGroupItemClass == null)
1439                         {
1440                                 return;
1441                         }
1442                         titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
1443                         pGroupItemClass->SetTitleText(titleText);
1444                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1445                         dateTime.AddDays(currentTime.GetDay() - 3 - 1);
1446                         pGroupItemClass->SetEndTime(dateTime);
1447                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1448                         dateTime.AddDays(currentTime.GetDay() - 10 - 1);
1449                         pGroupItemClass->SetStartTime(dateTime);
1450                         __pGroupData->Add(*pGroupItemClass);
1451                         break;
1452                 case FRIDAY:
1453                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1454                         if (pGroupItemClass == null)
1455                         {
1456                                 return;
1457                         }
1458                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
1459                         pGroupItemClass->SetTitleText(titleText);
1460                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1461                         pGroupItemClass->SetEndTime(dateTime);
1462                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1463                         dateTime.AddDays(currentTime.GetDay() - 1 - 1);
1464                         pGroupItemClass->SetStartTime(dateTime);
1465                         __pGroupData->Add(*pGroupItemClass);
1466
1467                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1468                         if (pGroupItemClass == null)
1469                         {
1470                                 return;
1471                         }
1472                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_WED");
1473                         pGroupItemClass->SetTitleText(titleText);
1474                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1475                         dateTime.AddDays(currentTime.GetDay() - 1 - 1);
1476                         pGroupItemClass->SetEndTime(dateTime);
1477                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1478                         dateTime.AddDays(currentTime.GetDay() - 2 - 1);
1479                         pGroupItemClass->SetStartTime(dateTime);
1480                         __pGroupData->Add(*pGroupItemClass);
1481
1482                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1483                         if (pGroupItemClass == null)
1484                         {
1485                                 return;
1486                         }
1487                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_TUE");
1488                         pGroupItemClass->SetTitleText(titleText);
1489                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1490                         dateTime.AddDays(currentTime.GetDay() - 2 - 1);
1491                         pGroupItemClass->SetEndTime(dateTime);
1492                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1493                         dateTime.AddDays(currentTime.GetDay() - 3 - 1);
1494                         pGroupItemClass->SetStartTime(dateTime);
1495                         __pGroupData->Add(*pGroupItemClass);
1496
1497                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1498                         if (pGroupItemClass == null)
1499                         {
1500                                 return;
1501                         }
1502                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");
1503                         pGroupItemClass->SetTitleText(titleText);
1504                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1505                         dateTime.AddDays(currentTime.GetDay() - 3 - 1);
1506                         pGroupItemClass->SetEndTime(dateTime);
1507                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1508                         dateTime.AddDays(currentTime.GetDay() - 4 - 1);
1509                         pGroupItemClass->SetStartTime(dateTime);
1510                         __pGroupData->Add(*pGroupItemClass);
1511
1512                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1513                         if (pGroupItemClass == null)
1514                         {
1515                                 return;
1516                         }
1517                         titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
1518                         pGroupItemClass->SetTitleText(titleText);
1519                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1520                         dateTime.AddDays(currentTime.GetDay() - 4 - 1);
1521                         pGroupItemClass->SetEndTime(dateTime);
1522                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1523                         dateTime.AddDays(currentTime.GetDay() - 11 - 1);
1524                         pGroupItemClass->SetStartTime(dateTime);
1525                         __pGroupData->Add(*pGroupItemClass);
1526                         break;
1527                 case SATURDAY:
1528                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1529                         if (pGroupItemClass == null)
1530                         {
1531                                 return;
1532                         }
1533                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
1534                         pGroupItemClass->SetTitleText(titleText);
1535                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
1536                         pGroupItemClass->SetEndTime(dateTime);
1537                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1538                         dateTime.AddDays(currentTime.GetDay() - 1 - 1);
1539                         pGroupItemClass->SetStartTime(dateTime);
1540                         __pGroupData->Add(*pGroupItemClass);
1541
1542                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1543                         if (pGroupItemClass == null)
1544                         {
1545                                 return;
1546                         }
1547                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_THU");
1548                         pGroupItemClass->SetTitleText(titleText);
1549                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1550                         dateTime.AddDays(currentTime.GetDay() - 1 - 1);
1551                         pGroupItemClass->SetEndTime(dateTime);
1552                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1553                         dateTime.AddDays(currentTime.GetDay() - 2 - 1);
1554                         pGroupItemClass->SetStartTime(dateTime);
1555                         __pGroupData->Add(*pGroupItemClass);
1556
1557                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1558                         if (pGroupItemClass == null)
1559                         {
1560                                 return;
1561                         }
1562                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_WED");
1563                         pGroupItemClass->SetTitleText(titleText);
1564                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1565                         dateTime.AddDays(currentTime.GetDay() - 2 - 1);
1566                         pGroupItemClass->SetEndTime(dateTime);
1567                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1568                         dateTime.AddDays(currentTime.GetDay() - 3 - 1);
1569                         pGroupItemClass->SetStartTime(dateTime);
1570                         __pGroupData->Add(*pGroupItemClass);
1571
1572                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1573                         if (pGroupItemClass == null)
1574                         {
1575                                 return;
1576                         }
1577                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_TUE");
1578                         pGroupItemClass->SetTitleText(titleText);
1579                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1580                         dateTime.AddDays(currentTime.GetDay() - 3 - 1);
1581                         pGroupItemClass->SetEndTime(dateTime);
1582                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1583                         dateTime.AddDays(currentTime.GetDay() - 4 - 1);
1584                         pGroupItemClass->SetStartTime(dateTime);
1585                         __pGroupData->Add(*pGroupItemClass);
1586
1587                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1588                         if (pGroupItemClass == null)
1589                         {
1590                                 return;
1591                         }
1592                         titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");
1593                         pGroupItemClass->SetTitleText(titleText);
1594                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1595                         dateTime.AddDays(currentTime.GetDay() - 4 - 1);
1596                         pGroupItemClass->SetEndTime(dateTime);
1597                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1598                         dateTime.AddDays(currentTime.GetDay() - 5 - 1);
1599                         pGroupItemClass->SetStartTime(dateTime);
1600                         __pGroupData->Add(*pGroupItemClass);
1601
1602                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1603                         if (pGroupItemClass == null)
1604                         {
1605                                 return;
1606                         }
1607                         titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");
1608                         pGroupItemClass->SetTitleText(titleText);
1609                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1610                         dateTime.AddDays(currentTime.GetDay() - 5 - 1);
1611                         pGroupItemClass->SetEndTime(dateTime);
1612                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1613                         dateTime.AddDays(currentTime.GetDay() - 12 - 1);
1614                         pGroupItemClass->SetStartTime(dateTime);
1615                         __pGroupData->Add(*pGroupItemClass);
1616                         break;
1617
1618                 default:
1619                         break;
1620                 }
1621                 day = currentTime.GetDay();
1622                 switch(day/7)
1623                 {
1624                 case 2:
1625                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1626                         if (pGroupItemClass == null)
1627                         {
1628                                 return;
1629                         }
1630
1631                         pGroupItemClass->SetTitleText(weeksAgo2);
1632                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1633                         dateTime.AddDays(currentTime.GetDay() - 7 - dayOfWeek + 2 - 1);
1634                         pGroupItemClass->SetEndTime(dateTime);
1635                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1636                         dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1637                         pGroupItemClass->SetStartTime(dateTime);
1638                         __pGroupData->Add(*pGroupItemClass);
1639
1640                         if (pGroupItemClass->GetStartTime().GetDay() > 1 && pGroupItemClass->GetStartTime().GetDay() < 8)
1641                         {
1642                                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1643                                 if (pGroupItemClass == null)
1644                                 {
1645                                         return;
1646                                 }
1647                                 String weeksAgo3 = L"";
1648                                 weeksAgo3.Format(25,CommonUtil::GetString(L"IDS_BR_BODY_PD_WEEKS_AGO").GetPointer(),3);
1649                                 pGroupItemClass->SetTitleText(weeksAgo3);
1650                                 dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1651                                 dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1652                                 pGroupItemClass->SetEndTime(dateTime);
1653                                 dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1654                                 dateTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
1655                                 pGroupItemClass->SetStartTime(dateTime);
1656                                 __pGroupData->Add(*pGroupItemClass);
1657                         }
1658                         break;
1659                 case 3:
1660                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1661                         if (pGroupItemClass == null)
1662                         {
1663                                 return;
1664                         }
1665                         pGroupItemClass->SetTitleText(weeksAgo2);
1666                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1667                         dateTime.AddDays(currentTime.GetDay() - 7 - dayOfWeek + 2 - 1);
1668                         pGroupItemClass->SetEndTime(dateTime);
1669                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1670                         dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1671                         pGroupItemClass->SetStartTime(dateTime);
1672                         __pGroupData->Add(*pGroupItemClass);
1673
1674                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1675                         if (pGroupItemClass == null)
1676                         {
1677                                 return;
1678                         }
1679
1680                         pGroupItemClass->SetTitleText(weeksAgo3);
1681                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1682                         dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1683                         pGroupItemClass->SetEndTime(dateTime);
1684                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1685                         dateTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
1686                         pGroupItemClass->SetStartTime(dateTime);
1687                         __pGroupData->Add(*pGroupItemClass);
1688
1689                         if (pGroupItemClass->GetStartTime().GetDay() > 1 && pGroupItemClass->GetStartTime().GetDay() < 8)
1690                         {
1691                                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1692                                 if (pGroupItemClass == null)
1693                                 {
1694                                         return;
1695                                 }
1696                                 titleText = CommonUtil::GetString(L"IDS_BR_EARLIER_THIS_MONTH");
1697                                 pGroupItemClass->SetTitleText(titleText);
1698                                 dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1699                                 dateTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
1700                                 pGroupItemClass->SetEndTime(dateTime);
1701                                 dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1702                                 //dateTime.AddDays(currentTime.GetDay() - 28 - dayOfWeek + 2 - 1);
1703                                 pGroupItemClass->SetStartTime(dateTime);
1704                                 __pGroupData->Add(*pGroupItemClass);
1705                         }
1706                         break;
1707                 case 4:
1708                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1709                         if (pGroupItemClass == null)
1710                         {
1711                                 return;
1712                         }
1713                         pGroupItemClass->SetTitleText(weeksAgo2);
1714                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1715                         dateTime.AddDays(currentTime.GetDay() - 7 - dayOfWeek + 2 - 1);
1716                         pGroupItemClass->SetEndTime(dateTime);
1717                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1718                         dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1719                         pGroupItemClass->SetStartTime(dateTime);
1720                         __pGroupData->Add(*pGroupItemClass);
1721
1722                         pGroupItemClass = new(std::nothrow) GroupItemClass();
1723                         if (pGroupItemClass == null)
1724                         {
1725                                 return;
1726                         }
1727                         pGroupItemClass->SetTitleText(weeksAgo3);
1728                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1729                         dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
1730                         pGroupItemClass->SetEndTime(dateTime);
1731                         dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1732                         dateTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
1733                         pGroupItemClass->SetStartTime(dateTime);
1734                         __pGroupData->Add(*pGroupItemClass);
1735
1736                         if (pGroupItemClass->GetStartTime().GetDay() > 1 && pGroupItemClass->GetStartTime().GetDay() < 8)
1737                         {
1738                                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1739                                 if (pGroupItemClass == null)
1740                                 {
1741                                         return;
1742                                 }
1743                                 titleText = CommonUtil::GetString(L"IDS_BR_EARLIER_THIS_MONTH");
1744                                 pGroupItemClass->SetTitleText(titleText);
1745                                 dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1746                                 dateTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
1747                                 pGroupItemClass->SetEndTime(dateTime);
1748                                 dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1749                                 //dateTime.AddDays(currentTime.GetDay() - 28 - dayOfWeek + 2 - 1);
1750                                 pGroupItemClass->SetStartTime(dateTime);
1751                                 __pGroupData->Add(*pGroupItemClass);
1752                         }
1753                         break;
1754                 default:
1755                         break;
1756                 }
1757                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1758                 if (pGroupItemClass == null)
1759                 {
1760                         return;
1761                 }
1762                 titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_MONTH");
1763                 pGroupItemClass->SetTitleText(titleText);
1764                 dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
1765                 dateTime.AddDays(-1);
1766                 pGroupItemClass->SetEndTime(dateTime);
1767                 dateTime.SetValue(currentTime.GetYear(), 1, 1);
1768                 dateTime.AddMonths(currentTime.GetMonth() - 1 - 1);
1769                 pGroupItemClass->SetStartTime(dateTime);
1770                 __pGroupData->Add(*pGroupItemClass);
1771
1772                 pGroupItemClass = new(std::nothrow) GroupItemClass();
1773                 if (pGroupItemClass == null)
1774                 {
1775                         return;
1776                 }
1777                 titleText = CommonUtil::GetString(L"IDS_BR_BODY_OLDER");
1778                 pGroupItemClass->SetTitleText(titleText);
1779                 dateTime.SetValue(currentTime.GetYear(),1, 1);
1780                 dateTime.AddMonths(currentTime.GetMonth() - 2);
1781                 dateTime.AddDays(-1);
1782                 pGroupItemClass->SetEndTime(dateTime);
1783                 DateTime dateTime2;
1784                 dateTime2.SetValue(0, 0, 0);
1785                 pGroupItemClass->SetStartTime(dateTime2);
1786                 __pGroupData->Add(*pGroupItemClass);
1787         }
1788 }
1789
1790 GroupItemClass::GroupItemClass()
1791 {
1792         __pData = null;
1793 }
1794
1795 GroupItemClass&
1796 GroupItemClass::operator =(const GroupItemClass& rhs)
1797 {
1798         if (this != &rhs)
1799         {
1800                 __pData = rhs.__pData;
1801         }
1802         return *this;
1803 }
1804
1805 GroupItemClass::GroupItemClass(const GroupItemClass& groupItem)
1806 {
1807         __pData = groupItem.__pData;
1808 }
1809
1810 GroupItemClass::~GroupItemClass()
1811 {
1812         if (__pData)
1813         {
1814                 __pData->RemoveAll(true);
1815                 delete __pData;
1816         }
1817 }
1818
1819 void
1820 GroupItemClass::SetStartTime(DateTime& startTime)
1821 {
1822         __startTime = startTime;
1823 }
1824
1825 void
1826 GroupItemClass::SetEndTime(DateTime& endTime)
1827 {
1828         __endTime = endTime;
1829 }
1830
1831 void
1832 GroupItemClass::SetTitleText(String& titleText)
1833 {
1834         __titleText = titleText;
1835 }
1836
1837 void
1838 GroupItemClass::SetHistoryData(ArrayList* pData)
1839 {
1840         __pData = pData;
1841 }
1842
1843 DateTime
1844 GroupItemClass::GetStartTime(void)
1845 {
1846         return __startTime;
1847 }
1848
1849 DateTime
1850 GroupItemClass::GetEndTime(void)
1851 {
1852         return __endTime;
1853 }
1854
1855 String
1856 GroupItemClass::GetTitleText(void)
1857 {
1858         return __titleText;
1859 }
1860
1861 ArrayList*
1862 GroupItemClass::GetHistoryData(void)
1863 {
1864         return __pData;
1865 }
1866
1867 void
1868 HistoryListForm::OnSettingChanged(Tizen::Base::String& key)
1869 {
1870         if (__pGroupedListView)
1871         {
1872                 __pGroupedListView->UpdateList();
1873         }
1874 }