summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2010-11-04 23:08:50 +0100
committerMarcel Holtmann <marcel@holtmann.org>2010-11-04 23:08:50 +0100
commita33e7915a054d625a7b0183f3d1362e19b76cf69 (patch)
tree2b6ec7934b519fd05b9fa7dc4ff5d84601791fa9
parent249f86d3533ddc38d0e90616c7cc0dcdbe3cb802 (diff)
downloadconnman-a33e7915a054d625a7b0183f3d1362e19b76cf69.tar.gz
connman-a33e7915a054d625a7b0183f3d1362e19b76cf69.tar.bz2
connman-a33e7915a054d625a7b0183f3d1362e19b76cf69.zip
Remove unneeded CONNMAN_DEVICE_INTERFACE
-rw-r--r--include/dbus.h1
-rw-r--r--src/device.c306
2 files changed, 2 insertions, 305 deletions
diff --git a/include/dbus.h b/include/dbus.h
index 47a8be00..c321690f 100644
--- a/include/dbus.h
+++ b/include/dbus.h
@@ -42,7 +42,6 @@ extern "C" {
#define CONNMAN_TASK_INTERFACE CONNMAN_SERVICE ".Task"
#define CONNMAN_PROFILE_INTERFACE CONNMAN_SERVICE ".Profile"
#define CONNMAN_SERVICE_INTERFACE CONNMAN_SERVICE ".Service"
-#define CONNMAN_DEVICE_INTERFACE CONNMAN_SERVICE ".Device"
#define CONNMAN_PROVIDER_INTERFACE CONNMAN_SERVICE ".Provider"
#define CONNMAN_TECHNOLOGY_INTERFACE CONNMAN_SERVICE ".Technology"
diff --git a/src/device.c b/src/device.c
index 96dca026..16aa8d36 100644
--- a/src/device.c
+++ b/src/device.c
@@ -57,14 +57,9 @@ struct connman_device {
struct connman_device_driver *driver;
void *driver_data;
- connman_bool_t registered;
-
char *last_network;
struct connman_network *network;
GHashTable *networks;
-
- DBusMessage *pending;
- guint timeout;
};
static gboolean device_scan_trigger(gpointer user_data)
@@ -186,20 +181,6 @@ enum connman_service_type __connman_device_get_service_type(struct connman_devic
return CONNMAN_SERVICE_TYPE_UNKNOWN;
}
-static void powered_changed(struct connman_device *device)
-{
- connman_dbus_property_changed_basic(device->element.path,
- CONNMAN_DEVICE_INTERFACE, "Powered",
- DBUS_TYPE_BOOLEAN, &device->powered);
-}
-
-static void blocked_changed(struct connman_device *device)
-{
- connman_dbus_property_changed_basic(device->element.path,
- CONNMAN_DEVICE_INTERFACE, "Blocked",
- DBUS_TYPE_BOOLEAN, &device->blocked);
-}
-
int __connman_device_enable(struct connman_device *device)
{
int err;
@@ -283,250 +264,10 @@ static int set_powered(struct connman_device *device, connman_bool_t powered)
return __connman_device_disable(device);
}
-void __connman_device_list(DBusMessageIter *iter, void *user_data)
-{
- __connman_element_list(NULL, CONNMAN_ELEMENT_TYPE_DEVICE, iter);
-}
-
-static void append_path(gpointer key, gpointer value, gpointer user_data)
-{
- struct connman_element *element = value;
- DBusMessageIter *iter = user_data;
-
- dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH,
- &element->path);
-}
-
-static void append_networks(DBusMessageIter *iter, void *user_data)
-{
- struct connman_device *device = user_data;
-
- g_hash_table_foreach(device->networks, append_path, iter);
-}
-
-static DBusMessage *get_properties(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct connman_device *device = data;
- DBusMessage *reply;
- DBusMessageIter array, dict;
- const char *str;
-
- DBG("conn %p", conn);
-
- reply = dbus_message_new_method_return(msg);
- if (reply == NULL)
- return NULL;
-
- dbus_message_iter_init_append(reply, &array);
-
- connman_dbus_dict_open(&array, &dict);
-
- if (device->name != NULL)
- connman_dbus_dict_append_basic(&dict, "Name",
- DBUS_TYPE_STRING, &device->name);
-
- str = type2string(device->type);
- if (str != NULL)
- connman_dbus_dict_append_basic(&dict, "Type",
- DBUS_TYPE_STRING, &str);
-
- if (device->address != NULL)
- connman_dbus_dict_append_basic(&dict, "Address",
- DBUS_TYPE_STRING, &device->address);
-
- if (device->interface != NULL)
- connman_dbus_dict_append_basic(&dict, "Interface",
- DBUS_TYPE_STRING, &device->interface);
-
- connman_dbus_dict_append_basic(&dict, "Powered",
- DBUS_TYPE_BOOLEAN, &device->powered);
-
- connman_dbus_dict_append_basic(&dict, "Blocked",
- DBUS_TYPE_BOOLEAN, &device->blocked);
-
- if (device->driver && device->driver->scan)
- connman_dbus_dict_append_basic(&dict, "Scanning",
- DBUS_TYPE_BOOLEAN, &device->scanning);
-
- if (device->scan_interval > 0)
- connman_dbus_dict_append_basic(&dict, "ScanInterval",
- DBUS_TYPE_UINT16, &device->scan_interval);
-
- connman_dbus_dict_append_array(&dict, "Networks",
- DBUS_TYPE_OBJECT_PATH, append_networks, device);
-
- connman_dbus_dict_close(&array, &dict);
-
- return reply;
-}
-
-static gboolean powered_timeout(gpointer user_data)
-{
- struct connman_device *device = user_data;
-
- DBG("device %p", device);
-
- device->timeout = 0;
-
- if (device->pending != NULL) {
- DBusMessage *reply;
-
- reply = __connman_error_operation_timeout(device->pending);
- if (reply != NULL)
- g_dbus_send_message(connection, reply);
-
- dbus_message_unref(device->pending);
- device->pending = NULL;
- }
-
- return FALSE;
-}
-
-static DBusMessage *set_property(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct connman_device *device = data;
- DBusMessageIter iter, value;
- const char *name;
- int type;
-
- DBG("conn %p", conn);
-
- if (dbus_message_iter_init(msg, &iter) == FALSE)
- return __connman_error_invalid_arguments(msg);
-
- dbus_message_iter_get_basic(&iter, &name);
- dbus_message_iter_next(&iter);
- dbus_message_iter_recurse(&iter, &value);
-
- type = dbus_message_iter_get_arg_type(&value);
-
- if (g_str_equal(name, "Powered") == TRUE) {
- connman_bool_t powered;
- int err;
-
- if (type != DBUS_TYPE_BOOLEAN)
- return __connman_error_invalid_arguments(msg);
-
- dbus_message_iter_get_basic(&value, &powered);
-
- device->powered_persistent = powered;
-
- __connman_storage_save_device(device);
-
- if (device->powered == powered)
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
-
- if (device->pending != NULL)
- return __connman_error_in_progress(msg);
-
- err = set_powered(device, powered);
- if (err < 0) {
- if (err != -EINPROGRESS)
- return __connman_error_failed(msg, -err);
-
- device->pending = dbus_message_ref(msg);
-
- device->timeout = g_timeout_add_seconds(15,
- powered_timeout, device);
-
- return NULL;
- }
- } else if (g_str_equal(name, "ScanInterval") == TRUE) {
- connman_uint16_t interval;
-
- if (type != DBUS_TYPE_UINT16)
- return __connman_error_invalid_arguments(msg);
-
- dbus_message_iter_get_basic(&value, &interval);
-
- if (device->scan_interval != interval) {
- device->scan_interval = interval;
-
- __connman_storage_save_device(device);
-
- reset_scan_trigger(device);
- }
- } else
- return __connman_error_invalid_property(msg);
-
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
-}
-
-static DBusMessage *propose_scan(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct connman_device *device = data;
- int err;
-
- DBG("conn %p", conn);
-
- err = __connman_device_scan(device);
- if (err < 0)
- return __connman_error_failed(msg, -err);
-
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
-}
-
-static GDBusMethodTable device_methods[] = {
- { "GetProperties", "", "a{sv}", get_properties },
- { "SetProperty", "sv", "", set_property,
- G_DBUS_METHOD_FLAG_ASYNC },
- { "ProposeScan", "", "", propose_scan },
- { },
-};
-
-static GDBusSignalTable device_signals[] = {
- { "PropertyChanged", "sv" },
- { },
-};
-
-static int register_interface(struct connman_element *element)
-{
- struct connman_device *device = element->device;
-
- DBG("element %p name %s", element, element->name);
-
- if (g_dbus_register_interface(connection, element->path,
- CONNMAN_DEVICE_INTERFACE,
- device_methods, device_signals,
- NULL, device, NULL) == FALSE) {
- connman_error("Failed to register %s device", element->path);
- return -EIO;
- }
-
- device->registered = TRUE;
-
- return 0;
-}
-
-static void unregister_interface(struct connman_element *element)
-{
- struct connman_device *device = element->device;
-
- DBG("element %p name %s", element, element->name);
-
- device->registered = FALSE;
-
- g_dbus_unregister_interface(connection, element->path,
- CONNMAN_DEVICE_INTERFACE);
-}
-
static int setup_device(struct connman_device *device)
{
- int err;
-
DBG("device %p", device);
- err = register_interface(&device->element);
- if (err < 0) {
- if (device->driver->remove)
- device->driver->remove(device);
- device->driver = NULL;
- return err;
- }
-
__connman_technology_add_device(device);
if (device->offlinemode == FALSE &&
@@ -573,8 +314,6 @@ static void remove_device(struct connman_device *device)
__connman_technology_remove_device(device);
- unregister_interface(&device->element);
-
if (device->driver->remove)
device->driver->remove(device);
@@ -599,7 +338,7 @@ connman_bool_t __connman_device_has_driver(struct connman_device *device)
if (device == NULL || device->driver == NULL)
return FALSE;
- return device->registered;
+ return TRUE;
}
static GSList *driver_list = NULL;
@@ -668,18 +407,8 @@ static void device_destruct(struct connman_element *element)
DBG("element %p name %s", element, element->name);
- if (device->timeout > 0) {
- g_source_remove(device->timeout);
- device->timeout = 0;
- }
-
clear_scan_trigger(device);
- if (device->pending != NULL) {
- dbus_message_unref(device->pending);
- device->pending = NULL;
- }
-
g_free(device->ident);
g_free(device->node);
g_free(device->name);
@@ -932,19 +661,6 @@ int connman_device_set_powered(struct connman_device *device,
{
DBG("driver %p powered %d", device, powered);
- if (device->timeout > 0) {
- g_source_remove(device->timeout);
- device->timeout = 0;
- }
-
- if (device->pending != NULL) {
- g_dbus_send_reply(connection, device->pending,
- DBUS_TYPE_INVALID);
-
- dbus_message_unref(device->pending);
- device->pending = NULL;
- }
-
if (device->powered == powered) {
device->powered_pending = powered;
return -EALREADY;
@@ -963,15 +679,8 @@ int connman_device_set_powered(struct connman_device *device,
else
__connman_technology_disable_device(device);
- if (device->offlinemode == TRUE && powered == TRUE) {
- powered_changed(device);
+ if (device->offlinemode == TRUE && powered == TRUE)
return connman_device_set_powered(device, FALSE);
- }
-
- if (device->registered == FALSE)
- return 0;
-
- powered_changed(device);
if (powered == FALSE)
return 0;
@@ -993,8 +702,6 @@ int __connman_device_set_blocked(struct connman_device *device,
device->blocked = blocked;
- blocked_changed(device);
-
if (device->offlinemode == TRUE)
return 0;
@@ -1127,13 +834,6 @@ void __connman_device_cleanup_networks(struct connman_device *device)
remove_unavailable_network, NULL);
}
-static void scanning_changed(struct connman_device *device)
-{
- connman_dbus_property_changed_basic(device->element.path,
- CONNMAN_DEVICE_INTERFACE, "Scanning",
- DBUS_TYPE_BOOLEAN, &device->scanning);
-}
-
/**
* connman_device_set_scanning:
* @device: device structure
@@ -1154,8 +854,6 @@ int connman_device_set_scanning(struct connman_device *device,
device->scanning = scanning;
- scanning_changed(device);
-
if (scanning == TRUE) {
reset_scan_trigger(device);