From a803c3d5d29108d7e40c568022a81c2620474733 Mon Sep 17 00:00:00 2001
From: Chen Congwu <congwu.chen@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

