Skip to contentSkip to conversation

obex: isolate btio.[ch] as a library and do some cleanup

PATCH In review Zhenhua Zhang 2 participants 7 messages Sep 9, 2010 – Sep 10, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

These patches move obexd/src/btio.[ch] out from source directory and make it identical with bluez's btio.[ch]. So we can freely copy them among bluez, obex and ofono.

Regards,
Zhenhua

#1 lore raw

PATCH 1/4 btio: Remove blank line at EOF

---
 src/btio.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
src/btio.c +0 -1
index 485eec6..42a3bcd 100644
@@ -1297,4 +1297,3 @@ GQuark bt_io_error_quark(void)
 {
 	return g_quark_from_static_string("bt-io-error-quark");
 }
-
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH 2/4 btio: Seperate btio.[ch] into btio directory

In reply to Zhenhua Zhang

Seperate btio.[ch] from src directory to btio sub-folder.

---
 Makefile.am |   19 +-
 btio/btio.c | 1299 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 btio/btio.h |   97 +++++
 src/btio.c  | 1299 -----------------------------------------------------------
 src/btio.h  |   97 -----
 5 files changed, 1406 insertions(+), 1405 deletions(-)
 create mode 100644 btio/btio.c
 create mode 100644 btio/btio.h
 delete mode 100644 src/btio.c
 delete mode 100644 src/btio.h
Makefile.am +10 -9
index 07fc27d..961a375 100644
@@ -18,6 +18,8 @@ gwobex_sources = gwobex/gw-obex.h gwobex/gw-obex.c \
 			gwobex/obex-xfer.h gwobex/obex-xfer.c \
 			gwobex/utils.h gwobex/utils.c gwobex/log.h
 
+btio_sources = btio/btio.h btio/btio.c
+
 libexec_PROGRAMS =
 
 if SERVER
@@ -65,11 +67,10 @@ builtin_nodist += plugins/phonebook.c
 
 libexec_PROGRAMS += src/obexd
 
-src_obexd_SOURCES = $(gdbus_sources) $(builtin_sources) \
+src_obexd_SOURCES = $(gdbus_sources) $(builtin_sources) $(btio_sources) \
 			src/main.c src/obexd.h src/plugin.h src/plugin.c \
-			src/log.h src/log.c src/btio.h src/btio.c \
-			src/dbus.h src/manager.c src/obex.h src/obex.c \
-			src/obex-priv.h \
+			src/log.h src/log.c src/dbus.h src/manager.c \
+			src/obex.h src/obex.c src/obex-priv.h \
 			src/mimetype.h src/mimetype.c \
 			src/service.h src/service.c \
 			src/transport.h src/transport.c \
@@ -107,13 +108,12 @@ service_in_files += client/obex-client.service.in
 
 libexec_PROGRAMS += client/obex-client
 
-client_obex_client_SOURCES = $(gdbus_sources) $(gwobex_sources) client/main.c \
-				client/session.h client/session.c \
+client_obex_client_SOURCES = $(gdbus_sources) $(gwobex_sources) $(btio_sources) \
+				client/main.c client/session.h client/session.c \
 				src/log.h src/log.c \
 				client/pbap.h client/pbap.c \
 				client/sync.h client/sync.c \
-				client/transfer.h client/transfer.c \
-				src/btio.c src/btio.h
+				client/transfer.h client/transfer.c
 
 client_obex_client_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ @OPENOBEX_LIBS@ @BLUEZ_LIBS@
 endif
@@ -126,7 +126,8 @@ AM_CFLAGS = @OPENOBEX_CFLAGS@ @BLUEZ_CFLAGS@ @EBOOK_CFLAGS@ \
 			-DOBEX_PLUGIN_BUILTIN -DPLUGINDIR=\""$(plugindir)"\"
 
 INCLUDES = -I$(builddir)/src -I$(srcdir)/src -I$(srcdir)/plugins \
-				-I$(srcdir)/gdbus -I$(srcdir)/gwobex
+				-I$(srcdir)/gdbus -I$(srcdir)/gwobex \
+				-I$(srcdir)/btio
 
 CLEANFILES = $(service_DATA) $(builtin_files)
 
btio/btio.c new file +1299 -0

1,299 lines not on this page · raw message

btio/btio.h new file +97 -0

97 lines not on this page · raw message

src/btio.c deleted +0 -1299

1,299 lines not on this page · raw message

src/btio.h deleted +0 -97

97 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#3 lore raw

PATCH 3/4 btio: Remove unused bt_io_set function

In reply to Zhenhua Zhang

It is not used by either obex or bluez.

---
 btio/btio.c |   33 ---------------------------------
 btio/btio.h |    3 ---
 2 files changed, 0 insertions(+), 36 deletions(-)
btio/btio.c +0 -33
index 42a3bcd..d4969e5 100644
@@ -1074,39 +1074,6 @@ gboolean bt_io_accept(GIOChannel *io, BtIOConnect connect, void *user_data,
 	return TRUE;
 }
 
-gboolean bt_io_set(GIOChannel *io, BtIOType type, GError **err,
-							BtIOOption opt1, ...)
-{
-	va_list args;
-	gboolean ret;
-	struct set_opts opts;
-	int sock;
-
-	va_start(args, opt1);
-	ret = parse_set_opts(&opts, err, opt1, args);
-	va_end(args);
-
-	if (!ret)
-		return ret;
-
-	sock = g_io_channel_unix_get_fd(io);
-
-	switch (type) {
-	case BT_IO_L2RAW:
-	case BT_IO_L2CAP:
-		return l2cap_set(sock, opts.sec_level, opts.imtu, opts.omtu,
-						opts.mode, opts.master, err);
-	case BT_IO_RFCOMM:
-		return rfcomm_set(sock, opts.sec_level, opts.master, err);
-	case BT_IO_SCO:
-		return sco_set(sock, opts.mtu, err);
-	}
-
-	g_set_error(err, BT_IO_ERROR, BT_IO_ERROR_INVALID_ARGS,
-			"Unknown BtIO type %d", type);
-	return FALSE;
-}
-
 gboolean bt_io_get(GIOChannel *io, BtIOType type, GError **err,
 							BtIOOption opt1, ...)
 {
btio/btio.h +0 -3
index e9dcc9f..3c5db2a 100644
@@ -79,9 +79,6 @@ typedef void (*BtIOConnect)(GIOChannel *io, GError *err, void *user_data);
 gboolean bt_io_accept(GIOChannel *io, BtIOConnect connect, void *user_data,
 					GDestroyNotify destroy, GError **err);
 
-gboolean bt_io_set(GIOChannel *io, BtIOType type, GError **err,
-						BtIOOption opt1, ...);
-
 gboolean bt_io_get(GIOChannel *io, BtIOType type, GError **err,
 						BtIOOption opt1, ...);
 
Signature · 1 line
1.7.0.4
#4 lore raw

Re: [PATCH 3/4] btio: Remove unused bt_io_set function

Hi,

Quoted 5 lines · Zhenhua Zhang

It is not used by either obex or bluez.

---
 btio/btio.c |   33 ---------------------------------
 btio/btio.h |    3 ---
 2 files changed, 0 insertions(+), 36 deletions(-)

I don't think removing this feature is a good idea. Even though there aren't any current users of bt_io_set doesn't mean that there wont be in the future. I remember e.g. discussions regarding AMP about applications needing the ability to request a switch from BR/EDR to WLAN for an active connection. This could e.g. be accomplished through a setsockopt call. Other uses for setsockopt while a connection is open, or even changing settings for an existing server socket might exist too.

Johan

#5 lore raw

RE: [PATCH 3/4] btio: Remove unused bt_io_set function

Hi Johan,

Quoted 18 lines · Johan Hedberg

Hi,

Quoted 4 lines · Zhenhua Zhang

It is not used by either obex or bluez.
---
btio/btio.c | 33 --------------------------------- btio/btio.h |
3 --- 2 files changed, 0 insertions(+), 36 deletions(-)

I don't think removing this feature is a good idea. Even though there aren't any current users of bt_io_set doesn't mean that there wont be in
the future. I remember e.g. discussions regarding AMP about applications needing the ability to request a switch from BR/EDR to WLAN for an active connection. This could e.g. be accomplished through a setsockopt call. Other uses for setsockopt while a connection is open, or even changing settings for an existing server socket might exist too.

Quoted 1 line

Johan

That's fine for me. I don't see any current function call so I have this patch. I will resend them and remove patch 3/4. Let me know if you have other suggestiosn.

Regards,
Zhenhua

#6 lore raw

PATCH 4/4 btio: Replace void * with gpointer

In reply to Zhenhua Zhang

TO make it consistent with bluez btio.c.

---
 btio/btio.c |   24 ++++++++++++------------
 btio/btio.h |   10 +++++-----
 2 files changed, 17 insertions(+), 17 deletions(-)
btio/btio.c +12 -12
index d4969e5..41b698f 100644
@@ -62,20 +62,20 @@ struct set_opts {
 
 struct connect {
 	BtIOConnect connect;
-	void *user_data;
+	gpointer user_data;
 	GDestroyNotify destroy;
 };
 
 struct accept {
 	BtIOConnect connect;
-	void *user_data;
+	gpointer user_data;
 	GDestroyNotify destroy;
 };
 
 struct server {
 	BtIOConnect connect;
 	BtIOConfirm confirm;
-	void *user_data;
+	gpointer user_data;
 	GDestroyNotify destroy;
 };
 
@@ -115,7 +115,7 @@ static gboolean check_nval(GIOChannel *io)
 }
 
 static gboolean accept_cb(GIOChannel *io, GIOCondition cond,
-							void *user_data)
+							gpointer user_data)
 {
 	struct accept *accept = user_data;
 	GError *err = NULL;
@@ -136,7 +136,7 @@ static gboolean accept_cb(GIOChannel *io, GIOCondition cond,
 }
 
 static gboolean connect_cb(GIOChannel *io, GIOCondition cond,
-							void *user_data)
+							gpointer user_data)
 {
 	struct connect *conn = user_data;
 	GError *gerr = NULL;
@@ -169,7 +169,7 @@ static gboolean connect_cb(GIOChannel *io, GIOCondition cond,
 }
 
 static gboolean server_cb(GIOChannel *io, GIOCondition cond,
-							void *user_data)
+							gpointer user_data)
 {
 	struct server *server = user_data;
 	int srv_sock, cli_sock;
@@ -201,7 +201,7 @@ static gboolean server_cb(GIOChannel *io, GIOCondition cond,
 }
 
 static void server_add(GIOChannel *io, BtIOConnect connect,
-				BtIOConfirm confirm, void *user_data,
+				BtIOConfirm confirm, gpointer user_data,
 				GDestroyNotify destroy)
 {
 	struct server *server;
@@ -219,7 +219,7 @@ static void server_add(GIOChannel *io, BtIOConnect connect,
 }
 
 static void connect_add(GIOChannel *io, BtIOConnect connect,
-				void *user_data, GDestroyNotify destroy)
+				gpointer user_data, GDestroyNotify destroy)
 {
 	struct connect *conn;
 	GIOCondition cond;
@@ -234,7 +234,7 @@ static void connect_add(GIOChannel *io, BtIOConnect connect,
 					(GDestroyNotify) connect_remove);
 }
 
-static void accept_add(GIOChannel *io, BtIOConnect connect, void *user_data,
+static void accept_add(GIOChannel *io, BtIOConnect connect, gpointer user_data,
 							GDestroyNotify destroy)
 {
 	struct accept *accept;
@@ -1046,7 +1046,7 @@ static gboolean get_valist(GIOChannel *io, BtIOType type, GError **err,
 	return FALSE;
 }
 
-gboolean bt_io_accept(GIOChannel *io, BtIOConnect connect, void *user_data,
+gboolean bt_io_accept(GIOChannel *io, BtIOConnect connect, gpointer user_data,
 					GDestroyNotify destroy, GError **err)
 {
 	int sock;
@@ -1162,7 +1162,7 @@ failed:
 }
 
 GIOChannel *bt_io_connect(BtIOType type, BtIOConnect connect,
-				void *user_data, GDestroyNotify destroy,
+				gpointer user_data, GDestroyNotify destroy,
 				GError **gerr, BtIOOption opt1, ...)
 {
 	GIOChannel *io;
@@ -1216,7 +1216,7 @@ GIOChannel *bt_io_connect(BtIOType type, BtIOConnect connect,
 }
 
 GIOChannel *bt_io_listen(BtIOType type, BtIOConnect connect,
-				BtIOConfirm confirm, void *user_data,
+				BtIOConfirm confirm, gpointer user_data,
 				GDestroyNotify destroy, GError **err,
 				BtIOOption opt1, ...)
 {
btio/btio.h +5 -5
index 3c5db2a..5f2911a 100644
@@ -72,22 +72,22 @@ typedef enum {
 	BT_IO_SEC_HIGH,
 } BtIOSecLevel;
 
-typedef void (*BtIOConfirm)(GIOChannel *io, void *user_data);
+typedef void (*BtIOConfirm)(GIOChannel *io, gpointer user_data);
 
-typedef void (*BtIOConnect)(GIOChannel *io, GError *err, void *user_data);
+typedef void (*BtIOConnect)(GIOChannel *io, GError *err, gpointer user_data);
 
-gboolean bt_io_accept(GIOChannel *io, BtIOConnect connect, void *user_data,
+gboolean bt_io_accept(GIOChannel *io, BtIOConnect connect, gpointer user_data,
 					GDestroyNotify destroy, GError **err);
 
 gboolean bt_io_get(GIOChannel *io, BtIOType type, GError **err,
 						BtIOOption opt1, ...);
 
 GIOChannel *bt_io_connect(BtIOType type, BtIOConnect connect,
-				void *user_data, GDestroyNotify destroy,
+				gpointer user_data, GDestroyNotify destroy,
 				GError **err, BtIOOption opt1, ...);
 
 GIOChannel *bt_io_listen(BtIOType type, BtIOConnect connect,
-				BtIOConfirm confirm, void *user_data,
+				BtIOConfirm confirm, gpointer user_data,
 				GDestroyNotify destroy, GError **err,
 				BtIOOption opt1, ...);
 
Signature · 1 line
1.7.0.4