Fixed Nabi Issues
[apps/osp/Internet.git] / inc / IntBookmarkPresentationModel.h
1 //
2
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 //!Internet
19 /*@file: IntBookmarkPresentationModel.h
20  *@brief: This is the header file for BookmarkPresentationModel class
21  */
22
23 #ifndef _INT_BOOKMARK_PRESENTATION_MODEL_H
24 #define _INT_BOOKMARK_PRESENTATION_MODEL_H
25
26 #include <FAppApp.h>
27 #include <FBase.h>
28 #include <FIo.h>
29
30 #include "IntBookmarkData.h"
31 #include "IntPresentationModelBase.h"
32 #include "IntTypes.h"
33
34 enum {
35         BOOKMARK_ID = 0,
36         BOOKMARK_TYPE,
37         BOOKMARK_PARENT,
38         BOOKMARK_ADDRESS,
39         BOOKMARK_TITLE,
40         BOOKMARK_CREATIONDATE,
41         BOOKMARK_SEQUENCE,
42         BOOKMARK_UPDATEDATA,
43         BOOKMARK_VISITDATE,
44         BOOKMARK_EDITABLE,
45         BOOKMARK_ACCESSACCOUNT,
46         BOOKMARK_FAVICON,
47         BOOKMARK_FAVICON_LENGTH,
48         BOOKMARK_FAVICON_W,
49         BOOKMARK_FAVICON_H,
50         BOOKMARK_CREATED_DATE,
51         BOOKMARK_ACCOUNT_NAME,
52         BOOKMARK_ACCOUNT_TYPE,
53         BOOKMARK_THUMBNAIL,
54         BOOKMARK_THUMBNAIL_LENGTH,
55         BOOKMARK_THUMBNAIL_W,
56         BOOKMARK_THUMBNAIL_H,
57         BOOKMARK_VERSION,
58         BOOKMARK_SYNC,
59         BOOKMARK_TAG1,
60         BOOKMARK_TAG2,
61         BOOKMARK_TAG3,
62         BOOKMARK_TAG4,
63         /*HISTORY_ICON_PATH,
64         HISTORY_FAVICONID,
65         HISTORY_THUMBNAIL,
66         HISTORY_BOOKMARK_ID,
67         HISTORY_VISITED_COUNT*/
68 };
69
70 /**
71  * @class BookmarkPresentationModel
72  * @brief This class declares functions which will manage database
73  */
74 class BookmarkPresentationModel
75 :public PresentationModelBase
76  {
77 public:
78         /**
79          * @brief               The method used to get the already created instance of the FaviconManager
80          */
81         static BookmarkPresentationModel* GetInstance(void);
82         /**
83          * This function deletes the bookmark from the bookmark table
84          *
85          * @return      An error code
86          * @param               bookmarkId              The bookmarkId
87          * @exception   E_SUCCESS               The bookmark is successfully deleted
88          * @exception   E_FAILURE               The bookmark deletion is unsuccessful
89          */
90         result DeleteBookmark(int bookmarkId);
91
92         /**
93          * This function deletes the bookmark from the bookmark table
94          *
95          * @return      An error code
96          * @param               url                 URL of the bookmark
97          * @exception   E_SUCCESS               The bookmark is successfully deleted
98          * @exception   E_FAILURE               The bookmark deletion is unsuccessful
99          */
100         result DeleteBookmark(const Tizen::Base::String& url);
101
102         /**
103          * This function deletes the bookmark from the bookmark table
104          *
105          * @return      An error code
106          * @param               folderId                The folderID
107          * @exception   E_SUCCESS               The bookmark is successfully deleted
108          * @exception   E_FAILURE               The bookmark deletion is unsuccessful
109          */
110         result DeleteBookmarkByFolderId(int folderId);
111
112         /**
113          * This function deletes the folder from the folder table
114          *
115          * @return      An error code
116          * @param               bookmarkId              The folderId
117          * @exception   E_SUCCESS               The folder is successfully deleted
118          * @exception   E_FAILURE               The folder deletion is unsuccessful
119          */
120         result DeleteFolder(int folderId);
121
122
123         /**
124          * This function checks whether the Bookmark with given URl already exists or not
125          *
126          * @return      An error code
127          * @param               URl
128          * @exception   E_SUCCESS               The method is successful
129          * @exception   E_FAILURE               The method is not successful as the list is not being created
130          * @remarks             To check whether the Bookmark with given URl already exists or not
131          */
132         result DoesBookmarkExist(const Tizen::Base::String& Url, bool &exist, const Tizen::Base::String& parentId = L"-1", bool checkParentId = false);
133         /**
134          * This function selects the bookmarks from the table
135          *
136          * @return      An error code
137          * @param               parentID                parentId for bookmark : Folder or URL
138          * @param               startIndex              the OFFSET value
139          * @param               limit                   The LIMIT till which the select statement will be executed
140          * @param               bookmarkList    The arraylist where the selected bookmarks will be saved
141          */
142         result GetBookmark(const Tizen::Base::String& parentID, const int startIndex, const int limit, Tizen::Base::Collection::ArrayList& bookmarkList);
143
144
145         result GetBookmarkForHistory(int startIndex, Tizen::Base::Collection::ArrayList& bookmarkList);
146
147         /**
148          * This function returns the no of bookmarks
149          *
150          * @return      An error code
151          * @param               parentID                Folder or URL
152          */
153         result GetBookmarkCount(const Tizen::Base::String& parentID, int& count);
154
155         /**
156          * This function selects the bookmark folders  from the table
157          *
158          * @return      An error code
159          * @param               parentID                parentId for bookmark : Folder or URL
160          * @param               startIndex              the OFFSET value
161          * @param               limit                   The LIMIT till which the select statement will be executed
162          * @param               bookmarkList    The arraylist where the selected bookmarks will be saved
163          */
164         result GetFolder(const Tizen::Base::String& parentID, int startIndex,int limit, Tizen::Base::Collection::ArrayList& bookmarkList);
165
166
167         /**
168          * This function returns the no of bookmark folders
169          *
170          * @return      An error code
171          * @param               parentID                Folder or URL
172          */
173         result GetFolderBookmarkCount(const Tizen::Base::String& parentID, int& Count);
174
175         /**
176          * This function selects the bookmark folders from the table
177          *
178          * @return      An error code
179          * @param               parentID                parentId for bookmark : Folder or URL
180          * @param               startIndex              the OFFSET value
181          * @param               limit                   The LIMIT till which the select statement will be executed
182          * @param               bookmarkList    The arraylist where the selected bookmarks will be saved
183          */
184         result GetFoldersBookmarks(const Tizen::Base::String& parentID, const int startIndex, const int limit, Tizen::Base::Collection::ArrayList& bookmarkList);
185
186         /**
187          * This function returns the no of bookmark folders.
188          *
189          * @return      An error code
190          * @param               parentID                Folder or URL
191          */
192         result GetFolderCount(const Tizen::Base::String& parentID, int& count);
193
194         /**
195          * This function selects the searched bookmarks from the table
196          *
197          * @return      An error code
198          * @param               startIndex              the OFFSET value
199          * @param               limit                   The LIMIT till which the select statement will be executed
200          * @param               BookmarkList            The arraylist where the selected searched bookmarks will be saved
201          */
202         result GetSearchBookmark(int startIndex,int limit, Tizen::Base::Collection::ArrayList& BookmarkList, Tizen::Base::String& text);
203
204
205         /**
206          * This function returns the no of searched Bookmarks
207          *
208          * @return      An error code
209          * @param               count                   The no of matching bookmarks will be returned in count.
210          */
211         result GetSearchBookmarkCount(int& count, Tizen::Base::String& text);
212
213         /**
214          * This function selects the searched folders from the table
215          *
216          * @return      An error code
217          * @param               startIndex              the OFFSET value
218          * @param               limit                   The LIMIT till which the select statement will be executed
219          * @param               FolderList              The arraylist where the selected searched folders will be saved
220          */
221         result GetSearchFolder(int startIndex,int limit, Tizen::Base::Collection::ArrayList& FolderList, Tizen::Base::String& text);
222
223         /**
224          * This function returns the no of searched Bookmarks and Folders
225          *
226          * @return      An error code
227          * @param               count                   The no of matching bookmarks and folders will be returned in count.
228          */
229         result GetSearchFolderBookmarkCount(int& count, Tizen::Base::String& text);
230
231         /**
232          * This function returns the no of searched Folders
233          *
234          * @return      An error code
235          * @param               count                   The no of matching Folders will be returned in count.
236          */
237         result GetSearchFolderCount(int& count, Tizen::Base::String& text);
238
239         /**
240          * This function selects the searched bookmark folders from the table
241          *
242          * @return      An error code
243          * @param               startIndex              the OFFSET value
244          * @param               limit                   The LIMIT till which the select statement will be executed
245          * @param               BookmarkList            The arraylist where the selected searched bookmarks will be saved
246          */
247         result GetSearchFoldersBookmarks(int startIndex,int limit, Tizen::Base::Collection::ArrayList& BookmarkList, Tizen::Base::String& text);
248
249         /**
250          * This function adds the folder to the folder table
251          *
252          * @return      An error code
253          * @param               bookmark                The folder
254          * @exception   E_SUCCESS               The folder is inserted successfully to the table
255          * @exception   E_FAILURE               The folder is not inserted successfully
256          */
257         result SaveFolder(BookmarkData& bookmark);
258
259         /**
260          * This function adds the bookmarks to the bookmark table
261          *
262          * @return      An error code
263          * @param               bookmark                The bookmark
264          * @exception   E_SUCCESS               The bookmark is inserted successfully to the table
265          * @exception   E_FAILURE               The bookmark is not inserted successfully
266          */
267         result SaveBookmark(BookmarkData& bookmark);
268
269         result SaveTempBookmark(BookmarkData& bookmark);
270 private:
271         /**
272          * @brief The Default Constructor
273          */
274         BookmarkPresentationModel(void);
275
276         /**
277         * @brief                The Default Destructor
278         */
279         ~BookmarkPresentationModel(void);
280
281         /**
282          * copy constructor
283          */
284         BookmarkPresentationModel(const BookmarkPresentationModel& settingModelObj);
285
286         /**
287          * assignment operator
288          */
289
290         BookmarkPresentationModel& operator=(const BookmarkPresentationModel& settingModelObj);
291
292         /**
293          *@brief Initialize storage service
294          */
295         result Construct(void);
296
297         /**
298          * @brief               The method used to create the instance of the SettingsManager class
299          */
300         static void CreateInstance(void);
301
302         /**
303          * @brief               The method used to remove the already created instance of the SettingsManager
304          */
305         static void DestroyInstance(void);
306
307         /**
308          * This function creates the list of BookMark
309          *
310          * @return      An error code
311          * @param               nBookmarkCount  The no of BookMark present
312          * @param               bookmarkList    An ArrayList where the BookMark will be stored
313          * @exception   E_SUCCESS               The method is successful
314          * @exception   E_FAILURE               The method is not successful as the list is not being created
315          * @remarks             To work properly , the bookmark count and and existing list should be passed
316          */
317         result CreateBookmarkList(int nBookmarkCount, Tizen::Base::Collection::ArrayList& bookmarkList);
318         /**
319          * This function creates the list of BookMark folders
320          *
321          * @return      An error code
322          * @param               bookmarkCount  The no of BookMark folders present
323          * @param               bookmarkList    An ArrayList where the BookMark will be stored
324          * @exception   E_SUCCESS               The method is successful
325          * @exception   E_FAILURE               The method is not successful as the list is not being created
326          * @remarks             To work properly , the bookmark count and and existing list should be passed
327          */
328
329         result CreateFolderList(int bookmarkCount, Tizen::Base::Collection::ArrayList& bookmarkList);
330
331 private:
332         static BookmarkPresentationModel* __pBookmarkPresentationModel;
333
334  };
335
336 #endif //_INT_BOOKMARK_PRESENTATION_MODEL_H