Below is the modified patch to invoke the Introspect method with autostart enabled in non-blocking mode and enable wifi plugin if we get the Introspect data successfully.
Please note that I cannot use the existing supplicant_dbus_method_call API to
invoke the Introspect method since the autostart is set to FALSE.The patch adds
a new API supplicant_dbus_get_introspect with an auto_start boolean which will
set the auto_start accordingly. If auto_start is TRUE, it will start
wpa_supplicant if not running.
If we want to avoid adding this new supplicant_dbus_get_introspect API, it is
possible to modify the existing supplicant_dbus_method_call API to take a
auto_start argument which will accordingly set the auto_start. But this would
involve quite a bit of change. Hence I used the approach to add a new
supplicant_dbus_get_introspect API.
Kindly review the below patch:
----
gsupplicant/dbus.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++
gsupplicant/dbus.h | 4 +++
gsupplicant/supplicant.c | 27 +++++++++++++++++++------
3 files changed, 71 insertions(+), 7 deletions(-)
diff --git a/gsupplicant/dbus.c b/gsupplicant/dbus.c
index 53c56ae..32dafd8 100644
--- a/gsupplicant/dbus.c
+++ b/gsupplicant/dbus.c
@@ -450,6 +450,53 @@ int supplicant_dbus_method_call(const char *path,
return 0;
}
+int supplicant_dbus_get_introspect(const dbus_bool_t auto_start,
+ supplicant_dbus_result_function function,
+ void *user_data)
+{
+ struct method_call_data *data;
+ DBusMessage *message;
+ DBusPendingCall *call;
+
+ data = dbus_malloc0(sizeof(*data));
+ if (data == NULL)
+ return -ENOMEM;
+
+ message = dbus_message_new_method_call(SUPPLICANT_SERVICE,
+ SUPPLICANT_PATH,
+ DBUS_INTERFACE_INTROSPECTABLE,
+ "Introspect");
+
+ if (message == NULL)
+ return 0;
+
+ if (auto_start == FALSE)
+ dbus_message_set_auto_start(message, FALSE);
+
+ if (dbus_connection_send_with_reply(connection, message,
+ &call, TIMEOUT) == FALSE) {
+ dbus_message_unref(message);
+ dbus_free(data);
+ return -EIO;
+ }
+
+ if (call == NULL) {
+ dbus_message_unref(message);
+ dbus_free(data);
+ return -EIO;
+ }
+
+ data->function = function;
+ data->user_data = user_data;
+
+ dbus_pending_call_set_notify(call, method_call_reply,
+ data, dbus_free);
+
+ dbus_message_unref(message);
+
+ return 0;
+}
+
void supplicant_dbus_property_append_basic(DBusMessageIter *iter,
const char *key, int type, void *val)
{
diff --git a/gsupplicant/dbus.h b/gsupplicant/dbus.h
index 642e8b1..cfb6740 100644
--- a/gsupplicant/dbus.h
+++ b/gsupplicant/dbus.h
@@ -47,6 +47,10 @@ void supplicant_dbus_property_foreach(DBusMessageIter *iter,
supplicant_dbus_property_function function,
void *user_data);
+int supplicant_dbus_get_introspect(const dbus_bool_t auto_start,
+ supplicant_dbus_result_function function,
+ void *user_data);
+
int supplicant_dbus_property_get_all(const char *path, const char *interface,
supplicant_dbus_property_function function,
void *user_data);
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 322b63d..d0d5e16 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -2387,6 +2387,25 @@ static const char *g_supplicant_rule5 = "type=signal,"
static const char *g_supplicant_rule6 = "type=signal,"
"interface=" SUPPLICANT_INTERFACE ".Interface.Blob";
+static void introspect_result(const char *error, DBusMessageIter *iter,
+ void *user_data)
+{
+ char *introspect_data;
+
+ if (error != NULL)
+ return;
+
+ dbus_message_iter_get_basic(iter, &introspect_data);
+
+ if (introspect_data == NULL)
+ return;
+
+ system_available = TRUE;
+ supplicant_dbus_property_get_all(SUPPLICANT_PATH,
+ SUPPLICANT_INTERFACE,
+ service_property, NULL);
+}
+
int g_supplicant_register(const GSupplicantCallbacks *callbacks)
{
connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
@@ -2420,13 +2439,7 @@ int g_supplicant_register(const GSupplicantCallbacks
*callbacks)
dbus_bus_add_match(connection, g_supplicant_rule6, NULL);
dbus_connection_flush(connection);
- if (dbus_bus_name_has_owner(connection,
- SUPPLICANT_SERVICE, NULL) == TRUE) {
- system_available = TRUE;
- supplicant_dbus_property_get_all(SUPPLICANT_PATH,
- SUPPLICANT_INTERFACE,
- service_property, NULL);
- }
+ supplicant_dbus_get_introspect(TRUE, introspect_result, NULL);
return 0;
}
----
Please do not print this email unless it is absolutely necessary.
The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s) and may
contain proprietary, confidential or privileged information. If you are not the
intended recipient, you should not disseminate, distribute or copy this e-mail.
Please notify the sender immediately and destroy all copies of this message and
any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should
check this email and any attachments for the presence of viruses. The company
accepts no liability for any damage caused by any virus transmitted by this
email.
www.wipro.com
<<winmail.dat>>
_______________________________________________ connman mailing list [email protected] http://lists.connman.net/listinfo/connman
