* @retval MSG_ERR_NOT_SUPPORTED Not supported
*/
-int msg_backup_message(msg_handle_t handle, msg_message_backup_type_t type, const char *backup_filepath);
+int msg_backup_message(msg_handle_t handle, msg_message_backup_type_t type, const char *backup_filepath) DEPRECATED;
/**
* @retval MSG_ERR_NOT_SUPPORTED Not supported
*/
-int msg_restore_message(msg_handle_t handle, const char *backup_filepath);
+int msg_restore_message(msg_handle_t handle, const char *backup_filepath) DEPRECATED;
/**
*/
int msg_set_conversation_to_read(msg_handle_t handle, msg_thread_id_t thread_id);
+
+
+/**
+ * @brief Gets a DB records with specified query.
+ *
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/message.read
+ *
+ * @remarks You must release @a db_res using msg_db_free().
+ * @remarks You should set @a query with SQL query string after 'SELECT'.
+ *
+ * @param[in] handle The Message handle
+ * @param[in] query The SQL SELECT query
+ * @param[out] db_res The result of SQL SELECT query
+ * @param[out] row_count The row count of result
+ * @param[out] col_count The column count of result
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval MSG_SUCCESS Success in operation
+ * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
+ * @retval MSG_ERR_STORAGE_ERROR Storage error
+ * @retval MSG_ERR_DB_BUSY DB operation is busy
+ * @retval MSG_ERR_DB_GETTABLE DB get table operation is failed
+ * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
+ * @retval MSG_ERR_NOT_SUPPORTED Not supported
+ *
+ * @see msg_db_free()
+ */
+int msg_db_select_with_query(msg_handle_t handle, const char *query, char ***db_res, int *row_count, int *col_count);
+
+/**
+ * @brief Release memory for result of SQL query.
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in] handle The Message handle
+ * @param[in] db_res The result of SQL SELECT query
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval MSG_SUCCESS Success in operation
+ * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
+ * @retval MSG_ERR_STORAGE_ERROR Storage error
+ * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
+ * @retval MSG_ERR_NOT_SUPPORTED Not supported
+ *
+ * @see msg_db_select_with_query()
+ */
+int msg_db_free(msg_handle_t handle, char **db_res);
/**
* @}
*/
/* ETC */
msg_error_t searchMessage(const char *pSearchString, msg_struct_list_s *pThreadViewList);
+
+ msg_error_t dbSelectWithQuery(const char *query, char ***db_res, int *row_count, int *col_count);
+ void dbFree(char **db_res);
+
msg_error_t getRejectMsgList(const char *pNumber, msg_struct_list_s *pRejectMsgList);
msg_error_t regStorageChangeCallback(msg_storage_change_cb onStorageChange, void *pUserParam);
msg_error_t getReportStatus(msg_message_id_t msg_id, msg_struct_list_s *report_list);
bool checkTableExist(const char *pTableName);
msg_error_t execQuery(const char *pQuery);
msg_error_t getTable(const char *pQuery, int *pRowCnt, int *pColumnCnt);
+ msg_error_t getTableWithResult(const char *pQuery, char ***res, int *pRowCnt, int *pColumnCnt);
void freeTable();
+ void freeTable(char **db_res);
msg_error_t bindText(const char *pBindStr, int index);
msg_error_t bindInt(const int pBindint, int index);
msg_error_t bindBlob(const void * pBindBlob, int size, int index);
msg_error_t MsgStoGetMessageList(const MSG_LIST_CONDITION_S *pListCond, msg_struct_list_s *pMsgList, int contactCount);
msg_error_t MsgStoGetMediaList(const msg_thread_id_t threadId, msg_list_handle_t *pMediaList);
+msg_error_t MsgStoDbSelectWithQuery(const char *query, char ***db_res, int *row_count, int *col_count);
+void MsgStoDbFree(char **db_res);
+
#ifdef FEATURE_SMS_CDMA
msg_error_t MsgStoClearUniquenessTable();
#endif
return err;
}
+
+EXPORT_API int msg_db_select_with_query(msg_handle_t handle, const char *query, char ***db_res, int *row_count, int *col_count)
+{
+ CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
+ msg_error_t err = MSG_SUCCESS;
+
+ if (handle == NULL || query == NULL)
+ return MSG_ERR_INVALID_PARAMETER;
+
+ MsgHandle* pHandle = (MsgHandle*)handle;
+
+ try {
+ err = pHandle->dbSelectWithQuery(query, db_res, row_count, col_count);
+ } catch (MsgException& e) {
+ MSG_FATAL("%s", e.what());
+ return MSG_ERR_STORAGE_ERROR;
+ }
+
+ return err;
+}
+
+
+EXPORT_API int msg_db_free(msg_handle_t handle, char **db_res)
+{
+ CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
+
+ if (handle == NULL || db_res == NULL)
+ return MSG_ERR_INVALID_PARAMETER;
+
+ MsgHandle* pHandle = (MsgHandle*)handle;
+
+ try {
+ pHandle->dbFree(db_res);
+ } catch (MsgException& e) {
+ MSG_FATAL("%s", e.what());
+ return MSG_ERR_STORAGE_ERROR;
+ }
+
+ return MSG_SUCCESS;
+}
+
+
+
EXPORT_API int msg_get_reject_msg_list(msg_handle_t handle, const char *phone_num, msg_struct_list_s *msg_reject_msg_list)
{
CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
return MSG_SUCCESS;
}
+
+
+msg_error_t MsgHandle::dbSelectWithQuery(const char *query, char ***db_res, int *row_count, int *col_count)
+{
+ msg_error_t err = MSG_SUCCESS;
+
+ err = MsgStoDbSelectWithQuery(query, db_res, row_count, col_count);
+
+ if (err != MSG_SUCCESS)
+ return err;
+
+ MSG_END();
+
+ return err;
+}
+
+
+void MsgHandle::dbFree(char **db_res)
+{
+ MsgStoDbFree(db_res);
+ MSG_END();
+}
if (ret == SQLITE_OK) {
MSG_DEBUG("DB Connect Success : [%p]", handle);
return MSG_SUCCESS;
+ } else if (ret == SQLITE_PERM){
+ MSG_DEBUG("DB Connect Fail [%d]", ret);
+ return MSG_ERR_PERMISSION_DENIED;
} else {
MSG_DEBUG("DB Connect Fail [%d]", ret);
return MSG_ERR_DB_CONNECT;
if (ret == SQLITE_OK) {
MSG_DEBUG("DB Connect Success : [%p]", handle);
return MSG_SUCCESS;
+ } else if (ret == SQLITE_PERM){
+ MSG_DEBUG("DB Connect Fail [%d]", ret);
+ return MSG_ERR_PERMISSION_DENIED;
} else {
MSG_DEBUG("DB Connect Fail [%d]", ret);
return MSG_ERR_DB_CONNECT;
}
+msg_error_t MsgDbHandler::getTableWithResult(const char *pQuery, char ***res, int *pRowCnt, int *pColumnCnt)
+{
+ int ret = 0;
+
+ *pRowCnt = 0;
+ if (pColumnCnt)
+ *pColumnCnt = 0;
+
+ MSG_DEBUG("[%s]", pQuery);
+ ret = sqlite3_get_table(handle, pQuery, res, pRowCnt, pColumnCnt, NULL);
+
+ if (ret == SQLITE_OK) {
+ if (*pRowCnt == 0) { /* when the no record return 'MSG_ERR_DB_NORECORD' */
+ MSG_DEBUG("No Query Result");
+ return MSG_ERR_DB_NORECORD;
+ }
+
+ MSG_DEBUG("Get Table Success");
+ return MSG_SUCCESS;
+ } else if (ret == SQLITE_BUSY) {
+ MSG_DEBUG("The database file is locked [%d]", ret);
+ return MSG_ERR_DB_BUSY;
+ } else {
+ MSG_DEBUG("Get Table Fail [%d]", ret);
+ return MSG_ERR_DB_GETTABLE;
+ }
+
+ return MSG_SUCCESS;
+}
+
void MsgDbHandler::freeTable()
{
if (result) {
}
}
+void MsgDbHandler::freeTable(char **db_res)
+{
+ if (db_res) {
+ sqlite3_free_table(db_res);
+ db_res = NULL;
+ }
+}
msg_error_t MsgDbHandler::bindText(const char *pBindStr, int index)
{
#include "MsgGconfWrapper.h"
#include "MsgUtilFunction.h"
#include "MsgUtilStorage.h"
+#include "MsgException.h"
#include <storage.h>
return MSG_SUCCESS;
}
+
+msg_error_t MsgStoDbSelectWithQuery(const char *szQuery, char ***db_res, int *row_count, int *col_count)
+{
+ MSG_BEGIN();
+
+ msg_error_t err = MSG_SUCCESS;
+
+ MsgDbHandler *dbHandle = getDbHandle();
+ err = dbHandle->connectReadOnly();
+ if (err != MSG_SUCCESS) {
+ MSG_ERR("db connect (read only) is failed [%d]", err);
+ return err;
+ }
+
+ char *zSQL = sqlite3_mprintf("SELECT %q;", szQuery);
+
+ if (zSQL) {
+ err = dbHandle->getTableWithResult((const char *)zSQL, db_res, row_count, col_count);
+ sqlite3_free(zSQL);
+ zSQL = NULL;
+ } else {
+ THROW(MsgException::INVALID_RESULT, "sqlite3_mprintf() is failed");
+ }
+
+ MSG_DEBUG("getTableWithResult :: row_count=[%d], col_count=[%d]", *row_count, *col_count);
+
+ if (err == MSG_ERR_DB_NORECORD) {
+ dbHandle->freeTable(*db_res);
+ err = MSG_SUCCESS;
+ } else if (err != MSG_SUCCESS) {
+ MSG_DEBUG("Fail to getTable().");
+ dbHandle->freeTable(*db_res);
+ }
+
+ return err;
+}
+
+
+void MsgStoDbFree(char **db_res)
+{
+ MsgDbHandler *dbHandle = getDbHandle();
+ dbHandle->freeTable(db_res);
+}
+
+
#ifdef FEATURE_SMS_CDMA
msg_error_t MsgStoClearUniquenessTable()
{