From 8af2802c979ac2d63df1885c247a1cb387cab3bd Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Thu, 3 Jan 2008 09:11:41 +0100 Subject: [PATCH] Add callbacks for setting network name and passphrase --- include/iface.h | 5 +++++ src/iface.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/include/iface.h b/include/iface.h index d6b6793..cc79a4d 100644 --- a/include/iface.h +++ b/include/iface.h @@ -92,6 +92,11 @@ struct connman_iface_driver { int (*connect) (struct connman_iface *iface, struct connman_network *network); + void (*set_network) (struct connman_iface *iface, + const char *network); + void (*set_passphrase) (struct connman_iface *iface, + const char *passphrase); + void (*rtnl_carrier) (struct connman_iface *iface, int carrier); void (*rtnl_wireless) (struct connman_iface *iface, void *data, unsigned short len); diff --git a/src/iface.c b/src/iface.c index 53031f6..82fbdda 100644 --- a/src/iface.c +++ b/src/iface.c @@ -328,9 +328,61 @@ static DBusMessage *scan_iface(DBusConnection *conn, return reply; } +static DBusMessage *set_network(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + struct connman_iface *iface = data; + struct connman_iface_driver *driver = iface->driver; + DBusMessage *reply; + const char *network; + + DBG("conn %p", conn); + + dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &network, + DBUS_TYPE_INVALID); + + reply = dbus_message_new_method_return(msg); + if (reply == NULL) + return NULL; + + if (driver->set_network) + driver->set_network(iface, network); + + dbus_message_append_args(reply, DBUS_TYPE_INVALID); + + return reply; +} + +static DBusMessage *set_passphrase(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + struct connman_iface *iface = data; + struct connman_iface_driver *driver = iface->driver; + DBusMessage *reply; + const char *passphrase; + + DBG("conn %p", conn); + + dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &passphrase, + DBUS_TYPE_INVALID); + + reply = dbus_message_new_method_return(msg); + if (reply == NULL) + return NULL; + + if (driver->set_passphrase) + driver->set_passphrase(iface, passphrase); + + dbus_message_append_args(reply, DBUS_TYPE_INVALID); + + return reply; +} + static GDBusMethodTable iface_methods[] = { - { "Enable", "", "", enable_iface }, - { "Scan", "", "", scan_iface }, + { "Enable", "", "", enable_iface }, + { "Scan", "", "", scan_iface }, + { "SetNetwork", "s", "", set_network }, + { "SetPassphrase", "s", "", set_passphrase }, { }, }; -- 2.7.4