Hendrik Sattler | 15 Jul 2011 18:45
Picon

Summary of all current patches

Hi,

this is a list of all the patches pending on my side. It also include Iain's
patches to make it easier.

You can find all of these patches in my gitorious repository in the "testing"
branch.

The first 11 patches are strictly needed.

Patches 22-45 are the rework of the state machine. These are not fully tested
(some test app adaptions are still needed) but show the direction it is going.
The intention is to utilize non-blocking sockets and remove a lot of internal
hacks (e.g. the current abort and resume code).

HS

------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
Ries, the creator of the Lean Startup Methodology on "Lean Startup 
Secrets Revealed." This video shows you how to validate your ideas, 
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 01/46] Use bt_addr_t type consistently for BtOBEX_ functions

From: Iain Hibbert <plunky <at> netbsd.org>

---
 lib/obex.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/obex.c b/lib/obex.c
index 165fcb8..5e5fb31 100644
--- a/lib/obex.c
+++ b/lib/obex.c
 <at>  <at>  -1058,7 +1058,7  <at>  <at>  int CALLAPI IrOBEX_TransportConnect(obex_t *self, const char *service)
 	An easier server function to use for Bluetooth (Bluetooth OBEX) only.
  */
 LIB_SYMBOL
-int CALLAPI BtOBEX_ServerRegister(obex_t *self, bdaddr_t *src, uint8_t channel)
+int CALLAPI BtOBEX_ServerRegister(obex_t *self, bt_addr_t *src, uint8_t channel)
 {
 	DEBUG(3, "\n");

 <at>  <at>  -1085,8 +1085,8  <at>  <at>  int CALLAPI BtOBEX_ServerRegister(obex_t *self, bdaddr_t *src, uint8_t channel)
 	An easier connect function to use for Bluetooth (Bluetooth OBEX) only.
  */
 LIB_SYMBOL
-int CALLAPI BtOBEX_TransportConnect(obex_t *self, bdaddr_t *src,
-					bdaddr_t *dst, uint8_t channel)
+int CALLAPI BtOBEX_TransportConnect(obex_t *self, bt_addr_t *src,
+					bt_addr_t *dst, uint8_t channel)
 {
 	DEBUG(4, "\n");

(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 02/46] Use const for bt_addr_t in BtOBEX_ functions

From: Iain Hibbert <plunky <at> netbsd.org>

(For NetBSD at least, the BDADDR_ANY that is passed to
these functions is defined as a const)
---
 include/openobex/obex.h |    4 ++--
 lib/obex.c              |    6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/openobex/obex.h b/include/openobex/obex.h
index f948113..1e9e0d7 100644
--- a/include/openobex/obex.h
+++ b/include/openobex/obex.h
 <at>  <at>  -141,8 +141,8  <at>  <at>  OPENOBEX_SYMBOL(int) IrOBEX_TransportConnect(obex_t *self, const char *service);
 #    define bt_addr_t unsigned long
 #  endif
 #endif
-OPENOBEX_SYMBOL(int) BtOBEX_ServerRegister(obex_t *self, bt_addr_t *src, uint8_t channel);
-OPENOBEX_SYMBOL(int) BtOBEX_TransportConnect(obex_t *self, bt_addr_t *src, bt_addr_t *dst,
uint8_t channel);
+OPENOBEX_SYMBOL(int) BtOBEX_ServerRegister(obex_t *self, const bt_addr_t *src, uint8_t channel);
+OPENOBEX_SYMBOL(int) BtOBEX_TransportConnect(obex_t *self, const bt_addr_t *src, const bt_addr_t
*dst, uint8_t channel);

 /*
  * OBEX File API
diff --git a/lib/obex.c b/lib/obex.c
index 5e5fb31..874cfcd 100644
--- a/lib/obex.c
+++ b/lib/obex.c
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 03/46] Fix up bt_addr_t definition

From: Iain Hibbert <plunky <at> netbsd.org>

We need to detect the presence of "Bluetooth Device Address" type
in order to provide the BtOBEX_ function prototypes, which needs
to be from a header included prior to <openobex/obex.h>
---
 include/openobex/obex.h |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/include/openobex/obex.h b/include/openobex/obex.h
index 1e9e0d7..6dda861 100644
--- a/include/openobex/obex.h
+++ b/include/openobex/obex.h
 <at>  <at>  -131,18 +131,25  <at>  <at>  OPENOBEX_SYMBOL(int) IrOBEX_TransportConnect(obex_t *self, const char *service);
  * Bluetooth OBEX API
  */
 #if !defined(bt_addr_t)
-#  if defined(SOL_RFCOMM)
-#    if defined(_WIN32) /* Windows */
-#      define bt_addr_t BTH_ADDR
-#    else /* Linux, FreeBSD, NetBSD */
-#      define bt_addr_t bdaddr_t
+#  if defined(_WIN32)
+#    if defined(BTH_ADDR_NULL)
+#      define bt_addr_t	BTH_ADDR
+#    endif
+#  elif defined(__FreeBSD__)
+#    if defined(NG_HCI_BDADDR_ANY)
+#      define bt_addr_t	bdaddr_t
+#    endif
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 04/46] Remove spurious ;

From: Iain Hibbert <plunky <at> netbsd.org>

---
 lib/customtrans.c |    2 +-
 lib/inobex.c      |    2 +-
 lib/irobex.c      |    2 +-
 lib/obex_object.c |    2 +-
 lib/usb1obex.c    |    2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/customtrans.c b/lib/customtrans.c
index 0040550..20e264c 100644
--- a/lib/customtrans.c
+++ b/lib/customtrans.c
 <at>  <at>  -115,4 +115,4  <at>  <at>  int custom_register(obex_t *self, const obex_ctrans_t *in)
 void custom_get_ops(struct obex_transport_ops* ops)
 {
 	ops->clone = &custom_clone;
-};
+}
diff --git a/lib/inobex.c b/lib/inobex.c
index d7a450a..4ae2b61 100644
--- a/lib/inobex.c
+++ b/lib/inobex.c
 <at>  <at>  -410,4 +410,4  <at>  <at>  void inobex_get_ops(struct obex_transport_ops* ops)
 	ops->server.disconnect = &inobex_disconnect_server;
 	ops->client.connect = &inobex_connect_request;
 	ops->client.disconnect = &inobex_disconnect_request;
-};
+}
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 05/46] Don't use BEFORE for include path

From: Iain Hibbert <plunky <at> netbsd.org>

---
 lib/CMakeLists.txt |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 0110db4..6efa6d0 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
 <at>  <at>  -106,7 +106,7  <at>  <at>  if ( OPENOBEX_USB )
   list ( APPEND openobex_LIBRARIES
     ${LibUSB_LIBRARIES}
   )
-  include_directories ( BEFORE SYSTEM ${LibUSB_INCLUDE_DIRS} )
+  include_directories ( SYSTEM ${LibUSB_INCLUDE_DIRS} )
   if ( LibUSB_VERSION_1.0 )
     list ( APPEND SOURCES
       usb1obex.c
--

-- 
1.7.5.4

------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
Ries, the creator of the Lean Startup Methodology on "Lean Startup 
Secrets Revealed." This video shows you how to validate your ideas, 
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 06/46] Fix spelling mistake

From: Iain Hibbert <plunky <at> netbsd.org>

---
 CMakeModules/FindBluetooth.cmake |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/CMakeModules/FindBluetooth.cmake b/CMakeModules/FindBluetooth.cmake
index a62032d..9d82a84 100644
--- a/CMakeModules/FindBluetooth.cmake
+++ b/CMakeModules/FindBluetooth.cmake
 <at>  <at>  -73,7 +73,7  <at>  <at>  elseif ( CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" )
   mark_as_advanced ( Bluetooth_LIBRARIES )

   if ( Bluetooth_INCLUDE_DIRS )
-    set ( CMAKE_REQUIRED_INCLUDES ${Bluetooth_INLUDE_DIRS} )
+    set ( CMAKE_REQUIRED_INCLUDES ${Bluetooth_INCLUDE_DIRS} )
     CHECK_C_SOURCE_COMPILES (
       "#include <bluetooth.h>
        int main () {
 <at>  <at>  -102,7 +102,7  <at>  <at>  elseif ( CMAKE_SYSTEM_NAME STREQUAL "NetBSD" )
   mark_as_advanced ( Bluetooth_LIBRARIES )

   if ( Bluetooth_INCLUDE_DIRS )
-    set ( CMAKE_REQUIRED_INCLUDES ${Bluetooth_INLUDE_DIRS} )
+    set ( CMAKE_REQUIRED_INCLUDES ${Bluetooth_INCLUDE_DIRS} )
     CHECK_C_SOURCE_COMPILES (
       "#include <bluetooth.h>
        int main () {
--

-- 
1.7.5.4
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 07/46] Add function buf_empty() and use it to fix send bug

If non-blocking file descriptors or sockets are used, it can happen that
incomplete message get sent.
---
 lib/databuffer.c |    7 +++++++
 lib/databuffer.h |    1 +
 lib/obex_main.c  |    2 +-
 3 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/lib/databuffer.c b/lib/databuffer.c
index 1c43324..72bd4ca 100644
--- a/lib/databuffer.c
+++ b/lib/databuffer.c
 <at>  <at>  -113,6 +113,13  <at>  <at>  size_t buf_total_size(const buf_t *p)
 	return p->head_avail + p->data_avail + p->tail_avail + p->data_size;
 }

+int buf_empty(const buf_t *p)
+{
+	if (!p)
+		return 1;
+	return (p->data_size == 0);
+}
+
 void buf_resize(buf_t *p, size_t new_size)
 {
 	uint8_t *tmp;
diff --git a/lib/databuffer.h b/lib/databuffer.h
index f55a056..2ef8204 100644
--- a/lib/databuffer.h
+++ b/lib/databuffer.h
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 08/46] Fix BODY_END header and its debug message

---
 lib/obex_object.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/obex_object.c b/lib/obex_object.c
index 395c5ff..2773789 100644
--- a/lib/obex_object.c
+++ b/lib/obex_object.c
 <at>  <at>  -412,12 +412,14  <at>  <at>  static int send_body(obex_object_t *object, struct obex_header_element *h,
 		/* We have completely filled the tx-buffer */
 		actual = tx_left;
 	} else {
-		DEBUG(4, "Add BODY_END header\n");
-
-		if (slist_has_more(object->tx_headerq))
-			hdr->hi = OBEX_HDR_BODY_END;
-		else
+		if (slist_has_more(object->tx_headerq)) {
+			DEBUG(4, "Add BODY header\n");
 			hdr->hi = OBEX_HDR_BODY;
+		} else {
+			DEBUG(4, "Add BODY_END header\n");
+			hdr->hi = OBEX_HDR_BODY_END;
+		}
+
 		hdr->hl = htons((uint16_t)(h->buf->data_size + sizeof(*hdr)));
 		buf_insert_end(txmsg, h->buf->data, h->buf->data_size);
 		actual = h->buf->data_size;
--

-- 
1.7.5.4
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 09/46] Fix behaviour of STREAM send functionality

---
 lib/obex_object.c |   35 ++++++++++++++++-------------------
 1 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/lib/obex_object.c b/lib/obex_object.c
index 2773789..3fcd10a 100644
--- a/lib/obex_object.c
+++ b/lib/obex_object.c
 <at>  <at>  -307,7 +307,7  <at>  <at>  static int send_stream(obex_t *self,
 	actual = sizeof(*hdr);

 	do {
-		if (object->s_len == 0) {
+		if (object->s_len == 0 && !object->s_stop) {
 			/* Ask app for more data if no more */
 			object->s_offset = 0;
 			object->s_buf = NULL;
 <at>  <at>  -315,20 +315,9  <at>  <at>  static int send_stream(obex_t *self,
 								0, FALSE);
 			DEBUG(4, "s_len=%d, s_stop = %d\n",
 						object->s_len, object->s_stop);
-			/* End of stream ?*/
-			if (object->s_stop)
-				break;
-
-			/* User suspended and didn't provide any new data */
-			if (object->suspend && object->s_buf == NULL)
-				break;
-
-			/* Error ?*/
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 29/46] Cleanup obex_object_resume()

Now that the multi-level state machine is used, the resume function can be
simplified a lot. To actually continue now, you have to call the
OBEX_HandleInput() function.
---
 lib/obex.c        |    2 +-
 lib/obex_object.c |   45 +++++++--------------------------------------
 lib/obex_object.h |    2 +-
 3 files changed, 9 insertions(+), 40 deletions(-)

diff --git a/lib/obex.c b/lib/obex.c
index 5e16fc4..3aa6bac 100644
--- a/lib/obex.c
+++ b/lib/obex.c
 <at>  <at>  -575,7 +575,7  <at>  <at>  LIB_SYMBOL
 int CALLAPI OBEX_ResumeRequest(obex_t *self)
 {
 	obex_return_val_if_fail(self->object != NULL, -1);
-	return obex_object_resume(self, self->object);
+	return obex_object_resume(self->object);
 }

 /**
diff --git a/lib/obex_object.c b/lib/obex_object.c
index f888a2d..a7d5cb3 100644
--- a/lib/obex_object.c
+++ b/lib/obex_object.c
 <at>  <at>  -1146,49 +1146,18  <at>  <at>  int obex_object_readstream(obex_t *self, obex_object_t *object,

 int obex_object_suspend(obex_object_t *object)
 {
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 20/46] Update install instructions

---
 INSTALL.txt       |   10 +++-----
 INSTALL_Win32.txt |   54 ++++++++++++++++++++++++++--------------------------
 2 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/INSTALL.txt b/INSTALL.txt
index 25b4fcd..88f7b38 100644
--- a/INSTALL.txt
+++ b/INSTALL.txt
 <at>  <at>  -1,16 +1,15  <at>  <at> 
 How to compile OpenObex
 =======================

-
 The compilation of OpenObex is done using CMake.
 The following OBEX transports are available:
  * Bluetooth (not all systems, see below)
  * Irda (not all systems, see below)
  * TCP
+ * USB
  * Custom transport
  * File descriptor

-
 The following operating systems are supported:
  * Linux [Bluetooth, Irda]
  * FreeBSD [Bluetooth]
 <at>  <at>  -32,7 +31,6  <at>  <at>  system, please see INSTALL_Win32.txt.
 [2]: at http://www.cmake.org

(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 10/46] Fix reading user input in obex_test

---
 apps/obex_test/obex_test.c        |   12 ++++---
 apps/obex_test/obex_test_client.c |   61 ++++++++++++++++++++++--------------
 2 files changed, 44 insertions(+), 29 deletions(-)

diff --git a/apps/obex_test/obex_test.c b/apps/obex_test/obex_test.c
index 4200f9b..350d808 100644
--- a/apps/obex_test/obex_test.c
+++ b/apps/obex_test/obex_test.c
 <at>  <at>  -153,8 +153,8  <at>  <at>  static int inet_connect(obex_t *handle)
 //
 int main (int argc, char *argv[])
 {
-	char cmd[10];
-	int num, end = 0;
+	char cmd[3];
+	int end = 0;
 	int cobex = FALSE, tcpobex = FALSE, btobex = FALSE, r320 = FALSE, usbobex = FALSE;
 	obex_t *handle;
 #ifdef HAVE_BLUETOOTH
 <at>  <at>  -350,10 +350,12  <at>  <at>  int main (int argc, char *argv[])

 	while (!end) {
 		printf("> ");
-		num = scanf("%s", cmd);
-		if (num == EOF)
+		fflush(stdout);
+		(void)fgets(cmd, sizeof(cmd), stdin);
+		if (cmd[0] == 0) /* EOF */
 			break;
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:46
Picon

[PATCH 35/46] Use GNUInstallDirs.cmake

The cmake build files used some self-named variables or fixed value. Replace
them by the new GNUInstallDirs.cmake that introduces variables as defined for
GNU autotools.
---
 CMakeLists.txt                |   21 +++++----------------
 apps/CMakeLists.txt           |    2 +-
 apps/ircp/CMakeLists.txt      |    2 +-
 apps/obex_test/CMakeLists.txt |    2 +-
 doc/CMakeLists.txt            |    6 +++---
 lib/CMakeLists.txt            |    8 ++++----
 udev/CMakeLists.txt           |    8 ++++----
 7 files changed, 19 insertions(+), 30 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5a2bde4..fe1d8d5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
 <at>  <at>  -1,4 +1,4  <at>  <at> 
-cmake_minimum_required ( VERSION 2.6.3 FATAL_ERROR )
+cmake_minimum_required ( VERSION 2.8.5 FATAL_ERROR )

 project ( openobex C )

 <at>  <at>  -31,6 +31,7  <at>  <at>  if ( NOT CMAKE_BUILD_TYPE )
 endif ( NOT CMAKE_BUILD_TYPE )

 include ( MaintainerMode )
+include ( GNUInstallDirs )

 #
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 11/46] Fix: set MODE_SRV/STATE_IDLE _after_ sending event

This is needed for obex_test to actually work.
---
 lib/obex_client.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/obex_client.c b/lib/obex_client.c
index 5107d62..0199fbf 100644
--- a/lib/obex_client.c
+++ b/lib/obex_client.c
 <at>  <at>  -61,10 +61,10  <at>  <at>  static int obex_client_recv(obex_t *self, buf_t *msg, int rsp)
 		/* Response of a CMD_CONNECT needs some special treatment.*/
 		DEBUG(2, "We expect a connect-rsp\n");
 		if (obex_parse_connect_header(self, msg) < 0) {
-			self->mode = MODE_SRV;
-			self->state = STATE_IDLE;
 			obex_deliver_event(self, OBEX_EV_PARSEERR,
 						self->object->opcode, 0, TRUE);
+			self->mode = MODE_SRV;
+			self->state = STATE_IDLE;
 			return -1;
 		}
 		self->object->headeroffset=4;
 <at>  <at>  -82,10 +82,10  <at>  <at>  static int obex_client_recv(obex_t *self, buf_t *msg, int rsp)
 	/* Receive any headers */
 	ret = obex_object_receive(self, msg);
 	if (ret < 0) {
-		self->mode = MODE_SRV;
-		self->state = STATE_IDLE;
 		obex_deliver_event(self, OBEX_EV_PARSEERR,
 						self->object->opcode, 0, TRUE);
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:46
Picon

[PATCH 37/46] Convert OBEX_EV_* to an enum

---
 include/openobex/obex_const.h |   40 +++++++++++++++++++++++++++-------------
 1 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/include/openobex/obex_const.h b/include/openobex/obex_const.h
index ff147df..18d698a 100644
--- a/include/openobex/obex_const.h
+++ b/include/openobex/obex_const.h
 <at>  <at>  -151,19 +151,33  <at>  <at>  enum obex_mode {
 	OBEX_MODE_SERVER = 1, /**≤ server mode */
 };

-/* Possible events */
-#define OBEX_EV_PROGRESS	0	/* Progress has been made */
-#define OBEX_EV_REQHINT		1	/* An incoming request is about to come */
-#define OBEX_EV_REQ		2	/* An incoming request has arrived */
-#define OBEX_EV_REQDONE		3	/* Request has finished */
-#define OBEX_EV_LINKERR		4	/* Link has been disconnected */
-#define OBEX_EV_PARSEERR	5	/* Malformed data encountered */
-#define OBEX_EV_ACCEPTHINT	6	/* Connection accepted */
-#define OBEX_EV_ABORT		7	/* Request was aborted */
-#define OBEX_EV_STREAMEMPTY	8	/* Need to feed more data when sending a stream */
-#define OBEX_EV_STREAMAVAIL	9	/* Time to pick up data when receiving a stream */
-#define OBEX_EV_UNEXPECTED	10	/* Unexpected data, not fatal */
-#define OBEX_EV_REQCHECK	11	/* First packet of an incoming request has been parsed */
+/** Possible events */
+enum obex_event {
+	/** Progress has been made */
+	OBEX_EV_PROGRESS = 0,
+	/** An incoming request is about to come */
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:46
Picon

[PATCH 45/46] Move obex_response_request() to the only file it is used in

Additionally, it adds a small wrapper function for BAD_REQUEST which can be
used quite often. Still, this is the only case where an incomplete write/send
is not possible but adding more states for this seems overkill. After all its
only 3 bytes to send.
The abort cases are now using the STATE_ABORT with a small wrapper.
---
 lib/obex_main.c   |   21 ----------
 lib/obex_main.h   |    1 -
 lib/obex_server.c |  114 +++++++++++++++++++++++++---------------------------
 3 files changed, 55 insertions(+), 81 deletions(-)

diff --git a/lib/obex_main.c b/lib/obex_main.c
index bd18921..e089201 100644
--- a/lib/obex_main.c
+++ b/lib/obex_main.c
 <at>  <at>  -266,27 +266,6  <at>  <at>  void obex_deliver_event(obex_t *self, int event, int cmd, int rsp, int del)
 }

 /*
- * Function obex_response_request (self, opcode)
- *
- *    Send a response to peer device
- *
- */
-void obex_response_request(obex_t *self, uint8_t opcode)
-{
-	buf_t *msg;
-
-	obex_return_if_fail(self != NULL);
-
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:46
Picon

[PATCH 44/46] Add function that tells you the current data direction

---
 include/openobex/obex.h       |    1 +
 include/openobex/obex_const.h |    7 +++++++
 lib/obex.c                    |   16 ++++++++++++++++
 lib/obex.sym                  |    1 +
 lib/obex_main.c               |   16 +++++++++++++---
 lib/obex_main.h               |    1 +
 6 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/include/openobex/obex.h b/include/openobex/obex.h
index 0711c6d..b38cf93 100644
--- a/include/openobex/obex.h
+++ b/include/openobex/obex.h
 <at>  <at>  -111,6 +111,7  <at>  <at>  OPENOBEX_SYMBOL(void *)   OBEX_GetUserData(obex_t *self);
 OPENOBEX_SYMBOL(void)     OBEX_SetEventCb(obex_t *self, obex_event_cb_t eventcb, void * data);
 OPENOBEX_SYMBOL(int)      OBEX_SetTransportMTU(obex_t *self, uint16_t mtu_rx, uint16_t mtu_tx_max);
 OPENOBEX_SYMBOL(int)      OBEX_GetFD(obex_t *self);
+OPENOBEX_SYMBOL(enum obex_data_direction) OBEX_GetDataDirection(obex_t *self);

 OPENOBEX_SYMBOL(int)    OBEX_RegisterCTransport(obex_t *self, obex_ctrans_t *ctrans);
 OPENOBEX_SYMBOL(int)    OBEX_SetCustomData(obex_t *self, void * data);
diff --git a/include/openobex/obex_const.h b/include/openobex/obex_const.h
index cdcd823..c675802 100644
--- a/include/openobex/obex_const.h
+++ b/include/openobex/obex_const.h
 <at>  <at>  -204,6 +204,13  <at>  <at>  enum obex_transport_type {
 	OBEX_TRANS_BT_L2CAP = 7,  /**≤ Bluetooth L2CAP */
 };

+/** Possible directions for data */
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:46
Picon

[PATCH 36/46] Use only one set of obex_mode defines

This also makes the public type an enum (like it was for the internal type) but
the names for the values stay the same.
---
 include/openobex/obex_const.h |    7 +++++--
 lib/defines.h                 |    5 -----
 lib/obex.c                    |    6 +++---
 lib/obex_client.c             |   12 ++++++------
 lib/obex_main.c               |    9 +++------
 lib/obex_object.c             |    2 +-
 6 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/include/openobex/obex_const.h b/include/openobex/obex_const.h
index 8276aae..ff147df 100644
--- a/include/openobex/obex_const.h
+++ b/include/openobex/obex_const.h
 <at>  <at>  -145,8 +145,11  <at>  <at>  typedef union {
 	//obex_bluetooth_intf_t bt; // to be added
 } obex_interface_t;

-#define OBEX_MODE_CLIENT	0
-#define OBEX_MODE_SERVER	1
+/** Possible modes */
+enum obex_mode {
+	OBEX_MODE_CLIENT = 0, /**≤ client mode */
+	OBEX_MODE_SERVER = 1, /**≤ server mode */
+};

 /* Possible events */
 #define OBEX_EV_PROGRESS	0	/* Progress has been made */
diff --git a/lib/defines.h b/lib/defines.h
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 19/46] Add missing copyright and license plates

---
 lib/bluez_compat.h |    2 +-
 lib/cloexec.h      |   20 ++++++++++++++++++++
 lib/customtrans.c  |   22 ++++++++++++++++++++++
 lib/customtrans.h  |   21 +++++++++++++++++++++
 lib/fdobex.c       |   22 ++++++++++++++++++++++
 lib/fdobex.h       |   21 +++++++++++++++++++++
 6 files changed, 107 insertions(+), 1 deletions(-)

diff --git a/lib/bluez_compat.h b/lib/bluez_compat.h
index 6bd7000..b72b94f 100644
--- a/lib/bluez_compat.h
+++ b/lib/bluez_compat.h
 <at>  <at>  -3,7 +3,7  <at>  <at> 
 	Provides the Bluez API on other platforms.
 	OpenOBEX library - Free implementation of the Object Exchange protocol.

-	Copyright (c) 2007 Hendrik Sattler, All Rights Reserved.
+	Copyright (c) 2007-2011 Hendrik Sattler, All Rights Reserved.

 	OpenOBEX is free software; you can redistribute it and/or modify
 	it under the terms of the GNU Lesser General Public License as
diff --git a/lib/cloexec.h b/lib/cloexec.h
index 1c5c396..f2a77c0 100644
--- a/lib/cloexec.h
+++ b/lib/cloexec.h
 <at>  <at>  -1,3 +1,23  <at>  <at> 
+/**
+	\file cloexec.h
+	close-on-exec wrapper functions.
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 15/46] Allow usage of L2CAP transport with obex_test

---
 apps/obex_test/obex_test.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/apps/obex_test/obex_test.c b/apps/obex_test/obex_test.c
index 7527a51..4b9b0b2 100644
--- a/apps/obex_test/obex_test.c
+++ b/apps/obex_test/obex_test.c
 <at>  <at>  -167,9 +167,9  <at>  <at>  int main (int argc, char *argv[])
 	struct context global_context = {0};

 #ifdef HAVE_BLUETOOTH
-	int btobex = FALSE;
+	int btobex = 0;
 	bdaddr_t bdaddr;
-	uint8_t channel = 0;
+	uint16_t channel = 0;
 #endif
 #ifdef HAVE_USB
 	int usbobex = FALSE;
 <at>  <at>  -192,6 +192,7  <at>  <at>  int main (int argc, char *argv[])
 #endif
 #ifdef HAVE_BLUETOOTH
 			"    -b [addr] [chan]  Use bluetooth RFCOMM transport\n"
+			"    -B [addr] [psm]   Use bluetooth L2CAP transport\n"
 #endif
 #ifdef HAVE_USB
 			"    -u [interface]    Use USB transport\n"
 <at>  <at>  -214,7 +215,9  <at>  <at>  int main (int argc, char *argv[])
 #endif
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 13/46] Add Bluetooth L2CAP tranport

Note that the transport only works on Linux. Although it also compiles on
Windows, the operating system itself does not support it. FreeBSD and NetBSD do
not seem to support ERTM, yet. The code for the last two is not compile-tested.
---
 include/openobex/obex.h       |    4 +-
 include/openobex/obex_const.h |    3 +-
 lib/CMakeLists.txt            |    1 +
 lib/Makefile.am               |    3 +-
 lib/bluez_compat.h            |   16 ++-
 lib/btobex.c                  |   24 +++-
 lib/btobex.h                  |   11 ++-
 lib/btobex_l2cap.c            |  315 +++++++++++++++++++++++++++++++++++++++++
 lib/obex.c                    |   16 ++-
 lib/obex_main.c               |   20 +++
 lib/obex_main.h               |    1 +
 lib/obex_transport.c          |    4 +
 12 files changed, 401 insertions(+), 17 deletions(-)
 create mode 100644 lib/btobex_l2cap.c

diff --git a/include/openobex/obex.h b/include/openobex/obex.h
index 6dda861..6bf91d4 100644
--- a/include/openobex/obex.h
+++ b/include/openobex/obex.h
 <at>  <at>  -147,8 +147,8  <at>  <at>  OPENOBEX_SYMBOL(int) IrOBEX_TransportConnect(obex_t *self, const char *service);
 #endif

 #if defined(bt_addr_t)
-OPENOBEX_SYMBOL(int) BtOBEX_ServerRegister(obex_t *self, const bt_addr_t *src, uint8_t channel);
-OPENOBEX_SYMBOL(int) BtOBEX_TransportConnect(obex_t *self, const bt_addr_t *src, const bt_addr_t
*dst, uint8_t channel);
(Continue reading)

Iain Hibbert | 15 Jul 2011 21:02

Re: [PATCH 13/46] Add Bluetooth L2CAP tranport

On Fri, 15 Jul 2011, Hendrik Sattler wrote:

> Note that the transport only works on Linux. Although it also compiles on
> Windows, the operating system itself does not support it. FreeBSD and NetBSD do
> not seem to support ERTM, yet. The code for the last two is not compile-tested.

The only change I needed to build on NetBSD was addition of two lines as
per below. (the FreeBSD build should be ok I think)

I only tried bootstrap-configure though, my cmake 2.8.4 is too old :)

iain

--- bluez_compat.h.orig	2011-07-15 19:58:02.000000000 +0100
+++ bluez_compat.h	2011-07-15 19:53:40.000000000 +0100
 <at>  <at>  -75,9 +75,11  <at>  <at> 
 #define rc_family   bt_family
 #define rc_bdaddr   bt_bdaddr
 #define rc_channel  bt_channel
+#define sockaddr_l2 sockaddr_bt
 #define l2_family   bt_family
 #define l2_bdaddr   bt_bdaddr
 #define l2_psm      bt_psm
+#define SOL_L2CAP   BTPROTO_L2CAP
 #define bacpy(dst,src) memcpy((dst),(src),sizeof(bdaddr_t))
 #define bacmp(a,b)     memcmp((a),(b),sizeof(bdaddr_t))
 #define str2ba(str, ba)	(bt_aton((str), (ba)) == 1 ? 0 : -1)

------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
(Continue reading)

Hendrik Sattler | 16 Jul 2011 01:19
Picon

Re: [PATCH 13/46] Add Bluetooth L2CAP tranport

Am Freitag, 15. Juli 2011, 21:02:15 schrieb Iain Hibbert:
> On Fri, 15 Jul 2011, Hendrik Sattler wrote:
> > Note that the transport only works on Linux. Although it also compiles on
> > Windows, the operating system itself does not support it. FreeBSD and
> > NetBSD do not seem to support ERTM, yet. The code for the last two is
> > not compile-tested.
> 
> The only change I needed to build on NetBSD was addition of two lines as
> per below. (the FreeBSD build should be ok I think)

Great. So I was very close.. :-)

> I only tried bootstrap-configure though, my cmake 2.8.4 is too old :)

Never mind. That should then work as well, no real major changes there...

Thanks,

HS

------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
Ries, the creator of the Lean Startup Methodology on "Lean Startup 
Secrets Revealed." This video shows you how to validate your ideas, 
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
Hendrik Sattler | 15 Jul 2011 18:46
Picon

[PATCH 38/46] Convert OBEX_TRANS_* to an enum

---
 include/openobex/obex_const.h |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/include/openobex/obex_const.h b/include/openobex/obex_const.h
index 18d698a..cdcd823 100644
--- a/include/openobex/obex_const.h
+++ b/include/openobex/obex_const.h
 <at>  <at>  -193,14 +193,16  <at>  <at>  enum obex_event {
 #define OBEX_FL_STREAM_DATAEND	0x08	/* Body stream last data */
 #define OBEX_FL_SUSPEND		0x10	/* Suspend after sending this header */

-/* Transports */
-#define OBEX_TRANS_IRDA		1
-#define OBEX_TRANS_INET		2
-#define OBEX_TRANS_CUSTOM	3
-#define OBEX_TRANS_BLUETOOTH	4 /* Bluetooth RFCOMM */
-#define OBEX_TRANS_FD		5
-#define OBEX_TRANS_USB		6
-#define OBEX_TRANS_BT_L2CAP	7 /* Bluetooth L2CAP */
+/** Possible transports */
+enum obex_transport_type {
+	OBEX_TRANS_IRDA = 1,      /**≤ Infrared */
+	OBEX_TRANS_INET = 2,      /**≤ TCP over IPv4/v6 */
+	OBEX_TRANS_CUSTOM = 3,    /**≤ Custom transport with callbacks */
+	OBEX_TRANS_BLUETOOTH = 4, /**≤ Bluetooth RFCOMM */
+	OBEX_TRANS_FD = 5,        /**≤ file descriptors */
+	OBEX_TRANS_USB = 6,       /**≤ USB CDC OBEX */
+	OBEX_TRANS_BT_L2CAP = 7,  /**≤ Bluetooth L2CAP */
+};
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 16/46] Remove unused code in glib/

We never actually shipped the result from glib/ to be easily compilable, it has
no known dependencies.
---
 .gitignore                  |    6 -
 CMakeLists.txt              |   22 +-
 CMakeModules/FindGlib.cmake |   94 ----
 Makefile.am                 |    8 +-
 acinclude.m4                |   14 -
 configure.ac                |    3 +-
 glib/CMakeLists.txt         |  139 ------
 glib/Makefile.am            |   42 --
 glib/obex-client.c          |  589 -------------------------
 glib/obex-client.h          |  163 -------
 glib/obex-debug.h           |   28 --
 glib/obex-error.c           |  226 ----------
 glib/obex-error.h           |   31 --
 glib/obex-lowlevel.c        | 1014 -------------------------------------------
 glib/obex-lowlevel.h        |   50 ---
 glib/obex-marshal.list      |    1 -
 glib/test-client.c          |  237 ----------
 glib/test-lowlevel.c        |  104 -----
 openobex-glib.pc.in         |   12 -
 19 files changed, 8 insertions(+), 2775 deletions(-)
 delete mode 100644 CMakeModules/FindGlib.cmake
 delete mode 100644 glib/CMakeLists.txt
 delete mode 100644 glib/Makefile.am
 delete mode 100644 glib/obex-client.c
 delete mode 100644 glib/obex-client.h
 delete mode 100644 glib/obex-debug.h
 delete mode 100644 glib/obex-error.c
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 23/46] Split obex_data_indication

One step is triggered the transport handle_input function: this one fills the
rx_msg buffer. It also used to read from that rx_msg buffer right again and
trigger the state machine. This patch decouples the second part and is needed
for further splitting into substates.
---
 lib/obex.c           |    2 +-
 lib/obex_client.c    |   13 +++++++--
 lib/obex_client.h    |    2 +-
 lib/obex_main.c      |   73 ++++++++++++++++++++++++++++++++-----------------
 lib/obex_main.h      |    2 +
 lib/obex_server.c    |   18 +++++++++---
 lib/obex_server.h    |    2 +-
 lib/obex_transport.c |    2 +-
 8 files changed, 78 insertions(+), 36 deletions(-)

diff --git a/lib/obex.c b/lib/obex.c
index bf2b71b..e56ef74 100644
--- a/lib/obex.c
+++ b/lib/obex.c
 <at>  <at>  -535,7 +535,7  <at>  <at>  int CALLAPI OBEX_Request(obex_t *self, obex_object_t *object)
 	self->mode = MODE_CLI;
         self->state = STATE_SEND;

-	return obex_client(self, NULL, 0);
+	return obex_client_send(self, NULL, 0);
 }

 /**
diff --git a/lib/obex_client.c b/lib/obex_client.c
index 0199fbf..e17528a 100644
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 32/46] Fix ABORT event rsp code

---
 lib/obex_client.c |   11 ++++++-----
 lib/obex_server.c |    4 ++--
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/lib/obex_client.c b/lib/obex_client.c
index dc7502e..efaf9f3 100644
--- a/lib/obex_client.c
+++ b/lib/obex_client.c
 <at>  <at>  -130,17 +130,18  <at>  <at>  static int obex_client_recv_prepare_tx(obex_t *self)
 {
 	DEBUG(4, "STATE: RECV/PREPARE_TX\n");

+	/* Sending ABORT is allowed even during SRM */
+	if (self->object->abort == 1) {
+		self->state = STATE_ABORT;
+		return obex_client_abort_prepare(self);
+	}
+
 	if (self->object->rsp_mode == OBEX_RSP_MODE_NORMAL ||
 	    (self->object->rsp_mode == OBEX_RSP_MODE_SINGLE &&
 	     self->srm_flags & OBEX_SRM_FLAG_WAIT_REMOTE))
 	{
 		int ret;

-		if (self->object->abort == 1) {
-			self->state = STATE_ABORT;
-			return obex_client_abort_prepare(self);
-		}
-
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:46
Picon

[PATCH 39/46] Add new event callback with stricter types

To be backward compatible, the old obex_event_t callback type is still
supported but the documentation only refers to the new type and its functions.
---
 doc/openobex.coverpage  |   20 +-----
 include/openobex/obex.h |   44 +++++++++++++--
 lib/obex.c              |  143 +++++++++++++++++++++++++++-------------------
 lib/obex.sym            |    3 +
 lib/obex_main.c         |   70 ++++++++++++++++++++++-
 lib/obex_main.h         |    5 +-
 6 files changed, 201 insertions(+), 84 deletions(-)

diff --git a/doc/openobex.coverpage b/doc/openobex.coverpage
index 1f75eb4..1f7715b 100644
--- a/doc/openobex.coverpage
+++ b/doc/openobex.coverpage
 <at>  <at>  -31,9 +31,9  <at>  <at>  You might also find the OpenOBEX test applications useful.

 To be able to use the OpenOBEX API you must include the files openobex/obex_const.h and openobex/obex.h.

-First of all you must create an OBEX instance by calling #OBEX_Init.
+First of all you must create an OBEX instance by calling #OBEX_New.
 In this call you specify what transport you want to use, an event callback, and optional flags.
-#OBEX_Init will return a handle which shall be passed to almost all other functions.
+#OBEX_New will return a handle which shall be passed to almost all other functions.

 To let the parser do some work you must call #OBEX_HandleInput.
 It will block for at-most the specified timeout for read and write actions.
 <at>  <at>  -41,19 +41,7  <at>  <at>  You can call #OBEX_GetFD if you want to do select() yourself (this may not work

 	\subsection callback_sec The event callback
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 33/46] Add new OBEX_FL_NONBLOCK

---
 include/openobex/obex_const.h |    1 +
 lib/obex.c                    |    1 +
 lib/obex_main.c               |   22 ++++++++++++++++------
 lib/obex_transport.c          |   19 +++++++++++++++++--
 4 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/include/openobex/obex_const.h b/include/openobex/obex_const.h
index b4bad7f..8276aae 100644
--- a/include/openobex/obex_const.h
+++ b/include/openobex/obex_const.h
 <at>  <at>  -167,6 +167,7  <at>  <at>  typedef union {
 #define OBEX_FL_FILTERHINT	(1 <<  2) /* Filter devices based on hint bit */
 #define OBEX_FL_FILTERIAS	(1 <<  3) /* Filter devices based on IAS entry */
 #define OBEX_FL_CLOEXEC		(1 <<  4) /* Set CLOEXEC flag on file descriptors */
+#define OBEX_FL_NONBLOCK	(1 <<  5) /* Set the NONBLOCK flag on file descriptors */ 

 /* For OBEX_ObjectAddHeader */
 #define OBEX_FL_FIT_ONE_PACKET	0x01	/* This header must fit in one packet */
diff --git a/lib/obex.c b/lib/obex.c
index 3aa6bac..49de8cd 100644
--- a/lib/obex.c
+++ b/lib/obex.c
 <at>  <at>  -82,6 +82,7  <at>  <at> 
 			- #OBEX_FL_FILTERHINT : Filter target devices based on Obex hint bit
 			- #OBEX_FL_FILTERIAS  : Filter target devices based on IAS entry
 			- #OBEX_FL_CLOEXEC   : Open all sockets with SO_CLOEXEC set
+			- #OBEX_FL_NONBLOCK   : Open all sockets non-blocking
 	\return an OBEX handle or NULL on error.
  */
(Continue reading)

Hendrik Sattler | 16 Jul 2011 02:43
Picon

Re: [PATCH 33/46] Add new OBEX_FL_NONBLOCK

Am Freitag, 15. Juli 2011, 18:45:58 schrieb Hendrik Sattler:
> ---
>  include/openobex/obex_const.h |    1 +
>  lib/obex.c                    |    1 +
>  lib/obex_main.c               |   22 ++++++++++++++++------
>  lib/obex_transport.c          |   19 +++++++++++++++++--
>  4 files changed, 35 insertions(+), 8 deletions(-)

This patch got some fixes now and is now followed by another patch with extends 
obex_test to make this testable.

Updates will show up in the next resend or in my repository...

HS

------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
Ries, the creator of the Lean Startup Methodology on "Lean Startup 
Secrets Revealed." This video shows you how to validate your ideas, 
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
Hendrik Sattler | 15 Jul 2011 18:46
Picon

[PATCH 41/46] Fix documentation about what needs to be included

---
 doc/openobex.coverpage |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/doc/openobex.coverpage b/doc/openobex.coverpage
index 1f7715b..e13cc8c 100644
--- a/doc/openobex.coverpage
+++ b/doc/openobex.coverpage
 <at>  <at>  -29,7 +29,7  <at>  <at>  You might also find the OpenOBEX test applications useful.

 	\subsection preparations_sec Preparations

-To be able to use the OpenOBEX API you must include the files openobex/obex_const.h and openobex/obex.h.
+To be able to use the OpenOBEX API you must include the files openobex/obex_const.h or openobex/obex.h.

 First of all you must create an OBEX instance by calling #OBEX_New.
 In this call you specify what transport you want to use, an event callback, and optional flags.
--

-- 
1.7.5.4

------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
Ries, the creator of the Lean Startup Methodology on "Lean Startup 
Secrets Revealed." This video shows you how to validate your ideas, 
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 30/46] Remove now unused members from obex_object_t

---
 lib/obex_object.h |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/lib/obex_object.h b/lib/obex_object.h
index 31a7d80..914b405 100644
--- a/lib/obex_object.h
+++ b/lib/obex_object.h
 <at>  <at>  -74,8 +74,6  <at>  <at>  struct obex_object {
 	enum obex_rsp_mode rsp_mode;	/* OBEX_RSP_MODE_* */

 	int suspend;			/* Temporarily stop transfering object */
-	int continue_received;		/* CONTINUE received after sending last command */
-	int first_packet_sent;		/* Whether we've sent the first packet */

 	const uint8_t *s_buf;		/* Pointer to streaming data */
 	unsigned int s_len;		/* Length of stream-data */
--

-- 
1.7.5.4

------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
Ries, the creator of the Lean Startup Methodology on "Lean Startup 
Secrets Revealed." This video shows you how to validate your ideas, 
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 27/46] Split and use substate in obex_client_send()

---
 lib/obex.c        |    3 +-
 lib/obex_client.c |  207 ++++++++++++++++++++++++++++++++--------------------
 lib/obex_client.h |    2 -
 lib/obex_main.c   |   36 +++++-----
 4 files changed, 146 insertions(+), 102 deletions(-)

diff --git a/lib/obex.c b/lib/obex.c
index e56ef74..5e16fc4 100644
--- a/lib/obex.c
+++ b/lib/obex.c
 <at>  <at>  -534,8 +534,9  <at>  <at>  int CALLAPI OBEX_Request(obex_t *self, obex_object_t *object)
 	self->object = object;
 	self->mode = MODE_CLI;
         self->state = STATE_SEND;
+	self->substate = SUBSTATE_PREPARE_TX;

-	return obex_client_send(self, NULL, 0);
+	return obex_client(self);
 }

 /**
diff --git a/lib/obex_client.c b/lib/obex_client.c
index fd9962b..c8dc843 100644
--- a/lib/obex_client.c
+++ b/lib/obex_client.c
 <at>  <at>  -178,91 +178,135  <at>  <at>  static int obex_client_recv(obex_t *self)

 }

(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 31/46] Add new STATE_ABORT

The old way of aborting objects does not work anymore, neither with SRM nor
with the new possibilities of incomplete writes, as that may break the
synchronisation between server and client.
This patch integrates the abort action right within the affected states.
---
 lib/defines.h     |    1 +
 lib/obex_client.c |  125 ++++++++++++++++++++++++++++++++++++++++-------------
 lib/obex_main.c   |   35 ++-------------
 lib/obex_server.c |   87 ++++++++++++++++++++++++++++++++----
 4 files changed, 176 insertions(+), 72 deletions(-)

diff --git a/lib/defines.h b/lib/defines.h
index eb2257b..5935930 100644
--- a/lib/defines.h
+++ b/lib/defines.h
 <at>  <at>  -27,6 +27,7  <at>  <at>  enum obex_state {
 	STATE_IDLE,
 	STATE_SEND,
 	STATE_REC,
+	STATE_ABORT,
 };

 enum obex_substate {
diff --git a/lib/obex_client.c b/lib/obex_client.c
index c8dc843..dc7502e 100644
--- a/lib/obex_client.c
+++ b/lib/obex_client.c
 <at>  <at>  -49,6 +49,61  <at>  <at>  static __inline uint16_t msg_get_len(const buf_t *msg)
 		return 0;
 }
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 21/46] Fix documentation reference bug

---
 lib/obex.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/obex.c b/lib/obex.c
index a2409a2..bf2b71b 100644
--- a/lib/obex.c
+++ b/lib/obex.c
 <at>  <at>  -81,7 +81,7  <at>  <at> 
 			- #OBEX_FL_KEEPSERVER : Keep the server alive after incomming request
 			- #OBEX_FL_FILTERHINT : Filter target devices based on Obex hint bit
 			- #OBEX_FL_FILTERIAS  : Filter target devices based on IAS entry
-			- #OBEX_FL_CLOSEXEC   : Open all sockets with SO_CLOEXEC set
+			- #OBEX_FL_CLOEXEC   : Open all sockets with SO_CLOEXEC set
 	\return an OBEX handle or NULL on error.
  */
 LIB_SYMBOL
--

-- 
1.7.5.4

------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
Ries, the creator of the Lean Startup Methodology on "Lean Startup 
Secrets Revealed." This video shows you how to validate your ideas, 
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 26/46] Split and use substate in obex_client_recv()

---
 lib/obex_client.c |  101 +++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 72 insertions(+), 29 deletions(-)

diff --git a/lib/obex_client.c b/lib/obex_client.c
index e17528a..fd9962b 100644
--- a/lib/obex_client.c
+++ b/lib/obex_client.c
 <at>  <at>  -49,12 +49,63  <at>  <at>  static __inline uint16_t msg_get_len(const buf_t *msg)
 		return 0;
 }

-static int obex_client_recv(obex_t *self, buf_t *msg, int rsp)
+static int obex_client_recv_transmit_tx(obex_t *self)
+{
+	int ret = 0;
+	int rsp = OBEX_RSP_CONTINUE;
+
+	DEBUG(4, "STATE: RECV/TRANSMIT_TX\n");
+
+	ret = obex_object_send_transmit(self, self->object);
+	if (ret == -1) {
+		obex_deliver_event(self, OBEX_EV_LINKERR,
+				   self->object->opcode, rsp, TRUE);
+		self->state = STATE_IDLE;
+
+	} else if (ret == 1) {
+		obex_deliver_event(self, OBEX_EV_PROGRESS,
+				   self->object->opcode, rsp, FALSE);
+		self->substate = SUBSTATE_RECEIVE_RX;
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:46
Picon

[PATCH 40/46] Rename OBEX_HandleInput

The substates create situations where this function name doesn't fit anymore.
To avoid confusion, it is renamed to OBEX_Work(). The timeout argument is
now in milliseconds, the previous argument was in seconds which may be not
fine enough.
---
 include/openobex/obex.h |    3 ++-
 lib/fdobex.c            |   10 ++++++++--
 lib/obex.c              |    4 ++--
 lib/obex_main.c         |    2 +-
 lib/obex_main.h         |    2 +-
 lib/obex_transport.c    |   12 +++++++++---
 lib/obex_transport.h    |    4 ++--
 lib/usb1obex.c          |    6 +++---
 lib/usbobex.c           |    6 +++---
 9 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/include/openobex/obex.h b/include/openobex/obex.h
index 315601d..1f7c916 100644
--- a/include/openobex/obex.h
+++ b/include/openobex/obex.h
 <at>  <at>  -84,6 +84,7  <at>  <at>  OPENOBEX_SYMBOL(void)     OBEX_SetUserCallBack(obex_t *self,
 					       void * data);
 OPENOBEX_SYMBOL(obex_t *) OBEX_ServerAccept(obex_t *server,
 					    obex_event_t eventcb, void * data);
+#define OBEX_HandleInput(self, timeout) OBEX_Work((self), ((timeout)*1000))

 /*
  *  OBEX API
 <at>  <at>  -116,7 +117,7  <at>  <at>  OPENOBEX_SYMBOL(void *) OBEX_GetCustomData(obex_t *self);
 OPENOBEX_SYMBOL(int) OBEX_TransportConnect(obex_t *self, struct sockaddr *saddr, int addlen);
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:46
Picon

[PATCH 42/46] Make old API items dependent on OPENOBEX_DEPRECATED

---
 include/openobex/obex.h |    2 ++
 lib/obex_incl.h         |    4 ++++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/include/openobex/obex.h b/include/openobex/obex.h
index 1f7c916..0711c6d 100644
--- a/include/openobex/obex.h
+++ b/include/openobex/obex.h
 <at>  <at>  -65,6 +65,7  <at>  <at>  typedef struct obex_object obex_object_t;
 /*
  *  OBEX API (deprecated)
  */
+#if defined(OPENOBEX_DEPRECATED)
 /** The user event callback.
  *  \deprecated Use #obex_event_cb_t and its functions instead.
  *  \param handle the obex handle
 <at>  <at>  -85,6 +86,7  <at>  <at>  OPENOBEX_SYMBOL(void)     OBEX_SetUserCallBack(obex_t *self,
 OPENOBEX_SYMBOL(obex_t *) OBEX_ServerAccept(obex_t *server,
 					    obex_event_t eventcb, void * data);
 #define OBEX_HandleInput(self, timeout) OBEX_Work((self), ((timeout)*1000))
+#endif

 /*
  *  OBEX API
diff --git a/lib/obex_incl.h b/lib/obex_incl.h
index ae95e59..dbca28e 100644
--- a/lib/obex_incl.h
+++ b/lib/obex_incl.h
 <at>  <at>  -6,6 +6,10  <at>  <at> 
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 22/46] Split sending object in three steps

There are now three steps for sending an object: a prepare step where a new
TX message is written to the TX buffer, a transmit step where the object
is transmitted and the decision step on wether the whole object is finished.
The goal is to allow sending incomplete message buffers on non-blocking sockets.
---
 lib/obex_main.c   |   30 +++++++---
 lib/obex_main.h   |    4 +-
 lib/obex_object.c |  154 +++++++++++++++++++++++++++++++++++++----------------
 lib/obex_object.h |    5 ++
 4 files changed, 136 insertions(+), 57 deletions(-)

diff --git a/lib/obex_main.c b/lib/obex_main.c
index 1d39cd8..884c9e3 100644
--- a/lib/obex_main.c
+++ b/lib/obex_main.c
 <at>  <at>  -210,23 +210,20  <at>  <at>  void obex_response_request(obex_t *self, uint8_t opcode)
 	obex_return_if_fail(self != NULL);

 	msg = buf_reuse(self->tx_msg);
-
-	obex_data_request(self, msg, opcode | OBEX_FINAL);
+	obex_data_request_prepare(self, msg, opcode | OBEX_FINAL);
+	obex_data_request(self, msg);
 }

 /*
- * Function obex_data_request (self, opcode, cmd)
+ * Function obex_data_request_prepare (self, opcode, cmd)
  *
- *    Send response or command code along with optional headers/data.
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 12/46] Prepare for the addition of the Bluetooth L2CAP transport

---
 lib/bluez_compat.h   |    2 +-
 lib/btobex.c         |   45 +++++++++++++++++++++++++++------------------
 lib/btobex.h         |    6 +++++-
 lib/obex_transport.h |    2 +-
 4 files changed, 34 insertions(+), 21 deletions(-)

diff --git a/lib/bluez_compat.h b/lib/bluez_compat.h
index 3f36cd7..c8b046c 100644
--- a/lib/bluez_compat.h
+++ b/lib/bluez_compat.h
 <at>  <at>  -36,7 +36,7  <at>  <at> 
 #define rc_bdaddr   btAddr
 #define rc_channel  port
 #define PF_BLUETOOTH   PF_BTH
-#define AF_BLUETOOTH   PF_BLUETOOTH
+#define AF_BLUETOOTH   AF_BTH
 #define BTPROTO_RFCOMM BTHPROTO_RFCOMM
 /* TODO: should be const */
 extern bdaddr_t bluez_compat_bdaddr_any;
diff --git a/lib/btobex.c b/lib/btobex.c
index 749fefb..810ce91 100644
--- a/lib/btobex.c
+++ b/lib/btobex.c
 <at>  <at>  -32,10 +32,7  <at>  <at> 
 /* Linux/FreeBSD/NetBSD case */

 #include <string.h>
-#include <unistd.h>
-#include <stdio.h>		/* perror */
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:46
Picon

[PATCH 43/46] Convert all apps to new API

---
 apps/ircp/ircp_client.c           |   10 ++++++----
 apps/ircp/ircp_server.c           |   11 ++++++-----
 apps/irobex_palm3.c               |    4 ++--
 apps/irxfer.c                     |    4 ++--
 apps/lib/obex_put_common.c        |    5 +++--
 apps/lib/obex_put_common.h        |    4 ++--
 apps/obex_find.c                  |    7 ++++---
 apps/obex_tcp.c                   |    4 ++--
 apps/obex_test/obex_test.c        |   19 ++++++++++---------
 apps/obex_test/obex_test_client.c |    2 +-
 apps/obex_test/obex_test_server.c |    2 +-
 udev/obex-check-device.c          |    7 ++++---
 12 files changed, 43 insertions(+), 36 deletions(-)

diff --git a/apps/ircp/ircp_client.c b/apps/ircp/ircp_client.c
index 9035c2c..ed49096 100644
--- a/apps/ircp/ircp_client.c
+++ b/apps/ircp/ircp_client.c
 <at>  <at>  -87,7 +87,9  <at>  <at>  static int cli_fillstream(ircp_client_t *cli, obex_object_t *object)
 //
 // Incoming event from OpenOBEX.
 //
-static void cli_obex_event(obex_t *handle, obex_object_t *object, int mode, int event, int obex_cmd,
int obex_rsp)
+static void cli_obex_event(obex_t *handle, obex_object_t *object,
+			   enum obex_mode mode, enum obex_event event,
+			   uint8_t obex_cmd, uint8_t obex_rsp)
 {
 	ircp_client_t *cli;
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 28/46] Split and use substate in obex_server_recv()

---
 lib/obex_main.c   |   44 +---------
 lib/obex_server.c |  259 +++++++++++++++++++++++++++++++++++++---------------
 lib/obex_server.h |    2 -
 3 files changed, 187 insertions(+), 118 deletions(-)

diff --git a/lib/obex_main.c b/lib/obex_main.c
index d3f0612..bc55661 100644
--- a/lib/obex_main.c
+++ b/lib/obex_main.c
 <at>  <at>  -281,36 +281,12  <at>  <at>  int obex_work(obex_t *self, int timeout)
 {
 	int ret;

-	/* Waiting for an incoming packet will not work for single response mode
-	 * as the client is not supposed to send any when we (as server) are
-	 * sending the response.
-	 * For request reception, this is handled above */
-	if (self->mode == MODE_SRV &&
-			self->object &&
-			self->object->rsp_mode != OBEX_RSP_MODE_NORMAL &&
-			self->state == STATE_SEND &&
-			!(self->srm_flags & OBEX_SRM_FLAG_WAIT_LOCAL)) {
-		/* Still, we need to do a zero-wait check for an ABORT
-		 * and for connection errors. */
-		ret = obex_transport_handle_input(self, 0);
-		if (ret == 0) /* timeout: no error, no input */
-			ret = obex_server_send(self, NULL, self->object->cmd, 0);
-		if (ret < 0)
-			return -1;
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 18/46] Remove duplicate information from README

We don't need install instruction in the (usually installed by distributions)
README file, that's what the INSTALL* files are for. The copyright information
in this file is non-sense, it belongs to the source files.
---
 README |   21 ---------------------
 1 files changed, 0 insertions(+), 21 deletions(-)

diff --git a/README b/README
index ddbe0ab..e46e521 100644
--- a/README
+++ b/README
 <at>  <at>  -1,27 +1,6  <at>  <at> 
 OpenOBEX - Free implementation of the Object Exchange protocol
 **************************************************************
 
-Copyright (C) 1998-2000  Dag Brattli <dagb <at> cs.uit.no>
-Copyright (C) 1999-2000  Pontus Fuchs <pontus.fuchs <at> tactel.se>
-Copyright (C) 2001-2002  Jean Tourrilhes <jt <at> hpl.hp.com>
-Copyright (C) 2002-2008  Marcel Holtmann <marcel <at> holtmann.org>
-
-
-Compilation and installation
-============================
-
-In order to compile OpenOBEX you need following software packages:
-	- GCC compiler
-
-To configure run:
-	./configure --prefix=/usr
- 
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:46
Picon

[PATCH 46/46] Release version 2.0

---
 CMakeLists.txt |    4 ++--
 ChangeLog      |   18 ++++++++++++++++++
 configure.ac   |    2 +-
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index fe1d8d5..6a98870 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
 <at>  <at>  -5,8 +5,8  <at>  <at>  project ( openobex C )
 #
 # The project version
 #
-set ( VERSION_MAJOR 1 )
-set ( VERSION_MINOR 6 )
+set ( VERSION_MAJOR 2 )
+set ( VERSION_MINOR 0 )
 set ( VERSION_PATCH 0 )
 set ( VERSION "${VERSION_MAJOR}.${VERSION_MINOR}" )
 if ( VERSION_PATCH GREATER 0 )
diff --git a/ChangeLog b/ChangeLog
index fccdd41..c6d3bee 100644
--- a/ChangeLog
+++ b/ChangeLog
 <at>  <at>  -1,3 +1,21  <at>  <at> 
+ver 2.0:
+	Add support for Obex-over-L2CAP (experimental)
+	Add support for Single Response Mode (experimental)
+	Add manpages for the example applications
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 24/46] Remove the checked obex_object member

The member can be replaced by a rather static usage of a new parameter to
obex_server_recv().
---
 lib/obex_object.h |    1 -
 lib/obex_server.c |   10 ++++------
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/lib/obex_object.h b/lib/obex_object.h
index eef3458..5bcbe0b 100644
--- a/lib/obex_object.h
+++ b/lib/obex_object.h
 <at>  <at>  -71,7 +71,6  <at>  <at>  struct obex_object {
 	int totallen;			/* Size of all headers */
 	int abort;			/* Request shall be aborted */

-	int checked;			/* OBEX_EV_REQCHECK has been signaled */
 	enum obex_rsp_mode rsp_mode;	/* OBEX_RSP_MODE_* */

 	int suspend;			/* Temporarily stop transfering object */
diff --git a/lib/obex_server.c b/lib/obex_server.c
index 1902e4f..401a98d 100644
--- a/lib/obex_server.c
+++ b/lib/obex_server.c
 <at>  <at>  -137,7 +137,7  <at>  <at>  int obex_server_send(obex_t *self, buf_t *msg, int cmd, uint16_t len)
 	return 0;
 }

-static int obex_server_recv(obex_t *self, buf_t *msg, int final,
+static int obex_server_recv(obex_t *self, buf_t *msg, int first, int final,
 							int cmd, uint16_t len)
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 34/46] Handle non-blocking file descriptors in FdObex transport

---
 lib/fdobex.c |   58 +++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 43 insertions(+), 15 deletions(-)

diff --git a/lib/fdobex.c b/lib/fdobex.c
index fa2d64a..cdbc26a 100644
--- a/lib/fdobex.c
+++ b/lib/fdobex.c
 <at>  <at>  -68,6 +68,9  <at>  <at>  static int fdobex_write(obex_t *self, buf_t *msg)
 	struct obex_transport *trans = &self->trans;
 	int fd = trans->data.fd.writefd;
 	size_t size = msg->data_size;
+	int status;
+	fd_set fdset;
+	struct timeval time = {trans->timeout, 0};

 	if (size == 0)
 		return 0;
 <at>  <at>  -76,35 +79,60  <at>  <at>  static int fdobex_write(obex_t *self, buf_t *msg)
 		size = trans->mtu;
 	DEBUG(1, "sending %zu bytes\n", size);

-	if (trans->timeout >= 0) {
-		/* setup everything to check for blocking writes */
-		fd_set fdset;
-		struct timeval time = {trans->timeout, 0};
-		int status;
-
-		FD_ZERO(&fdset);
-		FD_SET(fd, &fdset);
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 25/46] Add definition for sub-states

This additional level of the state machine is used by the states SEND and REC
and will help to remove some work-arounds that are currently only there because
this additional level is missing.
---
 lib/defines.h   |    6 ++++++
 lib/obex_main.h |    1 +
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/lib/defines.h b/lib/defines.h
index 4169911..eb2257b 100644
--- a/lib/defines.h
+++ b/lib/defines.h
 <at>  <at>  -29,6 +29,12  <at>  <at>  enum obex_state {
 	STATE_REC,
 };

+enum obex_substate {
+	SUBSTATE_RECEIVE_RX,
+	SUBSTATE_PREPARE_TX,
+	SUBSTATE_TRANSMIT_TX,
+};
+
 #define OBEX_SRM_FLAG_WAIT_LOCAL  (1 << 0)
 #define OBEX_SRM_FLAG_WAIT_REMOTE (1 << 1)

diff --git a/lib/obex_main.h b/lib/obex_main.h
index 8a3e975..24d37c5 100644
--- a/lib/obex_main.h
+++ b/lib/obex_main.h
 <at>  <at>  -41,6 +41,7  <at>  <at>  struct obex {
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 14/46] Cleanup of obex_test

Change obex_test so that only the compiled-in parts are visible. Prepare the
bluetooth part for addition of L2CAP usage.
---
 apps/obex_test/obex_test.c |  247 ++++++++++++++++++++++++--------------------
 1 files changed, 136 insertions(+), 111 deletions(-)

diff --git a/apps/obex_test/obex_test.c b/apps/obex_test/obex_test.c
index 350d808..7527a51 100644
--- a/apps/obex_test/obex_test.c
+++ b/apps/obex_test/obex_test.c
 <at>  <at>  -27,6 +27,11  <at>  <at> 
 #include "../lib/bluez_compat.h"
 #ifdef _WIN32
 bdaddr_t bluez_compat_bdaddr_any = { BTH_ADDR_NULL };
+int str2ba(const char *str, bdaddr_t *ba) {
+	//TODO
+	*ba = *BDADDR_ANY;
+	return 0;
+}
 #endif
 #endif

 <at>  <at>  -36,9 +41,11  <at>  <at>  bdaddr_t bluez_compat_bdaddr_any = { BTH_ADDR_NULL };
 #include "obex_test_client.h"
 #include "obex_test_server.h"

-#ifndef _WIN32
+#if defined(_WIN32)
+#undef HAVE_CABLE_OBEX
+#else
(Continue reading)

Hendrik Sattler | 15 Jul 2011 18:45
Picon

[PATCH 17/46] Remove auto-generated autotools INSTALL file

The ./bootstrap (or autoreconf -i) will automatically copy the file to its
place but there is no need to keep that in the repository (it is not the one
that's shipped in releases anyway).
---
 .gitignore |    1 +
 INSTALL    |  236 ------------------------------------------------------------
 2 files changed, 1 insertions(+), 236 deletions(-)
 delete mode 100644 INSTALL

diff --git a/.gitignore b/.gitignore
index 2e6307f..5bd619f 100644
--- a/.gitignore
+++ b/.gitignore
 <at>  <at>  -5,6 +5,7  <at>  <at> 
 *.so
 .deps
 .libs
+INSTALL
 Makefile
 Makefile.in
 aclocal.m4
diff --git a/INSTALL b/INSTALL
deleted file mode 100644
index 56b077d..0000000
--- a/INSTALL
+++ /dev/null
 <at>  <at>  -1,236 +0,0  <at>  <at> 
-Installation Instructions
-*************************
-
(Continue reading)


Gmane