wip
authorŁukasz Stelmach <l.stelmach@samsung.com>
Tue, 4 Apr 2017 14:11:39 +0000 (16:11 +0200)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Tue, 4 Apr 2017 14:11:39 +0000 (16:11 +0200)
src/faultd.c

index 0a3e0ebf81aa87f21dcae8b0c3583c1d929dd7ca..e6c3acbc8ef97727afa73b9c9535648332e6f172 100644 (file)
@@ -67,11 +67,33 @@ int main(int ac, char* av[])
       break;
     }
 
-    if (m != NULL) {
-      fprintf(stderr, "Received a message!\n");
-      sd_bus_message_unref(m);
+    if (m == NULL) {
+      fprintf(stderr, "No message.\n");
+    } else {
+      uint8_t type;
+      int _rc;
+      _rc = sd_bus_message_get_type(m, &type);
+      if (_rc < 0) {
+       fprintf(stderr, "Oops!\n");
+       break;
+      }
+      fprintf(stdout, "Received a message!\n");
+      fprintf(stdout, "    Type: %s\n",
+             type ==  SD_BUS_MESSAGE_METHOD_CALL ? "method call" :
+             (type ==  SD_BUS_MESSAGE_METHOD_RETURN ? "method return" :
+             (type ==  SD_BUS_MESSAGE_METHOD_ERROR ? "method error" :
+             (type ==  SD_BUS_MESSAGE_SIGNAL ? "signal" : "INVALID"))));
+      fprintf(stdout, "    Interface: %s\n", sd_bus_message_get_interface(m));
+      fprintf(stdout, "    Member:    %s\n", sd_bus_message_get_member(m));
+      fprintf(stdout, "    Path:      %s\n", sd_bus_message_get_path(m));
+      if (type == SD_BUS_MESSAGE_SIGNAL &&
+         strcmp("org.freedesktop.DBus.Properties", sd_bus_message_get_interface(m)) &&
+         strcmp("PropertiesChanged", sd_bus_message_get_member(m)) &&
+         strncmp("/org/freedesktop/systemd1/unit/", sd_bus_message_get_path(m), 31))
+       printf("foo\n");
     }
 
+    sd_bus_message_unref(m);
     if (rc > 0)
       continue;