Index: openobex_svn/trunk/lib/obex_main.c
===================================================================
--- openobex_svn/trunk/lib/obex_main.c	(revision 304)
+++ openobex_svn/trunk/lib/obex_main.c	(working copy)
@@ -174,17 +174,14 @@
  *    Deliver an event to app.
  *
  */
-void obex_deliver_event(obex_t *self, int event, int cmd, int rsp, int del)
+void obex_deliver_event(obex_t *self, int event, int cmd, int rsp, int del, int mode)
 {
 	obex_object_t *object = self->object;
 
 	if (del == TRUE)
 		self->object = NULL;
 
-	if (self->state & MODE_SRV)
-		self->eventcb(self, object, OBEX_MODE_SERVER, event, cmd, rsp);
-	else
-		self->eventcb(self, object, OBEX_MODE_CLIENT, event, cmd, rsp);
+	self->eventcb(self, object, mode, event, cmd, rsp);
 	
 	if (del == TRUE)
 		obex_object_delete(object);
@@ -263,7 +260,7 @@
 
 		/* Check if we are still connected */
 		if (actual <= 0)	{
-			obex_deliver_event(self, OBEX_EV_LINKERR, 0, 0, TRUE);
+			obex_deliver_event(self, OBEX_EV_LINKERR, 0, 0, TRUE, self->state & MODE_SRV ? OBEX_MODE_SERVER : OBEX_MODE_CLIENT);
 			return actual;
 		}
 		buf += actual;
@@ -283,7 +280,7 @@
 
 			/* Check if we are still connected */
 			if (actual <= 0)	{
-				obex_deliver_event(self, OBEX_EV_LINKERR, 0, 0, TRUE);
+				obex_deliver_event(self, OBEX_EV_LINKERR, 0, 0, TRUE, self->state & MODE_SRV ? OBEX_MODE_SERVER : OBEX_MODE_CLIENT);
 				return actual;
 			}
 		}
@@ -349,13 +346,13 @@
 	/* Abort request without sending abort */
 	if (!nice) {
 		/* Deliver event will delete the object */
-		obex_deliver_event(self, OBEX_EV_ABORT, 0, 0, TRUE);
+		obex_deliver_event(self, OBEX_EV_ABORT, 0, 0, TRUE, self->state & MODE_SRV ? OBEX_MODE_SERVER : OBEX_MODE_CLIENT);
 		buf_reuse(self->tx_msg);
 		buf_reuse(self->rx_msg);
 		/* Since we didn't send ABORT to peer we are out of sync
 		   and need to disconnect transport immediately, so we signal
 		   link error to app */
-		obex_deliver_event(self, OBEX_EV_LINKERR, 0, 0, FALSE);
+		obex_deliver_event(self, OBEX_EV_LINKERR, 0, 0, FALSE, self->state & MODE_SRV ? OBEX_MODE_SERVER : OBEX_MODE_CLIENT);
 		return 1;
 	} else {
 		obex_object_t *object;
Index: openobex_svn/trunk/lib/obex_main.h
===================================================================
--- openobex_svn/trunk/lib/obex_main.h	(revision 304)
+++ openobex_svn/trunk/lib/obex_main.h	(working copy)
@@ -148,7 +148,7 @@
 int obex_create_socket(obex_t *self, int domain);
 int obex_delete_socket(obex_t *self, int fd);
 
-void obex_deliver_event(obex_t *self, int event, int cmd, int rsp, int del);
+void obex_deliver_event(obex_t *self, int event, int cmd, int rsp, int del, int mode);
 int obex_data_indication(obex_t *self, uint8_t *buf, int buflen);
 
 void obex_response_request(obex_t *self, uint8_t opcode);
Index: openobex_svn/trunk/lib/obex_object.c
===================================================================
--- openobex_svn/trunk/lib/obex_object.c	(revision 304)
+++ openobex_svn/trunk/lib/obex_object.c	(working copy)
@@ -302,7 +302,7 @@
 			/* Ask app for more data if no more */
 			object->s_offset = 0;
 			object->s_buf = NULL;
-			obex_deliver_event(self, OBEX_EV_STREAMEMPTY, 0, 0, FALSE);
+			obex_deliver_event(self, OBEX_EV_STREAMEMPTY, 0, 0, FALSE, self->state & MODE_SRV ? OBEX_MODE_SERVER : OBEX_MODE_CLIENT);
 			DEBUG(4, "s_len=%d, s_stop = %d\n",
 						object->s_len, object->s_stop);
 			/* End of stream ?*/
@@ -667,13 +667,13 @@
 	}
 	
 	/* Notify app that data has arrived */
-	obex_deliver_event(self, OBEX_EV_STREAMAVAIL, 0, 0, FALSE);
+	obex_deliver_event(self, OBEX_EV_STREAMAVAIL, 0, 0, FALSE, self->state & MODE_SRV ? OBEX_MODE_SERVER : OBEX_MODE_CLIENT);
 	
 	/* If send send EOS to app */
 	if(hi == OBEX_HDR_BODY_END && len != 0) {
 		object->s_buf = source;
 		object->s_len = 0;
-		obex_deliver_event(self, OBEX_EV_STREAMAVAIL, 0, 0, FALSE);
+		obex_deliver_event(self, OBEX_EV_STREAMAVAIL, 0, 0, FALSE, self->state & MODE_SRV ? OBEX_MODE_SERVER : OBEX_MODE_CLIENT);
 	}
 }
 
@@ -940,9 +940,9 @@
  		return 0;
 
 	if (obex_object_send(self, object, TRUE, FALSE) < 0)
-		obex_deliver_event(self, OBEX_EV_LINKERR, object->opcode, 0, TRUE);
+		obex_deliver_event(self, OBEX_EV_LINKERR, object->opcode, 0, TRUE, self->state & MODE_SRV ? OBEX_MODE_SERVER : OBEX_MODE_CLIENT);
 	else
-		obex_deliver_event(self, OBEX_EV_PROGRESS, object->opcode, 0, FALSE);
+		obex_deliver_event(self, OBEX_EV_PROGRESS, object->opcode, 0, FALSE, self->state & MODE_SRV ? OBEX_MODE_SERVER : OBEX_MODE_CLIENT);
 
 	self->state = MODE_CLI | STATE_REC;
 	object->first_packet_sent = 1;
Index: openobex_svn/trunk/lib/obex_client.c
===================================================================
--- openobex_svn/trunk/lib/obex_client.c	(revision 304)
+++ openobex_svn/trunk/lib/obex_client.c	(working copy)
@@ -67,7 +67,7 @@
 		   every fragment sent so we have to accept that too.*/
 		if(rsp != OBEX_RSP_SUCCESS && rsp != OBEX_RSP_CONTINUE) {
 			DEBUG(0, "STATE_SEND. request not accepted.\n");
-			obex_deliver_event(self, OBEX_EV_REQDONE, self->object->opcode, rsp, TRUE);
+			obex_deliver_event(self, OBEX_EV_REQDONE, self->object->opcode, rsp, TRUE, OBEX_MODE_CLIENT);
 			/* This is not an Obex error, it is just that the peer
 			 * doesn't accept the request, so return 0 - Jean II */
 			return 0;
@@ -98,10 +98,10 @@
 			if((self->object->opcode == OBEX_CMD_CONNECT) ||
 			   (obex_object_receive(self, msg) < 0))	{
 				self->state = MODE_SRV | STATE_IDLE;
-				obex_deliver_event(self, OBEX_EV_PARSEERR, self->object->opcode, 0, TRUE);
+				obex_deliver_event(self, OBEX_EV_PARSEERR, self->object->opcode, 0, TRUE, OBEX_MODE_CLIENT);
 				return -1;
 			}
-			obex_deliver_event(self, OBEX_EV_UNEXPECTED, self->object->opcode, 0, FALSE);
+			obex_deliver_event(self, OBEX_EV_UNEXPECTED, self->object->opcode, 0, FALSE, OBEX_MODE_CLIENT);
 			/* Note : we may want to get rid of received header,
 			 * however they are mixed with legitimate headers,
 			 * and the user may expect to consult them later.
@@ -117,11 +117,11 @@
 		if(ret < 0) {
 			/* Error while sending */
 			self->state = MODE_CLI | STATE_IDLE;
-			obex_deliver_event(self, OBEX_EV_LINKERR, self->object->opcode, 0, TRUE);
+			obex_deliver_event(self, OBEX_EV_LINKERR, self->object->opcode, 0, TRUE, OBEX_MODE_CLIENT);
 		}
 		else if (ret == 0) {
 			/* Some progress made */			
-			obex_deliver_event(self, OBEX_EV_PROGRESS, self->object->opcode, 0, FALSE);
+			obex_deliver_event(self, OBEX_EV_PROGRESS, self->object->opcode, 0, FALSE, OBEX_MODE_CLIENT);
                 	self->state = MODE_CLI | STATE_SEND;
 		}
                 else {
@@ -141,7 +141,7 @@
 			DEBUG(2, "We expect a connect-rsp\n");
 			if(obex_parse_connect_header(self, msg) < 0)	{
 				self->state = MODE_SRV | STATE_IDLE;
-				obex_deliver_event(self, OBEX_EV_PARSEERR, self->object->opcode, 0, TRUE);
+				obex_deliver_event(self, OBEX_EV_PARSEERR, self->object->opcode, 0, TRUE, OBEX_MODE_CLIENT);
 				return -1;
 			}
 			self->object->headeroffset=4;
@@ -156,7 +156,7 @@
 		/* Receive any headers */
 		if(obex_object_receive(self, msg) < 0)	{
 			self->state = MODE_SRV | STATE_IDLE;
-			obex_deliver_event(self, OBEX_EV_PARSEERR, self->object->opcode, 0, TRUE);
+			obex_deliver_event(self, OBEX_EV_PARSEERR, self->object->opcode, 0, TRUE, OBEX_MODE_CLIENT);
 			return -1;
 		}
 	
@@ -177,9 +177,9 @@
 			}
 
 			if (obex_object_send(self, self->object, TRUE, FALSE) < 0)
-				obex_deliver_event(self, OBEX_EV_LINKERR, self->object->opcode, 0, TRUE);
+				obex_deliver_event(self, OBEX_EV_LINKERR, self->object->opcode, 0, TRUE, OBEX_MODE_CLIENT);
 			else
-				obex_deliver_event(self, OBEX_EV_PROGRESS, self->object->opcode, 0, FALSE);
+				obex_deliver_event(self, OBEX_EV_PROGRESS, self->object->opcode, 0, FALSE, OBEX_MODE_CLIENT);
 
 			self->object->continue_received = 0;
 		} else {
@@ -188,18 +188,18 @@
 			self->state = MODE_SRV | STATE_IDLE;
 			if (self->object->abort) {
 				if (rsp == OBEX_RSP_SUCCESS)
-					obex_deliver_event(self, OBEX_EV_ABORT, self->object->opcode, rsp, TRUE);
+					obex_deliver_event(self, OBEX_EV_ABORT, self->object->opcode, rsp, TRUE, OBEX_MODE_CLIENT);
 				else
-					obex_deliver_event(self, OBEX_EV_LINKERR, self->object->opcode, rsp, TRUE);
+					obex_deliver_event(self, OBEX_EV_LINKERR, self->object->opcode, rsp, TRUE, OBEX_MODE_CLIENT);
 			}
 			else
-				obex_deliver_event(self, OBEX_EV_REQDONE, self->object->opcode, rsp, TRUE);
+				obex_deliver_event(self, OBEX_EV_REQDONE, self->object->opcode, rsp, TRUE, OBEX_MODE_CLIENT);
 		}
 		break;
        	
        	default:
 		DEBUG(0, "Unknown state\n");		
-		obex_deliver_event(self, OBEX_EV_PARSEERR, rsp, 0, TRUE);
+		obex_deliver_event(self, OBEX_EV_PARSEERR, rsp, 0, TRUE, OBEX_MODE_CLIENT);
 		return -1;
 	}
 
Index: openobex_svn/trunk/lib/obex_transport.c
===================================================================
--- openobex_svn/trunk/lib/obex_transport.c	(revision 304)
+++ openobex_svn/trunk/lib/obex_transport.c	(working copy)
@@ -121,7 +121,7 @@
 			/* Tell the app to perform the OBEX_Accept() */
 			if(self->keepserver)
 				obex_deliver_event(self, OBEX_EV_ACCEPTHINT,
-						   0, 0, FALSE);
+						   0, 0, FALSE, OBEX_MODE_SERVER);
 			/* Otherwise, just disconnect the server */
 			if((ret >= 0) && (! self->keepserver)) {
 				obex_transport_disconnect_server(self);
Index: openobex_svn/trunk/lib/obex_server.c
===================================================================
--- openobex_svn/trunk/lib/obex_server.c	(revision 304)
+++ openobex_svn/trunk/lib/obex_server.c	(working copy)
@@ -84,7 +84,7 @@
 		/* Hint app that something is about to come so that
 		   the app can deny a PUT-like request early, or
 		   set the header-offset */
-		obex_deliver_event(self, OBEX_EV_REQHINT, cmd, 0, FALSE);
+		obex_deliver_event(self, OBEX_EV_REQHINT, cmd, 0, FALSE, OBEX_MODE_SERVER);
 						
 		/* Some commands needs special treatment (data outside headers) */
 		switch(cmd)	{
@@ -93,7 +93,7 @@
 			/* Connect needs some extra special treatment */
 			if(obex_parse_connect_header(self, msg) < 0) {
 				obex_response_request(self, OBEX_RSP_BAD_REQUEST);
-				obex_deliver_event(self, OBEX_EV_PARSEERR, self->object->opcode, 0, TRUE);
+				obex_deliver_event(self, OBEX_EV_PARSEERR, self->object->opcode, 0, TRUE, OBEX_MODE_SERVER);
 				return -1;
 			}
 			self->object->headeroffset = 4;
@@ -115,7 +115,7 @@
 			DEBUG(1, "Got OBEX_ABORT request!\n");
 			obex_response_request(self, OBEX_RSP_SUCCESS);
 			self->state = MODE_SRV | STATE_IDLE;
-			obex_deliver_event(self, OBEX_EV_ABORT, self->object->opcode, cmd, TRUE);
+			obex_deliver_event(self, OBEX_EV_ABORT, self->object->opcode, cmd, TRUE, OBEX_MODE_SERVER);
 			/* This is not an Obex error, it is just that the peer
 			 * aborted the request, so return 0 - Jean II */
 			return 0;
@@ -127,7 +127,7 @@
 			   same as int the first fragment. Bail out! */
 			obex_response_request(self, OBEX_RSP_BAD_REQUEST);
 			self->state = MODE_SRV | STATE_IDLE;
-			obex_deliver_event(self, OBEX_EV_PARSEERR, self->object->opcode, cmd, TRUE);
+			obex_deliver_event(self, OBEX_EV_PARSEERR, self->object->opcode, cmd, TRUE, OBEX_MODE_SERVER);
 			return -1;
 		}
 		
@@ -135,7 +135,7 @@
 		if(obex_object_receive(self, msg) < 0)	{
 			obex_response_request(self, OBEX_RSP_BAD_REQUEST);
 			self->state = MODE_SRV | STATE_IDLE;
-			obex_deliver_event(self, OBEX_EV_PARSEERR, self->object->opcode, 0, TRUE);
+			obex_deliver_event(self, OBEX_EV_PARSEERR, self->object->opcode, 0, TRUE, OBEX_MODE_SERVER);
 			return -1;
 		}
 
@@ -143,7 +143,7 @@
 			/* Let the user decide whether to accept or deny a multi-packet
 			 * request by examining all headers in the first packet */
 			if (!self->object->checked) {
-				obex_deliver_event(self, OBEX_EV_REQCHECK, cmd, 0, FALSE);
+				obex_deliver_event(self, OBEX_EV_REQCHECK, cmd, 0, FALSE, OBEX_MODE_SERVER);
 				self->object->checked = 1;                       
 			}
 
@@ -164,11 +164,11 @@
 		if(!final) {
 			/* As a server, the final bit is always SET- Jean II */
 			if(obex_object_send(self, self->object, FALSE, TRUE) < 0) {
-				obex_deliver_event(self, OBEX_EV_LINKERR, cmd, 0, TRUE);
+				obex_deliver_event(self, OBEX_EV_LINKERR, cmd, 0, TRUE, OBEX_MODE_SERVER);
 				return -1;
 			}			
 			else {
-				obex_deliver_event(self, OBEX_EV_PROGRESS, cmd, 0, FALSE);
+				obex_deliver_event(self, OBEX_EV_PROGRESS, cmd, 0, FALSE, OBEX_MODE_SERVER);
 			}
 			break; /* Stay in this state if not final */
 		}
@@ -182,7 +182,7 @@
 			   this event is delivered the app should append the
 			   headers that should be in the response */
 			if (!deny)
-				obex_deliver_event(self, OBEX_EV_REQ, cmd, 0, FALSE);
+				obex_deliver_event(self, OBEX_EV_REQ, cmd, 0, FALSE, OBEX_MODE_SERVER);
 			self->state = MODE_SRV | STATE_SEND;
 			len = 3; /* Otherwise sanitycheck later will fail */
 		}
@@ -197,7 +197,7 @@
 			DEBUG(1, "Got OBEX_ABORT request!\n");
 			obex_response_request(self, OBEX_RSP_SUCCESS);
 			self->state = MODE_SRV | STATE_IDLE;
-			obex_deliver_event(self, OBEX_EV_ABORT, self->object->opcode, cmd, TRUE);
+			obex_deliver_event(self, OBEX_EV_ABORT, self->object->opcode, cmd, TRUE, OBEX_MODE_SERVER);
 			/* This is not an Obex error, it is just that the peer
 			 * aborted the request, so return 0 - Jean II */
 			return 0;		
@@ -230,10 +230,10 @@
 			   (obex_object_receive(self, msg) < 0))	{
 				obex_response_request(self, OBEX_RSP_BAD_REQUEST);
 				self->state = MODE_SRV | STATE_IDLE;
-				obex_deliver_event(self, OBEX_EV_PARSEERR, self->object->opcode, 0, TRUE);
+				obex_deliver_event(self, OBEX_EV_PARSEERR, self->object->opcode, 0, TRUE, OBEX_MODE_SERVER);
 				return -1;
 			}
-			obex_deliver_event(self, OBEX_EV_UNEXPECTED, self->object->opcode, 0, FALSE);
+			obex_deliver_event(self, OBEX_EV_UNEXPECTED, self->object->opcode, 0, FALSE, OBEX_MODE_SERVER);
 			/* Note : we may want to get rid of received header,
 			 * however they are mixed with legitimate headers,
 			 * and the user may expect to consult them later.
@@ -250,11 +250,11 @@
 		ret = obex_object_send(self, self->object, TRUE, TRUE);
 		if(ret == 0) {
 			/* Made some progress */
-			obex_deliver_event(self, OBEX_EV_PROGRESS, cmd, 0, FALSE);
+			obex_deliver_event(self, OBEX_EV_PROGRESS, cmd, 0, FALSE, OBEX_MODE_SERVER);
 		}
 		else if(ret < 0) {
 			/* Error sending response */
-			obex_deliver_event(self, OBEX_EV_LINKERR, cmd, 0, TRUE);
+			obex_deliver_event(self, OBEX_EV_LINKERR, cmd, 0, TRUE, OBEX_MODE_SERVER);
 			return -1;
 		}
 		else {
@@ -264,14 +264,14 @@
 				self->mtu_tx = OBEX_MINIMUM_MTU;
 			}
 			self->state = MODE_SRV | STATE_IDLE;
-			obex_deliver_event(self, OBEX_EV_REQDONE, cmd, 0, TRUE);
+			obex_deliver_event(self, OBEX_EV_REQDONE, cmd, 0, TRUE, OBEX_MODE_SERVER);
 		}
 		break;
 	
 	default:
 		DEBUG(0, "Unknown state\n");
 		obex_response_request(self, OBEX_RSP_BAD_REQUEST);
-		obex_deliver_event(self, OBEX_EV_PARSEERR, cmd, 0, TRUE);
+		obex_deliver_event(self, OBEX_EV_PARSEERR, cmd, 0, TRUE, OBEX_MODE_SERVER);
 		return -1;
 	}
 	return 0;
