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