diff options
author | Alexander Orlenko <zxteam@gmail.com> | 2010-08-12 11:22:23 +1100 |
---|---|---|
committer | Alexander Orlenko <zxteam@gmail.com> | 2010-08-12 11:22:23 +1100 |
commit | 2536337055de99f662612cdc3db6a969289c87ce (patch) | |
tree | a2ade2c4c1a29c06f20459da926d94cacecefe8a | |
parent | 6948e7dbb801105c5fb7d94d3ae6be88d669d4f4 (diff) | |
download | bluez-tools-2536337055de99f662612cdc3db6a969289c87ce.tar.gz |
Part of prev commit (forgot to add '-a' option)
55 files changed, 394 insertions, 218 deletions
diff --git a/configure.ac b/configure.ac index bf2ae33..6f403a1 100644 --- a/configure.ac +++ b/configure.ac @@ -3,14 +3,73 @@ AC_PREREQ([2.65]) AM_INIT_AUTOMAKE([1.11 no-define foreign -Wall subdir-objects]) AC_CONFIG_HEADERS([config.h]) +# The default CFLAGS and CXXFLAGS in Autoconf are "-g -O2" for gcc and just +# "-g" for any other compiler. There doesn't seem to be a standard way of +# getting rid of the -g (which I don't think is needed for a production +# library). This fudge seems to achieve the necessary. First, we remember the +# externally set values of CFLAGS and CXXFLAGS. Then call the AC_PROG_CC and +# AC_PROG_CXX macros to find the compilers - if CFLAGS and CXXFLAGS are not +# set, they will be set to Autoconf's defaults. Afterwards, if the original +# values were not set, remove the -g from the Autoconf defaults. +# (PH 02-May-07) + +remember_set_CFLAGS="$CFLAGS" + AC_PROG_CC AC_PROG_CC_C99 + +if test "x$remember_set_CFLAGS" = "x" +then + if test "$CFLAGS" = "-g -O2" + then + CFLAGS="-O2" + elif test "$CFLAGS" = "-g" + then + CFLAGS="" + fi +fi + AC_PROG_INSTALL AM_PROG_CC_C_O +# Handle --disable-obex +AC_ARG_ENABLE(obex, + AS_HELP_STRING([--disable-obex], + [disable obex support]), + , enable_obex=yes) + +# Checks for header files. +AC_HEADER_STDC + +# Check for the availability of dbus and glib libs +PKG_PROG_PKG_CONFIG + PKG_CHECK_MODULES([DBUS], [dbus-1 >= 1.2.16]) PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.24.0]) PKG_CHECK_MODULES([DBUS_GLIB], [dbus-glib-1 >= 0.84]) +# Check for the availability of libreadline +AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_H=1]) +AC_CHECK_HEADERS([readline/history.h], [HAVE_HISTORY_H=1]) +AC_CHECK_LIB([readline], [readline], [HAVE_LIB_READLINE=1]) + +if test "$enable_obex" = "yes"; then + AC_DEFINE([OBEX_SUPPORT], [], [ + Define to allow bluez-tools to be compiled with obex support.]) + + if test "$HAVE_READLINE_H" != "1"; then + echo "** readline/readline.h was not found." + exit 1 + fi + if test "$HAVE_HISTORY_H" != "1"; then + echo "** readline/history.h was not found." + exit 1 + fi + LIBREADLINE="-lreadline" +fi +AC_SUBST(LIBREADLINE) + +AM_CONDITIONAL(OBEX, test "$enable_obex" = "yes") + AC_CONFIG_FILES([Makefile src/Makefile]) AC_OUTPUT diff --git a/contrib/bluez-api-4.69-fixed/adapter-api.txt b/contrib/bluez-api-4.69-fixed/adapter-api.txt index 0653ccd..540bb0c 100644 --- a/contrib/bluez-api-4.69-fixed/adapter-api.txt +++ b/contrib/bluez-api-4.69-fixed/adapter-api.txt @@ -31,7 +31,7 @@ Methods dict GetProperties() Possible Errors: org.bluez.Error.DoesNotExist org.bluez.Error.InvalidArguments - void RequestSession() + void RequestSession() {unneeded_in_bluez_tools} This method will request a client session that provides operational Bluetooth. A possible mode @@ -39,7 +39,7 @@ Methods dict GetProperties() Possible Errors: org.bluez.Error.Rejected - void ReleaseSession() + void ReleaseSession() {unneeded_in_bluez_tools} Release a previous requested session. diff --git a/contrib/bluez-api-4.69-fixed/device-api.txt b/contrib/bluez-api-4.69-fixed/device-api.txt index 551d11a..8b7788c 100644 --- a/contrib/bluez-api-4.69-fixed/device-api.txt +++ b/contrib/bluez-api-4.69-fixed/device-api.txt @@ -79,7 +79,7 @@ Methods dict GetProperties() org.bluez.Error.Failed org.bluez.Error.OutOfMemory - object CreateNode(string uuid) + object CreateNode(string uuid) {unsupported_in_bluez} Creates a persistent device node binding with a remote device. The actual support for the specified @@ -90,7 +90,7 @@ Methods dict GetProperties() Possible errors: org.bluez.Error.InvalidArguments org.bluez.Error.NotSupported - void RemoveNode(object node) + void RemoveNode(object node) {unsupported_in_bluez} Removes a persistent device node binding. @@ -108,11 +108,11 @@ Signals PropertyChanged(string name, variant value) disconnection to a remote device has been requested. The actual disconnection will happen 2 seconds later. - NodeCreated(object node) + NodeCreated(object node) {unsupported_in_bluez} Parameter is object path of created device node. - NodeRemoved(object node) + NodeRemoved(object node) {unsupported_in_bluez} Parameter is object path of removed device node. @@ -175,7 +175,7 @@ Properties string Address [readonly] emitted PropertyChanged signal will show the remote name again. - array{object} Nodes [readonly] + array{object} Nodes [readonly] {unsupported_in_bluez} List of device node object paths. diff --git a/contrib/build-mans.sh b/contrib/build-mans.sh index 9f04983..7191465 100755 --- a/contrib/build-mans.sh +++ b/contrib/build-mans.sh @@ -3,3 +3,10 @@ pod2man -n bt-adapter -c "bluez-tools" -r "" man/bt-adapter.pod > ../src/bt-adapter.1 pod2man -n bt-agent -c "bluez-tools" -r "" man/bt-agent.pod > ../src/bt-agent.1 pod2man -n bt-device -c "bluez-tools" -r "" man/bt-device.pod > ../src/bt-device.1 + +pod2man -n bt-monitor -c "bluez-tools" -r "" man/bt-monitor.pod > ../src/bt-monitor.1 + +pod2man -n bt-audio -c "bluez-tools" -r "" man/bt-audio.pod > ../src/bt-audio.1 +pod2man -n bt-input -c "bluez-tools" -r "" man/bt-input.pod > ../src/bt-input.1 +pod2man -n bt-network -c "bluez-tools" -r "" man/bt-network.pod > ../src/bt-network.1 +pod2man -n bt-serial -c "bluez-tools" -r "" man/bt-serial.pod > ../src/bt-serial.1 diff --git a/contrib/gen-dbus-gobject.pl b/contrib/gen-dbus-gobject.pl index fa86326..be2d85f 100755 --- a/contrib/gen-dbus-gobject.pl +++ b/contrib/gen-dbus-gobject.pl @@ -328,7 +328,9 @@ sub generate_source { #endif #include <string.h> + #include <glib.h> +#include <dbus/dbus-glib.h> #include "../dbus-common.h" #include "../marshallers.h" diff --git a/contrib/man/bt-adapter.pod b/contrib/man/bt-adapter.pod index d03e274..5a19ada 100644 --- a/contrib/man/bt-adapter.pod +++ b/contrib/man/bt-adapter.pod @@ -101,4 +101,4 @@ Alexander Orlenko <zxteam@gmail.com>. =head1 SEE ALSO -bt-agent(1) bt-device(1) +bt-agent(1) bt-audio(1) bt-device(1) bt-input(1) bt-monitor(1) bt-network(1) bt-serial(1) diff --git a/contrib/man/bt-agent.pod b/contrib/man/bt-agent.pod index 5d2764f..927d224 100644 --- a/contrib/man/bt-agent.pod +++ b/contrib/man/bt-agent.pod @@ -32,4 +32,4 @@ Alexander Orlenko <zxteam@gmail.com>. =head1 SEE ALSO -bt-adapter(1) bt-device(1) +bt-adapter(1) bt-audio(1) bt-device(1) bt-input(1) bt-monitor(1) bt-network(1) bt-serial(1) diff --git a/contrib/man/bt-audio.pod b/contrib/man/bt-audio.pod index 2eb3bf5..8f88833 100644 --- a/contrib/man/bt-audio.pod +++ b/contrib/man/bt-audio.pod @@ -1,6 +1,6 @@ =head1 NAME -bt-adapter - a bluetooth generic audio manager +bt-audio - a bluetooth generic audio manager =head1 SYNOPSIS @@ -39,4 +39,4 @@ Alexander Orlenko <zxteam@gmail.com>. =head1 SEE ALSO -bt-agent(1) bt-device(1) +bt-adapter(1) bt-agent(1) bt-device(1) bt-input(1) bt-monitor(1) bt-network(1) bt-serial(1) diff --git a/contrib/man/bt-device.pod b/contrib/man/bt-device.pod index 50f4221..3821905 100644 --- a/contrib/man/bt-device.pod +++ b/contrib/man/bt-device.pod @@ -38,7 +38,7 @@ B<-l, --list> List added devices B<-c, --connect E<lt>macE<gt>> - Connect to the remote device by his MAC and retrieve all SDP + Connect to the remote device by his MAC, retrieve all SDP records and then initiate the pairing B<-r, --remove> @@ -110,4 +110,4 @@ Alexander Orlenko <zxteam@gmail.com>. =head1 SEE ALSO -bt-agent(1) bt-adapter(1) +bt-adapter(1) bt-agent(1) bt-audio(1) bt-input(1) bt-monitor(1) bt-network(1) bt-serial(1) diff --git a/contrib/man/bt-input.pod b/contrib/man/bt-input.pod index c0309e8..43ff179 100644 --- a/contrib/man/bt-input.pod +++ b/contrib/man/bt-input.pod @@ -1,6 +1,6 @@ =head1 NAME -bt-adapter - a bluetooth input manager +bt-input - a bluetooth input manager =head1 SYNOPSIS @@ -39,4 +39,4 @@ Alexander Orlenko <zxteam@gmail.com>. =head1 SEE ALSO -bt-audio(1) bt-device(1) +bt-adapter(1) bt-agent(1) bt-audio(1) bt-device(1) bt-monitor(1) bt-network(1) bt-serial(1) diff --git a/contrib/man/bt-monitor.pod b/contrib/man/bt-monitor.pod index 6058f68..7f3c196 100644 --- a/contrib/man/bt-monitor.pod +++ b/contrib/man/bt-monitor.pod @@ -1,6 +1,6 @@ =head1 NAME -bt-device - a bluetooth monitor +bt-monitor - a bluetooth monitor =head1 SYNOPSIS @@ -52,4 +52,4 @@ Alexander Orlenko <zxteam@gmail.com>. =head1 SEE ALSO -bt-adapter(1) bt-device(1) bt-audio(1) bt-input(1) bt-network(1) +bt-adapter(1) bt-agent(1) bt-audio(1) bt-device(1) bt-input(1) bt-network(1) bt-serial(1) diff --git a/contrib/man/bt-network.pod b/contrib/man/bt-network.pod index 814375a..711022e 100644 --- a/contrib/man/bt-network.pod +++ b/contrib/man/bt-network.pod @@ -1,22 +1,24 @@ =head1 NAME -bt-adapter - a bluetooth network manager +bt-network - a bluetooth network manager =head1 SYNOPSIS -bt-input [OPTION...] +bt-network [OPTION...] Help Options: -h, --help Application Options: -a, --adapter=<name|mac> - -c, --connect=<name|mac> + -c, --connect <name|mac> <uuid> -d, --disconnect=<name|mac> + -s, --server <gn|panu|nap> <brige> =head1 DESCRIPTION -This utility is used to manage outgoing input (HID) service connections. +This utility is used to manage network services (client/server). +All servers will be automatically unregistered when the application terminates. =head1 OPTIONS @@ -27,11 +29,16 @@ B<-a, --adapter E<lt>name|macE<gt>> Specify adapter to use by his Name or MAC address (if this option does not defined - default adapter used) -B<-c, --connect E<lt>name|macE<gt>> - Connect to the input device +B<-c, --connect E<lt>name|macE<gt> E<lt>uuidE<gt>> + Connect to the network device and return the network interface name, + uuid can be either one of "gn", "panu" or "nap" B<-d, --disconnect E<lt>name|macE<gt>> - Disconnect from the input device + Disconnect from the network device + +B<-s, --server E<lt>gn|panu|napE<gt> E<lt>brigeE<gt>> + Register server for the provided UUID, + every new connection to this server will be added the bridge interface =head1 AUTHOR @@ -39,4 +46,4 @@ Alexander Orlenko <zxteam@gmail.com>. =head1 SEE ALSO -bt-agent(1) bt-device(1) +bt-adapter(1) bt-agent(1) bt-audio(1) bt-device(1) bt-input(1) bt-monitor(1) bt-serial(1) diff --git a/contrib/man/bt-serial.pod b/contrib/man/bt-serial.pod index edeba53..058bcdb 100644 --- a/contrib/man/bt-serial.pod +++ b/contrib/man/bt-serial.pod @@ -1,22 +1,22 @@ =head1 NAME -bt-adapter - a bluetooth input manager +bt-serial - a bluetooth serial manager =head1 SYNOPSIS -bt-input [OPTION...] +bt-serial [OPTION...] Help Options: -h, --help Application Options: -a, --adapter=<name|mac> - -c, --connect=<name|mac> - -d, --disconnect=<name|mac> + -c, --connect <name|mac> <pattern> + -d, --disconnect <name|mac> <tty_device> =head1 DESCRIPTION -This utility is used to manage outgoing input (HID) service connections. +This utility is used to manage serial service connections. =head1 OPTIONS @@ -27,11 +27,14 @@ B<-a, --adapter E<lt>name|macE<gt>> Specify adapter to use by his Name or MAC address (if this option does not defined - default adapter used) -B<-c, --connect E<lt>name|macE<gt>> - Connect to the input device +B<-c, --connect E<lt>name|macE<gt> E<lt>patternE<gt>> + Connects to a specific RFCOMM based service on a + remote device and then creates a RFCOMM TTY + device for it; `pattern` is a profile short name (spp, dun), + RFCOMM channel (1-30) -B<-d, --disconnect E<lt>name|macE<gt>> - Disconnect from the input device +B<-d, --disconnect E<lt>name|macE<gt> E<lt>tty_deviceE<gt>> + Disconnect a RFCOMM TTY device that has been created =head1 AUTHOR @@ -39,4 +42,4 @@ Alexander Orlenko <zxteam@gmail.com>. =head1 SEE ALSO -bt-agent(1) bt-device(1) +bt-adapter(1) bt-agent(1) bt-audio(1) bt-device(1) bt-input(1) bt-monitor(1) bt-network(1) diff --git a/src/Makefile.am b/src/Makefile.am index b0442f3..d02d5a1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,14 +2,14 @@ AM_CPPFLAGS = $(DBUS_CFLAGS) $(GLIB_CFLAGS) $(DBUS_GLIB_CFLAGS) AM_LDFLAGS = $(DBUS_LIBS) $(GLIB_LIBS) $(DBUS_GLIB_LIBS) # Marshallers generation -BUILT_SOURCES = lib/marshallers.c lib/marshallers.h -GENMARSHAL_FLAGS = --prefix="g_cclosure_bt_marshal" --g-fatal-warnings - -lib/marshallers.h: lib/marshallers.list - glib-genmarshal $(GENMARSHAL_FLAGS) --header lib/marshallers.list > lib/marshallers.h - -lib/marshallers.c: lib/marshallers.list - glib-genmarshal $(GENMARSHAL_FLAGS) --body lib/marshallers.list > lib/marshallers.c +#BUILT_SOURCES = lib/marshallers.c lib/marshallers.h +#GENMARSHAL_FLAGS = --prefix="g_cclosure_bt_marshal" --g-fatal-warnings +# +#lib/marshallers.h: lib/marshallers.list +# glib-genmarshal $(GENMARSHAL_FLAGS) --header lib/marshallers.list > lib/marshallers.h +# +#lib/marshallers.c: lib/marshallers.list +# glib-genmarshal $(GENMARSHAL_FLAGS) --body lib/marshallers.list > lib/marshallers.c bluez_sources = lib/bluez/adapter.c lib/bluez/adapter.h \ lib/bluez/agent.c lib/bluez/agent.h \ @@ -21,6 +21,7 @@ bluez_sources = lib/bluez/adapter.c lib/bluez/adapter.h \ lib/bluez/network_server.c lib/bluez/network_server.h \ lib/bluez/serial.c lib/bluez/serial.h +if OBEX obexd_sources = lib/obexd/obexagent.c lib/obexd/obexagent.h \ lib/obexd/obexclient.c lib/obexd/obexclient.h \ lib/obexd/obexclient_file_transfer.c lib/obexd/obexclient_file_transfer.h \ @@ -29,14 +30,21 @@ obexd_sources = lib/obexd/obexagent.c lib/obexd/obexagent.h \ lib/obexd/obexmanager.c lib/obexd/obexmanager.h \ lib/obexd/obexsession.c lib/obexd/obexsession.h \ lib/obexd/obextransfer.c lib/obexd/obextransfer.h +else +obexd_sources = +endif lib_sources = lib/marshallers.c lib/marshallers.h \ lib/dbus-common.c lib/dbus-common.h \ lib/helpers.c lib/helpers.h \ lib/sdp.c lib/sdp.h \ - lib/bluez-api.h lib/obexd-api.h + lib/bluez-api.h + +if OBEX +lib_sources += lib/obexd-api.h +endif -bin_PROGRAMS = bt-monitor bt-adapter bt-agent bt-device bt-input bt-audio bt-network bt-serial bt-obex +bin_PROGRAMS = bt-monitor bt-adapter bt-agent bt-device bt-input bt-audio bt-network bt-serial bt_monitor_SOURCES = $(lib_sources) $(bluez_sources) $(obexd_sources) bt-monitor.c bt_adapter_SOURCES = ${lib_sources} $(bluez_sources) $(obexd_sources) bt-adapter.c bt_agent_SOURCES = $(lib_sources) $(bluez_sources) $(obexd_sources) bt-agent.c @@ -45,7 +53,16 @@ bt_input_SOURCES = $(lib_sources) $(bluez_sources) $(obexd_sources) bt-input.c bt_audio_SOURCES = $(lib_sources) $(bluez_sources) $(obexd_sources) bt-audio.c bt_network_SOURCES = $(lib_sources) $(bluez_sources) $(obexd_sources) bt-network.c bt_serial_SOURCES = $(lib_sources) $(bluez_sources) $(obexd_sources) bt-serial.c + +if OBEX +bin_PROGRAMS += bt-obex bt_obex_SOURCES = $(lib_sources) $(bluez_sources) $(obexd_sources) bt-obex.c +bt_obex_LDADD = $(LIBREADLINE) +endif + +man_MANS = bt-monitor.1 bt-adapter.1 bt-agent.1 bt-device.1 bt-input.1 bt-audio.1 bt-network.1 bt-serial.1 +if OBEX +man_MANS += bt-obex.1 +endif -CLEANFILES = Makefile.in \ - lib/marshallers.c lib/marshallers.h +#CLEANFILES = lib/marshallers.c lib/marshallers.h diff --git a/src/bt-adapter.1 b/src/bt-adapter.1 index 0c974dd..2a21b37 100644 --- a/src/bt-adapter.1 +++ b/src/bt-adapter.1 @@ -147,37 +147,38 @@ Application Options: .SH "DESCRIPTION" .IX Header "DESCRIPTION" This utility is used to manage Bluetooth adapters. You can list all available adapters, -show information about adapter, set adapter properties or discover remote devices. +show information about adapter, change adapter properties or discover remote devices. .SH "OPTIONS" .IX Header "OPTIONS" -\&\fB\-h\fR +\&\fB\-h, \-\-help\fR Show help .PP -\&\fB\-l\fR +\&\fB\-l, \-\-list\fR List all available adapters .PP -\&\fB\-a <name|mac>\fR +\&\fB\-a, \-\-adapter <name|mac>\fR Specify adapter to use by his Name or \s-1MAC\s0 address (if this option does not defined \- default adapter used) .PP -\&\fB\-i\fR +\&\fB\-i, \-\-info\fR Show information about adapter (returns all properties) .PP -\&\fB\-d\fR +\&\fB\-d, \-\-discover\fR Discover remote devices (with remote device name resolving) .PP \&\fB\-\-set <property> <value>\fR - Set adapter property (see \s-1PROPERTIES\s0 section for list of available properties) + Change adapter properties (see \s-1PROPERTIES\s0 section for list of + available properties) .SH "ADAPTER PROPERTIES" .IX Header "ADAPTER PROPERTIES" string Address [ro] - The Bluetooth adapter address (\s-1MAC\s0). + The Bluetooth adapter address (\s-1MAC\s0). .PP string Name [rw] - The Bluetooth adapter friendly name. + The Bluetooth adapter friendly name. .PP uint32 Class [ro] - The Bluetooth class of device. + The Bluetooth class of device. .PP boolean Powered [rw] Switch an adapter on or off. This will also set the @@ -223,10 +224,11 @@ boolean Discovering [ro] Indicates that a device discovery procedure is active. .PP list UUIDs [ro] - List of 128\-bit UUIDs that represents the available local services. + List of 128\-bit UUIDs that represents the available local + services. .SH "AUTHOR" .IX Header "AUTHOR" Alexander Orlenko <zxteam@gmail.com>. .SH "SEE ALSO" .IX Header "SEE ALSO" -\&\fIbt\-agent\fR\|(1) \fIbt\-device\fR\|(1) +\&\fIbt\-agent\fR\|(1) \fIbt\-audio\fR\|(1) \fIbt\-device\fR\|(1) \fIbt\-input\fR\|(1) \fIbt\-monitor\fR\|(1) \fIbt\-network\fR\|(1) \fIbt\-serial\fR\|(1) diff --git a/src/bt-adapter.c b/src/bt-adapter.c index f6404ea..20f609d 100644 --- a/src/bt-adapter.c +++ b/src/bt-adapter.c @@ -27,6 +27,7 @@ #include <stdlib.h> #include <string.h> + #include <glib.h> #include "lib/dbus-common.h" diff --git a/src/bt-agent.1 b/src/bt-agent.1 index 604cc80..3d8bdaa 100644 --- a/src/bt-agent.1 +++ b/src/bt-agent.1 @@ -146,10 +146,10 @@ This interactive utility is used to manage incoming Bluetooth requests (eg. request of pincode, request of authorize a connection/service request, etc). .SH "OPTIONS" .IX Header "OPTIONS" -\&\fB\-h\fR +\&\fB\-h, \-\-help\fR Show help .PP -\&\fB\-a <name|mac>\fR +\&\fB\-a, \-\-adapter <name|mac>\fR Specify adapter to use by his Name or \s-1MAC\s0 address (if this option does not defined \- default adapter used) .SH "AUTHOR" @@ -157,4 +157,4 @@ This interactive utility is used to manage incoming Bluetooth requests Alexander Orlenko <zxteam@gmail.com>. .SH "SEE ALSO" .IX Header "SEE ALSO" -\&\fIbt\-adapter\fR\|(1) \fIbt\-device\fR\|(1) +\&\fIbt\-adapter\fR\|(1) \fIbt\-audio\fR\|(1) \fIbt\-device\fR\|(1) \fIbt\-input\fR\|(1) \fIbt\-monitor\fR\|(1) \fIbt\-network\fR\|(1) \fIbt\-serial\fR\|(1) diff --git a/src/bt-agent.c b/src/bt-agent.c index 070dcd8..288d350 100644 --- a/src/bt-agent.c +++ b/src/bt-agent.c @@ -28,6 +28,7 @@ #include <stdlib.h> #include <string.h> #include <signal.h> + #include <glib.h> #include "lib/dbus-common.h" diff --git a/src/bt-audio.1 b/src/bt-audio.1 index 22eb339..37c8e39 100644 --- a/src/bt-audio.1 +++ b/src/bt-audio.1 @@ -130,7 +130,7 @@ .if n .ad l .nh .SH "NAME" -bt\-adapter \- a bluetooth generic audio manager +bt\-audio \- a bluetooth generic audio manager .SH "SYNOPSIS" .IX Header "SYNOPSIS" bt-audio [\s-1OPTION\s0...] @@ -164,4 +164,4 @@ This utility is used to manage outgoing audio service connections. Alexander Orlenko <zxteam@gmail.com>. .SH "SEE ALSO" .IX Header "SEE ALSO" -\&\fIbt\-agent\fR\|(1) \fIbt\-device\fR\|(1) +\&\fIbt\-adapter\fR\|(1) \fIbt\-agent\fR\|(1) \fIbt\-device\fR\|(1) \fIbt\-input\fR\|(1) \fIbt\-monitor\fR\|(1) \fIbt\-network\fR\|(1) \fIbt\-serial\fR\|(1) diff --git a/src/bt-audio.c b/src/bt-audio.c index 067135d..3fc59e5 100644 --- a/src/bt-audio.c +++ b/src/bt-audio.c @@ -27,6 +27,7 @@ #include <stdlib.h> #include <string.h> + #include <glib.h> #include "lib/dbus-common.h" diff --git a/src/bt-device.1 b/src/bt-device.1 index d9de5de..4873024 100644 --- a/src/bt-device.1 +++ b/src/bt-device.1 @@ -124,7 +124,7 @@ .\" ======================================================================== .\" .IX Title "bt-device 1" -.TH bt-device 1 "2010-08-11" "" "bluez-tools" +.TH bt-device 1 "2010-08-12" "" "bluez-tools" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -165,7 +165,7 @@ discover remote device services or change device properties. List added devices .PP \&\fB\-c, \-\-connect <mac>\fR - Connect to the remote device by his \s-1MAC\s0 and retrieve all \s-1SDP\s0 + Connect to the remote device by his \s-1MAC\s0, retrieve all \s-1SDP\s0 records and then initiate the pairing .PP \&\fB\-r, \-\-remove\fR @@ -236,4 +236,4 @@ boolean LegacyPairing [ro] Alexander Orlenko <zxteam@gmail.com>. .SH "SEE ALSO" .IX Header "SEE ALSO" -\&\fIbt\-agent\fR\|(1) \fIbt\-adapter\fR\|(1) +\&\fIbt\-adapter\fR\|(1) \fIbt\-agent\fR\|(1) \fIbt\-audio\fR\|(1) \fIbt\-input\fR\|(1) \fIbt\-monitor\fR\|(1) \fIbt\-network\fR\|(1) \fIbt\-serial\fR\|(1) diff --git a/src/bt-device.c b/src/bt-device.c index b15aa5b..46c67cb 100644 --- a/src/bt-device.c +++ b/src/bt-device.c @@ -27,6 +27,7 @@ #include <stdlib.h> #include <string.h> + #include <glib.h> #include "lib/dbus-common.h" @@ -355,7 +356,7 @@ int main(int argc, char *argv[]) g_print(" Alias: %s [rw]\n", device_get_alias(device)); g_print(" Address: %s\n", device_get_address(device)); g_print(" Icon: %s\n", device_get_icon(device)); - g_print(" Class: %x\n", device_get_class(device)); + g_print(" Class: 0x%x\n", device_get_class(device)); g_print(" Paired: %d\n", device_get_paired(device)); g_print(" Trusted: %d [rw]\n", device_get_trusted(device)); g_print(" Blocked: %d [rw]\n", device_get_blocked(device)); diff --git a/src/bt-input.1 b/src/bt-input.1 index 78fa15d..aba5dac 100644 --- a/src/bt-input.1 +++ b/src/bt-input.1 @@ -130,7 +130,7 @@ .if n .ad l .nh .SH "NAME" -bt\-adapter \- a bluetooth input manager +bt\-input \- a bluetooth input manager .SH "SYNOPSIS" .IX Header "SYNOPSIS" bt-input [\s-1OPTION\s0...] @@ -164,4 +164,4 @@ This utility is used to manage outgoing input (\s-1HID\s0) service connections. Alexander Orlenko <zxteam@gmail.com>. .SH "SEE ALSO" .IX Header "SEE ALSO" -\&\fIbt\-agent\fR\|(1) \fIbt\-device\fR\|(1) +\&\fIbt\-adapter\fR\|(1) \fIbt\-agent\fR\|(1) \fIbt\-audio\fR\|(1) \fIbt\-device\fR\|(1) \fIbt\-monitor\fR\|(1) \fIbt\-network\fR\|(1) \fIbt\-serial\fR\|(1) diff --git a/src/bt-input.c b/src/bt-input.c index 1248791..fb75c5a 100644 --- a/src/bt-input.c +++ b/src/bt-input.c @@ -27,6 +27,7 @@ #include <stdlib.h> #include <string.h> + #include <glib.h> #include "lib/dbus-common.h" diff --git a/src/bt-monitor.1 b/src/bt-monitor.1 index 454fa39..779ee89 100644 --- a/src/bt-monitor.1 +++ b/src/bt-monitor.1 @@ -130,7 +130,7 @@ .if n .ad l .nh .SH "NAME" -bt\-device \- a bluetooth monitor +bt\-monitor \- a bluetooth monitor .SH "SYNOPSIS" .IX Header "SYNOPSIS" bt-monitor [\s-1OPTION\s0...] @@ -177,4 +177,4 @@ This utility is used to capture DBus signals of bluetoothd. Captured next signal Alexander Orlenko <zxteam@gmail.com>. .SH "SEE ALSO" .IX Header "SEE ALSO" -\&\fIbt\-adapter\fR\|(1) \fIbt\-device\fR\|(1) +\&\fIbt\-adapter\fR\|(1) \fIbt\-agent\fR\|(1) \fIbt\-audio\fR\|(1) \fIbt\-device\fR\|(1) \fIbt\-input\fR\|(1) \fIbt\-network\fR\|(1) \fIbt\-serial\fR\|(1) diff --git a/src/bt-monitor.c b/src/bt-monitor.c index 2078e04..1d03c51 100644 --- a/src/bt-monitor.c +++ b/src/bt-monitor.c @@ -27,6 +27,7 @@ #include <stdlib.h> #include <string.h> + #include <glib.h> #include "lib/dbus-common.h" @@ -180,20 +181,6 @@ static void device_disconnect_requested(Device *device, gpointer data) g_print("[Device: %s (%s)] Disconnect requested\n", device_get_alias(device), device_get_address(device)); } -static void device_node_created(Device *device, const gchar *node, gpointer data) -{ - //g_print("device_node_created()\n"); - - g_print("[Device: %s (%s)] Node created: %s\n", device_get_alias(device), device_get_address(device), node); -} - -static void device_node_removed(Device *device, const gchar *node, gpointer data) -{ - //g_print("device_node_removed()\n"); - - g_print("[Device: %s (%s)] Node removed: %s\n", device_get_alias(device), device_get_address(device), node); -} - static void device_property_changed(Device *device, const gchar *name, const GValue *value, gpointer data) { //g_print("device_property_changed()\n"); @@ -344,8 +331,6 @@ static void capture_device(Device *device) t2 = g_slist_append(t2, device); g_signal_connect(device, "DisconnectRequested", G_CALLBACK(device_disconnect_requested), NULL); - g_signal_connect(device, "NodeCreated", G_CALLBACK(device_node_created), NULL); - g_signal_connect(device, "NodeRemoved", G_CALLBACK(device_node_removed), NULL); g_signal_connect(device, "PropertyChanged", G_CALLBACK(device_property_changed), NULL); g_hash_table_insert(captured_adapters_devices_t, device_get_adapter(device), t); diff --git a/src/bt-network.c b/src/bt-network.c index 4128da6..8c1e906 100644 --- a/src/bt-network.c +++ b/src/bt-network.c @@ -28,6 +28,7 @@ #include <stdlib.h> #include <string.h> #include <signal.h> + #include <glib.h> #include "lib/dbus-common.h" diff --git a/src/bt-obex.c b/src/bt-obex.c index f9a432b..e9f7432 100644 --- a/src/bt-obex.c +++ b/src/bt-obex.c @@ -25,12 +25,17 @@ #include <config.h> #endif +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <errno.h> + +#include <readline/readline.h> +#include <readline/history.h> + #include <glib.h> #include "lib/dbus-common.h" @@ -124,13 +129,13 @@ static gchar *server_path_arg = NULL; static gboolean opp_arg = FALSE; static gchar *opp_device_arg = NULL; static gchar *opp_file_arg = NULL; -//static gchar *ftp_arg = NULL; +static gchar *ftp_arg = NULL; static GOptionEntry entries[] = { {"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "<name|mac>"}, {"server", 's', 0, G_OPTION_ARG_NONE, &server_arg, "Register self at OBEX server", NULL}, {"opp", 'p', 0, G_OPTION_ARG_NONE, &opp_arg, "Send file to remote device", NULL}, - //{"ftp", 'f', 0, G_OPTION_ARG_STRING, &ftp_arg, "Start FTP session with remote device", "<name|mac>"}, + {"ftp", 'f', 0, G_OPTION_ARG_STRING, &ftp_arg, "Start FTP session with remote device", "<name|mac>"}, {NULL} }; @@ -161,7 +166,7 @@ int main(int argc, char *argv[]) g_print("%s: %s\n", g_get_prgname(), error->message); g_print("Try `%s --help` for more information.\n", g_get_prgname()); exit(EXIT_FAILURE); - } else if (!server_arg && !opp_arg /*&& (!ftp_arg || strlen(ftp_arg) == 0)*/) { + } else if (!server_arg && !opp_arg && (!ftp_arg || strlen(ftp_arg) == 0)) { g_print("%s", g_option_context_get_help(context, FALSE, NULL)); exit(EXIT_FAILURE); } else if (server_arg && argc != 1 && (argc != 2 || strlen(argv[1]) == 0)) { @@ -299,7 +304,8 @@ int main(int argc, char *argv[]) /* Get destination address (address of remote device) */ Device *device = find_device(adapter, opp_device_arg, &error); - exit_if_error(error); + if (error && g_strcmp0(dbus_g_error_get_name(error), "org.bluez.Error.DoesNotExist") != 0) + exit_if_error(error); gchar *dst_address = g_strdup(device == NULL ? opp_device_arg : device_get_address(device)); g_object_unref(device); @@ -349,15 +355,16 @@ int main(int argc, char *argv[]) g_free(src_address); g_free(dst_address); - g_strfreev(files_to_send); - } /*else if (ftp_arg) { + g_free(files_to_send[0]); + files_to_send[0] = NULL; + } else if (ftp_arg) { /* Get source address (address of adapter) */ - /*Adapter *adapter = find_adapter(adapter_arg, &error); + Adapter *adapter = find_adapter(adapter_arg, &error); exit_if_error(error); gchar *src_address = g_strdup(adapter_get_address(adapter)); /* Get destination address (address of remote device) */ - /*/Device *device = find_device(adapter, ftp_arg, &error); + Device *device = find_device(adapter, ftp_arg, &error); exit_if_error(error); gchar *dst_address = g_strdup(device == NULL ? ftp_arg : device_get_address(device)); @@ -365,7 +372,7 @@ int main(int argc, char *argv[]) g_object_unref(adapter); /* Build arguments */ - /*GHashTable *device_dict = g_hash_table_new(g_str_hash, g_str_equal); + GHashTable *device_dict = g_hash_table_new(g_str_hash, g_str_equal); GValue source = {0}; GValue destination = {0}; GValue target = {0}; @@ -383,20 +390,151 @@ int main(int argc, char *argv[]) OBEXAgent *agent = g_object_new(OBEXAGENT_TYPE, NULL); /* Create FTP session */ - //gchar *session_path = obexclient_create_session(client, device_dict, &error); - //exit_if_error(error); + gchar *session_path = obexclient_create_session(client, device_dict, &error); + exit_if_error(error); - //OBEXClientFileTransfer *ftp_session = g_object_new(OBEXCLIENT_FILE_TRANSFER_TYPE, "DBusObjectPath", session_path, NULL); + OBEXClientFileTransfer *ftp_session = g_object_new(OBEXCLIENT_FILE_TRANSFER_TYPE, "DBusObjectPath", session_path, NULL); + g_free(session_path); - /*g_print("FTP session opened\n"); + g_print("FTP session opened\n"); while (TRUE) { - g_print("> "); - gchar cmd[128] = {0,}; - if (!fgets(cmd, 127, stdin)) continue; - g_print("cmd: %s\n", cmd); + gchar *cmd = readline("> "); + if (cmd == NULL || strlen(cmd) == 0) { + continue; + } else { + add_history(cmd); + } + + gint f_argc; + gchar **f_argv; + /* Parsing command line */ + if (!g_shell_parse_argv(cmd, &f_argc, &f_argv, &error)) { + g_print("%s\n", error->message); + g_error_free(error); + error = NULL; + } + + /* Execute commands */ + if (g_strcmp0(f_argv[0], "cd") == 0) { + if (f_argc != 2 || strlen(f_argv[1]) == 0) { + g_print("invalid arguments\n"); + } else { + obexclient_file_transfer_change_folder(ftp_session, f_argv[1], &error); + if (error) { + g_print("%s\n", error->message); + g_error_free(error); + error = NULL; + } + } + } else if (g_strcmp0(f_argv[0], "mkdir") == 0) { + if (f_argc != 2 || strlen(f_argv[1]) == 0) { + g_print("invalid arguments\n"); + } else { + obexclient_file_transfer_create_folder(ftp_session, f_argv[1], &error); + if (error) { + g_print("%s\n", error->message); + g_error_free(error); + error = NULL; + } + } + } else if (g_strcmp0(f_argv[0], "ls") == 0) { + if (f_argc != 1) { + g_print("invalid arguments\n"); + } else { + GPtrArray *folders = obexclient_file_transfer_list_folder(ftp_session, &error); + if (error) { + g_print("%s\n", error->message); + g_error_free(error); + error = NULL; + } else { + for (int i = 0; i < folders->len; i++) { + GHashTable *el = g_ptr_array_index(folders, i); + g_print("%s\n", g_value_get_string(g_hash_table_lookup(el, "Name"))); + } + //g_ptr_array_unref(folders); + + /*obexclient_remove_session(client, obexclient_file_transfer_get_dbus_object_path(ftp_session), &error); + exit_if_error(error); + g_object_unref(ftp_session); + session_path = obexclient_create_session(client, device_dict, &error); + exit_if_error(error); + ftp_session = g_object_new(OBEXCLIENT_FILE_TRANSFER_TYPE, "DBusObjectPath", session_path, NULL); + g_free(session_path);*/ + } + } + } else if (g_strcmp0(f_argv[0], "get") == 0) { + if (f_argc != 3 || strlen(f_argv[1]) == 0 || strlen(f_argv[2]) == 0) { + g_print("invalid arguments\n"); + } else { + obexclient_file_transfer_get_file(ftp_session, f_argv[1], f_argv[2], &error); + if (error) { + g_print("%s\n", error->message); + g_error_free(error); + error = NULL; + } + } + } else if (g_strcmp0(f_argv[0], "put") == 0) { + if (f_argc != 3 || strlen(f_argv[1]) == 0 || strlen(f_argv[2]) == 0) { + g_print("invalid arguments\n"); + } else { + obexclient_file_transfer_put_file(ftp_session, f_argv[1], f_argv[2], &error); + if (error) { + g_print("%s\n", error->message); + g_error_free(error); + error = NULL; + } + } + } else if (g_strcmp0(f_argv[0], "cp") == 0) { + if (f_argc != 3 || strlen(f_argv[1]) == 0 || strlen(f_argv[2]) == 0) { + g_print("invalid arguments\n"); + } else { + obexclient_file_transfer_copy_file(ftp_session, f_argv[1], f_argv[2], &error); + if (error) { + g_print("%s\n", error->message); + g_error_free(error); + error = NULL; + } + } + } else if (g_strcmp0(f_argv[0], "mv") == 0) { + if (f_argc != 3 || strlen(f_argv[1]) == 0 || strlen(f_argv[2]) == 0) { + g_print("invalid arguments\n"); + } else { + obexclient_file_transfer_move_file(ftp_session, f_argv[1], f_argv[2], &error); + if (error) { + g_print("%s\n", error->message); + g_error_free(error); + error = NULL; + } + } + } else if (g_strcmp0(f_argv[0], "rm") == 0) { + if (f_argc != 2 || strlen(f_argv[1]) == 0) { + g_print("invalid arguments\n"); + } else { + obexclient_file_transfer_delete(ftp_session, f_argv[1], &error); + if (error) { + g_print("%s\n", error->message); + g_error_free(error); + error = NULL; + } + } + } else if (g_strcmp0(f_argv[0], "help") == 0) { + + } else if (g_strcmp0(f_argv[0], "exit") == 0 || g_strcmp0(f_argv[0], "quit") == 0) { + obexclient_remove_session(client, obexclient_file_transfer_get_dbus_object_path(ftp_session), &error); + exit_if_error(error); + + g_strfreev(f_argv); + g_free(cmd); + break; + } else { + g_print("invalid command\n"); + } + + g_strfreev(f_argv); + g_free(cmd); } - }*/ + } dbus_disconnect(); diff --git a/src/bt-serial.c b/src/bt-serial.c index 49a0f81..cedde7e 100644 --- a/src/bt-serial.c +++ b/src/bt-serial.c @@ -27,6 +27,7 @@ #include <stdlib.h> #include <string.h> + #include <glib.h> #include "lib/dbus-common.h" @@ -63,7 +64,7 @@ int main(int argc, char *argv[]) "Connect Options:\n" " -c, --connect <name|mac> <pattern>\n" " Where\n" - " `name|mac` is a device name or MAC\n" + " `name|mac` is a device Name or MAC\n" " `pattern` is:\n" " UUID 128 bit string\n" " Profile short name, e.g: spp, dun\n" diff --git a/src/lib/bluez-api.h b/src/lib/bluez-api.h index 56ecae6..241ad75 100644 --- a/src/lib/bluez-api.h +++ b/src/lib/bluez-api.h @@ -24,6 +24,10 @@ #ifndef __BLUEZ_API_H #define __BLUEZ_API_H +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + /* Global includes */ #include <glib.h> #include <dbus/dbus-glib.h> diff --git a/src/lib/bluez/adapter.c b/src/lib/bluez/adapter.c index b6cfd0e..00ad300 100644 --- a/src/lib/bluez/adapter.c +++ b/src/lib/bluez/adapter.c @@ -26,7 +26,9 @@ #endif #include <string.h> + #include <glib.h> +#include <dbus/dbus-glib.h> #include "../dbus-common.h" #include "../marshallers.h" @@ -562,14 +564,6 @@ void adapter_register_agent(Adapter *self, const gchar *agent, const gchar *capa dbus_g_proxy_call(self->priv->dbus_g_proxy, "RegisterAgent", error, DBUS_TYPE_G_OBJECT_PATH, agent, G_TYPE_STRING, capability, G_TYPE_INVALID, G_TYPE_INVALID); } -/* void ReleaseSession() */ -void adapter_release_session(Adapter *self, GError **error) -{ - g_assert(ADAPTER_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "ReleaseSession", error, G_TYPE_INVALID, G_TYPE_INVALID); -} - /* void RemoveDevice(object device) */ void adapter_remove_device(Adapter *self, const gchar *device, GError **error) { @@ -578,14 +572,6 @@ void adapter_remove_device(Adapter *self, const gchar *device, GError **error) dbus_g_proxy_call(self->priv->dbus_g_proxy, "RemoveDevice", error, DBUS_TYPE_G_OBJECT_PATH, device, G_TYPE_INVALID, G_TYPE_INVALID); } -/* void RequestSession() */ -void adapter_request_session(Adapter *self, GError **error) -{ - g_assert(ADAPTER_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "RequestSession", error, G_TYPE_INVALID, G_TYPE_INVALID); -} - /* void SetProperty(string name, variant value) */ void adapter_set_property(Adapter *self, const gchar *name, const GValue *value, GError **error) { diff --git a/src/lib/bluez/adapter.h b/src/lib/bluez/adapter.h index d94675b..22ee02f 100644 --- a/src/lib/bluez/adapter.h +++ b/src/lib/bluez/adapter.h @@ -66,9 +66,7 @@ gchar *adapter_create_paired_device_end(Adapter *self, GError **error); gchar *adapter_find_device(Adapter *self, const gchar *address, GError **error); GHashTable *adapter_get_properties(Adapter *self, GError **error); void adapter_register_agent(Adapter *self, const gchar *agent, const gchar *capability, GError **error); -void adapter_release_session(Adapter *self, GError **error); void adapter_remove_device(Adapter *self, const gchar *device, GError **error); -void adapter_request_session(Adapter *self, GError **error); void adapter_set_property(Adapter *self, const gchar *name, const GValue *value, GError **error); void adapter_start_discovery(Adapter *self, GError **error); void adapter_stop_discovery(Adapter *self, GError **error); diff --git a/src/lib/bluez/agent.c b/src/lib/bluez/agent.c index 04dbd03..bff75c0 100644 --- a/src/lib/bluez/agent.c +++ b/src/lib/bluez/agent.c @@ -28,7 +28,9 @@ #include <stdio.h> #include <errno.h> #include <string.h> + #include <glib.h> +#include <dbus/dbus-glib.h> #include "../dbus-common.h" #include "../helpers.h" diff --git a/src/lib/bluez/audio.c b/src/lib/bluez/audio.c index 6c6c0d5..8343bf5 100644 --- a/src/lib/bluez/audio.c +++ b/src/lib/bluez/audio.c @@ -26,7 +26,9 @@ #endif #include <string.h> + #include <glib.h> +#include <dbus/dbus-glib.h> #include "../dbus-common.h" #include "../marshallers.h" diff --git a/src/lib/bluez/device.c b/src/lib/bluez/device.c index 587b804..8824593 100644 --- a/src/lib/bluez/device.c +++ b/src/lib/bluez/device.c @@ -26,7 +26,9 @@ #endif #include <string.h> + #include <glib.h> +#include <dbus/dbus-glib.h> #include "../dbus-common.h" #include "../marshallers.h" @@ -52,7 +54,6 @@ struct _DevicePrivate { gchar *icon; gboolean legacy_pairing; gchar *name; - GPtrArray *nodes; gboolean paired; gboolean trusted; gchar **uuids; @@ -73,7 +74,6 @@ enum { PROP_ICON, /* readonly */ PROP_LEGACY_PAIRING, /* readonly */ PROP_NAME, /* readonly */ - PROP_NODES, /* readonly */ PROP_PAIRED, /* readonly */ PROP_TRUSTED, /* readwrite */ PROP_UUIDS /* readonly */ @@ -84,8 +84,6 @@ static void _device_set_property(GObject *object, guint property_id, const GValu enum { DISCONNECT_REQUESTED, - NODE_CREATED, - NODE_REMOVED, PROPERTY_CHANGED, LAST_SIGNAL @@ -94,8 +92,6 @@ enum { static guint signals[LAST_SIGNAL] = {0}; static void disconnect_requested_handler(DBusGProxy *dbus_g_proxy, gpointer data); -static void node_created_handler(DBusGProxy *dbus_g_proxy, const gchar *node, gpointer data); -static void node_removed_handler(DBusGProxy *dbus_g_proxy, const gchar *node, gpointer data); static void property_changed_handler(DBusGProxy *dbus_g_proxy, const gchar *name, const GValue *value, gpointer data); static void device_dispose(GObject *gobject) @@ -104,8 +100,6 @@ static void device_dispose(GObject *gobject) /* DBus signals disconnection */ dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "DisconnectRequested", G_CALLBACK(disconnect_requested_handler), self); - dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "NodeCreated", G_CALLBACK(node_created_handler), self); - dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "NodeRemoved", G_CALLBACK(node_removed_handler), self); dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "PropertyChanged", G_CALLBACK(property_changed_handler), self); /* Properties free */ @@ -114,7 +108,6 @@ static void device_dispose(GObject *gobject) g_free(self->priv->alias); g_free(self->priv->icon); g_free(self->priv->name); - g_ptr_array_unref(self->priv->nodes); g_strfreev(self->priv->uuids); /* Proxy free */ @@ -182,10 +175,6 @@ static void device_class_init(DeviceClass *klass) pspec = g_param_spec_string("Name", NULL, NULL, NULL, G_PARAM_READABLE); g_object_class_install_property(gobject_class, PROP_NAME, pspec); - /* array{object} Nodes [readonly] */ - pspec = g_param_spec_boxed("Nodes", NULL, NULL, G_TYPE_PTR_ARRAY, G_PARAM_READABLE); - g_object_class_install_property(gobject_class, PROP_NODES, pspec); - /* boolean Paired [readonly] */ pspec = g_param_spec_boolean("Paired", NULL, NULL, FALSE, G_PARAM_READABLE); g_object_class_install_property(gobject_class, PROP_PAIRED, pspec); @@ -206,20 +195,6 @@ static void device_class_init(DeviceClass *klass) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - signals[NODE_CREATED] = g_signal_new("NodeCreated", - G_TYPE_FROM_CLASS(gobject_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, - 0, NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); - - signals[NODE_REMOVED] = g_signal_new("NodeRemoved", - G_TYPE_FROM_CLASS(gobject_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, - 0, NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); - signals[PROPERTY_CHANGED] = g_signal_new("PropertyChanged", G_TYPE_FROM_CLASS(gobject_class), G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, @@ -268,14 +243,6 @@ static void device_post_init(Device *self, const gchar *dbus_object_path) dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "DisconnectRequested", G_TYPE_INVALID); dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "DisconnectRequested", G_CALLBACK(disconnect_requested_handler), self, NULL); - /* NodeCreated(object node) */ - dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "NodeCreated", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "NodeCreated", G_CALLBACK(node_created_handler), self, NULL); - - /* NodeRemoved(object node) */ - dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "NodeRemoved", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "NodeRemoved", G_CALLBACK(node_removed_handler), self, NULL); - /* PropertyChanged(string name, variant value) */ dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "PropertyChanged", G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "PropertyChanged", G_CALLBACK(property_changed_handler), self, NULL); @@ -351,13 +318,6 @@ static void device_post_init(Device *self, const gchar *dbus_object_path) self->priv->name = g_strdup("undefined"); } - /* array{object} Nodes [readonly] */ - if (g_hash_table_lookup(properties, "Nodes")) { - self->priv->nodes = g_value_dup_boxed(g_hash_table_lookup(properties, "Nodes")); - } else { - self->priv->nodes = g_ptr_array_new(); - } - /* boolean Paired [readonly] */ if (g_hash_table_lookup(properties, "Paired")) { self->priv->paired = g_value_get_boolean(g_hash_table_lookup(properties, "Paired")); @@ -428,10 +388,6 @@ static void _device_get_property(GObject *object, guint property_id, GValue *val g_value_set_string(value, device_get_name(self)); break; - case PROP_NODES: - g_value_set_boxed(value, device_get_nodes(self)); - break; - case PROP_PAIRED: g_value_set_boolean(value, device_get_paired(self)); break; @@ -493,17 +449,6 @@ void device_cancel_discovery(Device *self, GError **error) dbus_g_proxy_call(self->priv->dbus_g_proxy, "CancelDiscovery", error, G_TYPE_INVALID, G_TYPE_INVALID); } -/* object CreateNode(string uuid) */ -gchar *device_create_node(Device *self, const gchar *uuid, GError **error) -{ - g_assert(DEVICE_IS(self)); - - gchar *ret = NULL; - dbus_g_proxy_call(self->priv->dbus_g_proxy, "CreateNode", error, G_TYPE_STRING, uuid, G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH, &ret, G_TYPE_INVALID); - - return ret; -} - /* void Disconnect() */ void device_disconnect(Device *self, GError **error) { @@ -534,14 +479,6 @@ GHashTable *device_get_properties(Device *self, GError **error) return ret; } -/* void RemoveNode(object node) */ -void device_remove_node(Device *self, const gchar *node, GError **error) -{ - g_assert(DEVICE_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "RemoveNode", error, DBUS_TYPE_G_OBJECT_PATH, node, G_TYPE_INVALID, G_TYPE_INVALID); -} - /* void SetProperty(string name, variant value) */ void device_set_property(Device *self, const gchar *name, const GValue *value, GError **error) { @@ -657,13 +594,6 @@ const gchar *device_get_name(Device *self) return self->priv->name; } -const GPtrArray *device_get_nodes(Device *self) -{ - g_assert(DEVICE_IS(self)); - - return self->priv->nodes; -} - const gboolean device_get_paired(Device *self) { g_assert(DEVICE_IS(self)); @@ -711,20 +641,6 @@ static void disconnect_requested_handler(DBusGProxy *dbus_g_proxy, gpointer data g_signal_emit(self, signals[DISCONNECT_REQUESTED], 0); } -static void node_created_handler(DBusGProxy *dbus_g_proxy, const gchar *node, gpointer data) -{ - Device *self = DEVICE(data); - - g_signal_emit(self, signals[NODE_CREATED], 0, node); -} - -static void node_removed_handler(DBusGProxy *dbus_g_proxy, const gchar *node, gpointer data) -{ - Device *self = DEVICE(data); - - g_signal_emit(self, signals[NODE_REMOVED], 0, node); -} - static void property_changed_handler(DBusGProxy *dbus_g_proxy, const gchar *name, const GValue *value, gpointer data) { Device *self = DEVICE(data); @@ -752,9 +668,6 @@ static void property_changed_handler(DBusGProxy *dbus_g_proxy, const gchar *name } else if (g_strcmp0(name, "Name") == 0) { g_free(self->priv->name); self->priv->name = g_value_dup_string(value); - } else if (g_strcmp0(name, "Nodes") == 0) { - g_ptr_array_unref(self->priv->nodes); - self->priv->nodes = g_value_dup_boxed(value); } else if (g_strcmp0(name, "Paired") == 0) { self->priv->paired = g_value_get_boolean(value); } else if (g_strcmp0(name, "Trusted") == 0) { diff --git a/src/lib/bluez/device.h b/src/lib/bluez/device.h index b13e750..98cb3a6 100644 --- a/src/lib/bluez/device.h +++ b/src/lib/bluez/device.h @@ -60,11 +60,9 @@ GType device_get_type(void) G_GNUC_CONST; * Method definitions */ void device_cancel_discovery(Device *self, GError **error); -gchar *device_create_node(Device *self, const gchar *uuid, GError **error); void device_disconnect(Device *self, GError **error); GHashTable *device_discover_services(Device *self, const gchar *pattern, GError **error); GHashTable *device_get_properties(Device *self, GError **error); -void device_remove_node(Device *self, const gchar *node, GError **error); void device_set_property(Device *self, const gchar *name, const GValue *value, GError **error); const gchar *device_get_dbus_object_path(Device *self); @@ -79,7 +77,6 @@ const gboolean device_get_connected(Device *self); const gchar *device_get_icon(Device *self); const gboolean device_get_legacy_pairing(Device *self); const gchar *device_get_name(Device *self); -const GPtrArray *device_get_nodes(Device *self); const gboolean device_get_paired(Device *self); const gboolean device_get_trusted(Device *self); void device_set_trusted(Device *self, const gboolean value); diff --git a/src/lib/bluez/input.c b/src/lib/bluez/input.c index 09dbdfe..0ed19b2 100644 --- a/src/lib/bluez/input.c +++ b/src/lib/bluez/input.c @@ -26,7 +26,9 @@ #endif #include <string.h> + #include <glib.h> +#include <dbus/dbus-glib.h> #include "../dbus-common.h" #include "../marshallers.h" diff --git a/src/lib/bluez/manager.c b/src/lib/bluez/manager.c index 7eea246..53cc597 100644 --- a/src/lib/bluez/manager.c +++ b/src/lib/bluez/manager.c @@ -26,7 +26,9 @@ #endif #include <string.h> + #include <glib.h> +#include <dbus/dbus-glib.h> #include "../dbus-common.h" #include "../marshallers.h" diff --git a/src/lib/bluez/network.c b/src/lib/bluez/network.c index d6967f0..411bc0e 100644 --- a/src/lib/bluez/network.c +++ b/src/lib/bluez/network.c @@ -26,7 +26,9 @@ #endif #include <string.h> + #include <glib.h> +#include <dbus/dbus-glib.h> #include "../dbus-common.h" #include "../marshallers.h" diff --git a/src/lib/bluez/network_server.c b/src/lib/bluez/network_server.c index 78ab124..3acf614 100644 --- a/src/lib/bluez/network_server.c +++ b/src/lib/bluez/network_server.c @@ -26,7 +26,9 @@ #endif #include <string.h> + #include <glib.h> +#include <dbus/dbus-glib.h> #include "../dbus-common.h" #include "../marshallers.h" diff --git a/src/lib/bluez/serial.c b/src/lib/bluez/serial.c index 8cd230a..03f9e4e 100644 --- a/src/lib/bluez/serial.c +++ b/src/lib/bluez/serial.c @@ -26,7 +26,9 @@ #endif #include <string.h> + #include <glib.h> +#include <dbus/dbus-glib.h> #include "../dbus-common.h" #include "../marshallers.h" diff --git a/src/lib/dbus-common.c b/src/lib/dbus-common.c index 91ee2c9..1ebc56d 100644 --- a/src/lib/dbus-common.c +++ b/src/lib/dbus-common.c @@ -25,8 +25,13 @@ #include <config.h> #endif +#include <glib.h> +#include <dbus/dbus-glib.h> + #include "bluez-api.h" +#ifdef OBEX_SUPPORT #include "obexd-api.h" +#endif #include "dbus-common.h" @@ -46,7 +51,9 @@ void dbus_init() /* Agents installation */ dbus_g_object_type_install_info(AGENT_TYPE, &dbus_glib_agent_object_info); +#ifdef OBEX_SUPPORT dbus_g_object_type_install_info(OBEXAGENT_TYPE, &dbus_glib_obexagent_object_info); +#endif dbus_initialized = TRUE; } diff --git a/src/lib/dbus-common.h b/src/lib/dbus-common.h index e0fcb9c..ad4e210 100644 --- a/src/lib/dbus-common.h +++ b/src/lib/dbus-common.h @@ -42,3 +42,4 @@ void dbus_system_disconnect(); void dbus_disconnect(); #endif /* __DBUS_COMMON_H */ + diff --git a/src/lib/helpers.c b/src/lib/helpers.c index 7dc1b03..d287843 100644 --- a/src/lib/helpers.c +++ b/src/lib/helpers.c @@ -26,6 +26,7 @@ #endif #include <string.h> + #include <glib.h> #include <dbus/dbus-glib.h> @@ -236,8 +237,10 @@ gboolean intf_supported(const gchar *dbus_service_name, const gchar *dbus_object if (g_strcmp0(dbus_service_name, BLUEZ_DBUS_NAME) == 0) { conn = system_conn; +#ifdef OBEX_SUPPORT } else if (g_strcmp0(dbus_service_name, OBEXD_DBUS_NAME) == 0) { conn = session_conn; +#endif } else { return FALSE; } diff --git a/src/lib/helpers.h b/src/lib/helpers.h index 71db329..90ca331 100644 --- a/src/lib/helpers.h +++ b/src/lib/helpers.h @@ -25,10 +25,13 @@ #define __HELPERS_H #include <stdio.h> + #include <glib.h> #include "bluez-api.h" +#ifdef OBEX_SUPPORT #include "obexd-api.h" +#endif /* DBus helpers */ gboolean intf_supported(const gchar *dbus_service_name, const gchar *dbus_object_path, const gchar *intf_name); @@ -40,7 +43,7 @@ Device *find_device(Adapter *adapter, const gchar *name, GError **error); /* Others helpers */ #define exit_if_error(error) G_STMT_START{ \ if (error) { \ - g_printerr("%s: %s\n", (dbus_g_error_get_name(error) != NULL && strlen(dbus_g_error_get_name(error)) ? dbus_g_error_get_name(error) : "Error"), error->message); \ + g_printerr("%s: %s\n", (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION && dbus_g_error_get_name(error) != NULL && strlen(dbus_g_error_get_name(error)) ? dbus_g_error_get_name(error) : "Error"), error->message); \ exit(EXIT_FAILURE); \ }; }G_STMT_END diff --git a/src/lib/obexd-api.h b/src/lib/obexd-api.h index e299530..2eea818 100644 --- a/src/lib/obexd-api.h +++ b/src/lib/obexd-api.h @@ -24,10 +24,15 @@ #ifndef __OBEXD_API_H #define __OBEXD_API_H +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + /* Global includes */ #include <glib.h> #include <dbus/dbus-glib.h> +#ifdef OBEX_SUPPORT #define OBEXD_DBUS_NAME "org.openobex" /* OBEXD DBus API */ @@ -39,6 +44,7 @@ #include "obexd/obexmanager.h" #include "obexd/obexsession.h" #include "obexd/obextransfer.h" +#endif #endif /* __OBEXD_API_H */ diff --git a/src/lib/obexd/obexagent.c b/src/lib/obexd/obexagent.c index a45bb1b..78024d3 100644 --- a/src/lib/obexd/obexagent.c +++ b/src/lib/obexd/obexagent.c @@ -28,7 +28,9 @@ #include <stdio.h> #include <string.h> #include <errno.h> + #include <glib.h> +#include <dbus/dbus-glib.h> #include "../dbus-common.h" #include "../helpers.h" diff --git a/src/lib/obexd/obexclient.c b/src/lib/obexd/obexclient.c index 1a15c93..d8cfa78 100644 --- a/src/lib/obexd/obexclient.c +++ b/src/lib/obexd/obexclient.c @@ -26,7 +26,9 @@ #endif #include <string.h> + #include <glib.h> +#include <dbus/dbus-glib.h> #include "../dbus-common.h" #include "../marshallers.h" diff --git a/src/lib/obexd/obexclient_file_transfer.c b/src/lib/obexd/obexclient_file_transfer.c index e15de6c..05fa36d 100644 --- a/src/lib/obexd/obexclient_file_transfer.c +++ b/src/lib/obexd/obexclient_file_transfer.c @@ -26,7 +26,9 @@ #endif #include <string.h> + #include <glib.h> +#include <dbus/dbus-glib.h> #include "../dbus-common.h" #include "../marshallers.h" diff --git a/src/lib/obexd/obexclient_session.c b/src/lib/obexd/obexclient_session.c index 8702d39..a5b52f8 100644 --- a/src/lib/obexd/obexclient_session.c +++ b/src/lib/obexd/obexclient_session.c @@ -26,7 +26,9 @@ #endif #include <string.h> + #include <glib.h> +#include <dbus/dbus-glib.h> #include "../dbus-common.h" #include "../marshallers.h" diff --git a/src/lib/obexd/obexclient_transfer.c b/src/lib/obexd/obexclient_transfer.c index b3e7560..68c4bf3 100644 --- a/src/lib/obexd/obexclient_transfer.c +++ b/src/lib/obexd/obexclient_transfer.c @@ -26,7 +26,9 @@ #endif #include <string.h> + #include <glib.h> +#include <dbus/dbus-glib.h> #include "../dbus-common.h" #include "../marshallers.h" diff --git a/src/lib/obexd/obexmanager.c b/src/lib/obexd/obexmanager.c index 3a6d368..1e3e0d4 100644 --- a/src/lib/obexd/obexmanager.c +++ b/src/lib/obexd/obexmanager.c @@ -26,7 +26,9 @@ #endif #include <string.h> + #include <glib.h> +#include <dbus/dbus-glib.h> #include "../dbus-common.h" #include "../marshallers.h" diff --git a/src/lib/obexd/obexsession.c b/src/lib/obexd/obexsession.c index fa80e02..48380cf 100644 --- a/src/lib/obexd/obexsession.c +++ b/src/lib/obexd/obexsession.c @@ -26,7 +26,9 @@ #endif #include <string.h> + #include <glib.h> +#include <dbus/dbus-glib.h> #include "../dbus-common.h" #include "../marshallers.h" diff --git a/src/lib/obexd/obextransfer.c b/src/lib/obexd/obextransfer.c index 59556e4..78dcf52 100644 --- a/src/lib/obexd/obextransfer.c +++ b/src/lib/obexd/obextransfer.c @@ -26,7 +26,9 @@ #endif #include <string.h> + #include <glib.h> +#include <dbus/dbus-glib.h> #include "../dbus-common.h" #include "../marshallers.h" diff --git a/src/lib/sdp.h b/src/lib/sdp.h index 04267d0..b7490cb 100644 --- a/src/lib/sdp.h +++ b/src/lib/sdp.h @@ -164,3 +164,4 @@ const char* sdp_get_uuid_name(int uuid); const char* sdp_get_attr_id_name(int attr_id); #endif /* __SDP_H */ + |