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