}
-HistoryItemVector& HistoryService::getMostVisitedHistoryItems()
+std::shared_ptr<HistoryItemVector> HistoryService::getMostVisitedHistoryItems()
{
- history_list.clear();
+ std::shared_ptr<HistoryItemVector> ret_history_list(new HistoryItemVector);
int *ids=nullptr;
int count=-1;
memcpy(hi->imageData, (void*)history_info.thumbnail, history_info.thumbnail_length);
history->setThumbnail(hi);
- history_list.push_back(history);
+ ret_history_list->push_back(history);
}
free(ids);
- return history_list;
+ return ret_history_list;
}
void HistoryService::addHistoryItem(std::shared_ptr<HistoryItem> his,std::shared_ptr<tizen_browser::tools::BrowserImage> thumbnail){
historyDeleted(url);
}
-
-HistoryItemVector& HistoryService::getHistoryItems(int historyDepthInDays, int maxItems)
+std::shared_ptr<HistoryItem> HistoryService::getHistoryItem(int * ids, int idNumber)
{
- history_list.clear();
+ bp_history_offset offset = (BP_HISTORY_O_URL | BP_HISTORY_O_TITLE | BP_HISTORY_O_FAVICON | BP_HISTORY_O_DATE_CREATED);
+ bp_history_info_fmt history_info;
+ bp_history_adaptor_get_info(ids[idNumber], offset, &history_info);
+
+ int date;
+ bp_history_adaptor_get_date_created(ids[idNumber], &date);
+
+ struct tm *item_time_info;
+ time_t item_time = (time_t) date;
+ item_time_info = localtime(&item_time);
+
+ int m_year = item_time_info->tm_year;
+ int m_month = item_time_info->tm_mon + 1;
+ int m_day = item_time_info->tm_yday;
+ int m_month_day = item_time_info->tm_mday;
+ int m_date = date;
+ int min = item_time_info->tm_min;
+ int hour = item_time_info->tm_hour;
+ int sec = item_time_info->tm_sec;
+
+ m_year = 2000 + m_year % 100;
+
+ std::shared_ptr<HistoryItem> history = std::make_shared <HistoryItem> (std::string(history_info.url));
+ boost::gregorian::date d(m_year, m_month, m_month_day);
+ boost::posix_time::ptime t(d, boost::posix_time::time_duration(hour, min, sec));
+ history->setLastVisit(t);
+ history->setUrl(std::string(history_info.url ? history_info.url : ""));
+ history->setTitle(std::string(history_info.title ? history_info.title : ""));
+
+ //thumbail
+ std::shared_ptr<tizen_browser::tools::BrowserImage> hi = std::make_shared<tizen_browser::tools::BrowserImage>();
+ hi->imageType = tizen_browser::tools::BrowserImage::ImageType::ImageTypePNG;
+ hi->width = history_info.thumbnail_width;
+ hi->height = history_info.thumbnail_height;
+ hi->dataSize = history_info.thumbnail_length;
+ hi->imageData = (void*) malloc(history_info.thumbnail_length);
+ memcpy(hi->imageData, (void*) history_info.thumbnail, history_info.thumbnail_length);
+ history->setThumbnail(hi);
+
+ return history;
+}
+std::shared_ptr<HistoryItem> HistoryService::getCurrentTab()
+{
int *ids=nullptr;
- int count=-1;
+ int count = -1;
bp_history_rows_cond_fmt conds;
conds.limit = 20; //no of rows to get negative means no limitation
conds.offset = -1; //the first row's index
- conds.order_offset =BP_HISTORY_O_DATE_CREATED; // property to sort
+ conds.order_offset = BP_HISTORY_O_DATE_VISITED; // property to sort
conds.ordering = 1; //way of ordering 0 asc 1 desc
conds.period_offset = BP_HISTORY_O_DATE_CREATED;
conds.period_type = BP_HISTORY_DATE_TODAY;
- int ret = bp_history_adaptor_get_cond_ids_p(&ids ,&count, &conds, 0, nullptr, 0);
+ int ret = bp_history_adaptor_get_cond_ids_p(&ids , &count, &conds, 0, nullptr, 0);
if (ret<0){
BROWSER_LOGD("Error! Could not get ids!");
}
- bp_history_offset offset = (BP_HISTORY_O_URL | BP_HISTORY_O_TITLE | BP_HISTORY_O_FAVICON | BP_HISTORY_O_DATE_CREATED);
-
- for(int i = 0; i< count; i++){
- bp_history_info_fmt history_info;
- bp_history_adaptor_get_info(ids[i],offset,&history_info);
-
- int date;
- bp_history_adaptor_get_date_created(ids[i], &date);
-
- struct tm *item_time_info;
- time_t item_time = (time_t)date;
- item_time_info = localtime(&item_time);
-
- int m_year = item_time_info->tm_year;
- int m_month = item_time_info->tm_mon + 1;
- int m_day = item_time_info->tm_yday;
- int m_month_day = item_time_info->tm_mday;
- int m_date = date;
- int min = item_time_info->tm_min;
- int hour= item_time_info->tm_hour;
- int sec = item_time_info->tm_sec;
+ return getHistoryItem(ids);
+}
- m_year = 2000 + m_year % 100;
+std::shared_ptr<HistoryItemVector> HistoryService::getHistoryItems(bp_history_date_defs period, int maxItems)
+{
+ std::shared_ptr<HistoryItemVector> ret_history_list(new HistoryItemVector);
- std::shared_ptr<HistoryItem> history = std::make_shared<HistoryItem>(std::string(history_info.url));
- boost::gregorian::date d(m_year,m_month,m_month_day);
- boost::posix_time::ptime t(d,boost::posix_time::time_duration(hour,min,sec));
- history->setLastVisit(t);
- history->setUrl(std::string(history_info.url ? history_info.url : ""));
- history->setTitle(std::string(history_info.title ? history_info.title : ""));
+ int *ids=nullptr;
+ int count=-1;
+ bp_history_rows_cond_fmt conds;
+ conds.limit = 20; //no of rows to get negative means no limitation
+ conds.offset = -1; //the first row's index
+ conds.order_offset = BP_HISTORY_O_DATE_VISITED; // property to sort
+ conds.ordering = 1; //way of ordering 0 asc 1 desc
+ conds.period_offset = BP_HISTORY_O_DATE_CREATED;
+ conds.period_type = period;
- //thumbail
- std::shared_ptr<tizen_browser::tools::BrowserImage> hi = std::make_shared<tizen_browser::tools::BrowserImage>();
- hi->imageType = tizen_browser::tools::BrowserImage::ImageType::ImageTypePNG;
- hi->width = history_info.thumbnail_width;
- hi->height = history_info.thumbnail_height;
- hi->dataSize = history_info.thumbnail_length;
- hi->imageData = (void*)malloc(history_info.thumbnail_length);
- memcpy(hi->imageData, (void*)history_info.thumbnail, history_info.thumbnail_length);
- history->setThumbnail(hi);
+ int ret = bp_history_adaptor_get_cond_ids_p(&ids ,&count, &conds, 0, nullptr, 0);
+ if (ret<0) {
+ BROWSER_LOGD("Error! Could not get ids!");
+ }
- history_list.push_back(history);
+ for(int i = 0; i< count; i++) {
+ ret_history_list->push_back(getHistoryItem(ids, i));
}
free(ids);
- return history_list;
+ return ret_history_list;
}
int HistoryService::getHistoryVisitCounter(const std::string & url)
/**
* @throws HistoryException on error
*/
- HistoryItemVector & getHistoryItems(int historyDepthInDays = 7, int maxItems = 50);
- HistoryItemVector & getMostVisitedHistoryItems();
+ std::shared_ptr<HistoryItemVector> getHistoryItems(bp_history_date_defs period = BP_HISTORY_DATE_TODAY, int maxItems = 50);
+ std::shared_ptr<HistoryItem> getCurrentTab();
+ std::shared_ptr<HistoryItemVector> getMostVisitedHistoryItems();
/**
* @throws HistoryException on error
*/
void initDatabaseBookmark(const std::string & db_str);
+ std::shared_ptr<HistoryItem> getHistoryItem(int* ids, int idNumber = 0);
std::shared_ptr<tizen_browser::services::StorageService> getStorageManager();
};
BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
}
-void HistoryUI::addHistoryItem(std::shared_ptr<tizen_browser::services::HistoryItem> hi)
+void HistoryUI::addHistoryItem(std::shared_ptr<services::HistoryItem> hi)
{
BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
HistoryItemData *itemData = new HistoryItemData();
setEmptyGengrid(false);
}
-void HistoryUI::addHistoryItems(std::vector<std::shared_ptr<tizen_browser::services::HistoryItem> > items)
+void HistoryUI::addHistoryItems(std::shared_ptr<services::HistoryItemVector> items)
{
BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
_history_item_data.clear();
- for (auto it = items.begin(); it != items.end(); ++it)
+ for (auto it = items->begin(); it != items->end(); ++it)
addHistoryItem(*it);
}
~HistoryUI();
void init(Evas_Object *main_layout);
virtual std::string getName();
- void addHistoryItem(std::shared_ptr<tizen_browser::services::HistoryItem>);
- void addHistoryItems(std::vector<std::shared_ptr<tizen_browser::services::HistoryItem> >);
+ void addHistoryItem(std::shared_ptr<services::HistoryItem>);
+ void addHistoryItems(std::shared_ptr<services::HistoryItemVector>);
void removeHistoryItem(const std::string& uri);
void clearItems();
void hide();
mainUI->bookmarkManagerClicked(std::string());
}
-void MainUI::addHistoryItem(std::shared_ptr<tizen_browser::services::HistoryItem> hi)
+void MainUI::addHistoryItem(std::shared_ptr<services::HistoryItem> hi)
{
BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
if (m_map_history_views.size() >= MAX_TILES_NUMBER)
m_map_history_views.insert(std::pair<std::string,Elm_Object_Item*>(hi->getUrl(),historyView));
}
-void MainUI::addHistoryItems(std::vector<std::shared_ptr<tizen_browser::services::HistoryItem> > items)
+void MainUI::addHistoryItems(std::shared_ptr<services::HistoryItemVector> items)
{
BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
int i = 0;
- for (auto it = items.begin(); it != items.end(); ++it) {
+ for (auto it = items->begin(); it != items->end(); ++it) {
i++;
if (i > MAX_TILES_NUMBER)
break;
void showBookmarks();
void clearItems();
- void addHistoryItem(std::shared_ptr<tizen_browser::services::HistoryItem>);
- void addHistoryItems(std::vector<std::shared_ptr<tizen_browser::services::HistoryItem> >);
+ void addHistoryItem(std::shared_ptr<services::HistoryItem>);
+ void addHistoryItems(std::shared_ptr<services::HistoryItemVector>);
void addBookmarkItem(std::shared_ptr<tizen_browser::services::BookmarkItem>);
void addBookmarkItems(std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> >);
struct ItemData{
tizen_browser::base_ui::MoreMenuUI * m_moreMenu;
- tizen_browser::services::HistoryItem * h_item;
+ std::shared_ptr<tizen_browser::services::HistoryItem> h_item;
Elm_Object_Item * e_item;
};
addItems();
}
-void MoreMenuUI::showCurrentTab(const std::shared_ptr<tizen_browser::services::HistoryItem> item)
+void MoreMenuUI::showCurrentTab(std::shared_ptr<tizen_browser::services::HistoryItem> item)
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
elm_theme_extension_add(NULL, m_edjFilePath.c_str());
m_itemClass->func.text_get = &listItemTextGet;
m_itemClass->func.content_get = &listItemContentGet;
m_itemClass->func.state_get = 0;
- m_itemClass->func.del = 0;
+ m_itemClass->func.del = &listItemDel;
ItemData * id = new ItemData;
id->m_moreMenu = this;
- id->h_item = item ? item.get() : NULL;
+ id->h_item = item;
Elm_Object_Item* elmItem = elm_genlist_item_append(m_genList, //genlist
m_itemClass, //item Class
id,
const char *part_name3 = "close_click";
static const int part_name3_len = strlen(part_name3);
- if (!strncmp(part_name1, part, part_name1_len) && id->h_item && id->h_item->getFavIcon()) {
+ if (!strncmp(part_name1, part, part_name1_len) && id->h_item.get() && id->h_item->getFavIcon()) {
// Currently favicon is not getting fetched from the engine,
// so we are showing Google's favicon by default.
Evas_Object *thumb_nail = elm_icon_add(obj);
static const int part_name2_len = strlen(part_name2);
if (!strncmp(part_name1, part, part_name1_len)) {
- if (!id->h_item) {
+ if (!id->h_item.get()) {
return strdup("New Tab");
}
return strdup(id->h_item->getTitle().c_str());
}
if (!strncmp(part_name2, part, part_name2_len)) {
- if(!id->h_item)
+ if(!id->h_item.get())
return strdup("");
return strdup(id->h_item->getUrl().c_str());
}
return strdup("");
}
+void MoreMenuUI::listItemDel(void* data, Evas_Object* obj)
+{
+ BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+ if(data)
+ delete (ItemData *)data;
+}
+
void MoreMenuUI::hide()
{
evas_object_hide(elm_layout_content_get(m_mm_layout, "elm.swallow.grid"));
MoreMenuUI();
~MoreMenuUI();
void show(Evas_Object *main_layout);
- void showCurrentTab(const std::shared_ptr<tizen_browser::services::HistoryItem> item);
+ void showCurrentTab(std::shared_ptr<tizen_browser::services::HistoryItem> item);
virtual std::string getName();
void addItems();
void hide();
static Evas_Object* listItemContentGet(void *data, Evas_Object *obj, const char *part);
static char* listItemTextGet(void *data, Evas_Object *obj, const char *part);
+ static void listItemDel(void *, Evas_Object *);
void newFolderPopup(std::string);
void NewFolderCreate(Evas_Object * popup_content);
return m_favoriteService->getBookmarks(folder_id);
}
-std::vector<std::shared_ptr<tizen_browser::services::HistoryItem> > SimpleUI::getHistory()
+std::shared_ptr<services::HistoryItemVector> SimpleUI::getHistory()
{
return m_historyService->getMostVisitedHistoryItems();
}
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
bool current_tab_as_new_tab = isHomePageActive() || (m_historyService->getHistoryItemsCount() == 0);
- if(!m_moreMenuUI){
- m_moreMenuUI =
- std::dynamic_pointer_cast
- <tizen_browser::base_ui::MoreMenuUI,tizen_browser::core::AbstractService>
- (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.moremenuui"));
+ if (!m_moreMenuUI) {
+ m_moreMenuUI = std::dynamic_pointer_cast<tizen_browser::base_ui::MoreMenuUI, tizen_browser::core::AbstractService>
+ (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.moremenuui"));
M_ASSERT(m_moreMenuUI);
+
m_moreMenuUI->bookmarkManagerClicked.connect(boost::bind(&SimpleUI::onBookmarkManagerButtonClicked, this, _1));
- m_moreMenuUI->historyUIClicked.connect(boost::bind(&SimpleUI::showHistoryUI, this,_1));
- m_moreMenuUI->settingsClicked.connect(boost::bind(&SimpleUI::showSettingsUI, this,_1));
+ m_moreMenuUI->historyUIClicked.connect(boost::bind(&SimpleUI::showHistoryUI, this, _1));
+ m_moreMenuUI->settingsClicked.connect(boost::bind(&SimpleUI::showSettingsUI, this, _1));
m_moreMenuUI->closeMoreMenuClicked.disconnect_all_slots();
- m_moreMenuUI->closeMoreMenuClicked.connect(boost::bind(&SimpleUI::closeMoreMenu, this,_1));
+ m_moreMenuUI->closeMoreMenuClicked.connect(boost::bind(&SimpleUI::closeMoreMenu, this, _1));
m_moreMenuUI->addToBookmarkClicked.disconnect_all_slots();
m_moreMenuUI->addToBookmarkClicked.connect(boost::bind(&SimpleUI::addBookmarkFolders, this));
m_moreMenuUI->AddBookmarkInput.disconnect_all_slots();
- m_moreMenuUI->AddBookmarkInput.connect(boost::bind(&SimpleUI::addToBookmarks, this,_1));
+ m_moreMenuUI->AddBookmarkInput.connect(boost::bind(&SimpleUI::addToBookmarks, this, _1));
m_moreMenuUI->BookmarkFolderCreated.disconnect_all_slots();
- m_moreMenuUI->BookmarkFolderCreated.connect(boost::bind(&SimpleUI::newFolderMoreMenu, this,_1,_2));
+ m_moreMenuUI->BookmarkFolderCreated.connect(boost::bind(&SimpleUI::newFolderMoreMenu, this, _1, _2));
m_moreMenuUI->show(m_window.get());
- m_moreMenuUI->showCurrentTab(current_tab_as_new_tab ? nullptr : m_historyService->getHistoryItems().front());
+ m_moreMenuUI->showCurrentTab(current_tab_as_new_tab ? nullptr : m_historyService->getCurrentTab());
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
}
}
void bookmarkCheck();
std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> > getBookmarks(int folder_id = -1);
std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> > getBookmarkFolders(int folder_id);
- std::vector<std::shared_ptr<tizen_browser::services::HistoryItem> > getHistory();
+ std::shared_ptr<services::HistoryItemVector> getHistory();
void onBookmarkAdded(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
void onBookmarkClicked(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);