/*
- * libnotification
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
*/
#include <stdio.h>
#define DBUS_SERVICE_DBUS "org.freedesktop.DBus"
#define DBUS_PATH_DBUS "/org/freedesktop/DBus"
#define DBUS_INTERFACE_DBUS "org.freedesktop.DBus"
+#define ERR_BUFFER_SIZE 1024
static const gchar *_bus_name = NULL;
static GDBusConnection *_gdbus_conn = NULL;
static int _ipc_monitor_deregister(void);
static void _do_deffered_task(void);
-static void _print_noti(notification_h noti) {
+static void _print_noti(notification_h noti)
+{
char *pkgname = NULL;
char *text = NULL;
char *content = NULL;
notification_get_tag(noti, &tag);
notification_get_vibration(noti, &vib_type, NULL);
- NOTIFICATION_DBG("client print_noti pkgname = %s ", pkgname );
- NOTIFICATION_DBG("client print_noti title = %s ", text );
- NOTIFICATION_DBG("client print_noti content = %s ", content );
- NOTIFICATION_DBG("client print_noti tag = %s ", tag );
+ NOTIFICATION_DBG("client print_noti pkgname = %s ", pkgname);
+ NOTIFICATION_DBG("client print_noti title = %s ", text);
+ NOTIFICATION_DBG("client print_noti content = %s ", content);
+ NOTIFICATION_DBG("client print_noti tag = %s ", tag);
NOTIFICATION_DBG("client print_noti priv_id = %d ", noti->priv_id);
NOTIFICATION_DBG("client print_noti vibration_path = %s ", noti->vibration_path);
NOTIFICATION_DBG("client print_noti vibration_type = %d ", vib_type);
}
}
- if(result)
+ if (result)
g_variant_unref(result);
return is_master_started;
static inline char *_dup_string(const char *string)
{
char *ret;
+ char err_buf[ERR_BUFFER_SIZE];
if (string == NULL)
return NULL;
ret = strdup(string);
if (!ret)
- NOTIFICATION_ERR("Error: %s\n", strerror(errno));
+ NOTIFICATION_ERR("Error: %s\n", strerror_r(errno, err_buf, sizeof(err_buf)));
return ret;
}
}
if (g_dbus_message_to_gerror(*reply, &err)) {
- ret = err->code;
- NOTIFICATION_ERR("_send_sync_noti cmd = %s, error %s", cmd, err->message);
+ if (err->code == G_DBUS_ERROR_ACCESS_DENIED)
+ ret = NOTIFICATION_ERROR_PERMISSION_DENIED;
+ else
+ ret = err->code;
+
+ NOTIFICATION_ERR("_send_sync_noti cmd = %s, error %s, err code %d", cmd, err->message, ret);
g_error_free(err);
return ret;
}
result = NOTIFICATION_ERROR_SERVICE_NOT_READY;
} else if (g_dbus_message_to_gerror(reply, &err)) {
- result = err->code;
- g_error_free(err);
+ if (err->code == G_DBUS_ERROR_ACCESS_DENIED)
+ result = NOTIFICATION_ERROR_PERMISSION_DENIED;
+ else
+ result = err->code;
+
NOTIFICATION_ERR("_send_async_noti error %s", err->message);
+ g_error_free(err);
}
NOTIFICATION_DBG("_send_async_noti done !![%d]", result);
int notification_ipc_request_insert(notification_h noti, int *priv_id)
{
int result;
- int id;
+ int id = NOTIFICATION_PRIV_ID_NONE;
GDBusMessage *reply = NULL;
GVariant *body;
GVariant *reply_body;
*priv_id = id;
}
- if(reply)
+ if (reply)
g_object_unref(reply);
- NOTIFICATION_DBG("notification_ipc_request_insert done [priv_id : %d, result: %d]", *priv_id, result);
+ NOTIFICATION_DBG("notification_ipc_request_insert done [priv_id : %d, result: %d]", id, result);
return result;
}
int notification_ipc_request_update(notification_h noti)
{
int result;
- int priv_id;
+ int priv_id = NOTIFICATION_PRIV_ID_NONE;
GDBusMessage *reply = NULL;
GVariant *body;
g_variant_get(reply_body, "(i)", &priv_id);
}
- if(reply)
+ if (reply)
g_object_unref(reply);
NOTIFICATION_DBG("notification_ipc_request_update done [result: %d, priv_id :%d]", result, priv_id);
body = g_variant_new("(i)", NOTIFICATION_OP_REFRESH);
result = _send_sync_noti(body, &reply, "refresh_noti");
- if(reply)
+ if (reply)
g_object_unref(reply);
NOTIFICATION_ERR("notification_ipc_request_refresh done [result: %d]", result);
g_variant_get(reply_body, "(i)", &id);
}
- if(reply)
+ if (reply)
g_object_unref(reply);
NOTIFICATION_ERR("notification_ipc_request_delete_single done [result: %d]", result);
NOTIFICATION_ERR("num deleted:%d", num_deleted);
}
- if(reply)
+ if (reply)
g_object_unref(reply);
return result;
}
- if(reply)
+ if (reply)
g_object_unref(reply);
NOTIFICATION_DBG("notification_ipc_request_load_noti_by_tag done [result: %d]", result);
_print_noti(noti);
}
- if(reply)
+ if (reply)
g_object_unref(reply);
NOTIFICATION_DBG("notification_ipc_request_load_noti_by_priv_id done [result: %d]", result);
NOTIFICATION_DBG("noti count [%d]", re_count);
}
- if(reply)
+ if (reply)
g_object_unref(reply);
NOTIFICATION_DBG("notification_ipc_request_get_count done [result: %d]", result);
g_variant_iter_free(iter);
}
- if(reply)
+ if (reply)
g_object_unref(reply);
NOTIFICATION_DBG("notification_ipc_request_load_noti_grouping_list done [result: %d]", result);
g_variant_iter_free(iter);
}
- if(reply)
+ if (reply)
g_object_unref(reply);
NOTIFICATION_DBG("notification_ipc_request_load_noti_detail_list done [result: %d]", result);
g_variant_iter_free(iter);
}
- if(reply)
+ if (reply)
g_object_unref(reply);
NOTIFICATION_DBG("notification_ipc_request_get_setting_array done [result: %d]", result);
g_variant_unref(setting_body);
}
- if(reply)
+ if (reply)
g_object_unref(reply);
NOTIFICATION_DBG("notification_ipc_request_get_setting_by_package_name done [result: %d]", result);
g_variant_unref(setting_body);
}
- if(reply)
+ if (reply)
g_object_unref(reply);
NOTIFICATION_DBG("notification_ipc_request_load_system_setting done [result: %d]", result);
result = _send_sync_noti(body, &reply, "update_noti_setting");
- if(reply)
+ if (reply)
g_object_unref(reply);
NOTIFICATION_DBG("notification_ipc_update_setting done [result: %d]", result);
return body;
}
-static gboolean _variant_to_int_dict(GHashTable **dict, GVariant *variant) {
-
+static gboolean _variant_to_int_dict(GHashTable **dict, GVariant *variant)
+{
GVariantIter iter;
int key;
int *hash_key;
result = _send_sync_noti(NULL, &reply, "noti_service_register");
- if(reply)
+ if (reply)
g_object_unref(reply);
NOTIFICATION_ERR("_send_service_register done = %s, result = %d", _bus_name, result);
{
return _ipc_monitor_deregister();
}
+