From: jiseob.jang Date: Wed, 16 Dec 2015 08:21:38 +0000 (+0900) Subject: apply tizen coding rule. X-Git-Tag: submit/tizen_mobile/20151228.112115^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=615f0681c341867590a3cb32c27e37cbbc45d4dd;p=platform%2Fcore%2Fapi%2Flibaccount-service.git apply tizen coding rule. Change-Id: Ia5aea5c0d36b7ef67a7558969465950274652db7 Signed-off-by: jiseob.jang --- diff --git a/include/account-error.h b/include/account-error.h index c61e298..363cc9e 100644 --- a/include/account-error.h +++ b/include/account-error.h @@ -36,14 +36,11 @@ extern "C" * @brief This file contains ACCOUNT error definitions. */ -//#define TIZEN_ERROR_ACCOUNT_CLASS SLP_ERROR_ACCOUNT | 0x90 - /** * @brief Enumerations of error codes for ACCOUNT APIs. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.4 @endif */ -typedef enum -{ +typedef enum { ACCOUNT_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ ACCOUNT_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ ACCOUNT_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ diff --git a/include/account-types.h b/include/account-types.h index 9b92667..c4cbf34 100644 --- a/include/account-types.h +++ b/include/account-types.h @@ -40,81 +40,74 @@ extern "C" * @brief Enumeration for the state of capability. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.4 @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; /** * @brief Enumeration for the state of account secrecy. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.4 @endif */ -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 -} -account_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 +} account_secrecy_state_e; /** * @brief Enumeration for the account sync status. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.4 @endif */ -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; /** * @brief Enumeration for the account auth type. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.4 @endif */ -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; /** * @brief The structure type for the Account handle. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.4 @endif */ -typedef struct account_s* account_h; +typedef struct account_s *account_h; /** * @brief The structure type for the Account provider handle. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.4 @endif */ -typedef struct account_type_s* account_type_h; +typedef struct account_type_s *account_type_h; /** * @brief The structure type for the Account handle. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.4 @endif */ -typedef struct label_s* label_h; +typedef struct label_s *label_h; /** * @brief The structure type for the Account subscribe handle. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.4 @endif */ -typedef struct account_subscribe_s* account_subscribe_h; +typedef struct account_subscribe_s *account_subscribe_h; /** * @brief The insert notification type. @@ -157,7 +150,7 @@ typedef struct account_subscribe_s* account_subscribe_h; * @brief This is a key of app_control_h’s extra data. The value of the key is a user account name. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.4 @endif * @remarks You can retrieve the value like this, app_control_get_extra_data(app_control, ACCOUNT_DATA_USERNAME, &username).\n - This value will be sent with ACCOUNT_OPERATION_VIEW. + * This value will be sent with ACCOUNT_OPERATION_VIEW. */ #define ACCOUNT_DATA_USERNAME "http://tizen.org/account/data/username" @@ -165,7 +158,7 @@ typedef struct account_subscribe_s* account_subscribe_h; * @brief This is a key of app_control_h’s extra data. The value of the key is account DB ID of the user’s account information. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.4 @endif * @remarks You can retrieve the value like this, app_control_get_extra_data(app_control, ACCOUNT_DATA_ID, &id).\n - This value will be sent with ACCOUNT_OPERATION_VIEW. + * This value will be sent with ACCOUNT_OPERATION_VIEW. */ #define ACCOUNT_DATA_ID "http://tizen.org/appcontrol/data/account/id" diff --git a/include/account_internal.h b/include/account_internal.h index 1fc0524..1051a35 100644 --- a/include/account_internal.h +++ b/include/account_internal.h @@ -233,7 +233,7 @@ int account_type_set_multiple_account_support(account_type_h account_type, const * * @see account_type_get_label() */ -int account_type_set_label(account_type_h account_type, const char* label, const char* locale); +int account_type_set_label(account_type_h account_type, const char *label, const char *locale); /** * @internal @@ -250,7 +250,7 @@ int account_type_set_label(account_type_h account_type, const char* label, const * * @see account_set_capability() */ -int account_type_set_provider_feature(account_type_h account_type, const char* provider_feature); +int account_type_set_provider_feature(account_type_h account_type, const char *provider_feature); /** * @internal @@ -279,7 +279,7 @@ int account_type_set_provider_feature(account_type_h account_type, const char* p * @see account_connect() * @see account_disconnect() */ -int account_type_insert_to_db(account_type_h account_type, int* account_type_id); +int account_type_insert_to_db(account_type_h account_type, int *account_type_id); /** * @internal @@ -307,7 +307,7 @@ int account_type_insert_to_db(account_type_h account_type, int* account_type_id) * @see account_connect() * @see account_disconnect() */ -int account_type_update_to_db_by_app_id(const account_type_h account_type, const char* app_id); +int account_type_update_to_db_by_app_id(const account_type_h account_type, const char *app_id); /** * @internal @@ -334,7 +334,7 @@ int account_type_update_to_db_by_app_id(const account_type_h account_type, const * @see account_connect() * @see account_disconnect() */ -int account_type_delete_by_app_id(const char* app_id); +int account_type_delete_by_app_id(const char *app_id); /** * @internal @@ -352,7 +352,7 @@ int account_type_delete_by_app_id(const char* app_id); * @see account_unsubscribe_notification() * @see account_subscribe_notification() */ -int account_subscribe_notification_ex(account_subscribe_h account_subscribe, account_event_cb cb_func, void* user_data); +int account_subscribe_notification_ex(account_subscribe_h account_subscribe, account_event_cb cb_func, void *user_data); /** * @internal @@ -393,9 +393,9 @@ int account_unsubscribe_notification_ex(account_subscribe_h account_subscribe); int account_get_total_count_from_db_ex(int *count); /*offline apis*/ -int account_type_insert_to_db_offline(account_type_h account_type, int* account_type_id); +int account_type_insert_to_db_offline(account_type_h account_type, int *account_type_id); -int account_type_delete_by_app_id_offline(const char* app_id); +int account_type_delete_by_app_id_offline(const char *app_id); /** * @} diff --git a/include/mobile/account.h b/include/mobile/account.h index 700b107..7934824 100644 --- a/include/mobile/account.h +++ b/include/mobile/account.h @@ -75,7 +75,7 @@ typedef bool (*account_cb)(account_h account, void *user_data); * * @see account_query_capability_by_account_id() */ -typedef bool (*capability_cb)(const char* capability_type, account_capability_state_e capability_state, void *user_data); +typedef bool (*capability_cb)(const char *capability_type, account_capability_state_e capability_state, void *user_data); /** * @brief Called once for each custom data of an account in the database. @@ -92,7 +92,7 @@ typedef bool (*capability_cb)(const char* capability_type, account_capability_st * * @see account_query_capability_by_account_id() */ -typedef bool (*account_custom_cb)(char* key, char* value, void *user_data); +typedef bool (*account_custom_cb)(char *key, char *value, void *user_data); /** @@ -131,7 +131,7 @@ typedef bool (*account_type_cb)(account_type_h account_type, void *user_data); * @see account_type_get_label() * @see account_type_query_label_by_app_id() */ -typedef bool (*account_label_cb)(char* app_id, char* label, char* locale, void *user_data); +typedef bool (*account_label_cb)(char *app_id, char *label, char *locale, void *user_data); /** @@ -150,7 +150,7 @@ typedef bool (*account_label_cb)(char* app_id, char* label, char* locale, void * * @see account_type_query_provider_feature_by_app_id() * @see account_type_get_provider_feature_all() */ -typedef bool (*provider_feature_cb)(char* app_id, char* key, void* user_data); +typedef bool (*provider_feature_cb)(char *app_id, char *key, void *user_data); /** @@ -168,7 +168,7 @@ typedef bool (*provider_feature_cb)(char* app_id, char* key, void* user_data); * * @see account_subscribe_notification() */ -typedef bool (*account_event_cb)(const char* event_type, int account_id, void* user_data); +typedef bool (*account_event_cb)(const char *event_type, int account_id, void *user_data); /** @@ -596,7 +596,7 @@ int account_set_display_name(account_h account, const char *display_name); * * @see account_set_capability() */ -int account_get_capability(account_h account, const char* capability_type, account_capability_state_e* capability_value); +int account_get_capability(account_h account, const char *capability_type, account_capability_state_e *capability_value); /** * @brief Gets all the capabilities of an account. @@ -630,7 +630,7 @@ int account_get_capability_all(account_h account, capability_cb callback, void * * * @see account_get_capability() */ -int account_set_capability(account_h account, const char* capability_type, account_capability_state_e capability_state); +int account_set_capability(account_h account, const char *capability_type, account_capability_state_e capability_state); /** @@ -1047,7 +1047,7 @@ int account_set_source(account_h account, const char *source); * * @see account_get_custom() */ -int account_set_custom(account_h account, const char* key, const char* value); +int account_set_custom(account_h account, const char *key, const char *value); /** * @brief Gets the user specific custom text of an account key. @@ -1065,7 +1065,7 @@ int account_set_custom(account_h account, const char* key, const char* value); * * @see account_set_custom() */ -int account_get_custom(account_h account, const char* key, char** value); +int account_get_custom(account_h account, const char *key, char **value); /** @@ -1084,7 +1084,7 @@ int account_get_custom(account_h account, const char* key, char** value); * * @see account_set_custom() */ -int account_get_custom_all(account_h account, account_custom_cb callback, void* user_data); +int account_get_custom_all(account_h account, account_custom_cb callback, void *user_data); /** * @brief Retrieves all accounts details by invoking the given callback function iteratively. @@ -1176,7 +1176,7 @@ int account_query_account_by_account_id(int account_db_id, account_h *account); * @see account_query_account_by_capability() * */ -int account_query_account_by_user_name(account_cb callback, const char* user_name, void* user_data); +int account_query_account_by_user_name(account_cb callback, const char *user_name, void *user_data); /** * @brief Retrieves all accounts with the package name. @@ -1239,7 +1239,7 @@ int account_query_account_by_package_name(account_cb callback, const char *packa * @see account_query_account_by_user_name() * @see account_query_account_by_package_name() */ -int account_query_account_by_capability(account_cb callback, const char* capability_type, account_capability_state_e capability_value, void *user_data); +int account_query_account_by_capability(account_cb callback, const char *capability_type, account_capability_state_e capability_value, void *user_data); /** * @brief Retrieves all accounts with the capability type. @@ -1270,7 +1270,7 @@ int account_query_account_by_capability(account_cb callback, const char* capabil * @see account_query_account_by_user_name() * @see account_query_account_by_package_name() */ -int account_query_account_by_capability_type(account_cb callback, const char* capability_type, void* user_data); +int account_query_account_by_capability_type(account_cb callback, const char *capability_type, void *user_data); /** * @brief Retrieves all capabilities with the account database ID. @@ -1413,7 +1413,7 @@ int account_type_destroy(account_type_h account_type); * @pre This function requires an open connection to an account service by account_connect() on tizen 2.3.\n * But the account_connect() is not required to use this function since tizen 2.4. */ -int account_type_query_provider_feature_by_app_id(provider_feature_cb callback, const char* app_id, void *user_data ); +int account_type_query_provider_feature_by_app_id(provider_feature_cb callback, const char *app_id, void *user_data); /** * @brief Checks whether the given application ID supports the capability. @@ -1441,7 +1441,7 @@ int account_type_query_provider_feature_by_app_id(provider_feature_cb callback, * @pre This function requires an open connection to an account service by account_connect() on tizen 2.3.\n * But the account_connect() is not required to use this function since tizen 2.4. */ -bool account_type_query_supported_feature(const char* app_id, const char* capability); +bool account_type_query_supported_feature(const char *app_id, const char *capability); /** * @brief Gets the application ID of an account provider. @@ -1566,7 +1566,7 @@ int account_type_get_multiple_account_support(account_type_h account_type, int * * @pre This function requires an open connection to an account service by account_connect() on tizen 2.3.\n * But the account_connect() is not required to use this function since tizen 2.4. */ -int account_type_get_provider_feature_all(account_type_h account_type, provider_feature_cb callback, void* user_data); +int account_type_get_provider_feature_all(account_type_h account_type, provider_feature_cb callback, void *user_data); /** * @brief Gets the specific label information detail of an account provider. @@ -1588,7 +1588,7 @@ int account_type_get_provider_feature_all(account_type_h account_type, provider_ * @see account_type_query_by_app_id() */ -int account_type_get_label_by_locale(account_type_h account_type, const char* locale, char** label); +int account_type_get_label_by_locale(account_type_h account_type, const char *locale, char **label); /** * @brief Gets the label information detail of an account provider. @@ -1636,7 +1636,7 @@ int account_type_get_label(account_type_h account_type, account_label_cb callbac * @see account_type_query_by_app_id() * @see account_type_foreach_account_type_from_db() */ -int account_type_query_label_by_app_id(account_label_cb callback, const char* app_id, void *user_data ); +int account_type_query_label_by_app_id(account_label_cb callback, const char *app_id, void *user_data); /** * @brief Retrieves the account provider information with your application ID. @@ -1669,7 +1669,7 @@ int account_type_query_label_by_app_id(account_label_cb callback, const char* ap * @see account_type_get_label() * @see account_type_destroy() */ -int account_type_query_by_app_id(const char* app_id, account_type_h *account_type); +int account_type_query_by_app_id(const char *app_id, account_type_h *account_type); /** * @brief Retrieves all account priovider information. @@ -1729,7 +1729,7 @@ int account_type_foreach_account_type_from_db(account_type_cb callback, void *us * @pre This function requires an open connection to an account service by account_connect() on tizen 2.3.\n * But the account_connect() is not required to use this function since tizen 2.4. */ -int account_type_query_label_by_locale(const char* app_id, const char* locale, char** label); +int account_type_query_label_by_locale(const char *app_id, const char *locale, char **label); /** * @brief Retrieves account provider information with the capability name. @@ -1755,7 +1755,7 @@ int account_type_query_label_by_locale(const char* app_id, const char* locale, c * @pre This function requires an open connection to an account service by account_connect() on tizen 2.3.\n * But the account_connect() is not required to use this function since tizen 2.4. */ -int account_type_query_by_provider_feature(account_type_cb callback, const char* key, void* user_data); +int account_type_query_by_provider_feature(account_type_cb callback, const char *key, void *user_data); /** * @brief Checks whether the given app_id exists in the account provider DB. @@ -1780,7 +1780,7 @@ int account_type_query_by_provider_feature(account_type_cb callback, const char* * * @see account_type_query_by_app_id() */ -int account_type_query_app_id_exist(const char* app_id); +int account_type_query_app_id_exist(const char *app_id); @@ -1803,7 +1803,7 @@ int account_type_query_app_id_exist(const char* app_id); * @see account_unsubscribe_notification() * @see account_subscribe_notification() */ -int account_subscribe_create(account_subscribe_h* account_subscribe); +int account_subscribe_create(account_subscribe_h *account_subscribe); /** * @brief Starts to subscribe account event through the given callback function. @@ -1827,7 +1827,7 @@ int account_subscribe_create(account_subscribe_h* account_subscribe); * @see account_unsubscribe_notification() * @see account_subscribe_notification() */ -int account_subscribe_notification(account_subscribe_h account_subscribe, account_event_cb callback, void* user_data); +int account_subscribe_notification(account_subscribe_h account_subscribe, account_event_cb callback, void *user_data); /** * @brief Destroys the account subscribe handle and releases all its resources. @@ -1854,4 +1854,4 @@ int account_unsubscribe_notification(account_subscribe_h account_subscribe); #endif -#endif //__ACCOUNT_H_ +#endif /* __ACCOUNT_H_ */ diff --git a/include/wearable/account.h b/include/wearable/account.h index e8e1ee1..442dfc9 100644 --- a/include/wearable/account.h +++ b/include/wearable/account.h @@ -75,7 +75,7 @@ typedef bool (*account_cb)(account_h account, void *user_data); * * @see account_query_capability_by_account_id() */ -typedef bool (*capability_cb)(const char* capability_type, account_capability_state_e capability_state, void *user_data); +typedef bool (*capability_cb)(const char *capability_type, account_capability_state_e capability_state, void *user_data); /** * @brief Called once for each custom data of an account in the database. @@ -92,7 +92,7 @@ typedef bool (*capability_cb)(const char* capability_type, account_capability_st * * @see account_query_capability_by_account_id() */ -typedef bool (*account_custom_cb)(char* key, char* value, void *user_data); +typedef bool (*account_custom_cb)(char *key, char *value, void *user_data); /** @@ -131,7 +131,7 @@ typedef bool (*account_type_cb)(account_type_h account_type, void *user_data); * @see account_type_get_label() * @see account_type_query_label_by_app_id() */ -typedef bool (*account_label_cb)(char* app_id, char* label, char* locale, void *user_data); +typedef bool (*account_label_cb)(char *app_id, char *label, char *locale, void *user_data); /** @@ -150,7 +150,7 @@ typedef bool (*account_label_cb)(char* app_id, char* label, char* locale, void * * @see account_type_query_provider_feature_by_app_id() * @see account_type_get_provider_feature_all() */ -typedef bool (*provider_feature_cb)(char* app_id, char* key, void* user_data); +typedef bool (*provider_feature_cb)(char *app_id, char *key, void *user_data); /** @@ -168,7 +168,7 @@ typedef bool (*provider_feature_cb)(char* app_id, char* key, void* user_data); * * @see account_subscribe_notification() */ -typedef bool (*account_event_cb)(const char* event_type, int account_id, void* user_data); +typedef bool (*account_event_cb)(const char *event_type, int account_id, void *user_data); /** * @brief Creates a handle to the account. @@ -526,7 +526,7 @@ int account_set_display_name(account_h account, const char *display_name); * * @see account_set_capability() */ -int account_get_capability(account_h account, const char* capability_type, account_capability_state_e* capability_value); +int account_get_capability(account_h account, const char *capability_type, account_capability_state_e *capability_value); /** * @brief Gets all the capabilities of an account. @@ -560,7 +560,7 @@ int account_get_capability_all(account_h account, capability_cb callback, void * * * @see account_get_capability() */ -int account_set_capability(account_h account, const char* capability_type, account_capability_state_e capability_state); +int account_set_capability(account_h account, const char *capability_type, account_capability_state_e capability_state); /** @@ -977,7 +977,7 @@ int account_set_source(account_h account, const char *source); * * @see account_get_custom() */ -int account_set_custom(account_h account, const char* key, const char* value); +int account_set_custom(account_h account, const char *key, const char *value); /** * @brief Gets the user specific custom text of an account key. @@ -995,7 +995,7 @@ int account_set_custom(account_h account, const char* key, const char* value); * * @see account_set_custom() */ -int account_get_custom(account_h account, const char* key, char** value); +int account_get_custom(account_h account, const char *key, char **value); /** @@ -1014,7 +1014,7 @@ int account_get_custom(account_h account, const char* key, char** value); * * @see account_set_custom() */ -int account_get_custom_all(account_h account, account_custom_cb callback, void* user_data); +int account_get_custom_all(account_h account, account_custom_cb callback, void *user_data); /** * @brief Retrieves all accounts details by invoking the given callback function iteratively. @@ -1099,7 +1099,7 @@ int account_query_account_by_account_id(int account_db_id, account_h *account); * @see account_query_account_by_capability() * */ -int account_query_account_by_user_name(account_cb callback, const char* user_name, void* user_data); +int account_query_account_by_user_name(account_cb callback, const char *user_name, void *user_data); /** * @brief Retrieves all accounts with the package name. @@ -1158,7 +1158,7 @@ int account_query_account_by_package_name(account_cb callback, const char *packa * @see account_query_account_by_user_name() * @see account_query_account_by_package_name() */ -int account_query_account_by_capability(account_cb callback, const char* capability_type, account_capability_state_e capability_value, void *user_data); +int account_query_account_by_capability(account_cb callback, const char *capability_type, account_capability_state_e capability_value, void *user_data); /** * @brief Retrieves all accounts with the capability type. @@ -1187,7 +1187,7 @@ int account_query_account_by_capability(account_cb callback, const char* capabil * @see account_query_account_by_user_name() * @see account_query_account_by_package_name() */ -int account_query_account_by_capability_type(account_cb callback, const char* capability_type, void* user_data); +int account_query_account_by_capability_type(account_cb callback, const char *capability_type, void *user_data); /** * @brief Retrieves all capabilities with the account database ID. @@ -1322,7 +1322,7 @@ int account_type_destroy(account_type_h account_type); * @retval #ACCOUNT_ERROR_DB_NOT_OPENED Account database did not opened * */ -int account_type_query_provider_feature_by_app_id(provider_feature_cb callback, const char* app_id, void *user_data ); +int account_type_query_provider_feature_by_app_id(provider_feature_cb callback, const char *app_id, void *user_data); /** * @brief Checks whether the given application ID supports the capability. @@ -1348,7 +1348,7 @@ int account_type_query_provider_feature_by_app_id(provider_feature_cb callback, * @excaption #ACCOUNT_ERROR_DB_NOT_OPENED Account database did not opened * */ -bool account_type_query_supported_feature(const char* app_id, const char* capability); +bool account_type_query_supported_feature(const char *app_id, const char *capability); /** * @brief Gets the application ID of an account provider. @@ -1471,7 +1471,7 @@ int account_type_get_multiple_account_support(account_type_h account_type, int * * @retval #ACCOUNT_ERROR_DB_FAILED Database operation failed * */ -int account_type_get_provider_feature_all(account_type_h account_type, provider_feature_cb callback, void* user_data); +int account_type_get_provider_feature_all(account_type_h account_type, provider_feature_cb callback, void *user_data); /** * @brief Gets the specific label information detail of an account provider. @@ -1493,7 +1493,7 @@ int account_type_get_provider_feature_all(account_type_h account_type, provider_ * @see account_type_query_by_app_id() */ -int account_type_get_label_by_locale(account_type_h account_type, const char* locale, char** label); +int account_type_get_label_by_locale(account_type_h account_type, const char *locale, char **label); /** * @brief Gets the label information detail of an account provider. @@ -1538,7 +1538,7 @@ int account_type_get_label(account_type_h account_type, account_label_cb callbac * @see account_type_query_by_app_id() * @see account_type_foreach_account_type_from_db() */ -int account_type_query_label_by_app_id(account_label_cb callback, const char* app_id, void *user_data ); +int account_type_query_label_by_app_id(account_label_cb callback, const char *app_id, void *user_data); /** * @brief Retrieves the account provider information with your application ID. @@ -1569,7 +1569,7 @@ int account_type_query_label_by_app_id(account_label_cb callback, const char* ap * @see account_type_get_label() * @see account_type_destroy() */ -int account_type_query_by_app_id(const char* app_id, account_type_h *account_type); +int account_type_query_by_app_id(const char *app_id, account_type_h *account_type); /** * @brief Retrieves all account priovider information. @@ -1624,7 +1624,7 @@ int account_type_foreach_account_type_from_db(account_type_cb callback, void *us * @retval #ACCOUNT_ERROR_DB_NOT_OPENED Account database did not opened * */ -int account_type_query_label_by_locale(const char* app_id, const char* locale, char** label); +int account_type_query_label_by_locale(const char *app_id, const char *locale, char **label); /** * @brief Retrieves account provider information with the capability name. @@ -1648,7 +1648,7 @@ int account_type_query_label_by_locale(const char* app_id, const char* locale, c * @retval #ACCOUNT_ERROR_DB_NOT_OPENED Account database did not opened * */ -int account_type_query_by_provider_feature(account_type_cb callback, const char* key, void* user_data); +int account_type_query_by_provider_feature(account_type_cb callback, const char *key, void *user_data); /** * @brief Checks whether the given app_id exists in the account provider DB. @@ -1670,7 +1670,7 @@ int account_type_query_by_provider_feature(account_type_cb callback, const char* * * @see account_type_query_by_app_id() */ -int account_type_query_app_id_exist(const char* app_id); +int account_type_query_app_id_exist(const char *app_id); @@ -1693,7 +1693,7 @@ int account_type_query_app_id_exist(const char* app_id); * @see account_unsubscribe_notification() * @see account_subscribe_notification() */ -int account_subscribe_create(account_subscribe_h* account_subscribe); +int account_subscribe_create(account_subscribe_h *account_subscribe); /** * @brief Starts to subscribe account event through the given callback function. @@ -1717,7 +1717,7 @@ int account_subscribe_create(account_subscribe_h* account_subscribe); * @see account_unsubscribe_notification() * @see account_subscribe_notification() */ -int account_subscribe_notification(account_subscribe_h account_subscribe, account_event_cb callback, void* user_data); +int account_subscribe_notification(account_subscribe_h account_subscribe, account_event_cb callback, void *user_data); /** * @brief Destroys the account subscribe handle and releases all its resources. @@ -1744,4 +1744,4 @@ int account_unsubscribe_notification(account_subscribe_h account_subscribe); #endif -#endif //__ACCOUNT_H_ +#endif /* __ACCOUNT_H_ */ diff --git a/src/account.c b/src/account.c index b11f4d6..953a5bd 100644 --- a/src/account.c +++ b/src/account.c @@ -54,31 +54,29 @@ static char *_account_get_text(const char *text_data) { char *text_value = NULL; - if (text_data != NULL) { + if (text_data != NULL) text_value = strdup(text_data); - } + return text_value; } -//FIXME : add true singleton logic AccountManager * -_account_manager_get_instance () +_account_manager_get_instance() { _INFO("_account_manager_get_instance"); - if (_acc_mgr != NULL) - { + if (_acc_mgr != NULL) { _INFO("instance already created."); return _acc_mgr; } -#if !GLIB_CHECK_VERSION(2,35,0) +#if !GLIB_CHECK_VERSION(2, 35, 0) g_type_init(); #endif GDBusConnection *connection = NULL; GError *error = NULL; - connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); + connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); _INFO("after g_bus_get_sync"); @@ -106,7 +104,7 @@ _account_manager_get_instance () _ERR("Unable account_manager_proxy_new_sync: %s", error->message); g_clear_error(&error); } - if(connection) + if (connection) g_object_unref(connection); return NULL; } @@ -116,8 +114,7 @@ _account_manager_get_instance () return _acc_mgr; } -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"}, @@ -140,25 +137,20 @@ GDBusErrorEntry _account_svc_errors[] = static int _account_get_error_code(bool is_success, GError *error) { - if (!is_success) - { + if (!is_success) { _INFO("Received error Domain[%d] Message[%s] Code[%d]", error->domain, error->message, error->code); - if (g_dbus_error_is_remote_error(error)) - { + if (g_dbus_error_is_remote_error(error)) { gchar *remote_error = g_dbus_error_get_remote_error(error); - if (remote_error) - { + if (remote_error) { _INFO("Remote error[%s]", remote_error); - //FIXME: Temp fix, error->code sent from daemon is not the same as the one received. - //However error->message matches, so doing reverse lookup + /* FIXME: Temp fix, error->code sent from daemon is not the same as the one received. + However error->message matches, so doing reverse lookup */ int error_enum_count = G_N_ELEMENTS(_account_svc_errors); int i = 0; - for (i = 0; i < error_enum_count; i++) - { - if (g_strcmp0(_account_svc_errors[i].dbus_error_name, remote_error) == 0) - { + for (i = 0; i < error_enum_count; i++) { + if (g_strcmp0(_account_svc_errors[i].dbus_error_name, remote_error) == 0) { _INFO("Remote error code matched[%d]", _account_svc_errors[i].error_code); g_free(remote_error); return _account_svc_errors[i].error_code; @@ -167,7 +159,7 @@ static int _account_get_error_code(bool is_success, GError *error) g_free(remote_error); } } - //All undocumented errors mapped to ACCOUNT_ERROR_PERMISSION_DENIED + /* All undocumented errors mapped to ACCOUNT_ERROR_PERMISSION_DENIED */ return ACCOUNT_ERROR_PERMISSION_DENIED; } return ACCOUNT_ERROR_NONE; @@ -198,16 +190,16 @@ ACCOUNT_API int account_insert_to_db(account_h account, int *account_db_id) ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL")); ACCOUNT_RETURN_VAL((account_db_id != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT ID POINTER IS NULL")); - account_s *account_data = (account_s*) account; + account_s *account_data = (account_s *)account; int error_code = ACCOUNT_ERROR_NONE; GError *error = NULL; _INFO("2. Before _account_manager_get_instance()"); - AccountManager* acc_mgr = _account_manager_get_instance(); + AccountManager *acc_mgr = _account_manager_get_instance(); ACCOUNT_CATCH_ERROR((acc_mgr != NULL), {}, ACCOUNT_ERROR_PERMISSION_DENIED, "Failed to get dbus."); int db_id = -1; - GVariant* account_serialized = marshal_account(account_data); + GVariant *account_serialized = marshal_account(account_data); _INFO("3. Before account_manager_call_account_add_sync"); bool is_success = account_manager_call_account_add_sync(acc_mgr, account_serialized, (int)getuid(), &db_id, NULL, &error); @@ -223,7 +215,6 @@ ACCOUNT_API int account_insert_to_db(account_h account, int *account_db_id) CATCH: g_clear_error(&error); - //Failed to get dbus. _ERR("account_manager_call_account_add_sync()=[%d]", error_code); return error_code; @@ -238,9 +229,8 @@ ACCOUNT_API int account_delete_from_db_by_id(int account_db_id) GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -249,8 +239,7 @@ ACCOUNT_API int account_delete_from_db_by_id(int account_db_id) GVariant *account_serialized_old = NULL; bool is_success = account_manager_call_account_query_account_by_account_id_sync(acc_mgr, account_db_id, (int)getuid(), &account_serialized_old, NULL, &error); - if (!is_success) - { + if (!is_success) { error_code = _account_get_error_code(is_success, error); g_clear_error(&error); _ERR("account_manager_call_account_query_account_by_account_id_sync failed [%d]", error_code); @@ -261,8 +250,7 @@ ACCOUNT_API int account_delete_from_db_by_id(int account_db_id) _INFO("3. Before account_manager_call_account_delete_from_db_by_id_sync"); is_success = account_manager_call_account_delete_from_db_by_id_sync(acc_mgr, account_db_id, (int)getuid(), NULL, &error); - if (!is_success) - { + if (!is_success) { error_code = _account_get_error_code(is_success, error); _ERR("account_manager_call_account_delete_from_db_by_id_sync failed [%d]", error_code); g_clear_error(&error); @@ -285,38 +273,31 @@ ACCOUNT_API int account_delete_from_db_by_user_name(char *user_name, char *packa GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } - GVariant* account_list_variant = NULL; + GVariant *account_list_variant = NULL; bool is_success = account_manager_call_account_query_account_by_user_name_sync(acc_mgr, user_name, (int)getuid(), &account_list_variant, NULL, &error); error_code = _account_get_error_code(is_success, error); g_clear_error(&error); - if (error_code != ACCOUNT_ERROR_NONE) - { + if (error_code != ACCOUNT_ERROR_NONE) { _ERR("account_query_account_by_user_name error=[%d]", error_code); return error_code; } - GSList* account_list = unmarshal_account_list(account_list_variant); + GSList *account_list = unmarshal_account_list(account_list_variant); g_variant_unref(account_list_variant); if (account_list == NULL) - { return ACCOUNT_ERROR_NO_DATA; - } - - //TODO free account_list, account_list_variant is_success = account_manager_call_account_delete_from_db_by_user_name_sync(acc_mgr, user_name, package_name, (int)getuid(), NULL, &error); - if (!is_success) - { + if (!is_success) { error_code = _account_get_error_code(is_success, error); g_clear_error(&error); _ERR("account_manager_call_account_delete_from_db_by_user_name_sync failed [%d]", error_code); @@ -338,9 +319,8 @@ int _account_delete_from_db_by_package_name(const char *package_name, bool permi GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -365,8 +345,7 @@ int _account_delete_from_db_by_package_name(const char *package_name, bool permi */ bool is_success = account_manager_call_account_delete_from_db_by_package_name_sync(acc_mgr, package_name, permission, (int)getuid(), NULL, &error); - if (!is_success) - { + if (!is_success) { error_code = _account_get_error_code(is_success, error); g_clear_error(&error); _ERR("account_manager_call_account_delete_from_db_by_package_name_sync failed [%d]", error_code); @@ -385,7 +364,6 @@ ACCOUNT_API int account_delete_from_db_by_package_name(const char *package_name) ACCOUNT_API int account_update_to_db_by_id(account_h account, int account_id) { - //First we will update account db _INFO("1. account_update_to_db_by_id start"); int error_code = ACCOUNT_ERROR_NONE; @@ -394,9 +372,8 @@ ACCOUNT_API int account_update_to_db_by_id(account_h account, int account_id) GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -405,8 +382,7 @@ ACCOUNT_API int account_update_to_db_by_id(account_h account, int account_id) GVariant *account_serialized_old = NULL; bool is_success = account_manager_call_account_query_account_by_account_id_sync(acc_mgr, account_id, (int)getuid(), &account_serialized_old, NULL, &error); - if (!is_success) - { + if (!is_success) { error_code = _account_get_error_code(is_success, error); g_clear_error(&error); _ERR("account_manager_call_account_query_account_by_account_id_sync failed [%d]", error_code); @@ -415,11 +391,10 @@ ACCOUNT_API int account_update_to_db_by_id(account_h account, int account_id) g_clear_error(&error); _INFO("3. Before account_manager_call_account_update_to_db_by_id_sync"); - GVariant* account_serialized = marshal_account((account_s*) account); + GVariant *account_serialized = marshal_account((account_s *)account); is_success = account_manager_call_account_update_to_db_by_id_sync(acc_mgr, account_serialized, account_id, (int)getuid(), NULL, &error); - if (!is_success) - { + if (!is_success) { error_code = _account_get_error_code(is_success, error); g_clear_error(&error); _ERR("account_manager_call_account_update_to_db_by_id_sync failed [%d]", error_code); @@ -441,9 +416,6 @@ ACCOUNT_API int account_update_to_db_by_id_ex(account_h account, int account_id) ACCOUNT_INTERNAL_API int account_update_to_db_by_id_without_permission(account_h account, int account_id) { - //First we will update account db - //Then we will update gSSO DB, if it fails then we will rollback account db updates - _INFO("account_update_to_db_by_id_without_permission start"); int error_code = ACCOUNT_ERROR_NONE; @@ -452,9 +424,8 @@ ACCOUNT_INTERNAL_API int account_update_to_db_by_id_without_permission(account_h GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -463,8 +434,7 @@ ACCOUNT_INTERNAL_API int account_update_to_db_by_id_without_permission(account_h _INFO("before query() account_id[%d]", account_id); bool is_success = account_manager_call_account_query_account_by_account_id_sync(acc_mgr, account_id, (int)getuid(), &account_serialized_old, NULL, &error); - if (!is_success) - { + if (!is_success) { error_code = _account_get_error_code(is_success, error); g_clear_error(&error); _ERR("account_manager_call_account_query_account_by_account_id_sync failed [%d]", error_code); @@ -472,11 +442,10 @@ ACCOUNT_INTERNAL_API int account_update_to_db_by_id_without_permission(account_h } g_clear_error(&error); - _INFO("before marshal() : account_id[%d], user_name=%s", account_id, ((account_s*)account)->user_name); - GVariant* account_serialized = marshal_account((account_s*) account); + _INFO("before marshal() : account_id[%d], user_name=%s", account_id, ((account_s *)account)->user_name); + GVariant *account_serialized = marshal_account((account_s *)account); _INFO("after marshal() : account_id[%d]", account_id); - if (account_serialized == NULL) - { + if (account_serialized == NULL) { _ERR("Invalid input"); return ACCOUNT_ERROR_INVALID_PARAMETER; } @@ -485,8 +454,7 @@ ACCOUNT_INTERNAL_API int account_update_to_db_by_id_without_permission(account_h is_success = account_manager_call_account_update_to_db_by_id_ex_sync(acc_mgr, account_serialized, account_id, (int)getuid(), NULL, &error); _INFO("after call update() : is_success=%d", is_success); - if (!is_success) - { + if (!is_success) { error_code = _account_get_error_code(is_success, error); g_clear_error(&error); _ERR("account_manager_call_account_update_to_db_by_id_ex_sync failed [%d]", error_code); @@ -499,7 +467,6 @@ ACCOUNT_INTERNAL_API int account_update_to_db_by_id_without_permission(account_h ACCOUNT_API int account_update_to_db_by_user_name(account_h account, const char *user_name, const char *package_name) { - //First we will update account db _INFO("account_update_to_db_by_user_name starting"); int error_code = ACCOUNT_ERROR_NONE; @@ -509,19 +476,17 @@ ACCOUNT_API int account_update_to_db_by_user_name(account_h account, const char GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } GVariant *account_serialized_old = NULL; - account_s *account_data = (account_s*) account; + account_s *account_data = (account_s *)account; bool is_success = account_manager_call_account_query_account_by_account_id_sync(acc_mgr, account_data->id, (int)getuid(), &account_serialized_old, NULL, &error); - if (!is_success) - { + if (!is_success) { error_code = _account_get_error_code(is_success, error); g_clear_error(&error); _ERR("account_manager_call_account_query_account_by_account_id_sync failed [%d]", error_code); @@ -529,11 +494,10 @@ ACCOUNT_API int account_update_to_db_by_user_name(account_h account, const char } g_clear_error(&error); - GVariant* account_serialized = marshal_account(account_data); + GVariant *account_serialized = marshal_account(account_data); is_success = account_manager_call_account_update_to_db_by_user_name_sync(acc_mgr, account_serialized, user_name, package_name, (int)getuid(), NULL, &error); - if (!is_success) - { + if (!is_success) { error_code = _account_get_error_code(is_success, error); g_clear_error(&error); _ERR("account_manager_call_account_update_to_db_by_user_name_sync failed [%d]", error_code); @@ -552,7 +516,7 @@ ACCOUNT_API int account_create(account_h *account) return ACCOUNT_ERROR_INVALID_PARAMETER; } - account_s *data = (account_s*)malloc(sizeof(account_s)); + account_s *data = (account_s *)malloc(sizeof(account_s)); if (data == NULL) { ACCOUNT_FATAL("Memory Allocation Failed"); return ACCOUNT_ERROR_OUT_OF_MEMORY; @@ -560,19 +524,16 @@ ACCOUNT_API int account_create(account_h *account) ACCOUNT_MEMSET(data, 0, sizeof(account_s)); - /*Setting account as visible by default*/ + /* Setting account as visible by default */ data->secret = ACCOUNT_SECRECY_VISIBLE; - /*Setting account as not supporting sync by default*/ + /* Setting account as not supporting sync by default */ data->sync_support = ACCOUNT_SYNC_NOT_SUPPORT; data->auth_type = ACCOUNT_AUTH_TYPE_INVALID; -// data->account_list = NULL; data->capablity_list = NULL; data->custom_list = NULL; -// data->domain_list = NULL; -// data->mechanism_list = NULL; *account = (account_h)data; @@ -583,7 +544,7 @@ ACCOUNT_API int account_create(account_h *account) ACCOUNT_API int account_destroy(account_h account) { _INFO("account_destroy start"); - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; ACCOUNT_RETURN_VAL((data != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Account handle is null!")); @@ -605,7 +566,7 @@ ACCOUNT_API int account_set_user_name(account_h account, const char *user_name) return ACCOUNT_ERROR_INVALID_PARAMETER; } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; _ACCOUNT_FREE(data->user_name); data->user_name = _account_get_text(user_name); @@ -629,7 +590,7 @@ ACCOUNT_API int account_set_display_name(account_h account, const char *display_ return ACCOUNT_ERROR_INVALID_PARAMETER; } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; _ACCOUNT_FREE(data->display_name); data->display_name = _account_get_text(display_name); @@ -653,7 +614,7 @@ ACCOUNT_API int account_set_email_address(account_h account, const char *email_a return ACCOUNT_ERROR_INVALID_PARAMETER; } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; _ACCOUNT_FREE(data->email_address); data->email_address = _account_get_text(email_address); @@ -677,7 +638,7 @@ ACCOUNT_API int account_set_icon_path(account_h account, const char *icon_path) return ACCOUNT_ERROR_INVALID_PARAMETER; } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; _ACCOUNT_FREE(data->icon_path); data->icon_path = _account_get_text(icon_path); @@ -700,7 +661,7 @@ ACCOUNT_API int account_set_source(account_h account, const char *source) ACCOUNT_SLOGE("(%s)-(%d) source is NULL.\n", __FUNCTION__, __LINE__); return ACCOUNT_ERROR_INVALID_PARAMETER; } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; _ACCOUNT_FREE(data->source); data->source = _account_get_text(source); @@ -724,7 +685,7 @@ ACCOUNT_API int account_set_package_name(account_h account, const char *package_ return ACCOUNT_ERROR_INVALID_PARAMETER; } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; _ACCOUNT_FREE(data->package_name); data->package_name = _account_get_text(package_name); @@ -747,7 +708,7 @@ ACCOUNT_API int account_set_domain_name(account_h account, const char *domain_na ACCOUNT_SLOGE("(%s)-(%d) domain_name is NULL.\n", __FUNCTION__, __LINE__); return ACCOUNT_ERROR_INVALID_PARAMETER; } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; _ACCOUNT_FREE(data->domain_name); data->domain_name = _account_get_text(domain_name); @@ -771,7 +732,7 @@ ACCOUNT_API int account_set_access_token(account_h account, const char *access_t return ACCOUNT_ERROR_INVALID_PARAMETER; } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; _ACCOUNT_FREE(data->access_token); data->access_token = _account_get_text(access_token); @@ -799,7 +760,7 @@ ACCOUNT_API int account_set_user_text(account_h account, int idx, const char *us return ACCOUNT_ERROR_INVALID_PARAMETER; } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; _ACCOUNT_FREE(data->user_data_txt[idx]); data->user_data_txt[idx] = _account_get_text(user_txt); @@ -811,7 +772,7 @@ ACCOUNT_API int account_set_user_text(account_h account, int idx, const char *us return ACCOUNT_ERROR_NONE; } -ACCOUNT_API int account_set_custom(account_h account, const char* key, const char* value) +ACCOUNT_API int account_set_custom(account_h account, const char *key, const char *value) { if (!account) { ACCOUNT_SLOGE("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__); @@ -828,18 +789,18 @@ ACCOUNT_API int account_set_custom(account_h account, const char* key, const cha return ACCOUNT_ERROR_INVALID_PARAMETER; } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; GSList *iter; bool b_is_new = TRUE; for (iter = data->custom_list; iter != NULL; iter = g_slist_next(iter)) { - account_custom_s* custom_data = NULL; - custom_data = (account_custom_s*)iter->data; - ACCOUNT_SLOGD( "account_custom_s->key = %s, account_custom_s->value = %s \n", custom_data->key, custom_data->value); + account_custom_s *custom_data = NULL; + custom_data = (account_custom_s *)iter->data; + ACCOUNT_SLOGD("account_custom_s->key = %s, account_custom_s->value = %s \n", custom_data->key, custom_data->value); - if(!strcmp(custom_data->key, key)) { + if (!strcmp(custom_data->key, key)) { char *new_value = NULL; new_value = _account_get_text(value); if (new_value == NULL) { @@ -854,10 +815,10 @@ ACCOUNT_API int account_set_custom(account_h account, const char* key, const cha } } - if(b_is_new) { + if (b_is_new) { int error_code = ACCOUNT_ERROR_NONE; - account_custom_s* custom_data = (account_custom_s*)malloc(sizeof(account_custom_s)); + account_custom_s* custom_data = (account_custom_s *)malloc(sizeof(account_custom_s)); if (custom_data == NULL) { ACCOUNT_FATAL("Memory Allocation Failed"); return ACCOUNT_ERROR_OUT_OF_MEMORY; @@ -903,11 +864,10 @@ ACCOUNT_API int account_set_auth_type(account_h account, const account_auth_type { ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__)); - if ( ((int)auth_type < 0) || (auth_type > ACCOUNT_AUTH_TYPE_CLIENT_LOGIN)) { + if (((int)auth_type < 0) || (auth_type > ACCOUNT_AUTH_TYPE_CLIENT_LOGIN)) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; data->auth_type = (int)auth_type; @@ -918,11 +878,10 @@ ACCOUNT_API int account_set_secret(account_h account, const account_secrecy_stat { ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__)); - if ( ((int)secret < 0) || (secret > ACCOUNT_SECRECY_VISIBLE)) { + if (((int)secret < 0) || (secret > ACCOUNT_SECRECY_VISIBLE)) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; data->secret = (int)secret; @@ -933,61 +892,57 @@ ACCOUNT_API int account_set_sync_support(account_h account, const account_sync_s { ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__)); - if ( ((int)sync_support < 0) || (sync_support > ACCOUNT_SUPPORTS_SYNC)) { + if (((int)sync_support < 0) || (sync_support > ACCOUNT_SUPPORTS_SYNC)) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; - data->sync_support= (int)sync_support; + data->sync_support = (int)sync_support; return ACCOUNT_ERROR_NONE; } ACCOUNT_API int account_set_user_int(account_h account, int idx, const int user_int) { - if (!account) { + if (!account) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (idx >= USER_INT_CNT ||idx < 0) { + if (idx >= USER_INT_CNT || idx < 0) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; data->user_data_int[idx] = user_int; return ACCOUNT_ERROR_NONE; } -ACCOUNT_API int account_set_capability(account_h account, const char* capability_type, account_capability_state_e capability_value) +ACCOUNT_API int account_set_capability(account_h account, const char *capability_type, account_capability_state_e capability_value) { ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("account handle is null")); ACCOUNT_RETURN_VAL((capability_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("capability_type is null")); - if ((capability_value != ACCOUNT_CAPABILITY_DISABLED) && (capability_value != ACCOUNT_CAPABILITY_ENABLED)) { + if ((capability_value != ACCOUNT_CAPABILITY_DISABLED) && (capability_value != ACCOUNT_CAPABILITY_ENABLED)) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; GSList *iter = NULL; bool b_is_new = TRUE; - for(iter = data->capablity_list; iter != NULL; iter = g_slist_next(iter)) { + for (iter = data->capablity_list; iter != NULL; iter = g_slist_next(iter)) { account_capability_s *cap_data = NULL; - cap_data = (account_capability_s*)iter->data; + cap_data = (account_capability_s *)iter->data; - if(!strcmp(cap_data->type, capability_type)) { + if (!strcmp(cap_data->type, capability_type)) { cap_data->value = capability_value; b_is_new = FALSE; break; } } - if(b_is_new) { - account_capability_s* cap_data = (account_capability_s*)malloc(sizeof(account_capability_s)); + if (b_is_new) { + account_capability_s *cap_data = (account_capability_s *)malloc(sizeof(account_capability_s)); if (cap_data == NULL) { ACCOUNT_FATAL("Memory Allocation Failed"); return ACCOUNT_ERROR_OUT_OF_MEMORY; @@ -1012,15 +967,13 @@ ACCOUNT_API int account_set_capability(account_h account, const char* capability ACCOUNT_API int account_get_user_name(account_h account, char **user_name) { - if (!account) { + if (!account) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!user_name) { + if (!user_name) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; (*user_name) = NULL; *user_name = _account_get_text(data->user_name); @@ -1034,15 +987,13 @@ ACCOUNT_API int account_get_user_name(account_h account, char **user_name) ACCOUNT_API int account_get_display_name(account_h account, char **display_name) { - if (!account) { + if (!account) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!display_name) { + if (!display_name) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; (*display_name) = NULL; @@ -1056,17 +1007,15 @@ ACCOUNT_API int account_get_display_name(account_h account, char **display_name) return ACCOUNT_ERROR_NONE; } -ACCOUNT_API int account_get_email_address(account_h account,char **email_address) +ACCOUNT_API int account_get_email_address(account_h account, char **email_address) { - if (!account) { + if (!account) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!email_address) { + if (!email_address) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; (*email_address) = NULL; @@ -1081,15 +1030,13 @@ ACCOUNT_API int account_get_email_address(account_h account,char **email_address ACCOUNT_API int account_get_icon_path(account_h account, char **icon_path) { - if (!account) { + if (!account) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!icon_path) { + if (!icon_path) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; (*icon_path) = NULL; @@ -1104,15 +1051,13 @@ ACCOUNT_API int account_get_icon_path(account_h account, char **icon_path) ACCOUNT_API int account_get_source(account_h account, char **source) { - if (!account) { + if (!account) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!source) { + if (!source) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; (*source) = NULL; @@ -1127,15 +1072,13 @@ ACCOUNT_API int account_get_source(account_h account, char **source) ACCOUNT_API int account_get_package_name(account_h account, char **package_name) { - if (!account) { + if (!account) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!package_name) { + if (!package_name) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; (*package_name) = NULL; @@ -1151,15 +1094,13 @@ ACCOUNT_API int account_get_package_name(account_h account, char **package_name) ACCOUNT_API int account_get_domain_name(account_h account, char **domain_name) { - if (!account) { + if (!account) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!domain_name) { + if (!domain_name) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; (*domain_name) = NULL; @@ -1174,15 +1115,13 @@ ACCOUNT_API int account_get_domain_name(account_h account, char **domain_name) ACCOUNT_API int account_get_access_token(account_h account, char **access_token) { - if (!account) { + if (!account) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!access_token) { + if (!access_token) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; (*access_token) = NULL; @@ -1197,17 +1136,15 @@ ACCOUNT_API int account_get_access_token(account_h account, char **access_token) ACCOUNT_API int account_get_user_text(account_h account, int user_text_index, char **text) { - if (!account) { + if (!account) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!text) { + if (!text) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - ACCOUNT_RETURN_VAL((user_text_index >=0 && user_text_index < USER_TXT_CNT ), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("INVALID USER TEXT INDEX")); + ACCOUNT_RETURN_VAL((user_text_index >= 0 && user_text_index < USER_TXT_CNT), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("INVALID USER TEXT INDEX")); - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; (*text) = NULL; @@ -1222,14 +1159,13 @@ ACCOUNT_API int account_get_user_text(account_h account, int user_text_index, ch ACCOUNT_API int account_get_auth_type(account_h account, account_auth_type_e *auth_type) { - if (!account) { + if (!account) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!auth_type) { + + if (!auth_type) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_s* data = (account_s*)account; + account_s *data = (account_s *)account; *auth_type = data->auth_type; @@ -1238,14 +1174,13 @@ ACCOUNT_API int account_get_auth_type(account_h account, account_auth_type_e *au ACCOUNT_API int account_get_secret(account_h account, account_secrecy_state_e *secret) { - if (!account) { + if (!account) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!secret) { + + if (!secret) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_s* data = (account_s*)account; + account_s *data = (account_s *)account; *secret = data->secret; @@ -1254,14 +1189,13 @@ ACCOUNT_API int account_get_secret(account_h account, account_secrecy_state_e *s ACCOUNT_API int account_get_sync_support(account_h account, account_sync_state_e *sync_support) { - if (!account) { + if (!account) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!sync_support) { + + if (!sync_support) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_s* data = (account_s*)account; + account_s *data = (account_s *)account; *sync_support = data->sync_support; @@ -1270,14 +1204,13 @@ ACCOUNT_API int account_get_sync_support(account_h account, account_sync_state_e ACCOUNT_API int account_get_account_id(account_h 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_s *data = (account_s*)account; + account_s *data = (account_s *)account; *account_id = data->id; @@ -1286,38 +1219,36 @@ ACCOUNT_API int account_get_account_id(account_h account, int *account_id) ACCOUNT_API int account_get_user_int(account_h account, int user_int_index, int *integer) { - if (!account) { + if (!account) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - ACCOUNT_RETURN_VAL((user_int_index >=0 && user_int_index < USER_TXT_CNT ), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("INVALID USER TEXT INDEX")); + ACCOUNT_RETURN_VAL((user_int_index >= 0 && user_int_index < USER_TXT_CNT), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("INVALID USER TEXT INDEX")); - if (!integer) { + if (!integer) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; *integer = data->user_data_int[user_int_index]; return ACCOUNT_ERROR_NONE; } -ACCOUNT_API int account_get_capability(account_h account, const char* capability_type, account_capability_state_e* capability_value) +ACCOUNT_API int account_get_capability(account_h account, const char *capability_type, account_capability_state_e *capability_value) { ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL")); ACCOUNT_RETURN_VAL((capability_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("capability_type is NULL")); ACCOUNT_RETURN_VAL((capability_value != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("capability_value is NULL")); GSList *iter; - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; for (iter = data->capablity_list; iter != NULL; iter = g_slist_next(iter)) { account_capability_s *cap_data = NULL; - cap_data = (account_capability_s*)iter->data; + cap_data = (account_capability_s *)iter->data; - if(!strcmp(capability_type, cap_data->type)) { + if (!strcmp(capability_type, cap_data->type)) { *capability_value = cap_data->value; return ACCOUNT_ERROR_NONE; } @@ -1332,36 +1263,35 @@ ACCOUNT_API int account_get_capability_all(account_h account, capability_cb call ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("NO CALLBACK FUNCTION")); GSList *iter; - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; for (iter = data->capablity_list; iter != NULL; iter = g_slist_next(iter)) { account_capability_s *cap_data = NULL; - cap_data = (account_capability_s*)iter->data; + cap_data = (account_capability_s *)iter->data; - if(callback(cap_data->type, cap_data->value, user_data)!=TRUE){ + if (callback(cap_data->type, cap_data->value, user_data) != TRUE) return ACCOUNT_ERROR_NONE; - } } return ACCOUNT_ERROR_NONE; } -ACCOUNT_API int account_get_custom(account_h account, const char* key, char** value) +ACCOUNT_API int account_get_custom(account_h account, const char *key, char **value) { ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL")); ACCOUNT_RETURN_VAL((key != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("NO KEY TO REQUEST")); ACCOUNT_RETURN_VAL((value != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("VALUE POINTER IS NULL")); GSList *iter; - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; for (iter = data->custom_list; iter != NULL; iter = g_slist_next(iter)) { account_custom_s *custom_data = NULL; - custom_data = (account_custom_s*)iter->data; + custom_data = (account_custom_s *)iter->data; - if(!strcmp(key, custom_data->key)) { + if (!strcmp(key, custom_data->key)) { (*value) = NULL; *value = _account_get_text(custom_data->value); if (custom_data->value != NULL && *value == NULL) { @@ -1376,24 +1306,23 @@ ACCOUNT_API int account_get_custom(account_h account, const char* key, char** va return ACCOUNT_ERROR_RECORD_NOT_FOUND; } -ACCOUNT_API int account_get_custom_all(account_h account, account_custom_cb callback, void* user_data) +ACCOUNT_API int account_get_custom_all(account_h account, account_custom_cb callback, void *user_data) { ACCOUNT_RETURN_VAL((account != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL")); ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("NO CALLBACK FUNCTION")); GSList *iter; - account_s *data = (account_s*)account; + account_s *data = (account_s *)account; for (iter = data->custom_list; iter != NULL; iter = g_slist_next(iter)) { bool cb_ret = FALSE; account_custom_s *custom_data = NULL; - custom_data = (account_custom_s*)iter->data; + custom_data = (account_custom_s *)iter->data; cb_ret = callback(custom_data->key, custom_data->value, user_data); - if(!cb_ret) { + if (!cb_ret) break; - } } return ACCOUNT_ERROR_NONE; @@ -1407,39 +1336,34 @@ ACCOUNT_API int account_foreach_account_from_db(account_cb callback, void *user_ GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } - GVariant* account_list_variant = NULL; + GVariant *account_list_variant = NULL; bool is_success = account_manager_call_account_query_all_sync(acc_mgr, (int)getuid(), &account_list_variant, NULL, &error); int error_code = _account_get_error_code(is_success, error); g_clear_error(&error); if (error_code != ACCOUNT_ERROR_NONE) - { return error_code; - } - GSList* account_list = unmarshal_account_list(account_list_variant); + GSList *account_list = unmarshal_account_list(account_list_variant); g_variant_unref(account_list_variant); - GSList* iter; + GSList *iter; - for (iter = account_list; iter != NULL; iter = g_slist_next(iter)) - { + for (iter = account_list; iter != NULL; iter = g_slist_next(iter)) { _INFO("iterating received account_list"); account_s *account = NULL; - account = (account_s*)iter->data; + account = (account_s *)iter->data; _INFO("Before _account_query_identity_info_by_id"); _INFO("account->id=%d", account->id); - if (callback((account_h)account, user_data) == false) - { + if (callback((account_h)account, user_data) == false) { _INFO("application callback requested to discontinue."); break; } @@ -1461,29 +1385,25 @@ ACCOUNT_API int account_query_account_by_account_id(int account_db_id, account_h GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } - GVariant* account_variant = NULL; + GVariant *account_variant = NULL; bool is_success = account_manager_call_account_query_account_by_account_id_sync(acc_mgr, account_db_id, (int)getuid(), &account_variant, NULL, &error); int error_code = _account_get_error_code(is_success, error); g_clear_error(&error); if (error_code != ACCOUNT_ERROR_NONE) - { return error_code; - } _INFO("before unmarshal_account"); - account_s* account_data = umarshal_account(account_variant); + account_s *account_data = umarshal_account(account_variant); _INFO("after unmarshal_account"); - if (account_data == NULL) - { + if (account_data == NULL) { _ERR("Failed to unmarshal"); return ACCOUNT_ERROR_DB_FAILED; } @@ -1499,7 +1419,7 @@ ACCOUNT_API int account_query_account_by_account_id(int account_db_id, account_h return ACCOUNT_ERROR_NONE; } -ACCOUNT_API int account_query_account_by_user_name(account_cb callback, const char* user_name, void* user_data) +ACCOUNT_API int account_query_account_by_user_name(account_cb callback, const char *user_name, void *user_data) { _INFO("account_query_account_by_user_name starting"); @@ -1508,40 +1428,33 @@ ACCOUNT_API int account_query_account_by_user_name(account_cb callback, const ch GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } - GVariant* account_list_variant = NULL; + GVariant *account_list_variant = NULL; bool is_success = account_manager_call_account_query_account_by_user_name_sync(acc_mgr, user_name, (int)getuid(), &account_list_variant, NULL, &error); int error_code = _account_get_error_code(is_success, error); g_clear_error(&error); if (error_code != ACCOUNT_ERROR_NONE) - { return error_code; - } - GSList* account_list = unmarshal_account_list(account_list_variant); + GSList *account_list = unmarshal_account_list(account_list_variant); g_variant_unref(account_list_variant); if (account_list == NULL) - { return ACCOUNT_ERROR_NO_DATA; - } - GSList* iter; + GSList *iter; - for (iter = account_list; iter != NULL; iter = g_slist_next(iter)) - { + for (iter = account_list; iter != NULL; iter = g_slist_next(iter)) { _INFO("iterating received account_list"); account_s *account = NULL; - account = (account_s*)iter->data; - if (callback((account_h)account, user_data) == false) - { + account = (account_s *)iter->data; + if (callback((account_h)account, user_data) == false) { _INFO("application callback requested to discontinue."); break; } @@ -1561,41 +1474,34 @@ ACCOUNT_API int account_query_account_by_package_name(account_cb callback, const GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } - GVariant* account_list_variant = NULL; + GVariant *account_list_variant = NULL; bool is_success = account_manager_call_account_query_account_by_package_name_sync(acc_mgr, package_name, (int)getuid(), &account_list_variant, NULL, &error); int error_code = _account_get_error_code(is_success, error); g_clear_error(&error); if (error_code != ACCOUNT_ERROR_NONE) - { return error_code; - } - GSList* account_list = unmarshal_account_list(account_list_variant); + GSList *account_list = unmarshal_account_list(account_list_variant); g_variant_unref(account_list_variant); if (account_list == NULL) - { return ACCOUNT_ERROR_NO_DATA; - } - GSList* iter; + GSList *iter; - for (iter = account_list; iter != NULL; iter = g_slist_next(iter)) - { + for (iter = account_list; iter != NULL; iter = g_slist_next(iter)) { _INFO("iterating received account_list"); account_s *account = NULL; - account = (account_s*)iter->data; + account = (account_s *)iter->data; - if (callback((account_h)account, user_data) == false) - { + if (callback((account_h)account, user_data) == false) { _INFO("application callback requested to discontinue."); break; } @@ -1605,13 +1511,13 @@ ACCOUNT_API int account_query_account_by_package_name(account_cb callback, const return ACCOUNT_ERROR_NONE; } -ACCOUNT_API int account_query_account_by_capability(account_cb callback, const char* capability_type, account_capability_state_e capability_value, void *user_data) +ACCOUNT_API int account_query_account_by_capability(account_cb callback, const char *capability_type, account_capability_state_e capability_value, void *user_data) { _INFO("account_query_account_by_capability starting"); ACCOUNT_RETURN_VAL((capability_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("capability_type IS NULL")); - if (((int)capability_value < 0) || (capability_value > ACCOUNT_CAPABILITY_ENABLED)) { + if (((int)capability_value < 0) || (capability_value > ACCOUNT_CAPABILITY_ENABLED)) { ACCOUNT_SLOGE("(%s)-(%d) capability_value is not equal to 0 or 1.\n", __FUNCTION__, __LINE__); return ACCOUNT_ERROR_INVALID_PARAMETER; } @@ -1620,40 +1526,33 @@ ACCOUNT_API int account_query_account_by_capability(account_cb callback, const c GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } - GVariant* account_list_variant = NULL; + GVariant *account_list_variant = NULL; bool is_success = account_manager_call_account_query_account_by_capability_sync(acc_mgr, capability_type, capability_value, (int)getuid(), &account_list_variant, NULL, &error); int error_code = _account_get_error_code(is_success, error); g_clear_error(&error); if (error_code != ACCOUNT_ERROR_NONE) - { return error_code; - } - GSList* account_list = unmarshal_account_list(account_list_variant); + GSList *account_list = unmarshal_account_list(account_list_variant); g_variant_unref(account_list_variant); if (account_list == NULL) - { return ACCOUNT_ERROR_NO_DATA; - } - GSList* iter; + GSList *iter; - for (iter = account_list; iter != NULL; iter = g_slist_next(iter)) - { + for (iter = account_list; iter != NULL; iter = g_slist_next(iter)) { _INFO("iterating received account_list"); account_s *account = NULL; - account = (account_s*)iter->data; + account = (account_s *)iter->data; - if (callback((account_h)account, user_data) == false) - { + if (callback((account_h)account, user_data) == false) { _INFO("application callback requested to discontinue."); break; } @@ -1663,7 +1562,7 @@ ACCOUNT_API int account_query_account_by_capability(account_cb callback, const c return ACCOUNT_ERROR_NONE; } -ACCOUNT_API int account_query_account_by_capability_type(account_cb callback, const char* capability_type, void* user_data) +ACCOUNT_API int account_query_account_by_capability_type(account_cb callback, const char *capability_type, void *user_data) { _INFO("account_query_account_by_capability_type starting"); @@ -1672,41 +1571,34 @@ ACCOUNT_API int account_query_account_by_capability_type(account_cb callback, co GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } - GVariant* account_list_variant = NULL; + GVariant *account_list_variant = NULL; bool is_success = account_manager_call_account_query_account_by_capability_type_sync(acc_mgr, capability_type, (int)getuid(), &account_list_variant, NULL, &error); int error_code = _account_get_error_code(is_success, error); g_clear_error(&error); if (error_code != ACCOUNT_ERROR_NONE) - { return error_code; - } - GSList* account_list = unmarshal_account_list(account_list_variant); + GSList *account_list = unmarshal_account_list(account_list_variant); g_variant_unref(account_list_variant); if (account_list == NULL) - { return ACCOUNT_ERROR_NO_DATA; - } - GSList* iter; + GSList *iter; - for (iter = account_list; iter != NULL; iter = g_slist_next(iter)) - { + for (iter = account_list; iter != NULL; iter = g_slist_next(iter)) { _INFO("iterating received account_list"); account_s *account = NULL; - account = (account_s*)iter->data; + account = (account_s *)iter->data; - if (callback((account_h)account, user_data) == false) - { + if (callback((account_h)account, user_data) == false) { _INFO("application callback requested to discontinue."); break; } @@ -1724,45 +1616,35 @@ ACCOUNT_API int account_query_capability_by_account_id(capability_cb callback, i ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("NO CALLBACK FUNCTION")); GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } - GVariant* capability_list_variant = NULL; + GVariant *capability_list_variant = NULL; bool is_success = account_manager_call_account_query_capability_by_account_id_sync(acc_mgr, account_id, (int)getuid(), &capability_list_variant, NULL, &error); int error_code = _account_get_error_code(is_success, error); g_clear_error(&error); if (error_code != ACCOUNT_ERROR_NONE) - { return error_code; - } - _INFO("before unmarshal_capability_list"); - GSList* capability_list = unmarshal_capability_list(capability_list_variant); - _INFO("after unmarshal_capability_list"); + GSList *capability_list = unmarshal_capability_list(capability_list_variant); + if (capability_list == NULL) - { return ACCOUNT_ERROR_NO_DATA; - } - GSList* iter; + GSList *iter; - for (iter = capability_list; iter != NULL; iter = g_slist_next(iter)) - { + for (iter = capability_list; iter != NULL; iter = g_slist_next(iter)) { _INFO("iterating received account_list"); account_capability_s *capability = NULL; - capability = (account_capability_s*)iter->data; - _INFO(""); - if (callback(capability->type, capability->value, user_data) == false) - { + capability = (account_capability_s *)iter->data; + if (callback(capability->type, capability->value, user_data) == false) { _INFO("application callback requested to discontinue."); break; } - _INFO(""); } _account_gslist_capability_free(capability_list); @@ -1774,23 +1656,20 @@ static int _account_get_total_count(int *count, bool include_hidden) { _INFO("account_get_total_count_from_db starting"); - if (!count) - { + if (!count) { ACCOUNT_SLOGE("(%s)-(%d) count is NULL.\n", __FUNCTION__, __LINE__); return ACCOUNT_ERROR_INVALID_PARAMETER; } GError *error = NULL; - if (count == NULL) - { + if (count == NULL) { _INFO("Invalid input"); return -1; } - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -1800,9 +1679,7 @@ static int _account_get_total_count(int *count, bool include_hidden) int error_code = _account_get_error_code(is_success, error); g_clear_error(&error); if (error_code != ACCOUNT_ERROR_NONE) - { return error_code; - } *count = temp_count; _INFO("account_get_total_count_from_db end"); @@ -1829,16 +1706,15 @@ ACCOUNT_API int account_update_sync_status_by_id(int account_db_id, const accoun int error_code = ACCOUNT_ERROR_NONE; ACCOUNT_RETURN_VAL((account_db_id > 0), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT INDEX IS LESS THAN 0")); - if ( ((int)sync_status < 0) || (sync_status > ACCOUNT_SYNC_STATUS_RUNNING)) { + if (((int)sync_status < 0) || (sync_status > ACCOUNT_SYNC_STATUS_RUNNING)) { ACCOUNT_SLOGE("(%s)-(%d) sync_status is less than 0 or more than enum max.\n", __FUNCTION__, __LINE__); return ACCOUNT_ERROR_INVALID_PARAMETER; } GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -1851,124 +1727,6 @@ ACCOUNT_API int account_update_sync_status_by_id(int account_db_id, const accoun return error_code; } -/* -static int _account_type_free_label_items(label_s *data) -{ - if(!data) { - return ACCOUNT_ERROR_INVALID_PARAMETER; - } - - _ACCOUNT_FREE(data->app_id); - _ACCOUNT_FREE(data->label); - _ACCOUNT_FREE(data->locale); - - return ACCOUNT_ERROR_NONE; -} - -static int _account_type_label_gslist_free(GSList* list) -{ - ACCOUNT_RETURN_VAL((list != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("GSlist is NULL")); - - GSList* iter; - - for (iter = list; iter != NULL; iter = g_slist_next(iter)) { - label_s *label_data = (label_s*)iter->data; - _account_type_free_label_items(label_data); - _ACCOUNT_FREE(label_data); - } - - g_slist_free(list); - list = NULL; - - return ACCOUNT_ERROR_NONE; -} - -static int _account_type_free_provider_feature_items(provider_feature_s *data) -{ - if(!data) { - return ACCOUNT_ERROR_INVALID_PARAMETER; - } - - _ACCOUNT_FREE(data->key); - _ACCOUNT_FREE(data->app_id); - - return ACCOUNT_ERROR_NONE; -} - -static int _account_type_provider_feature_gslist_free(GSList* list) -{ - ACCOUNT_RETURN_VAL((list != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("GSlist is NULL")); - - GSList* iter; - - for (iter = list; iter != NULL; iter = g_slist_next(iter)) { - provider_feature_s *feature_data = (provider_feature_s*)iter->data; - _account_type_free_provider_feature_items(feature_data); - _ACCOUNT_FREE(feature_data); - } - - g_slist_free(list); - list = NULL; - - return ACCOUNT_ERROR_NONE; -} - -static int _account_type_free_account_type_items(account_type_s *data) -{ - if(!data) { - return ACCOUNT_ERROR_INVALID_PARAMETER; - } - - _ACCOUNT_FREE(data->app_id); - _ACCOUNT_FREE(data->service_provider_id); - _ACCOUNT_FREE(data->icon_path); - _ACCOUNT_FREE(data->small_icon_path); - - _account_type_label_gslist_free(data->label_list); - _account_type_provider_feature_gslist_free(data->provider_feature_list); -// _account_type_glist_free(data->account_type_list); - - return ACCOUNT_ERROR_NONE; -} - -static int _account_type_gslist_free(GSList* list) -{ - ACCOUNT_RETURN_VAL((list != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Glist is NULL")); - - GSList* iter; - - for (iter = list; iter != NULL; iter = g_slist_next(iter)) { - account_type_s *account_type_record = (account_type_s*)iter->data; - _account_type_free_account_type_items(account_type_record); - _ACCOUNT_FREE(account_type_record); - } - - g_slist_free(list); - list = NULL; - - return ACCOUNT_ERROR_NONE; -} -*/ - -/* -static int _account_type_glist_free(GList* list) -{ - ACCOUNT_RETURN_VAL((list != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Glist is NULL")); - - GList* iter; - - for (iter = list; iter != NULL; iter = g_list_next(iter)) { - account_type_s *account_type_record = (account_type_s*)iter->data; - _account_type_free_account_type_items(account_type_record); - _ACCOUNT_FREE(account_type_record); - } - - g_list_free(list); - list = NULL; - - return ACCOUNT_ERROR_NONE; -} -*/ ACCOUNT_API int account_type_create(account_type_h *account_type) { @@ -1977,7 +1735,7 @@ ACCOUNT_API int account_type_create(account_type_h *account_type) return ACCOUNT_ERROR_INVALID_PARAMETER; } - account_type_s *data = (account_type_s*)malloc(sizeof(account_type_s)); + account_type_s *data = (account_type_s *)malloc(sizeof(account_type_s)); if (data == NULL) { ACCOUNT_FATAL("Memory Allocation Failed"); return ACCOUNT_ERROR_OUT_OF_MEMORY; @@ -1992,7 +1750,6 @@ ACCOUNT_API int account_type_create(account_type_h *account_type) data->small_icon_path = NULL; data->multiple_account_support = false; data->label_list = NULL; -// data->account_type_list = NULL; data->provider_feature_list = NULL; *account_type = (account_type_h)data; @@ -2004,10 +1761,9 @@ ACCOUNT_API int account_type_destroy(account_type_h account_type) { _INFO("account_type_destroy"); - account_type_s *data = (account_type_s*)account_type; + account_type_s *data = (account_type_s *)account_type; - if (data == NULL) - { + if (data == NULL) { _ERR("Account type handle is null!"); return ACCOUNT_ERROR_INVALID_PARAMETER; } @@ -2029,7 +1785,7 @@ ACCOUNT_INTERNAL_API int account_type_set_app_id(account_type_h account_type, co return ACCOUNT_ERROR_INVALID_PARAMETER; } - account_type_s *data = (account_type_s*)account_type; + account_type_s *data = (account_type_s *)account_type; _ACCOUNT_FREE(data->app_id); data->app_id = _account_get_text(app_id); @@ -2043,15 +1799,13 @@ ACCOUNT_INTERNAL_API int account_type_set_app_id(account_type_h account_type, co ACCOUNT_INTERNAL_API int account_type_set_service_provider_id(account_type_h account_type, const char *service_provider_id) { - if (!account_type) { + if (!account_type) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!service_provider_id) { + if (!service_provider_id) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_type_s *data = (account_type_s*)account_type; + account_type_s *data = (account_type_s *)account_type; _ACCOUNT_FREE(data->service_provider_id); data->service_provider_id = _account_get_text(service_provider_id); @@ -2065,15 +1819,13 @@ ACCOUNT_INTERNAL_API int account_type_set_service_provider_id(account_type_h acc ACCOUNT_INTERNAL_API int account_type_set_icon_path(account_type_h account_type, const char *icon_path) { - if (!account_type) { + if (!account_type) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!icon_path) { + if (!icon_path) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_type_s *data = (account_type_s*)account_type; + account_type_s *data = (account_type_s *)account_type; _ACCOUNT_FREE(data->icon_path); data->icon_path = _account_get_text(icon_path); @@ -2087,15 +1839,13 @@ ACCOUNT_INTERNAL_API int account_type_set_icon_path(account_type_h account_type, ACCOUNT_INTERNAL_API int account_type_set_small_icon_path(account_type_h account_type, const char *small_icon_path) { - if (!account_type) { + if (!account_type) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!small_icon_path) { + if (!small_icon_path) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_type_s *data = (account_type_s*)account_type; + account_type_s *data = (account_type_s *)account_type; _ACCOUNT_FREE(data->small_icon_path); data->small_icon_path = _account_get_text(small_icon_path); @@ -2107,30 +1857,29 @@ ACCOUNT_INTERNAL_API int account_type_set_small_icon_path(account_type_h account return ACCOUNT_ERROR_NONE; } -ACCOUNT_INTERNAL_API int account_type_set_multiple_account_support(account_type_h account_type, const bool multiple_account_support) +ACCOUNT_INTERNAL_API int account_type_set_multiple_account_support(account_type_h account_type, bool multiple_account_support) { ACCOUNT_RETURN_VAL((account_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("(%s)-(%d) account handle is NULL.\n", __FUNCTION__, __LINE__)); - account_type_s *data = (account_type_s*)account_type; + account_type_s *data = (account_type_s *)account_type; data->multiple_account_support = multiple_account_support; return ACCOUNT_ERROR_NONE; } -ACCOUNT_INTERNAL_API int account_type_set_label(account_type_h account_type, const char* label, const char* locale) +ACCOUNT_INTERNAL_API int account_type_set_label(account_type_h account_type, const char *label, const char *locale) { if (!account_type) { ACCOUNT_SLOGE("(%s)-(%d) account_type handle is NULL.\n", __FUNCTION__, __LINE__); return ACCOUNT_ERROR_INVALID_PARAMETER; } - if(!label || !locale) { + if (!label || !locale) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_type_s *data = (account_type_s*)account_type; - label_s *label_data = (label_s*)malloc(sizeof(label_s)); + account_type_s *data = (account_type_s *)account_type; + label_s *label_data = (label_s *)malloc(sizeof(label_s)); if (label_data == NULL) { ACCOUNT_FATAL("Memory Allocation Failed"); return ACCOUNT_ERROR_OUT_OF_MEMORY; @@ -2156,28 +1905,28 @@ ACCOUNT_INTERNAL_API int account_type_set_label(account_type_h account_type, con return ACCOUNT_ERROR_NONE; } -ACCOUNT_INTERNAL_API int account_type_set_provider_feature(account_type_h account_type, const char* provider_feature) +ACCOUNT_INTERNAL_API int account_type_set_provider_feature(account_type_h account_type, const char *provider_feature) { ACCOUNT_RETURN_VAL((account_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("account type handle is null")); ACCOUNT_RETURN_VAL((provider_feature != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("provider_feature is null")); - account_type_s *data = (account_type_s*)account_type; + account_type_s *data = (account_type_s *)account_type; GSList *iter = NULL; bool b_is_new = TRUE; - for(iter = data->provider_feature_list; iter != NULL; iter = g_slist_next(iter)) { + for (iter = data->provider_feature_list; iter != NULL; iter = g_slist_next(iter)) { provider_feature_s *feature_data = NULL; - feature_data = (provider_feature_s*)iter->data; + feature_data = (provider_feature_s *)iter->data; - if(!strcmp(feature_data->key, provider_feature)) { + if (!strcmp(feature_data->key, provider_feature)) { b_is_new = FALSE; break; } } - if(b_is_new) { - provider_feature_s* feature_data = (provider_feature_s*)malloc(sizeof(provider_feature_s)); + if (b_is_new) { + provider_feature_s* feature_data = (provider_feature_s *)malloc(sizeof(provider_feature_s)); if (feature_data == NULL) { ACCOUNT_FATAL("Memory Allocation Failed"); return ACCOUNT_ERROR_OUT_OF_MEMORY; @@ -2198,7 +1947,7 @@ ACCOUNT_INTERNAL_API int account_type_set_provider_feature(account_type_h accoun return ACCOUNT_ERROR_NONE; } -ACCOUNT_API int account_type_query_provider_feature_by_app_id(provider_feature_cb callback, const char* app_id, void *user_data ) +ACCOUNT_API int account_type_query_provider_feature_by_app_id(provider_feature_cb callback, const char *app_id, void *user_data) { _INFO("account_type_query_provider_feature_by_app_id start"); @@ -2208,20 +1957,18 @@ ACCOUNT_API int account_type_query_provider_feature_by_app_id(provider_feature_c GError *error = NULL; gint error_code = ACCOUNT_ERROR_NONE; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } - GVariant* feature_list_variant = NULL; + GVariant *feature_list_variant = NULL; bool is_success = account_manager_call_account_type_query_provider_feature_by_app_id_sync(acc_mgr, app_id, (int)getuid(), &feature_list_variant, NULL, &error); _INFO("account_manager_call_account_type_query_provider_feature_by_app_id_sync end=[%d]", is_success); - if (!is_success) - { + if (!is_success) { error_code = _account_get_error_code(is_success, error); g_clear_error(&error); _ERR("Account IPC call returned error[%d]", error_code); @@ -2229,9 +1976,8 @@ ACCOUNT_API int account_type_query_provider_feature_by_app_id(provider_feature_c } g_clear_error(&error); - GSList* provider_feature_list = variant_to_provider_feature_list(feature_list_variant); - if (provider_feature_list == NULL) - { + GSList *provider_feature_list = variant_to_provider_feature_list(feature_list_variant); + if (provider_feature_list == NULL) { error_code = ACCOUNT_ERROR_NO_DATA; _ERR("[%d]", error_code); return error_code; @@ -2241,9 +1987,9 @@ ACCOUNT_API int account_type_query_provider_feature_by_app_id(provider_feature_c for (iter = provider_feature_list; iter != NULL; iter = g_slist_next(iter)) { provider_feature_s *feature_data = NULL; - feature_data = (provider_feature_s*)iter->data; + feature_data = (provider_feature_s *)iter->data; - if(callback(feature_data->app_id, feature_data->key, user_data)!=TRUE) { + if (callback(feature_data->app_id, feature_data->key, user_data) != TRUE) { ACCOUNT_DEBUG("Callback func returs FALSE, its iteration is stopped!!!!\n"); return ACCOUNT_ERROR_NONE; } @@ -2254,12 +2000,11 @@ ACCOUNT_API int account_type_query_provider_feature_by_app_id(provider_feature_c return error_code; } -ACCOUNT_API bool account_type_query_supported_feature(const char* app_id, const char* capability) +ACCOUNT_API bool account_type_query_supported_feature(const char *app_id, const char *capability) { _INFO("account_type_query_supported_feature start"); - if (app_id == NULL || capability == NULL) - { + if (app_id == NULL || capability == NULL) { set_last_result(ACCOUNT_ERROR_INVALID_PARAMETER); return false; } @@ -2268,9 +2013,8 @@ ACCOUNT_API bool account_type_query_supported_feature(const char* app_id, const GError *error = NULL; gint ret = ACCOUNT_ERROR_NONE; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); set_last_result(ACCOUNT_ERROR_PERMISSION_DENIED); return false; @@ -2280,8 +2024,7 @@ ACCOUNT_API bool account_type_query_supported_feature(const char* app_id, const _INFO("account_manager_call_account_type_query_supported_feature_sync end=[%d]", is_success); - if (!is_success) - { + if (!is_success) { ret = _account_get_error_code(is_success, error); g_clear_error(&error); _ERR("Account IPC call returned error[%d]", ret); @@ -2297,15 +2040,13 @@ ACCOUNT_API bool account_type_query_supported_feature(const char* app_id, const ACCOUNT_API int account_type_get_app_id(account_type_h account_type, char **app_id) { - if (!account_type) { + if (!account_type) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!app_id) { + if (!app_id) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_type_s *data = (account_type_s*)account_type; + account_type_s *data = (account_type_s *)account_type; (*app_id) = NULL; *app_id = _account_get_text(data->app_id); @@ -2319,15 +2060,13 @@ ACCOUNT_API int account_type_get_app_id(account_type_h account_type, char **app_ ACCOUNT_API int account_type_get_service_provider_id(account_type_h account_type, char **service_provider_id) { - if (!account_type) { + if (!account_type) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!service_provider_id) { + if (!service_provider_id) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_type_s *data = (account_type_s*)account_type; + account_type_s *data = (account_type_s *)account_type; (*service_provider_id) = NULL; *service_provider_id = _account_get_text(data->service_provider_id); @@ -2341,15 +2080,13 @@ ACCOUNT_API int account_type_get_service_provider_id(account_type_h account_type ACCOUNT_API int account_type_get_icon_path(account_type_h account_type, char **icon_path) { - if (!account_type) { + if (!account_type) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!icon_path) { + if (!icon_path) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_type_s *data = (account_type_s*)account_type; + account_type_s *data = (account_type_s *)account_type; (*icon_path) = NULL; *icon_path = _account_get_text(data->icon_path); @@ -2363,15 +2100,13 @@ ACCOUNT_API int account_type_get_icon_path(account_type_h account_type, char **i ACCOUNT_API int account_type_get_small_icon_path(account_type_h account_type, char **small_icon_path) { - if (!account_type) { + if (!account_type) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!small_icon_path) { + if (!small_icon_path) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_type_s *data = (account_type_s*)account_type; + account_type_s *data = (account_type_s *)account_type; (*small_icon_path) = NULL; *small_icon_path = _account_get_text(data->small_icon_path); @@ -2386,34 +2121,33 @@ ACCOUNT_API int account_type_get_small_icon_path(account_type_h account_type, ch ACCOUNT_API int account_type_get_multiple_account_support(account_type_h account_type, int *multiple_account_support) { - if (!account_type) { + if (!account_type) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - if (!multiple_account_support) { + + if (!multiple_account_support) return ACCOUNT_ERROR_INVALID_PARAMETER; - } - account_type_s *data = (account_type_s*)account_type; + account_type_s *data = (account_type_s *)account_type; *multiple_account_support = data->multiple_account_support; return ACCOUNT_ERROR_NONE; } -ACCOUNT_API int account_type_get_provider_feature_all(account_type_h account_type, provider_feature_cb callback, void* user_data) +ACCOUNT_API int account_type_get_provider_feature_all(account_type_h account_type, provider_feature_cb callback, void *user_data) { ACCOUNT_RETURN_VAL((account_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL")); ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("NO CALLBACK FUNCTION")); GSList *iter; - account_type_s *data = (account_type_s*)account_type; + account_type_s *data = (account_type_s *)account_type; for (iter = data->provider_feature_list; iter != NULL; iter = g_slist_next(iter)) { provider_feature_s *feature_data = NULL; - feature_data = (provider_feature_s*)iter->data; + feature_data = (provider_feature_s *)iter->data; - if(callback(feature_data->app_id, feature_data->key, user_data)!=TRUE) { + if (callback(feature_data->app_id, feature_data->key, user_data) != TRUE) { ACCOUNT_DEBUG("Callback func returs FALSE, its iteration is stopped!!!!\n"); return ACCOUNT_ERROR_NONE; } @@ -2422,22 +2156,22 @@ ACCOUNT_API int account_type_get_provider_feature_all(account_type_h account_typ return ACCOUNT_ERROR_NONE; } -ACCOUNT_API int account_type_get_label_by_locale(account_type_h account_type, const char* locale, char** label) +ACCOUNT_API int account_type_get_label_by_locale(account_type_h account_type, const char *locale, char **label) { ACCOUNT_RETURN_VAL((account_type != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("ACCOUNT HANDLE IS NULL")); ACCOUNT_RETURN_VAL((label != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("INVALID PARAMETER")); GSList *iter; - account_type_s *data = (account_type_s*)account_type; + account_type_s *data = (account_type_s *)account_type; for (iter = data->label_list; iter != NULL; iter = g_slist_next(iter)) { label_s *label_data = NULL; - label_data = (label_s*)iter->data; + label_data = (label_s *)iter->data; *label = NULL; - if(!strcmp(locale, label_data->locale)) { + if (!strcmp(locale, label_data->locale)) { *label = _account_get_text(label_data->label); if (*label == NULL) { ACCOUNT_FATAL("OUT OF MEMORY\n"); @@ -2446,19 +2180,19 @@ ACCOUNT_API int account_type_get_label_by_locale(account_type_h account_type, co return ACCOUNT_ERROR_NONE; } - gchar** tokens = g_strsplit(locale, "-", 2); + gchar **tokens = g_strsplit(locale, "-", 2); - if(tokens != NULL) { - if((char*)(tokens[1]) != NULL) { - char* upper_token = g_ascii_strup(tokens[1], strlen(tokens[1])); + if (tokens != NULL) { + if ((char *)(tokens[1]) != NULL) { + char *upper_token = g_ascii_strup(tokens[1], strlen(tokens[1])); if (upper_token == NULL) { ACCOUNT_FATAL("Memory Allocation Failed"); g_strfreev(tokens); return ACCOUNT_ERROR_OUT_OF_MEMORY; } - if(upper_token != NULL) { - char* converted_locale = g_strdup_printf("%s_%s", tokens[0], upper_token); + if (upper_token != NULL) { + char *converted_locale = g_strdup_printf("%s_%s", tokens[0], upper_token); if (converted_locale == NULL) { ACCOUNT_FATAL("Memory Allocation Failed"); _ACCOUNT_FREE(upper_token); @@ -2466,7 +2200,7 @@ ACCOUNT_API int account_type_get_label_by_locale(account_type_h account_type, co return ACCOUNT_ERROR_OUT_OF_MEMORY; } - if(!strcmp(converted_locale, label_data->locale)) { + if (!strcmp(converted_locale, label_data->locale)) { _ACCOUNT_FREE(converted_locale); _ACCOUNT_FREE(upper_token); g_strfreev(tokens); @@ -2495,14 +2229,14 @@ ACCOUNT_API int account_type_get_label(account_type_h account_type, account_labe ACCOUNT_RETURN_VAL((callback != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("NO CALLBACK FUNCTION")); GSList *iter; - account_type_s *data = (account_type_s*)account_type; + account_type_s *data = (account_type_s *)account_type; for (iter = data->label_list; iter != NULL; iter = g_slist_next(iter)) { label_s *label_data = NULL; - label_data = (label_s*)iter->data; + label_data = (label_s *)iter->data; - if(callback(label_data->app_id, label_data->label, label_data->locale, user_data)!=TRUE) { + if (callback(label_data->app_id, label_data->label, label_data->locale, user_data) != TRUE) { ACCOUNT_DEBUG("Callback func returs FALSE, its iteration is stopped!!!!\n"); return ACCOUNT_ERROR_NONE; } @@ -2511,7 +2245,7 @@ ACCOUNT_API int account_type_get_label(account_type_h account_type, account_labe return ACCOUNT_ERROR_NONE; } -ACCOUNT_INTERNAL_API int account_type_insert_to_db(account_type_h account_type, int* account_type_id) +ACCOUNT_INTERNAL_API int account_type_insert_to_db(account_type_h account_type, int *account_type_id) { _INFO("account_type_insert_to_db starting"); @@ -2520,36 +2254,33 @@ ACCOUNT_INTERNAL_API int account_type_insert_to_db(account_type_h account_type, GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } int db_id = -1; - GVariant* account_type_serialized = marshal_account_type((account_type_s*) account_type); + GVariant *account_type_serialized = marshal_account_type((account_type_s *)account_type); bool is_success = account_manager_call_account_type_add_sync(acc_mgr, account_type_serialized, (int)getuid(), &db_id, NULL, &error); int ret = _account_get_error_code(is_success, error); g_clear_error(&error); if (ret != ACCOUNT_ERROR_NONE) - { return ret; - } _INFO("account_type_insert_to_db end id=[%d]", db_id); *account_type_id = db_id; - account_type_s* account_type_data = (account_type_s*)account_type; + account_type_s *account_type_data = (account_type_s *)account_type; account_type_data->id = db_id; return ACCOUNT_ERROR_NONE; } -ACCOUNT_INTERNAL_API int account_type_update_to_db_by_app_id(const account_type_h account_type, const char* app_id) +ACCOUNT_INTERNAL_API int account_type_update_to_db_by_app_id(const account_type_h account_type, const char *app_id) { _INFO("account_type_update_to_db_by_app_id starting"); int error_code = ACCOUNT_ERROR_NONE; @@ -2559,16 +2290,14 @@ ACCOUNT_INTERNAL_API int account_type_update_to_db_by_app_id(const account_type_ GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } - GVariant* account_type_variant = marshal_account_type((account_type_s*) account_type); - if (account_type_variant == NULL) - { + GVariant *account_type_variant = marshal_account_type((account_type_s *)account_type); + if (account_type_variant == NULL) { _ERR("Failed to serialize"); return ACCOUNT_ERROR_INVALID_PARAMETER; } @@ -2581,7 +2310,7 @@ ACCOUNT_INTERNAL_API int account_type_update_to_db_by_app_id(const account_type_ return error_code; } -ACCOUNT_INTERNAL_API int account_type_delete_by_app_id(const char* app_id) +ACCOUNT_INTERNAL_API int account_type_delete_by_app_id(const char *app_id) { _INFO("account_type_delete_by_app_id starting"); int error_code = ACCOUNT_ERROR_NONE; @@ -2590,9 +2319,8 @@ ACCOUNT_INTERNAL_API int account_type_delete_by_app_id(const char* app_id) GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -2605,7 +2333,7 @@ ACCOUNT_INTERNAL_API int account_type_delete_by_app_id(const char* app_id) return error_code; } -ACCOUNT_API int account_type_query_label_by_app_id(account_label_cb callback, const char* app_id, void *user_data ) +ACCOUNT_API int account_type_query_label_by_app_id(account_label_cb callback, const char *app_id, void *user_data) { _INFO("account_type_query_label_by_app_id starting"); @@ -2614,46 +2342,35 @@ ACCOUNT_API int account_type_query_label_by_app_id(account_label_cb callback, co GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } - GVariant* label_list_variant = NULL; + GVariant *label_list_variant = NULL; bool is_success = account_manager_call_account_type_query_label_by_app_id_sync(acc_mgr, app_id, (int)getuid(), &label_list_variant, NULL, &error); int ret = _account_get_error_code(is_success, error); g_clear_error(&error); if (ret != ACCOUNT_ERROR_NONE) - { return ret; - } - _INFO("before variant_to_label_list"); - GSList* label_list = variant_to_label_list (label_list_variant); - _INFO("after variant_to_label_list"); + GSList *label_list = variant_to_label_list(label_list_variant); if (label_list == NULL) - { return ACCOUNT_ERROR_NO_DATA; - } - GSList* iter; + GSList *iter; - for (iter = label_list; iter != NULL; iter = g_slist_next(iter)) - { + for (iter = label_list; iter != NULL; iter = g_slist_next(iter)) { _INFO("iterating received account_list"); label_s *label_record = NULL; - label_record = (label_s*)iter->data; - _INFO(""); - if (callback(label_record->app_id, label_record->label, label_record->locale, user_data) == false) - { + label_record = (label_s *)iter->data; + if (callback(label_record->app_id, label_record->label, label_record->locale, user_data) == false) { _INFO("application callback requested to discontinue."); break; } - _INFO(""); } _account_type_gslist_label_free(label_list); @@ -2661,7 +2378,7 @@ ACCOUNT_API int account_type_query_label_by_app_id(account_label_cb callback, co return ACCOUNT_ERROR_NONE; } -ACCOUNT_API int account_type_query_by_app_id(const char* app_id, account_type_h *account_type) +ACCOUNT_API int account_type_query_by_app_id(const char *app_id, account_type_h *account_type) { _INFO("account_type_query_by_app_id starting"); @@ -2671,15 +2388,14 @@ ACCOUNT_API int account_type_query_by_app_id(const char* app_id, account_type_h GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } - GVariant* account_type_variant = NULL; - account_type_s *in_data = (account_type_s*) (*account_type); + GVariant *account_type_variant = NULL; + account_type_s *in_data = (account_type_s *)*account_type; bool is_success = account_manager_call_account_type_query_by_app_id_sync(acc_mgr, app_id, (int)getuid(), &account_type_variant, NULL, &error); @@ -2687,11 +2403,9 @@ ACCOUNT_API int account_type_query_by_app_id(const char* app_id, account_type_h g_clear_error(&error); if (ret != ACCOUNT_ERROR_NONE) - { return ret; - } - account_type_s* received_account_type = umarshal_account_type (account_type_variant); + account_type_s *received_account_type = umarshal_account_type(account_type_variant); ACCOUNT_RETURN_VAL((received_account_type != NULL), {}, ACCOUNT_ERROR_DB_FAILED, ("INVALID DATA RECEIVED FROM SVC")); in_data->id = received_account_type->id; @@ -2716,14 +2430,13 @@ ACCOUNT_API int account_type_foreach_account_type_from_db(account_type_cb callba GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } - GVariant* account_type_list_variant = NULL; + GVariant *account_type_list_variant = NULL; _INFO("before account_type_query_all_sync()"); bool is_success = account_manager_call_account_type_query_all_sync(acc_mgr, (int)getuid(), &account_type_list_variant, NULL, &error); @@ -2732,28 +2445,22 @@ ACCOUNT_API int account_type_foreach_account_type_from_db(account_type_cb callba g_clear_error(&error); if (ret != ACCOUNT_ERROR_NONE) - { return ret; - } - GSList* account_type_list = unmarshal_account_type_list(account_type_list_variant); + GSList *account_type_list = unmarshal_account_type_list(account_type_list_variant); g_variant_unref(account_type_list_variant); if (account_type_list == NULL) - { return ACCOUNT_ERROR_NO_DATA; - } - GSList* iter; + GSList *iter; - for (iter = account_type_list; iter != NULL; iter = g_slist_next(iter)) - { + for (iter = account_type_list; iter != NULL; iter = g_slist_next(iter)) { _INFO("iterating received account_list"); account_type_s *account_type = NULL; - account_type = (account_type_s*)iter->data; + account_type = (account_type_s *)iter->data; - if (callback((account_type_h)account_type, user_data) == false) - { + if (callback((account_type_h)account_type, user_data) == false) { _INFO("application callback requested to discontinue."); break; } @@ -2764,7 +2471,7 @@ ACCOUNT_API int account_type_foreach_account_type_from_db(account_type_cb callba return ACCOUNT_ERROR_NONE; } -ACCOUNT_API int account_type_query_label_by_locale(const char* app_id, const char* locale, char** label) +ACCOUNT_API int account_type_query_label_by_locale(const char *app_id, const char *locale, char **label) { _INFO("account_type_query_label_by_locale starting"); @@ -2774,14 +2481,13 @@ ACCOUNT_API int account_type_query_label_by_locale(const char* app_id, const cha GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } - char* label_temp = NULL; + char *label_temp = NULL; _INFO("before account_type_query_label_by_locale_sync()"); bool is_success = account_manager_call_account_type_query_label_by_locale_sync(acc_mgr, app_id, locale, (int)getuid(), &label_temp, NULL, &error); @@ -2790,14 +2496,10 @@ ACCOUNT_API int account_type_query_label_by_locale(const char* app_id, const cha g_clear_error(&error); if (ret != ACCOUNT_ERROR_NONE) - { return ret; - } if (label_temp == NULL) - { return ACCOUNT_ERROR_NO_DATA; - } *label = NULL; *label = _account_get_text(label_temp); @@ -2811,7 +2513,7 @@ ACCOUNT_API int account_type_query_label_by_locale(const char* app_id, const cha } -ACCOUNT_API int account_type_query_by_provider_feature(account_type_cb callback, const char* key, void* user_data) +ACCOUNT_API int account_type_query_by_provider_feature(account_type_cb callback, const char *key, void *user_data) { _INFO("account_type_query_by_provider_feature starting"); @@ -2820,43 +2522,36 @@ ACCOUNT_API int account_type_query_by_provider_feature(account_type_cb callback, GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } - GVariant* account_type_list_variant = NULL; + GVariant *account_type_list_variant = NULL; bool is_success = account_manager_call_account_type_query_by_provider_feature_sync(acc_mgr, key, (int)getuid(), &account_type_list_variant, NULL, &error); int ret = _account_get_error_code(is_success, error); g_clear_error(&error); if (ret != ACCOUNT_ERROR_NONE) - { return ret; - } _INFO("before unmarshal_account_type_list"); - GSList* account_type_list = unmarshal_account_type_list(account_type_list_variant); + GSList *account_type_list = unmarshal_account_type_list(account_type_list_variant); g_variant_unref(account_type_list_variant); if (account_type_list == NULL) - { return ACCOUNT_ERROR_NO_DATA; - } - GSList* iter; + GSList *iter; - for (iter = account_type_list; iter != NULL; iter = g_slist_next(iter)) - { + for (iter = account_type_list; iter != NULL; iter = g_slist_next(iter)) { _INFO("iterating received account_type_list"); account_type_s *account_type = NULL; - account_type = (account_type_s*)iter->data; + account_type = (account_type_s *)iter->data; _INFO(""); - if (callback((account_type_h)account_type, user_data) == false) - { + if (callback((account_type_h)account_type, user_data) == false) { _INFO("Application callback requested not to continue"); break; } @@ -2868,7 +2563,7 @@ ACCOUNT_API int account_type_query_by_provider_feature(account_type_cb callback, return ACCOUNT_ERROR_NONE; } -ACCOUNT_API int account_type_query_app_id_exist(const char* app_id) +ACCOUNT_API int account_type_query_app_id_exist(const char *app_id) { _INFO("account_type_query_app_id_exist starting"); int error_code = ACCOUNT_ERROR_NONE; @@ -2877,9 +2572,8 @@ ACCOUNT_API int account_type_query_app_id_exist(const char* app_id) GError *error = NULL; - AccountManager* acc_mgr = _account_manager_get_instance(); - if (acc_mgr == NULL) - { + AccountManager *acc_mgr = _account_manager_get_instance(); + if (acc_mgr == NULL) { _ERR("g_bus_get_sync failed"); return ACCOUNT_ERROR_PERMISSION_DENIED; } @@ -2895,34 +2589,33 @@ ACCOUNT_API int account_type_query_app_id_exist(const char* app_id) static void _account_subscribe_vconf_callback(keynode_t *key, void *user_data) { - account_subscribe_s* tmp = (account_subscribe_s*)user_data; + account_subscribe_s *tmp = (account_subscribe_s *)user_data; char *msg = NULL, *vconf_key = NULL; const char *key_name = NULL; - char event_msg[256] ={0, }; + char event_msg[256] = {0, }; int account_id = -1; - if(!key) { + if (!key) { ACCOUNT_ERROR("No subscribtion msg !!!!!\n"); return; } - if(!tmp) { + if (!tmp) { ACCOUNT_ERROR("user data required\n"); return; } key_name = vconf_keynode_get_name(key); - if ( key_name == NULL ) { + if (key_name == NULL) { ACCOUNT_ERROR("vconf_keynode_get_name(key) fail\n"); return; } - if(!memcmp(key_name, VCONFKEY_ACCOUNT_MSG_STR, strlen(VCONFKEY_ACCOUNT_MSG_STR))) - { + if (!memcmp(key_name, VCONFKEY_ACCOUNT_MSG_STR, strlen(VCONFKEY_ACCOUNT_MSG_STR))) { vconf_key = vconf_keynode_get_str(key); - if( vconf_key == NULL){ + if (vconf_key == NULL) { ACCOUNT_ERROR("vconf key is NULL.\n"); return; } @@ -2933,35 +2626,35 @@ static void _account_subscribe_vconf_callback(keynode_t *key, void *user_data) return; } - char* event_type = NULL; - char* id = NULL; - char* ptr = NULL; + char *event_type = NULL; + char *id = NULL; + char *ptr = NULL; event_type = strtok_r(msg, ":", &ptr); id = strtok_r(NULL, ":", &ptr); ACCOUNT_SLOGD("msg(%s), event_type(%s), id(%s)", msg, event_type, id); - ACCOUNT_SNPRINTF(event_msg,sizeof(event_msg),"%s", event_type); + ACCOUNT_SNPRINTF(event_msg, sizeof(event_msg), "%s", event_type); account_id = atoi(id); - if(tmp->account_subscription_callback) + if (tmp->account_subscription_callback) tmp->account_subscription_callback(event_msg, account_id, tmp->user_data); _ACCOUNT_FREE(msg); } } -ACCOUNT_API int account_subscribe_create(account_subscribe_h* account_subscribe) +ACCOUNT_API int account_subscribe_create(account_subscribe_h *account_subscribe) { if (!account_subscribe) { ACCOUNT_SLOGE("account is NULL.\n", __FUNCTION__, __LINE__); return ACCOUNT_ERROR_INVALID_PARAMETER; } - account_subscribe_s *data = (account_subscribe_s*)calloc(1,sizeof(account_subscribe_s)); - if(!data) { + account_subscribe_s *data = (account_subscribe_s *)calloc(1, sizeof(account_subscribe_s)); + if (!data) { ACCOUNT_FATAL("OUT OF MEMORY\n"); return ACCOUNT_ERROR_OUT_OF_MEMORY; } @@ -2971,11 +2664,11 @@ ACCOUNT_API int account_subscribe_create(account_subscribe_h* account_subscribe) return ACCOUNT_ERROR_NONE; } -ACCOUNT_API int account_subscribe_notification(account_subscribe_h account_subscribe, account_event_cb callback, void* user_data) +ACCOUNT_API int account_subscribe_notification(account_subscribe_h account_subscribe, account_event_cb callback, void *user_data) { ACCOUNT_RETURN_VAL((account_subscribe != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("(%s)-(%d) account subscribe handle is NULL.\n", __FUNCTION__, __LINE__)); - account_subscribe_s* tmp =(account_subscribe_s*)account_subscribe; + account_subscribe_s *tmp = (account_subscribe_s *)account_subscribe; tmp->account_subscription_callback = callback; tmp->user_data = user_data; @@ -2983,11 +2676,11 @@ ACCOUNT_API int account_subscribe_notification(account_subscribe_h account_subsc int ret = -1; ret = vconf_notify_key_changed(VCONFKEY_ACCOUNT_MSG_STR, (vconf_callback_fn)_account_subscribe_vconf_callback, - (void*)tmp); + (void *)tmp); ACCOUNT_SLOGI("vconf_notify_key_changed ret = %d", ret); - if(ret != VCONF_OK) { + if (ret != VCONF_OK) { ACCOUNT_ERROR("Vconf Subscription Failed ret = %d", ret); return ACCOUNT_ERROR_EVENT_SUBSCRIPTION_FAIL; } @@ -2999,7 +2692,7 @@ ACCOUNT_API int account_unsubscribe_notification(account_subscribe_h account_sub { ACCOUNT_RETURN_VAL((account_subscribe != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("(%s)-(%d) account subscribe handle is NULL.\n", __FUNCTION__, __LINE__)); - account_subscribe_s* tmp =(account_subscribe_s*)account_subscribe; + account_subscribe_s *tmp = (account_subscribe_s *)account_subscribe; _ACCOUNT_FREE(tmp); @@ -3014,34 +2707,33 @@ ACCOUNT_API int account_unsubscribe_notification(account_subscribe_h account_sub static void _account_subscribe_vconf_callback_ex(keynode_t *key, void *user_data) { - account_subscribe_s* tmp = (account_subscribe_s*)user_data; + account_subscribe_s *tmp = (account_subscribe_s *)user_data; char *msg = NULL, *vconf_key = NULL; - char event_msg[256] ={0, }; + char event_msg[256] = {0, }; int account_id = -1; const char *key_name = NULL; - if(!key) { + if (!key) { ACCOUNT_ERROR("No subscribtion msg !!!!!\n"); return; } - if(!tmp) { + if (!tmp) { ACCOUNT_ERROR("user data required\n"); return; } key_name = vconf_keynode_get_name(key); - if ( key_name == NULL ) { + if (key_name == NULL) { ACCOUNT_ERROR("vconf_keynode_get_name(key) fail\n"); return; } - if(!memcmp(key_name, VCONFKEY_ACCOUNT_MSG_STR, strlen(VCONFKEY_ACCOUNT_MSG_STR))) - { + if (!memcmp(key_name, VCONFKEY_ACCOUNT_MSG_STR, strlen(VCONFKEY_ACCOUNT_MSG_STR))) { vconf_key = vconf_keynode_get_str(key); - if( vconf_key == NULL){ + if (vconf_key == NULL) { ACCOUNT_ERROR("vconf key is NULL.\n"); return; } @@ -3051,20 +2743,20 @@ static void _account_subscribe_vconf_callback_ex(keynode_t *key, void *user_data return; } - char* event_type = NULL; - char* id = NULL; - char* ptr = NULL; + char *event_type = NULL; + char *id = NULL; + char *ptr = NULL; event_type = strtok_r(msg, ":", &ptr); id = strtok_r(NULL, ":", &ptr); ACCOUNT_SLOGD("msg(%s), event_type(%s), id(%s)", msg, event_type, id); - ACCOUNT_SNPRINTF(event_msg,sizeof(event_msg),"%s", event_type); + ACCOUNT_SNPRINTF(event_msg, sizeof(event_msg), "%s", event_type); account_id = atoi(id); - if(tmp->account_subscription_callback) + if (tmp->account_subscription_callback) tmp->account_subscription_callback(event_msg, account_id, tmp->user_data); } @@ -3076,7 +2768,7 @@ ACCOUNT_API int account_unsubscribe_notification_ex(account_subscribe_h account_ { ACCOUNT_RETURN_VAL((account_subscribe != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("(%s)-(%d) account subscribe handle is NULL.\n", __FUNCTION__, __LINE__)); - account_subscribe_s* tmp =(account_subscribe_s*)account_subscribe; + account_subscribe_s *tmp = (account_subscribe_s *)account_subscribe; _ACCOUNT_FREE(tmp); @@ -3089,11 +2781,11 @@ ACCOUNT_API int account_unsubscribe_notification_ex(account_subscribe_h account_ return ACCOUNT_ERROR_NONE; } -ACCOUNT_API int account_subscribe_notification_ex(account_subscribe_h account_subscribe, account_event_cb callback, void* user_data) +ACCOUNT_API int account_subscribe_notification_ex(account_subscribe_h account_subscribe, account_event_cb callback, void *user_data) { ACCOUNT_RETURN_VAL((account_subscribe != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("(%s)-(%d) account subscribe handle is NULL.\n", __FUNCTION__, __LINE__)); - account_subscribe_s* tmp =(account_subscribe_s*)account_subscribe; + account_subscribe_s *tmp = (account_subscribe_s *)account_subscribe; tmp->account_subscription_callback = callback; tmp->user_data = user_data; @@ -3101,11 +2793,11 @@ ACCOUNT_API int account_subscribe_notification_ex(account_subscribe_h account_su int ret = -1; ret = vconf_notify_key_changed(VCONFKEY_ACCOUNT_MSG_STR, (vconf_callback_fn)_account_subscribe_vconf_callback_ex, - (void*)tmp); + (void *)tmp); ACCOUNT_SLOGI("vconf_notify_key_changed ret = %d", ret); - if(ret != VCONF_OK) { + if (ret != VCONF_OK) { ACCOUNT_ERROR("Vconf Subscription Failed ret = %d", ret); return ACCOUNT_ERROR_EVENT_SUBSCRIPTION_FAIL; } diff --git a/src/account_offline.c b/src/account_offline.c index b5e2497..aa9ea2e 100644 --- a/src/account_offline.c +++ b/src/account_offline.c @@ -25,7 +25,6 @@ #include #include #include -//#include #include #include @@ -44,16 +43,14 @@ #define ACCOUNT_DB_OPEN_READONLY 0 #define ACCOUNT_DB_OPEN_READWRITE 1 -//#define OWNER_ROOT 0 -//#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) #define APP_GID 100 #define MIN_USER_UID 5000 -typedef sqlite3_stmt* account_stmt; +typedef sqlite3_stmt * account_stmt; -static sqlite3* g_hAccountUserDB = NULL; -static sqlite3* g_hAccountGlobalDB = NULL; -static int g_refCntDB = 0; +static sqlite3 *g_hAccountUserDB = NULL; +static sqlite3 *g_hAccountGlobalDB = NULL; +static int g_refCntDB = 0; pthread_mutex_t account_mutex = PTHREAD_MUTEX_INITIALIZER; static int _account_user_db_close(sqlite3 *hAccountDB) @@ -63,11 +60,11 @@ static int _account_user_db_close(sqlite3 *hAccountDB) if (hAccountDB) { rc = db_util_close(hAccountDB); - if( rc == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(SQLITE_PERM)"); + if (rc == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(SQLITE_PERM)"); return ACCOUNT_ERROR_PERMISSION_DENIED; - } else if ( rc == SQLITE_BUSY ){ - ACCOUNT_ERROR( "database busy"); + } else if (rc == SQLITE_BUSY) { + ACCOUNT_ERROR("database busy"); return ACCOUNT_ERROR_DATABASE_BUSY; } ACCOUNT_RETURN_VAL((rc == SQLITE_OK), {}, ACCOUNT_ERROR_DB_FAILED, ("The database isn't connected. rc : %d", rc)); @@ -89,29 +86,27 @@ static int _account_user_db_open(sqlite3 **p_hAccountDB, int mode, uid_t uid) ACCOUNT_MEMSET(account_db_path, 0x00, sizeof(account_db_path)); ACCOUNT_GET_USER_DB_PATH(account_db_path, sizeof(account_db_path), uid); - _INFO( "account_db_path canonicalized = %s", account_db_path); + _INFO("account_db_path canonicalized = %s", account_db_path); - if (!g_hAccountUserDB) { + if (!g_hAccountUserDB) _account_user_db_close(*p_hAccountDB); - } + ACCOUNT_GET_USER_DB_DIR(account_db_dir, sizeof(account_db_dir), uid); - if ((-1 == access (account_db_dir, F_OK)) && uid != OWNER_ROOT) { + if ((-1 == access(account_db_dir, F_OK)) && uid != OWNER_ROOT) mkdir(account_db_dir, 644); - } if (mode == ACCOUNT_DB_OPEN_READWRITE) rc = db_util_open(account_db_path, p_hAccountDB, DB_UTIL_REGISTER_HOOK_METHOD); - else { + else return ACCOUNT_ERROR_DB_NOT_OPENED; - } - if (_account_db_err_code(*p_hAccountDB) == SQLITE_PERM){ - ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg(*p_hAccountDB)); + if (_account_db_err_code(*p_hAccountDB) == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(*p_hAccountDB)); return ACCOUNT_ERROR_PERMISSION_DENIED; } if (rc == SQLITE_BUSY) { - ACCOUNT_ERROR( "busy handler fail."); + ACCOUNT_ERROR("busy handler fail."); return ACCOUNT_ERROR_DATABASE_BUSY; } @@ -143,7 +138,7 @@ static int _account_global_db_open(int mode) char account_db_path[256] = {0, }; uid_t uid = -1; - _INFO( "start to get DB path"); + _INFO("start to get DB path"); ACCOUNT_MEMSET(account_db_dir, 0x00, sizeof(account_db_dir)); ACCOUNT_MEMSET(account_db_path, 0x00, sizeof(account_db_path)); @@ -155,29 +150,26 @@ static int _account_global_db_open(int mode) } ACCOUNT_GET_GLOBAL_DB_PATH(account_db_path, sizeof(account_db_path)); -// else -// ACCOUNT_GET_USER_DB_PATH(account_db_path, sizeof(account_db_path), uid); - _INFO( "account_db_path canonicalized = %s", account_db_path); + + _INFO("account_db_path canonicalized = %s", account_db_path); if (!g_hAccountGlobalDB) { ACCOUNT_GET_USER_DB_DIR(account_db_dir, sizeof(account_db_dir), uid); - if ((-1 == access (account_db_dir, F_OK)) && uid != OWNER_ROOT) { + if ((-1 == access(account_db_dir, F_OK)) && uid != OWNER_ROOT) mkdir(account_db_dir, 644); - } if (mode == ACCOUNT_DB_OPEN_READWRITE) rc = db_util_open(account_db_path, &g_hAccountGlobalDB, DB_UTIL_REGISTER_HOOK_METHOD); - else { + else return ACCOUNT_ERROR_DB_NOT_OPENED; - } - 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; } if (rc == SQLITE_BUSY) { - ACCOUNT_ERROR( "busy handler fail."); + ACCOUNT_ERROR("busy handler fail."); return ACCOUNT_ERROR_DATABASE_BUSY; } @@ -213,16 +205,15 @@ static int _account_global_db_close(void) int ret = -1; if (g_hAccountGlobalDB) { - if (g_refCntDB > 0) { + if (g_refCntDB > 0) g_refCntDB--; - } if (g_refCntDB == 0) { rc = db_util_close(g_hAccountGlobalDB); - if( rc == SQLITE_PERM ){ - ACCOUNT_ERROR( "Access failed(SQLITE_PERM)"); + if (rc == SQLITE_PERM) { + ACCOUNT_ERROR("Access failed(SQLITE_PERM)"); return ACCOUNT_ERROR_PERMISSION_DENIED; - } else if ( rc == SQLITE_BUSY ){ - ACCOUNT_ERROR( "database busy"); + } else if (rc == SQLITE_BUSY) { + ACCOUNT_ERROR("database busy"); return ACCOUNT_ERROR_DATABASE_BUSY; } ACCOUNT_RETURN_VAL((rc == SQLITE_OK), {}, ACCOUNT_ERROR_DB_FAILED, ("The database isn't connected. rc : %d", rc)); @@ -230,7 +221,7 @@ static int _account_global_db_close(void) } ret = ACCOUNT_ERROR_NONE; } else { - ACCOUNT_ERROR( "_account_svc_db_close: No handle(). refcnt=%d ", g_refCntDB); + ACCOUNT_ERROR("_account_svc_db_close: No handle(). refcnt=%d ", g_refCntDB); ret = ACCOUNT_ERROR_DB_FAILED; } @@ -238,7 +229,7 @@ static int _account_global_db_close(void) } -ACCOUNT_INTERNAL_API int account_type_insert_to_db_offline(account_type_h account_type, int* account_type_id) +ACCOUNT_INTERNAL_API int account_type_insert_to_db_offline(account_type_h account_type, int *account_type_id) { _INFO("account_type_insert_to_db starting"); @@ -256,16 +247,13 @@ ACCOUNT_INTERNAL_API int account_type_insert_to_db_offline(account_type_h accoun _INFO("client Id = [%u]", pid); return_code = _account_global_db_open(1); - if (return_code != ACCOUNT_ERROR_NONE) - { + if (return_code != ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } uid = getuid(); - if (uid != OWNER_ROOT && uid != GLOBAL_USER) - { + if (uid != OWNER_ROOT && uid != GLOBAL_USER) { _ERR("current process is not root user nor global user, uid=%d", uid); goto RETURN; } @@ -283,8 +271,7 @@ ACCOUNT_INTERNAL_API int account_type_insert_to_db_offline(account_type_h accoun _INFO("before _account_type_insert_to_db"); return_code = _account_type_insert_to_db(g_hAccountGlobalDB, account_type_data, &db_id); _INFO("after _account_type_insert_to_db"); - if (return_code != ACCOUNT_ERROR_NONE) - { + if (return_code != ACCOUNT_ERROR_NONE) { _ERR("_account_type_insert_to_db error"); goto RETURN; } @@ -295,20 +282,17 @@ ACCOUNT_INTERNAL_API int account_type_insert_to_db_offline(account_type_h accoun RETURN: _INFO("account_manager_account_type_add end"); - if( g_hAccountUserDB == NULL ) + if (g_hAccountUserDB == NULL) return return_code; return_code = _account_global_db_close(); if (return_code != ACCOUNT_ERROR_NONE) - { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); -// return_code = ACCOUNT_ERROR_DB_FAILED; - } return return_code; } -ACCOUNT_INTERNAL_API int account_type_delete_by_app_id_offline(const char* app_id) +ACCOUNT_INTERNAL_API int account_type_delete_by_app_id_offline(const char *app_id) { _INFO("account_type_delete_by_app_id starting"); @@ -319,62 +303,40 @@ ACCOUNT_INTERNAL_API int account_type_delete_by_app_id_offline(const char* app_i _INFO("client Id = [%u]", pid); int return_code = _account_global_db_open(1); - if (return_code != ACCOUNT_ERROR_NONE) - { + if (return_code != ACCOUNT_ERROR_NONE) { _ERR("_account_global_db_open() error, ret = %d", return_code); - goto RETURN; } uid_t uid = getuid(); - if (uid != OWNER_ROOT && uid != GLOBAL_USER) - { + if (uid != OWNER_ROOT && uid != GLOBAL_USER) { _ERR("current daemon is not root user, uid=%d", uid); goto RETURN; } -// _account_begin_transaction(g_hAccountGlobalDB); pthread_mutex_lock(&account_mutex); _INFO("before _account_type_delete_by_app_id"); return_code = _account_type_delete_by_app_id(g_hAccountGlobalDB, app_id); _INFO("after _account_type_delete_by_app_id=[%d]", return_code); pthread_mutex_unlock(&account_mutex); - if (return_code != ACCOUNT_ERROR_NONE) - { + if (return_code != ACCOUNT_ERROR_NONE) { _ERR("_account_type_delete_by_app_id error"); goto RETURN; } RETURN: -// _account_end_transaction(g_hAccountGlobalDB, true); - - if( g_hAccountGlobalDB == NULL ) + if (g_hAccountGlobalDB == NULL) return return_code; return_code = _account_global_db_close(); if (return_code != ACCOUNT_ERROR_NONE) - { ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code); -// return_code = ACCOUNT_ERROR_DB_FAILED; - } _INFO("account_type_delete_by_app_id_offline end"); return return_code; } -/* -static void _account_insert_delete_update_notification_send(char *noti_name, int pid) -{ - if (!noti_name) { - _ERR("Noti Name is NULL!!!!!!\n"); - return; - } - if (vconf_set_str(VCONFKEY_ACCOUNT_MSG_STR, noti_name) != 0) { - _ERR("Vconf MSG Str set FAILED !!!!!!\n");; - } -} -*/ ACCOUNT_INTERNAL_API int account_delete_from_db_by_package_name_offline(const char *package_name) { _INFO("_account_delete_from_db_by_package_name_offline"); @@ -391,36 +353,26 @@ ACCOUNT_INTERNAL_API int account_delete_from_db_by_package_name_offline(const ch return_code = ACCOUNT_ERROR_PERMISSION_DENIED; goto RETURN; } -// gid = getgid(); setpwent(); while ((user_pw = getpwent()) != NULL) { uid = user_pw->pw_uid; gid = user_pw->pw_gid; _INFO("user_pw->pw_uid=[%d], user_pw->pw_gid", uid, gid); - if (uid > MIN_USER_UID && gid == APP_GID ) { + if (uid > MIN_USER_UID && gid == APP_GID) { sqlite3 *hAccountDB = NULL; - _INFO("before _account_user_db_open"); return_code = _account_user_db_open(&hAccountDB, 1, uid); - _INFO("after _account_user_db_open ret=[%d]", return_code); + if (return_code != ACCOUNT_ERROR_NONE) - { ACCOUNT_DEBUG("_account_user_db_open() error, ret=[%d]", return_code); - } - _INFO("before _account_delete_account_by_package_name"); return_code = _account_delete_account_by_package_name(hAccountDB, package_name, false, getpid(), uid); - _INFO("after _account_delete_account_by_package_name ret=[%d]", return_code); if (return_code != ACCOUNT_ERROR_NONE) - { ACCOUNT_DEBUG("_account_delete_account_by_package_name error=[%d]", return_code); - } return_code = _account_user_db_close(hAccountDB); if (return_code != ACCOUNT_ERROR_NONE) - { ACCOUNT_DEBUG("_account_user_db_close() fail[%d]", return_code); - } } } endpwent(); diff --git a/src/account_private_client.h b/src/account_private_client.h index ad48a28..f4383f7 100644 --- a/src/account_private_client.h +++ b/src/account_private_client.h @@ -36,11 +36,10 @@ extern "C" #include "wearable/account.h" #endif -typedef struct _account_subscribe_s -{ +typedef struct _account_subscribe_s { account_event_cb account_subscription_callback; - void* user_data; -}account_subscribe_s; + void *user_data; +} account_subscribe_s; #ifdef __cplusplus }