From: "Libor Zoubek" <lzoubek@jezzovo.net>
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 26 Jul 2011 07:49:50 +0000 (07:49 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 26 Jul 2011 07:49:50 +0000 (07:49 +0000)
Subject: Re: [E-devel] [patch] e_dbus notification

I've reported a bug http://trac.enlightenment.org/e/ticket/775
Please review/apply attached patch that fixes above bug.

I am using libnotify 0.7.2. e_module-notification does not react on
anyhing like

notify-send -u critical "hello" "hello"

This prevents working notification when using for example xchat-2.8.8.
I was watching dbus-monitor and found out, that e_dbus does not return
proper values when getServerInformation is called. By  this spec
(v1.2) getServerInformation should return 4 string values, not 3 as it
was in  v0.9

Please apply attached patch which fixes this bug

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/e_dbus@61731 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/notification/E_Notification_Daemon.h
src/lib/notification/E_Notify.h
src/lib/notification/daemon.c
src/lib/notification/e_notify_private.h
src/lib/notification/marshal.c

index 9285373..fc530ba 100644 (file)
@@ -2,7 +2,7 @@
 #define E_NOTIFICATION_DAEMON_H
 
 #define E_NOTIFICATION_DAEMON_VERSION "0.9"
-
+#define E_NOTIFICATION_DAEMON_SUPPORTS_SPEC_VERSION "1.2"
 #include <E_Notify.h>
 
 #ifdef EAPI
index 9acaa15..157d83d 100644 (file)
@@ -76,6 +76,7 @@ struct E_Notification_Return_Get_Server_Information
   const char *name;
   const char *vendor;
   const char *version;
+  const char *spec_version;
 };
 
 /* signals */
index 2e4127b..cf389bb 100644 (file)
@@ -68,7 +68,7 @@ method_get_server_information(E_DBus_Object *obj, DBusMessage *message)
 
   daemon = e_dbus_object_data_get(obj);
 
-  return e_notify_marshal_get_server_information_return(message, daemon->name, daemon->vendor, E_NOTIFICATION_DAEMON_VERSION);
+  return e_notify_marshal_get_server_information_return(message, daemon->name, daemon->vendor, E_NOTIFICATION_DAEMON_VERSION, E_NOTIFICATION_DAEMON_SUPPORTS_SPEC_VERSION);
 }
 
 
@@ -126,7 +126,7 @@ e_notification_daemon_add(const char *name, const char *vendor)
   e_dbus_interface_method_add(daemon->iface, "GetCapabilities", "", "as", method_get_capabilities);
   e_dbus_interface_method_add(daemon->iface, "Notify", "susssasa{sv}i", "u", method_notify);
   e_dbus_interface_method_add(daemon->iface, "CloseNotification", "u", "u", method_close_notification);
-  e_dbus_interface_method_add(daemon->iface, "GetServerInformation", "", "sss", method_get_server_information);
+  e_dbus_interface_method_add(daemon->iface, "GetServerInformation", "", "ssss", method_get_server_information);
 
   return daemon;
 }
index 250f6d5..6879a2d 100644 (file)
@@ -23,7 +23,7 @@ DBusMessage * e_notify_marshal_get_capabilities_return(DBusMessage *method_call,
 void * e_notify_unmarshal_get_capabilities_return(DBusMessage *msg, DBusError *err);
 void   e_notify_free_get_capabilities_return(void *data);
 DBusMessage * e_notify_marshal_get_server_information();
-DBusMessage * e_notify_marshal_get_server_information_return(DBusMessage *method_call, const char *name, const char *vendor, const char *version);
+DBusMessage * e_notify_marshal_get_server_information_return(DBusMessage *method_call, const char *name, const char *vendor, const char *version, const char *spec_version);
 void * e_notify_unmarshal_get_server_information_return(DBusMessage *msg, DBusError *err);
 void   e_notify_free_get_server_information_return(void *data);
 DBusMessage * e_notify_marshal_close_notification(dbus_uint32_t id);
index 91b9389..fc009fa 100644 (file)
@@ -178,11 +178,11 @@ e_notify_marshal_get_server_information()
 }
 
 DBusMessage *
-e_notify_marshal_get_server_information_return(DBusMessage *method_call, const char *name, const char *vendor, const char *version)
+e_notify_marshal_get_server_information_return(DBusMessage *method_call, const char *name, const char *vendor, const char *version, const char *spec_version)
 {
   DBusMessage *msg;
   msg = dbus_message_new_method_return(method_call);
-  dbus_message_append_args(msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &vendor, DBUS_TYPE_STRING, &version, DBUS_TYPE_INVALID);
+  dbus_message_append_args(msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &vendor, DBUS_TYPE_STRING, &version, DBUS_TYPE_STRING, &spec_version, DBUS_TYPE_INVALID);
   return msg;
 }
 
@@ -190,21 +190,37 @@ void *
 e_notify_unmarshal_get_server_information_return(DBusMessage *msg, DBusError *err)
 {
   E_Notification_Return_Get_Server_Information *info;
-  if (!dbus_message_has_signature(msg, "sss")) return NULL;
-
-  info = calloc(1, sizeof(E_Notification_Return_Get_Server_Information));
-  dbus_message_get_args(msg, err,
-    DBUS_TYPE_STRING, &(info->name),
-    DBUS_TYPE_STRING, &(info->vendor),
-    DBUS_TYPE_STRING, &(info->version),
-    DBUS_TYPE_INVALID
-  );
+  if (dbus_message_has_signature(msg, "ssss"))
+  {
+    info = calloc(1, sizeof(E_Notification_Return_Get_Server_Information));
+    dbus_message_get_args(msg, err,
+      DBUS_TYPE_STRING, &(info->name),
+      DBUS_TYPE_STRING, &(info->vendor),
+      DBUS_TYPE_STRING, &(info->version),
+      DBUS_TYPE_STRING, &(info->spec_version),
+      DBUS_TYPE_INVALID
+    );
+  } 
+  else if (dbus_message_has_signature(msg,"sss")) 
+  {
+    // stay combatible with servers <= 0.9 spec
+    info = calloc(1, sizeof(E_Notification_Return_Get_Server_Information));
+    dbus_message_get_args(msg, err,
+      DBUS_TYPE_STRING, &(info->name),
+      DBUS_TYPE_STRING, &(info->vendor),
+      DBUS_TYPE_STRING, &(info->version),
+      DBUS_TYPE_INVALID
+    );
+  }
+  else 
+  {
+    return NULL;
+  }
   if (dbus_error_is_set(err))
   {
     free(info);
     return NULL;
   }
-
   return info;
 }