OSDN Git Service

gobex: Add support for multi-response requests (SRM)
authorJohan Hedberg <johan.hedberg@intel.com>
Sun, 3 Jul 2011 10:06:36 +0000 (13:06 +0300)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 4 Dec 2012 21:21:58 +0000 (22:21 +0100)
gobex/gobex.c

index 555d720..cd1ad5a 100644 (file)
@@ -439,11 +439,15 @@ static void parse_connect_data(GObex *obex, GObexPacket *pkt)
 static void handle_response(GObex *obex, GError *err, GObexPacket *rsp)
 {
        struct pending_pkt *p = obex->pending_req;
-       gboolean disconn = err ? TRUE : FALSE;
+       gboolean disconn = err ? TRUE : FALSE, final_rsp = TRUE;
 
        if (rsp != NULL) {
-               guint8 op = g_obex_packet_get_operation(p->pkt, NULL);
-               if (op == G_OBEX_OP_CONNECT)
+               guint8 opcode;
+
+               g_obex_packet_get_operation(rsp, &final_rsp);
+
+               opcode = g_obex_packet_get_operation(p->pkt, NULL);
+               if (opcode == G_OBEX_OP_CONNECT)
                        parse_connect_data(obex, rsp);
        }
 
@@ -457,8 +461,10 @@ static void handle_response(GObex *obex, GError *err, GObexPacket *rsp)
        if (p->cancelled)
                g_error_free(err);
 
-       pending_pkt_free(p);
-       obex->pending_req = NULL;
+       if (final_rsp) {
+               pending_pkt_free(p);
+               obex->pending_req = NULL;
+       }
 
        if (!disconn && g_queue_get_length(obex->tx_queue) > 0)
                enable_tx(obex);