static volatile gsize quark_volatile = 0;
g_dbus_error_register_error_domain(_ACCOUNT_SVC_ERROR_DOMAIN,
- &quark_volatile,
- _account_svc_errors,
- G_N_ELEMENTS(_account_svc_errors));
+ &quark_volatile,
+ _account_svc_errors,
+ G_N_ELEMENTS(_account_svc_errors));
return (GQuark) quark_volatile;
}
return _check_privilege(invocation, _PRIVILEGE_ACCOUNT_WRITE);
}
-gboolean account_manager_account_add(AccountManager *obj, GDBusMethodInvocation *invocation, GVariant* account_data, gint uid, gpointer user_data)
+void _account_set_db_close(gboolean flag)
{
- _INFO("account_manager_account_add start");
- lifecycle_method_call_active();
+ if (!flag) {
+ _ERR("invalid flag");
+ return;
+ }
- int db_id = -1;
- account_s* account = NULL;
+ int rc = _ACCOUNT_ERROR_NONE;
- guint pid = _get_client_pid(invocation);
- _INFO("client Id = [%u]", pid);
+ rc = _account_db_close();
+ if (rc != _ACCOUNT_ERROR_NONE)
+ ACCOUNT_DEBUG("_account_db_close() fail[%d]", rc);
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
+
+ rc = _account_global_db_close();
+ if (rc != _ACCOUNT_ERROR_NONE)
+ ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", rc);
+
+ return;
+}
+
+int _account_check_privilege_and_set_db_open(GDBusMethodInvocation *invocation, gint uid,
+ guint *pid, gboolean read_priv, gboolean write_priv)
+{
+ if (invocation == NULL) {
+ _ERR("invalid invocation");
+ return _ACCOUNT_ERROR_INVALID_PARAMETER;
}
- return_code = _check_priviliege_account_write(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
+ _INFO("uid - [%d], read_priv - [%d], write_priv - [%d]", uid, read_priv, write_priv);
+
+ *pid = _get_client_pid(invocation);
+ _INFO("client Id = [%u]", *pid);
+
+ int rc = _ACCOUNT_ERROR_NONE;
+
+ if (read_priv) {
+ rc = _check_priviliege_account_read(invocation);
+ if (rc != _ACCOUNT_ERROR_NONE) {
+ _ERR("_check_priviliege_account_read failed, ret = %d", rc);
+ goto RETURN;
+ }
+ }
+
+ if (write_priv) {
+ rc = _check_priviliege_account_write(invocation);
+ if (rc != _ACCOUNT_ERROR_NONE) {
+ _ERR("_check_priviliege_account_write failed, ret = %d", rc);
+ goto RETURN;
+ }
+ }
+
+ rc = _account_db_open(1, *pid, uid);
+ if (rc != _ACCOUNT_ERROR_NONE) {
+ _ERR("_account_db_open() error, ret = %d", rc);
goto RETURN;
}
- return_code = _account_db_open(1, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
+ rc = _account_global_db_open();
+ if (rc != _ACCOUNT_ERROR_NONE) {
+ _ERR("_account_global_db_open() error, ret = %d", rc);
goto RETURN;
}
- return_code = _account_global_db_open();
+RETURN:
+ return rc;
+}
+
+gboolean account_manager_account_add(AccountManager *obj, GDBusMethodInvocation *invocation, GVariant* account_data, gint uid, gpointer user_data)
+{
+ _INFO("account_manager_account_add start");
+ lifecycle_method_call_active();
+
+ int db_id = -1;
+ account_s* account = NULL;
+ guint pid = -1;
+
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_add(obj, invocation, db_id);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
_account_free_account_with_items(account);
lifecycle_method_call_active();
GVariant* account_list_variant = NULL;
+ guint pid = -1;
- guint pid = _get_client_pid(invocation);
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(0, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_query_all(obj, invocation, account_list_variant);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
lifecycle_method_call_inactive();
_INFO("account_manager_account_query_all end");
lifecycle_method_call_active();
GVariant* account_type_list_variant = NULL;
- guint pid = _get_client_pid(invocation);
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(0, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
+ guint pid = -1;
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_type_query_all(obj, invocation, account_type_list_variant);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
lifecycle_method_call_inactive();
_INFO("account_manager_account_query_all end");
int db_id = -1;
account_type_s *account_type = NULL;
+ guint pid = -1;
- guint pid = _get_client_pid(invocation);
- _INFO("client pid = [%u], uid = [%d]", pid, uid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _check_priviliege_account_write(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(1, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_type_add(obj, invocation, db_id);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
_account_type_free_account_type_with_items(account_type);
gboolean
account_manager_account_delete_from_db_by_id(AccountManager *object,
- GDBusMethodInvocation *invocation,
- gint account_db_id,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ gint account_db_id,
+ gint uid)
{
_INFO("account_manager_account_delete_from_db_by_id start");
lifecycle_method_call_active();
- guint pid = _get_client_pid(invocation);
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _check_priviliege_account_write(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(1, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
+ guint pid = -1;
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_delete_from_db_by_id(object, invocation);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
lifecycle_method_call_inactive();
_INFO("account_manager_account_delete_from_db_by_id end");
gboolean
account_manager_account_delete_from_db_by_user_name(AccountManager *object,
- GDBusMethodInvocation *invocation,
- const gchar *user_name,
- const gchar *package_name,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ const gchar *user_name,
+ const gchar *package_name,
+ gint uid)
{
_INFO("account_manager_account_delete_from_db_by_user_name start");
lifecycle_method_call_active();
- guint pid = _get_client_pid(invocation);
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _check_priviliege_account_write(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(1, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
+ guint pid = -1;
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_delete_from_db_by_id(object, invocation);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
lifecycle_method_call_inactive();
_INFO("account_manager_account_delete_from_db_by_user_name end");
gboolean
account_manager_account_delete_from_db_by_package_name(AccountManager *object,
- GDBusMethodInvocation *invocation,
- const gchar *package_name,
- gboolean permission,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ const gchar *package_name,
+ gboolean permission,
+ gint uid)
{
_INFO("account_manager_account_delete_from_db_by_package_name start");
lifecycle_method_call_active();
int return_code = _ACCOUNT_ERROR_NONE;
+ guint pid = -1;
- guint pid = _get_client_pid(invocation);
- _INFO("client Id = [%u]", pid);
-
- if (permission) {
- return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _check_priviliege_account_write(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
- goto RETURN;
- }
- }
-
- return_code = _account_db_open(1, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
+ if (permission)
+ return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
+ else
+ return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, false, false);
- return_code = _account_global_db_open();
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_delete_from_db_by_package_name(object, invocation);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
lifecycle_method_call_inactive();
_INFO("account_manager_account_delete_from_db_by_package_name end");
gboolean
account_manager_account_update_to_db_by_id(AccountManager *object,
- GDBusMethodInvocation *invocation,
- GVariant *account_data,
- gint account_id,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ GVariant *account_data,
+ gint account_id,
+ gint uid)
{
_INFO("account_manager_account_update_to_db_by_id start");
lifecycle_method_call_active();
account_s *account = NULL;
+ guint pid = -1;
- guint pid = _get_client_pid(invocation);
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _check_priviliege_account_write(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(1, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_update_to_db_by_id(object, invocation);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
_account_free_account_with_items(account);
gboolean
account_manager_handle_account_update_to_db_by_user_name(AccountManager *object,
- GDBusMethodInvocation *invocation,
- GVariant *account_data,
- const gchar *user_name,
- const gchar *package_name,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ GVariant *account_data,
+ const gchar *user_name,
+ const gchar *package_name,
+ gint uid)
{
_INFO("account_manager_handle_account_update_to_db_by_user_name start");
lifecycle_method_call_active();
account_s* account = NULL;
+ guint pid = -1;
- guint pid = _get_client_pid(invocation);
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _check_priviliege_account_write(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(1, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
}
RETURN:
-
if (return_code != _ACCOUNT_ERROR_NONE) {
_ERR("Account SVC is returning error [%d]", return_code);
GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound");
account_manager_complete_account_update_to_db_by_id(object, invocation);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
_account_free_account_with_items(account);
gboolean
account_manager_handle_account_type_query_label_by_locale(AccountManager *object,
- GDBusMethodInvocation *invocation,
- const gchar *app_id,
- const gchar *locale,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ const gchar *app_id,
+ const gchar *locale,
+ gint uid)
{
_INFO("account_manager_handle_account_type_query_label_by_locale start");
lifecycle_method_call_active();
char *label_name = NULL;
- guint pid = _get_client_pid(invocation);
-
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(0, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
+ guint pid = -1;
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
}
_ACCOUNT_FREE(label_name);
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
lifecycle_method_call_inactive();
_INFO("account_manager_handle_account_type_query_label_by_locale end");
gboolean
account_manager_handle_account_type_query_by_provider_feature(AccountManager *obj,
- GDBusMethodInvocation *invocation,
- const gchar *key,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ const gchar *key,
+ gint uid)
{
_INFO("account_manager_handle_account_type_query_by_provider_feature start");
lifecycle_method_call_active();
GVariant* account_type_list_variant = NULL;
+ guint pid = -1;
- guint pid = _get_client_pid(invocation);
-
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(0, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_type_query_by_provider_feature(obj, invocation, account_type_list_variant);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
lifecycle_method_call_inactive();
_INFO("account_manager_handle_account_type_query_by_provider_feature end");
lifecycle_method_call_active();
int count = -1;
- guint pid = _get_client_pid(invocation);
-
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(0, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
+ guint pid = -1;
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_get_total_count_from_db(object, invocation, count);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
lifecycle_method_call_inactive();
_INFO("account_manager_account_get_total_count_from_db end");
GVariant* account_variant = NULL;
account_s* account_data = NULL;
+ guint pid = -1;
- guint pid = _get_client_pid(invocation);
-
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(0, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_query_account_by_account_id(object, invocation, account_variant);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
_account_free_account_with_items(account_data);
lifecycle_method_call_active();
GVariant* account_list_variant = NULL;
- guint pid = _get_client_pid(invocation);
-
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(0, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
+ guint pid = -1;
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_query_account_by_user_name(obj, invocation, account_list_variant);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
lifecycle_method_call_inactive();
_INFO("account_manager_handle_account_query_account_by_user_name end");
gboolean
account_manager_handle_account_query_account_by_package_name(AccountManager *obj,
- GDBusMethodInvocation *invocation,
- const gchar *package_name,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ const gchar *package_name,
+ gint uid)
{
_INFO("account_manager_handle_account_query_account_by_package_name start");
lifecycle_method_call_active();
GVariant* account_list_variant = NULL;
- guint pid = _get_client_pid(invocation);
-
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(0, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
+ guint pid = -1;
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
}
_INFO("account_manager_handle_account_query_account_by_package_name start");
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
lifecycle_method_call_inactive();
_INFO("account_manager_handle_account_query_account_by_package_name start");
gboolean
account_manager_handle_account_query_account_by_capability(AccountManager *obj,
- GDBusMethodInvocation *invocation,
- const gchar *capability_type,
- gint capability_value,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ const gchar *capability_type,
+ gint capability_value,
+ gint uid)
{
_INFO("account_manager_handle_account_query_account_by_capability start");
lifecycle_method_call_active();
GVariant* account_list_variant = NULL;
+ guint pid = -1;
- guint pid = _get_client_pid(invocation);
-
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(0, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_query_account_by_capability(obj, invocation, account_list_variant);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
lifecycle_method_call_inactive();
_INFO("account_manager_handle_account_query_account_by_capability end");
gboolean
account_manager_handle_account_query_account_by_capability_type(AccountManager *obj,
- GDBusMethodInvocation *invocation,
- const gchar *capability_type,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ const gchar *capability_type,
+ gint uid)
{
_INFO("account_manager_handle_account_query_account_by_capability_type start");
lifecycle_method_call_active();
GVariant* account_list_variant = NULL;
+ guint pid = -1;
- guint pid = _get_client_pid(invocation);
-
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(0, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
-
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_query_account_by_capability(obj, invocation, account_list_variant);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
lifecycle_method_call_inactive();
_INFO("account_manager_handle_account_query_account_by_capability_type end");
gboolean
account_manager_handle_account_query_capability_by_account_id(AccountManager *obj,
- GDBusMethodInvocation *invocation,
- const int account_id,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ const int account_id,
+ gint uid)
{
_INFO("account_manager_handle_account_query_capability_by_account_id start");
lifecycle_method_call_active();
GVariant* capability_list_variant = NULL;
+ guint pid = -1;
- guint pid = _get_client_pid(invocation);
-
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(0, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_query_capability_by_account_id(obj, invocation, capability_list_variant);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
lifecycle_method_call_inactive();
_INFO("account_manager_handle_account_query_capability_by_account_id end");
gboolean
account_manager_handle_account_update_sync_status_by_id(AccountManager *object,
- GDBusMethodInvocation *invocation,
- const int account_db_id,
- const int sync_status,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ const int account_db_id,
+ const int sync_status,
+ gint uid)
{
_INFO("account_manager_handle_account_update_sync_status_by_id start");
lifecycle_method_call_active();
+ guint pid = -1;
- guint pid = _get_client_pid(invocation);
-
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _check_priviliege_account_write(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(1, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_update_sync_status_by_id(object, invocation);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
lifecycle_method_call_inactive();
_INFO("account_manager_handle_account_update_sync_status_by_id end");
gboolean
account_manager_handle_account_type_query_provider_feature_by_app_id(AccountManager *obj,
- GDBusMethodInvocation *invocation,
- const gchar* app_id,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ const gchar* app_id,
+ gint uid)
{
_INFO("account_manager_handle_account_type_query_provider_feature_by_app_id start");
lifecycle_method_call_active();
GSList* feature_record_list = NULL;
GVariant* feature_record_list_variant = NULL;
+ guint pid = -1;
- guint pid = _get_client_pid(invocation);
-
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(0, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_type_query_provider_feature_by_app_id(obj, invocation, feature_record_list_variant);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
lifecycle_method_call_inactive();
_INFO("account_manager_handle_account_type_query_provider_feature_by_app_id end");
gboolean
account_manager_handle_account_type_query_supported_feature(AccountManager *obj,
- GDBusMethodInvocation *invocation,
- const gchar* app_id,
- const gchar* capability,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ const gchar* app_id,
+ const gchar* capability,
+ gint uid)
{
_INFO("account_manager_handle_account_type_query_supported_feature start");
lifecycle_method_call_active();
int is_supported = 0;
- guint pid = _get_client_pid(invocation);
-
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(0, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
+ guint pid = -1;
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_type_query_supported_feature(obj, invocation, is_supported);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
lifecycle_method_call_inactive();
_INFO("account_manager_handle_account_type_query_supported_feature end");
gboolean
account_manager_handle_account_type_update_to_db_by_app_id(AccountManager *obj,
- GDBusMethodInvocation *invocation,
- GVariant *account_type_variant,
- const gchar *app_id,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ GVariant *account_type_variant,
+ const gchar *app_id,
+ gint uid)
{
_INFO("account_manager_handle_account_type_update_to_db_by_app_id start");
lifecycle_method_call_active();
account_type_s* account_type = NULL;
+ guint pid = -1;
- guint pid = _get_client_pid(invocation);
-
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _check_priviliege_account_write(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(1, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_type_update_to_db_by_app_id(obj, invocation);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
_account_type_free_account_type_with_items(account_type);
gboolean
account_manager_handle_account_type_delete_by_app_id(AccountManager *obj,
- GDBusMethodInvocation *invocation,
- const gchar *app_id,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ const gchar *app_id,
+ gint uid)
{
_INFO("account_manager_handle_account_type_delete_by_app_id start");
lifecycle_method_call_active();
- guint pid = _get_client_pid(invocation);
-
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _check_priviliege_account_write(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(1, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
+ guint pid = -1;
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_type_delete_by_app_id(obj, invocation);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
lifecycle_method_call_inactive();
_INFO("account_manager_handle_account_type_delete_by_app_id end");
gboolean
account_manager_handle_account_type_query_label_by_app_id(AccountManager *obj,
- GDBusMethodInvocation *invocation,
- const gchar *app_id,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ const gchar *app_id,
+ gint uid)
{
_INFO("account_manager_handle_account_type_query_label_by_app_id start");
lifecycle_method_call_active();
GSList* label_list = NULL;
GVariant* label_list_variant = NULL;
- guint pid = _get_client_pid(invocation);
-
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(0, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
+ guint pid = -1;
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_type_query_label_by_app_id(obj, invocation, label_list_variant);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
lifecycle_method_call_inactive();
_INFO("account_manager_handle_account_type_query_label_by_app_id end");
gboolean
account_manager_handle_account_type_query_by_app_id(AccountManager *obj,
- GDBusMethodInvocation *invocation,
- const gchar *app_id,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ const gchar *app_id,
+ gint uid)
{
_INFO("account_manager_handle_account_type_query_by_app_id start");
lifecycle_method_call_active();
account_type_s* account_type = NULL;
GVariant* account_type_variant = NULL;
+ guint pid = -1;
- guint pid = _get_client_pid(invocation);
-
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(0, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_type_query_by_app_id(obj, invocation, account_type_variant);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
_account_type_free_account_type_with_items(account_type);
gboolean
account_manager_handle_account_type_query_app_id_exist(AccountManager *obj,
- GDBusMethodInvocation *invocation,
- const gchar *app_id,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ const gchar *app_id,
+ gint uid)
{
_INFO("account_manager_handle_account_type_query_app_id_exist start");
lifecycle_method_call_active();
- guint pid = _get_client_pid(invocation);
-
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(0, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
+ guint pid = -1;
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_type_query_app_id_exist(obj, invocation);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
lifecycle_method_call_inactive();
_INFO("account_manager_handle_account_type_query_app_id_exist end");
gboolean
account_manager_handle_account_update_to_db_by_id_ex(AccountManager *obj,
- GDBusMethodInvocation *invocation,
- GVariant *account_data,
- gint account_id,
- gint uid)
+ GDBusMethodInvocation *invocation,
+ GVariant *account_data,
+ gint account_id,
+ gint uid)
{
_INFO("account_manager_handle_account_update_to_db_by_id_ex start");
lifecycle_method_call_active();
account_s* account = NULL;
- guint pid = _get_client_pid(invocation);
-
- _INFO("client Id = [%u]", pid);
-
- int return_code = _check_priviliege_account_read(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _check_priviliege_account_write(invocation);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
- goto RETURN;
- }
-
- return_code = _account_db_open(1, pid, uid);
- if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_db_open() error, ret = %d", return_code);
- goto RETURN;
- }
+ guint pid = -1;
- return_code = _account_global_db_open();
+ int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
if (return_code != _ACCOUNT_ERROR_NONE) {
- _ERR("_account_global_db_open() error, ret = %d", return_code);
+ _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
goto RETURN;
}
account_manager_complete_account_update_to_db_by_id_ex(obj, invocation);
}
- return_code = _account_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
-
- return_code = _account_global_db_close();
- if (return_code != _ACCOUNT_ERROR_NONE) {
- ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
- return_code = _ACCOUNT_ERROR_NONE;
- }
+ _account_set_db_close(true);
_account_free_account_with_items(account);
return true;
}
-static void
-on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
+static void on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
{
- _INFO("on_bus_acquired [%s]", name);
+ _INFO("on_bus_acquired [%s]", name);
- GDBusInterfaceSkeleton* interface = NULL;
- account_mgr_server_obj = account_manager_skeleton_new();
- if (account_mgr_server_obj == NULL) {
- _ERR("account_mgr_server_obj NULL!!");
- return;
- }
+ GDBusInterfaceSkeleton* interface = NULL;
+ account_mgr_server_obj = account_manager_skeleton_new();
+ if (account_mgr_server_obj == NULL) {
+ _ERR("account_mgr_server_obj NULL!!");
+ return;
+ }
- interface = G_DBUS_INTERFACE_SKELETON(account_mgr_server_obj);
- if (!g_dbus_interface_skeleton_export(interface, connection, ACCOUNT_MGR_DBUS_PATH, NULL)) {
- _ERR("export failed!!");
- return;
- }
+ interface = G_DBUS_INTERFACE_SKELETON(account_mgr_server_obj);
+ if (!g_dbus_interface_skeleton_export(interface, connection, ACCOUNT_MGR_DBUS_PATH, NULL)) {
+ _ERR("export failed!!");
+ return;
+ }
- _INFO("connecting account signals start");
+ _INFO("connecting account signals start");
- g_signal_connect(account_mgr_server_obj, "handle_account_add",
- G_CALLBACK(account_manager_account_add), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_add",
+ G_CALLBACK(account_manager_account_add), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_query_all",
- G_CALLBACK(account_manager_account_query_all), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_query_all",
+ G_CALLBACK(account_manager_account_query_all), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_type_add",
- G_CALLBACK(account_manager_account_type_add), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_type_add",
+ G_CALLBACK(account_manager_account_type_add), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_type_query_all",
- G_CALLBACK(account_manager_account_type_query_all), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_type_query_all",
+ G_CALLBACK(account_manager_account_type_query_all), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_delete_from_db_by_id",
- G_CALLBACK(account_manager_account_delete_from_db_by_id), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_delete_from_db_by_id",
+ G_CALLBACK(account_manager_account_delete_from_db_by_id), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_delete_from_db_by_user_name",
- G_CALLBACK(account_manager_account_delete_from_db_by_user_name), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_delete_from_db_by_user_name",
+ G_CALLBACK(account_manager_account_delete_from_db_by_user_name), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_delete_from_db_by_package_name",
- G_CALLBACK(account_manager_account_delete_from_db_by_package_name), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_delete_from_db_by_package_name",
+ G_CALLBACK(account_manager_account_delete_from_db_by_package_name), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_update_to_db_by_id",
- G_CALLBACK(account_manager_account_update_to_db_by_id), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_update_to_db_by_id",
+ G_CALLBACK(account_manager_account_update_to_db_by_id), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_get_total_count_from_db",
- G_CALLBACK(account_manager_account_get_total_count_from_db), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_get_total_count_from_db",
+ G_CALLBACK(account_manager_account_get_total_count_from_db), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_query_account_by_account_id",
- G_CALLBACK(account_manager_handle_account_query_account_by_account_id), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_query_account_by_account_id",
+ G_CALLBACK(account_manager_handle_account_query_account_by_account_id), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_update_to_db_by_user_name",
- G_CALLBACK(account_manager_handle_account_update_to_db_by_user_name), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_update_to_db_by_user_name",
+ G_CALLBACK(account_manager_handle_account_update_to_db_by_user_name), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_type_query_label_by_locale",
- G_CALLBACK(account_manager_handle_account_type_query_label_by_locale), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_type_query_label_by_locale",
+ G_CALLBACK(account_manager_handle_account_type_query_label_by_locale), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_type_query_by_provider_feature",
- G_CALLBACK(account_manager_handle_account_type_query_by_provider_feature), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_type_query_by_provider_feature",
+ G_CALLBACK(account_manager_handle_account_type_query_by_provider_feature), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_query_account_by_user_name",
- G_CALLBACK(account_manager_handle_account_query_account_by_user_name), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_query_account_by_user_name",
+ G_CALLBACK(account_manager_handle_account_query_account_by_user_name), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_query_account_by_package_name",
- G_CALLBACK(account_manager_handle_account_query_account_by_package_name), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_query_account_by_package_name",
+ G_CALLBACK(account_manager_handle_account_query_account_by_package_name), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_query_account_by_capability",
- G_CALLBACK(account_manager_handle_account_query_account_by_capability), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_query_account_by_capability",
+ G_CALLBACK(account_manager_handle_account_query_account_by_capability), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_query_account_by_capability_type",
- G_CALLBACK(account_manager_handle_account_query_account_by_capability_type), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_query_account_by_capability_type",
+ G_CALLBACK(account_manager_handle_account_query_account_by_capability_type), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_query_capability_by_account_id",
- G_CALLBACK(account_manager_handle_account_query_capability_by_account_id), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_query_capability_by_account_id",
+ G_CALLBACK(account_manager_handle_account_query_capability_by_account_id), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_update_sync_status_by_id",
- G_CALLBACK(account_manager_handle_account_update_sync_status_by_id), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_update_sync_status_by_id",
+ G_CALLBACK(account_manager_handle_account_update_sync_status_by_id), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_type_query_provider_feature_by_app_id",
- G_CALLBACK(account_manager_handle_account_type_query_provider_feature_by_app_id), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_type_query_provider_feature_by_app_id",
+ G_CALLBACK(account_manager_handle_account_type_query_provider_feature_by_app_id), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_type_query_supported_feature",
- G_CALLBACK(account_manager_handle_account_type_query_supported_feature), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_type_query_supported_feature",
+ G_CALLBACK(account_manager_handle_account_type_query_supported_feature), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_type_update_to_db_by_app_id",
- G_CALLBACK(account_manager_handle_account_type_update_to_db_by_app_id), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_type_update_to_db_by_app_id",
+ G_CALLBACK(account_manager_handle_account_type_update_to_db_by_app_id), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_type_delete_by_app_id",
- G_CALLBACK(account_manager_handle_account_type_delete_by_app_id), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_type_delete_by_app_id",
+ G_CALLBACK(account_manager_handle_account_type_delete_by_app_id), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_type_query_label_by_app_id",
- G_CALLBACK(account_manager_handle_account_type_query_label_by_app_id), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_type_query_label_by_app_id",
+ G_CALLBACK(account_manager_handle_account_type_query_label_by_app_id), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_type_query_by_app_id",
- G_CALLBACK(account_manager_handle_account_type_query_by_app_id), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_type_query_by_app_id",
+ G_CALLBACK(account_manager_handle_account_type_query_by_app_id), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_type_query_app_id_exist",
- G_CALLBACK(account_manager_handle_account_type_query_app_id_exist), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_type_query_app_id_exist",
+ G_CALLBACK(account_manager_handle_account_type_query_app_id_exist), NULL);
- g_signal_connect(account_mgr_server_obj, "handle_account_update_to_db_by_id_ex",
- G_CALLBACK(account_manager_handle_account_update_to_db_by_id_ex), NULL);
+ g_signal_connect(account_mgr_server_obj, "handle_account_update_to_db_by_id_ex",
+ G_CALLBACK(account_manager_handle_account_update_to_db_by_id_ex), NULL);
- _INFO("connecting account signals end");
+ _INFO("connecting account signals end");
- _INFO("on_bus_acquired end [%s]", name);
+ _INFO("on_bus_acquired end [%s]", name);
}
void terminate_main_loop()
_INFO("__initialize_dbus Enter");
owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
- "org.tizen.account.manager",
- G_BUS_NAME_OWNER_FLAGS_NONE,
- on_bus_acquired,
- on_name_acquired,
- on_name_lost,
- NULL,
- NULL);
+ "org.tizen.account.manager",
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ on_bus_acquired,
+ on_name_acquired,
+ on_name_lost,
+ NULL,
+ NULL);
_INFO("owner_id=[%d]", owner_id);