2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __HISTORY_SERVICE_H
18 #define __HISTORY_SERVICE_H
22 #include <boost/date_time/gregorian/gregorian.hpp>
23 #include <boost/signals2/signal.hpp>
25 #include "ServiceFactory.h"
26 #include "service_macros.h"
27 #include "BrowserImage.h"
28 #include "HistoryItem.h"
29 #include "HistoryStorage.h"
30 #include "StorageService.h"
31 #include <web/web_history.h>
32 #define DOMAIN_HISTORY_SERVICE "org.tizen.browser.historyservice"
34 namespace tizen_browser
39 class BROWSER_EXPORT HistoryService: public tizen_browser::core::AbstractService
43 virtual ~HistoryService();
44 virtual std::string getName();
46 int getHistoryId(const std::string & url);
49 * @throws HistoryException on error
51 void addHistoryItem(std::shared_ptr<HistoryItem> hi,
52 std::shared_ptr<tizen_browser::tools::BrowserImage> thumbnail=std::shared_ptr<tizen_browser::tools::BrowserImage>());
55 * If hi->getUrl() exists on a table HISTORY update visit_counter and visit_date, unless insert hi to database.
57 * @throws HistoryException on error
59 void insertOrRefresh(std::shared_ptr<HistoryItem> hi);
62 * @throws HistoryException on error
64 void clearAllHistory();
67 * @throws HistoryException on error
69 void clearURLHistory(const std::string & url);
72 * @throws HistoryException on error
74 std::shared_ptr<HistoryItem> getHistoryItem(const std::string & url);
77 * @throws HistoryException on error
79 HistoryItemVector & getHistoryItems(int historyDepthInDays = 7, int maxItems = 50);
80 HistoryItemVector & getMostVisitedHistoryItems();
83 * @throws HistoryException on error
85 int getHistoryItemsCount();
88 * @throws HistoryException on error
90 int getHistoryVisitCounter(const std::string & url);
92 void setStorageServiceTestMode(bool testmode = true);
94 boost::signals2::signal<void (bool)>historyEmpty;
95 boost::signals2::signal<void (std::shared_ptr<tizen_browser::services::HistoryItem>)> historyAdded;
96 boost::signals2::signal<void (const std::string& uri)> historyDeleted;
97 boost::signals2::signal<void ()> historyAllDeleted;
101 std::vector<std::shared_ptr<HistoryItem>> history_list;
102 std::shared_ptr<tizen_browser::services::StorageService> m_storageManager;
105 * @throws StorageExceptionInitialization on error
107 void initDatabaseBookmark(const std::string & db_str);
109 std::shared_ptr<tizen_browser::services::StorageService> getStorageManager();