Example #1
0
void __connman_technology_set_offlinemode(connman_bool_t offlinemode)
{
	GSList *list;
	int err = -EINVAL;

	if (global_offlinemode == offlinemode)
		return;

	DBG("offlinemode %s", offlinemode ? "On" : "Off");

	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 = technology_disable(technology);

		if (!offlinemode && (technology->enable_persistent || 
			technology->type == CONNMAN_SERVICE_TYPE_CELLULAR))
			err = technology_enable(technology);

		DBG("technology %i, err %i", technology->type, err);
	}

	connman_technology_save_offlinemode();
	__connman_notifier_offlinemode(offlinemode);
}
Example #2
0
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;
}
Example #3
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;
}