technology: Provide a function to get WiFi tethering information
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Mon, 25 Feb 2013 12:11:05 +0000 (14:11 +0200)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Tue, 26 Feb 2013 10:37:40 +0000 (12:37 +0200)
include/technology.h
src/technology.c

index f3fab20..71314f2 100644 (file)
@@ -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;
index 3f41d7f..f15fbd9 100644 (file)
@@ -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;