diff options
author | Ickhee Woo <ickhee.woo@samsung.com> | 2016-12-02 08:47:23 +0900 |
---|---|---|
committer | Ickhee Woo <ickhee.woo@samsung.com> | 2016-12-02 11:42:10 +0900 |
commit | ebcca4248a864b8cb4a94dd321c82ad46fb5b721 (patch) | |
tree | 0cc517b3835fcf9396eaa19b0a388d29ea7bf617 | |
parent | e1531a8d5b37dad209c99e29bf3a900c675df424 (diff) | |
download | account-manager-ebcca4248a864b8cb4a94dd321c82ad46fb5b721.tar.gz account-manager-ebcca4248a864b8cb4a94dd321c82ad46fb5b721.tar.bz2 account-manager-ebcca4248a864b8cb4a94dd321c82ad46fb5b721.zip |
fix code for coding convention
Change-Id: If48877ddb227bc962c00b1571c9f3396cc37b3e5
Signed-off-by: Ickhee Woo <ickhee.woo@samsung.com>
-rw-r--r-- | packaging/account-manager.spec | 2 | ||||
-rw-r--r-- | server/include/account-server-db.h | 2 | ||||
-rw-r--r-- | server/include/account_type.h | 66 | ||||
-rw-r--r-- | server/src/account-server-db.c | 1076 | ||||
-rw-r--r-- | server/src/account-server.c | 1192 | ||||
-rw-r--r-- | server/src/lifecycle.c | 5 |
6 files changed, 1003 insertions, 1340 deletions
diff --git a/packaging/account-manager.spec b/packaging/account-manager.spec index ac8634c..0c2261c 100644 --- a/packaging/account-manager.spec +++ b/packaging/account-manager.spec @@ -1,6 +1,6 @@ Name: account-manager Summary: Account Manager -Version: 0.1.10 +Version: 0.1.11 Release: 1 Group: Social & Content/Other License: Apache-2.0 diff --git a/server/include/account-server-db.h b/server/include/account-server-db.h index 1a5bcb2..f70d2c3 100644 --- a/server/include/account-server-db.h +++ b/server/include/account-server-db.h @@ -47,7 +47,7 @@ int _account_update_sync_status_by_id(uid_t uid, int account_db_id, const int sy GSList* _account_type_query_provider_feature_by_app_id(const char* app_id, int *error_code); bool _account_type_query_supported_feature(const char* app_id, const char* capability, int *error_code); int _account_type_update_to_db_by_app_id(account_type_s *account_type, const char* app_id); -GSList* _account_type_get_label_list_by_app_id(const char* app_id, int *error_code ); +GSList* _account_type_get_label_list_by_app_id(const char* app_id, int *error_code); int _account_type_query_by_app_id(const char* app_id, account_type_s **account_type_record); int _account_update_to_db_by_id_ex(account_s *account, int account_id); diff --git a/server/include/account_type.h b/server/include/account_type.h index d1be70d..e30d6fb 100644 --- a/server/include/account_type.h +++ b/server/include/account_type.h @@ -24,46 +24,38 @@ extern "C" { #endif +typedef enum { + _ACCOUNT_CAPABILITY_STATE_INVALID = 0, /**< Account capability is invalid */ + _ACCOUNT_CAPABILITY_DISABLED, /**< Account capability is disabled */ + _ACCOUNT_CAPABILITY_ENABLED, /**< Account capability is enabled */ + _ACCOUNT_CAPABILITY_STATE_MAX +} _account_capability_state_e; -typedef enum -{ - _ACCOUNT_CAPABILITY_STATE_INVALID = 0, /**< Account capability is invalid */ - _ACCOUNT_CAPABILITY_DISABLED, /**< Account capability is disabled */ - _ACCOUNT_CAPABILITY_ENABLED, /**< Account capability is enabled */ - _ACCOUNT_CAPABILITY_STATE_MAX -} -_account_capability_state_e; - -typedef enum -{ - _ACCOUNT_SECRECY_INVALID = 0, /**< Account secrecy is invalid */ - _ACCOUNT_SECRECY_INVISIBLE, /**< Account is not visible */ - _ACCOUNT_SECRECY_VISIBLE, /**< Account is visible */ - _ACCOUNT_SECRECY_MAX -} -_secrecy_state_e; +typedef enum { + _ACCOUNT_SECRECY_INVALID = 0, /**< Account secrecy is invalid */ + _ACCOUNT_SECRECY_INVISIBLE, /**< Account is not visible */ + _ACCOUNT_SECRECY_VISIBLE, /**< Account is visible */ + _ACCOUNT_SECRECY_MAX +} _secrecy_state_e; -typedef enum -{ - _ACCOUNT_SYNC_INVALID = 0, /**< Account sync is invalid */ - _ACCOUNT_SYNC_NOT_SUPPORT, /**< Account sync not supported */ - _ACCOUNT_SYNC_STATUS_OFF, /**< Account sync supported but all synchronization functionalities are off */ - _ACCOUNT_SYNC_STATUS_IDLE, /**< Account sync support and sync status is idle */ - _ACCOUNT_SYNC_STATUS_RUNNING, /**< Account sync support and sync status is running */ - _ACCOUNT_SUPPORTS_SYNC, /**< NOT USED, WILL BE REMOVED TO PREVENT BUILD ERROR */ - _ACCOUNT_NOT_SUPPORTS_SYNC, /**< NOT USED, WILL BE REMOVED TO PREVENT BUILD ERROR */ - _ACCOUNT_SYNC_MAX -} -_account_sync_state_e; +typedef enum { + _ACCOUNT_SYNC_INVALID = 0, /**< Account sync is invalid */ + _ACCOUNT_SYNC_NOT_SUPPORT, /**< Account sync not supported */ + _ACCOUNT_SYNC_STATUS_OFF, /**< Account sync supported but all synchronization functionalities are off */ + _ACCOUNT_SYNC_STATUS_IDLE, /**< Account sync support and sync status is idle */ + _ACCOUNT_SYNC_STATUS_RUNNING, /**< Account sync support and sync status is running */ + _ACCOUNT_SUPPORTS_SYNC, /**< NOT USED, WILL BE REMOVED TO PREVENT BUILD ERROR */ + _ACCOUNT_NOT_SUPPORTS_SYNC, /**< NOT USED, WILL BE REMOVED TO PREVENT BUILD ERROR */ + _ACCOUNT_SYNC_MAX +} _account_sync_state_e; -typedef enum -{ - _ACCOUNT_AUTH_TYPE_INVALID = 0, /**< Auth type is invalid */ - _ACCOUNT_AUTH_TYPE_XAUTH, /**< XAuth type */ - _ACCOUNT_AUTH_TYPE_OAUTH, /**< OAuth type */ - _ACCOUNT_AUTH_TYPE_CLIENT_LOGIN, /**< Client-Login type */ - _ACCOUNT_AUTH_TYPE_MAX -}_account_auth_type_e; +typedef enum { + _ACCOUNT_AUTH_TYPE_INVALID = 0, /**< Auth type is invalid */ + _ACCOUNT_AUTH_TYPE_XAUTH, /**< XAuth type */ + _ACCOUNT_AUTH_TYPE_OAUTH, /**< OAuth type */ + _ACCOUNT_AUTH_TYPE_CLIENT_LOGIN, /**< Client-Login type */ + _ACCOUNT_AUTH_TYPE_MAX +} _account_auth_type_e; #define _ACCOUNT_NOTI_NAME_INSERT "insert" diff --git a/server/src/account-server-db.c b/server/src/account-server-db.c index 27161da..0e4eb99 100644 --- a/server/src/account-server-db.c +++ b/server/src/account-server-db.c @@ -92,9 +92,8 @@ int _account_get_current_appid_cb(const pkgmgrinfo_appinfo_h handle, void *user_ pkgmgr_ret = pkgmgrinfo_appinfo_get_appid(handle, &appid); - if( pkgmgr_ret != PMINFO_R_OK ){ + if (pkgmgr_ret != PMINFO_R_OK) ACCOUNT_DEBUG("pkgmgrinfo_appinfo_get_appid(%d)", pkgmgr_ret); - } item = _account_dup_text(appid); *appid_list = g_slist_append(*appid_list, item); @@ -122,8 +121,9 @@ static inline int __read_proc(const char *path, char *buf, int size) ACCOUNT_ERROR("fd read error(%d)\n", fd); close(fd); return -1; - } else + } else { buf[ret] = 0; + } close(fd); @@ -145,19 +145,18 @@ char *_account_get_proc_cmdline_bypid(int pid) return strdup(buf); } - /* static int _account_execute_query_from_global_db(const char *query) { int rc = -1; char* pszErrorMsg = NULL; - if(!query){ + if (!query) { ACCOUNT_ERROR("NULL query\n"); return _ACCOUNT_ERROR_QUERY_SYNTAX_ERROR; } - if(!g_hAccountGlobalDB){ + if (!g_hAccountGlobalDB) { ACCOUNT_ERROR("Global DB is not opened\n"); return _ACCOUNT_ERROR_DB_NOT_OPENED; } @@ -171,6 +170,7 @@ static int _account_execute_query_from_global_db(const char *query) return rc; } */ + /* static int _account_begin_transaction_from_global_db(void) { @@ -179,10 +179,10 @@ static int _account_begin_transaction_from_global_db(void) ret = _account_execute_query_from_global_db("BEGIN IMMEDIATE TRANSACTION"); - if (ret == SQLITE_BUSY){ + if (ret == SQLITE_BUSY) { ACCOUNT_ERROR(" sqlite3 busy = %d", ret); return _ACCOUNT_ERROR_DATABASE_BUSY; - } else if(ret != SQLITE_OK) { + } else if (ret != SQLITE_OK) { ACCOUNT_ERROR("_account_svc_begin_transaction_in_global_db fail :: %d", ret); return _ACCOUNT_ERROR_DB_FAILED; } @@ -205,12 +205,12 @@ static int _account_end_transaction_from_global_db(bool is_success) ACCOUNT_DEBUG("_account_end_transaction ROLLBACK"); } - if(ret == SQLITE_PERM) { + if (ret == SQLITE_PERM) { ACCOUNT_ERROR("Account permission denied :: %d", ret); return _ACCOUNT_ERROR_PERMISSION_DENIED; } - if (ret == SQLITE_BUSY){ + if (ret == SQLITE_BUSY) { ACCOUNT_DEBUG(" sqlite3 busy = %d", ret); return _ACCOUNT_ERROR_DATABASE_BUSY; } @@ -246,9 +246,9 @@ int _account_global_db_open(void) ACCOUNT_DEBUG("db_util_close(g_hAccountGlobalDB2) fail ret = %d", ret); ACCOUNT_DEBUG("before _account_global_db_open()"); -// if(mode == ACCOUNT_DB_OPEN_READWRITE) +// if (mode == ACCOUNT_DB_OPEN_READWRITE) // rc = db_util_open(account_db_path, &g_hAccountDB, DB_UTIL_REGISTER_HOOK_METHOD); -// else if(mode == ACCOUNT_DB_OPEN_READONLY) +// else if (mode == ACCOUNT_DB_OPEN_READONLY) rc = db_util_open_with_options(account_db_path, &g_hAccountGlobalDB, SQLITE_OPEN_READONLY, NULL); // else // return _ACCOUNT_ERROR_DB_NOT_OPENED; @@ -279,8 +279,8 @@ int _account_global_db_close(void) int ret = -1; /* ret = _account_db_handle_close(g_hAccountGlobalDB2); - if( ret != _ACCOUNT_ERROR_NONE ) - ACCOUNT_DEBUG( "db_util_close(g_hAccountGlobalDB2) fail ret = %d", ret); + if (ret != _ACCOUNT_ERROR_NONE) + ACCOUNT_DEBUG("db_util_close(g_hAccountGlobalDB2) fail ret = %d", ret); */ ret = _account_db_handle_close(g_hAccountGlobalDB); if (ret != _ACCOUNT_ERROR_NONE) { @@ -295,7 +295,7 @@ int _account_global_db_close(void) static bool _account_check_add_more_account(const char* app_id) { char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - int rc = 0; + int rc = 0; ACCOUNT_RETURN_VAL((app_id != 0), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("APP ID IS NULL")); ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, _ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected.")); @@ -306,7 +306,7 @@ static bool _account_check_add_more_account(const char* app_id) rc = _account_get_record_count(g_hAccountDB, query); /* multiple account support case (User DB & global DB) */ - if(rc > 0 || _account_get_record_count(g_hAccountGlobalDB, query) > 0) { + if (rc > 0 || _account_get_record_count(g_hAccountGlobalDB, query) > 0) { ACCOUNT_SLOGD("app id (%s) supports multiple account. rc(%d)\n", app_id, rc); return TRUE; } @@ -316,7 +316,7 @@ static bool _account_check_add_more_account(const char* app_id) ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT COUNT(*) FROM %s WHERE package_name = '%s'", ACCOUNT_TABLE, app_id); rc = _account_get_record_count(g_hAccountDB, query); - if(rc <= 0) { + if (rc <= 0) { ACCOUNT_SLOGD("app id (%s) supports single account. and there is no account of the app id\n", app_id); return TRUE; } @@ -354,9 +354,9 @@ int _account_db_open(int mode, int pid, uid_t uid) ACCOUNT_DEBUG("\"%s\" is already exist directory", account_db_dir); ACCOUNT_DEBUG("before db_util_open()"); -// if(mode == ACCOUNT_DB_OPEN_READWRITE) +// if (mode == ACCOUNT_DB_OPEN_READWRITE) rc = db_util_open(account_db_path, &g_hAccountDB, DB_UTIL_REGISTER_HOOK_METHOD); -// else if(mode == ACCOUNT_DB_OPEN_READONLY) +// else if (mode == ACCOUNT_DB_OPEN_READONLY) // rc = db_util_open_with_options(account_db_path, &g_hAccountDB, SQLITE_OPEN_READONLY, NULL); // else // return _ACCOUNT_ERROR_DB_NOT_OPENED; @@ -402,12 +402,11 @@ int _account_db_close(void) int ret = -1; /* ret = _account_db_handle_close(g_hAccountDB2); - if( ret != _ACCOUNT_ERROR_NONE ) - ACCOUNT_DEBUG( "db_util_close(g_hAccountDB2) fail ret = %d", ret); + if (ret != _ACCOUNT_ERROR_NONE) + ACCOUNT_DEBUG("db_util_close(g_hAccountDB2) fail ret = %d", ret); */ ret = _account_db_handle_close(g_hAccountDB); - if( ret != _ACCOUNT_ERROR_NONE ) - { + if (ret != _ACCOUNT_ERROR_NONE) { ACCOUNT_ERROR("db_util_close(g_hAccountDB) fail ret = %d", ret); g_hAccountDB2 = g_hAccountDB; } @@ -423,7 +422,7 @@ static int _account_execute_insert_query(account_s *account) int rc = 0; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; int error_code = _ACCOUNT_ERROR_NONE; - account_stmt hstmt = NULL; + account_stmt hstmt = NULL; /* check whether app id exist in account type db */ @@ -450,9 +449,9 @@ static int _account_execute_insert_query(account_s *account) rc = _account_query_step(hstmt); if (rc != SQLITE_DONE) { _INFO(""); - ACCOUNT_ERROR( "account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); + ACCOUNT_ERROR("account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ) + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) error_code = _ACCOUNT_ERROR_PERMISSION_DENIED; else error_code = _ACCOUNT_ERROR_DB_FAILED; @@ -470,14 +469,14 @@ static int _account_execute_insert_query(account_s *account) static int _account_insert_capability(account_s *account, int account_id) { _INFO("_account_insert_capability start"); - int rc, count = 1; + int rc, count = 1; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - account_stmt hstmt = NULL; + account_stmt hstmt = NULL; ACCOUNT_RETURN_VAL((account != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL")); - if (g_slist_length( account->capablity_list)==0) { - ACCOUNT_DEBUG( "_account_insert_capability, no capability\n"); + if (g_slist_length(account->capablity_list) == 0) { + ACCOUNT_DEBUG("_account_insert_capability, no capability\n"); return _ACCOUNT_ERROR_NONE; } @@ -486,13 +485,13 @@ static int _account_insert_capability(account_s *account, int account_id) _INFO("_account_insert_capability _account_get_record_count [%s]", query); rc = _account_get_record_count(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ - _ERR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { + _ERR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_PERMISSION_DENIED; } - if (rc <= 0) { + + if (rc <= 0) return _ACCOUNT_ERROR_RECORD_NOT_FOUND; - } /* insert query*/ @@ -529,7 +528,7 @@ static int _account_insert_capability(account_s *account, int account_id) _INFO("_account_insert_capability _account_query_step[%d]", rc); if (rc != SQLITE_DONE) { - _ERR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); + _ERR("_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); break; } @@ -545,14 +544,14 @@ static int _account_insert_capability(account_s *account, int account_id) static int _account_update_capability(account_s *account, int account_id) { - int rc, count = 1; + int rc, count = 1; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - account_stmt hstmt = NULL; + account_stmt hstmt = NULL; ACCOUNT_RETURN_VAL((account != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL")); - if (g_slist_length( account->capablity_list)==0) { - ACCOUNT_ERROR( "_account_update_capability, no capability\n"); + if (g_slist_length(account->capablity_list) == 0) { + ACCOUNT_ERROR("_account_update_capability, no capability\n"); return _ACCOUNT_ERROR_NONE; } @@ -561,7 +560,7 @@ static int _account_update_capability(account_s *account, int account_id) rc = _account_get_record_count(g_hAccountDB, query); if (rc <= 0) { - ACCOUNT_SLOGI( "_account_update_capability : related account item is not existed rc=%d , %s", rc, _account_db_err_msg(g_hAccountDB)); + ACCOUNT_SLOGI("_account_update_capability : related account item is not existed rc=%d , %s", rc, _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_RECORD_NOT_FOUND; } @@ -574,7 +573,7 @@ static int _account_update_capability(account_s *account, int account_id) rc = _account_query_step(hstmt); if (rc != SQLITE_DONE) { - ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); + ACCOUNT_ERROR("_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_DB_FAILED; } rc = _account_query_finalize(hstmt); @@ -611,7 +610,7 @@ static int _account_update_capability(account_s *account, int account_id) rc = _account_query_step(hstmt); if (rc != SQLITE_DONE) { - ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); + ACCOUNT_ERROR("_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); break; } @@ -624,16 +623,16 @@ static int _account_update_capability(account_s *account, int account_id) return _ACCOUNT_ERROR_NONE; } -static int _account_update_capability_by_user_name(account_s *account, const char *user_name, const char *package_name ) +static int _account_update_capability_by_user_name(account_s *account, const char *user_name, const char *package_name) { - int rc, count = 1; + int rc, count = 1; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - account_stmt hstmt = NULL; + account_stmt hstmt = NULL; ACCOUNT_RETURN_VAL((account != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL")); - if (g_slist_length( account->capablity_list)==0) { - ACCOUNT_ERROR( "_account_update_capability_by_user_name, no capability\n"); + if (g_slist_length(account->capablity_list) == 0) { + ACCOUNT_ERROR("_account_update_capability_by_user_name, no capability\n"); return _ACCOUNT_ERROR_NONE; } @@ -642,7 +641,7 @@ static int _account_update_capability_by_user_name(account_s *account, const cha rc = _account_get_record_count(g_hAccountDB, query); if (rc <= 0) { - ACCOUNT_SLOGI( "_account_update_capability_by_user_name : related account item is not existed rc=%d , %s ", rc, _account_db_err_msg(g_hAccountDB)); + ACCOUNT_SLOGI("_account_update_capability_by_user_name : related account item is not existed rc=%d , %s ", rc, _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_RECORD_NOT_FOUND; } @@ -655,7 +654,7 @@ static int _account_update_capability_by_user_name(account_s *account, const cha _account_query_bind_text(hstmt, count++, (char*)account->user_name); rc = _account_query_step(hstmt); if (rc != SQLITE_DONE) { - ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); + ACCOUNT_ERROR("_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_DB_FAILED; } @@ -693,7 +692,7 @@ static int _account_update_capability_by_user_name(account_s *account, const cha rc = _account_query_step(hstmt); if (rc != SQLITE_DONE) { - ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); + ACCOUNT_ERROR("_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); break; } @@ -750,7 +749,7 @@ bool _account_add_custom_to_account_cb(const char* key, const char* value, accou static int _account_compare_old_record_by_user_name(account_s *new_account, const char* user_name, const char* package_name) { int error_code = _ACCOUNT_ERROR_NONE; - account_stmt hstmt = NULL; + account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; int rc = 0; account_s *old_account = NULL; @@ -761,7 +760,7 @@ static int _account_compare_old_record_by_user_name(account_s *new_account, cons ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, _ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected.")); old_account = (account_s*)calloc(1, sizeof(account_s)); - if(!old_account) { + if (!old_account) { ACCOUNT_FATAL("Memory alloc fail\n"); return _ACCOUNT_ERROR_OUT_OF_MEMORY; } @@ -795,38 +794,38 @@ static int _account_compare_old_record_by_user_name(account_s *new_account, cons new_account->id = old_account->id; //user name - if(!new_account->user_name) { - if(old_account->user_name) + if (!new_account->user_name) { + if (old_account->user_name) new_account->user_name = _account_dup_text(old_account->user_name); } // display name - if(!new_account->display_name) { - if(old_account->display_name) + if (!new_account->display_name) { + if (old_account->display_name) new_account->display_name = _account_dup_text(old_account->display_name); } // email address - if(!new_account->email_address) { - if(old_account->email_address) + if (!new_account->email_address) { + if (old_account->email_address) new_account->email_address = _account_dup_text(old_account->email_address); } // domain name - if(!new_account->domain_name) { - if(old_account->domain_name) + if (!new_account->domain_name) { + if (old_account->domain_name) new_account->domain_name = _account_dup_text(old_account->domain_name); } // icon path - if(!new_account->icon_path) { - if(old_account->icon_path) + if (!new_account->icon_path) { + if (old_account->icon_path) new_account->icon_path = _account_dup_text(old_account->icon_path); } // source - if(!new_account->source) { - if(old_account->source) + if (!new_account->source) { + if (old_account->source) new_account->source = _account_dup_text(old_account->source); } @@ -834,50 +833,41 @@ static int _account_compare_old_record_by_user_name(account_s *new_account, cons new_account->package_name = _account_dup_text(old_account->package_name); // access token - if(!new_account->access_token) { - if(old_account->access_token) + if (!new_account->access_token) { + if (old_account->access_token) new_account->access_token = _account_dup_text(old_account->access_token); } // auth type - if(new_account->auth_type == _ACCOUNT_AUTH_TYPE_INVALID) { + if (new_account->auth_type == _ACCOUNT_AUTH_TYPE_INVALID) new_account->auth_type = old_account->auth_type; - } //secret - if(new_account->secret== _ACCOUNT_SECRECY_INVALID) { + if (new_account->secret == _ACCOUNT_SECRECY_INVALID) new_account->secret = old_account->secret; - } // sync support - if(new_account->sync_support == _ACCOUNT_SYNC_INVALID) { + if (new_account->sync_support == _ACCOUNT_SYNC_INVALID) new_account->sync_support = old_account->sync_support; - } // TODO user text int i; - for(i=0;i<USER_TXT_CNT;i++) { - if(!new_account->user_data_txt[i]) { - if(old_account->user_data_txt[i]) + for (i = 0; i < USER_TXT_CNT; i++) { + if (!new_account->user_data_txt[i]) { + if (old_account->user_data_txt[i]) new_account->user_data_txt[i] = _account_dup_text(old_account->user_data_txt[i]); } } // TODO user int - for(i=0;i<USER_INT_CNT;i++) { - if(new_account->user_data_int[i] == 0) { + for (i = 0; i < USER_INT_CNT; i++) { + if (new_account->user_data_int[i] == 0) new_account->user_data_int[i] = old_account->user_data_int[i]; - } } - // capability - - // user custom table - CATCH: - if (old_account) { + if (old_account) _account_free_account_with_items(old_account); - } if (hstmt != NULL) { rc = _account_query_finalize(hstmt); @@ -888,17 +878,15 @@ CATCH: return _ACCOUNT_ERROR_NONE; } - - static int _account_update_account_by_user_name(int pid, uid_t uid, account_s *account, const char *user_name, const char *package_name) { int rc = 0, binding_count = 0, count = 0; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; int error_code = _ACCOUNT_ERROR_NONE; - account_stmt hstmt = NULL; + account_stmt hstmt = NULL; ACCOUNT_RETURN_VAL((user_name != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("user_name is NULL.\n")); - ACCOUNT_RETURN_VAL((package_name!= NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("package_name is NULL.\n")); + ACCOUNT_RETURN_VAL((package_name != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("package_name is NULL.\n")); char* current_appid = NULL; char* verified_appid = NULL; @@ -909,22 +897,21 @@ static int _account_update_account_by_user_name(int pid, uid_t uid, account_s *a _ACCOUNT_FREE(current_appid); _ACCOUNT_FREE(verified_appid); - if(error_code != _ACCOUNT_ERROR_NONE){ + if (error_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_ERROR("No permission to update\n"); return _ACCOUNT_ERROR_PERMISSION_DENIED; } error_code = encrypt_access_token(account); - if (error_code != _ACCOUNT_ERROR_NONE) - { + if (error_code != _ACCOUNT_ERROR_NONE) { _ERR("_encrypt_access_token error"); return error_code; } _account_compare_old_record_by_user_name(account, user_name, package_name); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + 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; } @@ -943,8 +930,8 @@ static int _account_update_account_by_user_name(int pid, uid_t uid, account_s *a 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)); + 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; } @@ -963,9 +950,9 @@ static int _account_update_account_by_user_name(int pid, uid_t uid, account_s *a "int_custom0=?, int_custom1=?, int_custom2=?, int_custom3=?, int_custom4=? WHERE user_name=? and package_name=? ", ACCOUNT_TABLE); hstmt = _account_prepare_query(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ + 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)); + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_PERMISSION_DENIED; } ACCOUNT_RETURN_VAL((hstmt != NULL), {}, _ACCOUNT_ERROR_DB_FAILED, ("_account_svc_query_prepare() failed(%s).\n", _account_db_err_msg(g_hAccountDB))); @@ -974,10 +961,11 @@ static int _account_update_account_by_user_name(int pid, uid_t uid, account_s *a _account_query_bind_text(hstmt, binding_count++, user_name); _account_query_bind_text(hstmt, binding_count++, package_name); + rc = _account_query_step(hstmt); - if (rc != SQLITE_DONE) { - ACCOUNT_ERROR( "account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); - } + if (rc != SQLITE_DONE) + ACCOUNT_ERROR("account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); + rc = _account_query_finalize(hstmt); ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {}, rc, ("finalize error")); hstmt = NULL; @@ -995,7 +983,7 @@ int _account_insert_to_db(account_s* account, int pid, uid_t uid, int *account_i { _INFO(""); int error_code = _ACCOUNT_ERROR_NONE; - int ret_transaction = 0; + int ret_transaction = 0; ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, _ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected.")); ACCOUNT_RETURN_VAL((account != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL")); @@ -1014,9 +1002,9 @@ int _account_insert_to_db(account_s* account, int pid, uid_t uid, int *account_i /* transaction control required*/ ret_transaction = _account_begin_transaction(g_hAccountDB); - if(_account_db_err_code(g_hAccountDB) == SQLITE_PERM){ + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { pthread_mutex_unlock(&account_mutex); - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -1024,7 +1012,7 @@ int _account_insert_to_db(account_s* account, int pid, uid_t uid, int *account_i ACCOUNT_ERROR("account insert:_account_begin_transaction fail %d\n", ret_transaction); pthread_mutex_unlock(&account_mutex); return _ACCOUNT_ERROR_DATABASE_BUSY; - }else if (ret_transaction != _ACCOUNT_ERROR_NONE) { + } else if (ret_transaction != _ACCOUNT_ERROR_NONE) { ACCOUNT_ERROR("account insert:_account_begin_transaction fail %d\n", ret_transaction); pthread_mutex_unlock(&account_mutex); return ret_transaction; @@ -1036,8 +1024,7 @@ int _account_insert_to_db(account_s* account, int pid, uid_t uid, int *account_i char* appid = NULL; appid = _account_get_current_appid(pid, uid); - if(!appid) - { + if (!appid) { _INFO(""); // API caller cannot be recognized ret_transaction = _account_end_transaction(g_hAccountDB, FALSE); @@ -1050,8 +1037,7 @@ int _account_insert_to_db(account_s* account, int pid, uid_t uid, int *account_i char* verified_appid = NULL; error_code = _account_get_represented_appid_from_db(g_hAccountDB, g_hAccountGlobalDB, appid, uid, &verified_appid);//FIX _ACCOUNT_FREE(appid); - if(error_code != _ACCOUNT_ERROR_NONE) - { + if (error_code != _ACCOUNT_ERROR_NONE) { _ERR("error_code = %d", error_code); ret_transaction = _account_end_transaction(g_hAccountDB, FALSE); ACCOUNT_ERROR("App id is not registered in account type DB, transaction ret (%x)!!!!\n", ret_transaction); @@ -1060,8 +1046,7 @@ int _account_insert_to_db(account_s* account, int pid, uid_t uid, int *account_i return error_code; } - if(verified_appid) - { + if (verified_appid) { _INFO(""); error_code = _account_check_duplicated(g_hAccountDB, data, verified_appid, uid); if (error_code != _ACCOUNT_ERROR_NONE) { @@ -1072,7 +1057,7 @@ int _account_insert_to_db(account_s* account, int pid, uid_t uid, int *account_i pthread_mutex_unlock(&account_mutex); return error_code; } - if(!_account_check_add_more_account(verified_appid)) { + if (!_account_check_add_more_account(verified_appid)) { ret_transaction = _account_end_transaction(g_hAccountDB, FALSE); ACCOUNT_ERROR("No more account cannot be added, transaction ret (%x)!!!!\n", ret_transaction); pthread_mutex_unlock(&account_mutex); @@ -1085,8 +1070,7 @@ int _account_insert_to_db(account_s* account, int pid, uid_t uid, int *account_i _ACCOUNT_FREE(verified_appid); } - if(!_account_check_add_more_account(data->package_name)) - { + if (!_account_check_add_more_account(data->package_name)) { _INFO(""); ret_transaction = _account_end_transaction(g_hAccountDB, FALSE); ACCOUNT_ERROR("No more account cannot be added, transaction ret (%x)!!!!\n", ret_transaction); @@ -1095,8 +1079,7 @@ int _account_insert_to_db(account_s* account, int pid, uid_t uid, int *account_i } error_code = encrypt_access_token(data); - if (error_code != _ACCOUNT_ERROR_NONE) - { + if (error_code != _ACCOUNT_ERROR_NONE) { ret_transaction = _account_end_transaction(g_hAccountDB, FALSE); ACCOUNT_ERROR("encrypt_access_token fail, rollback insert query(%x)!!!!\n", ret_transaction); *account_id = -1; @@ -1106,8 +1089,7 @@ int _account_insert_to_db(account_s* account, int pid, uid_t uid, int *account_i error_code = _account_execute_insert_query(data); - if (error_code != _ACCOUNT_ERROR_NONE) - { + if (error_code != _ACCOUNT_ERROR_NONE) { _INFO(""); ret_transaction = _account_end_transaction(g_hAccountDB, FALSE); ACCOUNT_ERROR("INSERT account fail, rollback insert query(%x)!!!!\n", ret_transaction); @@ -1118,8 +1100,7 @@ int _account_insert_to_db(account_s* account, int pid, uid_t uid, int *account_i _INFO(""); error_code = _account_insert_capability(data, *account_id); - if (error_code != _ACCOUNT_ERROR_NONE) - { + if (error_code != _ACCOUNT_ERROR_NONE) { _INFO(""); ret_transaction = _account_end_transaction(g_hAccountDB, FALSE); ACCOUNT_ERROR("INSERT capability fail, rollback insert capability query(%x)!!!!\n", ret_transaction); @@ -1130,8 +1111,7 @@ int _account_insert_to_db(account_s* account, int pid, uid_t uid, int *account_i _INFO(""); error_code = _account_insert_custom(data, *account_id); - if (error_code != _ACCOUNT_ERROR_NONE) - { + if (error_code != _ACCOUNT_ERROR_NONE) { ret_transaction = _account_end_transaction(g_hAccountDB, FALSE); ACCOUNT_ERROR("INSERT custom fail, rollback insert capability query(%x)!!!!\n", ret_transaction); *account_id = -1; @@ -1145,13 +1125,12 @@ int _account_insert_to_db(account_s* account, int pid, uid_t uid, int *account_i _account_end_transaction(g_hAccountDB, TRUE); ACCOUNT_SLOGD("(%s)-(%d) account _end_transaction.\n", __FUNCTION__, __LINE__); - char buf[64]={0,}; + char buf[64] = {0,}; ACCOUNT_SNPRINTF(buf, sizeof(buf), "%s:%d", _ACCOUNT_NOTI_NAME_INSERT, *account_id); _account_insert_delete_update_notification_send(buf); _INFO("account _notification_send end."); return _ACCOUNT_ERROR_NONE; - } GSList* _account_get_capability_list_by_account_id(int account_id, int *error_code) @@ -1159,19 +1138,19 @@ GSList* _account_get_capability_list_by_account_id(int account_id, int *error_co *error_code = _ACCOUNT_ERROR_NONE; account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - int rc = 0; + int rc = 0; GSList* capability_list = NULL; - ACCOUNT_RETURN_VAL((account_id > 0), {*error_code = _ACCOUNT_ERROR_INVALID_PARAMETER;}, NULL, ("ACCOUNT INDEX IS LESS THAN 0")); - ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {*error_code = _ACCOUNT_ERROR_DB_NOT_OPENED;}, NULL, ("The database isn't connected.")); + ACCOUNT_RETURN_VAL((account_id > 0), { *error_code = _ACCOUNT_ERROR_INVALID_PARAMETER; }, NULL, ("ACCOUNT INDEX IS LESS THAN 0")); + ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), { *error_code = _ACCOUNT_ERROR_DB_NOT_OPENED; }, NULL, ("The database isn't connected.")); ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX); ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE account_id = %d", CAPABILITY_TABLE, account_id); hstmt = _account_prepare_query(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); *error_code = _ACCOUNT_ERROR_PERMISSION_DENIED; return NULL; } @@ -1205,27 +1184,27 @@ GSList* _account_get_capability_list_by_account_id(int account_id, int *error_co } rc = _account_query_finalize(hstmt); - ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {*error_code = rc;}, NULL, ("finalize error")); + ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), { *error_code = rc; }, NULL, ("finalize error")); hstmt = NULL; *error_code = _ACCOUNT_ERROR_NONE; CATCH: - if (hstmt != NULL) - { + if (hstmt != NULL) { rc = _account_query_finalize(hstmt); - ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {*error_code = rc;}, NULL, ("finalize error")); + ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), { *error_code = rc; }, NULL, ("finalize error")); hstmt = NULL; } pthread_mutex_unlock(&account_mutex); + return capability_list; } static int _account_compare_old_record(account_s *new_account, int account_id) { int error_code = _ACCOUNT_ERROR_NONE; - account_stmt hstmt = NULL; + account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; int rc = 0; account_s *old_account = NULL; @@ -1270,38 +1249,38 @@ static int _account_compare_old_record(account_s *new_account, int account_id) new_account->id = old_account->id; //user name - if(!new_account->user_name) { - if(old_account->user_name) + if (!new_account->user_name) { + if (old_account->user_name) new_account->user_name = _account_dup_text(old_account->user_name); } // display name - if(!new_account->display_name) { - if(old_account->display_name) + if (!new_account->display_name) { + if (old_account->display_name) new_account->display_name = _account_dup_text(old_account->display_name); } // email address - if(!new_account->email_address) { - if(old_account->email_address) + if (!new_account->email_address) { + if (old_account->email_address) new_account->email_address = _account_dup_text(old_account->email_address); } // domain name - if(!new_account->domain_name) { - if(old_account->domain_name) + if (!new_account->domain_name) { + if (old_account->domain_name) new_account->domain_name = _account_dup_text(old_account->domain_name); } // icon path - if(!new_account->icon_path) { - if(old_account->icon_path) + if (!new_account->icon_path) { + if (old_account->icon_path) new_account->icon_path = _account_dup_text(old_account->icon_path); } // source - if(!new_account->source) { - if(old_account->source) + if (!new_account->source) { + if (old_account->source) new_account->source = _account_dup_text(old_account->source); } @@ -1309,55 +1288,47 @@ static int _account_compare_old_record(account_s *new_account, int account_id) new_account->package_name = _account_dup_text(old_account->package_name); // access token - if(!new_account->access_token) { - if(old_account->access_token) + if (!new_account->access_token) { + if (old_account->access_token) new_account->access_token = _account_dup_text(old_account->access_token); } // user text int i; - for(i=0;i<USER_TXT_CNT;i++) { - if(!new_account->user_data_txt[i]) { - if(old_account->user_data_txt[i]) + for (i = 0; i < USER_TXT_CNT; i++) { + if (!new_account->user_data_txt[i]) { + if (old_account->user_data_txt[i]) new_account->user_data_txt[i] = _account_dup_text(old_account->user_data_txt[i]); } } // auth type - if(new_account->auth_type == _ACCOUNT_AUTH_TYPE_INVALID) { + if (new_account->auth_type == _ACCOUNT_AUTH_TYPE_INVALID) new_account->auth_type = old_account->auth_type; - } - //secret - if(new_account->secret== _ACCOUNT_SECRECY_INVALID) { + // secret + if (new_account->secret == _ACCOUNT_SECRECY_INVALID) new_account->secret = old_account->secret; - } // sync support - if(new_account->sync_support == _ACCOUNT_SYNC_INVALID) { + if (new_account->sync_support == _ACCOUNT_SYNC_INVALID) new_account->sync_support = old_account->sync_support; - } // user int - for(i=0;i<USER_INT_CNT;i++) { - if(new_account->user_data_int[i] == 0) { + for (i = 0; i < USER_INT_CNT; i++) { + if (new_account->user_data_int[i] == 0) new_account->user_data_int[i] = old_account->user_data_int[i]; - } } - // capability - - // user custom table - CATCH: - if (old_account) - _account_free_account_with_items(old_account); + if (old_account) + _account_free_account_with_items(old_account); - if (hstmt != NULL) { - rc = _account_query_finalize(hstmt); - ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {}, rc, ("finalize error")); - hstmt = NULL; - } + if (hstmt != NULL) { + rc = _account_query_finalize(hstmt); + ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {}, rc, ("finalize error")); + hstmt = NULL; + } return _ACCOUNT_ERROR_NONE; } @@ -1365,7 +1336,7 @@ CATCH: static int _account_get_package_name_from_account_id(int account_id, char **package_name) { int error_code = _ACCOUNT_ERROR_NONE; - account_stmt hstmt = NULL; + account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; int rc = 0; account_s *old_account = NULL; @@ -1399,17 +1370,15 @@ static int _account_get_package_name_from_account_id(int account_id, char **pack // get package name. *package_name = _account_dup_text(old_account->package_name); +CATCH: + if (old_account) + _account_free_account_with_items(old_account); - CATCH: - if (old_account) { - _account_free_account_with_items(old_account); - } - - if (hstmt != NULL) { - rc = _account_query_finalize(hstmt); - ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {}, rc, ("finalize error")); - hstmt = NULL; - } + if (hstmt != NULL) { + rc = _account_query_finalize(hstmt); + ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {}, rc, ("finalize error")); + hstmt = NULL; + } return error_code; @@ -1417,10 +1386,10 @@ static int _account_get_package_name_from_account_id(int account_id, char **pack static int _account_update_account(int pid, uid_t uid, account_s *account, int account_id) { - int rc = 0, binding_count =0; + int rc = 0, binding_count = 0; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - int error_code = _ACCOUNT_ERROR_NONE, count=0, ret_transaction = 0; - account_stmt hstmt = NULL; + int error_code = _ACCOUNT_ERROR_NONE, count = 0, ret_transaction = 0; + account_stmt hstmt = NULL; if (!account->package_name) { ACCOUNT_ERROR("Package name is mandetory field, it can not be NULL!!!!\n"); @@ -1434,7 +1403,7 @@ static int _account_update_account(int pid, uid_t uid, account_s *account, int a current_appid = _account_get_current_appid(pid, uid); error_code = _account_get_package_name_from_account_id(account_id, &package_name); - if(error_code != _ACCOUNT_ERROR_NONE || package_name == NULL){ + if (error_code != _ACCOUNT_ERROR_NONE || package_name == NULL) { ACCOUNT_ERROR("No package name with account_id\n"); _ACCOUNT_FREE(current_appid); _ACCOUNT_FREE(package_name); @@ -1442,19 +1411,18 @@ static int _account_update_account(int pid, uid_t uid, account_s *account, int a } error_code = _account_check_appid_group_with_package_name(current_appid, package_name, uid); - ACCOUNT_DEBUG( "UPDATE:account_id[%d],current_appid[%s]package_name[%s]", account_id, current_appid, package_name); // TODO: remove the log later. + ACCOUNT_DEBUG("UPDATE:account_id[%d],current_appid[%s]package_name[%s]", account_id, current_appid, package_name); // TODO: remove the log later. _ACCOUNT_FREE(current_appid); _ACCOUNT_FREE(package_name); - if(error_code != _ACCOUNT_ERROR_NONE){ + if (error_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_ERROR("No permission to update\n"); return _ACCOUNT_ERROR_PERMISSION_DENIED; } error_code = encrypt_access_token(account); - if (error_code != _ACCOUNT_ERROR_NONE) - { + if (error_code != _ACCOUNT_ERROR_NONE) { _ERR("_encrypt_access_token error"); return error_code; } @@ -1465,11 +1433,11 @@ static int _account_update_account(int pid, uid_t uid, account_s *account, int a return error_code; } - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + 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; - } else if( _account_db_err_code(g_hAccountDB) == SQLITE_BUSY ){ - ACCOUNT_ERROR( "database busy(%s)", _account_db_err_msg(g_hAccountDB)); + } else if (_account_db_err_code(g_hAccountDB) == SQLITE_BUSY) { + ACCOUNT_ERROR("database busy(%s)", _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_DATABASE_BUSY; } @@ -1490,8 +1458,8 @@ static int _account_update_account(int pid, uid_t uid, account_s *account, int a /* transaction control required*/ ret_transaction = _account_begin_transaction(g_hAccountDB); - if( ret_transaction == _ACCOUNT_ERROR_DATABASE_BUSY ){ - ACCOUNT_ERROR( "database busy(%s)", _account_db_err_msg(g_hAccountDB)); + if (ret_transaction == _ACCOUNT_ERROR_DATABASE_BUSY) { + ACCOUNT_ERROR("database busy(%s)", _account_db_err_msg(g_hAccountDB)); pthread_mutex_unlock(&account_mutex); return _ACCOUNT_ERROR_DATABASE_BUSY; } @@ -1504,9 +1472,9 @@ static int _account_update_account(int pid, uid_t uid, account_s *account, int a hstmt = _account_prepare_query(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { ret_transaction = _account_end_transaction(g_hAccountDB, FALSE); - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -1516,9 +1484,8 @@ static int _account_update_account(int pid, uid_t uid, account_s *account, int a _account_query_bind_int(hstmt, binding_count++, account_id); rc = _account_query_step(hstmt); - if (rc != SQLITE_DONE) { - ACCOUNT_SLOGE( "account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); - } + if (rc != SQLITE_DONE) + ACCOUNT_SLOGE("account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); rc = _account_query_finalize(hstmt); ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {}, rc, ("finalize error")); @@ -1528,7 +1495,7 @@ static int _account_update_account(int pid, uid_t uid, account_s *account, int a /*update capability*/ error_code = _account_update_capability(account, account_id); - if(error_code != _ACCOUNT_ERROR_NONE && error_code!= _ACCOUNT_ERROR_RECORD_NOT_FOUND){ + if (error_code != _ACCOUNT_ERROR_NONE && error_code != _ACCOUNT_ERROR_RECORD_NOT_FOUND) { ret_transaction = _account_end_transaction(g_hAccountDB, FALSE); ACCOUNT_ERROR("update capability Failed, trying to roll back(%x) !!!\n", ret_transaction); return error_code; @@ -1536,7 +1503,7 @@ static int _account_update_account(int pid, uid_t uid, account_s *account, int a /* update custom */ error_code = _account_update_custom(account, account_id); - if(error_code != _ACCOUNT_ERROR_NONE && error_code!= _ACCOUNT_ERROR_RECORD_NOT_FOUND){ + if (error_code != _ACCOUNT_ERROR_NONE && error_code != _ACCOUNT_ERROR_RECORD_NOT_FOUND) { ret_transaction = _account_end_transaction(g_hAccountDB, FALSE); ACCOUNT_ERROR("update capability Failed, trying to roll back(%x) !!!\n", ret_transaction); return error_code; @@ -1545,16 +1512,17 @@ static int _account_update_account(int pid, uid_t uid, account_s *account, int a ret_transaction = _account_end_transaction(g_hAccountDB, TRUE); _INFO("update end"); + return error_code; } static int _account_update_account_ex(account_s *account, int account_id) { - int rc = 0, binding_count =0; + int rc = 0, binding_count = 0; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - int error_code = _ACCOUNT_ERROR_NONE, count=0, ret_transaction = 0; - account_stmt hstmt = NULL; + int error_code = _ACCOUNT_ERROR_NONE, count = 0, ret_transaction = 0; + account_stmt hstmt = NULL; if (!account->package_name) { ACCOUNT_ERROR("Package name is mandetory field, it can not be NULL!!!!\n"); @@ -1562,8 +1530,7 @@ static int _account_update_account_ex(account_s *account, int account_id) } error_code = encrypt_access_token(account); - if (error_code != _ACCOUNT_ERROR_NONE) - { + if (error_code != _ACCOUNT_ERROR_NONE) { _ERR("_encrypt_access_token error"); return error_code; } @@ -1574,8 +1541,8 @@ static int _account_update_account_ex(account_s *account, int account_id) return error_code; } - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + 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; } @@ -1596,8 +1563,8 @@ static int _account_update_account_ex(account_s *account, int account_id) /* transaction control required*/ ret_transaction = _account_begin_transaction(g_hAccountDB); - if( ret_transaction == _ACCOUNT_ERROR_DATABASE_BUSY ){ - ACCOUNT_ERROR( "database busy(%s)", _account_db_err_msg(g_hAccountDB)); + if (ret_transaction == _ACCOUNT_ERROR_DATABASE_BUSY) { + ACCOUNT_ERROR("database busy(%s)", _account_db_err_msg(g_hAccountDB)); pthread_mutex_unlock(&account_mutex); return _ACCOUNT_ERROR_DATABASE_BUSY; } @@ -1610,9 +1577,9 @@ static int _account_update_account_ex(account_s *account, int account_id) hstmt = _account_prepare_query(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { ret_transaction = _account_end_transaction(g_hAccountDB, FALSE); - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -1626,9 +1593,8 @@ static int _account_update_account_ex(account_s *account, int account_id) _INFO("account_update_to_db_by_id_ex_p : after bind() : ret = %d", rc); rc = _account_query_step(hstmt); - if (rc != SQLITE_DONE) { - ACCOUNT_SLOGE( "account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); - } + if (rc != SQLITE_DONE) + ACCOUNT_SLOGE("account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); _INFO("account_update_to_db_by_id_ex_p : after query_step() : ret = %d", rc); rc = _account_query_finalize(hstmt); @@ -1639,7 +1605,7 @@ static int _account_update_account_ex(account_s *account, int account_id) _INFO("account_update_to_db_by_id_ex_p : before update_capability()"); /*update capability*/ error_code = _account_update_capability(account, account_id); - if(error_code != _ACCOUNT_ERROR_NONE && error_code!= _ACCOUNT_ERROR_RECORD_NOT_FOUND){ + if (error_code != _ACCOUNT_ERROR_NONE && error_code != _ACCOUNT_ERROR_RECORD_NOT_FOUND) { ret_transaction = _account_end_transaction(g_hAccountDB, FALSE); ACCOUNT_ERROR("update capability Failed, trying to roll back(%x) !!!\n", ret_transaction); return error_code; @@ -1649,7 +1615,7 @@ static int _account_update_account_ex(account_s *account, int account_id) _INFO("account_update_to_db_by_id_ex_p : before update_custom()"); /* update custom */ error_code = _account_update_custom(account, account_id); - if(error_code != _ACCOUNT_ERROR_NONE && error_code!= _ACCOUNT_ERROR_RECORD_NOT_FOUND){ + if (error_code != _ACCOUNT_ERROR_NONE && error_code != _ACCOUNT_ERROR_RECORD_NOT_FOUND) { ret_transaction = _account_end_transaction(g_hAccountDB, FALSE); ACCOUNT_ERROR("update capability Failed, trying to roll back(%x) !!!\n", ret_transaction); return error_code; @@ -1674,14 +1640,14 @@ int _account_update_to_db_by_id(int pid, uid_t uid, account_s* account, int acco error_code = _account_update_account(pid, uid, data, account_id); - if(error_code != _ACCOUNT_ERROR_NONE) { + if (error_code != _ACCOUNT_ERROR_NONE) { pthread_mutex_unlock(&account_mutex); return error_code; } pthread_mutex_unlock(&account_mutex); - char buf[64]={0,}; + char buf[64] = {0,}; ACCOUNT_SNPRINTF(buf, sizeof(buf), "%s:%d", _ACCOUNT_NOTI_NAME_UPDATE, account_id); _account_insert_delete_update_notification_send(buf); @@ -1702,21 +1668,20 @@ int _account_update_to_db_by_id_ex(account_s* account, int account_id) error_code = _account_update_account_ex(data, account_id); _INFO("after update_account_ex() : account_id[%d], user_name=%s", account_id, data->user_name); - if(error_code != _ACCOUNT_ERROR_NONE) { + if (error_code != _ACCOUNT_ERROR_NONE) { pthread_mutex_unlock(&account_mutex); return error_code; } pthread_mutex_unlock(&account_mutex); - char buf[64]={0,}; + char buf[64] = {0,}; ACCOUNT_SNPRINTF(buf, sizeof(buf), "%s:%d", _ACCOUNT_NOTI_NAME_UPDATE, account_id); _account_insert_delete_update_notification_send(buf); return _ACCOUNT_ERROR_NONE; } - int _account_update_to_db_by_user_name(int pid, uid_t uid, account_s* account, const char *user_name, const char *package_name) { ACCOUNT_RETURN_VAL((user_name != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("USER NAME IS NULL")); @@ -1732,7 +1697,7 @@ int _account_update_to_db_by_user_name(int pid, uid_t uid, account_s* account, c pthread_mutex_unlock(&account_mutex); - char buf[64]={0,}; + char buf[64] = {0,}; ACCOUNT_SNPRINTF(buf, sizeof(buf), "%s:%d", _ACCOUNT_NOTI_NAME_UPDATE, data->id); _account_insert_delete_update_notification_send(buf); @@ -1741,10 +1706,10 @@ int _account_update_to_db_by_user_name(int pid, uid_t uid, account_s* account, c GSList* _account_db_query_all(int pid, uid_t uid) { - //int error_code = _ACCOUNT_ERROR_NONE; + //int error_code = _ACCOUNT_ERROR_NONE; account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - int rc = 0; + int rc = 0; GSList *account_list = NULL; ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, NULL, ("The database isn't connected.")); @@ -1754,8 +1719,8 @@ GSList* _account_db_query_all(int pid, uid_t uid) ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s ", ACCOUNT_TABLE); hstmt = _account_prepare_query(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); return NULL; } @@ -1763,13 +1728,12 @@ GSList* _account_db_query_all(int pid, uid_t uid) account_s *account_record = NULL; - if (rc != SQLITE_ROW) - { + if (rc != SQLITE_ROW) { _ERR("The record isn't found"); goto CATCH; } - while(rc == SQLITE_ROW) { + while (rc == SQLITE_ROW) { account_record = (account_s*) malloc(sizeof(account_s)); if (account_record == NULL) { @@ -1799,27 +1763,27 @@ GSList* _account_db_query_all(int pid, uid_t uid) CATCH: if (hstmt != NULL) { rc = _account_query_finalize(hstmt); - ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {_account_gslist_account_free(account_list);}, NULL, ("finalize error")); + ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {_account_gslist_account_free(account_list); }, NULL, ("finalize error")); hstmt = NULL; } + if (account_list) - { _remove_sensitive_info_from_non_owning_account_slist(account_list, pid, uid); - } + return account_list; } int _account_update_sync_status_by_id(uid_t uid, int account_db_id, const int sync_status) { int error_code = _ACCOUNT_ERROR_NONE; - account_stmt hstmt = NULL; + account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; int rc = 0; - int count =1; + int count = 1; ACCOUNT_RETURN_VAL((account_db_id > 0), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT INDEX IS LESS THAN 0")); ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, _ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected.")); - if ( (sync_status < 0) || (sync_status >= _ACCOUNT_SYNC_MAX)) { + if ((sync_status < 0) || (sync_status >= _ACCOUNT_SYNC_MAX)) { ACCOUNT_SLOGE("(%s)-(%d) sync_status is less than 0 or more than enum max.\n", __FUNCTION__, __LINE__); return _ACCOUNT_ERROR_INVALID_PARAMETER; } @@ -1832,14 +1796,14 @@ int _account_update_sync_status_by_id(uid_t uid, int account_db_id, const int sy rc = _account_get_record_count(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { pthread_mutex_unlock(&account_mutex); - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_PERMISSION_DENIED; } if (rc <= 0) { - ACCOUNT_SLOGE( "account_update_sync_status_by_id : related account item is not existed rc=%d , %s", rc, _account_db_err_msg(g_hAccountDB)); + ACCOUNT_SLOGE("account_update_sync_status_by_id : related account item is not existed rc=%d , %s", rc, _account_db_err_msg(g_hAccountDB)); pthread_mutex_unlock(&account_mutex); return _ACCOUNT_ERROR_RECORD_NOT_FOUND; } @@ -1853,9 +1817,9 @@ int _account_update_sync_status_by_id(uid_t uid, int account_db_id, const int sy rc = _account_query_step(hstmt); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { pthread_mutex_unlock(&account_mutex); - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -1868,7 +1832,8 @@ int _account_update_sync_status_by_id(uid_t uid, int account_db_id, const int sy pthread_mutex_unlock(&account_mutex); return rc; } - char buf[64]={0,}; + + char buf[64] = {0,}; ACCOUNT_SNPRINTF(buf, sizeof(buf), "%s:%d", _ACCOUNT_NOTI_NAME_SYNC_UPDATE, account_db_id); _account_insert_delete_update_notification_send(buf); @@ -1884,6 +1849,7 @@ CATCH: } pthread_mutex_unlock(&account_mutex); + return error_code; } @@ -1892,7 +1858,7 @@ int _account_query_account_by_account_id(int pid, uid_t uid, int account_db_id, _INFO("_account_query_account_by_account_id() start, account_db_id=[%d]", account_db_id); int error_code = _ACCOUNT_ERROR_NONE; - account_stmt hstmt = NULL; + account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; int rc = 0; @@ -1909,8 +1875,8 @@ int _account_query_account_by_account_id(int pid, uid_t uid, int account_db_id, rc = _account_db_err_code(g_hAccountDB); _INFO("after _account_prepare_query, rc=[%d]", rc); - if( rc == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + if (rc == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -1951,24 +1917,23 @@ CATCH: } if (account_record) - { _remove_sensitive_info_from_non_owning_account(account_record, pid, uid); - } + pthread_mutex_unlock(&account_mutex); ACCOUNT_DEBUG("_account_query_account_by_account_id end [%d]", error_code); + return error_code; } GList* _account_query_account_by_user_name(int pid, uid_t uid, const char *user_name, int *error_code) { *error_code = _ACCOUNT_ERROR_NONE; - account_stmt hstmt = NULL; + account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; int rc = 0; account_s *account_head = NULL; - if (user_name == NULL) - { + if (user_name == NULL) { _ERR("USER NAME IS NULL"); *error_code = _ACCOUNT_ERROR_INVALID_PARAMETER; goto CATCH; @@ -1980,9 +1945,8 @@ GList* _account_query_account_by_user_name(int pid, uid_t uid, const char *user_ hstmt = _account_prepare_query(g_hAccountDB, query); - if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) - { - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); *error_code = _ACCOUNT_ERROR_PERMISSION_DENIED; goto CATCH; } @@ -1992,8 +1956,7 @@ GList* _account_query_account_by_user_name(int pid, uid_t uid, const char *user_ rc = _account_query_step(hstmt); - if (rc != SQLITE_ROW) - { + if (rc != SQLITE_ROW) { _ERR("The record isn't found"); *error_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND; goto CATCH; @@ -2006,9 +1969,7 @@ GList* _account_query_account_by_user_name(int pid, uid_t uid, const char *user_ ACCOUNT_FATAL("malloc Failed"); if (hstmt != NULL) { rc = _account_query_finalize(hstmt); - - if (rc != _ACCOUNT_ERROR_NONE) - { + if (rc != _ACCOUNT_ERROR_NONE) { _ERR("finalize error"); *error_code = rc; goto CATCH; @@ -2041,8 +2002,7 @@ GList* _account_query_account_by_user_name(int pid, uid_t uid, const char *user_ rc = _account_query_finalize(hstmt); - if (rc != _ACCOUNT_ERROR_NONE) - { + if (rc != _ACCOUNT_ERROR_NONE) { _ERR("finalize error"); *error_code = rc; goto CATCH; @@ -2052,18 +2012,16 @@ GList* _account_query_account_by_user_name(int pid, uid_t uid, const char *user_ GList *iter; - tmp = g_list_length(account_head->account_list); for (iter = account_head->account_list; iter != NULL; iter = g_list_next(iter)) { -// account_h account; -// account = (account_h)iter->data; + //account_h account; + //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); - } *error_code = _ACCOUNT_ERROR_NONE; @@ -2071,8 +2029,7 @@ GList* _account_query_account_by_user_name(int pid, uid_t uid, const char *user_ CATCH: if (hstmt != NULL) { rc = _account_query_finalize(hstmt); - if (rc != _ACCOUNT_ERROR_NONE) - { + if (rc != _ACCOUNT_ERROR_NONE) { _ERR("finalize error"); *error_code = rc; } @@ -2080,13 +2037,14 @@ CATCH: } pthread_mutex_unlock(&account_mutex); - if (account_head) - { + + if (account_head) { _remove_sensitive_info_from_non_owning_account_list(account_head->account_list, pid, uid); GList* result = account_head->account_list; _ACCOUNT_FREE(account_head); return result; } + return NULL; } @@ -2096,9 +2054,9 @@ _account_query_account_by_capability(int pid, uid_t uid, const char* capability_ *error_code = _ACCOUNT_ERROR_NONE; account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - int rc = 0; + int rc = 0; - ACCOUNT_RETURN_VAL((capability_type != NULL), {*error_code = _ACCOUNT_ERROR_INVALID_PARAMETER;}, NULL, ("capability_type IS NULL")); + ACCOUNT_RETURN_VAL((capability_type != NULL), { *error_code = _ACCOUNT_ERROR_INVALID_PARAMETER; }, NULL, ("capability_type IS NULL")); if ((capability_value < 0) || (capability_value >= _ACCOUNT_CAPABILITY_STATE_MAX)) { ACCOUNT_SLOGE("(%s)-(%d) capability_value is not equal to 0 or 1.\n", __FUNCTION__, __LINE__); @@ -2106,7 +2064,7 @@ _account_query_account_by_capability(int pid, uid_t uid, const char* capability_ return NULL; } - ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {*error_code = _ACCOUNT_ERROR_DB_NOT_OPENED;}, NULL, ("The database isn't connected.")); + ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), { *error_code = _ACCOUNT_ERROR_DB_NOT_OPENED; }, NULL, ("The database isn't connected.")); ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX); @@ -2114,8 +2072,8 @@ _account_query_account_by_capability(int pid, uid_t uid, const char* capability_ hstmt = _account_prepare_query(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); *error_code = _ACCOUNT_ERROR_PERMISSION_DENIED; return NULL; } @@ -2137,7 +2095,7 @@ _account_query_account_by_capability(int pid, uid_t uid, const char* capability_ ACCOUNT_FATAL("malloc Failed"); if (hstmt != NULL) { rc = _account_query_finalize(hstmt); - ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {*error_code = rc;}, NULL, ("finalize error")); + ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), { *error_code = rc; }, NULL, ("finalize error")); hstmt = NULL; } *error_code = _ACCOUNT_ERROR_OUT_OF_MEMORY; @@ -2174,8 +2132,8 @@ _account_query_account_by_capability(int pid, uid_t uid, const char* capability_ tmp = g_list_length(account_head->account_list); for (iter = account_head->account_list; iter != NULL; iter = g_list_next(iter)) { -// account_h account = NULL; -// account = (account_h)iter->data; + //account_h account = NULL; + //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); @@ -2183,20 +2141,19 @@ _account_query_account_by_capability(int pid, uid_t uid, const char* capability_ } - *error_code = _ACCOUNT_ERROR_NONE; CATCH: if (hstmt != NULL) { rc = _account_query_finalize(hstmt); - if ( rc != _ACCOUNT_ERROR_NONE ) { + if (rc != _ACCOUNT_ERROR_NONE) { *error_code = rc; _ERR("finalize error"); } hstmt = NULL; } - if( *error_code != _ACCOUNT_ERROR_NONE && account_head ) { + if (*error_code != _ACCOUNT_ERROR_NONE && account_head) { _account_glist_account_free(account_head->account_list); _ACCOUNT_FREE(account_head); account_head = NULL; @@ -2204,13 +2161,13 @@ CATCH: pthread_mutex_unlock(&account_mutex); - if (account_head) - { + if (account_head) { _remove_sensitive_info_from_non_owning_account_list(account_head->account_list, pid, uid); GList* result = account_head->account_list; _ACCOUNT_FREE(account_head); return result; } + return NULL; } @@ -2219,10 +2176,10 @@ GList* _account_query_account_by_capability_type(int pid, uid_t uid, const char* *error_code = _ACCOUNT_ERROR_NONE; account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - int rc = 0; + int rc = 0; - ACCOUNT_RETURN_VAL((capability_type != NULL), {*error_code = _ACCOUNT_ERROR_INVALID_PARAMETER;}, NULL, ("capability_type IS NULL")); - ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {*error_code = _ACCOUNT_ERROR_DB_NOT_OPENED;}, + ACCOUNT_RETURN_VAL((capability_type != NULL), { *error_code = _ACCOUNT_ERROR_INVALID_PARAMETER; }, NULL, ("capability_type IS NULL")); + ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), { *error_code = _ACCOUNT_ERROR_DB_NOT_OPENED; }, NULL, ("The database isn't connected.")); ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX); @@ -2231,8 +2188,8 @@ GList* _account_query_account_by_capability_type(int pid, uid_t uid, const char* hstmt = _account_prepare_query(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); *error_code = _ACCOUNT_ERROR_PERMISSION_DENIED; return NULL; } @@ -2253,7 +2210,7 @@ GList* _account_query_account_by_capability_type(int pid, uid_t uid, const char* ACCOUNT_FATAL("malloc Failed"); if (hstmt != NULL) { rc = _account_query_finalize(hstmt); - ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {*error_code = rc;}, NULL, ("finalize error")); + ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), { *error_code = rc; }, NULL, ("finalize error")); hstmt = NULL; } *error_code = _ACCOUNT_ERROR_OUT_OF_MEMORY; @@ -2300,8 +2257,7 @@ GList* _account_query_account_by_capability_type(int pid, uid_t uid, const char* *error_code = _ACCOUNT_ERROR_NONE; CATCH: - if (hstmt != NULL) - { + if (hstmt != NULL) { rc = _account_query_finalize(hstmt); if (rc != _ACCOUNT_ERROR_NONE) { *error_code = rc; @@ -2310,7 +2266,7 @@ CATCH: hstmt = NULL; } - if( (*error_code != _ACCOUNT_ERROR_NONE) && account_head ) { + if ((*error_code != _ACCOUNT_ERROR_NONE) && account_head) { _account_glist_account_free(account_head->account_list); _ACCOUNT_FREE(account_head); account_head = NULL; @@ -2318,13 +2274,13 @@ CATCH: pthread_mutex_unlock(&account_mutex); - if (account_head) - { + if (account_head) { _remove_sensitive_info_from_non_owning_account_list(account_head->account_list, pid, uid); GList* result = account_head->account_list; _ACCOUNT_FREE(account_head); return result; } + return NULL; } @@ -2335,12 +2291,13 @@ GList* account_server_query_account_by_package_name(const char* package_name, in GList * account_list = NULL; *error_code = _ACCOUNT_ERROR_NONE; - ACCOUNT_RETURN_VAL((package_name != NULL), {*error_code = _ACCOUNT_ERROR_INVALID_PARAMETER;}, NULL, ("PACKAGE NAME IS NULL")); - ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {*error_code = _ACCOUNT_ERROR_DB_NOT_OPENED;}, NULL, ("The database isn't connected.")); + ACCOUNT_RETURN_VAL((package_name != NULL), { *error_code = _ACCOUNT_ERROR_INVALID_PARAMETER; }, NULL, ("PACKAGE NAME IS NULL")); + ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), { *error_code = _ACCOUNT_ERROR_DB_NOT_OPENED; }, NULL, ("The database isn't connected.")); account_list = _account_query_account_by_package_name(g_hAccountDB, package_name, error_code, pid, uid); _INFO("account_server_query_account_by_package_name end"); + return account_list; } @@ -2356,13 +2313,14 @@ int account_server_delete_account_by_package_name(const char* package_name, bool error_code = _account_delete_account_by_package_name(g_hAccountDB, package_name, permission, pid, uid); _INFO("account_server_delete_account_by_package_name end"); + return error_code; } int _account_delete(int pid, uid_t uid, int account_id) { int error_code = _ACCOUNT_ERROR_NONE; - account_stmt hstmt = NULL; + account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; int rc = 0; int ret_transaction = 0; @@ -2376,9 +2334,9 @@ int _account_delete(int pid, uid_t uid, int account_id) count = _account_get_record_count(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { pthread_mutex_unlock(&account_mutex); - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -2395,20 +2353,20 @@ int _account_delete(int pid, uid_t uid, int account_id) error_code = _account_get_package_name_from_account_id(account_id, &package_name); - if(error_code != _ACCOUNT_ERROR_NONE){ + if (error_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_ERROR("No package name with account_id\n"); _ACCOUNT_FREE(current_appid); _ACCOUNT_FREE(package_name); return _ACCOUNT_ERROR_RECORD_NOT_FOUND; } - ACCOUNT_DEBUG( "DELETE:account_id[%d],current_appid[%s]package_name[%s]", account_id, current_appid, package_name); + ACCOUNT_DEBUG("DELETE:account_id[%d],current_appid[%s]package_name[%s]", account_id, current_appid, package_name); error_code = _account_check_appid_group_with_package_name(current_appid, package_name, uid); _ACCOUNT_FREE(current_appid); _ACCOUNT_FREE(package_name); - if(error_code != _ACCOUNT_ERROR_NONE){ + if (error_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_ERROR("No permission to delete\n"); return _ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -2416,14 +2374,14 @@ int _account_delete(int pid, uid_t uid, int account_id) /* transaction control required*/ ret_transaction = _account_begin_transaction(g_hAccountDB); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { pthread_mutex_unlock(&account_mutex); - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_PERMISSION_DENIED; } - if( ret_transaction == _ACCOUNT_ERROR_DATABASE_BUSY ){ - ACCOUNT_ERROR( "database busy(%s)", _account_db_err_msg(g_hAccountDB)); + if (ret_transaction == _ACCOUNT_ERROR_DATABASE_BUSY) { + ACCOUNT_ERROR("database busy(%s)", _account_db_err_msg(g_hAccountDB)); pthread_mutex_unlock(&account_mutex); return _ACCOUNT_ERROR_DATABASE_BUSY; } @@ -2439,9 +2397,9 @@ int _account_delete(int pid, uid_t uid, int account_id) hstmt = _account_prepare_query(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { pthread_mutex_unlock(&account_mutex); - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -2493,7 +2451,7 @@ int _account_delete(int pid, uid_t uid, int account_id) CATCH: if (hstmt != NULL) { rc = _account_query_finalize(hstmt); - if(rc != _ACCOUNT_ERROR_NONE ){ + if (rc != _ACCOUNT_ERROR_NONE) { ACCOUNT_ERROR("rc (%d)", rc); is_success = FALSE; } @@ -2507,7 +2465,7 @@ CATCH: ACCOUNT_ERROR("account_delete:_account_end_transaction fail %d, is_success=%d\n", ret_transaction, is_success); } else { if (is_success == true) { - char buf[64]={0,}; + char buf[64] = {0,}; ACCOUNT_SNPRINTF(buf, sizeof(buf), "%s:%d", _ACCOUNT_NOTI_NAME_DELETE, account_id); _account_insert_delete_update_notification_send(buf); } @@ -2516,7 +2474,6 @@ CATCH: pthread_mutex_unlock(&account_mutex); return error_code; - } static int _account_query_account_by_username_and_package(const char* username, const char* package_name, account_s *account) @@ -2524,7 +2481,7 @@ static int _account_query_account_by_username_and_package(const char* username, //FIXME //return -1; int error_code = _ACCOUNT_ERROR_NONE; - account_stmt hstmt = NULL; + account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; int rc = 0; int binding_count = 1; @@ -2539,8 +2496,8 @@ static int _account_query_account_by_username_and_package(const char* username, ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE user_name = ? and package_name = ?", ACCOUNT_TABLE); hstmt = _account_prepare_query(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + 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; } @@ -2573,6 +2530,7 @@ CATCH: } pthread_mutex_unlock(&account_mutex); + return error_code; } @@ -2592,10 +2550,10 @@ int _account_create(account_s **account) ACCOUNT_MEMSET(data, 0, sizeof(account_s)); /*Setting account as visible by default*/ -// data->secret = _ACCOUNT_SECRECY_VISIBLE; + //data->secret = _ACCOUNT_SECRECY_VISIBLE; /*Setting account as not supporting sync by default*/ -// data->sync_support = _ACCOUNT_SYNC_NOT_SUPPORT; + //data->sync_support = _ACCOUNT_SYNC_NOT_SUPPORT; *account = data; @@ -2615,12 +2573,11 @@ int _account_destroy(account_s *account) int _account_get_account_id(account_s* account, int *account_id) { - if (!account) { + if (!account) return _ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!account_id) { + + if (!account_id) return _ACCOUNT_ERROR_INVALID_PARAMETER; - } *account_id = account->id; @@ -2631,14 +2588,14 @@ int _account_delete_from_db_by_user_name(int pid, uid_t uid, const char *user_na { _INFO("[%s][%s]", user_name, package_name); - int error_code = _ACCOUNT_ERROR_NONE; + int error_code = _ACCOUNT_ERROR_NONE; account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - int rc = 0; - int ret_transaction = 0; + int rc = 0; + int ret_transaction = 0; bool is_success = FALSE; account_s *account = NULL; - int binding_count = 1; + int binding_count = 1; int account_id = -1; ACCOUNT_RETURN_VAL((user_name != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("user_name is null!")); @@ -2653,14 +2610,14 @@ int _account_delete_from_db_by_user_name(int pid, uid_t uid, const char *user_na package_name_temp = _account_dup_text(package_name); - ACCOUNT_DEBUG( "DELETE:user_name[%s],current_appid[%s], package_name[%s]", user_name, current_appid, package_name_temp); + ACCOUNT_DEBUG("DELETE:user_name[%s],current_appid[%s], package_name[%s]", user_name, current_appid, package_name_temp); error_code = _account_check_appid_group_with_package_name(current_appid, package_name_temp, uid); _ACCOUNT_FREE(current_appid); _ACCOUNT_FREE(package_name_temp); - if(error_code != _ACCOUNT_ERROR_NONE){ + if (error_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_ERROR("No permission to delete\n"); return _ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -2670,10 +2627,9 @@ int _account_delete_from_db_by_user_name(int pid, uid_t uid, const char *user_na _INFO(""); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ) - { + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { _account_destroy(account); - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -2687,21 +2643,18 @@ int _account_delete_from_db_by_user_name(int pid, uid_t uid, const char *user_na /* transaction control required*/ ret_transaction = _account_begin_transaction(g_hAccountDB); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ) - { - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); pthread_mutex_unlock(&account_mutex); return _ACCOUNT_ERROR_PERMISSION_DENIED; } _INFO(""); - if( ret_transaction == _ACCOUNT_ERROR_DATABASE_BUSY ) - { - ACCOUNT_ERROR( "database busy(%s)", _account_db_err_msg(g_hAccountDB)); + if (ret_transaction == _ACCOUNT_ERROR_DATABASE_BUSY) { + ACCOUNT_ERROR("database busy(%s)", _account_db_err_msg(g_hAccountDB)); pthread_mutex_unlock(&account_mutex); return _ACCOUNT_ERROR_DATABASE_BUSY; - } - else if (ret_transaction != _ACCOUNT_ERROR_NONE) { + } else if (ret_transaction != _ACCOUNT_ERROR_NONE) { ACCOUNT_ERROR("account_delete:_account_begin_transaction fail %d\n", ret_transaction); pthread_mutex_unlock(&account_mutex); return ret_transaction; @@ -2713,10 +2666,10 @@ int _account_delete_from_db_by_user_name(int pid, uid_t uid, const char *user_na hstmt = _account_prepare_query(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { _account_end_transaction(g_hAccountDB, FALSE); pthread_mutex_unlock(&account_mutex); - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -2787,7 +2740,7 @@ CATCH: ACCOUNT_ERROR("account_svc_delete:_account_svc_end_transaction fail %d, is_success=%d\n", ret_transaction, is_success); } else { if (is_success == true) { - char buf[64]={0,}; + char buf[64] = {0,}; ACCOUNT_SNPRINTF(buf, sizeof(buf), "%s:%d", _ACCOUNT_NOTI_NAME_DELETE, account_id); _account_insert_delete_update_notification_send(buf); } @@ -2806,7 +2759,7 @@ int _account_get_total_count_from_db(gboolean include_hidden, int *count) return _ACCOUNT_ERROR_INVALID_PARAMETER; } - if(!g_hAccountDB){ + if (!g_hAccountDB) { ACCOUNT_ERROR("DB is not opened\n"); return _ACCOUNT_ERROR_DB_NOT_OPENED; } @@ -2815,19 +2768,15 @@ int _account_get_total_count_from_db(gboolean include_hidden, int *count) ACCOUNT_MEMSET(query, 0x00, sizeof(query)); if (include_hidden) - { ACCOUNT_SNPRINTF(query, sizeof(query), "select count(*) from %s", ACCOUNT_TABLE); - } else - { ACCOUNT_SNPRINTF(query, sizeof(query), "select count(*) from %s where secret = %d", ACCOUNT_TABLE, _ACCOUNT_SECRECY_VISIBLE); - } *count = _account_get_record_count(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { pthread_mutex_unlock(&account_mutex); - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -2872,6 +2821,7 @@ int account_server_query_app_id_exist(const char* app_id) ret = _account_type_query_app_id_exist_from_all_db(g_hAccountDB, g_hAccountGlobalDB, app_id); _INFO("account_server_query_app_id_exist end error_code=[%d]", ret); + return ret; } @@ -2892,6 +2842,7 @@ int account_server_insert_account_type_to_user_db(account_type_s *account_type, ret = _account_type_insert_to_db(g_hAccountDB, account_type, account_type_id); _INFO("account_server_insert_account_type_to_user_db end error_code=[%d]", ret); + return ret; } @@ -2904,6 +2855,7 @@ int account_server_delete_account_type_by_app_id_from_user_db(const char * app_i ret = _account_type_delete_by_app_id(g_hAccountDB, app_id); _INFO("account_server_delete_account_type_by_app_id_from_user_db end error_code=[%d]", ret); + return ret; } @@ -2915,9 +2867,9 @@ GSList* _account_type_query_provider_feature_by_app_id_from_global_db(const char int rc = 0, binding_count = 1; GSList* feature_list = NULL; - ACCOUNT_RETURN_VAL((app_id != NULL), {*error_code = _ACCOUNT_ERROR_INVALID_PARAMETER;}, NULL, ("APP ID IS NULL")); - ACCOUNT_RETURN_VAL((error_code != NULL), {_ERR("error_code pointer is NULL");}, NULL, ("")); - ACCOUNT_RETURN_VAL((g_hAccountGlobalDB != NULL), {*error_code = _ACCOUNT_ERROR_INVALID_PARAMETER; _ERR("The database isn't connected.");}, NULL, ("The database isn't connected.")); + ACCOUNT_RETURN_VAL((app_id != NULL), { *error_code = _ACCOUNT_ERROR_INVALID_PARAMETER; }, NULL, ("APP ID IS NULL")); + ACCOUNT_RETURN_VAL((error_code != NULL), {_ERR("error_code pointer is NULL"); }, NULL, ("")); + ACCOUNT_RETURN_VAL((g_hAccountGlobalDB != NULL), { *error_code = _ACCOUNT_ERROR_INVALID_PARAMETER; _ERR("The database isn't connected."); }, NULL, ("The database isn't connected.")); ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX); @@ -2926,8 +2878,8 @@ GSList* _account_type_query_provider_feature_by_app_id_from_global_db(const char hstmt = _account_prepare_query(g_hAccountGlobalDB, query); - if( _account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + if (_account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); *error_code = _ACCOUNT_ERROR_PERMISSION_DENIED; return NULL; } @@ -2937,7 +2889,7 @@ GSList* _account_type_query_provider_feature_by_app_id_from_global_db(const char rc = _account_query_step(hstmt); - ACCOUNT_CATCH_ERROR_P(rc == SQLITE_ROW, {*error_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND; _ERR("The record isn't found from global db. rc=[%d]", rc);}, _ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n")); + ACCOUNT_CATCH_ERROR_P(rc == SQLITE_ROW, { *error_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND; _ERR("The record isn't found from global db. rc=[%d]", rc); }, _ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n")); provider_feature_s* feature_record = NULL; @@ -2971,11 +2923,11 @@ CATCH: } } - if (*error_code != _ACCOUNT_ERROR_NONE) { + if (*error_code != _ACCOUNT_ERROR_NONE) _account_type_gslist_feature_free(feature_list); - } _INFO("Returning account feature_list from global db"); + return feature_list; } @@ -2987,9 +2939,9 @@ GSList* _account_type_query_provider_feature_by_app_id(const char* app_id, int * int rc = 0, binding_count = 1; GSList* feature_list = NULL; - ACCOUNT_RETURN_VAL((app_id != NULL), {*error_code = _ACCOUNT_ERROR_INVALID_PARAMETER;}, NULL, ("APP ID IS NULL")); - ACCOUNT_RETURN_VAL((error_code != NULL), {_ERR("error_code pointer is NULL");}, NULL, ("")); - ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {*error_code = _ACCOUNT_ERROR_DB_NOT_OPENED;}, NULL, ("The database isn't connected.")); + ACCOUNT_RETURN_VAL((app_id != NULL), { *error_code = _ACCOUNT_ERROR_INVALID_PARAMETER; }, NULL, ("APP ID IS NULL")); + ACCOUNT_RETURN_VAL((error_code != NULL), {_ERR("error_code pointer is NULL"); }, NULL, ("")); + ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), { *error_code = _ACCOUNT_ERROR_DB_NOT_OPENED; }, NULL, ("The database isn't connected.")); ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX); @@ -2998,8 +2950,8 @@ GSList* _account_type_query_provider_feature_by_app_id(const char* app_id, int * hstmt = _account_prepare_query(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); *error_code = _ACCOUNT_ERROR_PERMISSION_DENIED; return NULL; } @@ -3008,7 +2960,7 @@ GSList* _account_type_query_provider_feature_by_app_id(const char* app_id, int * rc = _account_query_step(hstmt); - ACCOUNT_CATCH_ERROR_P(rc == SQLITE_ROW, {*error_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND; _ERR("The record isn't found from user db. rc=[%d]", rc);}, _ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n")); + ACCOUNT_CATCH_ERROR_P(rc == SQLITE_ROW, { *error_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND; _ERR("The record isn't found from user db. rc=[%d]", rc); }, _ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n")); provider_feature_s* feature_record = NULL; @@ -3034,7 +2986,7 @@ GSList* _account_type_query_provider_feature_by_app_id(const char* app_id, int * *error_code = _ACCOUNT_ERROR_NONE; rc = _account_query_finalize(hstmt); - ACCOUNT_CATCH_ERROR_P((rc == _ACCOUNT_ERROR_NONE), {*error_code = rc;}, rc, ("account finalize error")); + ACCOUNT_CATCH_ERROR_P((rc == _ACCOUNT_ERROR_NONE), { *error_code = rc; }, rc, ("account finalize error")); hstmt = NULL; CATCH: @@ -3048,23 +3000,23 @@ CATCH: } _INFO("*error_code=[%d]", *error_code); - if (*error_code == _ACCOUNT_ERROR_RECORD_NOT_FOUND) { + if (*error_code == _ACCOUNT_ERROR_RECORD_NOT_FOUND) feature_list = _account_type_query_provider_feature_by_app_id_from_global_db(app_id, error_code); - } if (*error_code != _ACCOUNT_ERROR_NONE) _account_type_gslist_feature_free(feature_list); _INFO("Returning account feature_list"); + return feature_list; } -int _account_type_query_provider_feature_cb_by_app_id_from_global_db(account_type_provider_feature_cb callback, const char* app_id, void *user_data ) +int _account_type_query_provider_feature_cb_by_app_id_from_global_db(account_type_provider_feature_cb callback, const char* app_id, void *user_data) { - int error_code = _ACCOUNT_ERROR_NONE; + int error_code = _ACCOUNT_ERROR_NONE; account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - int rc = 0, binding_count = 1; + int rc = 0, binding_count = 1; _INFO("_account_type_query_provider_feature_cb_by_app_id_in_global_db start app_id=%s", app_id); ACCOUNT_RETURN_VAL((app_id != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("APP ID IS NULL")); @@ -3076,15 +3028,15 @@ int _account_type_query_provider_feature_cb_by_app_id_from_global_db(account_typ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE app_id = ?", PROVIDER_FEATURE_TABLE); hstmt = _account_prepare_query(g_hAccountGlobalDB, query); - if( _account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountGlobalDB)); + if (_account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountGlobalDB)); ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, _ACCOUNT_ERROR_PERMISSION_DENIED, ("global db permission denied.\n")); } _account_query_bind_text(hstmt, binding_count++, app_id); rc = _account_query_step(hstmt); - ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {_ERR("The record isn't found. rc=[%d]", rc);}, _ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n")); + ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {_ERR("The record isn't found. rc=[%d]", rc); }, _ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n")); provider_feature_s* feature_record = NULL; @@ -3123,15 +3075,16 @@ CATCH: } _INFO("_account_type_query_provider_feature_cb_by_app_id_in_global_db end. error_code=[%d]", error_code); + return error_code; } -int _account_type_query_provider_feature_cb_by_app_id(account_type_provider_feature_cb callback, const char* app_id, void *user_data ) +int _account_type_query_provider_feature_cb_by_app_id(account_type_provider_feature_cb callback, const char* app_id, void *user_data) { - int error_code = _ACCOUNT_ERROR_NONE; + int error_code = _ACCOUNT_ERROR_NONE; account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - int rc = 0, binding_count = 1; + int rc = 0, binding_count = 1; _INFO("_account_type_query_provider_feature_cb_by_app_id start app_id=%s", app_id); ACCOUNT_RETURN_VAL((app_id != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("APP ID IS NULL")); @@ -3143,8 +3096,8 @@ int _account_type_query_provider_feature_cb_by_app_id(account_type_provider_feat ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE app_id = ?", PROVIDER_FEATURE_TABLE); hstmt = _account_prepare_query(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + 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; } @@ -3190,17 +3143,17 @@ CATCH: hstmt = NULL; } /* - if (error_code == _ACCOUNT_ERROR_RECORD_NOT_FOUND) { + if (error_code == _ACCOUNT_ERROR_RECORD_NOT_FOUND) error_code = _account_type_query_provider_feature_cb_by_app_id_from_global_db(callback, app_id, user_data); - } */ _INFO("_account_type_query_provider_feature_cb_by_app_id end"); + return error_code; } -int account_type_query_provider_feature_cb_by_app_id(account_type_provider_feature_cb callback, const char* app_id, void *user_data ) +int account_type_query_provider_feature_cb_by_app_id(account_type_provider_feature_cb callback, const char* app_id, void *user_data) { - int error_code = _ACCOUNT_ERROR_NONE; + int error_code = _ACCOUNT_ERROR_NONE; ACCOUNT_RETURN_VAL((app_id != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("APP ID IS NULL")); ACCOUNT_RETURN_VAL((callback != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("NO CALLBACK FUNCTION")); @@ -3208,9 +3161,8 @@ int account_type_query_provider_feature_cb_by_app_id(account_type_provider_featu error_code = _account_type_query_provider_feature_cb_by_app_id(callback, app_id, user_data); - if (error_code == _ACCOUNT_ERROR_RECORD_NOT_FOUND) { + if (error_code == _ACCOUNT_ERROR_RECORD_NOT_FOUND) error_code = _account_type_query_provider_feature_cb_by_app_id_from_global_db(callback, app_id, user_data); - } return error_code; } @@ -3225,8 +3177,7 @@ bool _account_type_query_supported_feature_from_global_db(const char* app_id, co char query[ACCOUNT_SQL_LEN_MAX] = {0, }; int record_count = 0; - if (app_id == NULL || capability == NULL) - { + if (app_id == NULL || capability == NULL) { *error_code = _ACCOUNT_ERROR_INVALID_PARAMETER; return false; } @@ -3235,18 +3186,18 @@ bool _account_type_query_supported_feature_from_global_db(const char* app_id, co record_count = _account_get_record_count(g_hAccountGlobalDB, query); - if( _account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountGlobalDB)); + if (_account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountGlobalDB)); *error_code = _ACCOUNT_ERROR_PERMISSION_DENIED; } - if (record_count <= 0) - { + if (record_count <= 0) { *error_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND; return false; } _INFO("_account_type_query_supported_feature_in_global_db end"); + return true; } @@ -3257,10 +3208,9 @@ bool _account_type_query_supported_feature(const char* app_id, const char* capab *error_code = _ACCOUNT_ERROR_NONE; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - int record_count = 0; + int record_count = 0; - if (app_id == NULL || capability == NULL) - { + if (app_id == NULL || capability == NULL) { *error_code = _ACCOUNT_ERROR_INVALID_PARAMETER; return false; } @@ -3269,14 +3219,13 @@ bool _account_type_query_supported_feature(const char* app_id, const char* capab 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)); + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); *error_code = _ACCOUNT_ERROR_PERMISSION_DENIED; return false; } - if (record_count <= 0) - { + if (record_count <= 0) { bool is_exist = false; is_exist = _account_type_query_supported_feature_from_global_db(app_id, capability, error_code); if (!is_exist) @@ -3284,32 +3233,33 @@ bool _account_type_query_supported_feature(const char* app_id, const char* capab } _INFO("_account_type_query_supported_feature end"); + return true; } static int _account_type_update_provider_feature(sqlite3 *account_db_handle, account_type_s *account_type, const char* app_id) { - int rc, count = 1; + int rc, count = 1; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; account_stmt hstmt = NULL; ACCOUNT_RETURN_VAL((account_type != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL")); - if (g_slist_length( account_type->provider_feature_list)==0) { - ACCOUNT_ERROR( "no feature\n"); + if (g_slist_length(account_type->provider_feature_list) == 0) { + ACCOUNT_ERROR("no feature\n"); return _ACCOUNT_ERROR_NONE; } - ACCOUNT_DEBUG( "app id", app_id); + ACCOUNT_DEBUG("app id", app_id); ACCOUNT_MEMSET(query, 0x00, sizeof(query)); ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE app_id=? ", PROVIDER_FEATURE_TABLE); 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)); + 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; } @@ -3318,7 +3268,7 @@ static int _account_type_update_provider_feature(sqlite3 *account_db_handle, acc rc = _account_query_step(hstmt); if (rc != SQLITE_DONE) { - ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(account_db_handle)); + ACCOUNT_ERROR("_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(account_db_handle)); return _ACCOUNT_ERROR_DB_FAILED; } rc = _account_query_finalize(hstmt); @@ -3349,7 +3299,7 @@ static int _account_type_update_provider_feature(sqlite3 *account_db_handle, acc rc = _account_query_step(hstmt); if (rc != SQLITE_DONE) { - ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(account_db_handle)); + ACCOUNT_ERROR("_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(account_db_handle)); break; } rc = _account_query_finalize(hstmt); @@ -3362,23 +3312,22 @@ static int _account_type_update_provider_feature(sqlite3 *account_db_handle, acc static int _account_type_update_label(sqlite3 *account_db_handle, account_type_s *account_type, const char* app_id) { - int rc, count = 1; + int rc, count = 1; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - account_stmt hstmt = NULL; + account_stmt hstmt = NULL; ACCOUNT_RETURN_VAL((account_type != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL")); - if (g_slist_length( account_type->label_list)==0) { + if (g_slist_length(account_type->label_list) == 0) return _ACCOUNT_ERROR_NONE; - } ACCOUNT_MEMSET(query, 0x00, sizeof(query)); ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE AppId=? ", LABEL_TABLE); 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)); + 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; } @@ -3387,7 +3336,7 @@ static int _account_type_update_label(sqlite3 *account_db_handle, account_type_s rc = _account_query_step(hstmt); if (rc != SQLITE_DONE) { - ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(account_db_handle)); + ACCOUNT_ERROR("_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(account_db_handle)); return _ACCOUNT_ERROR_DB_FAILED; } rc = _account_query_finalize(hstmt); @@ -3420,7 +3369,7 @@ static int _account_type_update_label(sqlite3 *account_db_handle, account_type_s rc = _account_query_step(hstmt); if (rc != SQLITE_DONE) { - ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(account_db_handle)); + ACCOUNT_ERROR("_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(account_db_handle)); break; } rc = _account_query_finalize(hstmt); @@ -3434,10 +3383,10 @@ static int _account_type_update_label(sqlite3 *account_db_handle, account_type_s static int _account_type_update_account(sqlite3 *account_db_handle, account_type_s *account_type, const char* app_id) { - int rc = 0, binding_count =1; + int rc = 0, binding_count = 1; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; int error_code = _ACCOUNT_ERROR_NONE; - account_stmt hstmt = NULL; + account_stmt hstmt = NULL; if (!account_type->app_id) { ACCOUNT_ERROR("app id is mandetory field, it can not be NULL!!!!\n"); @@ -3450,11 +3399,11 @@ static int _account_type_update_account(sqlite3 *account_db_handle, account_type 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)); + 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; - } else if (_account_db_err_code(account_db_handle) == SQLITE_BUSY){ - ACCOUNT_ERROR( "database busy(%s)", _account_db_err_msg(account_db_handle)); + } else if (_account_db_err_code(account_db_handle) == SQLITE_BUSY) { + ACCOUNT_ERROR("database busy(%s)", _account_db_err_msg(account_db_handle)); return _ACCOUNT_ERROR_DATABASE_BUSY; } @@ -3464,9 +3413,8 @@ static int _account_type_update_account(sqlite3 *account_db_handle, account_type _account_query_bind_text(hstmt, binding_count++, app_id); rc = _account_query_step(hstmt); - if (rc != SQLITE_DONE) { - ACCOUNT_ERROR( "account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg(account_db_handle)); - } + if (rc != SQLITE_DONE) + ACCOUNT_ERROR("account_db_query_step() failed(%d, %s)", rc, _account_db_err_msg(account_db_handle)); rc = _account_query_finalize(hstmt); ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {}, rc, ("finalize error")); @@ -3499,15 +3447,15 @@ int _account_type_update_to_db_by_app_id(account_type_s* account_type, const cha return error_code; } -GSList* _account_type_get_label_list_by_app_id_from_global_db(const char* app_id, int *error_code ) +GSList* _account_type_get_label_list_by_app_id_from_global_db(const char* app_id, int *error_code) { *error_code = _ACCOUNT_ERROR_NONE; account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - int rc = 0, binding_count = 1; + int rc = 0, binding_count = 1; GSList* label_list = NULL; - ACCOUNT_RETURN_VAL((app_id != NULL), {*error_code = _ACCOUNT_ERROR_INVALID_PARAMETER;}, NULL, ("APP ID IS NULL")); + ACCOUNT_RETURN_VAL((app_id != NULL), { *error_code = _ACCOUNT_ERROR_INVALID_PARAMETER; }, NULL, ("APP ID IS NULL")); ACCOUNT_RETURN_VAL((g_hAccountGlobalDB != NULL), {}, _ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected.")); ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX); @@ -3515,8 +3463,8 @@ GSList* _account_type_get_label_list_by_app_id_from_global_db(const char* app_id ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE AppId = ?", LABEL_TABLE); hstmt = _account_prepare_query(g_hAccountGlobalDB, query); - if( _account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountGlobalDB)); + if (_account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountGlobalDB)); *error_code = _ACCOUNT_ERROR_PERMISSION_DENIED; goto CATCH; @@ -3525,7 +3473,7 @@ GSList* _account_type_get_label_list_by_app_id_from_global_db(const char* app_id _account_query_bind_text(hstmt, binding_count++, app_id); rc = _account_query_step(hstmt); - ACCOUNT_CATCH_ERROR_P((rc == SQLITE_ROW), {_ERR("The record isn't found. rc=[%d] done", rc);}, _ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n")); + ACCOUNT_CATCH_ERROR_P((rc == SQLITE_ROW), {_ERR("The record isn't found. rc=[%d] done", rc); }, _ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n")); label_s* label_record = NULL; @@ -3542,7 +3490,7 @@ GSList* _account_type_get_label_list_by_app_id_from_global_db(const char* app_id _account_type_convert_column_to_label(hstmt, label_record); _INFO("Adding account label_list"); - label_list = g_slist_append (label_list, label_record); + label_list = g_slist_append(label_list, label_record); rc = _account_query_step(hstmt); } @@ -3552,34 +3500,34 @@ GSList* _account_type_get_label_list_by_app_id_from_global_db(const char* app_id CATCH: if (hstmt != NULL) { rc = _account_query_finalize(hstmt); - if (rc != _ACCOUNT_ERROR_NONE) { + if (rc != _ACCOUNT_ERROR_NONE) _ERR("global db finalize error[%d]", rc); - } hstmt = NULL; } _INFO("Returning account global label_list"); + return label_list; } -GSList* _account_type_get_label_list_by_app_id(const char* app_id, int *error_code ) +GSList* _account_type_get_label_list_by_app_id(const char* app_id, int *error_code) { *error_code = _ACCOUNT_ERROR_NONE; account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - int rc = 0, binding_count = 1; + int rc = 0, binding_count = 1; GSList* label_list = NULL; - ACCOUNT_RETURN_VAL((app_id != NULL), {*error_code = _ACCOUNT_ERROR_INVALID_PARAMETER;}, NULL, ("APP ID IS NULL")); - ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {*error_code = _ACCOUNT_ERROR_DB_NOT_OPENED;}, NULL, ("The database isn't connected.")); + ACCOUNT_RETURN_VAL((app_id != NULL), { *error_code = _ACCOUNT_ERROR_INVALID_PARAMETER; }, NULL, ("APP ID IS NULL")); + ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), { *error_code = _ACCOUNT_ERROR_DB_NOT_OPENED; }, NULL, ("The database isn't connected.")); ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX); ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE AppId = ?", LABEL_TABLE); hstmt = _account_prepare_query(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); *error_code = _ACCOUNT_ERROR_PERMISSION_DENIED; return NULL; } @@ -3604,13 +3552,13 @@ GSList* _account_type_get_label_list_by_app_id(const char* app_id, int *error_co _account_type_convert_column_to_label(hstmt, label_record); _INFO("Adding account label_list"); - label_list = g_slist_append (label_list, label_record); + label_list = g_slist_append(label_list, label_record); rc = _account_query_step(hstmt); } rc = _account_query_finalize(hstmt); - ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {*error_code = rc;}, NULL, ("finalize error")); + ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), { *error_code = rc; }, NULL, ("finalize error")); hstmt = NULL; *error_code = _ACCOUNT_ERROR_NONE; @@ -3618,24 +3566,24 @@ GSList* _account_type_get_label_list_by_app_id(const char* app_id, int *error_co CATCH: if (hstmt != NULL) { rc = _account_query_finalize(hstmt); - ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {*error_code = rc;}, NULL, ("finalize error")); + ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), { *error_code = rc; }, NULL, ("finalize error")); hstmt = NULL; } - if (*error_code == _ACCOUNT_ERROR_RECORD_NOT_FOUND) { + if (*error_code == _ACCOUNT_ERROR_RECORD_NOT_FOUND) label_list = _account_type_get_label_list_by_app_id_from_global_db(app_id, error_code); - } _INFO("Returning account label_list"); + return label_list; } -int _account_type_query_label_by_app_id_from_global_db(account_type_label_cb callback, const char* app_id, void *user_data ) +int _account_type_query_label_by_app_id_from_global_db(account_type_label_cb callback, const char* app_id, void *user_data) { - int error_code = _ACCOUNT_ERROR_NONE; + int error_code = _ACCOUNT_ERROR_NONE; account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - int rc = 0, binding_count = 1; + int rc = 0, binding_count = 1; _INFO("account_type_query_label_by_app_id_from_global_db start"); @@ -3648,8 +3596,8 @@ int _account_type_query_label_by_app_id_from_global_db(account_type_label_cb cal ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE AppId = ?", LABEL_TABLE); hstmt = _account_prepare_query(g_hAccountGlobalDB, query); - if( _account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountGlobalDB)); + if (_account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountGlobalDB)); error_code = _ACCOUNT_ERROR_PERMISSION_DENIED; goto CATCH; } @@ -3688,22 +3636,22 @@ int _account_type_query_label_by_app_id_from_global_db(account_type_label_cb cal CATCH: if (hstmt != NULL) { rc = _account_query_finalize(hstmt); - if (rc != _ACCOUNT_ERROR_NONE) { + if (rc != _ACCOUNT_ERROR_NONE) _ERR("global db finalize error[%d]", rc); - } hstmt = NULL; } _INFO("account_type_query_label_by_app_id_from_global_db end [%d]", error_code); + return error_code; } -int _account_type_query_label_by_app_id(account_type_label_cb callback, const char* app_id, void *user_data ) +int _account_type_query_label_by_app_id(account_type_label_cb callback, const char* app_id, void *user_data) { - int error_code = _ACCOUNT_ERROR_NONE; + int error_code = _ACCOUNT_ERROR_NONE; account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - int rc = 0, binding_count = 1; + int rc = 0, binding_count = 1; ACCOUNT_RETURN_VAL((app_id != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("APP ID IS NULL")); ACCOUNT_RETURN_VAL((callback != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("NO CALLBACK FUNCTION")); @@ -3714,8 +3662,8 @@ int _account_type_query_label_by_app_id(account_type_label_cb callback, const ch ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE AppId = ?", LABEL_TABLE); hstmt = _account_prepare_query(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + 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; } @@ -3743,8 +3691,8 @@ int _account_type_query_label_by_app_id(account_type_label_cb callback, const ch _account_type_free_label_with_items(label_record); -// ACCOUNT_CATCH_ERROR(cb_ret == TRUE, {}, _ACCOUNT_ERROR_NONE, ("Callback func returs FALSE, its iteration is stopped!!!!\n")); - if(cb_ret != TRUE) { + //ACCOUNT_CATCH_ERROR(cb_ret == TRUE, {}, _ACCOUNT_ERROR_NONE, ("Callback func returs FALSE, its iteration is stopped!!!!\n")); + if (cb_ret != TRUE) { _INFO("Callback func returs FALSE, its iteration is stopped!!!!\n"); break; } @@ -3772,9 +3720,9 @@ CATCH: return error_code; } -int account_type_query_label_by_app_id(account_type_label_cb callback, const char* app_id, void *user_data ) +int account_type_query_label_by_app_id(account_type_label_cb callback, const char* app_id, void *user_data) { - int error_code = _ACCOUNT_ERROR_NONE; + int error_code = _ACCOUNT_ERROR_NONE; ACCOUNT_RETURN_VAL((app_id != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("APP ID IS NULL")); ACCOUNT_RETURN_VAL((callback != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("NO CALLBACK FUNCTION")); @@ -3782,9 +3730,8 @@ int account_type_query_label_by_app_id(account_type_label_cb callback, const cha error_code = _account_type_query_label_by_app_id(callback, app_id, user_data); - if (error_code == _ACCOUNT_ERROR_RECORD_NOT_FOUND) { + if (error_code == _ACCOUNT_ERROR_RECORD_NOT_FOUND) error_code = _account_type_query_label_by_app_id_from_global_db(callback, app_id, user_data); - } return error_code; } @@ -3834,10 +3781,10 @@ int _account_type_query_by_app_id_from_global_db(const char* app_id, account_typ { _INFO("_account_type_query_by_app_id_from_global_db start"); - int error_code = _ACCOUNT_ERROR_NONE; + int error_code = _ACCOUNT_ERROR_NONE; account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - int rc = 0, binding_count = 1; + int rc = 0, binding_count = 1; ACCOUNT_RETURN_VAL((app_id != 0), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("APP ID IS NULL")); ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {}, _ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected.")); @@ -3848,8 +3795,8 @@ int _account_type_query_by_app_id_from_global_db(const char* app_id, account_typ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE AppId = ?", ACCOUNT_TYPE_TABLE); hstmt = _account_prepare_query(g_hAccountGlobalDB, query); - if( _account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountGlobalDB)); + if (_account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountGlobalDB)); return _ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -3866,9 +3813,9 @@ int _account_type_query_by_app_id_from_global_db(const char* app_id, account_typ } rc = _account_query_finalize(hstmt); - ACCOUNT_CATCH_ERROR((rc == _ACCOUNT_ERROR_NONE), {_ERR("global db finalize error rc=[%d]", rc);}, rc, ("finalize error")); + ACCOUNT_CATCH_ERROR((rc == _ACCOUNT_ERROR_NONE), {_ERR("global db finalize error rc=[%d]", rc); }, rc, ("finalize error")); _account_type_query_label_by_app_id_from_global_db(_account_get_label_text_cb, app_id, (void*)(*account_type_record)); - _account_type_query_provider_feature_cb_by_app_id_from_global_db(_account_get_provider_feature_cb, app_id,(void*)(*account_type_record)); + _account_type_query_provider_feature_cb_by_app_id_from_global_db(_account_get_provider_feature_cb, app_id, (void*)(*account_type_record)); hstmt = NULL; error_code = _ACCOUNT_ERROR_NONE; @@ -3881,6 +3828,7 @@ CATCH: } _INFO("_account_type_query_by_app_id_from_global_db end [%d]", error_code); + return error_code; } @@ -3888,10 +3836,10 @@ int _account_type_query_by_app_id(const char* app_id, account_type_s** account_t { _INFO("_account_type_query_by_app_id start"); - int error_code = _ACCOUNT_ERROR_NONE; + int error_code = _ACCOUNT_ERROR_NONE; account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - int rc = 0, binding_count = 1; + int rc = 0, binding_count = 1; ACCOUNT_RETURN_VAL((app_id != 0), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("APP ID IS NULL")); ACCOUNT_RETURN_VAL((account_type_record != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("account type record(account_type_s**) is NULL")); @@ -3902,8 +3850,8 @@ int _account_type_query_by_app_id(const char* app_id, account_type_s** account_t ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE AppId = ?", ACCOUNT_TYPE_TABLE); hstmt = _account_prepare_query(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + 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; } @@ -3927,7 +3875,7 @@ int _account_type_query_by_app_id(const char* app_id, account_type_s** account_t rc = _account_query_finalize(hstmt); ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {}, rc, ("finalize error")); _account_type_query_label_by_app_id(_account_get_label_text_cb, app_id, (void*)(*account_type_record)); - _account_type_query_provider_feature_cb_by_app_id(_account_get_provider_feature_cb, app_id,(void*)(*account_type_record)); + _account_type_query_provider_feature_cb_by_app_id(_account_get_provider_feature_cb, app_id, (void*)(*account_type_record)); hstmt = NULL; error_code = _ACCOUNT_ERROR_NONE; @@ -3939,11 +3887,11 @@ CATCH: hstmt = NULL; } - if (error_code == _ACCOUNT_ERROR_RECORD_NOT_FOUND) { + if (error_code == _ACCOUNT_ERROR_RECORD_NOT_FOUND) error_code = _account_type_query_by_app_id_from_global_db(app_id, account_type_record); - } _INFO("_account_type_query_by_app_id end [%d]", error_code); + return error_code; } @@ -3952,19 +3900,17 @@ int _account_type_query_by_provider_feature_from_global_db(const char* key, GSLi int error_code = _ACCOUNT_ERROR_NONE; account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - int rc = 0; + int rc = 0; GSList *account_type_list = NULL; _INFO("_account_type_query_by_provider_feature_from_global_db start key=%s", key); - if(key == NULL) - { + if (key == NULL) { ACCOUNT_ERROR("capability_type IS NULL."); error_code = _ACCOUNT_ERROR_INVALID_PARAMETER; goto CATCH; } - if(g_hAccountGlobalDB == NULL) - { + if (g_hAccountGlobalDB == NULL) { ACCOUNT_ERROR("The database isn't connected."); error_code = _ACCOUNT_ERROR_DB_NOT_OPENED; goto CATCH; @@ -3976,9 +3922,8 @@ int _account_type_query_by_provider_feature_from_global_db(const char* key, GSLi hstmt = _account_prepare_query(g_hAccountGlobalDB, query); - if( _account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM ) - { - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountGlobalDB)); + if (_account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountGlobalDB)); error_code = _ACCOUNT_ERROR_PERMISSION_DENIED; goto CATCH; } @@ -3990,14 +3935,13 @@ int _account_type_query_by_provider_feature_from_global_db(const char* key, GSLi account_type_s *account_type_record = NULL; - if(rc != SQLITE_ROW) - { + if (rc != SQLITE_ROW) { ACCOUNT_ERROR("The record isn't found. rc=[%d]", rc); error_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND; goto CATCH; } - while(rc == SQLITE_ROW) { + while (rc == SQLITE_ROW) { account_type_record = (account_type_s*) malloc(sizeof(account_type_s)); if (account_type_record == NULL) { @@ -4012,8 +3956,7 @@ int _account_type_query_by_provider_feature_from_global_db(const char* key, GSLi } rc = _account_query_finalize(hstmt); - if (rc != _ACCOUNT_ERROR_NONE ) - { + if (rc != _ACCOUNT_ERROR_NONE) { _account_type_gslist_account_type_free(account_type_list); ACCOUNT_ERROR("finalize error(%s)", rc); error_code = rc; @@ -4026,8 +3969,8 @@ int _account_type_query_by_provider_feature_from_global_db(const char* key, GSLi for (iter = account_type_list; iter != NULL; iter = g_slist_next(iter)) { account_type_s *account_type = NULL; account_type = (account_type_s*)iter->data; - _account_type_query_label_by_app_id_from_global_db(_account_get_label_text_cb,account_type->app_id,(void*)account_type); - _account_type_query_provider_feature_cb_by_app_id_from_global_db(_account_get_provider_feature_cb, account_type->app_id,(void*)account_type); + _account_type_query_label_by_app_id_from_global_db(_account_get_label_text_cb, account_type->app_id, (void*)account_type); + _account_type_query_provider_feature_cb_by_app_id_from_global_db(_account_get_provider_feature_cb, account_type->app_id, (void*)account_type); _INFO("add label & provider_feature"); } @@ -4045,8 +3988,7 @@ int _account_type_query_by_provider_feature_from_global_db(const char* key, GSLi CATCH: if (hstmt != NULL) { rc = _account_query_finalize(hstmt); - if (rc != _ACCOUNT_ERROR_NONE) - { + if (rc != _ACCOUNT_ERROR_NONE) { ACCOUNT_ERROR("finalize error(%s)", rc); return rc; } @@ -4054,6 +3996,7 @@ CATCH: } _INFO("_account_type_query_by_provider_feature_from_global_db end. error_code=[%d]", error_code); + return error_code; } @@ -4066,15 +4009,13 @@ GSList* _account_type_query_by_provider_feature(const char* key, int *error_code GSList *account_type_list = NULL; _INFO("account_type_query_by_provider_feature start key=%s", key); - if(key == NULL) - { + if (key == NULL) { ACCOUNT_ERROR("capability_type IS NULL."); *error_code = _ACCOUNT_ERROR_INVALID_PARAMETER; goto CATCH; } - if(g_hAccountDB == NULL) - { + if (g_hAccountDB == NULL) { ACCOUNT_ERROR("The database isn't connected."); *error_code = _ACCOUNT_ERROR_DB_NOT_OPENED; goto CATCH; @@ -4086,9 +4027,8 @@ GSList* _account_type_query_by_provider_feature(const char* key, int *error_code hstmt = _account_prepare_query(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ) - { - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); *error_code = _ACCOUNT_ERROR_PERMISSION_DENIED; goto CATCH; } @@ -4100,14 +4040,13 @@ GSList* _account_type_query_by_provider_feature(const char* key, int *error_code account_type_s *account_type_record = NULL; - if(rc != SQLITE_ROW) - { + if (rc != SQLITE_ROW) { ACCOUNT_ERROR("The record isn't found. rc=[%d]", rc); *error_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND; goto CATCH; } - while(rc == SQLITE_ROW) { + while (rc == SQLITE_ROW) { account_type_record = (account_type_s*) malloc(sizeof(account_type_s)); if (account_type_record == NULL) { @@ -4122,8 +4061,7 @@ GSList* _account_type_query_by_provider_feature(const char* key, int *error_code } rc = _account_query_finalize(hstmt); - if (rc != _ACCOUNT_ERROR_NONE ) - { + if (rc != _ACCOUNT_ERROR_NONE) { _account_type_gslist_account_type_free(account_type_list); ACCOUNT_ERROR("finalize error(%s)", rc); *error_code = rc; @@ -4136,8 +4074,8 @@ GSList* _account_type_query_by_provider_feature(const char* key, int *error_code for (iter = account_type_list; iter != NULL; iter = g_slist_next(iter)) { account_type_s *account_type = NULL; account_type = (account_type_s*)iter->data; - _account_type_query_label_by_app_id(_account_get_label_text_cb,account_type->app_id,(void*)account_type); - _account_type_query_provider_feature_cb_by_app_id(_account_get_provider_feature_cb, account_type->app_id,(void*)account_type); + _account_type_query_label_by_app_id(_account_get_label_text_cb, account_type->app_id, (void*)account_type); + _account_type_query_provider_feature_cb_by_app_id(_account_get_provider_feature_cb, account_type->app_id, (void*)account_type); } *error_code = _ACCOUNT_ERROR_NONE; @@ -4145,8 +4083,7 @@ GSList* _account_type_query_by_provider_feature(const char* key, int *error_code CATCH: if (hstmt != NULL) { rc = _account_query_finalize(hstmt); - if (rc != _ACCOUNT_ERROR_NONE) - { + if (rc != _ACCOUNT_ERROR_NONE) { *error_code = rc; return NULL; } @@ -4156,7 +4093,7 @@ CATCH: if (*error_code == _ACCOUNT_ERROR_NONE || *error_code == _ACCOUNT_ERROR_RECORD_NOT_FOUND) { rc = _account_type_query_by_provider_feature_from_global_db(key, &account_type_list); if (rc != _ACCOUNT_ERROR_NONE && rc != _ACCOUNT_ERROR_RECORD_NOT_FOUND) { - ACCOUNT_ERROR( "_account_type_query_by_provider_feature_from_global_db fail=[%d]", rc); + ACCOUNT_ERROR("_account_type_query_by_provider_feature_from_global_db fail=[%d]", rc); _account_type_gslist_account_type_free(account_type_list); return NULL; } @@ -4165,6 +4102,7 @@ CATCH: } _INFO("account_type_query_by_provider_feature end"); + return account_type_list; } @@ -4186,21 +4124,20 @@ int _account_type_query_all_from_global_db(GSList **account_type_list_all) rc = _account_query_step(hstmt); - if( _account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountGlobalDB)); + if (_account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountGlobalDB)); return _ACCOUNT_ERROR_PERMISSION_DENIED; } account_type_s *account_type_record = NULL; - if (rc != SQLITE_ROW) - { + if (rc != SQLITE_ROW) { _INFO("[_ACCOUNT_ERROR_RECORD_NOT_FOUND]The record isn't found."); error_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND; goto CATCH; } - while(rc == SQLITE_ROW) { + while (rc == SQLITE_ROW) { account_type_record = (account_type_s*) malloc(sizeof(account_type_s)); if (account_type_record == NULL) { @@ -4223,8 +4160,8 @@ int _account_type_query_all_from_global_db(GSList **account_type_list_all) for (iter = account_type_list; iter != NULL; iter = g_slist_next(iter)) { account_type_s *account_type = NULL; account_type = (account_type_s*)iter->data; - _account_type_query_label_by_app_id_from_global_db(_account_get_label_text_cb,account_type->app_id,(void*)account_type); - _account_type_query_provider_feature_cb_by_app_id_from_global_db(_account_get_provider_feature_cb, account_type->app_id,(void*)account_type); + _account_type_query_label_by_app_id_from_global_db(_account_get_label_text_cb, account_type->app_id, (void*)account_type); + _account_type_query_provider_feature_cb_by_app_id_from_global_db(_account_get_provider_feature_cb, account_type->app_id, (void*)account_type); } for (iter = account_type_list; iter != NULL; iter = g_slist_next(iter)) { @@ -4235,15 +4172,16 @@ int _account_type_query_all_from_global_db(GSList **account_type_list_all) g_slist_free(account_type_list); error_code = _ACCOUNT_ERROR_NONE; + CATCH: - if (hstmt != NULL) - { + if (hstmt != NULL) { rc = _account_query_finalize(hstmt); - ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {_account_type_gslist_account_type_free(account_type_list);}, rc, ("finalize error")); + ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {_account_type_gslist_account_type_free(account_type_list); }, rc, ("finalize error")); hstmt = NULL; } _INFO("_account_type_query_all_in_global_db end"); + return error_code; } @@ -4265,21 +4203,20 @@ GSList* _account_type_query_all(void) rc = _account_query_step(hstmt); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); return NULL; } account_type_s *account_type_record = NULL; - if (rc != SQLITE_ROW) - { + if (rc != SQLITE_ROW) { _INFO("[_ACCOUNT_ERROR_RECORD_NOT_FOUND]The record isn't found."); error_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND; goto CATCH; } - while(rc == SQLITE_ROW) { + while (rc == SQLITE_ROW) { account_type_record = (account_type_s*) malloc(sizeof(account_type_s)); if (account_type_record == NULL) { @@ -4302,39 +4239,40 @@ GSList* _account_type_query_all(void) for (iter = account_type_list; iter != NULL; iter = g_slist_next(iter)) { account_type_s *account_type = NULL; account_type = (account_type_s*)iter->data; - _account_type_query_label_by_app_id(_account_get_label_text_cb,account_type->app_id,(void*)account_type); - _account_type_query_provider_feature_cb_by_app_id(_account_get_provider_feature_cb, account_type->app_id,(void*)account_type); + _account_type_query_label_by_app_id(_account_get_label_text_cb, account_type->app_id, (void*)account_type); + _account_type_query_provider_feature_cb_by_app_id(_account_get_provider_feature_cb, account_type->app_id, (void*)account_type); } error_code = _ACCOUNT_ERROR_NONE; + CATCH: - if (hstmt != NULL) - { + if (hstmt != NULL) { rc = _account_query_finalize(hstmt); - ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {_account_type_gslist_account_type_free(account_type_list);}, NULL, ("finalize error")); + ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {_account_type_gslist_account_type_free(account_type_list); }, NULL, ("finalize error")); hstmt = NULL; } if (error_code == _ACCOUNT_ERROR_NONE || error_code == _ACCOUNT_ERROR_RECORD_NOT_FOUND) { error_code = _account_type_query_all_from_global_db(&account_type_list); if (rc != _ACCOUNT_ERROR_NONE && rc != _ACCOUNT_ERROR_RECORD_NOT_FOUND) { - ACCOUNT_ERROR( "_account_type_query_all_from_global_db fail=[%d]", rc); + ACCOUNT_ERROR("_account_type_query_all_from_global_db fail=[%d]", rc); _account_type_gslist_account_type_free(account_type_list); return NULL; } } _INFO("_account_type_query_all end"); + return account_type_list; } // output parameter label must be free int _account_type_query_label_by_locale_from_global_db(const char* app_id, const char* locale, char **label) { - int error_code = _ACCOUNT_ERROR_NONE; + int error_code = _ACCOUNT_ERROR_NONE; account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - int rc = 0, binding_count = 1; + int rc = 0, binding_count = 1; char* converted_locale = NULL; ACCOUNT_RETURN_VAL((app_id != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("NO APP ID")); @@ -4348,10 +4286,10 @@ int _account_type_query_label_by_locale_from_global_db(const char* app_id, const converted_locale = _account_dup_text(locale); gchar** tokens = g_strsplit(converted_locale, "-", 2); - if(tokens != NULL) { - if((char*)(tokens[1]) != NULL) { + if (tokens != NULL) { + if ((char*)(tokens[1]) != NULL) { char* upper_token = g_ascii_strup(tokens[1], strlen(tokens[1])); - if(upper_token != NULL) { + if (upper_token != NULL) { _ACCOUNT_FREE(converted_locale); converted_locale = g_strdup_printf("%s_%s", tokens[0], upper_token); } @@ -4365,8 +4303,8 @@ int _account_type_query_label_by_locale_from_global_db(const char* app_id, const hstmt = _account_prepare_query(g_hAccountGlobalDB, query); - if( _account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountGlobalDB)); + if (_account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountGlobalDB)); return _ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -4387,7 +4325,7 @@ int _account_type_query_label_by_locale_from_global_db(const char* app_id, const ACCOUNT_MEMSET(label_record, 0x00, sizeof(label_s)); - _account_type_convert_column_to_label(hstmt,label_record); + _account_type_convert_column_to_label(hstmt, label_record); _ACCOUNT_FREE(*label); //Making label newly created @@ -4412,16 +4350,17 @@ CATCH: } _INFO("_account_type_query_label_by_locale_from_global_db() end : error_code = %d", error_code); + return error_code; } // output parameter label must be free int _account_type_query_label_by_locale(const char* app_id, const char* locale, char **label) { - int error_code = _ACCOUNT_ERROR_NONE; + int error_code = _ACCOUNT_ERROR_NONE; account_stmt hstmt = NULL; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - int rc = 0, binding_count = 1; + int rc = 0, binding_count = 1; char* converted_locale = NULL; ACCOUNT_RETURN_VAL((app_id != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("NO APP ID")); @@ -4435,10 +4374,10 @@ int _account_type_query_label_by_locale(const char* app_id, const char* locale, converted_locale = _account_dup_text(locale); gchar** tokens = g_strsplit(converted_locale, "-", 2); - if(tokens != NULL) { - if((char*)(tokens[1]) != NULL) { + if (tokens != NULL) { + if ((char*)(tokens[1]) != NULL) { char* upper_token = g_ascii_strup(tokens[1], strlen(tokens[1])); - if(upper_token != NULL) { + if (upper_token != NULL) { _ACCOUNT_FREE(converted_locale); converted_locale = g_strdup_printf("%s_%s", tokens[0], upper_token); } @@ -4452,8 +4391,8 @@ int _account_type_query_label_by_locale(const char* app_id, const char* locale, hstmt = _account_prepare_query(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + 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; } @@ -4474,7 +4413,7 @@ int _account_type_query_label_by_locale(const char* app_id, const char* locale, ACCOUNT_MEMSET(label_record, 0x00, sizeof(label_s)); - _account_type_convert_column_to_label(hstmt,label_record); + _account_type_convert_column_to_label(hstmt, label_record); _ACCOUNT_FREE(*label); //Making label newly created @@ -4491,18 +4430,18 @@ int _account_type_query_label_by_locale(const char* app_id, const char* locale, error_code = _ACCOUNT_ERROR_NONE; - CATCH: +CATCH: if (hstmt != NULL) { rc = _account_query_finalize(hstmt); ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {}, rc, ("finalize error")); hstmt = NULL; } - if (error_code == _ACCOUNT_ERROR_RECORD_NOT_FOUND) { + if (error_code == _ACCOUNT_ERROR_RECORD_NOT_FOUND) error_code = _account_type_query_label_by_locale_from_global_db(app_id, locale, label); - } _INFO("_account_type_query_label_by_locale() end : error_code = %d", error_code); + return error_code; } @@ -4510,14 +4449,14 @@ static int _account_insert_custom(account_s *account, int account_id) { _INFO("_account_insert_custom start"); - int rc, count = 1; + int rc, count = 1; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - account_stmt hstmt = NULL; + account_stmt hstmt = NULL; ACCOUNT_RETURN_VAL((account != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL")); - if (g_slist_length( account->custom_list)==0) { - ACCOUNT_DEBUG( "_account_insert_custom, no custom data\n"); + if (g_slist_length(account->custom_list) == 0) { + ACCOUNT_DEBUG("_account_insert_custom, no custom data\n"); return _ACCOUNT_ERROR_NONE; } @@ -4525,13 +4464,13 @@ static int _account_insert_custom(account_s *account, int account_id) rc = _account_get_record_count(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%d, %s)", _account_db_err_msg(g_hAccountDB)); + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%d, %s)", _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_PERMISSION_DENIED; } if (rc <= 0) { - ACCOUNT_SLOGE( "_account_insert_custom : related account item is not existed rc=%d , %s", rc, _account_db_err_msg(g_hAccountDB)); + ACCOUNT_SLOGE("_account_insert_custom : related account item is not existed rc=%d , %s", rc, _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_RECORD_NOT_FOUND; } @@ -4548,8 +4487,8 @@ static int _account_insert_custom(account_s *account, int account_id) hstmt = _account_prepare_query(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + 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; } @@ -4570,7 +4509,7 @@ static int _account_insert_custom(account_s *account, int account_id) rc = _account_query_step(hstmt); if (rc != SQLITE_DONE) { - ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); + ACCOUNT_ERROR("_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); break; } @@ -4581,19 +4520,20 @@ static int _account_insert_custom(account_s *account, int account_id) } _INFO("_account_insert_custom end"); + return _ACCOUNT_ERROR_NONE; } static int _account_update_custom(account_s *account, int account_id) { - int rc, count = 1; + int rc, count = 1; char query[ACCOUNT_SQL_LEN_MAX] = {0, }; - account_stmt hstmt = NULL; + account_stmt hstmt = NULL; ACCOUNT_RETURN_VAL((account != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL")); - if (g_slist_length( account->custom_list)==0) { - ACCOUNT_DEBUG( "_account_update_custom, no custom data\n"); + if (g_slist_length(account->custom_list) == 0) { + ACCOUNT_DEBUG("_account_update_custom, no custom data\n"); return _ACCOUNT_ERROR_NONE; } @@ -4601,18 +4541,18 @@ static int _account_update_custom(account_s *account, int account_id) rc = _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)); + if (_account_db_err_code(g_hAccountDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(g_hAccountDB)); pthread_mutex_unlock(&account_mutex); return _ACCOUNT_ERROR_PERMISSION_DENIED; - } else if( _account_db_err_code(g_hAccountDB) == SQLITE_BUSY ){ - ACCOUNT_ERROR( "database busy(%s)", _account_db_err_msg(g_hAccountDB)); + } else if (_account_db_err_code(g_hAccountDB) == SQLITE_BUSY) { + ACCOUNT_ERROR("database busy(%s)", _account_db_err_msg(g_hAccountDB)); pthread_mutex_unlock(&account_mutex); return _ACCOUNT_ERROR_DATABASE_BUSY; } if (rc <= 0) { - ACCOUNT_SLOGE( "_account_update_custom : related account item is not existed rc=%d , %s", rc, _account_db_err_msg(g_hAccountDB)); + ACCOUNT_SLOGE("_account_update_custom : related account item is not existed rc=%d , %s", rc, _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_RECORD_NOT_FOUND; } @@ -4625,10 +4565,10 @@ static int _account_update_custom(account_s *account, int account_id) rc = _account_query_step(hstmt); if (rc == SQLITE_BUSY) { - ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); + ACCOUNT_ERROR("_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_DATABASE_BUSY; } else if (rc != SQLITE_DONE) { - ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); + ACCOUNT_ERROR("_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); return _ACCOUNT_ERROR_DB_FAILED; } @@ -4647,8 +4587,8 @@ static int _account_update_custom(account_s *account, int account_id) hstmt = _account_prepare_query(g_hAccountDB, query); - if( _account_db_err_code(g_hAccountDB) == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(g_hAccountDB)); + 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; } @@ -4669,7 +4609,7 @@ static int _account_update_custom(account_s *account, int account_id) rc = _account_query_step(hstmt); if (rc != SQLITE_DONE) { - ACCOUNT_ERROR( "_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); + ACCOUNT_ERROR("_account_query_step() failed(%d, %s)", rc, _account_db_err_msg(g_hAccountDB)); break; } diff --git a/server/src/account-server.c b/server/src/account-server.c index 14bc0a1..6e55d43 100644 --- a/server/src/account-server.c +++ b/server/src/account-server.c @@ -21,7 +21,7 @@ #include <stdlib.h> #include <signal.h> #include <glib.h> -#if !GLIB_CHECK_VERSION (2, 31, 0) +#if !GLIB_CHECK_VERSION(2, 31, 0) #include <glib/gmacros.h> #endif #include <cynara-client.h> @@ -55,8 +55,7 @@ static cynara *p_cynara; // one client can have multiple connections having different modes //static GHashTable* mode_table = NULL; -GDBusErrorEntry _account_svc_errors[] = -{ +GDBusErrorEntry _account_svc_errors[] = { {_ACCOUNT_ERROR_NONE, _ACCOUNT_SVC_ERROR_PREFIX".NoError"}, {_ACCOUNT_ERROR_OUT_OF_MEMORY, _ACCOUNT_SVC_ERROR_PREFIX".OutOfMemory"}, {_ACCOUNT_ERROR_INVALID_PARAMETER, _ACCOUNT_SVC_ERROR_PREFIX".InvalidParameter"}, @@ -82,8 +81,7 @@ _get_client_pid(GDBusMethodInvocation* invoc) { const char *name = NULL; name = g_dbus_method_invocation_get_sender(invoc); - if (name == NULL) - { + if (name == NULL) { _ERR("g_dbus_method_invocation_get_sender failed"); return -1; } @@ -109,8 +107,7 @@ _get_client_pid(GDBusMethodInvocation* invoc) NULL, &error); - if (_ret != NULL) - { + if (_ret != NULL) { g_variant_get(_ret, "(u)", &pid); g_variant_unref(_ret); } @@ -120,14 +117,14 @@ _get_client_pid(GDBusMethodInvocation* invoc) } static GQuark -__ACCOUNT_ERROR_quark (void) +__ACCOUNT_ERROR_quark(void) { static volatile gsize quark_volatile = 0; - g_dbus_error_register_error_domain (_ACCOUNT_SVC_ERROR_DOMAIN, + g_dbus_error_register_error_domain(_ACCOUNT_SVC_ERROR_DOMAIN, &quark_volatile, _account_svc_errors, - G_N_ELEMENTS (_account_svc_errors)); + G_N_ELEMENTS(_account_svc_errors)); return (GQuark) quark_volatile; } @@ -139,16 +136,16 @@ static int __check_privilege_by_cynara(const char *client, const char *session, ret = cynara_check(p_cynara, client, session, user, privilege); switch (ret) { - case CYNARA_API_ACCESS_ALLOWED: - _DBG("cynara_check success"); - return _ACCOUNT_ERROR_NONE; - case CYNARA_API_ACCESS_DENIED: - _ERR("cynara_check permission deined, privilege=%s, error = CYNARA_API_ACCESS_DENIED", privilege); - return _ACCOUNT_ERROR_PERMISSION_DENIED; - default: - cynara_strerror(ret, err_buf, sizeof(err_buf)); - _ERR("cynara_check error : %s, privilege=%s, ret = %d", err_buf, privilege, ret); - return _ACCOUNT_ERROR_PERMISSION_DENIED; + case CYNARA_API_ACCESS_ALLOWED: + _DBG("cynara_check success"); + return _ACCOUNT_ERROR_NONE; + case CYNARA_API_ACCESS_DENIED: + _ERR("cynara_check permission deined, privilege=%s, error = CYNARA_API_ACCESS_DENIED", privilege); + return _ACCOUNT_ERROR_PERMISSION_DENIED; + default: + cynara_strerror(ret, err_buf, sizeof(err_buf)); + _ERR("cynara_check error : %s, privilege=%s, ret = %d", err_buf, privilege, ret); + return _ACCOUNT_ERROR_PERMISSION_DENIED; } } @@ -160,30 +157,26 @@ int __get_information_for_cynara_check(GDBusMethodInvocation *invocation, char * //get GDBusConnection gdbus_conn = g_dbus_method_invocation_get_connection(invocation); - if(gdbus_conn == NULL) - { + if (gdbus_conn == NULL) { _ERR("g_dbus_method_invocation_get_connection failed"); return -1; } //get sender(unique_name) sender = (char*) g_dbus_method_invocation_get_sender(invocation); - if (sender == NULL) - { + if (sender == NULL) { _ERR("g_dbus_method_invocation_get_sender failed"); return -1; } ret = cynara_creds_gdbus_get_user(gdbus_conn, sender, USER_METHOD_DEFAULT, user); - if (ret != CYNARA_API_SUCCESS) - { + if (ret != CYNARA_API_SUCCESS) { _ERR("cynara_creds_gdbus_get_user failed, ret = %d", ret); return -1; } ret = cynara_creds_gdbus_get_client(gdbus_conn, sender, CLIENT_METHOD_DEFAULT, client); - if (ret != CYNARA_API_SUCCESS) - { + if (ret != CYNARA_API_SUCCESS) { _ERR("cynara_creds_gdbus_get_client failed, ret = %d", ret); return -1; } @@ -192,11 +185,11 @@ int __get_information_for_cynara_check(GDBusMethodInvocation *invocation, char * _INFO("client Id = [%u]", pid); *session = cynara_session_from_pid(pid); - if (*session == NULL) - { + if (*session == NULL) { _ERR("cynara_session_from_pid failed"); return -1; } + return _ACCOUNT_ERROR_NONE; } @@ -208,27 +201,29 @@ int _check_privilege(GDBusMethodInvocation *invocation, const char* privilege) char *user = NULL; ret = __get_information_for_cynara_check(invocation, &client, &user, &session); - if ( ret != _ACCOUNT_ERROR_NONE ) - { + if (ret != _ACCOUNT_ERROR_NONE) { _ERR("__get_information_for_cynara_check failed"); g_free(client); g_free(user); _ACCOUNT_FREE(session); + return _ACCOUNT_ERROR_PERMISSION_DENIED; } ret = __check_privilege_by_cynara(client, session, user, privilege); - if ( ret != _ACCOUNT_ERROR_NONE ) - { + if (ret != _ACCOUNT_ERROR_NONE) { _ERR("__check_privilege_by_cynara failed, ret = %d", ret); g_free(client); g_free(user); _ACCOUNT_FREE(session); + return _ACCOUNT_ERROR_PERMISSION_DENIED; } + g_free(client); g_free(user); _ACCOUNT_FREE(session); + return _ACCOUNT_ERROR_NONE; } @@ -254,77 +249,62 @@ gboolean account_manager_account_add(AccountManager *obj, GDBusMethodInvocation _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } return_code = _check_priviliege_account_write(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_write failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(1, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } account = umarshal_account(account_data); - if (account == NULL) - { + if (account == NULL) { _ERR("account unmarshalling failed"); return_code = _ACCOUNT_ERROR_DB_FAILED; - goto RETURN; } return_code = _account_insert_to_db(account, pid, (int)uid, &db_id); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_insert_to_db() error"); - goto RETURN; } RETURN: - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("Account SVC is returning error [%d]", return_code); - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { account_manager_complete_account_add(obj, invocation, db_id); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } @@ -333,10 +313,12 @@ RETURN: lifecycle_method_call_inactive(); _INFO("account_manager_account_add end"); + return true; } -gboolean account_manager_account_query_all(AccountManager *obj, GDBusMethodInvocation *invocation, gint uid) +gboolean +account_manager_account_query_all(AccountManager *obj, GDBusMethodInvocation *invocation, gint uid) { _INFO("account_manager_account_query_all start"); lifecycle_method_call_active(); @@ -347,35 +329,29 @@ gboolean account_manager_account_query_all(AccountManager *obj, GDBusMethodInvoc _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(0, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } //Mode checking not required, since default mode is read. - GSList* account_list = NULL; + GSList *account_list = NULL; account_list = _account_db_query_all(pid, (uid_t)uid); - if (account_list == NULL) - { + if (account_list == NULL) { return_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND; _ERR("No account found."); goto RETURN; @@ -391,37 +367,34 @@ gboolean account_manager_account_query_all(AccountManager *obj, GDBusMethodInvoc RETURN: - if (account_list_variant == NULL) - { - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + if (account_list_variant == NULL) { + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { account_manager_complete_account_query_all(obj, invocation, account_list_variant); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } lifecycle_method_call_inactive(); _INFO("account_manager_account_query_all end"); + return true; } -gboolean account_manager_account_type_query_all(AccountManager *obj, GDBusMethodInvocation *invocation, gint uid) +gboolean +account_manager_account_type_query_all(AccountManager *obj, GDBusMethodInvocation *invocation, gint uid) { _INFO("account_manager_account_query_all start"); lifecycle_method_call_active(); @@ -431,35 +404,29 @@ gboolean account_manager_account_type_query_all(AccountManager *obj, GDBusMethod _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(0, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } //Mode checking not required, since default mode is read. - GSList* account_type_list = NULL; + GSList *account_type_list = NULL; account_type_list = _account_type_query_all(); - if (account_type_list == NULL) - { + if (account_type_list == NULL) { return_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND; _ERR("No account type found."); goto RETURN; @@ -475,79 +442,70 @@ gboolean account_manager_account_type_query_all(AccountManager *obj, GDBusMethod RETURN: - if (account_type_list_variant == NULL) - { - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + if (account_type_list_variant == NULL) { + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { account_manager_complete_account_type_query_all(obj, invocation, account_type_list_variant); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } lifecycle_method_call_inactive(); _INFO("account_manager_account_query_all end"); + return true; } -gboolean account_manager_account_type_add(AccountManager *obj, GDBusMethodInvocation *invocation, GVariant *account_type_data, gint uid, gpointer user_data) +gboolean +account_manager_account_type_add(AccountManager *obj, GDBusMethodInvocation *invocation, GVariant *account_type_data, gint uid, gpointer user_data) { _INFO("account_manager_account_type_add start"); lifecycle_method_call_active(); int db_id = -1; - account_type_s* account_type = NULL; + account_type_s *account_type = NULL; guint pid = _get_client_pid(invocation); _INFO("client pid = [%u], uid = [%d]", pid, uid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } + return_code = _check_priviliege_account_write(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_write failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(1, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } account_type = umarshal_account_type(account_type_data); - if (account_type == NULL) - { + if (account_type == NULL) { _ERR("account_type unmarshalling failed"); return_code = _ACCOUNT_ERROR_DB_FAILED; goto RETURN; @@ -556,36 +514,31 @@ gboolean account_manager_account_type_add(AccountManager *obj, GDBusMethodInvoca _INFO("before account_server_insert_account_type_to_user_db"); return_code = account_server_insert_account_type_to_user_db(account_type, &db_id, (uid_t)uid); _INFO("after account_server_insert_account_type_to_user_db"); - if (return_code != _ACCOUNT_ERROR_NONE) - { + + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_type_insert_to_db error"); goto RETURN; } RETURN: - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("Account SVC is returning error [%d]", return_code); - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { account_manager_complete_account_type_add(obj, invocation, db_id); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } @@ -594,10 +547,12 @@ RETURN: lifecycle_method_call_inactive(); _INFO("account_manager_account_type_add end"); + return true; } -gboolean account_manager_account_delete_from_db_by_id(AccountManager *object, +gboolean +account_manager_account_delete_from_db_by_id(AccountManager *object, GDBusMethodInvocation *invocation, gint account_db_id, gint uid) @@ -609,31 +564,26 @@ gboolean account_manager_account_delete_from_db_by_id(AccountManager *object, _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } + return_code = _check_priviliege_account_write(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_write failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(1, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } @@ -641,46 +591,42 @@ gboolean account_manager_account_delete_from_db_by_id(AccountManager *object, return_code = _account_delete(pid, uid, account_db_id); _INFO("after _account_delete=[%d]", return_code); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_delete error"); goto RETURN; } RETURN: - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("Account SVC is returning error [%d]", return_code); - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { account_manager_complete_account_delete_from_db_by_id(object, invocation); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } lifecycle_method_call_inactive(); _INFO("account_manager_account_delete_from_db_by_id end"); + return true; } -gboolean account_manager_account_delete_from_db_by_user_name(AccountManager *object, +gboolean +account_manager_account_delete_from_db_by_user_name(AccountManager *object, GDBusMethodInvocation *invocation, const gchar *user_name, const gchar *package_name, @@ -693,31 +639,26 @@ gboolean account_manager_account_delete_from_db_by_user_name(AccountManager *obj _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } + return_code = _check_priviliege_account_write(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_write failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(1, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } @@ -725,46 +666,42 @@ gboolean account_manager_account_delete_from_db_by_user_name(AccountManager *obj return_code = _account_delete_from_db_by_user_name(pid, uid, user_name, package_name); _INFO("after _account_delete_from_db_by_user_name=[%d]", return_code); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_delete_from_db_by_user_name error"); goto RETURN; } RETURN: - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("Account SVC is returning error [%d]", return_code); - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { account_manager_complete_account_delete_from_db_by_id(object, invocation); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } lifecycle_method_call_inactive(); _INFO("account_manager_account_delete_from_db_by_user_name end"); + return true; } -gboolean account_manager_account_delete_from_db_by_package_name(AccountManager *object, +gboolean +account_manager_account_delete_from_db_by_package_name(AccountManager *object, GDBusMethodInvocation *invocation, const gchar *package_name, gboolean permission, @@ -778,33 +715,29 @@ gboolean account_manager_account_delete_from_db_by_package_name(AccountManager * guint pid = _get_client_pid(invocation); _INFO("client Id = [%u]", pid); - if( permission ) { + if (permission) { return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } + return_code = _check_priviliege_account_write(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_write failed, ret = %d", return_code); goto RETURN; } } return_code = _account_db_open(1, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } @@ -812,46 +745,42 @@ gboolean account_manager_account_delete_from_db_by_package_name(AccountManager * return_code = account_server_delete_account_by_package_name(package_name, permission, pid, (uid_t)uid); _INFO("after account_delete_from_db_by_package_name=[%d]", return_code); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_delete_from_db_by_package_name error"); goto RETURN; } RETURN: - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("Account SVC is returning error [%d]", return_code); - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { account_manager_complete_account_delete_from_db_by_package_name(object, invocation); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } lifecycle_method_call_inactive(); _INFO("account_manager_account_delete_from_db_by_package_name end"); + return true; } -gboolean account_manager_account_update_to_db_by_id(AccountManager *object, +gboolean +account_manager_account_update_to_db_by_id(AccountManager *object, GDBusMethodInvocation *invocation, GVariant *account_data, gint account_id, @@ -860,43 +789,37 @@ gboolean account_manager_account_update_to_db_by_id(AccountManager *object, _INFO("account_manager_account_update_to_db_by_id start"); lifecycle_method_call_active(); - account_s* account = NULL; + account_s *account = NULL; guint pid = _get_client_pid(invocation); _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } + return_code = _check_priviliege_account_write(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_write failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(1, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } account = umarshal_account(account_data); - if (account == NULL) - { + if (account == NULL) { _ERR("Unmarshal failed"); return_code = _ACCOUNT_ERROR_DB_FAILED; goto RETURN; @@ -906,36 +829,30 @@ gboolean account_manager_account_update_to_db_by_id(AccountManager *object, return_code = _account_update_to_db_by_id(pid, uid, account, account_id); _INFO("after account_update_to_db_by_id=[%d]", return_code); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_update_to_db_by_id error"); goto RETURN; } RETURN: - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("Account SVC is returning error [%d]", return_code); - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { account_manager_complete_account_update_to_db_by_id(object, invocation); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } @@ -944,10 +861,12 @@ RETURN: lifecycle_method_call_inactive(); _INFO("account_manager_account_update_to_db_by_id end"); + return true; } -gboolean account_manager_handle_account_update_to_db_by_user_name(AccountManager *object, +gboolean +account_manager_handle_account_update_to_db_by_user_name(AccountManager *object, GDBusMethodInvocation *invocation, GVariant *account_data, const gchar *user_name, @@ -963,37 +882,31 @@ gboolean account_manager_handle_account_update_to_db_by_user_name(AccountManager _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } + return_code = _check_priviliege_account_write(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_write failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(1, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } account = umarshal_account(account_data); - if (account == NULL) - { + if (account == NULL) { _ERR("Unmarshal failed"); return_code = _ACCOUNT_ERROR_DB_FAILED; goto RETURN; @@ -1003,36 +916,30 @@ gboolean account_manager_handle_account_update_to_db_by_user_name(AccountManager return_code = _account_update_to_db_by_user_name(pid, uid, account, user_name, package_name); _INFO("after account_update_to_db_by_id=[%d]", return_code); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_update_to_db_by_id error"); goto RETURN; } RETURN: - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("Account SVC is returning error [%d]", return_code); - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { account_manager_complete_account_update_to_db_by_id(object, invocation); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } @@ -1041,6 +948,7 @@ RETURN: lifecycle_method_call_inactive(); _INFO("account_manager_handle_account_update_to_db_by_user_name end"); + return true; } @@ -1060,25 +968,20 @@ account_manager_handle_account_type_query_label_by_locale(AccountManager *object _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(0, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } @@ -1086,42 +989,38 @@ account_manager_handle_account_type_query_label_by_locale(AccountManager *object return_code = _account_type_query_label_by_locale(app_id, locale, &label_name); _INFO("after _account_type_query_label_by_locale=[%d]", return_code); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_type_query_label_by_locale error"); goto RETURN; } RETURN: - if (return_code != _ACCOUNT_ERROR_NONE) - { + + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("Account SVC is returning error [%d]", return_code); - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { account_manager_complete_account_type_query_label_by_locale(object, invocation, label_name); } _ACCOUNT_FREE(label_name); return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } lifecycle_method_call_inactive(); _INFO("account_manager_handle_account_type_query_label_by_locale end"); + return true; } @@ -1141,47 +1040,40 @@ account_manager_handle_account_type_query_by_provider_feature(AccountManager *ob _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(0, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } //Mode checking not required, since default mode is read. - GSList* account_type_list = NULL; + GSList *account_type_list = NULL; + account_type_list = _account_type_query_by_provider_feature(key, &return_code); - if (return_code != 0) - { + if (return_code != 0) { _ERR("_account_type_query_by_provider_feature=[%d]", return_code); goto RETURN; } - if (account_type_list == NULL) - { + if (account_type_list == NULL) { return_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND; _ERR("No account type found."); goto RETURN; } - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_type_query_by_provider_feature error"); goto RETURN; } @@ -1195,37 +1087,34 @@ account_manager_handle_account_type_query_by_provider_feature(AccountManager *ob RETURN: - if (account_type_list_variant == NULL) - { - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), _ACCOUNT_ERROR_RECORD_NOT_FOUND, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + if (account_type_list_variant == NULL) { + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), _ACCOUNT_ERROR_RECORD_NOT_FOUND, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { account_manager_complete_account_type_query_by_provider_feature(obj, invocation, account_type_list_variant); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } lifecycle_method_call_inactive(); _INFO("account_manager_handle_account_type_query_by_provider_feature end"); + return true; } -gboolean account_manager_account_get_total_count_from_db(AccountManager *object, GDBusMethodInvocation *invocation, gboolean include_hidden, gint uid) +gboolean +account_manager_account_get_total_count_from_db(AccountManager *object, GDBusMethodInvocation *invocation, gboolean include_hidden, gint uid) { _INFO("account_manager_account_get_total_count_from_db start"); lifecycle_method_call_active(); @@ -1236,72 +1125,63 @@ gboolean account_manager_account_get_total_count_from_db(AccountManager *object, _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(0, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } - _INFO("before account_get_total_count_from_db"); return_code = _account_get_total_count_from_db(include_hidden, &count); _INFO("before account_get_total_count_from_db=[%d], return_code"); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_get_total_count_from_db error"); goto RETURN; } RETURN: - if (return_code != _ACCOUNT_ERROR_NONE) - { + + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("Account SVC is returning error [%d]", return_code); - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { account_manager_complete_account_get_total_count_from_db(object, invocation, count); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } lifecycle_method_call_inactive(); _INFO("account_manager_account_get_total_count_from_db end"); + return true; } -gboolean account_manager_handle_account_query_account_by_account_id(AccountManager *object, GDBusMethodInvocation *invocation, +gboolean +account_manager_handle_account_query_account_by_account_id(AccountManager *object, GDBusMethodInvocation *invocation, gint account_db_id, gint uid) { _INFO("account_manager_handle_account_query_account_by_account_id start"); @@ -1315,73 +1195,61 @@ gboolean account_manager_handle_account_query_account_by_account_id(AccountManag _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(0, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } account_data = create_empty_account_instance(); - if (account_data == NULL) - { + if (account_data == NULL) { _ERR("out of memory"); return_code = _ACCOUNT_ERROR_DB_FAILED; goto RETURN; } + _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); _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]); if (return_code == _ACCOUNT_ERROR_NONE) - { account_variant = marshal_account(account_data); - } - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_type_query_label_by_locale error"); goto RETURN; } RETURN: - if (account_variant == NULL || return_code != _ACCOUNT_ERROR_NONE) - { - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + + if (account_variant == NULL || return_code != _ACCOUNT_ERROR_NONE) { + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { account_manager_complete_account_query_account_by_account_id(object, invocation, account_variant); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } @@ -1390,6 +1258,7 @@ RETURN: lifecycle_method_call_inactive(); _INFO("account_manager_handle_account_query_account_by_account_id end"); + return true; } @@ -1408,36 +1277,30 @@ account_manager_handle_account_query_account_by_user_name(AccountManager *obj, _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(0, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } //Mode checking not required, since default mode is read. - GList* account_list = NULL; + GList *account_list = NULL; account_list = _account_query_account_by_user_name(pid, (uid_t)uid, user_name, &return_code); - if (account_list == NULL) - { + if (account_list == NULL) { return_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND; _ERR("No account found."); goto RETURN; @@ -1450,40 +1313,36 @@ account_manager_handle_account_query_account_by_user_name(AccountManager *obj, _account_glist_account_free(account_list); _INFO("after calling marshal_account_list_double"); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_query_account_by_user_name error"); goto RETURN; } RETURN: - if (account_list_variant == NULL) - { - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), _ACCOUNT_ERROR_RECORD_NOT_FOUND, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + + if (account_list_variant == NULL) { + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), _ACCOUNT_ERROR_RECORD_NOT_FOUND, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { account_manager_complete_account_query_account_by_user_name(obj, invocation, account_list_variant); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } lifecycle_method_call_inactive(); _INFO("account_manager_handle_account_query_account_by_user_name end"); + return true; } @@ -1502,36 +1361,30 @@ account_manager_handle_account_query_account_by_package_name(AccountManager *obj _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(0, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } //Mode checking not required, since default mode is read. - GList* account_list = NULL; + GList *account_list = NULL; account_list = account_server_query_account_by_package_name(package_name, &return_code, pid, (uid_t)uid); - if (account_list == NULL) - { + if (account_list == NULL) { return_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND; _ERR("No account found."); goto RETURN; @@ -1542,42 +1395,37 @@ account_manager_handle_account_query_account_by_package_name(AccountManager *obj account_list_variant = marshal_account_list_double(account_list); _account_glist_account_free(account_list); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_query_account_by_package_name error"); goto RETURN; } RETURN: - if (account_list_variant == NULL) - { - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + if (account_list_variant == NULL) { + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { account_manager_complete_account_query_account_by_package_name(obj, invocation, account_list_variant); } _INFO("account_manager_handle_account_query_account_by_package_name start"); return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } lifecycle_method_call_inactive(); _INFO("account_manager_handle_account_query_account_by_package_name start"); + return true; } @@ -1598,38 +1446,32 @@ account_manager_handle_account_query_account_by_capability(AccountManager *obj, _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(0, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } //Mode checking not required, since default mode is read. - GList* account_list = NULL; + GList *account_list = NULL; _INFO("before _account_query_account_by_capability"); account_list = _account_query_account_by_capability(pid, (uid_t)uid, capability_type, capability_value, &return_code); _INFO("after _account_query_account_by_capability"); - if (account_list == NULL) - { + if (account_list == NULL) { return_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND; _ERR("No account found."); goto RETURN; @@ -1640,41 +1482,36 @@ account_manager_handle_account_query_account_by_capability(AccountManager *obj, account_list_variant = marshal_account_list_double(account_list); _account_glist_account_free(account_list); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_query_account_by_capability error"); goto RETURN; } RETURN: - if (account_list_variant == NULL) - { - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), _ACCOUNT_ERROR_RECORD_NOT_FOUND, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + if (account_list_variant == NULL) { + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), _ACCOUNT_ERROR_RECORD_NOT_FOUND, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { account_manager_complete_account_query_account_by_capability(obj, invocation, account_list_variant); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } lifecycle_method_call_inactive(); _INFO("account_manager_handle_account_query_account_by_capability end"); + return true; } @@ -1694,23 +1531,19 @@ account_manager_handle_account_query_account_by_capability_type(AccountManager * _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(0, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); goto RETURN; @@ -1718,12 +1551,11 @@ account_manager_handle_account_query_account_by_capability_type(AccountManager * //Mode checking not required, since default mode is read. - GList* account_list = NULL; + GList *account_list = NULL; account_list = _account_query_account_by_capability_type(pid, (uid_t)uid, capability_type, &return_code); - if (account_list == NULL) - { + if (account_list == NULL) { return_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND; _ERR("No account found."); goto RETURN; @@ -1736,41 +1568,36 @@ account_manager_handle_account_query_account_by_capability_type(AccountManager * _account_glist_account_free(account_list); _INFO("after calling marshal_account_list_double"); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_query_account_by_capability_type error"); goto RETURN; } RETURN: - if (account_list_variant == NULL) - { - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), _ACCOUNT_ERROR_RECORD_NOT_FOUND, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + if (account_list_variant == NULL) { + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), _ACCOUNT_ERROR_RECORD_NOT_FOUND, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { account_manager_complete_account_query_account_by_capability(obj, invocation, account_list_variant); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } lifecycle_method_call_inactive(); _INFO("account_manager_handle_account_query_account_by_capability_type end"); + return true; } @@ -1790,36 +1617,30 @@ account_manager_handle_account_query_capability_by_account_id(AccountManager *ob _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(0, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } //Mode checking not required, since default mode is read. - GSList* capability_list = NULL; + GSList *capability_list = NULL; capability_list = _account_get_capability_list_by_account_id(account_id, &return_code); - if (capability_list == NULL) - { + if (capability_list == NULL) { return_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND; _ERR("No capability found."); goto RETURN; @@ -1832,45 +1653,41 @@ account_manager_handle_account_query_capability_by_account_id(AccountManager *ob _account_gslist_capability_free(capability_list); _INFO("after calling marshal_capability_list"); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_get_capability_list_by_account_id error"); goto RETURN; } RETURN: - if (capability_list_variant == NULL) - { - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), _ACCOUNT_ERROR_RECORD_NOT_FOUND, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + if (capability_list_variant == NULL) { + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), _ACCOUNT_ERROR_RECORD_NOT_FOUND, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { account_manager_complete_account_query_capability_by_account_id(obj, invocation, capability_list_variant); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } lifecycle_method_call_inactive(); _INFO("account_manager_handle_account_query_capability_by_account_id end"); + return true; } -gboolean account_manager_handle_account_update_sync_status_by_id(AccountManager *object, +gboolean +account_manager_handle_account_update_sync_status_by_id(AccountManager *object, GDBusMethodInvocation *invocation, const int account_db_id, const int sync_status, @@ -1884,31 +1701,26 @@ gboolean account_manager_handle_account_update_sync_status_by_id(AccountManager _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } + return_code = _check_priviliege_account_write(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_write failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(1, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } @@ -1916,46 +1728,42 @@ gboolean account_manager_handle_account_update_sync_status_by_id(AccountManager return_code = _account_update_sync_status_by_id(uid, account_db_id, sync_status); _INFO("after _account_update_sync_status_by_id=[%d]", return_code); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_update_sync_status_by_id error"); goto RETURN; } RETURN: - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("Account SVC is returning error [%d]", return_code); - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { account_manager_complete_account_update_sync_status_by_id(object, invocation); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } lifecycle_method_call_inactive(); _INFO("account_manager_handle_account_update_sync_status_by_id end"); + return true; } -gboolean account_manager_handle_account_type_query_provider_feature_by_app_id(AccountManager *obj, +gboolean +account_manager_handle_account_type_query_provider_feature_by_app_id(AccountManager *obj, GDBusMethodInvocation *invocation, const gchar* app_id, gint uid) @@ -1971,25 +1779,20 @@ gboolean account_manager_handle_account_type_query_provider_feature_by_app_id(Ac _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(0, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } @@ -1997,8 +1800,7 @@ gboolean account_manager_handle_account_type_query_provider_feature_by_app_id(Ac feature_record_list = _account_type_query_provider_feature_by_app_id(app_id, &return_code); _INFO("after account_type_query_provider_feature_by_app_id=[%d]", return_code); - if (feature_record_list == NULL) - { + if (feature_record_list == NULL) { _ERR("account feature_record_list is NULL"); return_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND; goto RETURN; @@ -2007,45 +1809,42 @@ gboolean account_manager_handle_account_type_query_provider_feature_by_app_id(Ac feature_record_list_variant = provider_feature_list_to_variant(feature_record_list); _account_type_gslist_feature_free(feature_record_list); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_type_query_provider_feature_by_app_id error"); goto RETURN; } RETURN: - if (return_code != _ACCOUNT_ERROR_NONE) - { - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + + if (return_code != _ACCOUNT_ERROR_NONE) { + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { _INFO("Calling account_manager_complete_account_type_query_provider_feature_by_app_id"); account_manager_complete_account_type_query_provider_feature_by_app_id(obj, invocation, feature_record_list_variant); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } lifecycle_method_call_inactive(); _INFO("account_manager_handle_account_type_query_provider_feature_by_app_id end"); + return true; } -gboolean account_manager_handle_account_type_query_supported_feature(AccountManager *obj, +gboolean +account_manager_handle_account_type_query_supported_feature(AccountManager *obj, GDBusMethodInvocation *invocation, const gchar* app_id, const gchar* capability, @@ -2060,25 +1859,20 @@ gboolean account_manager_handle_account_type_query_supported_feature(AccountMana _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(0, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } @@ -2086,45 +1880,42 @@ gboolean account_manager_handle_account_type_query_supported_feature(AccountMana is_supported = _account_type_query_supported_feature(app_id, capability, &return_code); _INFO("after _account_type_query_supported_feature=[%d]", return_code); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_type_query_supported_feature error"); goto RETURN; } RETURN: - if (return_code != _ACCOUNT_ERROR_NONE) - { - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + + if (return_code != _ACCOUNT_ERROR_NONE) { + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { _INFO("Calling account_manager_complete_account_type_query_provider_feature_by_app_id"); account_manager_complete_account_type_query_supported_feature(obj, invocation, is_supported); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } lifecycle_method_call_inactive(); _INFO("account_manager_handle_account_type_query_supported_feature end"); + return true; } -gboolean account_manager_handle_account_type_update_to_db_by_app_id (AccountManager *obj, +gboolean +account_manager_handle_account_type_update_to_db_by_app_id(AccountManager *obj, GDBusMethodInvocation *invocation, GVariant *account_type_variant, const gchar *app_id, @@ -2140,31 +1931,26 @@ gboolean account_manager_handle_account_type_update_to_db_by_app_id (AccountMana _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } + return_code = _check_priviliege_account_write(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_write failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(1, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } @@ -2174,35 +1960,30 @@ gboolean account_manager_handle_account_type_update_to_db_by_app_id (AccountMana return_code = _account_type_update_to_db_by_app_id(account_type, app_id); _INFO("after _account_type_update_to_db_by_app_id=[%d]", return_code); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_type_update_to_db_by_app_id error"); goto RETURN; } RETURN: - if (return_code != _ACCOUNT_ERROR_NONE) - { - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + + if (return_code != _ACCOUNT_ERROR_NONE) { + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { _INFO("Calling account_manager_complete_account_type_update_to_db_by_app_id"); account_manager_complete_account_type_update_to_db_by_app_id(obj, invocation); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } @@ -2211,10 +1992,12 @@ RETURN: lifecycle_method_call_inactive(); _INFO("account_manager_handle_account_type_update_to_db_by_app_id end"); + return true; } -gboolean account_manager_handle_account_type_delete_by_app_id (AccountManager *obj, +gboolean +account_manager_handle_account_type_delete_by_app_id(AccountManager *obj, GDBusMethodInvocation *invocation, const gchar *app_id, gint uid) @@ -2227,31 +2010,26 @@ gboolean account_manager_handle_account_type_delete_by_app_id (AccountManager *o _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } + return_code = _check_priviliege_account_write(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_write failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(1, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } @@ -2259,45 +2037,42 @@ gboolean account_manager_handle_account_type_delete_by_app_id (AccountManager *o return_code = account_server_delete_account_type_by_app_id_from_user_db(app_id); _INFO("after account_server_delete_account_type_by_app_id_from_user_db=[%d]", return_code); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("account_server_delete_account_type_by_app_id error"); goto RETURN; } RETURN: - if (return_code != _ACCOUNT_ERROR_NONE) - { - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + + if (return_code != _ACCOUNT_ERROR_NONE) { + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { _ERR("Calling account_manager_complete_account_type_update_to_db_by_app_id"); - account_manager_complete_account_type_delete_by_app_id (obj, invocation); + account_manager_complete_account_type_delete_by_app_id(obj, invocation); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } lifecycle_method_call_inactive(); _INFO("account_manager_handle_account_type_delete_by_app_id end"); + return true; } -gboolean account_manager_handle_account_type_query_label_by_app_id (AccountManager *obj, +gboolean +account_manager_handle_account_type_query_label_by_app_id(AccountManager *obj, GDBusMethodInvocation *invocation, const gchar *app_id, gint uid) @@ -2313,74 +2088,66 @@ gboolean account_manager_handle_account_type_query_label_by_app_id (AccountManag _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(0, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } _INFO("before _account_type_get_label_list_by_app_id"); - label_list = _account_type_get_label_list_by_app_id (app_id, &return_code); + label_list = _account_type_get_label_list_by_app_id(app_id, &return_code); _INFO("after _account_type_get_label_list_by_app_id=[%d]", return_code); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_type_get_label_list_by_app_id = [%d]", return_code); goto RETURN; } - label_list_variant = label_list_to_variant (label_list); + label_list_variant = label_list_to_variant(label_list); _account_type_gslist_label_free(label_list); RETURN: - if (return_code != _ACCOUNT_ERROR_NONE) - { - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + + if (return_code != _ACCOUNT_ERROR_NONE) { + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { _ERR("Calling account_manager_complete_account_type_query_label_by_app_id"); - account_manager_complete_account_type_query_label_by_app_id (obj, invocation, label_list_variant); + account_manager_complete_account_type_query_label_by_app_id(obj, invocation, label_list_variant); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } lifecycle_method_call_inactive(); _INFO("account_manager_handle_account_type_query_label_by_app_id end"); + return true; } -gboolean account_manager_handle_account_type_query_by_app_id (AccountManager *obj, +gboolean +account_manager_handle_account_type_query_by_app_id(AccountManager *obj, GDBusMethodInvocation *invocation, const gchar *app_id, gint uid) @@ -2396,70 +2163,60 @@ gboolean account_manager_handle_account_type_query_by_app_id (AccountManager *ob _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(0, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } _INFO("before _account_type_query_by_app_id"); - return_code = _account_type_query_by_app_id (app_id, &account_type); + return_code = _account_type_query_by_app_id(app_id, &account_type); _INFO("after _account_type_query_by_app_id=[%d]", return_code); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_type_query_by_app_id = [%d]", return_code); goto RETURN; } - if (account_type == NULL) - { + + if (account_type == NULL) { _ERR("account_type read is NULL"); return_code = _ACCOUNT_ERROR_RECORD_NOT_FOUND; goto RETURN; } - account_type_variant = marshal_account_type( account_type); + account_type_variant = marshal_account_type(account_type); RETURN: - if (return_code != _ACCOUNT_ERROR_NONE) - { + + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("Account SVC is returning error [%d]", return_code); - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { _INFO("Calling account_manager_complete_account_type_query_by_app_id"); - account_manager_complete_account_type_query_by_app_id (obj, invocation, account_type_variant); + account_manager_complete_account_type_query_by_app_id(obj, invocation, account_type_variant); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } @@ -2471,7 +2228,8 @@ RETURN: return true; } -gboolean account_manager_handle_account_type_query_app_id_exist (AccountManager *obj, +gboolean +account_manager_handle_account_type_query_app_id_exist(AccountManager *obj, GDBusMethodInvocation *invocation, const gchar *app_id, gint uid) @@ -2484,25 +2242,20 @@ gboolean account_manager_handle_account_type_query_app_id_exist (AccountManager _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(0, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } @@ -2510,46 +2263,43 @@ gboolean account_manager_handle_account_type_query_app_id_exist (AccountManager return_code = account_server_query_app_id_exist(app_id); _INFO("after _account_server_query_app_id_exist=[%d]", return_code); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_type_query_app_id_exist_from_all_db = [%d]", return_code); goto RETURN; } RETURN: - if (return_code != _ACCOUNT_ERROR_NONE) - { + + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("Account SVC is returning error [%d]", return_code); - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { _INFO("Calling account_manager_complete_account_type_query_by_app_id_exist"); - account_manager_complete_account_type_query_app_id_exist (obj, invocation); + account_manager_complete_account_type_query_app_id_exist(obj, invocation); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } lifecycle_method_call_inactive(); _INFO("account_manager_handle_account_type_query_app_id_exist end"); + return true; } -gboolean account_manager_handle_account_update_to_db_by_id_ex (AccountManager *obj, +gboolean +account_manager_handle_account_update_to_db_by_id_ex(AccountManager *obj, GDBusMethodInvocation *invocation, GVariant *account_data, gint account_id, @@ -2564,76 +2314,65 @@ gboolean account_manager_handle_account_update_to_db_by_id_ex (AccountManager *o _INFO("client Id = [%u]", pid); int return_code = _check_priviliege_account_read(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_read failed, ret = %d", return_code); goto RETURN; } + return_code = _check_priviliege_account_write(invocation); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_check_priviliege_account_write failed, ret = %d", return_code); goto RETURN; } return_code = _account_db_open(1, pid, uid); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_db_open() error, ret = %d", return_code); - goto RETURN; } return_code = _account_global_db_open(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } account = umarshal_account(account_data); - if (account == NULL) - { + if (account == NULL) { _ERR("Unmarshal failed"); return_code = _ACCOUNT_ERROR_INVALID_PARAMETER; goto RETURN; } _INFO("before _account_update_to_db_by_id_ex"); - return_code = _account_update_to_db_by_id_ex (account, account_id); + return_code = _account_update_to_db_by_id_ex(account, account_id); _INFO("after _account_update_to_db_by_id_ex()=[%d]", return_code); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("_account_update_to_db_by_id_ex error"); goto RETURN; } RETURN: - if (return_code != _ACCOUNT_ERROR_NONE) - { + + if (return_code != _ACCOUNT_ERROR_NONE) { _ERR("Account SVC is returning error [%d]", return_code); - GError* error = g_error_new (__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); - g_dbus_method_invocation_return_gerror (invocation, error); + GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound"); + g_dbus_method_invocation_return_gerror(invocation, error); g_error_free(error); - } - else - { + } else { _INFO("Calling account_manager_complete_account_update_to_db_by_id_ex"); - account_manager_complete_account_update_to_db_by_id_ex (obj, invocation); + account_manager_complete_account_update_to_db_by_id_ex(obj, invocation); } return_code = _account_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } return_code = _account_global_db_close(); - if (return_code != _ACCOUNT_ERROR_NONE) - { + if (return_code != _ACCOUNT_ERROR_NONE) { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); return_code = _ACCOUNT_ERROR_NONE; } @@ -2646,21 +2385,19 @@ RETURN: } static void -on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data) +on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) { _INFO("on_bus_acquired [%s]", name); GDBusInterfaceSkeleton* interface = NULL; account_mgr_server_obj = account_manager_skeleton_new(); - if (account_mgr_server_obj == NULL) - { + if (account_mgr_server_obj == NULL) { _ERR("account_mgr_server_obj NULL!!"); return; } - interface = G_DBUS_INTERFACE_SKELETON(account_mgr_server_obj); - if (!g_dbus_interface_skeleton_export(interface, connection, ACCOUNT_MGR_DBUS_PATH, NULL)) - { + interface = G_DBUS_INTERFACE_SKELETON(account_mgr_server_obj); + if (!g_dbus_interface_skeleton_export(interface, connection, ACCOUNT_MGR_DBUS_PATH, NULL)) { _ERR("export failed!!"); return; } @@ -2727,7 +2464,6 @@ on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_d g_signal_connect(account_mgr_server_obj, "handle_account_type_query_provider_feature_by_app_id", G_CALLBACK(account_manager_handle_account_type_query_provider_feature_by_app_id), NULL); - g_signal_connect(account_mgr_server_obj, "handle_account_type_query_supported_feature", G_CALLBACK(account_manager_handle_account_type_query_supported_feature), NULL); @@ -2753,9 +2489,10 @@ on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_d _INFO("connecting account signals end"); g_dbus_object_manager_server_set_connection(account_mgr_server_mgr, connection); - if( connection == NULL ) { + + if (connection == NULL) _INFO("g_dbus_object_manager_server_set_connection failed"); - } + _INFO("on_bus_acquired end [%s]", name); } @@ -2768,45 +2505,40 @@ void terminate_main_loop() } static void -on_name_acquired (GDBusConnection *connection, - const gchar *name, - gpointer user_data) +on_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) { _INFO("on_name_acquired"); - } static void -on_name_lost (GDBusConnection *connection, - const gchar *name, - gpointer user_data) +on_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data) { _INFO("on_name_lost"); - exit (1); + exit(1); } static bool _initialize_dbus() { _INFO("__initialize_dbus Enter"); - owner_id = g_bus_own_name (G_BUS_TYPE_SYSTEM, - "org.tizen.account.manager", - G_BUS_NAME_OWNER_FLAGS_NONE, - on_bus_acquired, - on_name_acquired, - on_name_lost, - NULL, - NULL); + owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, + "org.tizen.account.manager", + G_BUS_NAME_OWNER_FLAGS_NONE, + on_bus_acquired, + on_name_acquired, + on_name_lost, + NULL, + NULL); _INFO("owner_id=[%d]", owner_id); - if(owner_id == 0) - { - _INFO("gdbus own failed!!"); - return false; + if (owner_id == 0) { + _INFO("gdbus own failed!!"); + return false; } _INFO("g_bus_own_name SUCCESS"); + return true; } @@ -2818,20 +2550,19 @@ static void _terminate_server_by_timeout() static void _initialize() { -#if !GLIB_CHECK_VERSION(2,35,0) +#if !GLIB_CHECK_VERSION(2, 35, 0) g_type_init(); #endif int ret = -1; - if (_initialize_dbus() == false) - { /* because dbus's initialize - failed, we cannot continue any more. */ + if (_initialize_dbus() == false) { + /* because dbus's initialize failed, we cannot continue any more. */ _ERR("DBUS Initialization Failed"); exit(1); } ret = cynara_initialize(&p_cynara, NULL); - if(ret != CYNARA_API_SUCCESS) { + if (ret != CYNARA_API_SUCCESS) { _ERR("CYNARA Initialization fail"); exit(1); } @@ -2858,5 +2589,6 @@ int main() cynara_finish(p_cynara); _INFO("Ending Accounts SVC"); + return 0; } diff --git a/server/src/lifecycle.c b/server/src/lifecycle.c index f1786fe..48a506a 100644 --- a/server/src/lifecycle.c +++ b/server/src/lifecycle.c @@ -77,15 +77,14 @@ void lifecycle_method_call_inactive() pthread_mutex_unlock(&lifecycle_mutex); if (method_call_count <= 0) { - if (!is_running_timer) { pthread_mutex_lock(&lifecycle_mutex); pthread_mutex_unlock(&lifecycle_mutex); int ret = pthread_create(&curThread, NULL, lifecycle_termination_timer, NULL); _INFO("account create timer thread"); - if(ret != 0) + if (ret != 0) { _ERR("account pthread_create fail!"); - else { + } else { pthread_mutex_lock(&lifecycle_mutex); is_running_timer = true; pthread_mutex_unlock(&lifecycle_mutex); |