Hello, I think I have found a bug in obex_object_resume for server side role: the cmd code is wrong when delivering events.
I am using obexd as the server for a syncml service (developed by Forrest,Zhao). While I am testing, I found obexd received an event with a wrong cmd code. The root cause is from obex_object_resume. For the server side role, it is sending response. From the comments in obex_object.h: "The opcode fields are used as command when sending and response when receiving" Here opcode should stands for response code (as a server it is receiving) and should not be used as cmd code delivering to application. Here is my patch, it solved my problem. Could someone have a look to see whether this is the right direction? ------------- >From a803c3d5d29108d7e40c568022a81c2620474733 Mon Sep 17 00:00:00 2001 From: Chen Congwu <congwu.c...@intel.com> Date: Thu, 29 Oct 2009 10:46:43 +0800 Subject: [PATCH] obex_object_resume: fix the cmd code when delivering events for server case At server side, it is sending response to client so the opcode is the response code instead of the real cmd code. Should use cmd field instead. While at client side, it is sending request to server so the opcode should use opcode. --- lib/obex_object.c | 23 +++++++++++++++++------ 1 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/obex_object.c b/lib/obex_object.c index 1073c97..3b5b250 100644 --- a/lib/obex_object.c +++ b/lib/obex_object.c @@ -923,19 +923,30 @@ int obex_object_resume(obex_t *self, obex_object_t *object) ret = obex_object_send(self, object, TRUE, FALSE); if (ret < 0) { - obex_deliver_event(self, OBEX_EV_LINKERR, - object->opcode & ~OBEX_FINAL, 0, TRUE); + if (self->state & MODE_SRV) { + obex_deliver_event(self, OBEX_EV_LINKERR, + object->cmd, 0, TRUE); + } else { + obex_deliver_event(self, OBEX_EV_LINKERR, + object->opcode & ~OBEX_FINAL, 0, TRUE); + } return -1; } else if (ret == 0) { - obex_deliver_event(self, OBEX_EV_PROGRESS, - object->opcode & ~OBEX_FINAL, 0, - FALSE); + if (self->state & MODE_SRV) { + obex_deliver_event(self, OBEX_EV_PROGRESS, + object->cmd, 0, + FALSE); + } else { + obex_deliver_event(self, OBEX_EV_PROGRESS, + object->opcode & ~OBEX_FINAL, 0, + FALSE); + } object->first_packet_sent = 1; object->continue_received = 0; } else { if (self->state & MODE_SRV) { obex_deliver_event(self, OBEX_EV_REQDONE, - object->opcode & ~OBEX_FINAL, + object->cmd, 0, TRUE); self->state = MODE_SRV | STATE_IDLE; return 0; -- 1.6.0.4 Best Regards, Congwu
0001-obex_object_resume-fix-the-cmd-code-when-delivering.patch
Description: 0001-obex_object_resume-fix-the-cmd-code-when-delivering.patch
------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference
_______________________________________________ Openobex-users mailing list Openobex-users@lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/openobex-users