Add callbacks for setting network name and passphrase
authorMarcel Holtmann <marcel@holtmann.org>
Thu, 3 Jan 2008 08:11:41 +0000 (09:11 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 3 Jan 2008 08:11:41 +0000 (09:11 +0100)
include/iface.h
src/iface.c

index d6b6793..cc79a4d 100644 (file)
@@ -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);
index 53031f6..82fbdda 100644 (file)
@@ -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 },
        { },
 };