int __connman_iface_init(DBusConnection *conn);
void __connman_iface_cleanup(void);
+void __connman_iface_list(DBusMessageIter *iter);
+
#include <connman/rtnl.h>
int __connman_rtnl_init(void);
static GSList *interfaces = NULL;
+void __connman_iface_list(DBusMessageIter *iter)
+{
+ GSList *list;
+
+ DBG("");
+
+ for (list = interfaces; list; list = list->next) {
+ struct connman_iface *iface = list->data;
+
+ dbus_message_iter_append_basic(iter,
+ DBUS_TYPE_OBJECT_PATH, &iface->path);
+ }
+}
+
int connman_iface_update(struct connman_iface *iface,
- enum connman_iface_state state)
+ enum connman_iface_state state)
{
switch (state) {
case CONNMAN_IFACE_STATE_ACTIVE:
DBG("address %s", inet_ntoa(iface->ipv4.address));
}
+ g_dbus_emit_signal(conn, CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE,
+ "InterfaceAdded",
+ DBUS_TYPE_OBJECT_PATH, &iface->path,
+ DBUS_TYPE_INVALID);
+
if (driver->activate)
driver->activate(iface);
struct connman_iface *iface = list->data;
if (strcmp(udi, iface->udi) == 0) {
+ g_dbus_emit_signal(conn, CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE,
+ "InterfaceRemoved",
+ DBUS_TYPE_OBJECT_PATH, &iface->path,
+ DBUS_TYPE_INVALID);
interfaces = g_slist_remove(interfaces, iface);
g_dbus_unregister_object(conn, iface->path);
break;
DBG("path %s", iface->path);
+ g_dbus_emit_signal(conn, CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE,
+ "InterfaceRemoved",
+ DBUS_TYPE_OBJECT_PATH, &iface->path,
+ DBUS_TYPE_INVALID);
+
g_dbus_unregister_object(conn, iface->path);
}
#include "connman.h"
+static DBusMessage *list_interfaces(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBusMessage *reply;
+ DBusMessageIter array, iter;
+
+ DBG("conn %p", conn);
+
+ reply = dbus_message_new_method_return(msg);
+ if (reply == NULL)
+ return NULL;
+
+ dbus_message_iter_init_append(reply, &array);
+
+ dbus_message_iter_open_container(&array, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter);
+
+ __connman_iface_list(&iter);
+
+ dbus_message_iter_close_container(&array, &iter);
+
+ return reply;
+}
+
+static GDBusMethodTable manager_methods[] = {
+ { "ListInterfaces", "", "ao", list_interfaces },
+ { },
+};
+
+static GDBusSignalTable manager_signals[] = {
+ { "InterfaceAdded", "o" },
+ { "InterfaceRemoved", "o" },
+ { },
+};
+
static DBusConnection *connection = NULL;
int __connman_manager_init(DBusConnection *conn)
g_dbus_register_object(connection, CONNMAN_MANAGER_PATH, NULL, NULL);
+ g_dbus_register_interface(connection, CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE,
+ manager_methods,
+ manager_signals, NULL);
+
return 0;
}
{
DBG("conn %p", connection);
+ g_dbus_unregister_interface(connection, CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE);
+
g_dbus_unregister_object(connection, CONNMAN_MANAGER_PATH);
dbus_connection_unref(connection);