Fixed Nabi Issues and Hardware Key Implementation
[apps/osp/Internet.git] / src / IntHistoryListForm.cpp
index 6a1a22c..5fe41f4 100644 (file)
-//\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Flora License, Version 1.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-//     http://floralicense.org/license/\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an AS IS BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-//!Internet HistoryListForm class\r
-/*@file: HistoryListForm.cpp\r
- *@brief:      This class defines HistoryListForm used define history\r
- *\r
- */\r
-\r
-#include <FApp.h>\r
-#include <FUi.h>\r
-#include "IntBookmarkData.h"\r
-#include "IntBookmarkPresentationModel.h"\r
-#include "IntCommonLib.h"\r
-#include "IntFaviconManager.h"\r
-#include "IntHistoryListForm.h"\r
-#include "IntHistoryPresentationModel.h"\r
-#include "IntMultipleWindowPresentationModel.h"\r
-#include "IntSceneRegister.h"\r
-#include "IntTypes.h"\r
-\r
-using namespace Tizen::App;\r
-using namespace Tizen::Base;\r
-using namespace Tizen::Base::Collection;\r
-using namespace Tizen::Base::Runtime;\r
-using namespace Tizen::Graphics;\r
-using namespace Tizen::Locales;\r
-using namespace Tizen::Ui;\r
-using namespace Tizen::Ui::Controls;\r
-using namespace Tizen::Ui::Scenes;\r
-\r
-static const wchar_t* IDB_TAB_ICON_BOOKMARKS = L"I01_tab_icon_bookmarks.png";\r
-static const wchar_t* IDB_TAB_ICON_HISTORY = L"I01_tab_icon_history.png";\r
-static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";\r
-static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";\r
-\r
-\r
-const int HistoryListForm::IDA_TABBAR_ITEM_1 = 101;\r
-const int HistoryListForm::IDA_TABBAR_ITEM_2 = 102;\r
-const int HistoryListForm::IDA_EDIT_HISTORY_LIST_FORM = 103;\r
-const int HistoryListForm::IDA_FORMAT_ICON = 104;\r
-const int HistoryListForm::IDA_FORMAT_TITLE = 105;\r
-const int HistoryListForm::IDA_FORMAT_URL = 106;\r
-const int HistoryListForm::IDA_FORMAT_BOOKMARK = 107;\r
-\r
-\r
-HistoryListForm::HistoryListForm(void)\r
-{\r
-       __pGroupedListView =null;\r
-       __pSearchListView = null;\r
-       __pSearchBar = null;\r
-       __pGroupData = null;\r
-       __pSearchedData = null ;\r
-       __searchHistory = false;\r
-       __isNoHistoryPresent = true;\r
-       __searchText = L"";\r
-}\r
-\r
-HistoryListForm::~HistoryListForm(void)\r
-{\r
-       if (__pGroupData != null)\r
-       {\r
-               __pGroupData->RemoveAll(true);\r
-               delete __pGroupData;\r
-       }\r
-}\r
-\r
-bool\r
-HistoryListForm::Initialize(void)\r
-{\r
-       Construct(L"IDL_HISTORY_LIST");\r
-\r
-       return true;\r
-}\r
-\r
-result\r
-HistoryListForm::OnInitializing(void)\r
-{\r
-       AppLog("HistoryListForm::OnInitializing");\r
-       result r = E_SUCCESS;\r
-       SceneManager* pSceneManager = null;\r
-       HeaderItem bookmark;\r
-       HeaderItem history;\r
-       Header *pHeader = GetHeader();\r
-       Bitmap *pIconBitmap = null;\r
-       AppResource* pAppResource = UiApp::GetInstance()->GetAppResource();\r
-       const Color brown = Color(32, 32, 32, 0xFF);\r
-\r
-       // Setup back event listener\r
-       SetFormBackEventListener(this);\r
-\r
-       GetHeader()->AddActionEventListener(*this);\r
-       GetFooter()->AddActionEventListener(*this);\r
-\r
-       AddOrientationEventListener(*this);\r
-       pSceneManager = SceneManager::GetInstance();\r
-       if (pSceneManager != null)\r
-       {\r
-               pSceneManager->AddSceneEventListener(IDSCN_HISTORY_LIST, *this);\r
-       }\r
-\r
-       if (pAppResource == null)\r
-       {\r
-               return E_FAILURE;\r
-       }\r
-\r
-       __pGroupedListView = static_cast< GroupedListView* >(GetControl(L"IDC_GROUPEDLISTVIEW1"));\r
-       if (__pGroupedListView == null)\r
-       {\r
-               return E_FAILURE;\r
-       }\r
-\r
-       r = __pGroupedListView->SetItemProvider(*this);\r
-       if (IsFailed(r))\r
-       {\r
-               return r;\r
-       }\r
-\r
-\r
-       __pSearchBar = static_cast< SearchBar* >(GetControl(L"IDC_SEARCHBAR1"));\r
-       if (__pSearchBar == null)\r
-       {\r
-               return E_FAILURE;\r
-       }\r
-       __pSearchListView = new(std::nothrow) GroupedListView();\r
-       if (__pSearchListView == null)\r
-       {\r
-               return E_FAILURE;\r
-       }\r
-       __pGroupedListView->AddGroupedListViewItemEventListener(*this);\r
-       r = __pGroupedListView->SetBounds(Rectangle(0,__pGroupedListView->GetY(),GetClientAreaBounds().width,GetClientAreaBounds().height  - __pSearchBar->GetHeight() - __pSearchBar->GetY()));\r
-       if (IsFailed(r))\r
-       {\r
-               return r;\r
-       }\r
-       r = __pSearchListView->Construct(Rectangle(0,0, GetClientAreaBounds().width, GetClientAreaBounds().height -__pSearchBar->GetHeight() - __pSearchBar->GetY()), GROUPED_LIST_VIEW_STYLE_INDEXED, true, false);\r
-       if (IsFailed(r))\r
-       {\r
-               return r;\r
-       }\r
-       r = __pSearchListView->SetItemProvider(*this);\r
-       if (IsFailed(r))\r
-       {\r
-               return r;\r
-       }\r
-       r = __pSearchListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RESULTS_FOUND"));\r
-\r
-       if (IsFailed(r))\r
-       {\r
-               return r;\r
-       }\r
-\r
-       __pSearchListView->SetTextColorOfEmptyList(Color::GetColor(COLOR_ID_BLACK));\r
-       __pSearchListView->AddGroupedListViewItemEventListener(*this);\r
-       r = __pSearchListView->SetShowState(false);\r
-       if (IsFailed(r))\r
-       {\r
-               return r;\r
-       }\r
-\r
-\r
-       __pSearchBar->AddSearchBarEventListener(*this);\r
-       __pSearchBar->AddKeypadEventListener(*this);\r
-       r = __pSearchBar->SetContent(__pSearchListView);\r
-\r
-       if (pHeader != null)\r
-       {\r
-               pHeader->SetStyle(HEADER_STYLE_TAB);\r
-               bookmark.Construct(IDA_TABBAR_ITEM_1);\r
-               String strbookmark;\r
-               pAppResource->GetString(L"IDS_BR_TAB_BOOKMARKS", strbookmark);\r
-               bookmark.SetText(strbookmark);\r
-               pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_BOOKMARKS);\r
-               bookmark.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);\r
-               bookmark.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);\r
-               pHeader->AddItem(bookmark);\r
-\r
-               if (pIconBitmap)\r
-               {\r
-                       delete pIconBitmap;\r
-               }\r
-\r
-\r
-               history.Construct(IDA_TABBAR_ITEM_2);\r
-               String strhistory;\r
-               pAppResource->GetString(L"IDS_BR_TAB_HISTORY", strhistory);\r
-               history.SetText(strhistory);\r
-               pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_HISTORY);\r
-               history.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);\r
-               history.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);\r
-               pHeader->AddItem(history);\r
-               pHeader->SetItemSelected(1);\r
-\r
-               if (pIconBitmap != NULL)\r
-               {\r
-                       delete pIconBitmap;\r
-               }\r
-       }\r
-\r
-       return r;\r
-}\r
-\r
-result\r
-HistoryListForm::OnTerminating(void)\r
-{\r
-       result r = E_SUCCESS;\r
-\r
-       return r;\r
-}\r
-\r
-void\r
-HistoryListForm::OnActionPerformed(const Control& source, int actionId)\r
-{\r
-       AppLog("HistoryListForm::OnActionPerformed");\r
-       result r = E_FAILURE;\r
-       SceneManager* pSceneManager = SceneManager::GetInstance();\r
-       if (pSceneManager == null)\r
-       {\r
-               return;\r
-       }\r
-       switch (actionId)\r
-       {\r
-       case IDA_EDIT_HISTORY_LIST_FORM:\r
-       {\r
-               AppLog("ID_EDIT_HISTORY_LIST_FORM entered");\r
-               r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_EDIT_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));\r
-               if (IsFailed(r))\r
-               {\r
-                       return;\r
-               }\r
-       }\r
-       break;\r
-       case IDA_TABBAR_ITEM_1:\r
-       {\r
-               result r = GetHeader()->SetItemSelected(1);\r
-               AppLog("SetItemSelected result %s",GetErrorMessage(r));\r
-               GetHeader()->Invalidate(true);\r
-               r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));\r
-               if (IsFailed(r))\r
-               {\r
-                       return;\r
-               }\r
-       }\r
-       break;\r
-       default:\r
-               break;\r
-       }\r
-}\r
-\r
-void\r
-HistoryListForm::OnFormBackRequested(Form& source)\r
-{\r
-       SceneManager* pSceneManager = SceneManager::GetInstance();\r
-       if (pSceneManager == null)\r
-       {\r
-               return;\r
-       }\r
-       result r = pSceneManager->GoBackward(BackwardSceneTransition());\r
-       if(IsFailed(r))\r
-       {\r
-               AppLogDebug("HistoryListForm::OnFormBackRequested GoForward failed %s",GetErrorMessage(r));\r
-       }\r
-}\r
-\r
-GroupItem*\r
-HistoryListForm::CreateGroupItem(int groupIndex, int itemWidth)\r
-{\r
-       result r = E_FAILURE;\r
-       int strMonth = 0;\r
-       String text(L"");\r
-       DateTime endTime;\r
-       DateTime startTime;\r
-       int count = 0;\r
-       GroupItem* pItem = null;\r
-       GroupItemClass* pGroupItemClass = null;\r
-\r
-       String weeksAgo2 = L"";\r
-       weeksAgo2.Format(25,CommonUtil::GetString(L"IDS_BR_BODY_PD_WEEKS_AGO").GetPointer(),2);\r
-\r
-       String weeksAgo3 = L"";\r
-       weeksAgo3.Format(25,CommonUtil::GetString(L"IDS_BR_BODY_PD_WEEKS_AGO").GetPointer(),3);\r
-\r
-       String weeksAgo4 = L"";\r
-       weeksAgo4.Format(25,CommonUtil::GetString(L"IDS_BR_BODY_PD_WEEKS_AGO").GetPointer(),4);\r
-\r
-       pItem = new(std::nothrow) GroupItem();\r
-       if (pItem == null)\r
-       {\r
-               return null;\r
-       }\r
-       pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));\r
-\r
-       if (pGroupItemClass == null || pGroupItemClass->GetHistoryData() == null || pGroupItemClass->GetHistoryData()->GetCount() == 0)\r
-       {\r
-               AppLog("CreateGroupItem :: if history is null");\r
-               r = pItem->Construct(Dimension(itemWidth, 0));\r
-               return pItem;\r
-       }\r
-       else\r
-       {\r
-               r = pItem->Construct(Dimension(itemWidth, 48));\r
-       }\r
-       text = pGroupItemClass->GetTitleText();\r
-\r
-       if (__searchHistory == false)\r
-       {\r
-               String month = L"";\r
-               text.Append(L" (");\r
-               if (pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_COM_BODY_TODAY") || pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY"))\r
-               {\r
-                       int dayOfWeek = 0;\r
-                       Calendar* pGregorianCalendar = Calendar::CreateInstanceN(CALENDAR_GREGORIAN);\r
-                       if ( pGregorianCalendar != NULL)\r
-                       {\r
-                               r = pGregorianCalendar->SetTimeField(TIME_FIELD_YEAR, pGroupItemClass->GetStartTime().GetYear());\r
-                               if (IsFailed(r))\r
-                               {\r
-                                       if( pItem != null)\r
-                                       {\r
-                                               delete pItem;\r
-                                       }\r
-                                       delete pGregorianCalendar;\r
-                                       return null;\r
-                               }\r
-                               r = pGregorianCalendar->SetTimeField(TIME_FIELD_MONTH, pGroupItemClass->GetStartTime().GetMonth());\r
-                               if (IsFailed(r))\r
-                               {\r
-                                       if( pItem != null)\r
-                                       {\r
-                                               delete pItem;\r
-                                       }\r
-                                       delete pGregorianCalendar;\r
-                                       return null;\r
-                               }\r
-                               r = pGregorianCalendar->SetTimeField(TIME_FIELD_DAY_OF_MONTH, pGroupItemClass->GetStartTime().GetDay());\r
-                               if (IsFailed(r))\r
-                               {\r
-                                       if( pItem != null)\r
-                                       {\r
-                                               delete pItem;\r
-                                       }\r
-                                       delete pGregorianCalendar;\r
-                                       return null;\r
-                               }\r
-                               dayOfWeek = pGregorianCalendar->GetTimeField(TIME_FIELD_DAY_OF_WEEK);\r
-\r
-                               delete pGregorianCalendar;\r
-\r
-                       }\r
-                       switch(dayOfWeek)\r
-                       {\r
-                       case SUNDAY:\r
-                               text.Append(CommonUtil::GetString(L"IDS_COM_BODY_SUN"));\r
-                               break;\r
-                       case MONDAY:\r
-                               text.Append(CommonUtil::GetString(L"IDS_COM_BODY_MON"));\r
-                               break;\r
-                       case TUESDAY:\r
-                               text.Append(CommonUtil::GetString(L"IDS_COM_BODY_TUE"));\r
-                               break;\r
-                       case WEDNESDAY:\r
-                               text.Append(CommonUtil::GetString(L"IDS_COM_BODY_WED"));\r
-                               break;\r
-                       case THURSDAY:\r
-                               text.Append(CommonUtil::GetString(L"IDS_COM_BODY_THU"));\r
-                               break;\r
-                       case FRIDAY:\r
-                               text.Append(CommonUtil::GetString(L"IDS_COM_BODY_FRI"));\r
-                               break;\r
-                       case SATURDAY:\r
-                               text.Append(CommonUtil::GetString(L"IDS_COM_BODY_SAT"));\r
-                               break;\r
-                       default:\r
-                               break;\r
-                       }\r
-                       text.Append(L", ");\r
-               }\r
-\r
-               if (pGroupItemClass->GetTitleText() != CommonUtil::GetString(L"IDS_BR_BODY_OLDER"))\r
-               {\r
-                       text.Append(pGroupItemClass->GetStartTime().GetDay());\r
-                       text.Append(L". ");\r
-                       strMonth = pGroupItemClass->GetStartTime().GetMonth();\r
-                       month = GetMonth(strMonth);\r
-                       text.Append(month);\r
-               }\r
-               else\r
-               {\r
-                       text.Append(L"~ ");\r
-               }\r
-\r
-\r
-\r
-               if (pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK") || pGroupItemClass->GetTitleText() == weeksAgo2\r
-                               || 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"))\r
-               {\r
-                       text.Append(L" - ");\r
-                       text.Append(pGroupItemClass->GetEndTime().GetDay());\r
-                       text.Append(L". ");\r
-                       strMonth = pGroupItemClass->GetEndTime().GetMonth();\r
-                       month = GetMonth(strMonth);\r
-                       text.Append(month);\r
-               }\r
-               text.Append(L".)");\r
-       }\r
-\r
-       r = pItem->SetElement(text, null);\r
-       if (IsFailed(r))\r
-       {\r
-               delete pItem;\r
-               AppLogDebug("Failed with %s", GetErrorMessage(r));\r
-               return null;\r
-       }\r
-       r = pItem->SetTextSize(32);\r
-       if (IsFailed(r))\r
-       {\r
-               delete pItem;\r
-               return null;\r
-       }\r
-\r
-       return pItem;\r
-}\r
-\r
-ListItemBase*\r
-HistoryListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)\r
-{\r
-       AppLog("HistoryListForm::CreateItem");\r
-       result r = E_FAILURE;\r
-       History* pHistory = null;\r
-       Bitmap* pBitmap = null;\r
-       GroupItemClass* pGroupItemClass = null;\r
-       CustomItem* pItem = new(std::nothrow) CustomItem();\r
-       int bookmarkBtnWidth = 0;\r
-       Bitmap* pBookmarkBitmap = null;\r
-       String bitmapId;\r
-\r
-       if (pItem == null)\r
-       {\r
-               return null;\r
-       }\r
-       pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));\r
-       if (pGroupItemClass == null)\r
-       {\r
-               delete pItem;\r
-               return null;\r
-       }\r
-       pHistory = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(itemIndex));\r
-       if (pHistory == null)\r
-       {\r
-               delete pItem;\r
-               return null;\r
-       }\r
-       r = pItem->Construct(Dimension(itemWidth, 128), LIST_ANNEX_STYLE_NORMAL);\r
-       if (IsFailed(r))\r
-       {\r
-               delete pItem;\r
-               return null;\r
-       }\r
-\r
-       bitmapId = pHistory->GetFaviconId() ;\r
-\r
-       pBitmap = FaviconManager::GetInstance()->GetFaviconN(bitmapId);\r
-\r
-       if (pBitmap == null)\r
-       {\r
-               pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();\r
-       }\r
-       if (pBitmap != null)\r
-       {\r
-               r = pItem->AddElement(Rectangle(16, 28, 72, 72), IDA_FORMAT_ICON, *pBitmap, null);\r
-               delete pBitmap;\r
-               if (IsFailed(r))\r
-               {\r
-                       delete pItem;\r
-                       AppLogException("CreateItem failed with %s", GetErrorMessage(r));\r
-                       return null;\r
-               }\r
-       }\r
-//     if (pHistory->GetBookmarkId().GetLength()>0)\r
-//     {\r
-//             pBookmarkBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);\r
-//     }\r
-//     else\r
-//     {\r
-//             pBookmarkBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);\r
-//     }\r
-       bookmarkBtnWidth = 64;\r
-\r
-\r
-       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);\r
-       TryCatch(!IsFailed(r), "CreateItem failed with %s",GetErrorMessage(r));\r
-\r
-       if(__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)\r
-               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);\r
-       else\r
-               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);\r
-       TryCatch(!IsFailed(r), "CreateItem failed with %s",GetErrorMessage(r));\r
-//     if ( pBookmarkBitmap != null)\r
-//     {\r
-//             r = pItem->AddElement(Rectangle(GetClientAreaBounds().width - bookmarkBtnWidth - 16, (128 - pBookmarkBitmap->GetHeight())/2, bookmarkBtnWidth, bookmarkBtnWidth), IDA_FORMAT_BOOKMARK, *pBookmarkBitmap);\r
-//             TryCatch(!IsFailed(r), "CreateItem failed with %s",GetErrorMessage(r));\r
-//             delete pBookmarkBitmap;\r
-//     }\r
-       return pItem;\r
-\r
-       CATCH:\r
-       delete pItem;\r
-       delete pBookmarkBitmap;\r
-       return null;\r
-}\r
-\r
-bool\r
-HistoryListForm::DeleteGroupItem(int groupIndex, GroupItem* pItem, int itemWidth)\r
-{\r
-\r
-       //      delete pItem;\r
-       //      pItem = null;\r
-       return false;\r
-}\r
-\r
-bool\r
-HistoryListForm::DeleteItem(int groupIndex, int itemIndex, ListItemBase* pItem, int itemWidth)\r
-{\r
-       AppLog("HistoryListForm::DeleteItem");\r
-       result r = E_FAILURE;\r
-       GroupItemClass* pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));\r
-       if (pGroupItemClass == null)\r
-       {\r
-               return false;\r
-       }\r
-\r
-       //      if (pGroupItemClass->__pData != null)\r
-       //      {\r
-       //              r = pGroupItemClass->__pData->RemoveAt(itemIndex);\r
-       //              if (IsFailed(r))\r
-       //              {\r
-       //                      return false;\r
-       //              }\r
-       //      }\r
-\r
-       delete pItem;\r
-       pItem = null;\r
-       return true;\r
-}\r
-\r
-int\r
-HistoryListForm::GetGroupCount(void)\r
-{\r
-       __isNoHistoryPresent = true;\r
-       CreateGroupItems();\r
-       if (__pGroupData != null)\r
-       {\r
-               if (__searchHistory == false)\r
-               {\r
-                       int count = 0;\r
-                       HistoryPresentationModel::GetInstance()->GetHistoryCount(count);\r
-                       if (count == 0)\r
-                       {\r
-                               return 0;\r
-                       }\r
-                       return __pGroupData->GetCount();\r
-               }\r
-               else\r
-               {\r
-                       int count = 0;\r
-               //      String searchText = __pSearchBar->GetText();\r
-                       result r = HistoryPresentationModel::GetInstance()->GetSearchHistoryCount(count, __searchText);\r
-                       if(count)\r
-                               return 1;\r
-                       else\r
-                               return 0;\r
-               }\r
-       }\r
-       else\r
-       {\r
-               return 0;\r
-       }\r
-}\r
-\r
-int\r
-HistoryListForm::GetItemCount(int groupIndex)\r
-{\r
-       result r = E_FAILURE;\r
-       int count = 0;\r
-       DateTime endTime;\r
-       DateTime startTime;\r
-       String text;\r
-\r
-       GroupItemClass* pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));\r
-       if (pGroupItemClass == null)\r
-       {\r
-               return null;\r
-       }\r
-       if (__searchHistory == false)\r
-       {\r
-               startTime = pGroupItemClass->GetStartTime();\r
-               endTime = pGroupItemClass->GetEndTime();\r
-               r = HistoryPresentationModel::GetInstance()->GetHistoryCountWithTimeRange(startTime,endTime,count);\r
-       }\r
-       else\r
-       {\r
-               //text =  __pSearchBar->GetText();\r
-               r = HistoryPresentationModel::GetInstance()->GetSearchHistoryCount(count,__searchText);\r
-               if(count == 0)\r
-               {\r
-                       return count;\r
-               }\r
-       }\r
-       if (IsFailed(r))\r
-       {\r
-               return 0;\r
-       }\r
-\r
-       ArrayList* pData = new(std::nothrow) ArrayList();\r
-       if (pData == null)\r
-       {\r
-               return 0;\r
-       }\r
-       r = pData->Construct();\r
-\r
-       if (IsFailed(r))\r
-       {\r
-               delete pData;\r
-               return 0;\r
-       }\r
-\r
-       if (__searchHistory == false)\r
-       {\r
-               startTime = pGroupItemClass->GetStartTime();\r
-               endTime = pGroupItemClass->GetEndTime();\r
-               AppLog("Starttime %ls endtime %ls",startTime.ToString().GetPointer(),endTime.ToString().GetPointer());\r
-               r = HistoryPresentationModel::GetInstance()->GetHistoryWithTimeRange(startTime,endTime, 0, count, *pData);\r
-       }\r
-       else\r
-       {\r
-               //text = __pSearchBar->GetText() ;\r
-               r = HistoryPresentationModel::GetInstance()->GetSearchHistory(0, count, *pData,__searchText );\r
-       }\r
-       if (IsFailed(r))\r
-       {\r
-               delete pData;\r
-               return 0;\r
-       }\r
-       pGroupItemClass->SetHistoryData(pData);\r
-\r
-\r
-       if (__isNoHistoryPresent == true && count == 0)\r
-       {\r
-               __isNoHistoryPresent = true;\r
-               GetFooter()->SetItemEnabled(0, false);\r
-       }\r
-       else\r
-       {\r
-               __isNoHistoryPresent = false;\r
-               GetFooter()->SetItemEnabled(0, true);\r
-       }\r
-       //       pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));\r
-       if (pGroupItemClass == null || pGroupItemClass->GetHistoryData() == null)\r
-       {\r
-               delete pData;\r
-               return 0;\r
-       }\r
-       else\r
-       {\r
-               AppLogDebug("HistoryListForm::GetItemCount returning %d for %d title %ls",pGroupItemClass->GetHistoryData()->GetCount(),groupIndex,pGroupItemClass->GetTitleText().GetPointer());\r
-               return pGroupItemClass->GetHistoryData()->GetCount();\r
-       }\r
-}\r
-\r
-void\r
-HistoryListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)\r
-{\r
-\r
-       GetHeader()->SetItemSelected(1);\r
-\r
-       AppLog("HistoryListForm::OnSceneActivatedN called");\r
-       //GetHeader()->Invalidate(true);\r
-       if (__pGroupData == null)\r
-       {\r
-               __pGroupData = new(std::nothrow) ArrayList();\r
-               __pGroupData->Construct();\r
-       }\r
-       if (__pGroupedListView != null)\r
-       {\r
-               __pGroupedListView->UpdateList();\r
-       }\r
-       if (__isNoHistoryPresent == true)\r
-       {\r
-               GetFooter()->SetItemEnabled(0, false);\r
-       }\r
-       else\r
-       {\r
-               GetFooter()->SetItemEnabled(0, true);\r
-       }\r
-\r
-       int count = 0;\r
-       HistoryPresentationModel::GetInstance()->GetHistoryCount(count);\r
-       if (count == 0)\r
-       {\r
-               __pSearchBar->SetShowState(false);\r
-               __pSearchBar->Invalidate(true);\r
-       }\r
-       else\r
-       {\r
-               __pSearchBar->SetShowState(true);\r
-               __pSearchBar->Invalidate(true);\r
-       }\r
-\r
-       //      if (__isNoHistoryPresent == true)\r
-       //      {\r
-       //              //      __pGroupedListView->SetBitmapOfEmptyList(AppResource::GetInstance()->GetBitmapN(L"I01_Nocontents_Bookmarks.png"));\r
-       //              __pGroupedListView->UpdateList();\r
-       //      }\r
-\r
-       result r = GetHeader()->SetItemSelected(2);\r
-       if (IsFailed(r))\r
-       {\r
-               AppLog("HistoryListForm::OnSceneActivatedN header failed %ls", GetErrorMessage(r));\r
-               return;\r
-       }\r
-\r
-       Invalidate(true);\r
-\r
-}\r
-\r
-void\r
-HistoryListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)\r
-{\r
-       AppLog("HistoryListForm::OnSceneDeactivated");\r
-       __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);\r
-}\r
-\r
-void\r
-HistoryListForm::OnGroupedListViewContextItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListContextItemStatus status)\r
-{\r
-\r
-}\r
-\r
-void\r
-HistoryListForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListItemStatus status)\r
-{\r
-       GroupItemClass* pGroupItemClass = null;\r
-       History* pHistory = null;\r
-       AppLog("int groupIndex %d, int itemIndex %d, int elementId %d, ListItemStatus status %d",groupIndex,itemIndex,elementId,status);\r
-       if (elementId == IDA_FORMAT_BOOKMARK)\r
-       {\r
-               String toggledUrl = L"";\r
-               AppLog("BookMarkStatusChanged ID_FORMAT_BOOKMARK");\r
-               pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));\r
-               if (pGroupItemClass == null)\r
-               {\r
-                       return;\r
-               }\r
-               pHistory = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(itemIndex));\r
-               if (pHistory == null)\r
-               {\r
-                       return;\r
-               }\r
-               toggledUrl = pHistory->GetHistoryUrl();\r
-\r
-               AppLog("History's Bookmark ID %ls ToggledUrl %ls",pHistory->GetBookmarkId().GetPointer(),toggledUrl.GetPointer());\r
-               if (pHistory->GetBookmarkId().GetLength() > 0)\r
-               {\r
-                       AppLog("Already added to bookmark so will be removed");\r
-                       String bookmarkId = L"";\r
-                       int id = 0;\r
-\r
-                       bookmarkId = pHistory->GetBookmarkId();\r
-                       Integer::Parse(bookmarkId,id);\r
-                       BookmarkPresentationModel::GetInstance()->DeleteBookmark(id);\r
-                       pHistory->SetBookmarkId(L"");\r
-                       //listView.RefreshList(groupIndex,itemIndex,LIST_REFRESH_TYPE_ITEM_MODIFY);\r
-\r
-                       for(int grindex = 0 ; grindex < __pGroupData->GetCount() ; grindex++)\r
-                       {\r
-                               pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(grindex));\r
-                               if (pGroupItemClass == null)\r
-                               {\r
-                                       continue;\r
-                               }\r
-                               for(int index = 0 ; index < pGroupItemClass->GetHistoryData()->GetCount() ; index++)\r
-                               {\r
-                                       pHistory = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(index));\r
-                                       if (pHistory == null)\r
-                                       {\r
-                                               continue;\r
-                                       }\r
-                                       if (toggledUrl.CompareTo(pHistory->GetHistoryUrl()) == 0)\r
-                                       {\r
-                                               pHistory->SetBookmarkId(L"");\r
-                                               AppLog("Already added to bookmark so will be removed");\r
-                                               String bookmarkId = L"";\r
-                                               int id = 0;\r
-\r
-                                               bookmarkId = pHistory->GetBookmarkId();\r
-                                               Integer::Parse(bookmarkId,id);\r
-                                               BookmarkPresentationModel::GetInstance()->DeleteBookmark(id);\r
-                                               pHistory->SetBookmarkId(L"");\r
-                                               //listView.RefreshList(groupIndex,itemIndex,LIST_REFRESH_TYPE_ITEM_MODIFY);\r
-\r
-                                               for(int grindex = 0 ; grindex < __pGroupData->GetCount() ; grindex++)\r
-                                               {\r
-                                                       pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(grindex));\r
-                                                       if (pGroupItemClass == null)\r
-                                                       {\r
-                                                               continue;\r
-                                                       }\r
-                                                       for(int index = 0 ; index < pGroupItemClass->GetHistoryData()->GetCount() ; index++)\r
-                                                       {\r
-                                                               pHistory = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(index));\r
-                                                               if (pHistory == null)\r
-                                                               {\r
-                                                                       continue;\r
-                                                               }\r
-                                                               if (toggledUrl.CompareTo(pHistory->GetHistoryUrl()) == 0)\r
-                                                               {\r
-                                                                       pHistory->SetBookmarkId(L"");\r
-                                                                       //listView.RefreshList(grindex,index,LIST_REFRESH_TYPE_ITEM_MODIFY);\r
-                                                               }\r
-                                                       }\r
-                                               }\r
-\r
-                                               //listView.RefreshList(grindex,index,LIST_REFRESH_TYPE_ITEM_MODIFY);\r
-                                       }\r
-                               }\r
-                       }\r
-                       listView.UpdateList();\r
-\r
-               }\r
-               else\r
-               {\r
-                       AppLog("Adding history to bookmark");\r
-                       result r = E_FAILURE;\r
-                       BookmarkData pBookmark;\r
-\r
-                       String bookmarkTitle = pHistory->GetHistoryTitle();\r
-\r
-                       pBookmark.SetBookmarkTitle(bookmarkTitle);\r
-                       pBookmark.SetUrl(pHistory->GetHistoryUrl());\r
-                       pBookmark.SetFaviconId(pHistory->GetFaviconId());\r
-\r
-                       r = BookmarkPresentationModel::GetInstance()->SaveBookmark(pBookmark);\r
-                       if (!IsFailed(r))\r
-                       {\r
-                               AppLog("History added to bookmark with ID %ls",pBookmark.GetBookmarkId().GetPointer());\r
-                               pHistory->SetBookmarkId(pBookmark.GetBookmarkId());\r
-                       }\r
-\r
-                       listView.RefreshList(groupIndex,itemIndex,LIST_REFRESH_TYPE_ITEM_MODIFY);\r
-\r
-                       for(int grindex = 0 ; grindex < __pGroupData->GetCount() ; grindex++)\r
-                       {\r
-                               pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(grindex));\r
-                               if (pGroupItemClass == null)\r
-                               {\r
-                                       continue;\r
-                               }\r
-                               for(int index = 0 ; index < pGroupItemClass->GetHistoryData()->GetCount() ; index++)\r
-                               {\r
-                                       pHistory = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(index));\r
-                                       if (pHistory == null)\r
-                                       {\r
-                                               continue;\r
-                                       }\r
-                                       if (toggledUrl.CompareTo(pHistory->GetHistoryUrl()) == 0)\r
-                                       {\r
-                                               pHistory->SetBookmarkId(pBookmark.GetBookmarkId());\r
-                                               //listView.RefreshList(grindex,index,LIST_REFRESH_TYPE_ITEM_MODIFY);\r
-                                       }\r
-                               }\r
-                       }\r
-                       listView.UpdateList();\r
-               }\r
-       }\r
-       else\r
-       {\r
-\r
-               pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));\r
-               if (pGroupItemClass == null)\r
-               {\r
-                       return;\r
-               }\r
-\r
-               History* pHistory1 = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(itemIndex));\r
-               if (pHistory1 == null)\r
-               {\r
-                       return;\r
-               }\r
-               SceneManager* pSceneManager = SceneManager::GetInstance();\r
-               ArrayList *pArgList = null;\r
-               result r = E_SUCCESS;\r
-               pArgList = new(std::nothrow) ArrayList();\r
-               if (pArgList != null)\r
-               {\r
-                       r = pArgList->Construct();\r
-                       if (IsFailed(r))\r
-                       {\r
-                               delete pArgList;\r
-                               return;\r
-                       }\r
-\r
-                       r = pArgList->Add(*MultipleWindowPresentationModel::GetInstance()->GetActiveWindowInfo());\r
-                       r = pArgList->Add(*new(std::nothrow) String(pHistory1->GetHistoryUrl()));\r
-                       if (IsFailed(r))\r
-                       {\r
-                               delete pArgList;\r
-                               return;\r
-                       }\r
-\r
-\r
-               }\r
-\r
-               String scneId = L"";\r
-               MultipleWindowPresentationModel::GetInstance()->GetCurrentSceneId(scneId);\r
-\r
-               if (pSceneManager != null)\r
-               {\r
-                       AppLog("pSceneManager exists");\r
-                       r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(scneId), pArgList);\r
-                       if(pArgList)\r
-                       {\r
-                               pArgList->RemoveAll(false);\r
-                               delete pArgList;\r
-                       }\r
-                       if (IsFailed(r))\r
-                       {\r
-                               return;\r
-                       }\r
-               }\r
-       }\r
-\r
-}\r
-\r
-void\r
-HistoryListForm::OnGroupedListViewItemSwept(GroupedListView& listView, int groupIndex, int itemIndex, SweepDirection direction)\r
-{\r
-\r
-}\r
-\r
-void\r
-HistoryListForm::OnSearchBarModeChanged(SearchBar& source, SearchBarMode mode)\r
-{\r
-       result r = E_FAILURE;\r
-       if (mode == SEARCH_BAR_MODE_NORMAL)\r
-       {\r
-               //              __pSearchBar->SetMode(SEARCH_BAR_MODE_INPUT);\r
-               r = __pSearchListView->SetShowState(false);\r
-               if (IsFailed(r))\r
-               {\r
-                       return;\r
-               }\r
-               r = __pGroupedListView->SetShowState(true);\r
-               if (IsFailed(r))\r
-               {\r
-                       return;\r
-               }\r
-               __pSearchListView->SetEnabled(true);\r
-               Invalidate(true);\r
-               __searchHistory = false;\r
-               r = __pGroupedListView->UpdateList();\r
-               if (__isNoHistoryPresent == true)\r
-               {\r
-                       GetFooter()->SetItemEnabled(0, false);\r
-               }\r
-               else\r
-               {\r
-                       GetFooter()->SetItemEnabled(0, true);\r
-               }\r
-\r
-               if (IsFailed(r))\r
-               {\r
-                       return;\r
-               }\r
-       }\r
-       else\r
-       {\r
-               //              __pSearchListView->SetEnabled(false);\r
-               r = __pSearchListView->SetShowState(true);\r
-               if (IsFailed(r))\r
-               {\r
-                       return;\r
-               }\r
-               __pSearchListView->SetEnabled(false);\r
-               r = __pSearchListView->UpdateList();\r
-               if (IsFailed(r))\r
-               {\r
-                       return;\r
-               }\r
-               r = __pGroupedListView->SetShowState(false);\r
-               if (IsFailed(r))\r
-               {\r
-                       return;\r
-               }\r
-               if(__pSearchBar != null)\r
-               {\r
-                       __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));\r
-               }\r
-       }\r
-}\r
-\r
-String\r
-HistoryListForm::GetMonth(int month)\r
-{\r
-       String monthValue = L"";\r
-       switch (month)\r
-       {\r
-       case JANUARY:\r
-               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JAN"));\r
-               break;\r
-       case FEBRUARY:\r
-               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_FEB"));\r
-               break;\r
-       case MARCH:\r
-               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_MAR"));\r
-               break;\r
-       case APRIL:\r
-               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_APR"));\r
-               break;\r
-       case MAY:\r
-               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_MAY"));\r
-               break;\r
-       case JUNE:\r
-               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JUN"));\r
-               break;\r
-       case JULY:\r
-               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JUL"));\r
-               break;\r
-       case AUGUST:\r
-               monthValue.Append(CommonUtil::GetString(L"DS_COM_BODY_AUG"));\r
-               break;\r
-       case SEPTEMBER:\r
-               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_SEP"));\r
-               break;\r
-       case OCTOBER:\r
-               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_OCT"));\r
-               break;\r
-       case NOVEMBER:\r
-               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_NOV"));\r
-               break;\r
-       case DECEMBER:\r
-               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_DEC"));\r
-               break;\r
-       default:\r
-               break;\r
-       }\r
-\r
-\r
-       return monthValue;\r
-}\r
-\r
-void\r
-HistoryListForm::OnKeypadActionPerformed(Control &source, KeypadAction keypadAction)\r
-{\r
-       result r = E_FAILURE;\r
-       if (__pSearchBar != null)\r
-       {\r
-               __pSearchBar->HideKeypad();\r
-       }\r
-\r
-       if (keypadAction == KEYPAD_ACTION_SEARCH)\r
-       {\r
-               __pSearchListView->SetEnabled(true);\r
-               __searchHistory = true;\r
-               __searchText =__pSearchBar->GetText();\r
-\r
-               r = __pGroupedListView->SetShowState(false);\r
-               if (IsFailed(r))\r
-               {\r
-                       return;\r
-               }\r
-               r = __pSearchListView->SetShowState(true);\r
-               if (IsFailed(r))\r
-               {\r
-                       return;\r
-               }\r
-               r= __pSearchListView->UpdateList();\r
-               if (__isNoHistoryPresent == true)\r
-               {\r
-                       GetFooter()->SetItemEnabled(0, false);\r
-               }\r
-               else\r
-               {\r
-                       GetFooter()->SetItemEnabled(0, true);\r
-               }\r
-\r
-\r
-               if (IsFailed(r))\r
-               {\r
-                       return;\r
-               }\r
-       }\r
-       else\r
-       {\r
-               __searchHistory = false;\r
-       }\r
-       Invalidate(true);\r
-}\r
-\r
-void\r
-HistoryListForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)\r
-{\r
-       result r = E_FAILURE;\r
-       if (__pGroupedListView != null)\r
-       {\r
-               if(__pSearchBar != null &&__pSearchBar->GetShowState())\r
-                       r = __pGroupedListView->SetBounds(Rectangle(0,__pSearchBar->GetY() + __pSearchBar->GetHeight()/*72 + 30*/,GetClientAreaBounds().width,GetClientAreaBounds().height - __pSearchBar->GetHeight() - __pSearchBar->GetY()));\r
-               else if(__pSearchBar != null)\r
-                       r = __pGroupedListView->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pSearchBar->GetHeight() - __pSearchBar->GetY()));\r
-               if (IsFailed(r))\r
-               {\r
-                       return;\r
-               }\r
-               __pGroupedListView->UpdateList();\r
-\r
-               if (__pSearchListView != null)\r
-               {\r
-                       r = __pSearchListView->SetBounds(Rectangle(0,  0, GetClientAreaBounds().width, __pGroupedListView->GetHeight()));\r
-                       if (IsFailed(r))\r
-                       {\r
-                               return;\r
-                       }\r
-\r
-                       __pSearchListView->UpdateList();\r
-\r
-\r
-                       if(__pSearchBar != null)\r
-                               __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));\r
-               }\r
-\r
-       }\r
-\r
-       if (__isNoHistoryPresent == true)\r
-       {\r
-               GetFooter()->SetItemEnabled(0, false);\r
-       }\r
-       else\r
-       {\r
-               GetFooter()->SetItemEnabled(0, true);\r
-       }\r
-}\r
-\r
-void\r
-HistoryListForm::OnKeypadWillOpen(Control& source)\r
-{\r
-       GetFooter()->SetShowState(false);\r
-       __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());\r
-       __pSearchListView->SetEnabled(false);\r
-       __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));\r
-       Invalidate(true);\r
-\r
-}\r
-\r
-void\r
-HistoryListForm::OnKeypadOpened(Control& source)\r
-{\r
-       __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());\r
-}\r
-\r
-void\r
-HistoryListForm::OnKeypadClosed(Control& source)\r
-{\r
-       if ( Clipboard::GetInstance()->IsPopupVisible() == false && __searchHistory == false)\r
-       {\r
-               //              __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);\r
-               __pSearchListView->SetEnabled(true);\r
-\r
-       }\r
-       __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), __pSearchListView->GetHeight() - __pSearchBar->GetHeight());\r
-       __pSearchListView->Invalidate(false);\r
-       GetFooter()->SetShowState(true);\r
-       Invalidate(true);\r
-}\r
-\r
-void\r
-HistoryListForm::CreateGroupItems()\r
-{\r
-       result r = E_FAILURE;\r
-       DateTime currentTime;\r
-       DateTime dateTime;\r
-       GroupItemClass* pGroupItemClass = null;\r
-       String titleText;\r
-\r
-       String weeksAgo2 = L"";\r
-       weeksAgo2.Format(25,CommonUtil::GetString(L"IDS_BR_BODY_PD_WEEKS_AGO").GetPointer(),2);\r
-\r
-       String weeksAgo3 = L"";\r
-       weeksAgo3.Format(25,CommonUtil::GetString(L"IDS_BR_BODY_PD_WEEKS_AGO").GetPointer(),3);\r
-\r
-       if (__pGroupData != null)\r
-       {\r
-               __pGroupData->RemoveAll(true);\r
-               delete __pGroupData;\r
-               __pGroupData = null;\r
-       }\r
-       __pGroupData = new(std::nothrow) ArrayList();\r
-       if (__pGroupData == null)\r
-       {\r
-               return;\r
-       }\r
-       r = __pGroupData->Construct();\r
-       if (IsFailed(r))\r
-       {\r
-               delete __pGroupData;\r
-               __pGroupData = null;\r
-               return;\r
-       }\r
-       if (__searchHistory == true)\r
-       {\r
-               pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-               if (pGroupItemClass == null)\r
-               {\r
-                       return;\r
-               }\r
-               titleText = CommonUtil::GetString(L"IDS_BR_BODY_SEARCHED_ITEMS");\r
-               pGroupItemClass->SetTitleText(titleText);\r
-               r = __pGroupData->Add(*pGroupItemClass);\r
-               if (IsFailed(r))\r
-               {\r
-                       return;\r
-               }\r
-       }\r
-       else\r
-       {\r
-               Calendar* pGregorianCalendar = null;\r
-               int dayOfWeek = 0;\r
-               int day = 0;\r
-               HistoryPresentationModel::GetCurrentDateTime(currentTime);\r
-               pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-               if (pGroupItemClass == null)\r
-               {\r
-                       return;\r
-               }\r
-               titleText = CommonUtil::GetString(L"IDS_COM_BODY_TODAY");\r
-               pGroupItemClass->SetTitleText(titleText);\r
-               pGroupItemClass->SetEndTime(currentTime);\r
-               dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());\r
-               pGroupItemClass->SetStartTime(dateTime);\r
-               __pGroupData->Add(*pGroupItemClass);\r
-\r
-\r
-               pGregorianCalendar = Calendar::CreateInstanceN(CALENDAR_GREGORIAN);\r
-               if ( pGregorianCalendar != NULL )\r
-               {\r
-                       pGregorianCalendar->SetTimeField(TIME_FIELD_YEAR, currentTime.GetYear());\r
-                       pGregorianCalendar->SetTimeField(TIME_FIELD_MONTH, currentTime.GetMonth());\r
-                       pGregorianCalendar->SetTimeField(TIME_FIELD_DAY_OF_MONTH, currentTime.GetDay());\r
-                       dayOfWeek = pGregorianCalendar->GetTimeField(TIME_FIELD_DAY_OF_WEEK);\r
-                       delete pGregorianCalendar;\r
-               }\r
-               switch(dayOfWeek)\r
-               {\r
-               case SUNDAY:\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 6 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-                       break;\r
-               case MONDAY:\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 7 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-                       break;\r
-               case TUESDAY:\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 1 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 1 - 1);\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 8 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-                       break;\r
-               case WEDNESDAY:\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 1 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 1 - 1);\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 2 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 2 - 1);\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 9 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-                       break;\r
-               case THURSDAY:\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 1 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_TUE");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 1 - 1);\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 2 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 2 - 1);\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 3 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 3 - 1);\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 10 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-                       break;\r
-               case FRIDAY:\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 1 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_WED");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 1 - 1);\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 2 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_TUE");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 2 - 1);\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 3 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 3 - 1);\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 4 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 4 - 1);\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 11 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-                       break;\r
-               case SATURDAY:\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 1 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_THU");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 1 - 1);\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 2 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_WED");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 2 - 1);\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 3 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_TUE");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 3 - 1);\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 4 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 4 - 1);\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 5 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_WEEK");\r
-                       pGroupItemClass->SetTitleText(titleText);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 5 - 1);\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 12 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-                       break;\r
-\r
-               default:\r
-                       break;\r
-               }\r
-               day = currentTime.GetDay();\r
-               switch(day/7)\r
-               {\r
-               case 2:\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-\r
-                       pGroupItemClass->SetTitleText(weeksAgo2);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 7 - dayOfWeek + 2 - 1);\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-\r
-                       if (pGroupItemClass->GetStartTime().GetDay() > 1 && pGroupItemClass->GetStartTime().GetDay() < 8)\r
-                       {\r
-                               pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                               if (pGroupItemClass == null)\r
-                               {\r
-                                       return;\r
-                               }\r
-                               String weeksAgo3 = L"";\r
-                               weeksAgo3.Format(25,CommonUtil::GetString(L"IDS_BR_BODY_PD_WEEKS_AGO").GetPointer(),3);\r
-                               pGroupItemClass->SetTitleText(weeksAgo3);\r
-                               dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                               dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);\r
-                               pGroupItemClass->SetEndTime(dateTime);\r
-                               dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                               dateTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);\r
-                               pGroupItemClass->SetStartTime(dateTime);\r
-                               __pGroupData->Add(*pGroupItemClass);\r
-                       }\r
-                       break;\r
-               case 3:\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       pGroupItemClass->SetTitleText(weeksAgo2);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 7 - dayOfWeek + 2 - 1);\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-\r
-                       pGroupItemClass->SetTitleText(weeksAgo3);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-\r
-                       if (pGroupItemClass->GetStartTime().GetDay() > 1 && pGroupItemClass->GetStartTime().GetDay() < 8)\r
-                       {\r
-                               pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                               if (pGroupItemClass == null)\r
-                               {\r
-                                       return;\r
-                               }\r
-                               titleText = CommonUtil::GetString(L"IDS_BR_EARLIER_THIS_MONTH");\r
-                               pGroupItemClass->SetTitleText(titleText);\r
-                               dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                               dateTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);\r
-                               pGroupItemClass->SetEndTime(dateTime);\r
-                               dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                               //dateTime.AddDays(currentTime.GetDay() - 28 - dayOfWeek + 2 - 1);\r
-                               pGroupItemClass->SetStartTime(dateTime);\r
-                               __pGroupData->Add(*pGroupItemClass);\r
-                       }\r
-                       break;\r
-               case 4:\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       pGroupItemClass->SetTitleText(weeksAgo2);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 7 - dayOfWeek + 2 - 1);\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-\r
-                       pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                       if (pGroupItemClass == null)\r
-                       {\r
-                               return;\r
-                       }\r
-                       pGroupItemClass->SetTitleText(weeksAgo3);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);\r
-                       pGroupItemClass->SetEndTime(dateTime);\r
-                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                       dateTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);\r
-                       pGroupItemClass->SetStartTime(dateTime);\r
-                       __pGroupData->Add(*pGroupItemClass);\r
-\r
-                       if (pGroupItemClass->GetStartTime().GetDay() > 1 && pGroupItemClass->GetStartTime().GetDay() < 8)\r
-                       {\r
-                               pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-                               if (pGroupItemClass == null)\r
-                               {\r
-                                       return;\r
-                               }\r
-                               titleText = CommonUtil::GetString(L"IDS_BR_EARLIER_THIS_MONTH");\r
-                               pGroupItemClass->SetTitleText(titleText);\r
-                               dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                               dateTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);\r
-                               pGroupItemClass->SetEndTime(dateTime);\r
-                               dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-                               //dateTime.AddDays(currentTime.GetDay() - 28 - dayOfWeek + 2 - 1);\r
-                               pGroupItemClass->SetStartTime(dateTime);\r
-                               __pGroupData->Add(*pGroupItemClass);\r
-                       }\r
-                       break;\r
-               default:\r
-                       break;\r
-               }\r
-               pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-               if (pGroupItemClass == null)\r
-               {\r
-                       return;\r
-               }\r
-               titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_MONTH");\r
-               pGroupItemClass->SetTitleText(titleText);\r
-               dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);\r
-               dateTime.AddDays(-1);\r
-               pGroupItemClass->SetEndTime(dateTime);\r
-               dateTime.SetValue(currentTime.GetYear(), 1, 1);\r
-               dateTime.AddMonths(currentTime.GetMonth() - 1 - 1);\r
-               pGroupItemClass->SetStartTime(dateTime);\r
-               __pGroupData->Add(*pGroupItemClass);\r
-\r
-               pGroupItemClass = new(std::nothrow) GroupItemClass();\r
-               if (pGroupItemClass == null)\r
-               {\r
-                       return;\r
-               }\r
-               titleText = CommonUtil::GetString(L"IDS_BR_BODY_OLDER");\r
-               pGroupItemClass->SetTitleText(titleText);\r
-               dateTime.SetValue(currentTime.GetYear(),1, 1);\r
-               dateTime.AddMonths(currentTime.GetMonth() - 2);\r
-               dateTime.AddDays(-1);\r
-               pGroupItemClass->SetEndTime(dateTime);\r
-               DateTime dateTime2;\r
-               dateTime2.SetValue(0, 0, 0);\r
-               pGroupItemClass->SetStartTime(dateTime2);\r
-               __pGroupData->Add(*pGroupItemClass);\r
-       }\r
-}\r
-\r
-GroupItemClass::GroupItemClass()\r
-{\r
-       __pData = null;\r
-}\r
-\r
-GroupItemClass&\r
-GroupItemClass::operator =(const GroupItemClass& rhs)\r
-{\r
-       if (this != &rhs)\r
-       {\r
-               __pData = rhs.__pData;\r
-       }\r
-       return *this;\r
-}\r
-\r
-GroupItemClass::GroupItemClass(const GroupItemClass& groupItem)\r
-{\r
-       __pData = groupItem.__pData;\r
-}\r
-\r
-GroupItemClass::~GroupItemClass()\r
-{\r
-       if (__pData)\r
-       {\r
-               __pData->RemoveAll(true);\r
-               delete __pData;\r
-       }\r
-}\r
-\r
-void\r
-GroupItemClass::SetStartTime(DateTime& startTime)\r
-{\r
-       __startTime = startTime;\r
-}\r
-\r
-void\r
-GroupItemClass::SetEndTime(DateTime& endTime)\r
-{\r
-       __endTime = endTime;\r
-}\r
-\r
-void\r
-GroupItemClass::SetTitleText(String& titleText)\r
-{\r
-       __titleText = titleText;\r
-}\r
-\r
-void\r
-GroupItemClass::SetHistoryData(ArrayList* pData)\r
-{\r
-       __pData = pData;\r
-}\r
-\r
-DateTime\r
-GroupItemClass::GetStartTime(void)\r
-{\r
-       return __startTime;\r
-}\r
-\r
-DateTime\r
-GroupItemClass::GetEndTime(void)\r
-{\r
-       return __endTime;\r
-}\r
-\r
-String\r
-GroupItemClass::GetTitleText(void)\r
-{\r
-       return __titleText;\r
-}\r
-\r
-ArrayList*\r
-GroupItemClass::GetHistoryData(void)\r
-{\r
-       return __pData;\r
-}\r
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.1 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//!Internet HistoryListForm class
+/*@file: HistoryListForm.cpp
+ *@brief:      This class defines HistoryListForm used define history
+ *
+ */
+
+#include <FApp.h>
+#include <FUi.h>
+#include "IntBookmarkData.h"
+#include "IntBookmarkPresentationModel.h"
+#include "IntCommonLib.h"
+#include "IntFaviconManager.h"
+#include "IntHistoryListForm.h"
+#include "IntHistoryPresentationModel.h"
+#include "IntMultipleWindowPresentationModel.h"
+#include "IntSceneRegister.h"
+#include "IntTypes.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Graphics;
+using namespace Tizen::Locales;
+using namespace Tizen::Media;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::Ui::Scenes;
+using namespace Tizen::System;
+
+static const wchar_t* IDB_TAB_ICON_BOOKMARKS = L"I01_tab_icon_bookmarks.png";
+static const wchar_t* IDB_TAB_ICON_HISTORY = L"I01_tab_icon_history.png";
+static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
+static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
+
+
+const int HistoryListForm::IDA_TABBAR_ITEM_1 = 101;
+const int HistoryListForm::IDA_TABBAR_ITEM_2 = 102;
+const int HistoryListForm::IDA_EDIT_HISTORY_LIST_FORM = 103;
+const int HistoryListForm::IDA_FORMAT_ICON = 104;
+const int HistoryListForm::IDA_FORMAT_TITLE = 105;
+const int HistoryListForm::IDA_FORMAT_URL = 106;
+const int HistoryListForm::IDA_FORMAT_BOOKMARK = 107;
+
+
+HistoryListForm::HistoryListForm(void)
+{
+       __pBookmarkList = null;
+       __pGroupedListView =null;
+       __pSearchListView = null;
+       __pSearchBar = null;
+       __pGroupData = null;
+       __pSearchedData = null ;
+       __searchHistory = false;
+       __isNoHistoryPresent = true;
+       __searchText = L"";
+       __previousSceneId = L"";
+}
+
+HistoryListForm::~HistoryListForm(void)
+{
+       if (__pGroupData != null)
+       {
+               __pGroupData->RemoveAll(false);
+               delete __pGroupData;
+       }
+       if(__pBookmarkList != null)
+       {
+               __pBookmarkList->RemoveAll(false);
+               delete __pBookmarkList;
+       }
+       if (__pSearchListView)
+       {
+               delete __pSearchListView;
+               __pSearchListView = null;
+       }
+}
+
+bool
+HistoryListForm::Initialize(void)
+{
+       Construct(L"IDL_HISTORY_LIST");
+
+       return true;
+}
+
+result
+HistoryListForm::OnInitializing(void)
+{
+       AppLog("HistoryListForm::OnInitializing");
+       result r = E_SUCCESS;
+       SceneManager* pSceneManager = null;
+       HeaderItem bookmark;
+       HeaderItem history;
+       Header *pHeader = GetHeader();
+       Bitmap *pIconBitmap = null;
+       AppResource* pAppResource = UiApp::GetInstance()->GetAppResource();
+       const Color brown = Color(32, 32, 32, 0xFF);
+//     bool isHwBackButtonExist = false;
+//     Tizen::System::SystemInfo::GetValue(L"http:://tizen.org/feature/input.back.key",isHwBackButtonExist);
+//
+//     SetFormStyle(FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
+       // Setup back event listener
+       SetFormBackEventListener(this);
+
+       GetHeader()->AddActionEventListener(*this);
+       GetFooter()->AddActionEventListener(*this);
+
+//     if(isHwBackButtonExist)
+//     {
+//             GetFooter()->SetBackButtonEnabled(false);
+//     }
+       AddOrientationEventListener(*this);
+       SettingInfo::AddSettingEventListener(*this);
+
+       pSceneManager = SceneManager::GetInstance();
+       if (pSceneManager != null)
+       {
+               pSceneManager->AddSceneEventListener(IDSCN_HISTORY_LIST, *this);
+       }
+
+       __fontSize = CommonUtil::GetFontSize();
+       if (pAppResource == null)
+       {
+               return E_FAILURE;
+       }
+
+       __pGroupedListView = static_cast< GroupedListView* >(GetControl(L"IDC_GROUPEDLISTVIEW1"));
+       if (__pGroupedListView == null)
+       {
+               return E_FAILURE;
+       }
+
+       r = __pGroupedListView->SetItemProvider(*this);
+       if (IsFailed(r))
+       {
+               return r;
+       }
+
+
+       __pSearchBar = static_cast< SearchBar* >(GetControl(L"IDC_SEARCHBAR1"));
+       if (__pSearchBar == null)
+       {
+               return E_FAILURE;
+       }
+       __pSearchListView = new(std::nothrow) GroupedListView();
+       if (__pSearchListView == null)
+       {
+               return E_FAILURE;
+       }
+
+       __pGroupedListView->AddGroupedListViewItemEventListener(*this);
+       r = __pGroupedListView->SetBounds(Rectangle(0,__pGroupedListView->GetY(),GetClientAreaBounds().width,GetClientAreaBounds().height  - __pSearchBar->GetHeight() - __pSearchBar->GetY()));
+       if (IsFailed(r))
+       {
+               return r;
+       }
+       r = __pSearchListView->Construct(Rectangle(0,0, GetClientAreaBounds().width, GetClientAreaBounds().height -__pSearchBar->GetHeight() - __pSearchBar->GetY()), GROUPED_LIST_VIEW_STYLE_INDEXED, true, false);
+       if (IsFailed(r))
+       {
+               return r;
+       }
+       r = __pSearchListView->SetItemProvider(*this);
+       if (IsFailed(r))
+       {
+               return r;
+       }
+       r = __pSearchListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RESULTS_FOUND"));
+
+       if (IsFailed(r))
+       {
+               return r;
+       }
+
+       __pSearchListView->SetBackgroundColor(GetBackgroundColor());
+       __pSearchListView->SetTextColorOfEmptyList(Color::GetColor(COLOR_ID_BLACK));
+       __pSearchListView->AddGroupedListViewItemEventListener(*this);
+       r = __pSearchListView->SetShowState(false);
+       if (IsFailed(r))
+       {
+               return r;
+       }
+
+
+       __pSearchBar->AddSearchBarEventListener(*this);
+       __pSearchBar->AddKeypadEventListener(*this);
+       r = __pSearchBar->SetContent(__pSearchListView);
+
+       if (pHeader != null)
+       {
+               pHeader->SetStyle(HEADER_STYLE_TAB);
+               bookmark.Construct(IDA_TABBAR_ITEM_1);
+               String strbookmark;
+               pAppResource->GetString(L"IDS_BR_TAB_BOOKMARKS", strbookmark);
+               bookmark.SetText(strbookmark);
+               pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_BOOKMARKS);
+               bookmark.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
+               bookmark.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
+               pHeader->AddItem(bookmark);
+
+               if (pIconBitmap)
+               {
+                       delete pIconBitmap;
+               }
+
+
+               history.Construct(IDA_TABBAR_ITEM_2);
+               String strhistory;
+               pAppResource->GetString(L"IDS_BR_TAB_HISTORY", strhistory);
+               history.SetText(strhistory);
+               pIconBitmap = pAppResource->GetBitmapN(IDB_TAB_ICON_HISTORY);
+               history.SetIcon(HEADER_ITEM_STATUS_NORMAL, pIconBitmap);
+               history.SetIcon(HEADER_ITEM_STATUS_PRESSED, pIconBitmap);
+               pHeader->AddItem(history);
+               pHeader->SetItemSelected(1);
+               pHeader->SetTabEditModeEnabled(false);
+
+               if (pIconBitmap != NULL)
+               {
+                       delete pIconBitmap;
+               }
+       }
+
+       __pBookmarkList = new(std::nothrow) Collection::ArrayList();
+       __pBookmarkList->Construct();
+       BookmarkPresentationModel::GetInstance()->GetBookmarkForHistory(0,*__pBookmarkList);
+       return r;
+}
+
+result
+HistoryListForm::OnTerminating(void)
+{
+       result r = E_SUCCESS;
+
+       SettingInfo::RemoveSettingEventListener(*this);
+       return r;
+}
+
+void
+HistoryListForm::OnActionPerformed(const Control& source, int actionId)
+{
+       AppLog("HistoryListForm::OnActionPerformed");
+       result r = E_FAILURE;
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+       if (pSceneManager == null)
+       {
+               return;
+       }
+       switch (actionId)
+       {
+       case IDA_EDIT_HISTORY_LIST_FORM:
+       {
+               AppLog("ID_EDIT_HISTORY_LIST_FORM entered");
+               r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_EDIT_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
+               if (IsFailed(r))
+               {
+                       return;
+               }
+       }
+       break;
+       case IDA_TABBAR_ITEM_1:
+       {
+               result r = GetHeader()->SetItemSelected(1);
+               AppLog("SetItemSelected result %s",GetErrorMessage(r));
+               GetHeader()->Invalidate(true);
+
+               if (pSceneManager != null)
+               {
+                       if(__previousSceneId.CompareTo(IDSCN_BOOKMARK_VIEW) != 0)
+                       {
+                               if(pSceneManager->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_LEFT)) != E_SUCCESS)
+                               {
+                                       AppLogDebug("BookmarkListForm::OnActionPerformed GoForward failed");
+                                       return;
+                               }
+                       }
+                       else
+                       {
+
+                               if(pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT))!= E_SUCCESS)
+                               {
+                                       AppLogDebug("BookmarkListForm::OnActionPerformed GoBackward failed");
+                                       return;
+                               }
+
+                       }
+               }
+//             r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
+               if (IsFailed(r))
+               {
+                       return;
+               }
+       }
+       break;
+       default:
+               break;
+       }
+}
+
+void
+HistoryListForm::OnFormBackRequested(Form& source)
+{
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+       if (pSceneManager == null)
+       {
+               return;
+       }
+       result r = E_FAILURE;
+       if(__previousSceneId.CompareTo(IDSCN_BOOKMARK_VIEW) != 0)
+       {
+                       r = pSceneManager->GoBackward(BackwardSceneTransition());
+       }
+       else
+       {
+               r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
+       }
+       if(IsFailed(r))
+       {
+               AppLogDebug("HistoryListForm::OnFormBackRequested GoForward failed %s",GetErrorMessage(r));
+       }
+}
+
+GroupItem*
+HistoryListForm::CreateGroupItem(int groupIndex, int itemWidth)
+{
+       result r = E_FAILURE;
+       int strMonth = 0;
+       String text(L"");
+       DateTime endTime;
+       DateTime startTime;
+       int count = 0;
+       GroupItem* pItem = null;
+       GroupItemClass* pGroupItemClass = null;
+
+       String weeksAgo2 = L"";
+       weeksAgo2.Format(25,CommonUtil::GetString(L"IDS_EMAIL_BODY_PD_WEEKS_AGO").GetPointer(),2);
+
+       String weeksAgo3 = L"";
+       weeksAgo3.Format(25,CommonUtil::GetString(L"IDS_EMAIL_BODY_PD_WEEKS_AGO").GetPointer(),3);
+
+       String weeksAgo4 = L"";
+       weeksAgo4.Format(25,CommonUtil::GetString(L"IDS_EMAIL_BODY_PD_WEEKS_AGO").GetPointer(),4);
+
+       pItem = new(std::nothrow) GroupItem();
+       if (pItem == null)
+       {
+               return null;
+       }
+       pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
+
+       if (pGroupItemClass == null || pGroupItemClass->GetHistoryData() == null || pGroupItemClass->GetHistoryData()->GetCount() == 0)
+       {
+               AppLog("CreateGroupItem :: if history is null");
+               r = pItem->Construct(Dimension(itemWidth, 0));
+               return pItem;
+       }
+       else
+       {
+               r = pItem->Construct(Dimension(itemWidth, 48));
+       }
+       text = pGroupItemClass->GetTitleText();
+
+       if (__searchHistory == false)
+       {
+               String month = L"";
+               text.Append(L" (");
+               if (pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_COM_BODY_TODAY") || pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY"))
+               {
+                       int dayOfWeek = 0;
+                       Calendar* pGregorianCalendar = Calendar::CreateInstanceN(CALENDAR_GREGORIAN);
+                       if ( pGregorianCalendar != NULL)
+                       {
+                               r = pGregorianCalendar->SetTimeField(TIME_FIELD_YEAR, pGroupItemClass->GetStartTime().GetYear());
+                               if (IsFailed(r))
+                               {
+                                       if( pItem != null)
+                                       {
+                                               delete pItem;
+                                       }
+                                       delete pGregorianCalendar;
+                                       return null;
+                               }
+                               r = pGregorianCalendar->SetTimeField(TIME_FIELD_MONTH, pGroupItemClass->GetStartTime().GetMonth());
+                               if (IsFailed(r))
+                               {
+                                       if( pItem != null)
+                                       {
+                                               delete pItem;
+                                       }
+                                       delete pGregorianCalendar;
+                                       return null;
+                               }
+                               r = pGregorianCalendar->SetTimeField(TIME_FIELD_DAY_OF_MONTH, pGroupItemClass->GetStartTime().GetDay());
+                               if (IsFailed(r))
+                               {
+                                       if( pItem != null)
+                                       {
+                                               delete pItem;
+                                       }
+                                       delete pGregorianCalendar;
+                                       return null;
+                               }
+                               dayOfWeek = pGregorianCalendar->GetTimeField(TIME_FIELD_DAY_OF_WEEK);
+                               if (pGregorianCalendar != NULL)
+                               {
+                                       delete pGregorianCalendar;
+                               }
+
+                       }
+                       switch(dayOfWeek)
+                       {
+                       case SUNDAY:
+                               text.Append(CommonUtil::GetString(L"IDS_COM_BODY_SUN"));
+                               break;
+                       case MONDAY:
+                               text.Append(CommonUtil::GetString(L"IDS_COM_BODY_MON"));
+                               break;
+                       case TUESDAY:
+                               text.Append(CommonUtil::GetString(L"IDS_COM_BODY_TUE"));
+                               break;
+                       case WEDNESDAY:
+                               text.Append(CommonUtil::GetString(L"IDS_COM_BODY_WED"));
+                               break;
+                       case THURSDAY:
+                               text.Append(CommonUtil::GetString(L"IDS_COM_BODY_THU"));
+                               break;
+                       case FRIDAY:
+                               text.Append(CommonUtil::GetString(L"IDS_COM_BODY_FRI"));
+                               break;
+                       case SATURDAY:
+                               text.Append(CommonUtil::GetString(L"IDS_COM_BODY_SAT"));
+                               break;
+                       default:
+                               break;
+                       }
+                       text.Append(L", ");
+               }
+
+               if (pGroupItemClass->GetTitleText() != CommonUtil::GetString(L"IDS_BR_BODY_OLDER"))
+               {
+                       text.Append(pGroupItemClass->GetStartTime().GetDay());
+                       text.Append(L". ");
+                       strMonth = pGroupItemClass->GetStartTime().GetMonth();
+                       month = GetMonth(strMonth);
+                       text.Append(month);
+               }
+               else
+               {
+                       text.Append(L"~ ");
+               }
+
+
+
+               if (pGroupItemClass->GetTitleText() == CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK") || pGroupItemClass->GetTitleText() == weeksAgo2
+                               || 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"))
+               {
+                       text.Append(L" - ");
+                       text.Append(pGroupItemClass->GetEndTime().GetDay());
+                       text.Append(L". ");
+                       strMonth = pGroupItemClass->GetEndTime().GetMonth();
+                       month = GetMonth(strMonth);
+                       text.Append(month);
+               }
+               text.Append(L")");
+       }
+
+       r = pItem->SetElement(text, null);
+       if (IsFailed(r))
+       {
+               delete pItem;
+               AppLogDebug("Failed with %s", GetErrorMessage(r));
+               return null;
+       }
+       r = pItem->SetTextSize(32);
+       if (IsFailed(r))
+       {
+               delete pItem;
+               return null;
+       }
+
+       return pItem;
+}
+
+ListItemBase*
+HistoryListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
+{
+       AppLog("HistoryListForm::CreateItem");
+       result r = E_FAILURE;
+       History* pHistory = null;
+       Bitmap* pBitmap = null;
+       Bitmap* pBookmarkBitmap = null;
+       GroupItemClass* pGroupItemClass = null;
+       CustomItem* pItem = new(std::nothrow) CustomItem();
+       int bookmarkBtnWidth = 0;
+       String bitmapId;
+
+       Image* pImage = null;
+       pImage = new Image();
+       pImage->Construct();
+
+       if(__pGroupData == null)
+       {
+               delete pItem;
+               return null;
+       }
+
+       if (pItem == null)
+       {
+               return null;
+       }
+       pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
+       if (pGroupItemClass == null)
+       {
+               delete pItem;
+               return null;
+       }
+       if (pGroupItemClass->GetHistoryData() == null)
+       {
+               delete pItem;
+               return null;
+       }
+       pHistory = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(itemIndex));
+       if (pHistory == null)
+       {
+               delete pItem;
+               return null;
+       }
+       r = pItem->Construct(Dimension(itemWidth, 128 - 44 + __fontSize), LIST_ANNEX_STYLE_NORMAL);
+       if (IsFailed(r))
+       {
+               delete pItem;
+               return null;
+       }
+
+       ByteBuffer* pFavIconBuffer = null;
+       pFavIconBuffer = pHistory->GetFavIconBuffer();
+
+       AppLog("BookmarkListForm::CreateItem check 0");
+
+       if (pFavIconBuffer != null)
+       {
+               AppLog("BookmarkListForm::CreateItem pFavIconBuffer is not null");
+       }
+       else
+       {
+               AppLog("BookmarkListForm::CreateItem pFavIconBuffer is null");
+       }
+
+       pBitmap = pImage->DecodeN(*pFavIconBuffer, IMG_FORMAT_PNG, BITMAP_PIXEL_FORMAT_ARGB8888);
+
+       AppLog("BookmarkListForm::CreateItem check 1");
+
+       //bitmapId = pHistory->GetFaviconId() ;
+       //pBitmap = pHistory->GetFavIconBitmap();
+
+       if (pBitmap == null)
+       {
+               pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
+       }
+       if (pBitmap != null)
+       {
+               r = pItem->AddElement(Rectangle(16, 28 + (__fontSize - 44)/2,72, 72), IDA_FORMAT_ICON, *pBitmap, null);
+               delete pBitmap;
+               if (IsFailed(r))
+               {
+                       delete pItem;
+                       AppLogException("CreateItem failed with %s", GetErrorMessage(r));
+                       return null;
+               }
+       }
+       bool urlFoundInBookmark = false;
+
+       if(__pBookmarkList != null)
+       {
+               for (int i = 0; i < __pBookmarkList->GetCount();i++)
+               {
+                       BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pBookmarkList->GetAt(i));
+                       if(pBookMark != null && pHistory->GetHistoryUrl().CompareTo(pBookMark->GetUrl()) == 0)
+                       {
+                               urlFoundInBookmark = true;
+                               break;
+                       }
+               }
+       }
+       if (urlFoundInBookmark == true)
+       {
+               pBookmarkBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
+       }
+       else
+       {
+               pBookmarkBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
+       }
+       bookmarkBtnWidth = 64;
+
+
+       r = pItem->AddElement(Rectangle(104, 10, GetClientAreaBounds().width - 108 - 32 - bookmarkBtnWidth - 32, 60 - 44 + __fontSize), IDA_FORMAT_TITLE, pHistory->GetHistoryTitle(), __fontSize,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
+       TryCatch(!IsFailed(r), "CreateItem failed with %s",GetErrorMessage(r));
+
+//     if(__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
+//             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);
+//     else
+               r = pItem->AddElement(Rectangle(104, 70 - 44 +__fontSize, GetClientAreaBounds().width - 108 - 32 - bookmarkBtnWidth - 32, 48), IDA_FORMAT_URL, pHistory->GetHistoryUrl(),32,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,true);
+       TryCatch(!IsFailed(r), "CreateItem failed with %s",GetErrorMessage(r));
+       if ( pBookmarkBitmap != null)
+       {
+               r = pItem->AddElement(Rectangle(GetClientAreaBounds().width - bookmarkBtnWidth - 16, (128 - pBookmarkBitmap->GetHeight())/2 +(__fontSize - 44)/2, bookmarkBtnWidth, bookmarkBtnWidth), IDA_FORMAT_BOOKMARK, *pBookmarkBitmap);
+               TryCatch(!IsFailed(r), "CreateItem failed with %s",GetErrorMessage(r));
+               delete pBookmarkBitmap;
+       }
+       delete pImage;
+       return pItem;
+
+       CATCH:
+       delete pItem;
+       return null;
+}
+
+bool
+HistoryListForm::DeleteGroupItem(int groupIndex, GroupItem* pItem, int itemWidth)
+{
+
+       //      delete pItem;
+       //      pItem = null;
+       return false;
+}
+
+bool
+HistoryListForm::DeleteItem(int groupIndex, int itemIndex, ListItemBase* pItem, int itemWidth)
+{
+       AppLog("HistoryListForm::DeleteItem");
+       result r = E_FAILURE;
+       GroupItemClass* pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
+       if (pGroupItemClass == null)
+       {
+               return false;
+       }
+
+       //      if (pGroupItemClass->__pData != null)
+       //      {
+       //              r = pGroupItemClass->__pData->RemoveAt(itemIndex);
+       //              if (IsFailed(r))
+       //              {
+       //                      return false;
+       //              }
+       //      }
+
+       delete pItem;
+       pItem = null;
+       return true;
+}
+
+int
+HistoryListForm::GetGroupCount(void)
+{
+       __isNoHistoryPresent = true;
+       CreateGroupItems();
+       if (__pGroupData != null)
+       {
+               if (__searchHistory == false)
+               {
+                       int count = 0;
+                       DateTime startTime;
+                       DateTime endTime;
+                       HistoryPresentationModel::GetCurrentDateTime(endTime);;
+
+                       startTime.SetValue(0,0,0);
+
+                       HistoryPresentationModel::GetInstance()->GetHistoryCountWithTimeRange(startTime,endTime,count);
+                       if (count == 0)
+                       {
+                               return 0;
+                       }
+                       return __pGroupData->GetCount();
+               }
+               else
+               {
+                       int count = 0;
+               //      String searchText = __pSearchBar->GetText();
+                       result r = HistoryPresentationModel::GetInstance()->GetSearchHistoryCount(count, __searchText);
+                       if(count)
+                               return 1;
+                       else
+                               return 0;
+               }
+       }
+       else
+       {
+               return 0;
+       }
+}
+
+int
+HistoryListForm::GetItemCount(int groupIndex)
+{
+       result r = E_FAILURE;
+       int count = 0;
+       DateTime endTime;
+       DateTime startTime;
+       String text;
+
+       GroupItemClass* pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
+       if (pGroupItemClass == null)
+       {
+               return null;
+       }
+       if (__searchHistory == false)
+       {
+               startTime = pGroupItemClass->GetStartTime();
+               endTime = pGroupItemClass->GetEndTime();
+               r = HistoryPresentationModel::GetInstance()->GetHistoryCountWithTimeRange(startTime,endTime,count);
+       }
+       else
+       {
+               //text =  __pSearchBar->GetText();
+               r = HistoryPresentationModel::GetInstance()->GetSearchHistoryCount(count,__searchText);
+               if(count == 0)
+               {
+                       return count;
+               }
+       }
+       if (IsFailed(r))
+       {
+               return 0;
+       }
+
+       ArrayList* pData = new(std::nothrow) ArrayList();
+       if (pData == null)
+       {
+               return 0;
+       }
+       r = pData->Construct();
+
+       if (IsFailed(r))
+       {
+               delete pData;
+               return 0;
+       }
+
+       if (__searchHistory == false)
+       {
+               startTime = pGroupItemClass->GetStartTime();
+               endTime = pGroupItemClass->GetEndTime();
+               AppLog("Starttime %ls endtime %ls",startTime.ToString().GetPointer(),endTime.ToString().GetPointer());
+               r = HistoryPresentationModel::GetInstance()->GetHistoryWithTimeRange(startTime,endTime, 0, count, *pData);
+       }
+       else
+       {
+               //text = __pSearchBar->GetText() ;
+               r = HistoryPresentationModel::GetInstance()->GetSearchHistory(0, count, *pData,__searchText );
+       }
+       if (IsFailed(r))
+       {
+               delete pData;
+               return 0;
+       }
+       pGroupItemClass->SetHistoryData(pData);
+
+
+       if (__isNoHistoryPresent == true && count == 0)
+       {
+               __isNoHistoryPresent = true;
+               GetFooter()->SetItemEnabled(0, false);
+       }
+       else
+       {
+               __isNoHistoryPresent = false;
+               GetFooter()->SetItemEnabled(0, true);
+       }
+       //       pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
+       if (pGroupItemClass == null || pGroupItemClass->GetHistoryData() == null)
+       {
+               delete pData;
+               return 0;
+       }
+       else
+       {
+               AppLogDebug("HistoryListForm::GetItemCount returning %d for %d title %ls",pGroupItemClass->GetHistoryData()->GetCount(),groupIndex,pGroupItemClass->GetTitleText().GetPointer());
+               return pGroupItemClass->GetHistoryData()->GetCount();
+       }
+}
+
+void
+HistoryListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
+{
+
+       GetHeader()->SetItemSelected(1);
+//     __previousSceneId = previousSceneId;
+       ArrayListT<String> * pList = dynamic_cast<ArrayListT<String>* >(SceneManager::GetInstance()->GetSceneHistoryN());
+       if(pList != null)
+       {
+               pList->GetAt(pList->GetCount()-1,__previousSceneId);
+       }
+
+       if(__pBookmarkList != null)
+       {
+               __pBookmarkList->RemoveAll(false);
+       }
+
+       BookmarkPresentationModel::GetInstance()->GetBookmarkForHistory(0,*__pBookmarkList);
+
+       AppLog("HistoryListForm::OnSceneActivatedN called");
+       //GetHeader()->Invalidate(true);
+       if (__pGroupData == null)
+       {
+               __pGroupData = new(std::nothrow) ArrayList();
+               __pGroupData->Construct();
+       }
+       if (__pGroupedListView != null)
+       {
+               __pGroupedListView->UpdateList();
+       }
+       if (__isNoHistoryPresent == true)
+       {
+               GetFooter()->SetItemEnabled(0, false);
+       }
+       else
+       {
+               GetFooter()->SetItemEnabled(0, true);
+       }
+
+       int count = 0;
+       HistoryPresentationModel::GetInstance()->GetHistoryCount(count);
+       if (count == 0)
+       {
+               __pSearchBar->SetShowState(false);
+               __pSearchBar->Invalidate(true);
+       }
+       else
+       {
+               __pSearchBar->SetShowState(true);
+               __pSearchBar->Invalidate(true);
+       }
+
+       //      if (__isNoHistoryPresent == true)
+       //      {
+       //              //      __pGroupedListView->SetBitmapOfEmptyList(AppResource::GetInstance()->GetBitmapN(L"I01_Nocontents_Bookmarks.png"));
+       //              __pGroupedListView->UpdateList();
+       //      }
+
+       result r = GetHeader()->SetItemSelected(2);
+       if (IsFailed(r))
+       {
+               AppLog("HistoryListForm::OnSceneActivatedN header failed %ls", GetErrorMessage(r));
+               return;
+       }
+
+
+
+       Invalidate(true);
+
+}
+
+void
+HistoryListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
+{
+       AppLog("HistoryListForm::OnSceneDeactivated");
+       __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
+}
+
+void
+HistoryListForm::OnGroupedListViewContextItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListContextItemStatus status)
+{
+
+}
+
+void
+HistoryListForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListItemStatus status)
+{
+       GroupItemClass* pGroupItemClass = null;
+       History* pHistory = null;
+       AppLog("int groupIndex %d, int itemIndex %d, int elementId %d, ListItemStatus status %d",groupIndex,itemIndex,elementId,status);
+       if (elementId == IDA_FORMAT_BOOKMARK)
+       {
+               String toggledUrl = L"";
+               AppLog("BookMarkStatusChanged ID_FORMAT_BOOKMARK");
+               pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
+               if (pGroupItemClass == null)
+               {
+                       return;
+               }
+               pHistory = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(itemIndex));
+               if (pHistory == null)
+               {
+                       return;
+               }
+               toggledUrl = pHistory->GetHistoryUrl();
+
+               AppLog("History's Bookmark ID %ls ToggledUrl %ls",pHistory->GetBookmarkId().GetPointer(),toggledUrl.GetPointer());
+
+               bool bookmarkFound = false;
+               BookmarkData* pBookMark = null;
+               if(__pBookmarkList != null)
+               {
+                       for (int i = 0; i < __pBookmarkList->GetCount(); i++)
+                       {
+                               pBookMark = dynamic_cast< BookmarkData* >(__pBookmarkList->GetAt(i));
+                               if (pBookMark != null && toggledUrl.CompareTo(pBookMark->GetUrl()) == 0)
+                               {
+                                       bookmarkFound = true;
+                                       break;
+                               }
+                       }
+               }
+               if(bookmarkFound == false)
+               {
+                       // Add the history in bookmark database
+                       result r = E_FAILURE;
+                       BookmarkData bookmark;
+
+                       String bookmarkTitle = pHistory->GetHistoryTitle();
+
+                       bookmark.SetBookmarkTitle(bookmarkTitle);
+                       bookmark.SetUrl(pHistory->GetHistoryUrl());
+                       bookmark.SetFaviconId(pHistory->GetFaviconId());
+                       bookmark.SetFavIconBuffer(*pHistory->GetFavIconBuffer());
+                       //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(pBookmark);
+                       r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(bookmark);
+               }
+               else
+               {
+                       // remove the history from bookmark database
+                       BookmarkPresentationModel::GetInstance()->DeleteBookmark(toggledUrl);
+               }
+
+               if(__pBookmarkList != null)
+               {
+                       __pBookmarkList->RemoveAll(false);
+                       BookmarkPresentationModel::GetInstance()->GetBookmarkForHistory(0,*__pBookmarkList);
+               }
+               listView.RefreshList(groupIndex,itemIndex,LIST_REFRESH_TYPE_ITEM_MODIFY);
+               listView.UpdateList();
+       }
+       else
+       {
+               pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex));
+               if (pGroupItemClass == null)
+               {
+                       return;
+               }
+
+               History* pHistory1 = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(itemIndex));
+               if (pHistory1 == null)
+               {
+                       return;
+               }
+               SceneManager* pSceneManager = SceneManager::GetInstance();
+               ArrayList *pArgList = null;
+               result r = E_SUCCESS;
+               pArgList = new(std::nothrow) ArrayList();
+               if (pArgList != null)
+               {
+                       r = pArgList->Construct();
+                       if (IsFailed(r))
+                       {
+                               delete pArgList;
+                               return;
+                       }
+
+                       r = pArgList->Add(*MultipleWindowPresentationModel::GetInstance()->GetActiveWindowInfo());
+                       r = pArgList->Add(*new(std::nothrow) String(pHistory1->GetHistoryUrl()));
+                       if (IsFailed(r))
+                       {
+                               delete pArgList;
+                               return;
+                       }
+
+
+               }
+
+               String scneId = L"";
+               MultipleWindowPresentationModel::GetInstance()->GetCurrentSceneId(scneId);
+
+               if (pSceneManager != null)
+               {
+                       AppLog("pSceneManager exists");
+                       r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(scneId), pArgList);
+                       if(pArgList)
+                       {
+                               pArgList->RemoveAll(false);
+                               delete pArgList;
+                       }
+                       if (IsFailed(r))
+                       {
+                               return;
+                       }
+               }
+       }
+
+}
+
+void
+HistoryListForm::OnGroupedListViewItemSwept(GroupedListView& listView, int groupIndex, int itemIndex, SweepDirection direction)
+{
+
+}
+
+void
+HistoryListForm::OnSearchBarModeChanged(SearchBar& source, SearchBarMode mode)
+{
+       result r = E_FAILURE;
+       if (mode == SEARCH_BAR_MODE_NORMAL)
+       {
+               if ( Clipboard::GetInstance()->IsPopupVisible() == false && __searchHistory == false)
+               {
+                       __pSearchListView->SetEnabled(true);
+               }
+
+               r = __pSearchListView->SetShowState(false);
+               if (IsFailed(r))
+               {
+                       return;
+               }
+               r = __pGroupedListView->SetShowState(true);
+               if (IsFailed(r))
+               {
+                       return;
+               }
+
+               __pSearchListView->SetEnabled(true);
+               if(__pSearchBar != null)
+                       __pGroupedListView->SetBounds(0, __pSearchBar->GetY() + __pSearchBar->GetHeight(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
+               Invalidate(true);
+               __searchHistory = false;
+               r = __pGroupedListView->UpdateList();
+               if (__isNoHistoryPresent == true)
+               {
+                       GetFooter()->SetItemEnabled(0, false);
+               }
+               else
+               {
+                       GetFooter()->SetItemEnabled(0, true);
+               }
+               if(__pSearchBar != null)
+               {
+                       __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
+               }
+               if (IsFailed(r))
+               {
+                       return;
+               }
+       }
+       else
+       {
+
+               //              __pSearchListView->SetEnabled(false);
+               r = __pSearchListView->SetShowState(true);
+               if (IsFailed(r))
+               {
+                       return;
+               }
+               __pSearchListView->SetEnabled(false);
+               r = __pSearchListView->UpdateList();
+               if (IsFailed(r))
+               {
+                       return;
+               }
+               r = __pGroupedListView->SetShowState(false);
+               if (IsFailed(r))
+               {
+                       return;
+               }
+               if(__pSearchBar != null)
+               {
+                       __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
+               }
+       }
+}
+
+String
+HistoryListForm::GetMonth(int month)
+{
+       String monthValue = L"";
+       switch (month)
+       {
+       case JANUARY:
+               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JAN"));
+               break;
+       case FEBRUARY:
+               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_FEB"));
+               break;
+       case MARCH:
+               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_MAR"));
+               break;
+       case APRIL:
+               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_APR"));
+               break;
+       case MAY:
+               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_MAY"));
+               break;
+       case JUNE:
+               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JUNE"));
+               break;
+       case JULY:
+               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_JUL"));
+               break;
+       case AUGUST:
+               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_AUG"));
+               break;
+       case SEPTEMBER:
+               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_SEP"));
+               break;
+       case OCTOBER:
+               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_OCT"));
+               break;
+       case NOVEMBER:
+               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_NOV"));
+               break;
+       case DECEMBER:
+               monthValue.Append(CommonUtil::GetString(L"IDS_COM_BODY_DEC"));
+               break;
+       default:
+               break;
+       }
+
+
+       return monthValue;
+}
+
+void
+HistoryListForm::OnKeypadActionPerformed(Control &source, KeypadAction keypadAction)
+{
+       result r = E_FAILURE;
+       if (__pSearchBar != null)
+       {
+               __pSearchBar->HideKeypad();
+       }
+
+       if (__pSearchBar != null && keypadAction == KEYPAD_ACTION_SEARCH)
+       {
+               __pSearchListView->SetEnabled(true);
+               __searchHistory = true;
+               __searchText =__pSearchBar->GetText();
+               AppLog("SearchTextHistory %S errormsg %s",__searchText.GetPointer(),GetErrorMessage(GetLastResult()));
+
+               r = __pGroupedListView->SetShowState(false);
+               if (IsFailed(r))
+               {
+                       return;
+               }
+               r = __pSearchListView->SetShowState(true);
+               if (IsFailed(r))
+               {
+                       return;
+               }
+               r= __pSearchListView->UpdateList();
+               if (__isNoHistoryPresent == true)
+               {
+                       GetFooter()->SetItemEnabled(0, false);
+               }
+               else
+               {
+                       GetFooter()->SetItemEnabled(0, true);
+               }
+               __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
+
+               if (IsFailed(r))
+               {
+                       return;
+               }
+       }
+       else
+       {
+               __searchHistory = false;
+       }
+       Invalidate(true);
+}
+
+void
+HistoryListForm::OnKeypadBoundsChanged(Tizen::Ui::Control& source)
+{
+       FloatRectangle clientRect;
+       clientRect = GetClientAreaBoundsF();
+       AppLogDebug("SearchBarForm::OnKeypadBoundsChanged ClientBounds(%f, %f, %f, %f)",clientRect.x, clientRect.y, clientRect.width, clientRect.height);
+       __pSearchBar->SetContentAreaSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
+       __pSearchListView->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
+       __pGroupedListView->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
+//     __pGroupedListView->SetEnabled(false);
+       Invalidate(true);
+}
+
+void
+HistoryListForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
+{
+       result r = E_FAILURE;
+       if (__pGroupedListView != null)
+       {
+               if(__pSearchBar != null &&__pSearchBar->GetShowState())
+                       r = __pGroupedListView->SetBounds(Rectangle(0,__pSearchBar->GetY() + __pSearchBar->GetHeight()/*72 + 30*/,GetClientAreaBounds().width,GetClientAreaBounds().height - __pSearchBar->GetHeight() - __pSearchBar->GetY()));
+               else if(__pSearchBar != null)
+                       r = __pGroupedListView->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pSearchBar->GetHeight() - __pSearchBar->GetY()));
+               if (IsFailed(r))
+               {
+                       return;
+               }
+               __pGroupedListView->UpdateList();
+
+               if (__pSearchListView != null)
+               {
+                       r = __pSearchListView->SetBounds(Rectangle(0,  0, GetClientAreaBounds().width, __pGroupedListView->GetHeight()));
+                       if (IsFailed(r))
+                       {
+                               return;
+                       }
+
+                       __pSearchListView->UpdateList();
+
+                       if(__pSearchBar != null)
+                               __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
+               }
+
+       }
+
+       if (__isNoHistoryPresent == true)
+       {
+               GetFooter()->SetItemEnabled(0, false);
+       }
+       else
+       {
+               GetFooter()->SetItemEnabled(0, true);
+       }
+}
+
+void
+HistoryListForm::OnKeypadWillOpen(Control& source)
+{
+       GetFooter()->SetShowState(false);
+       __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
+       __pSearchListView->SetEnabled(false);
+       __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight()));
+       Invalidate(true);
+
+}
+
+void
+HistoryListForm::OnKeypadOpened(Control& source)
+{
+       // this is added because some time footer is shown when key pad is opened, do not remove
+       GetFooter()->SetShowState(false);
+       GetFooter()->Invalidate(true);
+       __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
+}
+
+void
+HistoryListForm::OnKeypadClosed(Control& source)
+{
+       if(Clipboard::GetInstance()->IsPopupVisible() == true)
+       {
+               return;
+       }
+       GetFooter()->SetShowState(true);
+       __pSearchListView->SetBounds(__pSearchListView->GetX(), __pSearchListView->GetY(), __pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight());
+       __pSearchListView->Invalidate(false);
+       __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), GetClientAreaBounds().height - __pSearchBar->GetHeight()));
+       __pGroupedListView->SetBounds(0, __pSearchBar->GetY() + __pSearchBar->GetHeight(), GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight());
+       Invalidate(true);
+}
+
+void
+HistoryListForm::CreateGroupItems()
+{
+       result r = E_FAILURE;
+       DateTime currentTime;
+       DateTime dateTime;
+       GroupItemClass* pGroupItemClass = null;
+       String titleText;
+
+       String weeksAgo2 = L"";
+       weeksAgo2.Format(25,CommonUtil::GetString(L"IDS_EMAIL_BODY_PD_WEEKS_AGO").GetPointer(),2);
+
+       String weeksAgo3 = L"";
+       weeksAgo3.Format(25,CommonUtil::GetString(L"IDS_EMAIL_BODY_PD_WEEKS_AGO").GetPointer(),3);
+
+       if (__pGroupData != null)
+       {
+               __pGroupData->RemoveAll(false);
+               delete __pGroupData;
+               __pGroupData = null;
+       }
+       __pGroupData = new(std::nothrow) ArrayList();
+       if (__pGroupData == null)
+       {
+               return;
+       }
+       r = __pGroupData->Construct();
+       if (IsFailed(r))
+       {
+               delete __pGroupData;
+               __pGroupData = null;
+               return;
+       }
+       if (__searchHistory == true)
+       {
+               pGroupItemClass = new(std::nothrow) GroupItemClass();
+               if (pGroupItemClass == null)
+               {
+                       return;
+               }
+               titleText = CommonUtil::GetString(L"IDS_BR_BODY_SEARCHED_ITEMS");
+               pGroupItemClass->SetTitleText(titleText);
+               r = __pGroupData->Add(*pGroupItemClass);
+               if (IsFailed(r))
+               {
+                       return;
+               }
+       }
+       else
+       {
+               Calendar* pGregorianCalendar = null;
+               int dayOfWeek = 0;
+               int day = 0;
+               HistoryPresentationModel::GetCurrentDateTime(currentTime);
+               pGroupItemClass = new(std::nothrow) GroupItemClass();
+               if (pGroupItemClass == null)
+               {
+                       return;
+               }
+               titleText = CommonUtil::GetString(L"IDS_COM_BODY_TODAY");
+               pGroupItemClass->SetTitleText(titleText);
+               pGroupItemClass->SetEndTime(currentTime);
+               dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
+               pGroupItemClass->SetStartTime(dateTime);
+               __pGroupData->Add(*pGroupItemClass);
+
+
+               pGregorianCalendar = Calendar::CreateInstanceN(CALENDAR_GREGORIAN);
+               if ( pGregorianCalendar != NULL )
+               {
+                       pGregorianCalendar->SetTimeField(TIME_FIELD_YEAR, currentTime.GetYear());
+                       pGregorianCalendar->SetTimeField(TIME_FIELD_MONTH, currentTime.GetMonth());
+                       pGregorianCalendar->SetTimeField(TIME_FIELD_DAY_OF_MONTH, currentTime.GetDay());
+                       dayOfWeek = pGregorianCalendar->GetTimeField(TIME_FIELD_DAY_OF_WEEK);
+                       delete pGregorianCalendar;
+               }
+               switch(dayOfWeek)
+               {
+               case SUNDAY:
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 6 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+                       break;
+               case MONDAY:
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 7 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+                       break;
+               case TUESDAY:
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 1 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 1 - 1);
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 8 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+                       break;
+               case WEDNESDAY:
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 1 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 1 - 1);
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 2 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 2 - 1);
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 9 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+                       break;
+               case THURSDAY:
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 1 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_TUE");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 1 - 1);
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 2 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 2 - 1);
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 3 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 3 - 1);
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 10 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+                       break;
+               case FRIDAY:
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 1 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_WED");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 1 - 1);
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 2 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_TUE");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 2 - 1);
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 3 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 3 - 1);
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 4 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 4 - 1);
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 11 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+                       break;
+               case SATURDAY:
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_YESTERDAY");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), currentTime.GetDay());
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 1 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_THU");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 1 - 1);
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 2 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_WED");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 2 - 1);
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 3 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_TUE");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 3 - 1);
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 4 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_COM_BODY_MON");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 4 - 1);
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 5 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       titleText = CommonUtil::GetString(L"IDS_BR_BODY_LAST_WEEK");
+                       pGroupItemClass->SetTitleText(titleText);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 5 - 1);
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 12 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+                       break;
+
+               default:
+                       break;
+               }
+               day = currentTime.GetDay();
+               switch(day/7)
+               {
+               case 2:
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+
+                       pGroupItemClass->SetTitleText(weeksAgo2);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 7 - dayOfWeek + 2 - 1);
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+
+                       if (pGroupItemClass->GetStartTime().GetDay() > 1 && pGroupItemClass->GetStartTime().GetDay() < 8)
+                       {
+                               pGroupItemClass = new(std::nothrow) GroupItemClass();
+                               if (pGroupItemClass == null)
+                               {
+                                       return;
+                               }
+                               String weeksAgo3 = L"";
+                               weeksAgo3.Format(25,CommonUtil::GetString(L"IDS_EMAIL_BODY_PD_WEEKS_AGO").GetPointer(),3);
+                               pGroupItemClass->SetTitleText(weeksAgo3);
+                               dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                               dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
+                               pGroupItemClass->SetEndTime(dateTime);
+                               dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                               dateTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
+                               pGroupItemClass->SetStartTime(dateTime);
+                               __pGroupData->Add(*pGroupItemClass);
+                       }
+                       break;
+               case 3:
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       pGroupItemClass->SetTitleText(weeksAgo2);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 7 - dayOfWeek + 2 - 1);
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+
+                       pGroupItemClass->SetTitleText(weeksAgo3);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+
+                       if (pGroupItemClass->GetStartTime().GetDay() > 1 && pGroupItemClass->GetStartTime().GetDay() < 8)
+                       {
+                               pGroupItemClass = new(std::nothrow) GroupItemClass();
+                               if (pGroupItemClass == null)
+                               {
+                                       return;
+                               }
+                               titleText = CommonUtil::GetString(L"IDS_BR_EARLIER_THIS_MONTH");
+                               pGroupItemClass->SetTitleText(titleText);
+                               dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                               dateTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
+                               pGroupItemClass->SetEndTime(dateTime);
+                               dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                               //dateTime.AddDays(currentTime.GetDay() - 28 - dayOfWeek + 2 - 1);
+                               pGroupItemClass->SetStartTime(dateTime);
+                               __pGroupData->Add(*pGroupItemClass);
+                       }
+                       break;
+               case 4:
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       pGroupItemClass->SetTitleText(weeksAgo2);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 7 - dayOfWeek + 2 - 1);
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+
+                       pGroupItemClass = new(std::nothrow) GroupItemClass();
+                       if (pGroupItemClass == null)
+                       {
+                               return;
+                       }
+                       pGroupItemClass->SetTitleText(weeksAgo3);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 14 - dayOfWeek + 2 - 1);
+                       pGroupItemClass->SetEndTime(dateTime);
+                       dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                       dateTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
+                       pGroupItemClass->SetStartTime(dateTime);
+                       __pGroupData->Add(*pGroupItemClass);
+
+                       if (pGroupItemClass->GetStartTime().GetDay() > 1 && pGroupItemClass->GetStartTime().GetDay() < 8)
+                       {
+                               pGroupItemClass = new(std::nothrow) GroupItemClass();
+                               if (pGroupItemClass == null)
+                               {
+                                       return;
+                               }
+                               titleText = CommonUtil::GetString(L"IDS_BR_EARLIER_THIS_MONTH");
+                               pGroupItemClass->SetTitleText(titleText);
+                               dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                               dateTime.AddDays(currentTime.GetDay() - 21 - dayOfWeek + 2 - 1);
+                               pGroupItemClass->SetEndTime(dateTime);
+                               dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+                               //dateTime.AddDays(currentTime.GetDay() - 28 - dayOfWeek + 2 - 1);
+                               pGroupItemClass->SetStartTime(dateTime);
+                               __pGroupData->Add(*pGroupItemClass);
+                       }
+                       break;
+               default:
+                       break;
+               }
+               pGroupItemClass = new(std::nothrow) GroupItemClass();
+               if (pGroupItemClass == null)
+               {
+                       return;
+               }
+               titleText = CommonUtil::GetString(L"IDS_EMAIL_BODY_LAST_MONTH");
+               pGroupItemClass->SetTitleText(titleText);
+               dateTime.SetValue(currentTime.GetYear(),currentTime.GetMonth(), 1);
+               dateTime.AddDays(-1);
+               pGroupItemClass->SetEndTime(dateTime);
+               dateTime.SetValue(currentTime.GetYear(), 1, 1);
+               dateTime.AddMonths(currentTime.GetMonth() - 1 - 1);
+               pGroupItemClass->SetStartTime(dateTime);
+               __pGroupData->Add(*pGroupItemClass);
+
+               pGroupItemClass = new(std::nothrow) GroupItemClass();
+               if (pGroupItemClass == null)
+               {
+                       return;
+               }
+               titleText = CommonUtil::GetString(L"IDS_BR_BODY_OLDER");
+               pGroupItemClass->SetTitleText(titleText);
+               dateTime.SetValue(currentTime.GetYear(),1, 1);
+               dateTime.AddMonths(currentTime.GetMonth() - 2);
+               dateTime.AddDays(-1);
+               pGroupItemClass->SetEndTime(dateTime);
+               DateTime dateTime2;
+               dateTime2.SetValue(0, 0, 0);
+               pGroupItemClass->SetStartTime(dateTime2);
+               __pGroupData->Add(*pGroupItemClass);
+       }
+}
+
+GroupItemClass::GroupItemClass()
+{
+       __pData = null;
+}
+
+GroupItemClass&
+GroupItemClass::operator =(const GroupItemClass& rhs)
+{
+       if (this != &rhs)
+       {
+               __pData = rhs.__pData;
+       }
+       return *this;
+}
+
+GroupItemClass::GroupItemClass(const GroupItemClass& groupItem)
+{
+       __pData = groupItem.__pData;
+}
+
+GroupItemClass::~GroupItemClass()
+{
+       if (__pData)
+       {
+               __pData->RemoveAll(true);
+               delete __pData;
+       }
+}
+
+void
+GroupItemClass::SetStartTime(DateTime& startTime)
+{
+       __startTime = startTime;
+}
+
+void
+GroupItemClass::SetEndTime(DateTime& endTime)
+{
+       __endTime = endTime;
+}
+
+void
+GroupItemClass::SetTitleText(String& titleText)
+{
+       __titleText = titleText;
+}
+
+void
+GroupItemClass::SetHistoryData(ArrayList* pData)
+{
+       __pData = pData;
+}
+
+DateTime
+GroupItemClass::GetStartTime(void)
+{
+       return __startTime;
+}
+
+DateTime
+GroupItemClass::GetEndTime(void)
+{
+       return __endTime;
+}
+
+String
+GroupItemClass::GetTitleText(void)
+{
+       return __titleText;
+}
+
+ArrayList*
+GroupItemClass::GetHistoryData(void)
+{
+       return __pData;
+}
+
+void
+HistoryListForm::OnSettingChanged(Tizen::Base::String& key)
+{
+       if (__pGroupedListView)
+       {
+               __pGroupedListView->UpdateList();
+       }
+}