OSDN Git Service

gobex: Allow g_obex_send_rsp to take custom headers
authorJohan Hedberg <johan.hedberg@intel.com>
Mon, 11 Jul 2011 19:28:47 +0000 (22:28 +0300)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 4 Dec 2012 21:22:01 +0000 (22:22 +0100)
gobex/gobex.c
gobex/gobex.h
tools/obex-server-tool.c

index 1a0e048..40757f3 100644 (file)
@@ -483,11 +483,15 @@ immediate_completion:
        return TRUE;
 }
 
-gboolean g_obex_send_rsp(GObex *obex, guint8 rspcode, GError **err)
+gboolean g_obex_send_rsp(GObex *obex, guint8 rspcode, GError **err,
+                                               guint8 first_hdr_type, ...)
 {
        GObexPacket *rsp;
+       va_list args;
 
-       rsp = g_obex_packet_new(rspcode, TRUE, G_OBEX_HDR_INVALID);
+       va_start(args, first_hdr_type);
+       rsp = g_obex_packet_new_valist(rspcode, TRUE, first_hdr_type, args);
+       va_end(args);
 
        return g_obex_send(obex, rsp, err);
 }
index 7c2d4b7..a8424f3 100644 (file)
@@ -49,7 +49,8 @@ guint g_obex_send_req(GObex *obex, GObexPacket *req, gint timeout,
 gboolean g_obex_cancel_req(GObex *obex, guint req_id,
                                                gboolean remove_callback);
 
-gboolean g_obex_send_rsp(GObex *obex, guint8 rspcode, GError **err);
+gboolean g_obex_send_rsp(GObex *obex, guint8 rspcode, GError **err,
+                                               guint8 first_hdr_type, ...);
 
 void g_obex_set_disconnect_function(GObex *obex, GObexFunc func,
                                                        gpointer user_data);
index a4cf327..3b71ac0 100644 (file)
@@ -127,7 +127,8 @@ static void handle_put(GObex *obex, GObexPacket *req, gpointer user_data)
        if (data->fd < 0) {
                g_printerr("open(%s): %s\n", name, strerror(errno));
                g_free(data);
-               g_obex_send_rsp(obex, G_OBEX_RSP_FORBIDDEN, NULL);
+               g_obex_send_rsp(obex, G_OBEX_RSP_FORBIDDEN, NULL,
+                                                       G_OBEX_HDR_INVALID);
                return;
        }
 
@@ -181,7 +182,8 @@ static void handle_get(GObex *obex, GObexPacket *req, gpointer user_data)
        if (data->fd < 0) {
                g_printerr("open(%s): %s\n", name, strerror(errno));
                g_free(data);
-               g_obex_send_rsp(obex, G_OBEX_RSP_FORBIDDEN, NULL);
+               g_obex_send_rsp(obex, G_OBEX_RSP_FORBIDDEN, NULL,
+                                                       G_OBEX_HDR_INVALID);
                return;
        }