static DBusMessage *disable_technology(DBusConnection *conn, DBusMessage *msg, void *data) { enum connman_service_type type; const char *str; DBG("conn %p", conn); dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID); if (g_strcmp0(str, "ethernet") == 0) type = CONNMAN_SERVICE_TYPE_ETHERNET; else if (g_strcmp0(str, "wifi") == 0) type = CONNMAN_SERVICE_TYPE_WIFI; else if (g_strcmp0(str, "wimax") == 0) type = CONNMAN_SERVICE_TYPE_WIMAX; else if (g_strcmp0(str, "bluetooth") == 0) type = CONNMAN_SERVICE_TYPE_BLUETOOTH; else if (g_strcmp0(str, "cellular") == 0) type = CONNMAN_SERVICE_TYPE_CELLULAR; else return __connman_error_invalid_arguments(msg); if (__connman_notifier_is_registered(type) == FALSE) return __connman_error_not_registered(msg); if (__connman_notifier_is_enabled(type) == FALSE) return __connman_error_already_disabled(msg); __connman_technology_disable(type, msg); return NULL; }
/** * connman_device_set_powered: * @device: device structure * @powered: powered state * * Change power state of device */ int connman_device_set_powered(struct connman_device *device, connman_bool_t powered) { int err; enum connman_service_type type; DBG("driver %p powered %d", device, powered); if (device->powered == powered) { device->powered_pending = powered; return -EALREADY; } if (powered == TRUE) err = __connman_device_enable(device); else err = __connman_device_disable(device); if (err < 0 && err != -EINPROGRESS && err != -EALREADY) return err; device->powered = powered; device->powered_pending = powered; type = __connman_device_get_service_type(device); if (device->powered == TRUE) __connman_technology_enable(type); else __connman_technology_disable(type); if (device->offlinemode == TRUE && powered == TRUE) return connman_device_set_powered(device, FALSE); if (powered == FALSE) return 0; reset_scan_trigger(device); if (device->driver && device->driver->scan) device->driver->scan(device); return 0; }
int __connman_technology_set_offlinemode(connman_bool_t offlinemode) { GSList *list; int err = -EINVAL; if (global_offlinemode == offlinemode) return 0; DBG("offlinemode %s", offlinemode ? "On" : "Off"); /* * This is a bit tricky. When you set offlinemode, there is no * way to differentiate between attempting offline mode and * resuming offlinemode from last saved profile. We need that * information in rfkill_update, otherwise it falls back on the * technology's persistent state. Hence we set the offline mode here * but save it & call the notifier only if its successful. */ global_offlinemode = offlinemode; /* Traverse technology list, enable/disable each technology. */ for (list = technology_list; list; list = list->next) { struct connman_technology *technology = list->data; if (offlinemode) err = __connman_technology_disable(technology->type, NULL); if (!offlinemode && technology->enable_persistent) err = __connman_technology_enable(technology->type, NULL); } if (err == 0 || err == -EINPROGRESS || err == -EALREADY) { connman_technology_save_offlinemode(); __connman_notifier_offlinemode(offlinemode); } else global_offlinemode = connman_technology_load_offlinemode(); return err; }
int __connman_device_disable(struct connman_device *device) { int err; enum connman_service_type type; DBG("device %p", device); if (!device->driver || !device->driver->disable) return -EOPNOTSUPP; if (device->powered == FALSE) return -ENOLINK; if (device->powered_pending == FALSE) return -EALREADY; device->reconnect = FALSE; clear_scan_trigger(device); if (device->network) connman_network_set_connected(device->network, FALSE); err = device->driver->disable(device); if (err < 0 && err != -EALREADY) { if (err == -EINPROGRESS) device->powered_pending = FALSE; return err; } g_hash_table_remove_all(device->networks); device->powered_pending = FALSE; device->powered = FALSE; type = __connman_device_get_service_type(device); __connman_technology_disable(type); return 0; }