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