*
* Connection Manager
*
- * Copyright (C) 2007-2009 Intel Corporation. All rights reserved.
+ * Copyright (C) 2007-2010 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
struct connman_element element;
enum connman_device_type type;
enum connman_device_mode mode;
- connman_bool_t secondary;
connman_bool_t offlinemode;
connman_bool_t blocked;
connman_bool_t powered;
return CONNMAN_SERVICE_TYPE_UNKNOWN;
}
-static int powered_changed(struct connman_device *device)
+static void powered_changed(struct connman_device *device)
{
- DBusMessage *signal;
- DBusMessageIter entry, value;
- const char *key = "Powered";
-
- signal = dbus_message_new_signal(device->element.path,
- CONNMAN_DEVICE_INTERFACE, "PropertyChanged");
- if (signal == NULL)
- return -ENOMEM;
-
- dbus_message_iter_init_append(signal, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_BOOLEAN_AS_STRING, &value);
- dbus_message_iter_append_basic(&value, DBUS_TYPE_BOOLEAN,
- &device->powered);
- dbus_message_iter_close_container(&entry, &value);
-
- g_dbus_send_message(connection, signal);
-
- return 0;
+ connman_dbus_property_changed_basic(device->element.path,
+ CONNMAN_DEVICE_INTERFACE, "Powered",
+ DBUS_TYPE_BOOLEAN, &device->powered);
}
static int set_powered(struct connman_device *device, connman_bool_t powered)
return err;
}
+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;
&element->path);
}
-static void append_networks(struct connman_device *device,
- DBusMessageIter *entry)
+static void append_networks(DBusMessageIter *iter, void *user_data)
{
- DBusMessageIter value, iter;
- const char *key = "Networks";
-
- dbus_message_iter_append_basic(entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter);
- g_hash_table_foreach(device->networks, append_path, &iter);
- dbus_message_iter_close_container(&value, &iter);
+ struct connman_device *device = user_data;
- dbus_message_iter_close_container(entry, &value);
+ g_hash_table_foreach(device->networks, append_path, iter);
}
static DBusMessage *get_properties(DBusConnection *conn,
{
struct connman_device *device = data;
DBusMessage *reply;
- DBusMessageIter array, dict, entry;
+ DBusMessageIter array, dict;
const char *str;
DBG("conn %p", conn);
dbus_message_iter_init_append(reply, &array);
- dbus_message_iter_open_container(&array, DBUS_TYPE_ARRAY,
- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
- DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
- DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
+ connman_dbus_dict_open(&array, &dict);
if (device->name != NULL)
- connman_dbus_dict_append_variant(&dict, "Name",
+ connman_dbus_dict_append_basic(&dict, "Name",
DBUS_TYPE_STRING, &device->name);
str = type2string(device->type);
if (str != NULL)
- connman_dbus_dict_append_variant(&dict, "Type",
+ connman_dbus_dict_append_basic(&dict, "Type",
DBUS_TYPE_STRING, &str);
if (device->address != NULL)
- connman_dbus_dict_append_variant(&dict, "Address",
+ connman_dbus_dict_append_basic(&dict, "Address",
DBUS_TYPE_STRING, &device->address);
if (device->interface != NULL)
- connman_dbus_dict_append_variant(&dict, "Interface",
+ connman_dbus_dict_append_basic(&dict, "Interface",
DBUS_TYPE_STRING, &device->interface);
- connman_dbus_dict_append_variant(&dict, "Powered",
+ connman_dbus_dict_append_basic(&dict, "Powered",
DBUS_TYPE_BOOLEAN, &device->powered);
if (device->driver && device->driver->scan)
- connman_dbus_dict_append_variant(&dict, "Scanning",
+ connman_dbus_dict_append_basic(&dict, "Scanning",
DBUS_TYPE_BOOLEAN, &device->scanning);
switch (device->mode) {
case CONNMAN_DEVICE_MODE_NETWORK_SINGLE:
case CONNMAN_DEVICE_MODE_NETWORK_MULTIPLE:
if (device->scan_interval > 0)
- connman_dbus_dict_append_variant(&dict, "ScanInterval",
+ connman_dbus_dict_append_basic(&dict, "ScanInterval",
DBUS_TYPE_UINT16, &device->scan_interval);
- dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY,
- NULL, &entry);
- append_networks(device, &entry);
- dbus_message_iter_close_container(&dict, &entry);
+ connman_dbus_dict_append_array(&dict, "Networks",
+ DBUS_TYPE_OBJECT_PATH, append_networks, device);
break;
}
- dbus_message_iter_close_container(&array, &dict);
+ connman_dbus_dict_close(&array, &dict);
return reply;
}
{ },
};
-static void append_devices(DBusMessageIter *entry)
-{
- DBusMessageIter value, iter;
- const char *key = "Devices";
-
- dbus_message_iter_append_basic(entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter);
- __connman_element_list(NULL, CONNMAN_ELEMENT_TYPE_DEVICE, &iter);
- dbus_message_iter_close_container(&value, &iter);
-
- dbus_message_iter_close_container(entry, &value);
-}
-
-static void emit_devices_signal(void)
-{
- DBusMessage *signal;
- DBusMessageIter entry;
-
- signal = dbus_message_new_signal(CONNMAN_MANAGER_PATH,
- CONNMAN_MANAGER_INTERFACE, "PropertyChanged");
- if (signal == NULL)
- return;
-
- dbus_message_iter_init_append(signal, &entry);
-
- append_devices(&entry);
-
- g_dbus_send_message(connection, signal);
-}
-
static int register_interface(struct connman_element *element)
{
struct connman_device *device = element->device;
device->registered = TRUE;
- emit_devices_signal();
-
return 0;
}
device->registered = FALSE;
- emit_devices_signal();
-
g_dbus_unregister_interface(connection, element->path,
CONNMAN_DEVICE_INTERFACE);
}
return err;
}
+ __connman_technology_add_device(device);
+
type = __connman_device_get_service_type(device);
__connman_notifier_register(type);
break;
}
+ if (__connman_udev_get_blocked(device->phyindex) == TRUE)
+ return 0;
+
if (device->offlinemode == FALSE &&
device->powered_persistent == TRUE)
__connman_device_enable(device);
type = __connman_device_get_service_type(device);
__connman_notifier_unregister(type);
+ __connman_technology_remove_device(device);
+
unregister_interface(&device->element);
if (device->driver->remove)
device->element.ipv4.method = CONNMAN_IPCONFIG_METHOD_DHCP;
- device->type = type;
- device->name = g_strdup(type2description(device->type));
- device->mode = CONNMAN_DEVICE_MODE_UNKNOWN;
- device->secondary = FALSE;
+ device->type = type;
+ device->name = g_strdup(type2description(device->type));
+ device->mode = CONNMAN_DEVICE_MODE_UNKNOWN;
device->powered_persistent = TRUE;
}
/**
- * connman_device_set_secondary:
- * @device: device structure
- * @secondary: secondary value
- *
- * Change secondary value of device
- */
-void connman_device_set_secondary(struct connman_device *device,
- connman_bool_t secondary)
-{
- device->secondary = secondary;
-}
-
-/**
- * connman_device_get_secondary:
- * @device: device structure
- *
- * Get secondary value of device
- */
-connman_bool_t connman_device_get_secondary(struct connman_device *device)
-{
- return device->secondary;
-}
-
-/**
* connman_device_set_powered:
* @device: device structure
* @powered: powered state
static void scanning_changed(struct connman_device *device)
{
- DBusMessage *signal;
- DBusMessageIter entry, value;
- const char *key = "Scanning";
-
- signal = dbus_message_new_signal(device->element.path,
- CONNMAN_DEVICE_INTERFACE, "PropertyChanged");
- if (signal == NULL)
- return;
-
- dbus_message_iter_init_append(signal, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_BOOLEAN_AS_STRING, &value);
- dbus_message_iter_append_basic(&value, DBUS_TYPE_BOOLEAN,
- &device->scanning);
- dbus_message_iter_close_container(&entry, &value);
-
- g_dbus_send_message(connection, signal);
+ connman_dbus_property_changed_basic(device->element.path,
+ CONNMAN_DEVICE_INTERFACE, "Scanning",
+ DBUS_TYPE_BOOLEAN, &device->scanning);
}
static void mark_network_available(gpointer key, gpointer value,
DBG("device %p", device);
- keyfile = __connman_storage_open(ident);
+ keyfile = __connman_storage_open_profile(ident);
if (keyfile == NULL)
return 0;
done:
g_free(identifier);
- __connman_storage_close(ident, keyfile, FALSE);
+ __connman_storage_close_profile(ident, keyfile, FALSE);
return 0;
}
DBG("device %p", device);
- keyfile = __connman_storage_open(ident);
+ keyfile = __connman_storage_open_profile(ident);
if (keyfile == NULL)
return 0;
done:
g_free(identifier);
- __connman_storage_close(ident, keyfile, TRUE);
+ __connman_storage_close_profile(ident, keyfile, TRUE);
return 0;
}