diff options
-rw-r--r-- | src/plugins/wireless/plugin.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/plugins/wireless/plugin.c b/src/plugins/wireless/plugin.c index 2dac3c4..5549060 100644 --- a/src/plugins/wireless/plugin.c +++ b/src/plugins/wireless/plugin.c @@ -20,6 +20,7 @@ static DBusHandlerResult wpa_supplicant_request(DBusConnection *connection, DBus typedef struct { struct wpa_ctrl *ctrl_conn; + const char *interface; } w_plugin_t; static int init(plugin_t *plugin, DBusConnection *connection) { @@ -50,7 +51,7 @@ static int init(plugin_t *plugin, DBusConnection *connection) { return -1; snprintf(cfile, flen, "%s/%s", ctrl_iface_dir, dent->d_name); w_plugin->ctrl_conn = wpa_ctrl_open(cfile); - w_plugin->ctrl_conn = wpa_ctrl_open(cfile); + w_plugin->interface = strdup(dent->d_name); free(cfile); break; } @@ -73,7 +74,8 @@ static void deinit(plugin_t *plugin, DBusConnection *connection) { close(plugin->fd); } -static void notify_event(DBusConnection *bus, char *event) { +static void notify_event(DBusConnection *bus, plugin_t *plugin, char *event) { + w_plugin_t *w_plugin = (w_plugin_t *) plugin->priv; DBusMessage *message; message = dbus_message_new_signal(WIRELESS_PATH, WIRELESS_INTERFACE, @@ -82,6 +84,8 @@ static void notify_event(DBusConnection *bus, char *event) { dbus_message_append_args(message, DBUS_TYPE_STRING, &event, + DBUS_TYPE_STRING, + &w_plugin->interface, DBUS_TYPE_INVALID); dbus_connection_send(bus, message, NULL); dbus_connection_flush(bus); @@ -94,8 +98,8 @@ static void handle_incoming(plugin_t *plugin, DBusConnection *connection) { size_t len = sizeof(buf); wpa_ctrl_recv(w_plugin->ctrl_conn, buf, &len); buf[len] = '\0'; - printf("received event: %s\n", buf); - notify_event(connection, buf); + printf("received event for %s: %s\n", w_plugin->interface, buf); + notify_event(connection, plugin, buf); } static DBusHandlerResult handle_message(DBusConnection *connection, DBusMessage *message, plugin_t *plugin) { |