Fixed Nabi Issues
[apps/osp/Internet.git] / inc / IntPresentationModelBase.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 //!Internet
19 /*@file:        IntPresentationModelBase.h
20  *@brief:       This is the header file for PresentationModelBase class
21  */
22
23
24 #ifndef _INT_PRESENTATION_MODEL_BASE_H_
25 #define _INT_PRESENTATION_MODEL_BASE_H_
26
27 #include <FAppApp.h>
28 #include <FBase.h>
29 #include <FIo.h>
30
31 #include "IntTypes.h"
32 #include "IntBookmarkData.h"
33 #include "IntHistoryData.h"
34
35 /**
36  * @class       PresentationModelBase
37  * @brief       This class declares functions which will manage database
38  */
39 class PresentationModelBase
40 {
41 public:
42         /**
43          * Default constructor
44          */
45         PresentationModelBase(void);
46
47         /**
48          * Default destructor
49          */
50         ~PresentationModelBase(void);
51
52         /**
53          * Initialize storage service
54          */
55          result Initialize();
56
57         /**
58          * Deinitialize storage service
59          */
60          result UnInitialize(void);
61
62 public:
63
64         /**
65          * This function deletes the database
66          *
67          * @return      An error code
68          * @param               No parameter
69          * @exception   E_SUCCESS               The database closed successfully
70          * @exception   E_FAILURE               The database is not closed successfully
71          */
72          result CloseDb(void);
73
74          result CommitDb(void);
75
76         /**
77          * This function creates the table in database
78          *
79          * @return      An error code
80          * @param               tableType               The name of the table
81          * @exception   E_SUCCESS               The table is created successfully in database
82          * @exception   E_FAILURE               The table creation in database is not successful
83          */
84          result CreateDBTables(BrowserDbTableTypes tableType);
85
86         /**
87          * This function drops the existing tables from database
88          *
89          * @return      An error code
90          * @param               No parameter
91          * @exception   E_SUCCESS               The table is dropped successfully from database
92          * @exception   E_FAILURE               The table drop is unsuccessful
93          */
94          result DropDBTables(void);
95
96          result DbIsNextRowPresent(bool& nextRowpresent);
97
98         /**
99          * This function drops the existing tables from database
100          *
101          * @return      An error code
102          * @param               No parameter
103          * @exception   E_SUCCESS               The table is dropped successfully from database
104          * @exception   E_FAILURE               The table drop is unsuccessful
105          */
106          result ExecuteQuery(const Tizen::Base::String& pszFormatQuery, int& nRowCount);
107
108          /**
109           * This function drops the existing tables from database
110           *
111           * @return      An error code
112           * @param              No parameter
113           * @exception  E_SUCCESS               The table is dropped successfully from database
114           * @exception  E_FAILURE               The table drop is unsuccessful
115           */
116          result ExecuteBookmarkQuery(const Tizen::Base::String& pszFormatQuery, int& nRowCount, BookmarkData& bookmark);
117
118          result ExecuteHistoryQuery(const Tizen::Base::String& pszFormatQuery, int& nRowCount, History& history);
119
120          result ExecuteUpdateHistoryFavIconQuery(const Tizen::Base::String& formatQuery, int& nRowCount, History& history);
121
122          result GetColumn(int nIndex, Tizen::Base::String& strVal);
123
124          result GetColumn(int nIndex, int& nIntVal);
125
126          result GetColumn(int nIndex, double& dblVal);
127
128          result GetColumn(int nIndex, Tizen::Base::DateTime& dtVal);
129
130          result GetColumn(int nIndex,Tizen::Base::ByteBuffer& favIconBuffer);
131
132         static bool GetCurrentDateTime(Tizen::Base::DateTime& dt);
133
134         Tizen::Base::String GetStringFromDate(Tizen::Base::DateTime& date);
135         /**
136          * This function gives the last inserted row id
137          *
138          * @return      An error code
139          * @param               tableName       The name of the table
140          * @param               rowId           The rowId in which last inserted rowId will be saved.
141          * @exception   E_SUCCESS               The method is successful
142          * @exception   E_FAILURE               The method is not successful
143          * @remarks             To work properly , the table name should be passed properly
144          */
145          result GetLastInsertedId(Tizen::Base::String& tableName, int& rowId);
146
147         /**
148          * This function calls the CreateDBTables function for all the tables
149          *
150          * @return      An error code
151          * @param               No parameter
152          */
153          result InitializeDBTables(void);
154
155          result IsNullColumn(int nIndex, bool& isColumNull);
156
157         /**
158          * This function creates the database and constructs it.
159          *
160          * @return      An error code
161          * @param               No parameter
162          * @exception   E_SUCCESS               The database created successfully
163          * @exception   E_FAILURE               The database creation is failed
164          */
165          result OpenDb(void);
166
167          result RollbackDb(void);
168
169 public:
170      Tizen::Base::String DB_FILE_PATH;
171
172         static const int MAX_DB_QUERY_SIZE;
173          static const int QUERY_TYPE_LENGTH;
174
175 private:
176      bool __isBeginTransaction;
177
178          Tizen::Io::Database* __pDataBase;
179          Tizen::Io::DbEnumerator* __pDbEnum;
180          Tizen::Io::DbStatement* __pDbStatement;
181
182 };
183
184  #endif //_INT_PRESENTATION_MODEL_BASE_H_