tools: Add support for broken WISPr responses
[framework/connectivity/connman.git] / tools / supplicant-dbus.c
index c95f2e7..96d9aa8 100644 (file)
@@ -2,7 +2,7 @@
  *
  *  Connection Manager
  *
- *  Copyright (C) 2007-2009  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2007-2010  Intel Corporation. All rights reserved.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License version 2 as
@@ -110,8 +110,6 @@ static void property_get_all_reply(DBusPendingCall *call, void *user_data)
        DBusMessageIter iter;
 
        reply = dbus_pending_call_steal_reply(call);
-       if (reply == NULL)
-               return;
 
        if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR)
                goto done;
@@ -127,6 +125,8 @@ static void property_get_all_reply(DBusPendingCall *call, void *user_data)
 
 done:
        dbus_message_unref(reply);
+
+       dbus_pending_call_unref(call);
 }
 
 int supplicant_dbus_property_get_all(const char *path, const char *interface,
@@ -195,8 +195,6 @@ static void property_set_reply(DBusPendingCall *call, void *user_data)
        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);
@@ -211,6 +209,8 @@ static void property_set_reply(DBusPendingCall *call, void *user_data)
 
 done:
        dbus_message_unref(reply);
+
+       dbus_pending_call_unref(call);
 }
 
 int supplicant_dbus_property_set(const char *path, const char *interface,
@@ -292,22 +292,20 @@ static void method_call_reply(DBusPendingCall *call, void *user_data)
        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;
+       dbus_message_iter_init(reply, &iter);
 
        if (data->function != NULL)
                data->function(error, &iter, data->user_data);
 
-done:
        dbus_message_unref(reply);
+
+       dbus_pending_call_unref(call);
 }
 
 int supplicant_dbus_method_call(const char *path,
@@ -324,10 +322,7 @@ int supplicant_dbus_method_call(const char *path,
        if (connection == NULL)
                return -EINVAL;
 
-       if (path == NULL || interface == NULL)
-               return -EINVAL;
-
-       if (method == NULL || setup == NULL)
+       if (path == NULL || interface == NULL || method == NULL)
                return -EINVAL;
 
        data = dbus_malloc0(sizeof(*data));
@@ -344,7 +339,8 @@ int supplicant_dbus_method_call(const char *path,
        dbus_message_set_auto_start(message, FALSE);
 
        dbus_message_iter_init_append(message, &iter);
-       setup(&iter, user_data);
+       if (setup != NULL)
+               setup(&iter, user_data);
 
        if (dbus_connection_send_with_reply(connection, message,
                                                &call, TIMEOUT) == FALSE) {