5 * Copyright (C) 2007-2010 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33 static DBusConnection *connection;
35 static GSList *technology_list = NULL;
37 static connman_bool_t global_offlinemode;
39 struct connman_rfkill {
41 enum connman_service_type type;
42 connman_bool_t softblock;
43 connman_bool_t hardblock;
46 enum connman_technology_state {
47 CONNMAN_TECHNOLOGY_STATE_UNKNOWN = 0,
48 CONNMAN_TECHNOLOGY_STATE_OFFLINE = 1,
49 CONNMAN_TECHNOLOGY_STATE_ENABLED = 2,
50 CONNMAN_TECHNOLOGY_STATE_CONNECTED = 3,
53 struct connman_technology {
55 enum connman_service_type type;
56 enum connman_technology_state state;
58 GHashTable *rfkill_list;
63 connman_bool_t tethering;
64 char *tethering_ident;
65 char *tethering_passphrase;
67 connman_bool_t enable_persistent; /* Save the tech state */
69 struct connman_technology_driver *driver;
72 DBusMessage *pending_reply;
73 guint pending_timeout;
76 static GSList *driver_list = NULL;
78 static gint compare_priority(gconstpointer a, gconstpointer b)
80 const struct connman_technology_driver *driver1 = a;
81 const struct connman_technology_driver *driver2 = b;
83 return driver2->priority - driver1->priority;
87 * connman_technology_driver_register:
88 * @driver: Technology driver definition
90 * Register a new technology driver
92 * Returns: %0 on success
94 int connman_technology_driver_register(struct connman_technology_driver *driver)
96 DBG("Registering %s driver", driver->name);
98 driver_list = g_slist_insert_sorted(driver_list, driver,
105 * connman_technology_driver_unregister:
106 * @driver: Technology driver definition
108 * Remove a previously registered technology driver
110 void connman_technology_driver_unregister(struct connman_technology_driver *driver)
113 struct connman_technology *technology;
115 DBG("Unregistering driver %p name %s", driver, driver->name);
117 for (list = technology_list; list; list = list->next) {
118 technology = list->data;
120 if (technology->driver == NULL)
123 if (technology->type == driver->type) {
124 technology->driver->remove(technology);
125 technology->driver = NULL;
129 driver_list = g_slist_remove(driver_list, driver);
132 static void tethering_changed(struct connman_technology *technology)
134 connman_bool_t tethering = technology->tethering;
136 connman_dbus_property_changed_basic(technology->path,
137 CONNMAN_TECHNOLOGY_INTERFACE, "Tethering",
138 DBUS_TYPE_BOOLEAN, &tethering);
141 void connman_technology_tethering_notify(struct connman_technology *technology,
142 connman_bool_t enabled)
146 DBG("technology %p enabled %u", technology, enabled);
148 if (technology->tethering == enabled)
151 technology->tethering = enabled;
153 tethering_changed(technology);
156 __connman_tethering_set_enabled();
158 for (list = technology_list; list; list = list->next) {
159 struct connman_technology *other_tech = list->data;
160 if (other_tech->tethering == TRUE)
164 __connman_tethering_set_disabled();
168 static int set_tethering(struct connman_technology *technology,
169 connman_bool_t enabled)
171 const char *ident, *passphrase, *bridge;
173 ident = technology->tethering_ident;
174 passphrase = technology->tethering_passphrase;
176 if (technology->driver == NULL ||
177 technology->driver->set_tethering == NULL)
180 bridge = __connman_tethering_get_bridge();
184 if (technology->type == CONNMAN_SERVICE_TYPE_WIFI &&
185 (ident == NULL || passphrase == NULL))
188 return technology->driver->set_tethering(technology, ident, passphrase,
192 void connman_technology_regdom_notify(struct connman_technology *technology,
198 connman_error("Failed to set regulatory domain");
200 DBG("Regulatory domain set to %s", alpha2);
202 g_free(technology->regdom);
203 technology->regdom = g_strdup(alpha2);
206 int connman_technology_set_regdom(const char *alpha2)
210 for (list = technology_list; list; list = list->next) {
211 struct connman_technology *technology = list->data;
213 if (technology->driver == NULL)
216 if (technology->driver->set_regdom)
217 technology->driver->set_regdom(technology, alpha2);
223 static void free_rfkill(gpointer data)
225 struct connman_rfkill *rfkill = data;
230 static const char *state2string(enum connman_technology_state state)
233 case CONNMAN_TECHNOLOGY_STATE_UNKNOWN:
235 case CONNMAN_TECHNOLOGY_STATE_OFFLINE:
237 case CONNMAN_TECHNOLOGY_STATE_ENABLED:
239 case CONNMAN_TECHNOLOGY_STATE_CONNECTED:
246 static void state_changed(struct connman_technology *technology)
250 str = state2string(technology->state);
254 connman_dbus_property_changed_basic(technology->path,
255 CONNMAN_TECHNOLOGY_INTERFACE, "State",
256 DBUS_TYPE_STRING, &str);
259 static const char *get_name(enum connman_service_type type)
262 case CONNMAN_SERVICE_TYPE_UNKNOWN:
263 case CONNMAN_SERVICE_TYPE_SYSTEM:
264 case CONNMAN_SERVICE_TYPE_GPS:
265 case CONNMAN_SERVICE_TYPE_VPN:
266 case CONNMAN_SERVICE_TYPE_GADGET:
268 case CONNMAN_SERVICE_TYPE_ETHERNET:
270 case CONNMAN_SERVICE_TYPE_WIFI:
272 case CONNMAN_SERVICE_TYPE_WIMAX:
274 case CONNMAN_SERVICE_TYPE_BLUETOOTH:
276 case CONNMAN_SERVICE_TYPE_CELLULAR:
283 static void load_state(struct connman_technology *technology)
287 GError *error = NULL;
288 connman_bool_t enable;
290 DBG("technology %p", technology);
292 keyfile = __connman_storage_load_global();
293 /* Fallback on disabling technology if file not found. */
294 if (keyfile == NULL) {
295 technology->enable_persistent = FALSE;
299 identifier = g_strdup_printf("%s", get_name(technology->type));
300 if (identifier == NULL)
303 enable = g_key_file_get_boolean(keyfile, identifier, "Enable", &error);
305 technology->enable_persistent = enable;
307 technology->enable_persistent = FALSE;
308 g_clear_error(&error);
313 g_key_file_free(keyfile);
318 static void save_state(struct connman_technology *technology)
323 DBG("technology %p", technology);
325 keyfile = __connman_storage_load_global();
327 keyfile = g_key_file_new();
329 identifier = g_strdup_printf("%s", get_name(technology->type));
330 if (identifier == NULL)
333 g_key_file_set_boolean(keyfile, identifier, "Enable",
334 technology->enable_persistent);
339 __connman_storage_save_global(keyfile);
341 g_key_file_free(keyfile);
346 connman_bool_t __connman_technology_get_offlinemode(void)
348 return global_offlinemode;
351 static void connman_technology_save_offlinemode()
355 keyfile = __connman_storage_load_global();
357 keyfile = g_key_file_new();
359 g_key_file_set_boolean(keyfile, "global",
360 "OfflineMode", global_offlinemode);
362 __connman_storage_save_global(keyfile);
364 g_key_file_free(keyfile);
369 static connman_bool_t connman_technology_load_offlinemode()
372 GError *error = NULL;
373 connman_bool_t offlinemode;
375 /* If there is a error, we enable offlinemode */
376 keyfile = __connman_storage_load_global();
380 offlinemode = g_key_file_get_boolean(keyfile, "global",
381 "OfflineMode", &error);
384 g_clear_error(&error);
387 g_key_file_free(keyfile);
392 static void append_properties(DBusMessageIter *iter,
393 struct connman_technology *technology)
395 DBusMessageIter dict;
398 connman_dbus_dict_open(iter, &dict);
400 str = state2string(technology->state);
402 connman_dbus_dict_append_basic(&dict, "State",
403 DBUS_TYPE_STRING, &str);
405 str = get_name(technology->type);
407 connman_dbus_dict_append_basic(&dict, "Name",
408 DBUS_TYPE_STRING, &str);
410 str = __connman_service_type2string(technology->type);
412 connman_dbus_dict_append_basic(&dict, "Type",
413 DBUS_TYPE_STRING, &str);
415 connman_dbus_dict_append_basic(&dict, "Tethering",
417 &technology->tethering);
419 if (technology->tethering_ident != NULL)
420 connman_dbus_dict_append_basic(&dict, "TetheringIdentifier",
422 &technology->tethering_ident);
424 if (technology->tethering_passphrase != NULL)
425 connman_dbus_dict_append_basic(&dict, "TetheringPassphrase",
427 &technology->tethering_passphrase);
429 connman_dbus_dict_close(iter, &dict);
432 static void technology_added_signal(struct connman_technology *technology)
435 DBusMessageIter iter;
437 signal = dbus_message_new_signal(CONNMAN_MANAGER_PATH,
438 CONNMAN_MANAGER_INTERFACE, "TechnologyAdded");
442 dbus_message_iter_init_append(signal, &iter);
443 append_properties(&iter, technology);
445 dbus_connection_send(connection, signal, NULL);
446 dbus_message_unref(signal);
449 static void technology_removed_signal(struct connman_technology *technology)
451 g_dbus_emit_signal(connection, CONNMAN_MANAGER_PATH,
452 CONNMAN_MANAGER_INTERFACE, "TechnologyRemoved",
453 DBUS_TYPE_OBJECT_PATH, technology->path,
457 static DBusMessage *get_properties(DBusConnection *conn,
458 DBusMessage *message, void *user_data)
460 struct connman_technology *technology = user_data;
462 DBusMessageIter iter;
464 reply = dbus_message_new_method_return(message);
468 dbus_message_iter_init_append(reply, &iter);
469 append_properties(&iter, technology);
474 void __connman_technology_list_struct(DBusMessageIter *array)
477 DBusMessageIter entry;
479 for (list = technology_list; list; list = list->next) {
480 struct connman_technology *technology = list->data;
482 if (technology->path == NULL)
485 dbus_message_iter_open_container(array, DBUS_TYPE_STRUCT,
487 dbus_message_iter_append_basic(&entry, DBUS_TYPE_OBJECT_PATH,
489 append_properties(&entry, technology);
490 dbus_message_iter_close_container(array, &entry);
494 static DBusMessage *set_property(DBusConnection *conn,
495 DBusMessage *msg, void *data)
497 struct connman_technology *technology = data;
498 DBusMessageIter iter, value;
502 DBG("conn %p", conn);
504 if (dbus_message_iter_init(msg, &iter) == FALSE)
505 return __connman_error_invalid_arguments(msg);
507 dbus_message_iter_get_basic(&iter, &name);
508 dbus_message_iter_next(&iter);
509 dbus_message_iter_recurse(&iter, &value);
511 type = dbus_message_iter_get_arg_type(&value);
513 DBG("property %s", name);
515 if (g_str_equal(name, "Tethering") == TRUE) {
517 connman_bool_t tethering;
519 if (type != DBUS_TYPE_BOOLEAN)
520 return __connman_error_invalid_arguments(msg);
522 dbus_message_iter_get_basic(&value, &tethering);
524 if (technology->tethering == tethering)
525 return __connman_error_in_progress(msg);
527 err = set_tethering(technology, tethering);
529 return __connman_error_failed(msg, -err);
531 } else if (g_str_equal(name, "TetheringIdentifier") == TRUE) {
534 dbus_message_iter_get_basic(&value, &str);
536 if (technology->type != CONNMAN_SERVICE_TYPE_WIFI)
537 return __connman_error_not_supported(msg);
539 technology->tethering_ident = g_strdup(str);
540 } else if (g_str_equal(name, "TetheringPassphrase") == TRUE) {
543 dbus_message_iter_get_basic(&value, &str);
545 if (technology->type != CONNMAN_SERVICE_TYPE_WIFI)
546 return __connman_error_not_supported(msg);
549 return __connman_error_invalid_arguments(msg);
551 technology->tethering_passphrase = g_strdup(str);
553 return __connman_error_invalid_property(msg);
555 return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
558 static GDBusMethodTable technology_methods[] = {
559 { "GetProperties", "", "a{sv}", get_properties },
560 { "SetProperty", "sv", "", set_property },
564 static GDBusSignalTable technology_signals[] = {
565 { "PropertyChanged", "sv" },
569 static struct connman_technology *technology_find(enum connman_service_type type)
573 DBG("type %d", type);
575 for (list = technology_list; list; list = list->next) {
576 struct connman_technology *technology = list->data;
578 if (technology->type == type)
585 static struct connman_technology *technology_get(enum connman_service_type type)
587 struct connman_technology *technology;
591 DBG("type %d", type);
593 technology = technology_find(type);
594 if (technology != NULL) {
595 __sync_fetch_and_add(&technology->refcount, 1);
599 str = __connman_service_type2string(type);
603 technology = g_try_new0(struct connman_technology, 1);
604 if (technology == NULL)
607 technology->refcount = 1;
609 technology->type = type;
610 technology->path = g_strdup_printf("%s/technology/%s",
613 technology->rfkill_list = g_hash_table_new_full(g_int_hash, g_int_equal,
615 technology->device_list = NULL;
617 technology->pending_reply = NULL;
618 technology->state = CONNMAN_TECHNOLOGY_STATE_OFFLINE;
620 load_state(technology);
622 if (g_dbus_register_interface(connection, technology->path,
623 CONNMAN_TECHNOLOGY_INTERFACE,
624 technology_methods, technology_signals,
625 NULL, technology, NULL) == FALSE) {
626 connman_error("Failed to register %s", technology->path);
631 technology_list = g_slist_append(technology_list, technology);
633 technology_added_signal(technology);
635 if (technology->driver != NULL)
638 for (list = driver_list; list; list = list->next) {
639 struct connman_technology_driver *driver = list->data;
641 DBG("driver %p name %s", driver, driver->name);
643 if (driver->type != technology->type)
646 if (driver->probe(technology) == 0) {
647 technology->driver = driver;
653 DBG("technology %p", technology);
658 static void technology_put(struct connman_technology *technology)
660 DBG("technology %p", technology);
662 if (__sync_fetch_and_sub(&technology->refcount, 1) != 1)
665 if (technology->driver) {
666 technology->driver->remove(technology);
667 technology->driver = NULL;
670 technology_list = g_slist_remove(technology_list, technology);
672 technology_removed_signal(technology);
674 g_dbus_unregister_interface(connection, technology->path,
675 CONNMAN_TECHNOLOGY_INTERFACE);
677 g_slist_free(technology->device_list);
678 g_hash_table_destroy(technology->rfkill_list);
680 g_free(technology->path);
681 g_free(technology->regdom);
685 void __connman_technology_add_interface(enum connman_service_type type,
686 int index, const char *name, const char *ident)
688 struct connman_technology *technology;
691 case CONNMAN_SERVICE_TYPE_UNKNOWN:
692 case CONNMAN_SERVICE_TYPE_SYSTEM:
694 case CONNMAN_SERVICE_TYPE_ETHERNET:
695 case CONNMAN_SERVICE_TYPE_WIFI:
696 case CONNMAN_SERVICE_TYPE_WIMAX:
697 case CONNMAN_SERVICE_TYPE_BLUETOOTH:
698 case CONNMAN_SERVICE_TYPE_CELLULAR:
699 case CONNMAN_SERVICE_TYPE_GPS:
700 case CONNMAN_SERVICE_TYPE_VPN:
701 case CONNMAN_SERVICE_TYPE_GADGET:
705 connman_info("Adding interface %s [ %s ]", name,
706 __connman_service_type2string(type));
708 technology = technology_find(type);
710 if (technology == NULL || technology->driver == NULL
711 || technology->driver->add_interface == NULL)
714 technology->driver->add_interface(technology,
718 void __connman_technology_remove_interface(enum connman_service_type type,
719 int index, const char *name, const char *ident)
721 struct connman_technology *technology;
724 case CONNMAN_SERVICE_TYPE_UNKNOWN:
725 case CONNMAN_SERVICE_TYPE_SYSTEM:
727 case CONNMAN_SERVICE_TYPE_ETHERNET:
728 case CONNMAN_SERVICE_TYPE_WIFI:
729 case CONNMAN_SERVICE_TYPE_WIMAX:
730 case CONNMAN_SERVICE_TYPE_BLUETOOTH:
731 case CONNMAN_SERVICE_TYPE_CELLULAR:
732 case CONNMAN_SERVICE_TYPE_GPS:
733 case CONNMAN_SERVICE_TYPE_VPN:
734 case CONNMAN_SERVICE_TYPE_GADGET:
738 connman_info("Remove interface %s [ %s ]", name,
739 __connman_service_type2string(type));
741 technology = technology_find(type);
743 if (technology == NULL || technology->driver == NULL)
746 if (technology->driver->remove_interface)
747 technology->driver->remove_interface(technology, index);
750 int __connman_technology_add_device(struct connman_device *device)
752 struct connman_technology *technology;
753 enum connman_service_type type;
755 DBG("device %p", device);
757 type = __connman_device_get_service_type(device);
758 __connman_notifier_register(type);
760 technology = technology_get(type);
761 if (technology == NULL)
764 if (technology->enable_persistent && !global_offlinemode)
765 __connman_device_enable(device);
766 /* if technology persistent state is offline */
767 if (!technology->enable_persistent)
768 __connman_device_disable(device);
770 technology->device_list = g_slist_append(technology->device_list,
776 int __connman_technology_remove_device(struct connman_device *device)
778 struct connman_technology *technology;
779 enum connman_service_type type;
781 DBG("device %p", device);
783 type = __connman_device_get_service_type(device);
784 __connman_notifier_unregister(type);
786 technology = technology_find(type);
787 if (technology == NULL)
790 technology->device_list = g_slist_remove(technology->device_list,
792 if (technology->device_list == NULL) {
793 technology->state = CONNMAN_TECHNOLOGY_STATE_OFFLINE;
794 state_changed(technology);
800 static gboolean technology_pending_reply(gpointer user_data)
802 struct connman_technology *technology = user_data;
805 /* Power request timedout, send ETIMEDOUT. */
806 if (technology->pending_reply != NULL) {
807 reply = __connman_error_failed(technology->pending_reply, ETIMEDOUT);
809 g_dbus_send_message(connection, reply);
811 dbus_message_unref(technology->pending_reply);
812 technology->pending_reply = NULL;
813 technology->pending_timeout = 0;
819 int __connman_technology_enabled(enum connman_service_type type)
821 struct connman_technology *technology;
823 technology = technology_find(type);
824 if (technology == NULL)
827 if (__sync_fetch_and_add(&technology->enabled, 1) == 0) {
828 __connman_notifier_enable(type);
829 technology->state = CONNMAN_TECHNOLOGY_STATE_ENABLED;
830 state_changed(technology);
833 if (technology->pending_reply != NULL) {
834 g_dbus_send_reply(connection, technology->pending_reply, DBUS_TYPE_INVALID);
835 dbus_message_unref(technology->pending_reply);
836 g_source_remove(technology->pending_timeout);
837 technology->pending_reply = NULL;
838 technology->pending_timeout = 0;
844 int __connman_technology_enable(enum connman_service_type type, DBusMessage *msg)
846 struct connman_technology *technology;
852 DBG("type %d enable", type);
854 technology = technology_find(type);
855 if (technology == NULL) {
860 if (technology->pending_reply != NULL) {
867 * This is a bit of a trick. When msg is not NULL it means
868 * thats technology_enable was invoked from the manager API. Hence we save
871 technology->enable_persistent = TRUE;
872 save_state(technology);
875 __connman_rfkill_block(technology->type, FALSE);
878 * An empty device list means that devices in the technology
879 * were rfkill blocked. The unblock above will enable the devs.
881 if (technology->device_list == NULL) {
886 for (list = technology->device_list; list; list = list->next) {
887 struct connman_device *device = list->data;
889 err = __connman_device_enable(device);
891 * err = 0 : Device was enabled right away.
892 * If atleast one device gets enabled, we consider
893 * the technology to be enabled.
902 g_dbus_send_reply(connection, msg, DBUS_TYPE_INVALID);
907 if (err == -EINPROGRESS) {
908 technology->pending_reply = dbus_message_ref(msg);
909 technology->pending_timeout = g_timeout_add_seconds(10,
910 technology_pending_reply, technology);
912 reply = __connman_error_failed(msg, -err);
914 g_dbus_send_message(connection, reply);
921 int __connman_technology_disabled(enum connman_service_type type)
923 struct connman_technology *technology;
925 technology = technology_find(type);
926 if (technology == NULL)
929 if (technology->pending_reply != NULL) {
930 g_dbus_send_reply(connection, technology->pending_reply, DBUS_TYPE_INVALID);
931 dbus_message_unref(technology->pending_reply);
932 g_source_remove(technology->pending_timeout);
933 technology->pending_reply = NULL;
934 technology->pending_timeout = 0;
937 if (__sync_fetch_and_sub(&technology->enabled, 1) != 1)
940 __connman_notifier_disable(type);
941 technology->state = CONNMAN_TECHNOLOGY_STATE_OFFLINE;
942 state_changed(technology);
947 int __connman_technology_disable(enum connman_service_type type, DBusMessage *msg)
949 struct connman_technology *technology;
955 DBG("type %d disable", type);
957 technology = technology_find(type);
958 if (technology == NULL) {
963 if (technology->pending_reply != NULL) {
968 if (technology->tethering == TRUE)
969 set_tethering(technology, FALSE);
972 technology->enable_persistent = FALSE;
973 save_state(technology);
976 __connman_rfkill_block(technology->type, TRUE);
978 for (list = technology->device_list; list; list = list->next) {
979 struct connman_device *device = list->data;
981 err = __connman_device_disable(device);
989 g_dbus_send_reply(connection, msg, DBUS_TYPE_INVALID);
994 if (err == -EINPROGRESS) {
995 technology->pending_reply = dbus_message_ref(msg);
996 technology->pending_timeout = g_timeout_add_seconds(10,
997 technology_pending_reply, technology);
999 reply = __connman_error_failed(msg, -err);
1001 g_dbus_send_message(connection, reply);
1008 int __connman_technology_set_offlinemode(connman_bool_t offlinemode)
1013 if (global_offlinemode == offlinemode)
1016 DBG("offlinemode %s", offlinemode ? "On" : "Off");
1019 * This is a bit tricky. When you set offlinemode, there is no
1020 * way to differentiate between attempting offline mode and
1021 * resuming offlinemode from last saved profile. We need that
1022 * information in rfkill_update, otherwise it falls back on the
1023 * technology's persistent state. Hence we set the offline mode here
1024 * but save it & call the notifier only if its successful.
1027 global_offlinemode = offlinemode;
1029 /* Traverse technology list, enable/disable each technology. */
1030 for (list = technology_list; list; list = list->next) {
1031 struct connman_technology *technology = list->data;
1034 err = __connman_technology_disable(technology->type, NULL);
1036 if (!offlinemode && technology->enable_persistent)
1037 err = __connman_technology_enable(technology->type, NULL);
1040 if (err == 0 || err == -EINPROGRESS || err == -EALREADY) {
1041 connman_technology_save_offlinemode();
1042 __connman_notifier_offlinemode(offlinemode);
1044 global_offlinemode = connman_technology_load_offlinemode();
1049 int __connman_technology_add_rfkill(unsigned int index,
1050 enum connman_service_type type,
1051 connman_bool_t softblock,
1052 connman_bool_t hardblock)
1054 struct connman_technology *technology;
1055 struct connman_rfkill *rfkill;
1057 DBG("index %u type %d soft %u hard %u", index, type,
1058 softblock, hardblock);
1060 technology = technology_get(type);
1061 if (technology == NULL)
1064 rfkill = g_try_new0(struct connman_rfkill, 1);
1068 __connman_notifier_register(type);
1070 rfkill->index = index;
1071 rfkill->type = type;
1072 rfkill->softblock = softblock;
1073 rfkill->hardblock = hardblock;
1075 g_hash_table_replace(technology->rfkill_list, &rfkill->index, rfkill);
1078 DBG("%s is switched off.", get_name(type));
1083 * If Offline mode is on, we softblock the device if it isnt already.
1084 * If Offline mode is off, we rely on the persistent state of tech.
1086 if (global_offlinemode) {
1088 return __connman_rfkill_block(type, TRUE);
1090 if (technology->enable_persistent && softblock)
1091 return __connman_rfkill_block(type, FALSE);
1092 /* if technology persistent state is offline */
1093 if (!technology->enable_persistent && !softblock)
1094 return __connman_rfkill_block(type, TRUE);
1100 int __connman_technology_update_rfkill(unsigned int index,
1101 enum connman_service_type type,
1102 connman_bool_t softblock,
1103 connman_bool_t hardblock)
1105 struct connman_technology *technology;
1106 struct connman_rfkill *rfkill;
1108 DBG("index %u soft %u hard %u", index, softblock, hardblock);
1110 technology = technology_find(type);
1111 if (technology == NULL)
1114 rfkill = g_hash_table_lookup(technology->rfkill_list, &index);
1118 if (rfkill->softblock == softblock &&
1119 rfkill->hardblock == hardblock)
1122 rfkill->softblock = softblock;
1123 rfkill->hardblock = hardblock;
1126 DBG("%s is switched off.", get_name(type));
1130 if (!global_offlinemode) {
1131 if (technology->enable_persistent && softblock)
1132 return __connman_rfkill_block(type, FALSE);
1133 if (!technology->enable_persistent && !softblock)
1134 return __connman_rfkill_block(type, TRUE);
1140 int __connman_technology_remove_rfkill(unsigned int index,
1141 enum connman_service_type type)
1143 struct connman_technology *technology;
1144 struct connman_rfkill *rfkill;
1146 DBG("index %u", index);
1148 technology = technology_find(type);
1149 if (technology == NULL)
1152 rfkill = g_hash_table_lookup(technology->rfkill_list, &index);
1156 g_hash_table_remove(technology->rfkill_list, &index);
1158 technology_put(technology);
1163 int __connman_technology_init(void)
1167 connection = connman_dbus_get_connection();
1169 global_offlinemode = connman_technology_load_offlinemode();
1174 void __connman_technology_cleanup(void)
1178 dbus_connection_unref(connection);