Adds checking dbus error messages 13/230113/2
authorJaechul Lee <jcsing.lee@samsung.com>
Wed, 8 Apr 2020 05:02:14 +0000 (14:02 +0900)
committerJaechul Lee <jcsing.lee@samsung.com>
Wed, 8 Apr 2020 05:46:10 +0000 (14:46 +0900)
It can't check error messages properly because dbus error message has a
space before org.tizen.bla. Besides, the messages are little difference
between sound-server and pulseaudio.

e.g)
a error message from sound-server(g_dbus api)
GDBus.Error:org.tizen.multimedia.audio.Internal: failed

a error message from pulseaudio(dbus api)
GDBus.Error:org.freedesktop.DBus.Error.Failed: org.tizen.multimedia.audio.Internal

[Version] 0.12.70
[Issue Type] Bug

Change-Id: I1f0ba391dd3645cac3a6bd7006ed8ca51b9c4a28
Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
common/mm_sound_dbus.c
packaging/libmm-sound.spec

index 66f600f..010b9e8 100644 (file)
@@ -169,37 +169,15 @@ static const GDBusErrorEntry mm_sound_error_entries[] = {
                Wrapper Functions of GDbus
 ******************************************************************************************/
 
-static int _parse_error_msg(char *full_err_msg, char **err_name, char **err_msg)
+static int _convert_error_name(const char *err_msg)
 {
-       char *save_p = NULL, *domain, *_err_name, *_err_msg;
+       int i;
 
-       if (!(domain = strtok_r(full_err_msg, ":", &save_p))) {
-               debug_error("get domain failed");
-               return -1;
-       }
-       if (!(_err_name = strtok_r(NULL, ":", &save_p))) {
-               debug_error("get err name failed");
-               return -1;
-       }
-       if (!(_err_msg = strtok_r(NULL, ":", &save_p))) {
-               debug_error("get err msg failed");
-               return -1;
-       }
-
-       *err_name = _err_name;
-       *err_msg = _err_msg;
-
-       return 0;
-}
-
-static int _convert_error_name(const char *err_name)
-{
-       int i = 0;
-
-       debug_error("error name is [%s]", err_name);
+       if (!err_msg)
+               return MM_ERROR_SOUND_INTERNAL;
 
        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 (strstr(err_msg, mm_sound_error_entries[i].dbus_error_name))
                        return mm_sound_error_entries[i].error_code;
        }
 
@@ -234,17 +212,11 @@ static int _dbus_method_call(GDBusConnection *conn, const char *bus_name, const
                                                                                        NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
 
        if (!dbus_reply || err) {
-               char *err_name = NULL, *err_msg = NULL;
                debug_error("Method Call '%s.%s' Failed, %s", intf, method, err ? err->message : NULL);
                ret = MM_ERROR_SOUND_INTERNAL;
-               if (err) {
-                       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;
-                       }
-                       ret = _convert_error_name(err_name);
-               }
+               if (err)
+                       ret = _convert_error_name(err->message);
+
                g_error_free(err);
        } else {
                debug_log("Method Call '%s.%s' Success", intf, method);
index 6acef70..48a5086 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-sound
 Summary:    MMSound Package contains client lib and sound_server binary
-Version:    0.12.69
+Version:    0.12.70
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0