This email list is read-only.  Emails sent to this list will be discarded
----------------------------------
 doc/connman-docs.xml |    3 +-
 doc/device-api.txt   |    7 +
 include/Makefile.am  |    5 +-
 include/device.h     |   74 +++--
 include/element.h    |    8 +
 include/network.h    |   34 ++
 plugins/bluetooth.c  |  330 +++++++++++++-------
 plugins/ethernet.c   |   93 +++---
 plugins/rtnllink.c   |   98 +++---
 plugins/supplicant.c |   38 ++-
 plugins/supplicant.h |   13 +-
 plugins/wifi.c       |  164 ++++++-----
 src/connman.h        |    7 +
 src/device.c         |  870 +++++++++++++++++++++++++++++++++++++++++++++++---
 src/element.c        |  386 +++++------------------
 src/error.c          |    6 +
 src/main.c           |    2 +
 src/network.c        |  144 +++++++++
 test/list-networks   |    2 +-
 test/start-scanning  |    7 +-
 20 files changed, 1591 insertions(+), 700 deletions(-)

New commits:
commit 4c1c88e40a46a41510faa3f1544bfc2aaf9d1063
Author: Marcel Holtmann <[email protected]>
Date:   Fri Dec 26 23:25:24 2008 +0100

    Add initial support for Bluetooth networks

commit f1d42616b9c8ad0158678f22256418c9c312b43b
Author: Marcel Holtmann <[email protected]>
Date:   Fri Dec 26 23:18:32 2008 +0100

    Convert WiFi device handling to generic driver

commit 1449d2e54341dd7d174fef91426f539a0b5fd13a
Author: Marcel Holtmann <[email protected]>
Date:   Fri Dec 26 22:54:18 2008 +0100

    Emit signal when list of devices changes

commit 7efb49e571b228f9c4ef55449cf03ab0f7fdf638
Author: Marcel Holtmann <[email protected]>
Date:   Fri Dec 26 22:53:11 2008 +0100

    Unlink node before calling remove callback

commit a5ebd7dd2d6b5d0c2d8d3a87d14d09e2779e8df1
Author: Marcel Holtmann <[email protected]>
Date:   Fri Dec 26 22:52:03 2008 +0100

    Remove device interface handling from element functions

commit d39c4913a08577025f5fe102d2c9d8739b01d9b1
Author: Marcel Holtmann <[email protected]>
Date:   Fri Dec 26 12:45:41 2008 +0100

    Fix networks list of devices

commit 552094eba3795ba2dd398dd30cfa69fae929753d
Author: Marcel Holtmann <[email protected]>
Date:   Fri Dec 26 12:43:26 2008 +0100

    Convert scripts using type lists

commit 219aefaa626b3b0c695d079acef6c08b30bfdd66
Author: Marcel Holtmann <[email protected]>
Date:   Fri Dec 26 12:34:05 2008 +0100

    Fix wrong order of arguments

commit 9b52307fecf2603a21c11e84b6cb70a416cf2901
Author: Marcel Holtmann <[email protected]>
Date:   Fri Dec 26 11:57:32 2008 +0100

    Fix documentation typos

commit 365854ddf4a9b8d717f6c455cd8124c1ee9d670e
Author: Marcel Holtmann <[email protected]>
Date:   Fri Dec 26 07:48:27 2008 +0100

    Add support for handling network details

commit aa2e6dc4b4896e1b3a440736e7c27271a1bbd2d0
Author: Marcel Holtmann <[email protected]>
Date:   Fri Dec 26 07:47:45 2008 +0100

    Add support for identifier and driver data

commit 1440a12d34f626a3041838af3001a894bc2089c8
Author: Marcel Holtmann <[email protected]>
Date:   Thu Dec 25 21:57:52 2008 +0100

    Initialize the element reference count

commit 72736b791ef6d2772da9f4e676659449e7b4decf
Author: Marcel Holtmann <[email protected]>
Date:   Thu Dec 25 21:56:27 2008 +0100

    Add private date pointer for networks

commit 07f1877243d7fb7127a4892478d88dcf9395ed73
Author: Marcel Holtmann <[email protected]>
Date:   Thu Dec 25 21:55:54 2008 +0100

    Add functions for network creation

commit 08898a3702fd821da3239eb93f8a0af02cff5573
Author: Marcel Holtmann <[email protected]>
Date:   Thu Dec 25 19:37:48 2008 +0100

    Add support for different network modes

commit 67e671bdba08cdd555a32551bcd18f34abeac2ae
Author: Marcel Holtmann <[email protected]>
Date:   Thu Dec 25 19:29:48 2008 +0100

    Add basic network definitions

commit 4cd41ba34edb0575535c564110fcf72aa837693d
Author: Marcel Holtmann <[email protected]>
Date:   Thu Dec 25 19:09:11 2008 +0100

    Add not supported error and use it

commit a78d60bdd0986e79f453fe1cf41a79f8c3a68eb3
Author: Marcel Holtmann <[email protected]>
Date:   Thu Dec 25 19:05:22 2008 +0100

    Add support for Name property to generic driver

commit f82ea40ef6d608e695d9041b8176a9a6f7bc85d6
Author: Marcel Holtmann <[email protected]>
Date:   Thu Dec 25 19:05:02 2008 +0100

    Add details about Interface property

commit 2fbe1fce4d2444da9af1b5c9316550c66164732e
Author: Marcel Holtmann <[email protected]>
Date:   Thu Dec 25 18:55:34 2008 +0100

    Fix broken device driver details of Bluetooth plugin

commit f6cc9bb6d4c1531d05fecee991db3f7c92f66e3b
Author: Marcel Holtmann <[email protected]>
Date:   Thu Dec 25 18:52:26 2008 +0100

    Add functions for handling path value

commit e29b62b9491e0d4a0ad3d47de9a5ce47df93f2b5
Author: Marcel Holtmann <[email protected]>
Date:   Thu Dec 25 04:27:23 2008 +0100

    Use device helpers to set power and carrier states

commit 899be488360ad24f079bbb204dc32a47c6aae093
Author: Marcel Holtmann <[email protected]>
Date:   Thu Dec 25 04:26:09 2008 +0100

    Create devices instead of raw elements

commit 48551ded08069a2d39d701bc78bab33a52ea96e0
Author: Marcel Holtmann <[email protected]>
Date:   Thu Dec 25 04:24:08 2008 +0100

    Add advanced device specific API

commit 008e44508b96501af3ce9b997f5a9dbbe9431525
Author: Marcel Holtmann <[email protected]>
Date:   Thu Dec 25 04:22:55 2008 +0100

    Fix reference docs inclusion

commit 990d345674c6dc7d8f07655d1d2e1ea61d173853
Author: Marcel Holtmann <[email protected]>
Date:   Thu Dec 25 03:36:25 2008 +0100

    Add destruct callback to element structure

commit 720b8692c453b14829b85b0c5647e7babe7a4752
Author: Marcel Holtmann <[email protected]>
Date:   Wed Dec 24 13:34:45 2008 +0100

    Add Type property to generic device driver

commit 84562870a1fa54e4ef768a52433044194efb2359
Author: Marcel Holtmann <[email protected]>
Date:   Wed Dec 24 12:37:58 2008 +0100

    Add skeleton for generic network driver

commit 04c45750075f5558499fd5e4079fc6a88bf8beb5
Author: Marcel Holtmann <[email protected]>
Date:   Wed Dec 24 12:29:12 2008 +0100

    Install device header file by default

commit 20bbe80f88aa0047bf6849ad7e5482417bce8129
Author: Marcel Holtmann <[email protected]>
Date:   Wed Dec 24 12:20:40 2008 +0100

    Convert Bluetooth plugin into a device driver

commit 27da31329144c6a2473db49798d96f53f25a5fc5
Author: Marcel Holtmann <[email protected]>
Date:   Wed Dec 24 12:20:06 2008 +0100

    Add support for scanning property of devices

commit f972a47e85625348030e28998ae9923180b0255e
Author: Marcel Holtmann <[email protected]>
Date:   Wed Dec 24 11:57:25 2008 +0100

    Convert Ethernet plugin into a device driver

commit 37b70174dc7f7e8e048a95bca7ecd9e102d14038
Author: Marcel Holtmann <[email protected]>
Date:   Wed Dec 24 11:56:08 2008 +0100

    Add support for changing device power state

commit 7a3e397e2cc0c275f81eec419fa144ad258b4b87
Author: Marcel Holtmann <[email protected]>
Date:   Wed Dec 24 11:42:18 2008 +0100

    Add support for device power functions

commit 180502c98a76dff1ac48b4de5203fff4b6644418
Author: Marcel Holtmann <[email protected]>
Date:   Wed Dec 24 10:47:05 2008 +0100

    Add functions for handling device driver data

commit 6e099bc9ea968ac8b7d0328ca4a347f64250dfe5
Author: Marcel Holtmann <[email protected]>
Date:   Wed Dec 24 10:39:28 2008 +0100

    Add D-Bus interface features for device driver

commit b02bc47fd3c6e55a529f11f7209b56d34ce4ce33
Author: Marcel Holtmann <[email protected]>
Date:   Wed Dec 24 09:20:30 2008 +0100

    Postpone initial driver probing after all plugins are loaded


Diff in this email is a maximum of 400 lines.
diff --git a/doc/connman-docs.xml b/doc/connman-docs.xml
index 542c4e1..8d51f3b 100644
--- a/doc/connman-docs.xml
+++ b/doc/connman-docs.xml
@@ -102,8 +102,7 @@
     <xi:include href="xml/log.xml" />
     <xi:include href="xml/plugin.xml" />
     <xi:include href="xml/security.xml" />
-    <xi:include href="xml/element.xml" />
-    <xi:include href="xml/driver.xml" />
+    <xi:include href="xml/resolver.xml" />
   </reference>
 
   <appendix id="license">
diff --git a/doc/device-api.txt b/doc/device-api.txt
index 45c7215..7d1b86f 100644
--- a/doc/device-api.txt
+++ b/doc/device-api.txt
@@ -54,6 +54,13 @@ Properties   string Name [readonly]
 
                        The device type (for example "ethernet", "wifi" etc.)
 
+               string Interface [readonly]
+
+                       The device interface (for example "eth0" etc.)
+
+                       This value is for pure informational purposes. It
+                       is not guaranteed that it is always present.
+
                string Policy [readwrite]
 
                        Setting of the device power policy. Possible values
diff --git a/include/Makefile.am b/include/Makefile.am
index 8c6617e..40f07eb 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -2,9 +2,8 @@
 includedir = @includedir@/connman
 
 include_HEADERS = log.h plugin.h security.h resolver.h driver.h \
-                       element.h property.h network.h ipv4.h rtnl.h dbus.h
-
-noinst_HEADERS = device.h
+                               element.h property.h rtnl.h dbus.h \
+                                               device.h network.h ipv4.h
 
 MAINTAINERCLEANFILES = Makefile.in
 
diff --git a/include/device.h b/include/device.h
index 3153148..95ffeee 100644
--- a/include/device.h
+++ b/include/device.h
@@ -26,12 +26,13 @@
 extern "C" {
 #endif
 
+#include <connman/network.h>
 #include <connman/element.h>
 
 /**
  * SECTION:device
- * @title: Device driver premitives
- * @short_description: Functions for registering device drivers
+ * @title: Device premitives
+ * @short_description: Functions for handling devices
  */
 
 enum connman_device_type {
@@ -42,10 +43,13 @@ enum connman_device_type {
        CONNMAN_DEVICE_TYPE_WIMAX     = CONNMAN_ELEMENT_SUBTYPE_WIMAX,
        CONNMAN_DEVICE_TYPE_MODEM     = CONNMAN_ELEMENT_SUBTYPE_MODEM,
        CONNMAN_DEVICE_TYPE_BLUETOOTH = CONNMAN_ELEMENT_SUBTYPE_BLUETOOTH,
+       CONNMAN_DEVICE_TYPE_VENDOR    = 42,
 };
 
-enum connman_device_capabilities {
-       CONNMAN_DEVICE_CAPABILITY_SCANNING = (1 << 0),
+enum connman_device_mode {
+       CONNMAN_DEVICE_MODE_NO_NETWORK        = 0,
+       CONNMAN_DEVICE_MODE_SINGLE_NETWORK    = 1,
+       CONNMAN_DEVICE_MODE_MULTIPLE_NETWORKS = 2,
 };
 
 enum connman_device_policy {
@@ -55,27 +59,45 @@ enum connman_device_policy {
        CONNMAN_DEVICE_POLICY_OFF     = 3,
 };
 
-enum connman_device_state {
-       CONNMAN_DEVICE_STATE_UNKNOWN = 0,
-       CONNMAN_DEVICE_STATE_OFF     = 1,
-};
-
-struct connman_device_driver;
-
-struct connman_device {
-       struct connman_element *element;
-       unsigned long capabilities;
-       enum connman_device_policy policy;
-       enum connman_device_state state;
-
-       struct connman_device_driver *driver;
-       void *driver_data;
-
-       GSList *networks;
-};
-
-extern int connman_device_set_enabled(struct connman_device *device,
-                                                       gboolean enabled);
+struct connman_device;
+
+extern struct connman_device *connman_device_create(const char *node,
+                                               enum connman_device_type type);
+extern struct connman_device *connman_device_ref(struct connman_device 
*device);
+extern void connman_device_unref(struct connman_device *device);
+
+extern void connman_device_set_path(struct connman_device *device,
+                                                       const char *path);
+extern const char *connman_device_get_path(struct connman_device *device);
+extern void connman_device_set_index(struct connman_device *device,
+                                                               int index);
+extern int connman_device_get_index(struct connman_device *device);
+extern void connman_device_set_interface(struct connman_device *device,
+                                                       const char *interface);
+extern const char *connman_device_get_interface(struct connman_device *device);
+
+extern void connman_device_set_mode(struct connman_device *device,
+                                               enum connman_device_mode mode);
+
+extern int connman_device_set_powered(struct connman_device *device,
+                                                       gboolean powered);
+extern int connman_device_set_carrier(struct connman_device *device,
+                                                       gboolean carrier);
+extern int connman_device_set_scanning(struct connman_device *device,
+                                                       gboolean scanning);
+
+extern int connman_device_add_network(struct connman_device *device,
+                                       struct connman_network *network);
+extern struct connman_network *connman_device_get_network(struct 
connman_device *device,
+                                                       const char *identifier);
+extern int connman_device_remove_network(struct connman_device *device,
+                                                       const char *identifier);
+
+extern int connman_device_register(struct connman_device *device);
+extern void connman_device_unregister(struct connman_device *device);
+
+extern void *connman_device_get_data(struct connman_device *device);
+extern void connman_device_set_data(struct connman_device *device, void *data);
 
 struct connman_device_driver {
        const char *name;
@@ -83,6 +105,8 @@ struct connman_device_driver {
        int priority;
        int (*probe) (struct connman_device *device);
        void (*remove) (struct connman_device *device);
+       int (*enable) (struct connman_device *device);
+       int (*disable) (struct connman_device *device);
        int (*scan) (struct connman_device *device);
 };
 
diff --git a/include/element.h b/include/element.h
index 083533d..afe7b0c 100644
--- a/include/element.h
+++ b/include/element.h
@@ -103,6 +103,14 @@ struct connman_element {
        struct connman_driver *driver;
        void *driver_data;
 
+       void (*destruct) (struct connman_element *element);
+
+       union {
+               void *private;
+               struct connman_device *device;
+               struct connman_network *network;
+       };
+
        GSList *properties;
 
        struct {
diff --git a/include/network.h b/include/network.h
index da7b67f..292dd9f 100644
--- a/include/network.h
+++ b/include/network.h
@@ -26,6 +26,40 @@
 extern "C" {
 #endif
 
+/**
+ * SECTION:network
+ * @title: Network premitives
+ * @short_description: Functions for handling networks
+ */
+
+enum connman_network_type {
+       CONNMAN_NETWORK_TYPE_UNKNOWN = 0,
+       CONNMAN_NETWORK_TYPE_WIFI    = 1,
+};
+
+struct connman_network;
+
+extern struct connman_network *connman_network_create(const char *identifier,
+                                               enum connman_network_type type);
+extern struct connman_network *connman_network_ref(struct connman_network 
*network);
+extern void connman_network_unref(struct connman_network *network);
+
+extern const char *connman_network_get_identifier(struct connman_network 
*network);
+
+extern void *connman_network_get_data(struct connman_network *network);
+extern void connman_network_set_data(struct connman_network *network, void 
*data);
+
+struct connman_network_driver {
+       const char *name;
+       enum connman_network_type type;
+       int priority;
+       int (*probe) (struct connman_network *network);
+       void (*remove) (struct connman_network *network);
+};
+
+extern int connman_network_driver_register(struct connman_network_driver 
*driver);
+extern void connman_network_driver_unregister(struct connman_network_driver 
*driver);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 9bb29d4..46f8f42 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -24,17 +24,19 @@
 #endif
 
 #include <errno.h>
+#include <stdlib.h>
 
 #include <gdbus.h>
 
 #include <connman/plugin.h>
-#include <connman/driver.h>
+#include <connman/device.h>
 #include <connman/dbus.h>
 #include <connman/log.h>
 
 #define BLUEZ_SERVICE                  "org.bluez"
 #define BLUEZ_MANAGER_INTERFACE                BLUEZ_SERVICE ".Manager"
 #define BLUEZ_ADAPTER_INTERFACE                BLUEZ_SERVICE ".Adapter"
+#define BLUEZ_DEVICE_INTERFACE         BLUEZ_SERVICE ".Device"
 
 #define LIST_ADAPTERS                  "ListAdapters"
 #define ADAPTER_ADDED                  "AdapterAdded"
@@ -46,15 +48,85 @@
 
 #define TIMEOUT 5000
 
+typedef void (* properties_callback_t) (DBusConnection *connection,
+                                                       const char *path,
+                                                       DBusMessage *message,
+                                                       void *user_data);
+
+struct properties_data {
+       DBusConnection *connection;
+       DBusMessage *message;
+       properties_callback_t callback;
+       void *user_data;
+};
+
+static void get_properties_reply(DBusPendingCall *call, void *user_data)
+{
+       struct properties_data *data = user_data;
+       DBusMessage *reply;
+       const char *path;
+
+       reply = dbus_pending_call_steal_reply(call);
+       if (reply == NULL)
+               goto done;
+
+       path = dbus_message_get_path(data->message);
+
+       data->callback(data->connection, path, reply, data->user_data);
+
+       dbus_message_unref(reply);
+
+done:
+       dbus_message_unref(data->message);
+       g_free(data);
+}
+
+static void get_properties(DBusConnection *connection,
+                               const char *path, const char *interface,
+                               properties_callback_t callback, void *user_data)
+{
+       struct properties_data *data;
+       DBusMessage *message;
+       DBusPendingCall *call;
+
+       DBG("path %s interface %s", path, interface);
+
+       data = g_try_new0(struct properties_data, 1);
+       if (data == NULL)
+               return;
+
+       message = dbus_message_new_method_call(BLUEZ_SERVICE, path,
+                                               interface, GET_PROPERTIES);
+       if (message == NULL) {
+               g_free(data);
+               return;
+       }
+
+       if (dbus_connection_send_with_reply(connection, message,
+                                               &call, TIMEOUT) == FALSE) {
+               connman_error("Failed to get properties for %s", interface);
+               dbus_message_unref(message);
+               g_free(data);
+               return;
+       }
+
+       data->connection = connection;
+       data->message    = message;
+       data->callback   = callback;
+       data->user_data  = user_data;
+
+       dbus_pending_call_set_notify(call, get_properties_reply, data, NULL);
+}
+
 struct adapter_data {
        DBusConnection *connection;
 };
 
-static int bluetooth_probe(struct connman_element *adapter)
+static int bluetooth_probe(struct connman_device *adapter)
 {
        struct adapter_data *data;
 
-       DBG("adapter %p name %s", adapter, adapter->name);
+       DBG("adapter %p", adapter);
 
        data = g_try_new0(struct adapter_data, 1);
        if (data == NULL)
@@ -66,18 +138,18 @@ static int bluetooth_probe(struct connman_element *adapter)
                return -EIO;
        }
 
-       connman_element_set_data(adapter, data);
+       connman_device_set_data(adapter, data);
 
        return 0;
 }
 
-static void bluetooth_remove(struct connman_element *adapter)
+static void bluetooth_remove(struct connman_device *adapter)
 {
-       struct adapter_data *data = connman_element_get_data(adapter);
+       struct adapter_data *data = connman_device_get_data(adapter);
 
-       DBG("adapter %p name %s", adapter, adapter->name);
+       DBG("adapter %p", adapter);
 
-       connman_element_set_data(adapter, NULL);
+       connman_device_set_data(adapter, NULL);
 
        dbus_connection_unref(data->connection);
 
@@ -127,58 +199,106 @@ static int change_powered(DBusConnection *connection, 
const char *path,
        return -EINPROGRESS;
 }
 
-static int bluetooth_enable(struct connman_element *adapter)
+static int bluetooth_enable(struct connman_device *adapter)
 {
-       struct adapter_data *data = connman_element_get_data(adapter);
+       struct adapter_data *data = connman_device_get_data(adapter);
+       const char *path = connman_device_get_path(adapter);
 
-       DBG("adapter %p name %s", adapter, adapter->name);
+       DBG("adapter %p", adapter);
 
-       return change_powered(data->connection, adapter->devpath, TRUE);
+       return change_powered(data->connection, path, TRUE);
 }
 
-static int bluetooth_disable(struct connman_element *adapter)
+static int bluetooth_disable(struct connman_device *adapter)
 {
-       struct adapter_data *data = connman_element_get_data(adapter);
+       struct adapter_data *data = connman_device_get_data(adapter);
+       const char *path = connman_device_get_path(adapter);
+
+       DBG("adapter %p", adapter);
 
-       DBG("adapter %p name %s", adapter, adapter->name);
+       return change_powered(data->connection, path, FALSE);
+}
+
+static int bluetooth_scan(struct connman_device *adapter)
+{
+       DBG("adapter %p", adapter);
 
-       return change_powered(data->connection, adapter->devpath, FALSE);
+       return -EIO;
 }
 
_______________________________________________
Commits mailing list
[email protected]
https://lists.moblin.org/mailman/listinfo/commits

Reply via email to