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