OSDN Git Service

gobex: Fix end of body packets for on-demand headers
authorJohan Hedberg <johan.hedberg@intel.com>
Tue, 5 Jul 2011 15:29:55 +0000 (18:29 +0300)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 4 Dec 2012 21:21:59 +0000 (22:21 +0100)
gobex/gobex-packet.c

index 16d4b7a..e5bf618 100644 (file)
@@ -290,6 +290,15 @@ gssize g_obex_packet_encode(GObexPacket *pkt, guint8 *buf, gsize len)
                if (ret < 0)
                        return ret;
 
+               /* Fix-up on-demand body header type and final bit. This
+                * breaks the layers of abstraction a bit but it's the
+                * simplest way to avoid two consecutive empty packets */
+               if (g_obex_header_get_id(hdr) == G_OBEX_HDR_ID_BODY &&
+                                                               ret == 3) {
+                       buf[0] |= FINAL_BIT;
+                       buf[count] = G_OBEX_HDR_ID_BODY_END;
+               }
+
                count += ret;
        }