kdbus: bugfix for return codes on call to non-existing destination 71/128371/9
authorAdrian Szyndela <adrian.s@samsung.com>
Tue, 9 May 2017 12:50:14 +0000 (14:50 +0200)
committerAdrian Szyndela <adrian.s@samsung.com>
Thu, 1 Jun 2017 09:35:11 +0000 (11:35 +0200)
Calling a method on non-existing destination with auto start disabled
caused error org.freedesktop.DBus.ServiceUnknown.
Non-kdbus implementation gives org.freedesktop.DBus.NameHasNoOwner.
This patch makes kdbus return the same error as non-kdbus implementation.

Change-Id: I0320adf1205e2db11259e3f544eef27873acf8b0

gio/gkdbus.c

index 5b4a909..6c9c051 100755 (executable)
@@ -3473,8 +3473,12 @@ _g_kdbus_send (GKDBusWorker  *worker,
                   break;
 
                   case DBUSPOLICY_RESULT_DEST_NOT_AVAILABLE:
-                    g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKNOWN,
-                                 "Cannot send message - destination not known");
+                    if (g_dbus_message_get_flags (message) & G_DBUS_MESSAGE_FLAGS_NO_AUTO_START)
+                      g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_NAME_HAS_NO_OWNER,
+                                   "Name \"%s\" does not exist", dst_name);
+                    else
+                      g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKNOWN,
+                                   "Cannot send message - destination '%s' not known", dst_name);
                   break;
 
                   case DBUSPOLICY_RESULT_KDBUS_ERROR:
@@ -3518,8 +3522,12 @@ _g_kdbus_send (GKDBusWorker  *worker,
       errno = ret;
       if (errno == ENXIO || errno == ESRCH)
         {
-          g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKNOWN,
-                       "Destination '%s' not known, %s", dst_name, info);
+          if (g_dbus_message_get_flags (message) & G_DBUS_MESSAGE_FLAGS_NO_AUTO_START)
+            g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_NAME_HAS_NO_OWNER,
+                         "Name \"%s\" does not exist, %s", dst_name, info);
+          else
+            g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKNOWN,
+                         "Destination '%s' not known, %s", dst_name, info);
         }
       else if (errno == EADDRNOTAVAIL)
         {