3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef DATA_ADAPTER_COMMON_H_
19 #define DATA_ADAPTER_COMMON_H_
36 #endif /* __cplusplus */
40 * @brief Common factor of Framework common database
43 /** @addtogroup data_adapter
50 #define SYNC_AGENT_DA_MO_HANDLER sqlite3
53 * @brief Data Adapter handler
55 #define SYNC_AGENT_DA_HANDLER sqlite3
58 * @brief Database retry count
60 #define SYNC_AGENT_DA_RETRY_COUNT 10
63 * @brief Max DB query length
65 #define SYNC_AGENT_DA_MAX_QUERY_LENGTH 2048
68 * @brief Max number account that sync-agent framework supports
70 #define SYNC_AGENT_DA_MAX_ACCOUNT 10
73 * @brief Redefined memset()
75 #define SYNC_AGENT_DA_MEMORY_SET(ptr) memset(ptr, 0x00, sizeof(ptr));
78 * @brief Redefined malloc()
80 #define SYNC_AGENT_DA_MEMORY_MALLOC(type, size, count) (type)malloc(size*count)
83 * @brief Redefined calloc()
85 #define SYNC_AGENT_DA_MEMORY_CALLOC(type, size, count) (type)calloc(count, size)
88 * @brief Redefined free()
90 #define SYNC_AGENT_DA_MEMORY_FREE(src) \
97 * @brief Redefined strdup()
99 #define SYNC_AGENT_DA_STRDUP(src) (src == NULL) ? NULL : strdup(src);
102 * @brief Redefined atoi()
104 #define SYNC_AGENT_DA_ATOI(src) (src == NULL) ? 0 : atoi(src);
107 * @brief Macro for fetching self thread id
109 #define SYNC_AGENT_DA_GET_THREAD_ID pthread_self()
112 * @brief Redefined sqlite3 connection
114 typedef sqlite3_stmt *daci_stmt;
117 * @brief Enumerations of database peak type
120 SYNC_AGENT_DA_PEAK_TYPE_ON = 601,
122 SYNC_AGENT_DA_PEAK_TYPE_ON_N_OFF,
123 /**< peak type N off */
124 SYNC_AGENT_DA_PEAK_TYPE_OFF
125 /**< peak type off */
126 } sync_agent_da_peak_type_e;
129 * @brief Enumerations of database transaction
132 SYNC_AGENT_DA_TRANSACTION_COMMIT,
134 SYNC_AGENT_DA_TRANSACTION_ROLLBACK
135 /**< means rollback */
136 } sync_agent_da_transaction_e;
139 * @brief Enumerations of common db's table list
142 SYNC_AGENT_DA_TABLE_NAME_ACCOUNT,
143 /**< means account_tbl */
144 SYNC_AGENT_DA_TABLE_NAME_FOLDER,/**< means folder_tbl */
145 SYNC_AGENT_DA_TABLE_NAME_ITEM,
146 /**< means item_tbl */
147 SYNC_AGENT_DA_TABLE_NAME_CONFIG,/**< means config_tbl */
148 SYNC_AGENT_DA_TABLE_NAME_ACCOUNT_ITEM_CHANGELOG,/**< means account_item_changelog_tbl */
149 SYNC_AGENT_DA_TABLE_NAME_LAST_ANCHOR,
150 /**< means last_anchor_tbl */
151 SYNC_AGENT_DA_TABLE_NAME_MAPPING,
152 /**< means mapping_tbl */
153 SYNC_AGENT_DA_TABLE_NAME_ID_PROVIDER,
154 /**< means id_provider_tbl */
155 SYNC_AGENT_DA_TABLE_NAME_ID_PAGE,
156 /**< means id_page_tbl */
158 SYNC_AGENT_DA_TABLE_NAME_MAX
159 /**< count of common database's tables */
160 } sync_agent_da_table_name_e;
163 * @brief Structure of Item information
169 /**< service data connector pluIn's ID described in F/W config file */
170 char *serviceId;/**< service item id */
171 int operationId;/**< operation type - add, delete, update */
173 /**< user defined status of item */
174 } sync_agent_da_item_info_s;
177 * @brief Structure of Item id's container
184 } sync_agent_da_id_list_s;
187 * @brief Structure of framework id provider instance
190 unsigned int id_provider_code;
191 /**< ID of id provider - this described in F/W configuration file */
192 unsigned int id_capacity; /**< max ID count possible id provider generate - this described in F/W configuration file */
193 unsigned int bit_per_page; /**< most number of bit per one page */
194 unsigned int last_id;
195 /**< current last provided ID */
196 unsigned int free_bit_cnt; /**< the number of IDs that can be issued */
197 } sync_agent_da_id_provider_s;
200 * @brief Structure of framework id page instance
203 unsigned int page_index;
204 /**< index of page */
205 unsigned int id_provider_code;
206 /**< ID of id provider - this described in F/W configuration file */
208 /**< real construction of ID issued */
209 } sync_agent_da_id_page_s;
217 #endif /* __cplusplus */
218 #endif /* SYNC_AGENT_DA_COMMON_H_ */