summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhishek Vijay <abhishek.v@samsung.com>2019-06-27 16:35:29 +0530
committerAbhishek Vijay <abhishek.v@samsung.com>2019-09-23 20:11:54 +0530
commit5a92f742cb0fa0509195063e1c1e32992a12eba5 (patch)
tree7c2a086146767df918cbc3f939837f1fc4641830
parente41ce52a6af91f667fba40c9b371f0dcac934485 (diff)
downloadaccount-manager-5a92f742cb0fa0509195063e1c1e32992a12eba5.tar.gz
account-manager-5a92f742cb0fa0509195063e1c1e32992a12eba5.tar.bz2
account-manager-5a92f742cb0fa0509195063e1c1e32992a12eba5.zip
[NewAPI][Querying for deleted account information]
Change-Id: Ieb096a7e0fc57934c6b901f5d7ccc1a7b8cefa1b Signed-off-by: Abhishek Vijay <abhishek.v@samsung.com>
-rw-r--r--server/include/account-server-db.h4
-rw-r--r--server/src/account-server-db.c216
-rw-r--r--server/src/account-server.c28
3 files changed, 19 insertions, 229 deletions
diff --git a/server/include/account-server-db.h b/server/include/account-server-db.h
index 04f1cd0..a7b6a5c 100644
--- a/server/include/account-server-db.h
+++ b/server/include/account-server-db.h
@@ -31,11 +31,9 @@ GSList* _account_db_query_all(int pid, uid_t uid);
GSList* _account_type_query_all(void);
int _account_delete(int pid, uid_t uid, int account_id);
int _account_delete_from_db_by_user_name(int pid, uid_t uid, const char *user_name, const char *package_name);
-//int _account_delete_from_db_by_package_name(int pid, uid_t uid, const char *package_name, gboolean permission);
-int account_server_empty_deleted_account_info_tables(const char* del_account_table, const char* del_capability_table, const char* del_account_custom_table);
int _account_update_to_db_by_id(int pid, uid_t uid, account_s *account, int account_id);
int _account_get_total_count_from_db(gboolean include_hidden, int *count);
-int _account_query_account_by_account_id(int pid, uid_t uid, int account_db_id, account_s *account_record, bool *IsDeletedAccount);
+int _account_query_account_by_account_id(int pid, uid_t uid, int account_db_id, account_s *account_record, bool query_del_acc);
int _account_update_to_db_by_user_name(int pid, uid_t uid, account_s* account, const char *user_name, const char *package_name);
int _account_type_query_label_by_locale(const char* app_id, const char* locale, char **label);
GSList* _account_type_query_by_provider_feature(const char* key, int *error_code);
diff --git a/server/src/account-server-db.c b/server/src/account-server-db.c
index 6783cba..05a2192 100644
--- a/server/src/account-server-db.c
+++ b/server/src/account-server-db.c
@@ -1857,179 +1857,9 @@ CATCH:
return error_code;
}
-int account_server_empty_deleted_account_info_tables(const char* del_account_table, const char* del_capability_table,
- const char* del_account_custom_table)
+int _account_query_account_by_account_id(int pid, uid_t uid, int account_db_id, account_s *account_record, bool query_del_acc)
{
- _INFO("account_server_empty_deleted_account_info_tables start");
-
- account_stmt hstmt = NULL;
- int error_code = _ACCOUNT_ERROR_NONE;
- int rc = 0, record_count = 0;
- char query[ACCOUNT_SQL_LEN_MAX] = {0, };
-
- ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, _ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
-
- rc = _account_begin_transaction(g_hAccountDB);
- _INFO("after _account_begin_trasaction");
-
- if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) {
- ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB));
- return _ACCOUNT_ERROR_PERMISSION_DENIED;
- }
-
- if (rc == _ACCOUNT_ERROR_DATABASE_BUSY) {
- ACCOUNT_ERROR("database busy(%s)", _account_db_err_msg(g_hAccountDB));
- return _ACCOUNT_ERROR_DATABASE_BUSY;
- } else if (rc != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_ERROR("account_delete:_account_begin_transaction fail %d\n", rc);
- return rc;
- }
-
- /*del_account_table - check record count*/
- ACCOUNT_SNPRINTF(query, sizeof(query), "select count(*) from %s", del_account_table);
-
- record_count = _account_get_record_count(g_hAccountDB, query);
- if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) {
- ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB));
- return _ACCOUNT_ERROR_PERMISSION_DENIED;
- }
-
- _INFO("item count val - [%d] table - [%s]", record_count, del_account_table);
-
- if (record_count > 0) {
- /*clear deleted account table*/
- ACCOUNT_MEMSET(query, 0, sizeof(query));
- ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s", del_account_table);
-
- _INFO("clearing deleted-account-table - query[%s]", query);
-
- hstmt = _account_prepare_query(g_hAccountDB, query);
- if ((_account_db_err_code(g_hAccountDB) == SQLITE_PERM)) {
- _account_end_transaction(g_hAccountDB, false);
- ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB));
- return _ACCOUNT_ERROR_PERMISSION_DENIED;
- }
-
- if (hstmt == NULL) {
- _ERR("_account_svc_query_prepare(%s) failed(%s).\n", query, _account_db_err_msg(g_hAccountDB));
- error_code = _ACCOUNT_ERROR_DB_FAILED;
- goto END;
- }
-
- rc = _account_query_step(hstmt);
- if (rc != SQLITE_DONE) {
- _ERR("The record isn't found");
- error_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND;
- goto END;
- }
-
- rc = _account_query_finalize(hstmt);
- if (rc != _ACCOUNT_ERROR_NONE) {
- _ERR("finalize error");
- error_code = rc;
- goto END;
- }
-
- record_count = 0;
- }
-
- /*del_capability_table - check record count*/
- ACCOUNT_MEMSET(query, 0, sizeof(query));
- ACCOUNT_SNPRINTF(query, sizeof(query), "select count(*) from %s", del_capability_table);
-
- record_count = _account_get_record_count(g_hAccountDB, query);
- if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) {
- ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB));
- return _ACCOUNT_ERROR_PERMISSION_DENIED;
- }
-
- _INFO("item count val - [%d] table - [%s]", record_count, del_capability_table);
-
- if (record_count > 0) {
- /*clear deleted capability table*/
- ACCOUNT_MEMSET(query, 0, sizeof(query));
- ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s", del_capability_table);
-
- _INFO("clearing deleted-capability-table - query[%s]", query);
-
- hstmt = _account_prepare_query(g_hAccountDB, query);
- if (hstmt == NULL) {
- _ERR("_account_svc_query_prepare(%s) failed(%s).\n", query, _account_db_err_msg(g_hAccountDB));
- error_code = _ACCOUNT_ERROR_DB_FAILED;
- goto END;
- }
-
- rc = _account_query_step(hstmt);
- if (rc != SQLITE_DONE) {
- _ERR("The record isn't found");
- error_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND;
- goto END;
- }
-
- rc = _account_query_finalize(hstmt);
- if (rc != _ACCOUNT_ERROR_NONE) {
- _ERR("finalize error");
- error_code = rc;
- goto END;
- }
-
- record_count = 0;
- }
-
- /*del_account_custom_table - check record count*/
- ACCOUNT_MEMSET(query, 0, sizeof(query));
- ACCOUNT_SNPRINTF(query, sizeof(query), "select count(*) from %s", del_account_custom_table);
-
- record_count = _account_get_record_count(g_hAccountDB, query);
- if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) {
- ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB));
- return _ACCOUNT_ERROR_PERMISSION_DENIED;
- }
-
- _INFO("item count val - [%d] table - [%s]", record_count, del_account_custom_table);
-
- if (record_count > 0) {
- /*clear deleted account_custom table*/
- ACCOUNT_MEMSET(query, 0, sizeof(query));
- ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s", del_account_custom_table);
-
- _INFO("clearing deleted-account-custom-table - query[%s]", query);
-
- hstmt = _account_prepare_query(g_hAccountDB, query);
- if (hstmt == NULL) {
- _ERR("_account_svc_query_prepare(%s) failed(%s).\n", query, _account_db_err_msg(g_hAccountDB));
- error_code = _ACCOUNT_ERROR_DB_FAILED;
- goto END;
- }
-
- rc = _account_query_step(hstmt);
- if (rc != SQLITE_DONE) {
- _ERR("The record isn't found");
- error_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND;
- goto END;
- }
-
- rc = _account_query_finalize(hstmt);
- if (rc != _ACCOUNT_ERROR_NONE) {
- _ERR("finalize error");
- error_code = rc;
- goto END;
- }
- }
-
- rc = _account_end_transaction(g_hAccountDB, true);
- if (rc != _ACCOUNT_ERROR_NONE)
- _ERR("clear deleted account tables - fail [%d]", rc);
-
- hstmt = NULL;
- _INFO("account_server_empty_deleted_account_info_tables end");
-END:
- return error_code;
-}
-
-int _account_query_account_by_account_id(int pid, uid_t uid, int account_db_id, account_s *account_record, bool *IsDeletedAccount)
-{
- _INFO("_account_query_account_by_account_id() start, account_db_id=[%d]", account_db_id);
+ _INFO("_account_query_account_by_account_id() start, account_db_id=[%d], query_del_acc=[%d]", account_db_id, query_del_acc);
int error_code = _ACCOUNT_ERROR_NONE;
account_stmt hstmt = NULL;
@@ -2044,7 +1874,10 @@ int _account_query_account_by_account_id(int pid, uid_t uid, int account_db_id,
/* prepare query for account-table */
ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
- ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE _id = %d", ACCOUNT_TABLE, account_db_id);
+ if (!query_del_acc)
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE _id = %d", ACCOUNT_TABLE, account_db_id);
+ else
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE _id = %d", DELETED_ACCOUNT_TABLE, account_db_id);
_INFO("after _account_prepare_query, rc=[%d]", rc);
@@ -2062,40 +1895,7 @@ int _account_query_account_by_account_id(int pid, uid_t uid, int account_db_id,
ACCOUNT_DEBUG("after _account_query_step returned [%d]", rc);
-#ifndef ACCOUNT_QUERY_DELETED_ACCOUNT_INFORMATION
ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, _ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
-#else
- /*querying information from deleted_account_table*/
- if (rc != SQLITE_ROW) {
-
- /*free previous hstmt*/
- if (hstmt != NULL) {
- rc = _account_query_finalize(hstmt);
- ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
- hstmt = NULL;
- }
-
- ACCOUNT_DEBUG("checking account info in deleted_account_table");
-
- /* query from deleted-account-info table */
- ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
- ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE _id = %d", DELETED_ACCOUNT_TABLE, account_db_id);
-
- hstmt = _account_prepare_query(g_hAccountDB, query);
-
- rc = _account_db_err_code(g_hAccountDB);
- if (rc == SQLITE_PERM) {
- ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB));
- 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"));
-
- ACCOUNT_DEBUG("getting account info from deleted_account_table");
- *IsDeletedAccount = true;
- }
-#endif
while (rc == SQLITE_ROW) {
ACCOUNT_DEBUG("before _account_convert_column_to_account");
@@ -2111,11 +1911,11 @@ int _account_query_account_by_account_id(int pid, uid_t uid, int account_db_id,
ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
ACCOUNT_DEBUG("before _account_query_capability_by_account_id");
- _account_query_capability_by_account_id(g_hAccountDB, _account_add_capability_to_account_cb, account_record->id, (void*)account_record, *IsDeletedAccount);
+ _account_query_capability_by_account_id(g_hAccountDB, _account_add_capability_to_account_cb, account_record->id, (void*)account_record, query_del_acc);
ACCOUNT_DEBUG("after _account_query_capability_by_account_id");
ACCOUNT_DEBUG("before _account_query_custom_by_account_id");
- _account_query_custom_by_account_id(g_hAccountDB, _account_add_custom_to_account_cb, account_record->id, (void*)account_record, *IsDeletedAccount);
+ _account_query_custom_by_account_id(g_hAccountDB, _account_add_custom_to_account_cb, account_record->id, (void*)account_record, query_del_acc);
ACCOUNT_DEBUG("after _account_query_custom_by_account_id");
hstmt = NULL;
diff --git a/server/src/account-server.c b/server/src/account-server.c
index 5547a12..bf459f3 100644
--- a/server/src/account-server.c
+++ b/server/src/account-server.c
@@ -705,10 +705,10 @@ RETURN:
gboolean
account_manager_account_delete_from_db_by_package_name(AccountManager *object,
- GDBusMethodInvocation *invocation,
- const gchar *package_name,
- gboolean permission,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ const gchar *package_name,
+ gboolean permission,
+ gint uid)
{
_INFO("account_manager_account_delete_from_db_by_package_name start");
lifecycle_method_call_active();
@@ -1185,14 +1185,13 @@ RETURN:
gboolean
account_manager_handle_account_query_account_by_account_id(AccountManager *object, GDBusMethodInvocation *invocation,
- gint account_db_id, gint uid)
+ gint account_db_id, gint uid, gboolean query_del_acc)
{
- _INFO("account_manager_handle_account_query_account_by_account_id start");
+ _INFO("account_manager_handle_account_query_account_by_account_id start - account_db_id[%d], query_del_acc[%d]");
lifecycle_method_call_active();
GVariant* account_variant = NULL;
account_s* account_data = NULL;
- bool IsDeletedAccount = false;
guint pid = _get_client_pid(invocation);
@@ -1224,9 +1223,11 @@ account_manager_handle_account_query_account_by_account_id(AccountManager *objec
}
_INFO("before _account_query_account_by_account_id");
- return_code = _account_query_account_by_account_id(pid, (uid_t)uid, account_db_id, account_data, &IsDeletedAccount);
+ return_code = _account_query_account_by_account_id(pid, (uid_t)uid, account_db_id, account_data, query_del_acc);
_INFO("after _account_query_account_by_return_code=[%d]", return_code);
- _INFO("user_name = %s, user_data_txt[0] = %s, user_data_int[1] = %d", account_data->user_name, account_data->user_data_txt[0], account_data->user_data_int[1]);
+
+ _INFO("user_name = %s, user_data_txt[0] = %s, user_data_int[1] = %d",
+ account_data->user_name, account_data->user_data_txt[0], account_data->user_data_int[1]);
if (return_code == _ACCOUNT_ERROR_NONE)
account_variant = marshal_account(account_data);
@@ -1246,15 +1247,6 @@ RETURN:
account_manager_complete_account_query_account_by_account_id(object, invocation, account_variant);
}
- /*clear deleted account tables*/
- if (1/*IsDeletedAccount*/) {
- _INFO("clearing deleted account-info tables - account_tbl,capability_tbl,custom_tbl");
- return_code = account_server_empty_deleted_account_info_tables(DEL_ACCOUNT_TBL, DEL_CAPABILITY_TBL, DEL_ACCOUNT_CUSTOM_TBL);
-
- if (return_code != _ACCOUNT_ERROR_NONE)
- _ERR("failed to clear deleted account tables");
- }
-
return_code = _account_db_close();
if (return_code != _ACCOUNT_ERROR_NONE) {
ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);