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