From 3352a36c11596e49962abe2b60e5094f4ea385ea Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 11 Jul 2011 22:28:47 +0300 Subject: [PATCH] gobex: Allow g_obex_send_rsp to take custom headers --- gobex/gobex.c | 8 ++++++-- gobex/gobex.h | 3 ++- tools/obex-server-tool.c | 6 ++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/gobex/gobex.c b/gobex/gobex.c index 1a0e048a1..40757f383 100644 --- a/gobex/gobex.c +++ b/gobex/gobex.c @@ -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); } diff --git a/gobex/gobex.h b/gobex/gobex.h index 7c2d4b799..a8424f32e 100644 --- a/gobex/gobex.h +++ b/gobex/gobex.h @@ -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); diff --git a/tools/obex-server-tool.c b/tools/obex-server-tool.c index a4cf32780..3b71ac019 100644 --- a/tools/obex-server-tool.c +++ b/tools/obex-server-tool.c @@ -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; } -- 2.47.3