chiark / gitweb /
terminal: forward DEVICE_CHANGE events via sysview
authorDavid Herrmann <dh.herrmann@gmail.com>
Sat, 20 Sep 2014 07:43:16 +0000 (09:43 +0200)
committerDavid Herrmann <dh.herrmann@gmail.com>
Sat, 20 Sep 2014 09:46:49 +0000 (11:46 +0200)
Whe need to react to "change" events on devices, but we want to avoid
duplicating udev-monitors everywhere. Therefore, make sysview forward
change events to the sysview controllers, which can then properly react
to it.

src/libsystemd-terminal/sysview.c
src/libsystemd-terminal/sysview.h

index 6c1a9543b97d46cb22c047bd4842d45c17e91994..23d564d6a0407417c57ed0d4a0ea329cefd98911 100644 (file)
@@ -517,6 +517,18 @@ static int context_raise_session_detach(sysview_context *c, sysview_session *ses
         return context_raise(c, &event, 0);
 }
 
+static int context_raise_device_change(sysview_context *c, sysview_device *device, struct udev_device *ud) {
+        sysview_event event = {
+                .type = SYSVIEW_EVENT_DEVICE_CHANGE,
+                .device_change = {
+                        .device = device,
+                        .ud = ud,
+                }
+        };
+
+        return context_raise(c, &event, 0);
+}
+
 static int context_add_device(sysview_context *c, sysview_device *device) {
         sysview_session *session;
         int r, error = 0;
@@ -872,7 +884,7 @@ static int context_ud_hotplug(sysview_context *c, struct udev_device *d) {
                 if (!device)
                         return 0;
 
-                /* TODO: send REFRESH event */
+                return context_raise_device_change(c, device, d);
         } else if (!action || streq_ptr(action, "add")) {
                 struct udev_device *p;
                 unsigned int type, t;
index de6ff371db55bbd688b432b955fbdc1e34bf3338..b9452fab896e4338136571deb8f475aa201219ae 100644 (file)
@@ -64,6 +64,8 @@ enum {
         SYSVIEW_EVENT_SESSION_ATTACH,
         SYSVIEW_EVENT_SESSION_DETACH,
         SYSVIEW_EVENT_SESSION_CONTROL,
+
+        SYSVIEW_EVENT_DEVICE_CHANGE,
 };
 
 struct sysview_event {
@@ -94,6 +96,11 @@ struct sysview_event {
                         sysview_session *session;
                         int error;
                 } session_control;
+
+                struct {
+                        sysview_device *device;
+                        struct udev_device *ud;
+                } device_change;
         };
 };