Fixed Nabi Issues, Changes for tizen-service implementation and DB Changes
[apps/osp/Internet.git] / inc / IntHistoryPresentationModel.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
19 //!Internet
20 /*@file: IntHistoryPresentationModel.h
21  *@brief: This is the header file for HistoryPresentationModel class
22  */
23
24
25 #ifndef _INT_HISTORY_PRESENTATION_MODEL_H
26 #define _INT_HISTORY_PRESENTATION_MODEL_H
27
28 #include <FAppApp.h>
29 #include <FBase.h>
30 #include <FIo.h>
31
32
33 #include "IntHistoryData.h"
34 #include "IntPresentationModelBase.h"
35 #include "IntTypes.h"
36
37 enum {
38         HISTORY_ID = 0,
39         HISTORY_URL,
40         HISTORY_TITLE,
41         HISTORY_COUNTER,
42         HISTORY_VISITED_TIME,
43         HISTORY_FAVICON,
44         HISTORY_FAVICON_LENGTH,
45         HISTORY_FAVICON_W,
46         HISTORY_FAVICON_H,
47         HISTORY_SNAPSHOT,
48         HISTORY_SNAPSHOT_STRIDE,
49         HISTORY_SNAPSHOT_W,
50         HISTORY_SNAPSHOT_H,
51 //      HISTORY_BOOKMARK_ID,
52         HISTORY_VISITED_COUNT
53         /*HISTORY_ICON_PATH,
54         HISTORY_FAVICONID,
55         HISTORY_THUMBNAIL,
56         HISTORY_BOOKMARK_ID,
57         HISTORY_VISITED_COUNT*/
58 };
59 //ID INTEGER PRIMARY KEY AUTOINCREMENT, ADDRESS TEXT, TITLE TEXT, COUNTER INTEGER, VISITDATE DATETIME, FAVICON BLOB,
60 //FAVICON_LENGTH INTEGER, FAVICON_W INTEGER, FAVICON_H INTEGER, SNAPSHOT BLOB, SNAPSHOT_STRIDE INTEGER, SNAPSHOT_W INTEGER, SNAPSHOT_H INTEGER
61 /**
62  * @class HistoryPresentationModel
63  * @brief This class declares functions which will manage Browser History
64  */
65 class HistoryPresentationModel
66      :public PresentationModelBase
67 {
68 public:
69     /**
70      * @brief           The method used to get the already created instance of the HistoryPresentationModel
71      */
72     static HistoryPresentationModel* GetInstance(void);
73
74          /**
75          * This function deletes all the histories.
76          *
77          * @return      An error code
78          * @param               No parameter
79          */
80         result ClearHistory(void);
81
82         /**
83          * This function creates the list of History
84          *
85          * @return      An error code
86          * @param               nHistoryCount   The no of History present
87          * @param               historyList     An ArrayList where the History will be stored
88          * @param               maxCount            is used for maximum most visited site else its value is default to -1
89          * @exception   E_SUCCESS               The method is successful
90          * @exception   E_FAILURE               The method is not successful as the list is not being created
91          * @remarks             To work properly , the history count and and existing list should be passed
92          */
93         result CreateHistoryList(int nHistoryCount, Tizen::Base::Collection::ArrayList& historyList, int maxCount = -1);
94
95         /**
96          * This function deletes particular history of history ID from the history table
97          *
98          * @return      An error code
99          * @param               historyId               The historyId
100          * @exception   E_SUCCESS               The history is successfully deleted
101          * @exception   E_FAILURE               The history deletion is unsuccessful
102          */
103         result DeleteHistory(int historyId);
104
105         /**
106          * This function deletes particular history of history URL.
107          *
108          * @return      An error code
109          * @param               No parameter
110          */
111         result DeleteHistory(Tizen::Base::String& historyUrl);
112
113         /**
114          * This function deletes Multiple histories from the history table
115          *
116          * @return      An error code
117          * @param               pHistoryIdList  The Arraylist of ids of history to be deleted
118          * @exception   E_SUCCESS               The history is successfully deleted
119          * @exception   E_FAILURE               The history deletion is unsuccessful
120          */
121         result DeleteMultipleHistory(Tizen::Base::Collection::ArrayList* pHistoryIdList);
122
123         /**
124          * This function adds the history to the history table
125          *
126          * @return      An error code
127          * @param               history                 The history
128          * @exception   E_SUCCESS               The history is inserted successfully to the table
129          * @exception   E_FAILURE               The history is not inserted successfully
130          */
131         result SaveHistory(History& history);
132
133         /**
134          * This function selects the history from the table
135          *
136          * @return      An error code
137          * @param               startIndex              the OFFSET value
138          * @param               limit                   The LIMIT till which the select statement will be executed
139          * @param               historyList             The arraylist where the selected history will be saved
140          */
141         result GetHistory( int startIndex, int limit, Tizen::Base::Collection::ArrayList& historyList);
142
143         /**
144          * This function returns the no of history
145          *
146          * @return      An error code
147          * @param               count                   The no of History present will be saved in count.
148          */
149         result GetHistoryCount(int& count);
150
151         /**
152          * This function returns the history count from the table on the basis of the time range
153          *
154          * @return      An error code
155          * @param               startTime               the startTime
156          * @param               endTime                 the end time
157          */
158         result GetHistoryCountWithTimeRange(Tizen::Base::DateTime& startTime, Tizen::Base::DateTime& endTime, int& count);
159
160         /**
161          * This function selects the history from the table within given time range
162          *
163          * @return      An error code
164          * @param               startTime               start value of time
165          * @param               endTime                 end value of time
166          * @param               startIndex              the OFFSET value
167          * @param               limit                   The LIMIT till which the select statement will be executed
168          * @param               historyList             The arraylist where the selected history will be saved
169          */
170         result GetHistoryWithTimeRange(Tizen::Base::DateTime& startTime, Tizen::Base::DateTime& endTime,int startIndex,int limit, Tizen::Base::Collection::ArrayList& pHistoryList);
171
172         /**
173          * This function used to get most visited site in a arraylist
174          *
175          * @return      An error code
176          * @param               historyList             The arraylist where the most visited sites will be saved.
177          */
178         result GetMostVisitedSites(Tizen::Base::Collection::ArrayList& historyList);
179
180         /**
181          * This function returns the no of searched text history
182          *
183          * @return      An error code
184          * @param               count                   The no of History present will be saved in count.
185          * @param       text                    text entered for search
186          */
187         result GetSearchHistoryCount(int& count, Tizen::Base::String& text);
188
189         /**
190          * This function selects the searched history from the table
191          *
192          * @return      An error code
193          * @param               startIndex              the OFFSET value
194          * @param               limit                   The LIMIT till which the select statement will be executed
195          * @param       text                    text entered for search
196          * @param               historyList             The arraylist where the selected history will be saved
197          */
198         result GetSearchHistory(int startIndex,int limit, Tizen::Base::Collection::ArrayList& historyList, Tizen::Base::String& text);
199
200         /**
201          * This function used to given URL count
202          *
203          * @return      An error code
204          * @param               url                     URL to get its count
205          * @param               count                   count of a URL
206          */
207         result GetUrlCount(const Tizen::Base::String& url, int& count);
208
209 private:
210
211         /**
212          * @brief The Default Constructor
213          */
214         HistoryPresentationModel(void);
215
216         /**
217          * @brief               The Default Destructor
218          */
219         ~HistoryPresentationModel(void);
220
221         /**
222          * copy constructor
223          */
224         HistoryPresentationModel(const HistoryPresentationModel& settingModelObj);
225
226         /**
227          * assignment operator
228          */
229
230         HistoryPresentationModel& operator=(const HistoryPresentationModel& settingModelObj);
231
232         /**
233          *@brief Initialize storage service
234          */
235         result Construct(void);
236
237         /**
238          * @brief               The method used to create the instance of the SettingsManager class
239          */
240         static void CreateInstance(void);
241
242         /**
243          * @brief               The method used to remove the already created instance of the SettingsManager
244          */
245         static void DestroyInstance(void);
246
247         /**
248          * This function is used to generate file name
249          *
250          * @return      filename                name of a file
251          * @param               No parameter
252          */
253         Tizen::Base::String GenerateFileName(void);
254
255         Tizen::Base::String GetStringFromDate(Tizen::Base::DateTime& date);
256
257         static HistoryPresentationModel* __pHistoryPresentationModel;
258 };
259
260 #endif //_INT_HISTORY_PRESENTATION_MODEL_H