Tizen 2.1 base
[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.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 //!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
33 /**
34  * @class       PresentationModelBase
35  * @brief       This class declares functions which will manage database
36  */
37 class PresentationModelBase
38 {
39 public:
40         /**
41          * Default constructor
42          */
43         PresentationModelBase(void);
44
45         /**
46          * Default destructor
47          */
48         ~PresentationModelBase(void);
49
50         /**
51          * Initialize storage service
52          */
53         static result Initialize(void);
54
55         /**
56          * Deinitialize storage service
57          */
58         static result UnInitialize(void);
59
60 public:
61
62         /**
63          * This function deletes the database
64          *
65          * @return      An error code
66          * @param               No parameter
67          * @exception   E_SUCCESS               The database closed successfully
68          * @exception   E_FAILURE               The database is not closed successfully
69          */
70         static result CloseDb(void);
71
72         static result CommitDb(void);
73
74         /**
75          * This function creates the table in database
76          *
77          * @return      An error code
78          * @param               tableType               The name of the table
79          * @exception   E_SUCCESS               The table is created successfully in database
80          * @exception   E_FAILURE               The table creation in database is not successful
81          */
82         static result CreateDBTables(BrowserDbTableTypes tableType);
83
84         /**
85          * This function drops the existing tables from database
86          *
87          * @return      An error code
88          * @param               No parameter
89          * @exception   E_SUCCESS               The table is dropped successfully from database
90          * @exception   E_FAILURE               The table drop is unsuccessful
91          */
92         static result DropDBTables(void);
93
94         static result DbIsNextRowPresent(bool& nextRowpresent);
95
96         /**
97          * This function drops the existing tables from database
98          *
99          * @return      An error code
100          * @param               No parameter
101          * @exception   E_SUCCESS               The table is dropped successfully from database
102          * @exception   E_FAILURE               The table drop is unsuccessful
103          */
104         static result ExecuteQuery(const Tizen::Base::String& pszFormatQuery, int& nRowCount);
105
106         static result GetColumn(int nIndex, Tizen::Base::String& strVal);
107
108         static result GetColumn(int nIndex, int& nIntVal);
109
110         static result GetColumn(int nIndex, double& dblVal);
111
112         static result GetColumn(int nIndex, Tizen::Base::DateTime& dtVal);
113
114         static bool GetCurrentDateTime(Tizen::Base::DateTime& dt);
115
116         /**
117          * This function gives the last inserted row id
118          *
119          * @return      An error code
120          * @param               tableName       The name of the table
121          * @param               rowId           The rowId in which last inserted rowId will be saved.
122          * @exception   E_SUCCESS               The method is successful
123          * @exception   E_FAILURE               The method is not successful
124          * @remarks             To work properly , the table name should be passed properly
125          */
126         static result GetLastInsertedId(Tizen::Base::String& tableName, int& rowId);
127
128         /**
129          * This function calls the CreateDBTables function for all the tables
130          *
131          * @return      An error code
132          * @param               No parameter
133          */
134         static result InitializeDBTables(void);
135
136         static result IsNullColumn(int nIndex, bool& isColumNull);
137
138         /**
139          * This function creates the database and constructs it.
140          *
141          * @return      An error code
142          * @param               No parameter
143          * @exception   E_SUCCESS               The database created successfully
144          * @exception   E_FAILURE               The database creation is failed
145          */
146         static result OpenDb(void);
147
148         static result RollbackDb(void);
149
150 public:
151     static Tizen::Base::String DB_FILE_PATH;
152         static const int MAX_DB_QUERY_SIZE;
153         static const int QUERY_TYPE_LENGTH;
154
155 private:
156     static bool __isBeginTransaction;
157
158         static Tizen::Io::Database* __pDataBase;
159         static Tizen::Io::DbEnumerator* __pDbEnum;
160         static Tizen::Io::DbStatement* __pDbStatement;
161
162 };
163
164  #endif //_INT_PRESENTATION_MODEL_BASE_H_