Initialize Tizen 2.3
[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.1 (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         result SaveTempHistory(History& history);
134
135         /**
136          * This function selects the history from the table
137          *
138          * @return      An error code
139          * @param               startIndex              the OFFSET value
140          * @param               limit                   The LIMIT till which the select statement will be executed
141          * @param               historyList             The arraylist where the selected history will be saved
142          */
143         result GetHistory( int startIndex, int limit, Tizen::Base::Collection::ArrayList& historyList);
144
145         /**
146          * This function returns the no of history
147          *
148          * @return      An error code
149          * @param               count                   The no of History present will be saved in count.
150          */
151         result GetHistoryCount(int& count);
152
153         /**
154          * This function returns the history count from the table on the basis of the time range
155          *
156          * @return      An error code
157          * @param               startTime               the startTime
158          * @param               endTime                 the end time
159          */
160         result GetHistoryCountWithTimeRange(Tizen::Base::DateTime& startTime, Tizen::Base::DateTime& endTime, int& count);
161
162         /**
163          * This function selects the history from the table within given time range
164          *
165          * @return      An error code
166          * @param               startTime               start value of time
167          * @param               endTime                 end value of time
168          * @param               startIndex              the OFFSET value
169          * @param               limit                   The LIMIT till which the select statement will be executed
170          * @param               historyList             The arraylist where the selected history will be saved
171          */
172         result GetHistoryWithTimeRange(Tizen::Base::DateTime& startTime, Tizen::Base::DateTime& endTime,int startIndex,int limit, Tizen::Base::Collection::ArrayList& pHistoryList);
173
174         /**
175          * This function used to get most visited site in a arraylist
176          *
177          * @return      An error code
178          * @param               historyList             The arraylist where the most visited sites will be saved.
179          */
180         result GetMostVisitedSites(Tizen::Base::Collection::ArrayList& historyList);
181
182         /**
183          * This function returns the no of searched text history
184          *
185          * @return      An error code
186          * @param               count                   The no of History present will be saved in count.
187          * @param       text                    text entered for search
188          */
189         result GetSearchHistoryCount(int& count, Tizen::Base::String& text);
190
191         /**
192          * This function selects the searched history from the table
193          *
194          * @return      An error code
195          * @param               startIndex              the OFFSET value
196          * @param               limit                   The LIMIT till which the select statement will be executed
197          * @param       text                    text entered for search
198          * @param               historyList             The arraylist where the selected history will be saved
199          */
200         result GetSearchHistory(int startIndex,int limit, Tizen::Base::Collection::ArrayList& historyList, Tizen::Base::String& text);
201
202         /**
203          * This function used to given URL count
204          *
205          * @return      An error code
206          * @param               url                     URL to get its count
207          * @param               count                   count of a URL
208          */
209         result GetUrlCount(const Tizen::Base::String& url, int& count);
210
211         void UpdateHistoryFavIcon(History& history, Tizen::Graphics::Bitmap& favIconImage);
212
213 private:
214
215         /**
216          * @brief The Default Constructor
217          */
218         HistoryPresentationModel(void);
219
220         /**
221          * @brief               The Default Destructor
222          */
223         ~HistoryPresentationModel(void);
224
225         /**
226          * copy constructor
227          */
228         HistoryPresentationModel(const HistoryPresentationModel& settingModelObj);
229
230         /**
231          * assignment operator
232          */
233
234         HistoryPresentationModel& operator=(const HistoryPresentationModel& settingModelObj);
235
236         /**
237          *@brief Initialize storage service
238          */
239         result Construct(void);
240
241         /**
242          * @brief               The method used to create the instance of the SettingsManager class
243          */
244         static void CreateInstance(void);
245
246         /**
247          * @brief               The method used to remove the already created instance of the SettingsManager
248          */
249         static void DestroyInstance(void);
250
251         /**
252          * This function is used to generate file name
253          *
254          * @return      filename                name of a file
255          * @param               No parameter
256          */
257         Tizen::Base::String GenerateFileName(void);
258
259         Tizen::Base::String GetStringFromDate(Tizen::Base::DateTime& date);
260
261         static HistoryPresentationModel* __pHistoryPresentationModel;
262
263         Tizen::Base::Collection::ArrayList *__pDataList;
264 };
265
266 #endif //_INT_HISTORY_PRESENTATION_MODEL_H