OSDN Git Service

obexd: Use pending request in ListFolders
authorChristian Fetzer <christian.fetzer@bmw-carit.de>
Fri, 13 Sep 2013 15:28:33 +0000 (17:28 +0200)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 16 Sep 2013 09:59:54 +0000 (12:59 +0300)
obexd/client/map.c

index 1b2b25d..29d33fa 100644 (file)
@@ -243,7 +243,7 @@ static void folder_listing_cb(struct obc_session *session,
                                                struct obc_transfer *transfer,
                                                GError *err, void *user_data)
 {
-       struct map_data *map = user_data;
+       struct pending_request *request = user_data;
        GMarkupParseContext *ctxt;
        DBusMessage *reply;
        DBusMessageIter iter, array;
@@ -252,7 +252,7 @@ static void folder_listing_cb(struct obc_session *session,
        int perr;
 
        if (err != NULL) {
-               reply = g_dbus_create_error(map->msg,
+               reply = g_dbus_create_error(request->msg,
                                                ERROR_INTERFACE ".Failed",
                                                "%s", err->message);
                goto done;
@@ -260,14 +260,14 @@ static void folder_listing_cb(struct obc_session *session,
 
        perr = obc_transfer_get_contents(transfer, &contents, &size);
        if (perr < 0) {
-               reply = g_dbus_create_error(map->msg,
+               reply = g_dbus_create_error(request->msg,
                                                ERROR_INTERFACE ".Failed",
                                                "Error reading contents: %s",
                                                strerror(-perr));
                goto done;
        }
 
-       reply = dbus_message_new_method_return(map->msg);
+       reply = dbus_message_new_method_return(request->msg);
        if (reply == NULL)
                return;
 
@@ -285,13 +285,14 @@ static void folder_listing_cb(struct obc_session *session,
 
 done:
        g_dbus_send_message(conn, reply);
-       dbus_message_unref(map->msg);
+       pending_request_free(request);
 }
 
 static DBusMessage *get_folder_listing(struct map_data *map,
                                                        DBusMessage *message,
                                                        GObexApparam *apparam)
 {
+       struct pending_request *request;
        struct obc_transfer *transfer;
        GError *err = NULL;
        DBusMessage *reply;
@@ -304,12 +305,16 @@ static DBusMessage *get_folder_listing(struct map_data *map,
 
        obc_transfer_set_apparam(transfer, apparam);
 
-       if (obc_session_queue(map->session, transfer, folder_listing_cb, map,
-                                                               &err)) {
-               map->msg = dbus_message_ref(message);
-               return NULL;
+       request = pending_request_new(map, message);
+
+       if (!obc_session_queue(map->session, transfer, folder_listing_cb,
+                                                       request, &err)) {
+               pending_request_free(request);
+               goto fail;
        }
 
+       return NULL;
+
 fail:
        reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s",
                                                                err->message);