gobex: Use opcode instead of entire req in g_obex_response

This commit is contained in:
Johan Hedberg 2011-07-04 23:32:43 +03:00 committed by Marcel Holtmann
parent 0fb35029cf
commit 2e49852cce
3 changed files with 9 additions and 5 deletions

View File

@ -801,14 +801,14 @@ static void prepare_connect_rsp(GObex *obex, GObexPacket *rsp)
g_obex_packet_prepend_header(rsp, connid);
}
gboolean g_obex_response(GObex *obex, GObexPacket *req, guint8 rspcode,
gboolean g_obex_response(GObex *obex, guint8 opcode, guint8 rspcode,
GSList *headers, GError **err)
{
GObexPacket *rsp;
rsp = g_obex_packet_new(rspcode, TRUE, headers);
if (g_obex_packet_get_operation(req, NULL) == G_OBEX_OP_CONNECT)
if (opcode == G_OBEX_OP_CONNECT)
prepare_connect_rsp(obex, rsp);
return g_obex_send(obex, rsp, err);

View File

@ -64,7 +64,8 @@ void g_obex_unref(GObex *obex);
guint g_obex_connect(GObex *obex, void *target, gsize target_len,
GObexResponseFunc func, gpointer user_data,
GError **err);
gboolean g_obex_response(GObex *obex, GObexPacket *req, guint8 rspcode,
gboolean g_obex_response(GObex *obex, guint8 opcode, guint8 rspcode,
GSList *headers, GError **err);
#endif /* __GOBEX_H */

View File

@ -63,9 +63,12 @@ static void disconn_func(GObex *obex, GError *err, gpointer user_data)
static void req_func(GObex *obex, GObexPacket *req, gpointer user_data)
{
g_print("Request 0x%02x\n", g_obex_packet_get_operation(req, NULL));
gboolean final;
guint8 op = g_obex_packet_get_operation(req, &final);
g_obex_response(obex, req, G_OBEX_RSP_SUCCESS, NULL, NULL);
g_print("Request 0x%02x%s\n", op, final ? " (final)" : "");
g_obex_response(obex, op, G_OBEX_RSP_SUCCESS, NULL, NULL);
}
static gboolean unix_accept(GIOChannel *chan, GIOCondition cond, gpointer data)