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