int __connman_technology_enable(enum connman_service_type type, DBusMessage *msg);
int __connman_technology_disabled(enum connman_service_type type);
int __connman_technology_disable(enum connman_service_type type, DBusMessage *msg);
+int __connman_technology_set_offlinemode(connman_bool_t offlinemode);
int __connman_technology_add_rfkill(unsigned int index,
enum connman_service_type type,
const char *__connman_device_get_type(struct connman_device *device);
-int __connman_device_set_offlinemode(connman_bool_t offlinemode);
-
#include <connman/network.h>
int __connman_network_init(void);
void __connman_profile_cleanup(void);
connman_bool_t __connman_profile_get_offlinemode(void);
-int __connman_profile_set_offlinemode(connman_bool_t offlinemode, connman_bool_t all_devices);
+int __connman_profile_set_offlinemode(connman_bool_t offlinemode);
int __connman_profile_save_default(void);
void __connman_profile_list(DBusMessageIter *iter, void *user_data);
return NULL;
}
-static void set_offlinemode(struct connman_device *device,
- connman_bool_t offlinemode)
-{
- connman_bool_t powered;
-
- DBG("device %p name %s", device, device->name);
-
- if (device == NULL)
- return;
-
- device->offlinemode = offlinemode;
-
- if (device->blocked == TRUE)
- return;
-
- powered = (offlinemode == TRUE) ? FALSE : TRUE;
-
- if (device->powered == powered)
- return;
-
- if (device->powered_persistent == FALSE)
- powered = FALSE;
-
- set_powered(device, powered);
-}
-
-int __connman_device_set_offlinemode(connman_bool_t offlinemode)
-{
- GSList *list;
-
- DBG("offlinmode %d", offlinemode);
-
- for (list = device_list; list != NULL; list = list->next) {
- struct connman_device *device = list->data;
-
- set_offlinemode(device, offlinemode);
- }
-
- __connman_notifier_offlinemode(offlinemode);
-
- return 0;
-}
-
void __connman_device_increase_connections(struct connman_device *device)
{
if (device == NULL)
dbus_message_iter_get_basic(&value, &offlinemode);
- __connman_profile_set_offlinemode(offlinemode, TRUE);
-
- __connman_profile_save_default();
+ __connman_technology_set_offlinemode(offlinemode);
} else if (g_str_equal(name, "ActiveProfile") == TRUE) {
const char *str;
return default_profile->offlinemode;
}
-int __connman_profile_set_offlinemode(connman_bool_t offlinemode,
- connman_bool_t all_devices)
+int __connman_profile_set_offlinemode(connman_bool_t offlinemode)
{
DBG("offlinemode %d", offlinemode);
default_profile->offlinemode = offlinemode;
offlinemode_changed(default_profile);
- if (all_devices)
- __connman_device_set_offlinemode(offlinemode);
-
return 0;
}
state_changed(technology);
}
- if (__connman_profile_get_offlinemode() == TRUE) {
- __connman_profile_set_offlinemode(FALSE, FALSE);
- __connman_profile_save_default();
- }
-
if (technology->pending_reply != NULL) {
g_dbus_send_reply(connection, technology->pending_reply, DBUS_TYPE_INVALID);
dbus_message_unref(technology->pending_reply);
return err;
}
+int __connman_technology_set_offlinemode(connman_bool_t offlinemode)
+{
+ GSList *list;
+ int err = -EINVAL;
+
+ DBG("offlinemode %s", offlinemode ? "On" : "Off");
+
+ /* 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) {
+ __connman_profile_set_offlinemode(offlinemode);
+ __connman_profile_save_default();
+
+ __connman_notifier_offlinemode(offlinemode);
+ }
+
+ return err;
+}
+
static void technology_blocked(struct connman_technology *technology,
connman_bool_t blocked)
{