match_rule_to_string: don't reinvent dbus_message_type_to_string
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 31 Jan 2011 15:55:53 +0000 (15:55 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Fri, 24 Jun 2011 15:00:13 +0000 (16:00 +0100)
We don't allow match rules with unknown message types, so losing the
"type='%d'" case isn't a great loss.

Reviewed-by: Cosimo Alfarano <cosimo.alfarano@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34040

bus/signals.c

index 4d34ca1..62881b5 100644 (file)
@@ -138,36 +138,9 @@ match_rule_to_string (BusMatchRule *rule)
   
   if (rule->flags & BUS_MATCH_MESSAGE_TYPE)
     {
-      if (rule->message_type == DBUS_MESSAGE_TYPE_INVALID)
-        {
-          if (!_dbus_string_append_printf (&str, "type='INVALID'"))
-            goto nomem;
-        }
-      else if (rule->message_type == DBUS_MESSAGE_TYPE_METHOD_CALL)
-        {
-          if (!_dbus_string_append_printf (&str, "type='method_call'"))
-            goto nomem;
-        }
-      else if (rule->message_type == DBUS_MESSAGE_TYPE_METHOD_RETURN)
-        {
-          if (!_dbus_string_append_printf (&str, "type='method_return'"))
-            goto nomem;
-        }
-      else if (rule->message_type == DBUS_MESSAGE_TYPE_ERROR)
-        {
-          if (!_dbus_string_append_printf (&str, "type='error'"))
-            goto nomem;
-        }
-      else if (rule->message_type == DBUS_MESSAGE_TYPE_SIGNAL)
-        {
-          if (!_dbus_string_append_printf (&str, "type='signal'"))
-            goto nomem;
-        }
-      else
-        {
-          if (!_dbus_string_append_printf (&str, "type='%d'", rule->message_type))
-            goto nomem;
-        }
+      if (!_dbus_string_append_printf (&str, "type='%s'",
+            dbus_message_type_to_string (rule->message_type)))
+        goto nomem;
     }
 
   if (rule->flags & BUS_MATCH_INTERFACE)