From c1f3036eeabe20903d077f5e0069d644d93d5bfd Mon Sep 17 00:00:00 2001 From: Tomasz Bursztyka Date: Wed, 4 Jul 2012 16:48:04 +0300 Subject: [PATCH] gsupplicant: Adapt set country callback to return a result This is necessary for the next coming patches, to fix country setting by interface --- gsupplicant/gsupplicant.h | 4 +++- gsupplicant/supplicant.c | 19 +++++++++---------- plugins/wifi.c | 9 +++++---- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h index 5dc5364..0f586a1 100644 --- a/gsupplicant/gsupplicant.h +++ b/gsupplicant/gsupplicant.h @@ -162,7 +162,9 @@ struct _GSupplicantScanParams { typedef struct _GSupplicantScanParams GSupplicantScanParams; /* global API */ -typedef void (*GSupplicantCountryCallback) (void *user_data); +typedef void (*GSupplicantCountryCallback) (int result, + const char *alpha2, + void *user_data); int g_supplicant_set_country(const char *alpha2, GSupplicantCountryCallback callback, diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c index 1a10291..5b09a9d 100644 --- a/gsupplicant/supplicant.c +++ b/gsupplicant/supplicant.c @@ -2321,6 +2321,7 @@ static DBusHandlerResult g_supplicant_filter(DBusConnection *conn, struct supplicant_regdom { GSupplicantCountryCallback callback; + const char *alpha2; const void *user_data; }; @@ -2328,22 +2329,21 @@ static void country_result(const char *error, DBusMessageIter *iter, void *user_data) { struct supplicant_regdom *regdom = user_data; - char *alpha2; + int result = 0; SUPPLICANT_DBG("Country setting result"); if (user_data == NULL) return; - if (error == NULL) { - alpha2 = (char *)regdom->user_data; - } else { + if (error != NULL) { SUPPLICANT_DBG("Country setting failure %s", error); - alpha2 = NULL; + result = -EINVAL; } if (regdom->callback) - regdom->callback(alpha2); + regdom->callback(result, regdom->alpha2, + (void *) regdom->user_data); g_free(regdom); } @@ -2351,11 +2351,9 @@ static void country_result(const char *error, static void country_params(DBusMessageIter *iter, void *user_data) { struct supplicant_regdom *regdom = user_data; - const char *country; - - country = regdom->user_data; - dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &country); + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, + ®dom->alpha2); } int g_supplicant_set_country(const char *alpha2, @@ -2374,6 +2372,7 @@ int g_supplicant_set_country(const char *alpha2, return -ENOMEM; regdom->callback = callback; + regdom->alpha2 = alpha2; regdom->user_data = user_data; return supplicant_dbus_property_set(SUPPLICANT_PATH, SUPPLICANT_INTERFACE, diff --git a/plugins/wifi.c b/plugins/wifi.c index 06604d5..6be5c0c 100644 --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -1880,21 +1880,22 @@ static int tech_set_tethering(struct connman_technology *technology, return -EOPNOTSUPP; } -static void regdom_callback(void *user_data) +static void regdom_callback(int result, const char *alpha2, void *user_data) { - char *alpha2 = user_data; - DBG(""); if (wifi_technology == NULL) return; + if (result != 0) + alpha2 = NULL; + connman_technology_regdom_notify(wifi_technology, alpha2); } static int tech_set_regdom(struct connman_technology *technology, const char *alpha2) { - return g_supplicant_set_country(alpha2, regdom_callback, alpha2); + return g_supplicant_set_country(alpha2, regdom_callback, NULL); } static struct connman_technology_driver tech_driver = { -- 2.7.4