From d58cb630cfaa01b9dc8b08135cf19f7f73d1caf0 Mon Sep 17 00:00:00 2001 From: Tomasz Bursztyka Date: Mon, 25 Feb 2013 14:11:05 +0200 Subject: [PATCH] technology: Provide a function to get WiFi tethering information --- include/technology.h | 3 +++ src/technology.c | 55 +++++++++++++++++++++++++++++++------------- 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/include/technology.h b/include/technology.h index f3fab203..71314f27 100644 --- a/include/technology.h +++ b/include/technology.h @@ -42,6 +42,9 @@ int connman_technology_set_regdom(const char *alpha2); void connman_technology_regdom_notify(struct connman_technology *technology, const char *alpha2); +connman_bool_t connman_technology_get_wifi_tethering(const char **ssid, + const char **psk); + struct connman_technology_driver { const char *name; enum connman_service_type type; diff --git a/src/technology.c b/src/technology.c index 3f41d7f3..f15fbd93 100644 --- a/src/technology.c +++ b/src/technology.c @@ -315,6 +315,45 @@ int connman_technology_set_regdom(const char *alpha2) return 0; } +static struct connman_technology *technology_find(enum connman_service_type type) +{ + GSList *list; + + DBG("type %d", type); + + for (list = technology_list; list; list = list->next) { + struct connman_technology *technology = list->data; + + if (technology->type == type) + return technology; + } + + return NULL; +} + +connman_bool_t connman_technology_get_wifi_tethering(const char **ssid, + const char **psk) +{ + struct connman_technology *technology; + + if (ssid == NULL || psk == NULL) + return FALSE; + + *ssid = *psk = NULL; + + technology = technology_find(CONNMAN_SERVICE_TYPE_WIFI); + if (technology == NULL) + return FALSE; + + if (technology->tethering == FALSE) + return FALSE; + + *ssid = technology->tethering_ident; + *psk = technology->tethering_passphrase; + + return TRUE; +} + static void free_rfkill(gpointer data) { struct connman_rfkill *rfkill = data; @@ -820,22 +859,6 @@ static DBusMessage *set_property(DBusConnection *conn, return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); } -static struct connman_technology *technology_find(enum connman_service_type type) -{ - GSList *list; - - DBG("type %d", type); - - for (list = technology_list; list; list = list->next) { - struct connman_technology *technology = list->data; - - if (technology->type == type) - return technology; - } - - return NULL; -} - static void reply_scan_pending(struct connman_technology *technology, int err) { DBusMessage *reply; -- 2.34.1