Bug#401203: patch for k700i behaviour

2006-12-02 Thread Hendrik Sattler
Am Samstag 02 Dezember 2006 13:08 schrieb Hendrik Sattler:
> the problem actually is a misbehaviour in libopenobex.
> It send the STREAMAVAIL too early, thus the file handle is not open, yet.
> This is triggered by the K700i sending the first (END-OF-)BODY Header in
> the first push packet (Siemens phones send it in the second packet and
> obexpushd was developed with those as clients).
> SE K700i is not to blame, here. It sends the name header before the body
> header.
>
> The correct solution will be to fix libopenobex.
>
> However, attached is a small patch that fixes it in obexpushd.

Sorry, patch was slightly broken. Here's a fixed one.
I actually tested it with a K700i (both small and big files).

HS
Index: obexpushd-0.4+svn10/src/obexpushd.c
===
--- obexpushd-0.4+svn10.orig/src/obexpushd.c	2006-12-02 12:59:14.465903016 +0100
+++ obexpushd-0.4+svn10/src/obexpushd.c	2006-12-02 14:19:35.091173266 +0100
@@ -396,6 +396,12 @@
 
 	if (!buf)
 		return -EINVAL;
+	if (!data->out) {
+		err = put_open(handle);
+		if (err)
+			return err;
+	}
+
 	(void)fwrite(buf,(size_t)len,1,data->out);
 	err = ferror(data->out);
 	if (err)
@@ -547,13 +553,15 @@
 		data->count += 1;
 		data->length = 0;
 		data->time = 0;
+		data->out = NULL;
 		break;
 
 	case OBEX_EV_REQCHECK:
-		if (put_open(handle) < 0)
-			(void)OBEX_ObjectSetRsp(obj,
-		OBEX_RSP_FORBIDDEN,
-		OBEX_RSP_FORBIDDEN);
+		if (!data->out)
+			if (put_open(handle) < 0)
+(void)OBEX_ObjectSetRsp(obj,
+			OBEX_RSP_FORBIDDEN,
+			OBEX_RSP_FORBIDDEN);
 		break;
 
 	case OBEX_EV_STREAMAVAIL:


Bug#401203: patch for k700i behaviour

2006-12-02 Thread Hendrik Sattler
Hi,

the problem actually is a misbehaviour in libopenobex.
It send the STREAMAVAIL too early, thus the file handle is not open, yet.
This is triggered by the K700i sending the first (END-OF-)BODY Header in the 
first push packet (Siemens phones send it in the second packet and obexpushd 
was developed with those as clients).
SE K700i is not to blame, here. It sends the name header before the body 
header.

The correct solution will be to fix libopenobex.

However, attached is a small patch that fixes it in obexpushd.

HS
Index: obexpushd-0.4+svn10/src/obexpushd.c
===
--- obexpushd-0.4+svn10.orig/src/obexpushd.c	2006-12-02 12:59:14.465903016 +0100
+++ obexpushd-0.4+svn10/src/obexpushd.c	2006-12-02 13:02:08.696791766 +0100
@@ -396,6 +396,12 @@
 
 	if (!buf)
 		return -EINVAL;
+	if (!data->out) {
+		err = put_open(handle);
+		if (err)
+			return err;
+	}
+
 	(void)fwrite(buf,(size_t)len,1,data->out);
 	err = ferror(data->out);
 	if (err)
@@ -547,13 +553,15 @@
 		data->count += 1;
 		data->length = 0;
 		data->time = 0;
+		data->out = NULL;
 		break;
 
 	case OBEX_EV_REQCHECK:
-		if (put_open(handle) < 0)
-			(void)OBEX_ObjectSetRsp(obj,
-		OBEX_RSP_FORBIDDEN,
-		OBEX_RSP_FORBIDDEN);
+		if (!data->out)
+			if (put_open(handle) < 0)
+(void)OBEX_ObjectSetRsp(obj,
+			OBEX_RSP_FORBIDDEN,
+			OBEX_RSP5A_FORBIDDEN);
 		break;
 
 	case OBEX_EV_STREAMAVAIL: