}
struct property_set_data {
+ supplicant_dbus_result_function function;
void *user_data;
};
static void property_set_reply(DBusPendingCall *call, void *user_data)
{
- //struct property_set_data *data = user_data;
+ struct property_set_data *data = user_data;
DBusMessage *reply;
+ DBusMessageIter iter;
+ const char *error;
reply = dbus_pending_call_steal_reply(call);
if (reply == NULL)
return;
+ if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR)
+ error = dbus_message_get_error_name(reply);
+ else
+ error = NULL;
+
+ if (dbus_message_iter_init(reply, &iter) == FALSE)
+ goto done;
+
+ if (data->function != NULL)
+ data->function(error, &iter, data->user_data);
+
+done:
dbus_message_unref(reply);
}
int supplicant_dbus_property_set(const char *path, const char *interface,
const char *key, const char *signature,
- supplicant_dbus_value_function function,
+ supplicant_dbus_setup_function setup,
+ supplicant_dbus_result_function function,
void *user_data)
{
struct property_set_data *data;
if (path == NULL || interface == NULL)
return -EINVAL;
+ if (key == NULL || signature == NULL || setup == NULL)
+ return -EINVAL;
+
data = dbus_malloc0(sizeof(*data));
if (data == NULL)
return -ENOMEM;
dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
signature, &value);
- if (function != NULL)
- function(&value, user_data);
+ setup(&value, user_data);
dbus_message_iter_close_container(&iter, &value);
if (dbus_connection_send_with_reply(connection, message,
return -EIO;
}
+ data->function = function;
data->user_data = user_data;
dbus_pending_call_set_notify(call, property_set_reply,
typedef void (* supplicant_dbus_property_function) (const char *key,
DBusMessageIter *iter, void *user_data);
-typedef void (* supplicant_dbus_value_function) (DBusMessageIter *iter,
+typedef void (* supplicant_dbus_setup_function) (DBusMessageIter *iter,
void *user_data);
+typedef void (* supplicant_dbus_result_function) (const char *error,
+ DBusMessageIter *iter, void *user_data);
+
void supplicant_dbus_setup(DBusConnection *conn);
void supplicant_dbus_array_foreach(DBusMessageIter *iter,
int supplicant_dbus_property_set(const char *path, const char *interface,
const char *key, const char *signature,
- supplicant_dbus_value_function function,
+ supplicant_dbus_setup_function setup,
+ supplicant_dbus_result_function function,
void *user_data);
eap_methods = 0;
}
+static void debug_level_result(const char *error,
+ DBusMessageIter *iter, void *user_data)
+{
+ if (error != NULL)
+ DBG("debug level failure: %s", error);
+}
+
static void add_debug_level(DBusMessageIter *iter, void *user_data)
{
dbus_int32_t level = GPOINTER_TO_UINT(user_data);
void supplicant_set_debug_level(unsigned int level)
{
supplicant_dbus_property_set(SUPPLICANT_PATH, SUPPLICANT_INTERFACE,
- "DebugParams", "(ibb)",
- add_debug_level, GUINT_TO_POINTER(level));
+ "DebugParams", "(ibb)", add_debug_level,
+ debug_level_result, GUINT_TO_POINTER(level));
}
static void add_show_timestamps(DBusMessageIter *iter, void *user_data)
void supplicant_set_debug_show_timestamps(dbus_bool_t enabled)
{
supplicant_dbus_property_set(SUPPLICANT_PATH, SUPPLICANT_INTERFACE,
- "DebugParams", "(ibb)",
- add_show_timestamps, GUINT_TO_POINTER(enabled));
+ "DebugParams", "(ibb)", add_show_timestamps,
+ NULL, GUINT_TO_POINTER(enabled));
}