Remove hardcoded path for multiuser support
[platform/core/messaging/msg-service.git] / include / utils / MsgSqliteWrapper.h
1 /*
2 * Copyright 2012-2013  Samsung Electronics Co., Ltd
3 *
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *    http://floralicense.org/license/
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef MSG_SQLITE_WRAPPER_H
18 #define MSG_SQLITE_WRAPPER_H
19
20 /*==================================================================================================
21                                     INCLUDE FILES
22 ==================================================================================================*/
23 #include <tzplatform_config.h>
24 #include "MsgTypes.h"
25
26
27 /*==================================================================================================
28                                     DEFINES
29 ==================================================================================================*/
30 #define MSGFW_DB_NAME                   tzplatform_mkpath(TZ_USER_DB,".msg_service.db")
31
32 #define MSGFW_MESSAGE_TABLE_NAME                                "MSG_MESSAGE_TABLE"
33 #define MSGFW_FOLDER_TABLE_NAME                                 "MSG_FOLDER_TABLE"
34 #define MSGFW_ADDRESS_TABLE_NAME                        "MSG_ADDRESS_TABLE"
35 #define MSGFW_CONVERSATION_TABLE_NAME           "MSG_CONVERSATION_TABLE"
36 #define MSGFW_SIM_MSG_TABLE_NAME                                "MSG_SIM_TABLE"
37 #define MSGFW_FILTER_TABLE_NAME                                 "MSG_FILTER_TABLE"
38 #define MSGFW_PUSH_MSG_TABLE_NAME                       "MSG_PUSH_TABLE"
39 #define MSGFW_CB_MSG_TABLE_NAME                         "MSG_CBMSG_TABLE"
40 #define MMS_PLUGIN_MESSAGE_TABLE_NAME           "MSG_MMS_MESSAGE_TABLE"
41 #define MSGFW_SYNCML_MSG_TABLE_NAME             "MSG_SYNCML_TABLE"
42 #define MSGFW_SMS_SENDOPT_TABLE_NAME            "MSG_SMS_SENDOPT_TABLE"
43 #define MSGFW_REPORT_TABLE_NAME                         "MSG_REPORT_TABLE"
44 #define MSGFW_PUSH_CONFIG_TABLE_NAME                    "MSG_PUSHCFG_TABLE"
45 #define MSGFW_MMS_PREVIEW_TABLE_NAME                    "MSG_MMS_PREVIEW_INFO_TABLE"
46
47 #define MSGFW_TMP_MSGID_TABLE_NAME                      "MSG_TMP_MSGID_TABLE"
48
49 #define MAX_QUERY_LEN                                   3072
50 #define MAX_FOLDER_NAME_LEN             20
51 #define MAX_ACCOUNT_NAME_LEN    51
52
53 #define MSGFW_DB_ESCAPE_CHAR            '\\'
54
55 /*==================================================================================================
56                                      FUNCTION PROTOTYPES
57 ==================================================================================================*/
58 void    MsgReleaseMemoryDB();
59 msg_error_t MsgConvertStrWithEscape(const char *input, char **output);
60 int     XSystem(const char *argv[]);
61
62 /*==================================================================================================
63                                      CLASS DEFINITIONS
64 ==================================================================================================*/
65 class MsgDbHandler
66 {
67 public:
68         MsgDbHandler();
69         ~MsgDbHandler();
70
71         msg_error_t connect();
72         msg_error_t disconnect();
73
74         bool checkTableExist(const char *pTableName);
75         msg_error_t execQuery(const char *pQuery);
76         msg_error_t getTable(const char *pQuery, int *pRowCnt);
77         void freeTable();
78         msg_error_t bindText(const char *pBindStr, int index);
79         msg_error_t bindBlob(const void * pBindBlob, int size, int index);
80         msg_error_t prepareQuery(const char *pQuery);
81         msg_error_t stepQuery();
82         void finalizeQuery();
83         int columnInt(int ColumnIndex);
84         const unsigned char* columnText(int ColumnIndex);
85         const void* columnBlob(int ColumnIndex);
86         msg_error_t beginTrans();
87         msg_error_t endTrans(bool Success);
88         int getColumnToInt(int RowIndex);
89         char getColumnToChar(int RowIndex);
90         void getColumnToString(int RowIndex, int Length, char *pString);
91         msg_error_t getRowId(const char *pTableName, unsigned int *pRowId);
92
93 private:
94
95         char **result;
96
97 };
98
99 #endif // MSG_SQLITE_WRAPPER_H
100