#include "../include/mm_sound_dbus.h"
#include "../include/mm_sound_intf.h"
-#define INTERFACE_DBUS "org.freedesktop.DBus.Properties"
-#define SIGNAL_PROP_CHANGED "PropertiesChanged"
-#define METHOD_GET "Get"
-#define METHOD_SET "Set"
-
struct callback_data {
mm_sound_dbus_callback user_cb;
void *user_data;
{MM_ERROR_SOUND_FILE_NOT_FOUND, "org.tizen.multimedia.audio.FileNotFound"},
{MM_ERROR_SOUND_NO_DATA, "org.tizen.multimedia.audio.NoData"},
{MM_ERROR_SOUND_INVALID_PATH, "org.tizen.multimedia.audio.InvalidPath"},
+ {MM_ERROR_SOUND_PERMISSION_DENIED, "org.freedesktop.DBus.Error.AccessDenied"},
};
{
int i = 0;
+ debug_error("error name is [%s]", err_name);
+
for (i = 0; i < G_N_ELEMENTS(mm_sound_error_entries); i++) {
if (!strcmp(mm_sound_error_entries[i].dbus_error_name, err_name)) {
return mm_sound_error_entries[i].error_code;
return MM_ERROR_COMMON_UNKNOWN;
}
-static int _dbus_method_call(GDBusConnection* conn, const char* bus_name, const char* object, const char* intf,
- const char* method, GVariant* args, GVariant** result)
+static int _dbus_method_call(GDBusConnection *conn, const char *bus_name, const char *object, const char *intf,
+ const char *method, GVariant *args, GVariant **result)
{
int ret = MM_ERROR_NONE;
GError *err = NULL;
- GVariant* dbus_reply = NULL;
+ GVariant *dbus_reply = NULL;
if (!conn || !object || !intf || !method) {
debug_error("Invalid Argument");
debug_log("Dbus call with obj'%s' intf'%s' method'%s'", object, intf, method);
dbus_reply = g_dbus_connection_call_sync(conn, bus_name, object , intf,
- method, args ,
- NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err );
+ method, args ,
+ NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
if (!dbus_reply) {
char *err_name = NULL, *err_msg = NULL;
debug_error("Method Call '%s.%s' Failed, %s", intf, method, err->message);
- if (_parse_error_msg(err->message, &err_name, &err_msg) < 0) {
+ if (_parse_error_msg(err->message, &err_name, &err_msg) < 0) {
debug_error("failed to parse error message");
g_error_free(err);
return MM_ERROR_SOUND_INTERNAL;
return ret;
}
-#if 0
-static int _dbus_set_property(GDBusConnection* conn, const char* bus_name, const char* object, const char* intf,
- const char* prop, GVariant* args, GVariant** result)
-{
- int ret = MM_ERROR_NONE;
-
- if (!conn || !object || !intf || !prop) {
- debug_error("Invalid Argument");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- debug_log("Dbus set property with obj'%s' intf'%s' prop'%s'", object, intf, prop);
-
- if ((ret = _dbus_method_call(conn, bus_name, object, INTERFACE_DBUS, METHOD_SET,
- g_variant_new("(ssv)", intf, prop, args), result)) != MM_ERROR_NONE) {
- debug_error("Dbus call for set property failed");
- }
-
- return ret;
-}
-
-static int _dbus_get_property(GDBusConnection *conn, const char* bus_name, const char* object_name,
- const char* intf_name, const char* prop, GVariant** result)
-{
- int ret = MM_ERROR_NONE;
-
- if (!conn || !object_name || !intf_name || !prop) {
- debug_error("Invalid Argument");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- debug_log("Dbus get property with obj'%s' intf'%s' prop'%s'", object_name, intf_name, prop);
-
- if ((ret = _dbus_method_call(conn,
- bus_name, object_name, INTERFACE_DBUS, METHOD_GET,
- g_variant_new("(ss)", intf_name, prop), result)) != MM_ERROR_NONE) {
- debug_error("Dbus call for get property failed");
- }
-
- return ret;
-}
-#endif
-
-static int _dbus_subscribe_signal(GDBusConnection *conn, const char* object_name, const char* intf_name,
- const char* signal_name, GDBusSignalCallback signal_cb, guint *subscribe_id, void* userdata, GDestroyNotify freefunc)
+static int _dbus_subscribe_signal(GDBusConnection *conn, const char *object_name, const char *intf_name,
+ const char *signal_name, GDBusSignalCallback signal_cb, guint *subscribe_id,
+ void *userdata, GDestroyNotify freefunc)
{
guint subs_id = 0;
NULL, G_DBUS_SIGNAL_FLAGS_NONE , signal_cb, userdata, freefunc);
if (!subs_id) {
- debug_error ("g_dbus_connection_signal_subscribe() failed ");
+ debug_error("g_dbus_connection_signal_subscribe() failed ");
return MM_ERROR_SOUND_INTERNAL;
}
if (subscribe_id)
g_dbus_connection_signal_unsubscribe(conn, subs_id);
}
-static GDBusConnection* _dbus_get_connection(GBusType bustype)
+static GDBusConnection * _dbus_get_connection(GBusType bustype)
{
static GDBusConnection *conn_system = NULL;
static GDBusConnection *conn_session = NULL;
} else {
debug_log("Get new connection on system bus");
if (!(conn_system = g_bus_get_sync(bustype, NULL, &err))) {
- debug_error ("g_dbus_get_sync() error (%s)", err->message);
+ debug_error("g_dbus_get_sync() error (%s)", err->message);
g_error_free(err);
}
}
} else {
debug_log("Get new connection on session bus");
if (!(conn_session = g_bus_get_sync(bustype, NULL, &err))) {
- debug_error ("g_dbus_get_sync() error (%s)", err->message);
+ debug_error("g_dbus_get_sync() error (%s)", err->message);
g_error_free(err);
}
}
}
-#if 0
-static void _dbus_disconnect(GDBusConnection* conn)
-{
- debug_fenter ();
- g_object_unref(conn);
- debug_fleave ();
-}
-#endif
-
/******************************************************************************************
Simple Functions For Communicate with Sound-Server
******************************************************************************************/
int ret = MM_ERROR_NONE;
GDBusConnection *conn = NULL;
- if (method_type < 0 || method_type >= AUDIO_METHOD_MAX) {
+ if (method_type >= AUDIO_METHOD_MAX) {
debug_error("Invalid method type : %d", method_type);
return MM_ERROR_INVALID_ARGUMENT;
}
- if (provider < 0 || provider >= AUDIO_PROVIDER_MAX) {
+ if (provider >= AUDIO_PROVIDER_MAX) {
debug_error("Invalid provider : %d", provider);
return MM_ERROR_INVALID_ARGUMENT;
}
}
if ((ret = _dbus_method_call(conn, g_paths[provider].bus_name,
- g_paths[provider].object,
- g_paths[provider].interface,
- g_methods[method_type].name,
- args, result)) != MM_ERROR_NONE) {
+ g_paths[provider].object,
+ g_paths[provider].interface,
+ g_methods[method_type].name,
+ args, result)) != MM_ERROR_NONE) {
debug_error("Dbus Call on Client Error");
}
}
/* This callback only transform signal-callback to dbus non-related form (mm_sound_dbus_callback) */
-static void _dbus_signal_callback(GDBusConnection *connection,
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal_name,
- GVariant *params,
- gpointer userdata)
+static void _dbus_signal_callback(GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *params,
+ gpointer userdata)
{
- struct callback_data *cb_data = (struct callback_data*) userdata;
+ struct callback_data *cb_data = (struct callback_data *)userdata;
- debug_log("Signal(%s.%s) Received , Let's call Wrapper-Callback", interface_name, signal_name);
+ debug_log("Signal(%s.%s) Received, Let's call Wrapper-Callback", interface_name, signal_name);
if (!strcmp(signal_name, g_events[AUDIO_EVENT_VOLUME_CHANGED].name)) {
(cb_data->user_cb)(AUDIO_EVENT_VOLUME_CHANGED, params, cb_data->user_data);
static void callback_data_free_func(gpointer data)
{
- struct callback_data *cb_data = (struct callback_data *) data;
+ struct callback_data *cb_data = (struct callback_data *)data;
if (cb_data->free_func)
cb_data->free_func(cb_data->user_data);
}
EXPORT_API
-int mm_sound_dbus_signal_subscribe_to(audio_provider_t provider, audio_event_t event, mm_sound_dbus_callback callback, void *userdata, mm_sound_dbus_userdata_free freefunc, unsigned *subs_id)
+int mm_sound_dbus_signal_subscribe_to(audio_provider_t provider, audio_event_t event, mm_sound_dbus_callback callback,
+ void *userdata, mm_sound_dbus_userdata_free freefunc, unsigned *subs_id)
{
GDBusConnection *conn = NULL;
guint _subs_id = 0;
return MM_ERROR_INVALID_ARGUMENT;
}
- if (event < 0 || event >= AUDIO_EVENT_MAX) {
+ if (event >= AUDIO_EVENT_MAX) {
debug_error("Wrong event Type : %d", event);
return MM_ERROR_INVALID_ARGUMENT;
}
- if (provider < 0 || provider >= AUDIO_PROVIDER_MAX) {
+ if (provider >= AUDIO_PROVIDER_MAX) {
debug_error("Invalid provider : %d", provider);
return MM_ERROR_INVALID_ARGUMENT;
}
return MM_ERROR_SOUND_INTERNAL;
}
- if (!(cb_data = (struct callback_data*) g_malloc0(sizeof(struct callback_data)))) {
+ if (!(cb_data = (struct callback_data*)g_malloc0(sizeof(struct callback_data)))) {
debug_error("Allocate for callback data failed");
return MM_ERROR_SOUND_INTERNAL;
}
return MM_ERROR_SOUND_INTERNAL;
}
- _dbus_unsubscribe_signal(conn, (guint) subs_id);
+ _dbus_unsubscribe_signal(conn, (guint)subs_id);
return MM_ERROR_NONE;
}
GError *err = NULL;
gboolean dbus_ret;
- if (event < 0 || event >= AUDIO_EVENT_MAX) {
- debug_error ("emit signal failed, invalid argument, event_type(%d)", event);
+ if (event >= AUDIO_EVENT_MAX) {
+ debug_error("emit signal failed, invalid argument, event_type(%d)", event);
return MM_ERROR_INVALID_ARGUMENT;
}
return MM_ERROR_SOUND_INTERNAL;
}
- dbus_ret = g_dbus_connection_emit_signal (conn,
- NULL, g_paths[provider].object,
- g_paths[provider].interface, g_events[event].name,
- param, &err);
+ dbus_ret = g_dbus_connection_emit_signal(conn,
+ NULL, g_paths[provider].object,
+ g_paths[provider].interface, g_events[event].name,
+ param, &err);
if (!dbus_ret) {
- debug_error ("g_dbus_connection_emit_signal() error (%s)", err->message);
+ debug_error("g_dbus_connection_emit_signal() error (%s)", err->message);
g_error_free(err);
return MM_ERROR_SOUND_INTERNAL;
}
g_dbus_connection_flush_sync(conn, NULL, NULL);
- debug_msg ("emit signal for [%s] success", g_events[event].name);
+ debug_msg("emit signal for [%s] success", g_events[event].name);
return MM_ERROR_NONE;
}
debug_error("Invalid Parameter, event_name NULL");
return MM_ERROR_INVALID_ARGUMENT;
}
- if (event < 0 || event >= AUDIO_EVENT_MAX) {
+ if (event >= AUDIO_EVENT_MAX) {
debug_error("invalid event : %d", event);
return MM_ERROR_INVALID_ARGUMENT;
}
debug_error("Invalid Parameter, method_name NULL");
return MM_ERROR_INVALID_ARGUMENT;
}
- if (method < 0 || method >= AUDIO_METHOD_MAX) {
+ if (method >= AUDIO_METHOD_MAX) {
debug_error("invalid method : %d", method);
return MM_ERROR_INVALID_ARGUMENT;
}