return count;
}
-static int __get_duplicated_ids_p(int **ids, int *count, const int limit, const int offset,
- const bp_history_offset order_column_offset, const int ordering,
- const bp_history_offset check_column_offset,
- const char *keyword, const int is_like)
-{
- bp_history_rows_cond_fmt conds;
- conds.limit = limit;
- conds.offset = offset;
- conds.ordering = ordering;
- conds.order_offset = order_column_offset;
- conds.period_offset = BP_HISTORY_O_DATE_CREATED;
- conds.period_type = BP_HISTORY_DATE_ALL;
-
- return bp_history_adaptor_get_cond_ids_p(ids, count, &conds, check_column_offset, keyword, is_like);
-}
-
-bool isDuplicate(const char* title)
+bool HistoryService::isDuplicate(const char* url) const
{
+ M_ASSERT(url);
int *ids=nullptr;
int count=0;
bp_history_rows_cond_fmt conds;
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);
+ bp_history_offset offset = (BP_HISTORY_O_URL | BP_HISTORY_O_DATE_CREATED);
- for(int i = 0; i< count; i++){
+ for (int i = 0; i < count; i++) {
bp_history_info_fmt history_info;
- bp_history_adaptor_get_info(ids[i],offset,&history_info);
- if(!strcmp(history_info.title, title)) {
- int freq;
- bp_history_adaptor_get_frequency(ids[i], &freq);
- bp_history_adaptor_set_frequency(ids[i], freq + 1);
- bp_history_adaptor_set_date_visited(ids[i],-1);
- return true;
+ bp_history_adaptor_get_info(ids[i], offset, &history_info);
+ if (!history_info.url) {
+ BROWSER_LOGD("Warning: history entry without url!");
+ } else if (!strcmp(history_info.url, url)) {
+ int freq;
+ bp_history_adaptor_get_frequency(ids[i], &freq);
+ bp_history_adaptor_set_frequency(ids[i], freq + 1);
+ bp_history_adaptor_set_date_visited(ids[i],-1);
+ return true;
}
}
return false;
-
}
std::shared_ptr<HistoryItemVector> HistoryService::getHistoryAll()
his->setFavIcon(his->getFavIcon());
his->setThumbnail(thumbnail);
- if(isDuplicate(his->getTitle().c_str()))
+ if (isDuplicate(his->getUrl().c_str()))
return;
int id = -1;
historyAdded(his);
}
-
-void HistoryService::insertOrRefresh(std::shared_ptr<HistoryItem> hi) {
- /**
- * No browser- provider implementation till now. Needs to be done
- */
- //getStorageManager()->insertOrRefresh(hi);
-}
-
void HistoryService::clearAllHistory()
{
bp_history_adaptor_reset();
int *ids = nullptr;
int ids_count = 0;
int ret = bp_history_adaptor_get_cond_ids_p(&ids ,&ids_count, &conds, BP_HISTORY_O_URL, url.c_str(), 0);
- if (ids_count!=0){
+ if (ret < 0) {
+ BROWSER_LOGD("Error! Could not get ids!");
+ } else if (ids_count != 0) {
int i = *ids;
free(ids);
return i;
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 ret_history_list;
}
-int HistoryService::getHistoryVisitCounter(const std::string & url)
-{ /**
- * No browser- provider implementation till now. Needs to be done
- */
-// return getStorageManager()->getHistoryVisitCounter(url);
-
-}
-
}
}
int getHistoryId(const std::string & url);
void addHistoryItem(std::shared_ptr<HistoryItem> hi,
std::shared_ptr<tizen_browser::tools::BrowserImage> thumbnail=std::shared_ptr<tizen_browser::tools::BrowserImage>());
- void insertOrRefresh(std::shared_ptr<HistoryItem> hi);
void clearAllHistory();
void clearURLHistory(const std::string & url);
std::shared_ptr<HistoryItem> getHistoryItem(const std::string & url);
std::shared_ptr<HistoryItemVector> getMostVisitedHistoryItems();
std::shared_ptr<HistoryItemVector> getHistoryItemsByURL(const std::string & url, int maxItems);
int getHistoryItemsCount();
- int getHistoryVisitCounter(const std::string & url);
void setStorageServiceTestMode(bool testmode = true);
boost::signals2::signal<void (bool)>historyEmpty;
std::shared_ptr<HistoryItem> getHistoryItem(int* ids, int idNumber = 0);
std::shared_ptr<HistoryItemVector> getHistoryItems(bp_history_date_defs period = BP_HISTORY_DATE_TODAY);
std::shared_ptr<tizen_browser::services::StorageService> getStorageManager();
-
+ bool isDuplicate(const char* url) const;
};
}