This email list is read-only. Emails sent to this list will be discarded
----------------------------------
doc/connection-api.txt | 1 -
doc/device-api.txt | 17 ++++++++-
doc/manager-api.txt | 1 -
doc/network-api.txt | 22 +++++++++--
doc/service-api.txt | 1 -
plugins/wifi.c | 14 ++++----
src/element.c | 91 ++++++++++++++++++++++++++++++++++++++++++++----
test/Makefile.am | 5 ++-
test/create-network | 26 ++++++++++++++
test/start-scanning | 4 +-
10 files changed, 156 insertions(+), 26 deletions(-)
New commits:
commit 03556de2e4798fd592f6f35c8845eb72c9ead693
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Tue Dec 9 18:45:52 2008 +0100
Add test script for network creation
commit 4b9a69f1d6b579679be9a8190f60eb28fceaf547
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Tue Dec 9 18:44:30 2008 +0100
Add first draft of implemention for CreateNetwork
commit 518c863bcaab4bd138d655dbb280fbd9153cda49
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Tue Dec 9 18:22:47 2008 +0100
Use ProposeScan method
commit 45d2f588889b385b8a7a209e3e6fe2559cd5b950
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Tue Dec 9 18:22:04 2008 +0100
Add skeleton for manual network creation API
commit b7f59753507e5ee0076a5cf4687d06b3da2ca0d3
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Tue Dec 9 18:20:04 2008 +0100
Use generic Name property instead of WiFi.Name
commit 1cfc371f117c273f8b633dd9e5b74dd95be7ecf1
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Tue Dec 9 18:16:11 2008 +0100
Document generic Name, Available and Remember properties
commit 2ace7fcefb7b636cea2d91e7c4c102b4b7037373
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Tue Dec 9 18:10:15 2008 +0100
Remove invalid error messages
commit 88bebe2a27bfcc790b5ca2d6bf8a395c0efbb4ad
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Tue Dec 9 18:08:37 2008 +0100
Document CreateNetwork and RemoveNetwork methods
Diff in this email is a maximum of 400 lines.
diff --git a/doc/connection-api.txt b/doc/connection-api.txt
index f0fba37..7f3d940 100644
--- a/doc/connection-api.txt
+++ b/doc/connection-api.txt
@@ -11,7 +11,6 @@ Methods dict GetProperties()
the properties section for available properties.
Possible Errors: [service].Error.InvalidArguments
- [service].Error.DoesNotExist
Signals PropertyChanged(string name, variant value)
diff --git a/doc/device-api.txt b/doc/device-api.txt
index d50a6c5..847b6f4 100644
--- a/doc/device-api.txt
+++ b/doc/device-api.txt
@@ -11,7 +11,6 @@ Methods dict GetProperties()
the properties section for available properties.
Possible Errors: [service].Error.InvalidArguments
- [service].Error.DoesNotExist
void SetProperty(string name, variant value)
@@ -23,6 +22,22 @@ Methods dict GetProperties()
Possible Errors: [service].Error.InvalidArguments
[service].Error.DoesNotExist
+ object CreateNetwork(dict network)
+
+ Creates a network object from the specified
+ properties. Valid properties are WiFi.SSID,
+ WiFi.Security and WiFi.Passphrase. Check the
+ network interface description for details.
+
+ Possible Errors: [service].Error.InvalidArguments
+
+ void RemoveNetwork(object network)
+
+ Removes a previously created network object.
+
+ Possible Errors: [service].Error.InvalidArguments
+ [service].Error.DoesNotExist
+
Signals PropertyChanged(string name, variant value)
This signal indicates a changed value of the given
diff --git a/doc/manager-api.txt b/doc/manager-api.txt
index 8ef4359..9365e66 100644
--- a/doc/manager-api.txt
+++ b/doc/manager-api.txt
@@ -11,7 +11,6 @@ Methods dict GetProperties()
properties section for available properties.
Possible Errors: [service].Error.InvalidArguments
- [service].Error.DoesNotExist
void SetProperty(string name, variant value)
diff --git a/doc/network-api.txt b/doc/network-api.txt
index eb7b40c..9bcdf12 100644
--- a/doc/network-api.txt
+++ b/doc/network-api.txt
@@ -11,7 +11,6 @@ Methods dict GetProperties()
the properties section for available properties.
Possible Errors: [service].Error.InvalidArguments
- [service].Error.DoesNotExist
void SetProperty(string name, variant value)
@@ -28,10 +27,25 @@ Signals PropertyChanged(string name, variant
value)
This signal indicates a changed value of the given
property.
-Properties string WiFi.Name [readonly]
+Properties string Name [readonly]
- If the network type is WiFi, then this property is
- present and contains the network name.
+ The pretty/long version of the network name. For
+ example in case of WiFi this should be the UTF-8
+ valid version of the SSID.
+
+ boolean Available [readonly]
+
+ Indicates that this network is in range and
+ ready to be used.
+
+ The scanning process can change this property.
+
+ boolean Remember [readwrite]
+
+ Indicates that this network will be remembered.
+
+ For manually created networks this is set by
+ default.
array{byte} WiFi.SSID [readonly]
diff --git a/doc/service-api.txt b/doc/service-api.txt
index 0e5b13e..ec29c95 100644
--- a/doc/service-api.txt
+++ b/doc/service-api.txt
@@ -11,7 +11,6 @@ Methods dict GetProperties()
the properties section for available properties.
Possible Errors: [service].Error.InvalidArguments
- [service].Error.DoesNotExist
Signals PropertyChanged(string name, variant value)
diff --git a/plugins/wifi.c b/plugins/wifi.c
index 5462bf2..39f288d 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -61,14 +61,14 @@ static void network_remove(struct connman_element *element)
static int network_enable(struct connman_element *element)
{
- char *identifier, *security = NULL, *passphrase = NULL;
+ char *name, *security = NULL, *passphrase = NULL;
unsigned char *ssid;
int ssid_len;
DBG("element %p name %s", element, element->name);
if (connman_element_get_static_property(element,
- "WiFi.Name", &identifier) == FALSE)
+ "Name", &name) == FALSE)
return -EIO;
if (connman_element_get_static_array_property(element,
@@ -83,7 +83,7 @@ static int network_enable(struct connman_element *element)
if (data != NULL) {
g_free(data->identifier);
- data->identifier = g_strdup(identifier);
+ data->identifier = g_strdup(name);
}
}
@@ -93,8 +93,8 @@ static int network_enable(struct connman_element *element)
connman_element_get_value(element,
CONNMAN_PROPERTY_ID_WIFI_PASSPHRASE, &passphrase);
- DBG("identifier %s security %s passhprase %s",
- identifier, security, passphrase);
+ DBG("name %s security %s passhprase %s",
+ name, security, passphrase);
if (__supplicant_connect(element, ssid, ssid_len,
security, passphrase) < 0)
@@ -133,7 +133,7 @@ static struct connman_element *find_element(struct
wifi_data *data,
struct connman_element *element = list->data;
if (connman_element_match_static_property(element,
- "WiFi.Name", &identifier) == TRUE)
+ "Name", &identifier) == TRUE)
return element;
}
@@ -216,7 +216,7 @@ static void scan_result(struct connman_element *parent,
data->list = g_slist_append(data->list, element);
- connman_element_add_static_property(element, "WiFi.Name",
+ connman_element_add_static_property(element, "Name",
DBUS_TYPE_STRING, &network->identifier);
connman_element_add_static_array_property(element, "WiFi.SSID",
diff --git a/src/element.c b/src/element.c
index 9dd3039..6ad75b1 100644
--- a/src/element.c
+++ b/src/element.c
@@ -395,7 +395,7 @@ static void append_networks(struct connman_element *element,
dbus_message_iter_close_container(dict, &entry);
}
-static DBusMessage *get_device_properties(DBusConnection *conn,
+static DBusMessage *device_get_properties(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct connman_element *element = data;
@@ -438,12 +438,11 @@ static DBusMessage *get_device_properties(DBusConnection
*conn,
return reply;
}
-static DBusMessage *set_device_property(DBusConnection *conn,
+static DBusMessage *device_set_property(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct connman_element *element = data;
- DBusMessageIter iter;
- DBusMessageIter value;
+ DBusMessageIter iter, value;
const char *name;
DBG("conn %p", conn);
@@ -475,6 +474,82 @@ static DBusMessage *set_device_property(DBusConnection
*conn,
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
+static int parse_network_dict(DBusMessageIter *iter, const char **ssid,
+ const char **security, const char **passphrase)
+{
+ while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter entry, value;
+ const char *key;
+
+ dbus_message_iter_recurse(iter, &entry);
+ dbus_message_iter_get_basic(&entry, &key);
+
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &value);
+
+ switch (dbus_message_iter_get_arg_type(&value)) {
+ case DBUS_TYPE_STRING:
+ if (g_str_equal(key, "WiFi.SSID") == TRUE)
+ dbus_message_iter_get_basic(&value, ssid);
+ else if (g_str_equal(key, "WiFi.Security") == TRUE)
+ dbus_message_iter_get_basic(&value, security);
+ else if (g_str_equal(key, "WiFi.Passphrase") == TRUE)
+ dbus_message_iter_get_basic(&value, passphrase);
+ break;
+ }
+
+ dbus_message_iter_next(iter);
+ }
+
+ return 0;
+}
+
+static DBusMessage *device_create_network(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct connman_element *element = data;
+ struct connman_element *network;
+ DBusMessageIter iter, array;
+ const char *ssid = NULL, *security = NULL, *passphrase = NULL;
+
+ DBG("conn %p", conn);
+
+ if (dbus_message_iter_init(msg, &iter) == FALSE)
+ return __connman_error_invalid_arguments(msg);
+
+ dbus_message_iter_recurse(&iter, &array);
+ parse_network_dict(&array, &ssid, &security, &passphrase);
+ if (ssid == NULL)
+ return __connman_error_invalid_arguments(msg);
+
+ DBG("ssid %s security %s passphrase %s", ssid, security, passphrase);
+
+ network = connman_element_create(ssid);
+
+ network->type = CONNMAN_ELEMENT_TYPE_NETWORK;
+ network->index = element->index;
+
+ connman_element_add_static_property(network, "Name",
+ DBUS_TYPE_STRING, &ssid);
+
+ connman_element_add_static_array_property(element, "WiFi.SSID",
+ DBUS_TYPE_BYTE, &ssid, strlen(ssid));
+
+ network->wifi.security = g_strdup(security);
+ network->wifi.passphrase = g_strdup(passphrase);
+
+ connman_element_register(network, element);
+
+ return g_dbus_create_reply(msg, DBUS_TYPE_OBJECT_PATH, &network->path,
+ DBUS_TYPE_INVALID);
+}
+
+static DBusMessage *device_remove_network(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+}
+
static DBusMessage *get_network_properties(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -704,9 +779,11 @@ static GDBusSignalTable element_signals[] = {
};
static GDBusMethodTable device_methods[] = {
- { "GetProperties", "", "a{sv}", get_device_properties },
- { "SetProperty", "sv", "", set_device_property },
- { "Scan", "", "", do_update },
+ { "GetProperties", "", "a{sv}", device_get_properties },
+ { "SetProperty", "sv", "", device_set_property },
+ { "CreateNetwork", "a{sv}", "o", device_create_network },
+ { "RemoveNetwork", "o", "", device_remove_network },
+ { "ProposeScan", "", "", do_update },
{ },
};
diff --git a/test/Makefile.am b/test/Makefile.am
index 9bf9ecf..1e38eff 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,7 +1,8 @@
EXTRA_DIST = get-state list-profiles list-connections \
list-devices enable-device disable-device start-scanning \
- list-networks select-network disable-network set-passphrase \
- simple-agent show-introspection test-manager test-compat
+ list-networks select-network disable-network create-network \
+ set-passphrase simple-agent show-introspection \
+ test-manager test-compat
MAINTAINERCLEANFILES = Makefile.in
diff --git a/test/create-network b/test/create-network
new file mode 100755
index 0000000..32c8ab3
--- /dev/null
+++ b/test/create-network
@@ -0,0 +1,26 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+if (len(sys.argv) < 2):
+ print "Usage: %s <network>" % (sys.argv[0])
+ sys.exit(1)
+
+bus = dbus.SystemBus()
+
+manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"),
+ "org.moblin.connman.Manager")
+
+properties = manager.GetProperties()
+
+for path in properties["Devices"]:
+ device = dbus.Interface(bus.get_object("org.moblin.connman", path),
+ "org.moblin.connman.Device")
+
+ properties = device.GetProperties()
+
+ if (properties["Type"] != "wifi" and properties["Type"] != "wimax"):
+ continue;
+
+ path = device.CreateNetwork({ "WiFi.SSID": sys.argv[1] });
diff --git a/test/start-scanning b/test/start-scanning
index 9d3f4db..aaa3e58 100755
--- a/test/start-scanning
+++ b/test/start-scanning
@@ -19,10 +19,10 @@ for path in properties["Devices"]:
if (properties["Type"] == "wifi"):
print " Started WiFi scanning"
- device.Scan()
+ device.ProposeScan()
elif (properties["Type"] == "wimax"):
print " Started WiMAX scanning"
- device.Scan()
+ device.ProposeScan()
else:
print " No scanning"
_______________________________________________
Commits mailing list
[email protected]
https://lists.moblin.org/mailman/listinfo/commits