return NULL;
}
+enum connman_service_type __connman_device_get_service_type(struct connman_device *device)
+{
+ enum connman_device_type type = connman_device_get_type(device);
+
+ switch (type) {
+ case CONNMAN_DEVICE_TYPE_UNKNOWN:
+ case CONNMAN_DEVICE_TYPE_VENDOR:
+ case CONNMAN_DEVICE_TYPE_GPS:
+ case CONNMAN_DEVICE_TYPE_NOZOMI:
+ case CONNMAN_DEVICE_TYPE_HUAWEI:
+ case CONNMAN_DEVICE_TYPE_NOVATEL:
+ break;
+ case CONNMAN_DEVICE_TYPE_ETHERNET:
+ return CONNMAN_SERVICE_TYPE_ETHERNET;
+ case CONNMAN_DEVICE_TYPE_WIFI:
+ return CONNMAN_SERVICE_TYPE_WIFI;
+ case CONNMAN_DEVICE_TYPE_WIMAX:
+ return CONNMAN_SERVICE_TYPE_WIMAX;
+ case CONNMAN_DEVICE_TYPE_BLUETOOTH:
+ return CONNMAN_SERVICE_TYPE_BLUETOOTH;
+ case CONNMAN_DEVICE_TYPE_MBM:
+ case CONNMAN_DEVICE_TYPE_HSO:
+ return CONNMAN_SERVICE_TYPE_CELLULAR;
+ }
+
+ return CONNMAN_SERVICE_TYPE_UNKNOWN;
+}
+
static int set_connected(struct connman_device *device,
connman_bool_t connected)
{
static int set_powered(struct connman_device *device, connman_bool_t powered)
{
struct connman_device_driver *driver = device->driver;
+ enum connman_service_type type;
int err;
DBG("device %p powered %d", device, powered);
if (!driver)
return -EINVAL;
+ type = __connman_device_get_service_type(device);
+
if (powered == TRUE) {
if (driver->enable) {
err = driver->enable(device);
- __connman_notifier_device_type_increase(device->type);
+ __connman_notifier_enable(type);
} else
err = -EINVAL;
} else {
if (driver->disable) {
err = driver->disable(device);
- __connman_notifier_device_type_decrease(device->type);
+ __connman_notifier_disable(type);
} else
err = -EINVAL;
}
static void device_enable(struct connman_device *device)
{
+ enum connman_service_type type;
+
DBG("device %p", device);
if (device->powered == TRUE)
return;
+ type = __connman_device_get_service_type(device);
+
if (device->driver->enable) {
if (device->driver->enable(device) == 0)
device->powered = TRUE;
- __connman_notifier_device_type_increase(device->type);
+ __connman_notifier_enable(type);
}
}
static void device_disable(struct connman_device *device)
{
+ enum connman_service_type type;
+
DBG("device %p", device);
if (device->powered == FALSE)
g_hash_table_remove_all(device->networks);
+ type = __connman_device_get_service_type(device);
+
if (device->driver->disable) {
if (device->driver->disable(device) == 0)
device->powered = FALSE;
- __connman_notifier_device_type_decrease(device->type);
+ __connman_notifier_disable(type);
}
}
*/
int connman_device_register(struct connman_device *device)
{
+ enum connman_service_type type;
+
__connman_storage_load_device(device);
switch (device->mode) {
break;
}
- __connman_notifier_device_type_register(device->type);
+ type = __connman_device_get_service_type(device);
+ __connman_notifier_register(type);
return connman_element_register(&device->element, NULL);
}
*/
void connman_device_unregister(struct connman_device *device)
{
+ enum connman_service_type type;
+
__connman_storage_save_device(device);
- __connman_notifier_device_type_unregister(device->type);
+ type = __connman_device_get_service_type(device);
+ __connman_notifier_unregister(type);
connman_element_unregister(&device->element);
}
notifier_list = g_slist_remove(notifier_list, notifier);
}
-static void device_enabled(enum connman_device_type type,
+static void technology_enabled(enum connman_device_type type,
connman_bool_t enabled)
{
GSList *list;
dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
DBUS_TYPE_STRING_AS_STRING, &iter);
- __connman_notifier_device_type_list(TRUE, &iter);
+ __connman_notifier_list(TRUE, &iter);
dbus_message_iter_close_container(&value, &iter);
dbus_message_iter_close_container(&entry, &value);
}
}
-static void device_registered(enum connman_device_type type,
+static void technology_registered(enum connman_service_type type,
connman_bool_t registered)
{
DBusMessage *signal;
dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
DBUS_TYPE_STRING_AS_STRING, &iter);
- __connman_notifier_device_type_list(FALSE, &iter);
+ __connman_notifier_list(FALSE, &iter);
dbus_message_iter_close_container(&value, &iter);
dbus_message_iter_close_container(&entry, &value);
g_dbus_send_message(connection, signal);
}
-static const char *type2string(enum connman_device_type type)
+static const char *type2string(enum connman_service_type type)
{
switch (type) {
- case CONNMAN_DEVICE_TYPE_UNKNOWN:
- case CONNMAN_DEVICE_TYPE_MBM:
- case CONNMAN_DEVICE_TYPE_HSO:
- case CONNMAN_DEVICE_TYPE_NOZOMI:
- case CONNMAN_DEVICE_TYPE_HUAWEI:
- case CONNMAN_DEVICE_TYPE_NOVATEL:
- case CONNMAN_DEVICE_TYPE_VENDOR:
+ case CONNMAN_SERVICE_TYPE_UNKNOWN:
break;
- case CONNMAN_DEVICE_TYPE_ETHERNET:
+ case CONNMAN_SERVICE_TYPE_ETHERNET:
return "ethernet";
- case CONNMAN_DEVICE_TYPE_WIFI:
+ case CONNMAN_SERVICE_TYPE_WIFI:
return "wifi";
- case CONNMAN_DEVICE_TYPE_WIMAX:
+ case CONNMAN_SERVICE_TYPE_WIMAX:
return "wimax";
- case CONNMAN_DEVICE_TYPE_BLUETOOTH:
+ case CONNMAN_SERVICE_TYPE_BLUETOOTH:
return "bluetooth";
- case CONNMAN_DEVICE_TYPE_GPS:
- return "gps";
+ case CONNMAN_SERVICE_TYPE_CELLULAR:
+ return "cellular";
}
return NULL;
}
-static volatile gint registered[20];
-static volatile gint enabled[20];
+static volatile gint registered[10];
+static volatile gint enabled[10];
-void __connman_notifier_device_type_list(gboolean powered,
- DBusMessageIter *iter)
+void __connman_notifier_list(gboolean powered, DBusMessageIter *iter)
{
int i;
}
}
-void __connman_notifier_device_type_register(enum connman_device_type type)
+void __connman_notifier_register(enum connman_service_type type)
{
DBG("type %d", type);
switch (type) {
- case CONNMAN_DEVICE_TYPE_UNKNOWN:
- case CONNMAN_DEVICE_TYPE_MBM:
- case CONNMAN_DEVICE_TYPE_HSO:
- case CONNMAN_DEVICE_TYPE_NOZOMI:
- case CONNMAN_DEVICE_TYPE_HUAWEI:
- case CONNMAN_DEVICE_TYPE_NOVATEL:
- case CONNMAN_DEVICE_TYPE_VENDOR:
+ case CONNMAN_SERVICE_TYPE_UNKNOWN:
return;
- case CONNMAN_DEVICE_TYPE_ETHERNET:
- case CONNMAN_DEVICE_TYPE_WIFI:
- case CONNMAN_DEVICE_TYPE_WIMAX:
- case CONNMAN_DEVICE_TYPE_BLUETOOTH:
- case CONNMAN_DEVICE_TYPE_GPS:
- if (g_atomic_int_exchange_and_add(®istered[type], 1) == 0)
- device_registered(type, TRUE);
+ case CONNMAN_SERVICE_TYPE_ETHERNET:
+ case CONNMAN_SERVICE_TYPE_WIFI:
+ case CONNMAN_SERVICE_TYPE_WIMAX:
+ case CONNMAN_SERVICE_TYPE_BLUETOOTH:
+ case CONNMAN_SERVICE_TYPE_CELLULAR:
break;
}
+
+ if (g_atomic_int_exchange_and_add(®istered[type], 1) == 0)
+ technology_registered(type, TRUE);
}
-void __connman_notifier_device_type_unregister(enum connman_device_type type)
+void __connman_notifier_unregister(enum connman_service_type type)
{
DBG("type %d", type);
switch (type) {
- case CONNMAN_DEVICE_TYPE_UNKNOWN:
- case CONNMAN_DEVICE_TYPE_MBM:
- case CONNMAN_DEVICE_TYPE_HSO:
- case CONNMAN_DEVICE_TYPE_NOZOMI:
- case CONNMAN_DEVICE_TYPE_HUAWEI:
- case CONNMAN_DEVICE_TYPE_NOVATEL:
- case CONNMAN_DEVICE_TYPE_VENDOR:
+ case CONNMAN_SERVICE_TYPE_UNKNOWN:
return;
- case CONNMAN_DEVICE_TYPE_ETHERNET:
- case CONNMAN_DEVICE_TYPE_WIFI:
- case CONNMAN_DEVICE_TYPE_WIMAX:
- case CONNMAN_DEVICE_TYPE_BLUETOOTH:
- case CONNMAN_DEVICE_TYPE_GPS:
- if (g_atomic_int_dec_and_test(®istered[type]) == TRUE)
- device_registered(type, FALSE);
+ case CONNMAN_SERVICE_TYPE_ETHERNET:
+ case CONNMAN_SERVICE_TYPE_WIFI:
+ case CONNMAN_SERVICE_TYPE_WIMAX:
+ case CONNMAN_SERVICE_TYPE_BLUETOOTH:
+ case CONNMAN_SERVICE_TYPE_CELLULAR:
break;
}
+
+ if (g_atomic_int_dec_and_test(®istered[type]) == TRUE)
+ technology_registered(type, FALSE);
}
-void __connman_notifier_device_type_increase(enum connman_device_type type)
+void __connman_notifier_enable(enum connman_service_type type)
{
DBG("type %d", type);
switch (type) {
- case CONNMAN_DEVICE_TYPE_UNKNOWN:
- case CONNMAN_DEVICE_TYPE_MBM:
- case CONNMAN_DEVICE_TYPE_HSO:
- case CONNMAN_DEVICE_TYPE_NOZOMI:
- case CONNMAN_DEVICE_TYPE_HUAWEI:
- case CONNMAN_DEVICE_TYPE_NOVATEL:
- case CONNMAN_DEVICE_TYPE_VENDOR:
+ case CONNMAN_SERVICE_TYPE_UNKNOWN:
return;
- case CONNMAN_DEVICE_TYPE_ETHERNET:
- case CONNMAN_DEVICE_TYPE_WIFI:
- case CONNMAN_DEVICE_TYPE_WIMAX:
- case CONNMAN_DEVICE_TYPE_BLUETOOTH:
- case CONNMAN_DEVICE_TYPE_GPS:
- if (g_atomic_int_exchange_and_add(&enabled[type], 1) == 0)
- device_enabled(type, TRUE);
+ case CONNMAN_SERVICE_TYPE_ETHERNET:
+ case CONNMAN_SERVICE_TYPE_WIFI:
+ case CONNMAN_SERVICE_TYPE_WIMAX:
+ case CONNMAN_SERVICE_TYPE_BLUETOOTH:
+ case CONNMAN_SERVICE_TYPE_CELLULAR:
break;
}
+
+ if (g_atomic_int_exchange_and_add(&enabled[type], 1) == 0)
+ technology_enabled(type, TRUE);
}
-void __connman_notifier_device_type_decrease(enum connman_device_type type)
+void __connman_notifier_disable(enum connman_service_type type)
{
DBG("type %d", type);
switch (type) {
- case CONNMAN_DEVICE_TYPE_UNKNOWN:
- case CONNMAN_DEVICE_TYPE_MBM:
- case CONNMAN_DEVICE_TYPE_HSO:
- case CONNMAN_DEVICE_TYPE_NOZOMI:
- case CONNMAN_DEVICE_TYPE_HUAWEI:
- case CONNMAN_DEVICE_TYPE_NOVATEL:
- case CONNMAN_DEVICE_TYPE_VENDOR:
+ case CONNMAN_SERVICE_TYPE_UNKNOWN:
return;
- case CONNMAN_DEVICE_TYPE_ETHERNET:
- case CONNMAN_DEVICE_TYPE_WIFI:
- case CONNMAN_DEVICE_TYPE_WIMAX:
- case CONNMAN_DEVICE_TYPE_BLUETOOTH:
- case CONNMAN_DEVICE_TYPE_GPS:
- if (g_atomic_int_dec_and_test(&enabled[type]) == TRUE)
- device_enabled(type, FALSE);
+ case CONNMAN_SERVICE_TYPE_ETHERNET:
+ case CONNMAN_SERVICE_TYPE_WIFI:
+ case CONNMAN_SERVICE_TYPE_WIMAX:
+ case CONNMAN_SERVICE_TYPE_BLUETOOTH:
+ case CONNMAN_SERVICE_TYPE_CELLULAR:
break;
}
+
+ if (g_atomic_int_dec_and_test(&enabled[type]) == TRUE)
+ technology_enabled(type, FALSE);
}
void __connman_notifier_offline_mode(connman_bool_t enabled)