From: Marcel Holtmann Date: Thu, 3 Jan 2008 08:11:41 +0000 (+0100) Subject: Add callbacks for setting network name and passphrase X-Git-Tag: 2.0_alpha~4963 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8af2802c979ac2d63df1885c247a1cb387cab3bd;p=framework%2Fconnectivity%2Fconnman.git Add callbacks for setting network name and passphrase --- 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 }, { }, };