merge with master
[apps/osp/Internet.git] / inc / IntPresentationModelBase.h
1 //\r
2 \r
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
4 //\r
5 // Licensed under the Flora License, Version 1.0 (the License);\r
6 // you may not use this file except in compliance with the License.\r
7 // You may obtain a copy of the License at\r
8 //\r
9 //     http://floralicense.org/license/\r
10 //\r
11 // Unless required by applicable law or agreed to in writing, software\r
12 // distributed under the License is distributed on an AS IS BASIS,\r
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14 // See the License for the specific language governing permissions and\r
15 // limitations under the License.\r
16 //\r
17 \r
18 //!Internet\r
19 /*@file:        IntPresentationModelBase.h\r
20  *@brief:       This is the header file for PresentationModelBase class\r
21  */\r
22 \r
23 \r
24 #ifndef _INT_PRESENTATION_MODEL_BASE_H_\r
25 #define _INT_PRESENTATION_MODEL_BASE_H_\r
26 \r
27 #include <FAppApp.h>\r
28 #include <FBase.h>\r
29 #include <FIo.h>\r
30 \r
31 #include "IntTypes.h"\r
32 \r
33 /**\r
34  * @class       PresentationModelBase\r
35  * @brief       This class declares functions which will manage database\r
36  */\r
37 class PresentationModelBase\r
38 {\r
39 public:\r
40         /**\r
41          * Default constructor\r
42          */\r
43         PresentationModelBase(void);\r
44 \r
45         /**\r
46          * Default destructor\r
47          */\r
48         ~PresentationModelBase(void);\r
49 \r
50         /**\r
51          * Initialize storage service\r
52          */\r
53          result Initialize();\r
54 \r
55         /**\r
56          * Deinitialize storage service\r
57          */\r
58          result UnInitialize(void);\r
59 \r
60 public:\r
61 \r
62         /**\r
63          * This function deletes the database\r
64          *\r
65          * @return      An error code\r
66          * @param               No parameter\r
67          * @exception   E_SUCCESS               The database closed successfully\r
68          * @exception   E_FAILURE               The database is not closed successfully\r
69          */\r
70          result CloseDb(void);\r
71 \r
72          result CommitDb(void);\r
73 \r
74         /**\r
75          * This function creates the table in database\r
76          *\r
77          * @return      An error code\r
78          * @param               tableType               The name of the table\r
79          * @exception   E_SUCCESS               The table is created successfully in database\r
80          * @exception   E_FAILURE               The table creation in database is not successful\r
81          */\r
82          result CreateDBTables(BrowserDbTableTypes tableType);\r
83 \r
84         /**\r
85          * This function drops the existing tables from database\r
86          *\r
87          * @return      An error code\r
88          * @param               No parameter\r
89          * @exception   E_SUCCESS               The table is dropped successfully from database\r
90          * @exception   E_FAILURE               The table drop is unsuccessful\r
91          */\r
92          result DropDBTables(void);\r
93 \r
94          result DbIsNextRowPresent(bool& nextRowpresent);\r
95 \r
96         /**\r
97          * This function drops the existing tables from database\r
98          *\r
99          * @return      An error code\r
100          * @param               No parameter\r
101          * @exception   E_SUCCESS               The table is dropped successfully from database\r
102          * @exception   E_FAILURE               The table drop is unsuccessful\r
103          */\r
104          result ExecuteQuery(const Tizen::Base::String& pszFormatQuery, int& nRowCount);\r
105 \r
106          result GetColumn(int nIndex, Tizen::Base::String& strVal);\r
107 \r
108          result GetColumn(int nIndex, int& nIntVal);\r
109 \r
110          result GetColumn(int nIndex, double& dblVal);\r
111 \r
112          result GetColumn(int nIndex, Tizen::Base::DateTime& dtVal);\r
113 \r
114         static bool GetCurrentDateTime(Tizen::Base::DateTime& dt);\r
115 \r
116         /**\r
117          * This function gives the last inserted row id\r
118          *\r
119          * @return      An error code\r
120          * @param               tableName       The name of the table\r
121          * @param               rowId           The rowId in which last inserted rowId will be saved.\r
122          * @exception   E_SUCCESS               The method is successful\r
123          * @exception   E_FAILURE               The method is not successful\r
124          * @remarks             To work properly , the table name should be passed properly\r
125          */\r
126          result GetLastInsertedId(Tizen::Base::String& tableName, int& rowId);\r
127 \r
128         /**\r
129          * This function calls the CreateDBTables function for all the tables\r
130          *\r
131          * @return      An error code\r
132          * @param               No parameter\r
133          */\r
134          result InitializeDBTables(void);\r
135 \r
136          result IsNullColumn(int nIndex, bool& isColumNull);\r
137 \r
138         /**\r
139          * This function creates the database and constructs it.\r
140          *\r
141          * @return      An error code\r
142          * @param               No parameter\r
143          * @exception   E_SUCCESS               The database created successfully\r
144          * @exception   E_FAILURE               The database creation is failed\r
145          */\r
146          result OpenDb(void);\r
147 \r
148          result RollbackDb(void);\r
149 \r
150 public:\r
151      Tizen::Base::String DB_FILE_PATH;\r
152 \r
153         static const int MAX_DB_QUERY_SIZE;\r
154          static const int QUERY_TYPE_LENGTH;\r
155 \r
156 private:\r
157      bool __isBeginTransaction;\r
158 \r
159          Tizen::Io::Database* __pDataBase;\r
160          Tizen::Io::DbEnumerator* __pDbEnum;\r
161          Tizen::Io::DbStatement* __pDbStatement;\r
162 \r
163 };\r
164 \r
165  #endif //_INT_PRESENTATION_MODEL_BASE_H_\r