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.
19 * Created on: Dec, 2014
23 #ifndef BOOKMARKSERVICE_H
24 #define BOOKMARKSERVICE_H
26 #include "browser_config.h"
28 #include <boost/signals2/signal.hpp>
31 #include "AbstractService.h"
32 #include "service_macros.h"
33 #include "BookmarkItem.h"
34 #include "BrowserImage.h"
35 #include "Config/Config.h"
36 #include "AbstractFavoriteService.h"
38 namespace tizen_browser{
41 class BROWSER_EXPORT BookmarkService
42 : public tizen_browser::interfaces::AbstractFavoriteService
46 virtual ~BookmarkService();
47 virtual std::string getName();
50 * @brief Add page to bookmarks
52 * @param address Webpage url.
53 * @param tittle Title of bookmark.
54 * @param note Bookmark note, default is empty .
55 * @param dirId Directory numeric ID, default is 0.
56 * @param thumbnail Page thumbnail, default is empty image.
57 * @param favicon Page favicon image, default is empty image.
59 * @return BookmarkItem class
61 std::shared_ptr<BookmarkItem> addToBookmarks(const std::string & address,
62 const std::string & tittle,
63 const std::string & note = std::string(),
64 std::shared_ptr<tizen_browser::tools::BrowserImage> thumbnail=std::shared_ptr<tizen_browser::tools::BrowserImage>(),
65 std::shared_ptr<tizen_browser::tools::BrowserImage> favicon = std::shared_ptr<tizen_browser::tools::BrowserImage>(),
66 unsigned int dirId = 0);
68 * @brief Count bookmarks and subfolders
69 * @return Number of bookmarks and subfolders
71 int countBookmarksAndSubFolders();
73 /** \todo Need to change this callback function for finding stored bookmark, check getBookmarkId function
74 * @brief Check if bookmark exists
76 * @param url url to find
77 * @return true if exists, false if not
79 bool bookmarkExists(const std::string & url);
82 * @brief Get bookmarks from platform service and store it in private m_bookmarksList
84 * @return list of bookmark items, bookmark items in a folder & bookmark folders
86 std::vector<std::shared_ptr<BookmarkItem> > getBookmarks(int folder_id = 0);
87 std::vector<std::shared_ptr<BookmarkItem> > getBookmarkFolders();
90 * @brief Delete all bookmarks
92 * @return true if success, false on error
94 bool deleteAllBookmarks();
97 * @brief Delete bookmark by given url
99 * @param url of bookmark to delete
100 * @return true if success, false on error of not found bookmark
102 bool deleteBookmark(const std::string & url);
105 void synchronizeBookmarks();
107 typedef struct _folder_info {
112 int get_root_folder_id(void);
113 int save_folder(const char *title, int *saved_bookmark_id, int parent_id=0,int by_operator = 0);
114 bool delete_by_id(int id);
115 bool delete_by_id_notify(int id);
116 bool delete_by_uri(const char *uri);
117 int update_bookmark(int id, const char *title, const char *uri, int parent_id, int order,
118 bool is_duplicate_check_needed = false, bool is_URI_check_needed = false);
119 int update_bookmark_notify(int id, const char *title, const char *uri, int parent_id, int order,
120 bool is_duplicate_check_needed = false, bool is_URI_check_needed = false);
121 bool delete_all(void);
122 bool get_item_by_id(int id, BookmarkItem *item);
123 std::vector<BookmarkItem *> get_list_by_folder(const int folder_id);
124 bool get_list_users_by_folder(const int folder_id, std::vector<BookmarkItem *> &list);
125 bool get_list_by_dividing(const int folder_id, std::vector<BookmarkItem *> &list, int *last_item, int genlist_block_size);
126 bool get_list_users_by_dividing(const int folder_id, std::vector<BookmarkItem *> &list, int *last_item, int genlist_block_size);
127 int _get_folder_count(const int folder_id);
128 int _get_bookmarks_count(const int folder_id);
129 int _get_total_contents_count(const int folder_id);
130 bool get_list_operators(const int folder_id, std::vector<BookmarkItem *> &list);
131 bool get_list_by_keyword(const char *keyword, std::vector<BookmarkItem *> &list);
132 void destroy_list(std::vector<BookmarkItem *> &list);
134 bool get_id(const char *uri, int *bookmark_id);
135 bool get_folder_id(const char *title, int parent_id, int *folder_id);
136 bool is_in_bookmark(const char *uri);
137 bool is_in_folder(int parent_folder, const char *title);
138 bool get_folder_depth_count(int *depth_count);
139 bool set_thumbnail(int id, Evas_Object *thumbnail);
140 Evas_Object *get_thumbnail(int id, Evas_Object *parent);
141 bool set_favicon(int id, Evas_Object *favicon);
142 Evas_Object *get_favicon(int id, Evas_Object *parent);
143 bool set_webicon(int id, Evas_Object *webicon);
144 Evas_Object *get_webicon(int id, Evas_Object *parent);
145 bool set_access_count(int id, int count);
146 bool get_access_count(int id, int *count);
147 bool increase_access_count(int id);
148 bool set_last_sequence(int id);
149 const char* get_path_info(void);
150 folder_info *get_path_by_index(unsigned int index);
151 int get_path_size(void);
152 void push_back_path(folder_info *item);
153 void pop_back_path(void);
154 void clear_path_history(void);
155 void free_path_history(void);
156 void change_path_lang(void);
157 void path_into_sub_folder(int folder_id, const char *folder_name);
158 bool path_to_upper_folder(int *curr_folder);
160 bool get_memory_full(void) { return m_memory_full; }
161 int get_current_folder_id(void) { return m_curr_folder; }
164 bool _get_depth_count_recursive(int folder_id, int cur_depth, int *depth_count);
166 std::vector<BookmarkItem *> m_bookmark_list;
167 std::vector<folder_info *> m_path_history;
168 std::string m_path_string;
170 bool m_bookmark_adaptor_initialize;
172 std::shared_ptr<tizen_browser::services::StorageService> m_storageManager;
173 std::vector<std::shared_ptr<BookmarkItem> > m_bookmarks;
175 /// \todo Need to change getBookmarkId function for finding stored bookmark - check getBookmarkExists function
176 int getBookmarkId(const std::string & url);
177 std::shared_ptr<tizen_browser::services::StorageService> getStorageManager();
178 config::DefaultConfig config;
184 #endif // FAVORITESERVICE_H