Remove deprecated APIs and codes for session backward compatibility
[platform/core/multimedia/libmm-sound.git] / common / mm_sound_dbus.c
index 1b432d5..db3f600 100644 (file)
@@ -24,7 +24,7 @@ const struct dbus_path g_paths[AUDIO_PROVIDER_MAX] = {
        [AUDIO_PROVIDER_SOUND_SERVER] = {
                .bus_name = "org.tizen.SoundServer",
                .object = "/org/tizen/SoundServer1",
-               .interface ="org.tizen.SoundServer1"
+               .interface = "org.tizen.SoundServer1"
        },
        [AUDIO_PROVIDER_FOCUS_SERVER] = {
                .bus_name = "org.tizen.FocusServer",
@@ -52,24 +52,15 @@ const mm_sound_dbus_method_info_t g_methods[AUDIO_METHOD_MAX] = {
        [AUDIO_METHOD_TEST] = {
                .name = "MethodTest1",
        },
-       [AUDIO_METHOD_PLAY_FILE_START] = {
-               .name = "PlayFileStart",
-       },
        [AUDIO_METHOD_PLAY_FILE_START_WITH_STREAM_INFO] = {
                .name = "PlayFileStartWithStreamInfo",
        },
        [AUDIO_METHOD_PLAY_FILE_STOP] = {
                .name = "PlayFileStop",
        },
-       [AUDIO_METHOD_PLAY_DTMF] = {
-               .name = "PlayDTMF",
-       },
        [AUDIO_METHOD_PLAY_DTMF_WITH_STREAM_INFO] = {
                .name = "PlayDTMFWithStreamInfo",
        },
-       [AUDIO_METHOD_CLEAR_FOCUS] = {
-               .name = "ClearFocus",
-       },
        [AUDIO_METHOD_SET_VOLUME_LEVEL] = {
                .name = "SetVolumeLevel",
        },
@@ -145,6 +136,9 @@ const mm_sound_dbus_signal_info_t g_events[AUDIO_EVENT_MAX] = {
        [AUDIO_EVENT_DEVICE_STATE_CHANGED] = {
                .name = "DeviceStateChanged",
        },
+       [AUDIO_EVENT_DEVICE_RUNNING_CHANGED] = {
+               .name = "DeviceRunningChanged",
+       },
        [AUDIO_EVENT_FOCUS_CHANGED] = {
                .name = "FocusChanged",
        },
@@ -163,8 +157,7 @@ const mm_sound_dbus_signal_info_t g_events[AUDIO_EVENT_MAX] = {
 };
 
 /* Only For error types which is currently being used in server-side */
-static const GDBusErrorEntry mm_sound_error_entries[] =
-{
+static const GDBusErrorEntry mm_sound_error_entries[] = {
        {MM_ERROR_OUT_OF_MEMORY, "org.tizen.multimedia.OutOfMemory"},
        {MM_ERROR_OUT_OF_STORAGE, "org.tizen.multimedia.OutOfStorage"},
        {MM_ERROR_INVALID_ARGUMENT, "org.tizen.multimedia.InvalidArgument"},
@@ -222,9 +215,8 @@ static int _convert_error_name(const char *err_name)
        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)) {
+               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;
@@ -322,12 +314,18 @@ static GDBusConnection * _dbus_get_connection(GBusType bustype)
 
        if (bustype == G_BUS_TYPE_SYSTEM) {
                if (conn_system) {
+#ifndef TIZEN_TV
                        debug_log("Already connected to system bus");
+#endif
                } else {
+#ifndef TIZEN_TV
                        debug_log("Get new connection on system bus");
+#endif
                        conn_system = g_bus_get_sync(bustype, NULL, &err);
                        if (!conn_system || err) {
-                               debug_error ("g_dbus_get_sync() error (%s)", err ? err->message : NULL);
+#ifndef TIZEN_TV
+                               debug_error("g_dbus_get_sync() error (%s)", err ? err->message : NULL);
+#endif
                                g_error_free(err);
                                return NULL;
                        }
@@ -335,19 +333,27 @@ static GDBusConnection * _dbus_get_connection(GBusType bustype)
                return conn_system;
        } else if (bustype == G_BUS_TYPE_SESSION) {
                if (conn_session) {
+#ifndef TIZEN_TV
                        debug_log("Already connected to session bus");
+#endif
                } else {
+#ifndef TIZEN_TV
                        debug_log("Get new connection on session bus");
+#endif
                        conn_session = g_bus_get_sync(bustype, NULL, &err);
                        if (!conn_session || err) {
-                               debug_error ("g_dbus_get_sync() error (%s)", err ? err->message : NULL);
+#ifndef TIZEN_TV
+                               debug_error("g_dbus_get_sync() error (%s)", err ? err->message : NULL);
+#endif
                                g_error_free(err);
                                return NULL;
                        }
                }
                return conn_session;
        } else {
+#ifndef TIZEN_TV
                debug_error("Invalid bus type");
+#endif
                return NULL;
        }
 
@@ -401,23 +407,24 @@ static void _dbus_signal_callback(GDBusConnection *connection,
 
        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)) {
+       if (!strcmp(signal_name, g_events[AUDIO_EVENT_VOLUME_CHANGED].name))
                (cb_data->user_cb)(AUDIO_EVENT_VOLUME_CHANGED, params, cb_data->user_data);
-       } else if (!strcmp(signal_name, g_events[AUDIO_EVENT_DEVICE_CONNECTED].name)) {
+       else if (!strcmp(signal_name, g_events[AUDIO_EVENT_DEVICE_CONNECTED].name))
                (cb_data->user_cb)(AUDIO_EVENT_DEVICE_CONNECTED, params, cb_data->user_data);
-       } else if (!strcmp(signal_name, g_events[AUDIO_EVENT_DEVICE_INFO_CHANGED].name)) {
+       else if (!strcmp(signal_name, g_events[AUDIO_EVENT_DEVICE_INFO_CHANGED].name))
                (cb_data->user_cb)(AUDIO_EVENT_DEVICE_INFO_CHANGED, params, cb_data->user_data);
-       } else if (!strcmp(signal_name, g_events[AUDIO_EVENT_DEVICE_STATE_CHANGED].name)) {
+       else if (!strcmp(signal_name, g_events[AUDIO_EVENT_DEVICE_STATE_CHANGED].name))
                (cb_data->user_cb)(AUDIO_EVENT_DEVICE_STATE_CHANGED, params, cb_data->user_data);
-       } else if (!strcmp(signal_name, g_events[AUDIO_EVENT_FOCUS_CHANGED].name)) {
+       else if (!strcmp(signal_name, g_events[AUDIO_EVENT_FOCUS_CHANGED].name))
                (cb_data->user_cb)(AUDIO_EVENT_FOCUS_CHANGED, params, cb_data->user_data);
-       } else if (!strcmp(signal_name, g_events[AUDIO_EVENT_FOCUS_WATCH].name)) {
+       else if (!strcmp(signal_name, g_events[AUDIO_EVENT_FOCUS_WATCH].name))
                (cb_data->user_cb)(AUDIO_EVENT_FOCUS_WATCH, params, cb_data->user_data);
-       } else if (!strcmp(signal_name, g_events[AUDIO_EVENT_PLAY_FILE_END].name)) {
+       else if (!strcmp(signal_name, g_events[AUDIO_EVENT_PLAY_FILE_END].name))
                (cb_data->user_cb)(AUDIO_EVENT_PLAY_FILE_END, params, cb_data->user_data);
-       } else if (!strcmp(signal_name, g_events[AUDIO_EVENT_EMERGENT_EXIT].name)) {
+       else if (!strcmp(signal_name, g_events[AUDIO_EVENT_EMERGENT_EXIT].name))
                (cb_data->user_cb)(AUDIO_EVENT_EMERGENT_EXIT, params, cb_data->user_data);
-       }
+       else if (!strcmp(signal_name, g_events[AUDIO_EVENT_DEVICE_RUNNING_CHANGED].name))
+               (cb_data->user_cb)(AUDIO_EVENT_DEVICE_RUNNING_CHANGED, params, cb_data->user_data);
 }
 
 static void callback_data_free_func(gpointer data)
@@ -504,27 +511,35 @@ int mm_sound_dbus_emit_signal(audio_provider_t provider, audio_event_t event, GV
        gboolean dbus_ret;
 
        if (event >= AUDIO_EVENT_MAX) {
+#ifndef TIZEN_TV
                debug_error("emit signal failed, invalid argument, event_type(%d)", event);
+#endif
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
        if (!(conn = _dbus_get_connection(G_BUS_TYPE_SYSTEM))) {
+#ifndef TIZEN_TV
                debug_error("Get Dbus Connection Error");
+#endif
                return MM_ERROR_SOUND_INTERNAL;
        }
 
-       dbus_ret = g_dbus_connection_emit_signal (conn,
+       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 || err) {
-               debug_error ("g_dbus_connection_emit_signal() error (%s)", err ? err->message : NULL);
+#ifndef TIZEN_TV
+               debug_error("g_dbus_connection_emit_signal() error (%s)", err ? err->message : NULL);
+#endif
                g_error_free(err);
                return MM_ERROR_SOUND_INTERNAL;
        }
        g_dbus_connection_flush_sync(conn, NULL, NULL);
 
+#ifndef TIZEN_TV
        debug_msg("emit signal for [%s] success", g_events[event].name);
+#endif
        return MM_ERROR_NONE;
 }