"Value TEXT "\
");"
-/* DELETED_TRIGGER_QUERY */
-/* ACCOUNT_TABLE */
+/* TRIGGER FOR DELETED_ACCOUNT_TABLE */
#define TRIGGER_QUERY_DEL_ACC_TAB "create trigger aft_acc_del \n"\
"after delete on account \n"\
"begin \n"\
");"\
"end;"
-/* CAPABILITY_TABLE */
+/* TRIGGER FOR DELETED_CAPABILITY_TABLE */
#define TRIGGER_QUERY_DEL_CAP_TAB "create trigger aft_capa_del \n"\
"after delete on capability \n"\
"begin \n"\
");"\
"end;"
-/* ACCOUNT_CUSTOM_TABLE */
+/* TRIGGER_FOR_ACCOUNT_CUSTOM_TABLE */
#define TRIGGER_QUERY_DEL_ACUST_TAB "create trigger aft_cust_del \n"\
"after delete on account_custom \n"\
"begin \n"\
int _account_get_represented_appid_from_db(sqlite3 *account_user_db, sqlite3 *account_global_db, const char *appid, uid_t uid, char **verified_appid);
int _account_check_appid_group_with_package_name(const char *appid, char *package_name, uid_t uid);
-int _account_query_capability_by_account_id(sqlite3 *account_db_handle, account_add_capability_cb callback, int account_id, void *user_data);
-int _account_query_custom_by_account_id(sqlite3 *account_db_handle, account_add_custom_cb callback, int account_id, void *user_data);
+int _account_query_by_account_id(sqlite3 *account_db_handle, account_add_capability_cb capability_cb, account_add_custom_cb custom_cb, int account_id, void *user_data, bool is_deleted);
+int _account_query_capability_by_account_id(sqlite3 *account_db_handle, account_add_capability_cb callback, int account_id, void *user_data, bool is_deleted);
+int _account_query_custom_by_account_id(sqlite3 *account_db_handle, account_add_custom_cb callback, int account_id, void *user_data, bool is_deleted);
GList *_account_query_account_by_package_name(sqlite3 *account_db_handle, const char *package_name, int *error_code, int pid, uid_t uid);
int _account_check_duplicated(sqlite3 *account_db_handle, account_s *data, const char *verified_appid, uid_t uid);
}
int _account_query_by_account_id(sqlite3 *account_db_handle, account_add_capability_cb capability_cb,
- account_add_custom_cb custom_cb, int account_id, void *user_data)
+ account_add_custom_cb custom_cb, int account_id, void *user_data, bool is_deleted)
{
_INFO("_account_query_by_account_id start");
/*check in proper tables of Capability & Account_Custom*/
if (capability_cb != NULL) {
- _INFO("account query capability by account-id - original table");
- ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE _id = %d", CAPABILITY_TABLE, account_id);
+ if (!is_deleted) {
+ _INFO("account query capability by account-id - original capability table");
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE account_id = %d", CAPABILITY_TABLE, account_id);
+ } else {
+ _INFO("account query capability by account-id - deleted capability table");
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE account_id = %d", DELETED_CAPABILITY_TABLE, account_id);
+ }
query_for_capability = true;
} else if (custom_cb != NULL) {
- _INFO("account query custom by account-id - original table");
- ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE AccountId = %d", ACCOUNT_CUSTOM_TABLE, account_id);
+ if (!is_deleted) {
+ _INFO("account query capability by account-id - original custom table");
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE AccountId = %d", ACCOUNT_CUSTOM_TABLE, account_id);
+ } else {
+ _INFO("account query capability by account-id - deleted custom table");
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE AccountId = %d", DELETED_ACCOUNT_CUSTOM_TABLE, account_id);
+ }
query_for_custom = true;
}
}
rc = _account_query_step(hstmt);
- if (rc != SQLITE_ROW) {
- rc = _account_query_finalize(hstmt);
- ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
- hstmt = NULL;
- }
-
- if ((rc != SQLITE_ROW) && query_for_capability) {
- _INFO("account query capability by account-id - deleted capability table");
- ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
- ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE _id = %d", DELETED_CAPABILITY_TABLE, account_id);
- } else if ((rc != SQLITE_ROW) && query_for_custom) {
- _INFO("account query capability by account-id - deleted account_custom table");
- ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
- ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE AccountId = %d", DELETED_ACCOUNT_CUSTOM_TABLE, account_id);
- }
-
- hstmt = _account_prepare_query(account_db_handle, query);
-
- if (_account_db_err_code(account_db_handle) == SQLITE_PERM) {
- ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(account_db_handle));
- return _ACCOUNT_ERROR_PERMISSION_DENIED;
- }
-
- rc = _account_query_step(hstmt);
+ ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, _ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
if (query_for_capability) {
account_capability_s *capability_record = NULL;
return error_code;
}
-int _account_query_capability_by_account_id(sqlite3 *account_db_handle, account_add_capability_cb callback, int account_id, void *user_data)
+int _account_query_capability_by_account_id(sqlite3 *account_db_handle, account_add_capability_cb callback, int account_id, void *user_data, bool is_deleted)
{
int error_code = _ACCOUNT_ERROR_NONE;
- error_code = _account_query_by_account_id(account_db_handle, callback, NULL, account_id, user_data);
+ error_code = _account_query_by_account_id(account_db_handle, callback, NULL, account_id, user_data, is_deleted);
ACCOUNT_RETURN_VAL((error_code == _ACCOUNT_ERROR_NONE), {}, error_code, ("_account_query_by_account_id failed for capability"));
return error_code;
}
-int _account_query_custom_by_account_id(sqlite3 *account_db_handle, account_add_custom_cb callback, int account_id, void *user_data)
+int _account_query_custom_by_account_id(sqlite3 *account_db_handle, account_add_custom_cb callback, int account_id, void *user_data, bool is_deleted)
{
int error_code = _ACCOUNT_ERROR_NONE;
- error_code = _account_query_by_account_id(account_db_handle, NULL, callback, account_id, user_data);
+ error_code = _account_query_by_account_id(account_db_handle, NULL, callback, account_id, user_data, is_deleted);
ACCOUNT_RETURN_VAL((error_code == _ACCOUNT_ERROR_NONE), {}, error_code, ("_account_query_by_account_id failed for custom"));
for (iter = account_head->account_list; iter != NULL; iter = g_list_next(iter)) {
account_s *testaccount = (account_s *)iter->data;
- _account_query_capability_by_account_id(account_db_handle, _account_add_capability_to_account_cb, testaccount->id, (void *)testaccount);
- _account_query_custom_by_account_id(account_db_handle, _account_add_custom_to_account_cb, testaccount->id, (void *)testaccount);
+ _account_query_capability_by_account_id(account_db_handle, _account_add_capability_to_account_cb, testaccount->id, (void *)testaccount, false);
+ _account_query_custom_by_account_id(account_db_handle, _account_add_custom_to_account_cb, testaccount->id, (void *)testaccount, false);
}
*error_code = _ACCOUNT_ERROR_NONE;