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