adding param for handling deleted account information 97/207997/1 accepted/tizen/unified/20190617.112002 submit/tizen/20190615.084842 submit/tizen/20190615.085031
authorAbhishek Vijay <abhishek.v@samsung.com>
Sat, 15 Jun 2019 08:27:41 +0000 (13:57 +0530)
committerAbhishek Vijay <abhishek.v@samsung.com>
Sat, 15 Jun 2019 08:27:41 +0000 (13:57 +0530)
Change-Id: I2563985156c312852547018a28fbc089ec09f6c9
Signed-off-by: Abhishek Vijay <abhishek.v@samsung.com>
server/src/account-server-db.c

index bf2d727..94def44 100644 (file)
@@ -781,11 +781,11 @@ static int _account_compare_old_record_by_user_name(account_s *new_account, cons
        hstmt = NULL;
 
        // get capability
-       error_code = _account_query_capability_by_account_id(g_hAccountDB, _account_add_capability_to_account_cb, old_account->id, (void*)old_account);
+       error_code = _account_query_capability_by_account_id(g_hAccountDB, _account_add_capability_to_account_cb, old_account->id, (void*)old_account, false);
        ACCOUNT_CATCH_ERROR((error_code == _ACCOUNT_ERROR_NONE), {}, error_code, ("account_query_capability_by_account_id error"));
 
        // get custom text
-       error_code = _account_query_custom_by_account_id(g_hAccountDB, _account_add_custom_to_account_cb, old_account->id, (void*)old_account);
+       error_code = _account_query_custom_by_account_id(g_hAccountDB, _account_add_custom_to_account_cb, old_account->id, (void*)old_account, false);
        ACCOUNT_CATCH_ERROR((error_code == _ACCOUNT_ERROR_NONE), {}, error_code, ("_account_query_custom_by_account_id error"));
 
        // compare
@@ -1241,11 +1241,11 @@ static int _account_compare_old_record(account_s *new_account, int account_id)
        hstmt = NULL;
 
        // get capability
-       error_code = _account_query_capability_by_account_id(g_hAccountDB, _account_add_capability_to_account_cb, old_account->id, (void*)old_account);
+       error_code = _account_query_capability_by_account_id(g_hAccountDB, _account_add_capability_to_account_cb, old_account->id, (void*)old_account, false);
        ACCOUNT_CATCH_ERROR((error_code == _ACCOUNT_ERROR_NONE), {}, error_code, ("account_query_capability_by_account_id error"));
 
        // get custom text
-       error_code = _account_query_custom_by_account_id(g_hAccountDB, _account_add_custom_to_account_cb, old_account->id, (void*)old_account);
+       error_code = _account_query_custom_by_account_id(g_hAccountDB, _account_add_custom_to_account_cb, old_account->id, (void*)old_account, false);
        ACCOUNT_CATCH_ERROR((error_code == _ACCOUNT_ERROR_NONE), {}, error_code, ("_account_query_custom_by_account_id error"));
 
        // compare
@@ -1760,8 +1760,8 @@ GSList* _account_db_query_all(int pid, uid_t uid)
        for (iter = account_list; iter != NULL; iter = g_slist_next(iter)) {
                account_s *account = NULL;
                account = (account_s*)iter->data;
-               _account_query_capability_by_account_id(g_hAccountDB, _account_add_capability_to_account_cb, account->id, (void*)account);
-               _account_query_custom_by_account_id(g_hAccountDB, _account_add_custom_to_account_cb, account->id, (void*)account);
+               _account_query_capability_by_account_id(g_hAccountDB, _account_add_capability_to_account_cb, account->id, (void*)account, false);
+               _account_query_custom_by_account_id(g_hAccountDB, _account_add_custom_to_account_cb, account->id, (void*)account, false);
        }
 
 CATCH:
@@ -2019,10 +2019,6 @@ int _account_query_account_by_account_id(int pid, uid_t uid, int account_db_id,
 
        /*querying information from deleted_account_table*/
        if (rc != SQLITE_ROW) {
-               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);
 
                /*free previous hstmt*/
                if (hstmt != NULL) {
@@ -2031,6 +2027,12 @@ int _account_query_account_by_account_id(int pid, uid_t uid, int account_db_id,
                        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);
@@ -2060,11 +2062,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);
+       _account_query_capability_by_account_id(g_hAccountDB, _account_add_capability_to_account_cb, account_record->id, (void*)account_record, *IsDeletedAccount);
        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);
+       _account_query_custom_by_account_id(g_hAccountDB, _account_add_custom_to_account_cb, account_record->id, (void*)account_record, *IsDeletedAccount);
        ACCOUNT_DEBUG("after _account_query_custom_by_account_id");
 
        hstmt = NULL;
@@ -2181,8 +2183,8 @@ GList* _account_query_account_by_user_name(int pid, uid_t uid, const char *user_
 
                account_s *testaccount = (account_s*)iter->data;
 
-               _account_query_capability_by_account_id(g_hAccountDB, _account_add_capability_to_account_cb, testaccount->id, (void*)testaccount);
-               _account_query_custom_by_account_id(g_hAccountDB, _account_add_custom_to_account_cb, testaccount->id, (void*)testaccount);
+               _account_query_capability_by_account_id(g_hAccountDB, _account_add_capability_to_account_cb, testaccount->id, (void*)testaccount, false);
+               _account_query_custom_by_account_id(g_hAccountDB, _account_add_custom_to_account_cb, testaccount->id, (void*)testaccount, false);
        }
 
        *error_code = _ACCOUNT_ERROR_NONE;
@@ -2297,8 +2299,8 @@ _account_query_account_by_capability(int pid, uid_t uid, const char* capability_
                //account = (account_h)iter->data;
                account_s* testaccount = (account_s*)iter->data;
 
-               _account_query_capability_by_account_id(g_hAccountDB, _account_add_capability_to_account_cb, testaccount->id, (void*)testaccount);
-               _account_query_custom_by_account_id(g_hAccountDB, _account_add_custom_to_account_cb, testaccount->id, (void*)testaccount);
+               _account_query_capability_by_account_id(g_hAccountDB, _account_add_capability_to_account_cb, testaccount->id, (void*)testaccount, false);
+               _account_query_custom_by_account_id(g_hAccountDB, _account_add_custom_to_account_cb, testaccount->id, (void*)testaccount, false);
 
        }
 
@@ -2410,8 +2412,8 @@ GList* _account_query_account_by_capability_type(int pid, uid_t uid, const char*
        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(g_hAccountDB, _account_add_capability_to_account_cb, testaccount->id, (void*)testaccount);
-               _account_query_custom_by_account_id(g_hAccountDB, _account_add_custom_to_account_cb, testaccount->id, (void*)testaccount);
+               _account_query_capability_by_account_id(g_hAccountDB, _account_add_capability_to_account_cb, testaccount->id, (void*)testaccount, false);
+               _account_query_custom_by_account_id(g_hAccountDB, _account_add_custom_to_account_cb, testaccount->id, (void*)testaccount, false);
 
        }
 
@@ -2677,8 +2679,8 @@ static int _account_query_account_by_username_and_package(const char* username,
 
        rc = _account_query_finalize(hstmt);
        ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
-       _account_query_capability_by_account_id(g_hAccountDB, _account_add_capability_to_account_cb, account_record->id, (void*)account_record);
-       _account_query_custom_by_account_id(g_hAccountDB, _account_add_custom_to_account_cb, account_record->id, (void*)account_record);
+       _account_query_capability_by_account_id(g_hAccountDB, _account_add_capability_to_account_cb, account_record->id, (void*)account_record, false);
+       _account_query_custom_by_account_id(g_hAccountDB, _account_add_custom_to_account_cb, account_record->id, (void*)account_record, false);
 
        hstmt = NULL;
        error_code = _ACCOUNT_ERROR_NONE;