Skip to contentSkip to conversation

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

PATCH New Zhenhua Zhang 1 participant 5 messages Sep 9, 2010

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

Hi,

These patches move bluez/src/btio.[ch] out from source directory and make it identical with obex'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 93079ae..8b273ca 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    |    8 +-
 Makefile.tools |    2 +-
 btio/btio.c    | 1299 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 btio/btio.h    |   94 ++++
 src/btio.c     | 1299 --------------------------------------------------------
 src/btio.h     |   94 ----
 6 files changed, 1399 insertions(+), 1397 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 +5 -3
index f74872d..4dcb56a 100644
@@ -101,6 +101,8 @@ endif
 
 gdbus_sources = gdbus/gdbus.h gdbus/mainloop.c gdbus/object.c gdbus/watch.c
 
+btio_sources = btio/btio.h btio/btio.c
+
 builtin_modules =
 builtin_sources =
 builtin_nodist =
@@ -215,14 +217,14 @@ endif
 sbin_PROGRAMS += src/bluetoothd
 
 src_bluetoothd_SOURCES = $(gdbus_sources) $(builtin_sources) \
-			$(attrib_sources) \
+			$(attrib_sources) $(btio_sources) \
 			$(mcap_sources) \
 			src/main.c src/log.h src/log.c \
 			src/security.c src/rfkill.c src/hcid.h src/sdpd.h \
 			src/sdpd-server.c src/sdpd-request.c \
 			src/sdpd-service.c src/sdpd-database.c \
 			src/attrib-server.h src/attrib-server.c \
-			src/sdp-xml.h src/sdp-xml.c src/btio.h src/btio.c \
+			src/sdp-xml.h src/sdp-xml.c \
 			src/textfile.h src/textfile.c \
 			src/glib-helper.h src/glib-helper.c \
 			src/oui.h src/oui.c src/uinput.h src/ppoll.h \
@@ -356,7 +358,7 @@ AM_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ @CAPNG_CFLAGS@ \
 
 INCLUDES = -I$(builddir)/lib -I$(builddir)/src -I$(srcdir)/src \
 			-I$(srcdir)/audio -I$(srcdir)/sbc -I$(srcdir)/gdbus \
-			-I$(srcdir)/attrib
+			-I$(srcdir)/attrib -I$(srcdir)/btio
 
 if MCAP
 	INCLUDES += -I$(builddir)/health
Makefile.tools +1 -1
index 1c46542..14ecf31 100644
@@ -170,7 +170,7 @@ test_bdaddr_LDADD = lib/libbluetooth.la
 
 test_agent_LDADD = @DBUS_LIBS@
 
-test_btiotest_SOURCES = test/btiotest.c src/btio.h src/btio.c
+test_btiotest_SOURCES = test/btiotest.c btio/btio.h btio/btio.c
 test_btiotest_LDADD = @GLIB_LIBS@ lib/libbluetooth.la
 
 test_test_textfile_SOURCES = test/test-textfile.c src/textfile.h src/textfile.c
btio/btio.c new file +1299 -0

1,299 lines not on this page · raw message

btio/btio.h new file +94 -0

94 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 -94

94 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 8b273ca..41b698f 100644
@@ -1074,39 +1074,6 @@ gboolean bt_io_accept(GIOChannel *io, BtIOConnect connect, gpointer 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 81fda8e..89d3d08 100644
@@ -77,9 +77,6 @@ typedef void (*BtIOConnect)(GIOChannel *io, GError *err, gpointer user_data);
 gboolean bt_io_accept(GIOChannel *io, BtIOConnect connect, gpointer 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

PATCH 4/4 btio: Add ifndef/endif guard for btio.h

In reply to Zhenhua Zhang

To avoid circular inclusion of include file.

---
 btio/btio.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
btio/btio.h +3 -0
index 89d3d08..5f2911a 100644
@@ -21,6 +21,8 @@
  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */
+#ifndef BT_IO_H
+#define BT_IO_H
 
 #include <glib.h>
 
@@ -89,3 +91,4 @@ GIOChannel *bt_io_listen(BtIOType type, BtIOConnect connect,
 				GDestroyNotify destroy, GError **err,
 				BtIOOption opt1, ...);
 
+#endif
Signature · 1 line
1.7.0.4