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); }
int __connman_technology_init(void) { DBG(""); connection = connman_dbus_get_connection(); rfkill_list = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_rfkill); global_offlinemode = connman_technology_load_offlinemode(); /* This will create settings file if it is missing */ connman_technology_save_offlinemode(); 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; }