diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 18 | ||||
-rw-r--r-- | src/adapter.c | 161 | ||||
-rw-r--r-- | src/bluetoothd.8 | 15 | ||||
-rw-r--r-- | src/dbus-database.c | 214 | ||||
-rw-r--r-- | src/dbus-database.h | 32 | ||||
-rwxr-xr-x | src/list-devices | 52 | ||||
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/service-did.xml | 33 | ||||
-rw-r--r-- | src/service-ftp.xml | 37 | ||||
-rw-r--r-- | src/service-opp.xml | 50 | ||||
-rw-r--r-- | src/service-record.dtd | 66 | ||||
-rw-r--r-- | src/service-spp.xml | 25 | ||||
-rwxr-xr-x | src/simple-agent | 112 | ||||
-rwxr-xr-x | src/simple-service | 127 | ||||
-rw-r--r-- | src/telephony.c | 44 | ||||
-rw-r--r-- | src/telephony.h | 26 | ||||
-rwxr-xr-x | src/test-adapter | 91 | ||||
-rwxr-xr-x | src/test-device | 128 | ||||
-rwxr-xr-x | src/test-discovery | 43 | ||||
-rwxr-xr-x | src/test-manager | 27 |
20 files changed, 168 insertions, 1135 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index e44ae579..2a353a47 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,14 +15,11 @@ endif sbin_PROGRAMS = bluetoothd -bluetoothd_SOURCES = main.c hcid.h sdpd.h \ - sdpd-server.c sdpd-request.c sdpd-service.c \ - sdpd-database.c security.c storage.c \ - manager.h manager.c error.h error.c \ - adapter.h adapter.c device.h device.c plugin.h plugin.c \ - dbus-common.c dbus-common.h dbus-hci.h dbus-hci.c \ - dbus-database.c dbus-database.h \ - telephony.h telephony.c agent.h agent.c +bluetoothd_SOURCES = main.c security.c hcid.h sdpd.h \ + sdpd-server.c sdpd-request.c sdpd-service.c sdpd-database.c \ + plugin.h plugin.c storage.h storage.c agent.h agent.c \ + error.h error.c manager.h manager.c adapter.h adapter.c \ + device.h device.c dbus-common.c dbus-common.h dbus-hci.h dbus-hci.c bluetoothd_LDADD = $(top_builddir)/common/libhelper.a \ @GDBUS_LIBS@ @GMODULE_LIBS@ @GLIB_LIBS@ @DBUS_LIBS@ @BLUEZ_LIBS@ @@ -43,9 +40,6 @@ if MANPAGES man_MANS = bluetoothd.8 endif -EXTRA_DIST = bluetooth.conf bluetoothd.8 main.conf \ - list-devices test-discovery test-manager test-adapter test-device \ - simple-service simple-agent service-record.dtd \ - service-did.xml service-spp.xml service-opp.xml service-ftp.xml +EXTRA_DIST = bluetooth.conf bluetoothd.8 main.conf MAINTAINERCLEANFILES = Makefile.in diff --git a/src/adapter.c b/src/adapter.c index 786c4953..a22112c8 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -50,12 +50,12 @@ #include "hcid.h" #include "sdpd.h" +#include "sdp-xml.h" #include "manager.h" #include "adapter.h" #include "device.h" #include "dbus-common.h" #include "dbus-hci.h" -#include "dbus-database.h" #include "error.h" #include "glib-helper.h" #include "agent.h" @@ -75,8 +75,8 @@ static DBusConnection *connection = NULL; static GSList *adapter_drivers = NULL; struct record_list { - sdp_list_t *recs; - const gchar *addr; + sdp_list_t *recs; + const gchar *addr; }; struct session_req { @@ -93,6 +93,27 @@ struct service_auth { void *user_data; }; +static GSList *records = NULL; + +struct record_data { + uint32_t handle; + char *sender; + guint listener_id; +}; + +static struct record_data *find_record(uint32_t handle, const char *sender) +{ + GSList *list; + + for (list = records; list; list = list->next) { + struct record_data *data = list->data; + if (handle == data->handle && !strcmp(sender, data->sender)) + return data; + } + + return NULL; +} + static inline DBusMessage *invalid_args(DBusMessage *msg) { return g_dbus_create_error(msg, ERROR_INTERFACE ".InvalidArguments", @@ -120,7 +141,7 @@ static inline DBusMessage *no_such_adapter(DBusMessage *msg) static inline DBusMessage *failed_strerror(DBusMessage *msg, int err) { return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed", - strerror(err)); + strerror(err)); } static inline DBusMessage *in_progress(DBusMessage *msg, const char *str) @@ -1887,6 +1908,56 @@ static DBusMessage *unregister_agent(DBusConnection *conn, return dbus_message_new_method_return(msg); } +static void exit_callback(void *user_data) +{ + struct record_data *user_record = user_data; + + debug("remove record"); + + records = g_slist_remove(records, user_record); + + remove_record_from_server(user_record->handle); + + g_free(user_record->sender); + g_free(user_record); +} + +static int add_xml_record(DBusConnection *conn, const char *sender, + bdaddr_t *src, const char *record, dbus_uint32_t *handle) +{ + struct record_data *user_record; + sdp_record_t *sdp_record; + + sdp_record = sdp_xml_parse_record(record, strlen(record)); + if (!sdp_record) { + error("Parsing of XML service record failed"); + return -EIO; + } + + if (add_record_to_server(src, sdp_record) < 0) { + error("Failed to register service record"); + sdp_record_free(sdp_record); + return -EIO; + } + + user_record = g_new0(struct record_data, 1); + + user_record->handle = sdp_record->handle; + + user_record->sender = g_strdup(sender); + + records = g_slist_append(records, user_record); + + user_record->listener_id = g_dbus_add_disconnect_watch(conn, sender, + exit_callback, user_record, NULL); + + debug("listener_id %d", user_record->listener_id); + + *handle = user_record->handle; + + return 0; +} + static DBusMessage *add_service_record(DBusConnection *conn, DBusMessage *msg, void *data) { @@ -1917,6 +1988,68 @@ static DBusMessage *add_service_record(DBusConnection *conn, return reply; } +static DBusMessage *update_record(DBusConnection *conn, DBusMessage *msg, + bdaddr_t *src, dbus_uint32_t handle, sdp_record_t *sdp_record) +{ + int err; + + if (remove_record_from_server(handle) < 0) { + sdp_record_free(sdp_record); + return g_dbus_create_error(msg, + ERROR_INTERFACE ".NotAvailable", + "Not Available"); + } + + sdp_record->handle = handle; + err = add_record_to_server(src, sdp_record); + if (err < 0) { + sdp_record_free(sdp_record); + error("Failed to update the service record"); + return g_dbus_create_error(msg, + ERROR_INTERFACE ".Failed", + strerror(EIO)); + } + + return dbus_message_new_method_return(msg); +} + +static DBusMessage *update_xml_record(DBusConnection *conn, + DBusMessage *msg, bdaddr_t *src) +{ + struct record_data *user_record; + sdp_record_t *sdp_record; + const char *record; + dbus_uint32_t handle; + int len; + + if (dbus_message_get_args(msg, NULL, + DBUS_TYPE_UINT32, &handle, + DBUS_TYPE_STRING, &record, + DBUS_TYPE_INVALID) == FALSE) + return NULL; + + len = (record ? strlen(record) : 0); + if (len == 0) + return invalid_args(msg); + + user_record = find_record(handle, dbus_message_get_sender(msg)); + if (!user_record) + return g_dbus_create_error(msg, + ERROR_INTERFACE ".NotAvailable", + "Not Available"); + + sdp_record = sdp_xml_parse_record(record, len); + if (!sdp_record) { + error("Parsing of XML service record failed"); + sdp_record_free(sdp_record); + return g_dbus_create_error(msg, + ERROR_INTERFACE ".Failed", + strerror(EIO)); + } + + return update_record(conn, msg, src, handle, sdp_record); +} + static DBusMessage *update_service_record(DBusConnection *conn, DBusMessage *msg, void *data) { @@ -1928,6 +2061,26 @@ static DBusMessage *update_service_record(DBusConnection *conn, return update_xml_record(conn, msg, &src); } +static int remove_record(DBusConnection *conn, const char *sender, + dbus_uint32_t handle) +{ + struct record_data *user_record; + + debug("remove record 0x%x", handle); + + user_record = find_record(handle, sender); + if (!user_record) + return -1; + + debug("listner_id %d", user_record->listener_id); + + g_dbus_remove_watch(conn, user_record->listener_id); + + exit_callback(user_record); + + return 0; +} + static DBusMessage *remove_service_record(DBusConnection *conn, DBusMessage *msg, void *data) { diff --git a/src/bluetoothd.8 b/src/bluetoothd.8 index 5b50b6df..28c03986 100644 --- a/src/bluetoothd.8 +++ b/src/bluetoothd.8 @@ -7,9 +7,6 @@ bluetoothd \- Bluetooth daemon .B bluetoothd [ .B \-n -] [ -.B \-f -.I config\-file ] .SH "DESCRIPTION" @@ -19,7 +16,7 @@ daemon, which manages all the Bluetooth devices. .B bluetoothd itself does not accept many command\-line options, as most of its configuration is done in the -.B hcid.conf +.B /etc/bluetooth/main.conf file, which has its own man page. .B bluetoothd can also provide a number of services via the D-Bus message bus @@ -27,19 +24,17 @@ system. .SH "OPTIONS" .TP .BI \-n -Don't fork to run daemon in background. +Don't run as daemon in background. .TP .BI \-d Enable debug information output. .TP .BI \-m\ mtu\-size Use specific MTU size for SDP server. -.TP -.BI \-f\ config\-file -Use alternate configuration file instead of /etc/bluetooth/hcid.conf + .SH "FILES" .TP -.I /etc/bluetooth/hcid.conf +.I /etc/bluetooth/main.conf Default location of the global configuration file. .TP @@ -92,7 +87,5 @@ the following columns separated by whitespace: \fIn\fP Remote device LMP sub-version integer. -.SH "SEE ALSO" -\fBhcid.conf\fR(5) .SH "AUTHOR" This manual page was written by Marcel Holtmann, Philipp Matthias Hahn and Fredrik Noring. diff --git a/src/dbus-database.c b/src/dbus-database.c deleted file mode 100644 index 4d2bb911..00000000 --- a/src/dbus-database.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * - * BlueZ - Bluetooth protocol stack for Linux - * - * Copyright (C) 2006-2007 Nokia Corporation - * Copyright (C) 2004-2008 Marcel Holtmann <marcel@holtmann.org> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <errno.h> -#include <stdlib.h> -#include <string.h> - -#include <bluetooth/bluetooth.h> -#include <bluetooth/hci.h> -#include <bluetooth/hci_lib.h> -#include <bluetooth/sdp.h> -#include <bluetooth/sdp_lib.h> - -#include <gdbus.h> - -#include "sdpd.h" -#include "sdp-xml.h" -#include "error.h" -#include "logging.h" - -static GSList *records = NULL; - -struct record_data { - uint32_t handle; - char *sender; - guint listener_id; -}; - -static struct record_data *find_record(uint32_t handle, const char *sender) -{ - GSList *list; - - for (list = records; list; list = list->next) { - struct record_data *data = list->data; - if (handle == data->handle && !strcmp(sender, data->sender)) - return data; - } - - return NULL; -} - -static void exit_callback(void *user_data) -{ - struct record_data *user_record = user_data; - - debug("remove record"); - - records = g_slist_remove(records, user_record); - - remove_record_from_server(user_record->handle); - - g_free(user_record->sender); - g_free(user_record); -} - -static inline DBusMessage *invalid_arguments(DBusMessage *msg) -{ - return g_dbus_create_error(msg, ERROR_INTERFACE ".InvalidArguments", - "Invalid arguments in method call"); -} - -static inline DBusMessage *not_available(DBusMessage *msg) -{ - return g_dbus_create_error(msg, ERROR_INTERFACE ".NotAvailable", - "Not Available"); -} - -static inline DBusMessage *failed(DBusMessage *msg) -{ - return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed", "Failed"); -} - -int add_xml_record(DBusConnection *conn, const char *sender, bdaddr_t *src, - const char *record, dbus_uint32_t *handle) -{ - struct record_data *user_record; - sdp_record_t *sdp_record; - - sdp_record = sdp_xml_parse_record(record, strlen(record)); - if (!sdp_record) { - error("Parsing of XML service record failed"); - return -EIO; - } - - if (add_record_to_server(src, sdp_record) < 0) { - error("Failed to register service record"); - sdp_record_free(sdp_record); - return -EIO; - } - - user_record = g_new0(struct record_data, 1); - - user_record->handle = sdp_record->handle; - - user_record->sender = g_strdup(sender); - - records = g_slist_append(records, user_record); - - user_record->listener_id = g_dbus_add_disconnect_watch(conn, sender, - exit_callback, user_record, NULL); - - debug("listener_id %d", user_record->listener_id); - - *handle = user_record->handle; - - return 0; -} - -static DBusMessage *update_record(DBusConnection *conn, DBusMessage *msg, - bdaddr_t *src, dbus_uint32_t handle, sdp_record_t *sdp_record) -{ - int err; - - if (remove_record_from_server(handle) < 0) { - sdp_record_free(sdp_record); - return g_dbus_create_error(msg, - ERROR_INTERFACE ".NotAvailable", - "Not Available"); - } - - sdp_record->handle = handle; - err = add_record_to_server(src, sdp_record); - if (err < 0) { - sdp_record_free(sdp_record); - error("Failed to update the service record"); - return g_dbus_create_error(msg, - ERROR_INTERFACE ".Failed", - strerror(EIO)); - } - - return dbus_message_new_method_return(msg); -} - -DBusMessage *update_xml_record(DBusConnection *conn, - DBusMessage *msg, bdaddr_t *src) -{ - struct record_data *user_record; - sdp_record_t *sdp_record; - const char *record; - dbus_uint32_t handle; - int len; - - if (dbus_message_get_args(msg, NULL, - DBUS_TYPE_UINT32, &handle, - DBUS_TYPE_STRING, &record, - DBUS_TYPE_INVALID) == FALSE) - return NULL; - - len = (record ? strlen(record) : 0); - if (len == 0) - return invalid_arguments(msg); - - user_record = find_record(handle, dbus_message_get_sender(msg)); - if (!user_record) - return g_dbus_create_error(msg, - ERROR_INTERFACE ".NotAvailable", - "Not Available"); - - sdp_record = sdp_xml_parse_record(record, len); - if (!sdp_record) { - error("Parsing of XML service record failed"); - sdp_record_free(sdp_record); - return g_dbus_create_error(msg, - ERROR_INTERFACE ".Failed", - strerror(EIO)); - } - - return update_record(conn, msg, src, handle, sdp_record); -} - -int remove_record(DBusConnection *conn, const char *sender, - dbus_uint32_t handle) -{ - struct record_data *user_record; - - debug("remove record 0x%x", handle); - - user_record = find_record(handle, sender); - if (!user_record) - return -1; - - debug("listner_id %d", user_record->listener_id); - - g_dbus_remove_watch(conn, user_record->listener_id); - - exit_callback(user_record); - - return 0; -} diff --git a/src/dbus-database.h b/src/dbus-database.h deleted file mode 100644 index 2f5606fc..00000000 --- a/src/dbus-database.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * BlueZ - Bluetooth protocol stack for Linux - * - * Copyright (C) 2006-2007 Nokia Corporation - * Copyright (C) 2004-2008 Marcel Holtmann <marcel@holtmann.org> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#define DATABASE_INTERFACE "org.bluez.Database" - -int add_xml_record(DBusConnection *conn, const char *sender, bdaddr_t *src, - const char *record, dbus_uint32_t *handle); -DBusMessage *update_xml_record(DBusConnection *conn, - DBusMessage *msg, bdaddr_t *src); -int remove_record(DBusConnection *conn, const char *sender, - dbus_uint32_t handle); diff --git a/src/list-devices b/src/list-devices deleted file mode 100755 index ec6c580a..00000000 --- a/src/list-devices +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/python - -import dbus - -bus = dbus.SystemBus() - -manager = dbus.Interface(bus.get_object("org.bluez", "/"), - "org.bluez.Manager") - -def extract_uuids(uuid_list): - list = "" - for uuid in uuid_list: - if (uuid.endswith("-0000-1000-8000-00805f9b34fb")): - if (uuid.startswith("0000")): - val = "0x" + uuid[4:8] - else: - val = "0x" + uuid[0:8] - else: - val = str(uuid) - list = list + val + " " - return list - -adapter_list = manager.ListAdapters() - -for i in adapter_list: - adapter = dbus.Interface(bus.get_object("org.bluez", i), - "org.bluez.Adapter") - print "[ " + i + " ]" - - properties = adapter.GetProperties() - for key in properties.keys(): - print " %s = %s" % (key, properties[key]) - - device_list = adapter.ListDevices() - - for n in device_list: - device = dbus.Interface(bus.get_object("org.bluez", n), - "org.bluez.Device") - print " [ " + n + " ]" - - properties = device.GetProperties() - for key in properties.keys(): - value = properties[key] - if (key == "UUIDs"): - list = extract_uuids(value) - print " %s = %s" % (key, list) - elif (key == "Class"): - print " %s = 0x%06x" % (key, value) - else: - print " %s = %s" % (key, value) - - print @@ -640,7 +640,7 @@ static gboolean option_debug = FALSE; static GOptionEntry options[] = { { "nodaemon", 'n', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &option_detach, - "Don't fork daemon to background" }, + "Don't run as daemon in background" }, { "debug", 'd', 0, G_OPTION_ARG_NONE, &option_debug, "Enable debug information output" }, { NULL }, diff --git a/src/service-did.xml b/src/service-did.xml deleted file mode 100644 index 52eb68c0..00000000 --- a/src/service-did.xml +++ /dev/null @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> - -<record> - <attribute id="0x0001"> - <sequence> - <uuid value="0x1200"/> - </sequence> - </attribute> - - <attribute id="0x0200"> - <uint16 value="0x0102" name="id"/> - </attribute> - - <attribute id="0x0201"> - <uint16 value="0x0a12" name="vendor"/> - </attribute> - - <attribute id="0x0202"> - <uint16 value="0x4711" name="product"/> - </attribute> - - <attribute id="0x0203"> - <uint16 value="0x0000" name="version"/> - </attribute> - - <attribute id="0x0204"> - <boolean value="true"/> - </attribute> - - <attribute id="0x0205"> - <uint16 value="0x0002" name="source"/> - </attribute> -</record> diff --git a/src/service-ftp.xml b/src/service-ftp.xml deleted file mode 100644 index 1bda8857..00000000 --- a/src/service-ftp.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> - -<record> - <attribute id="0x0001"> - <sequence> - <uuid value="0x1106"/> - </sequence> - </attribute> - - <attribute id="0x0004"> - <sequence> - <sequence> - <uuid value="0x0100"/> - </sequence> - <sequence> - <uuid value="0x0003"/> - <uint8 value="23" name="channel"/> - </sequence> - <sequence> - <uuid value="0x0008"/> - </sequence> - </sequence> - </attribute> - - <attribute id="0x0009"> - <sequence> - <sequence> - <uuid value="0x1106"/> - <uint16 value="0x0100" name="version"/> - </sequence> - </sequence> - </attribute> - - <attribute id="0x0100"> - <text value="OBEX File Transfer" name="name"/> - </attribute> -</record> diff --git a/src/service-opp.xml b/src/service-opp.xml deleted file mode 100644 index 351b4a41..00000000 --- a/src/service-opp.xml +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> - -<record> - <attribute id="0x0001"> - <sequence> - <uuid value="0x1105"/> - </sequence> - </attribute> - - <attribute id="0x0004"> - <sequence> - <sequence> - <uuid value="0x0100"/> - </sequence> - <sequence> - <uuid value="0x0003"/> - <uint8 value="23" name="channel"/> - </sequence> - <sequence> - <uuid value="0x0008"/> - </sequence> - </sequence> - </attribute> - - <attribute id="0x0009"> - <sequence> - <sequence> - <uuid value="0x1105"/> - <uint16 value="0x0100" name="version"/> - </sequence> - </sequence> - </attribute> - - <attribute id="0x0100"> - <text value="OBEX Object Push" name="name"/> - </attribute> - - <attribute id="0x0303"> - <sequence> - <uint8 value="0x01"/> - <uint8 value="0x01"/> - <uint8 value="0x02"/> - <uint8 value="0x03"/> - <uint8 value="0x04"/> - <uint8 value="0x05"/> - <uint8 value="0x06"/> - <uint8 value="0xff"/> - </sequence> - </attribute> -</record> diff --git a/src/service-record.dtd b/src/service-record.dtd deleted file mode 100644 index f53be5d0..00000000 --- a/src/service-record.dtd +++ /dev/null @@ -1,66 +0,0 @@ -<!ELEMENT record (attribute)*> - -<!ELEMENT attribute (sequence|alternate|text|url|uuid|boolean|uint8|uint16|uint32|uint64|nil)+> -<!ATTLIST attribute id CDATA #REQUIRED> - -<!ELEMENT sequence (sequence|alternate|text|url|uuid|boolean|uint8|uint16|uint32|uint64|uint128|int8|int16|int32|int64|int128|nil)+> - -<!ELEMENT alternate (sequence|alternate|text|url|uuid|boolean|uint8|uint16|uint32|uint64|uint128|int8|int16|int32|int64|int128|nil)+> - -<!ELEMENT text EMPTY> -<!ATTLIST text value CDATA #REQUIRED> -<!ATTLIST text name CDATA> -<!ATTLIST text encoding (normal|hex) "normal"> - -<!ELEMENT url EMPTY> -<!ATTLIST url value CDATA #REQUIRED> -<!ATTLIST url name CDATA> - -<!ELEMENT uuid EMPTY> -<!ATTLIST uuid value CDATA #REQUIRED> - -<!ELEMENT boolean EMPTY> -<!ATTLIST boolean value CDATA #REQUIRED> -<!ATTLIST boolean name CDATA> - -<!ELEMENT uint8 EMPTY> -<!ATTLIST uint8 value CDATA #REQUIRED> -<!ATTLIST uint8 name CDATA> - -<!ELEMENT uint16 EMPTY> -<!ATTLIST uint16 value CDATA #REQUIRED> -<!ATTLIST uint16 name CDATA> - -<!ELEMENT uint32 EMPTY> -<!ATTLIST uint32 value CDATA #REQUIRED> -<!ATTLIST uint32 name CDATA> - -<!ELEMENT uint64 EMPTY> -<!ATTLIST uint64 value CDATA #REQUIRED> -<!ATTLIST uint64 name CDATA> - -<!ELEMENT uint128 EMPTY> -<!ATTLIST uint128 value CDATA #REQUIRED> -<!ATTLIST uint128 name CDATA> - -<!ELEMENT int8 EMPTY> -<!ATTLIST int8 value CDATA #REQUIRED> -<!ATTLIST int8 name CDATA> - -<!ELEMENT int16 EMPTY> -<!ATTLIST int16 value CDATA #REQUIRED> -<!ATTLIST int16 name CDATA> - -<!ELEMENT int32 EMPTY> -<!ATTLIST int32 value CDATA #REQUIRED> -<!ATTLIST int32 name CDATA> - -<!ELEMENT int64 EMPTY> -<!ATTLIST int64 value CDATA #REQUIRED> -<!ATTLIST int64 name CDATA> - -<!ELEMENT int128 EMPTY> -<!ATTLIST int128 value CDATA #REQUIRED> -<!ATTLIST int128 name CDATA> - -<!ELEMENT nil EMPTY> diff --git a/src/service-spp.xml b/src/service-spp.xml deleted file mode 100644 index 2b156c3f..00000000 --- a/src/service-spp.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> - -<record> - <attribute id="0x0001"> - <sequence> - <uuid value="0x1101"/> - </sequence> - </attribute> - - <attribute id="0x0004"> - <sequence> - <sequence> - <uuid value="0x0100"/> - </sequence> - <sequence> - <uuid value="0x0003"/> - <uint8 value="23" name="channel"/> - </sequence> - </sequence> - </attribute> - - <attribute id="0x0100"> - <text value="COM5" name="name"/> - </attribute> -</record> diff --git a/src/simple-agent b/src/simple-agent deleted file mode 100755 index 0d3dc1f7..00000000 --- a/src/simple-agent +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/python - -import gobject - -import sys -import dbus -import dbus.service -import dbus.mainloop.glib - -class Rejected(dbus.DBusException): - _dbus_error_name = "org.bluez.Error.Rejected" - -class Agent(dbus.service.Object): - exit_on_release = True - - def set_exit_on_release(self, exit_on_release): - self.exit_on_release = exit_on_release - - @dbus.service.method("org.bluez.Agent", - in_signature="", out_signature="") - def Release(self): - print "Release" - if self.exit_on_release: - mainloop.quit() - - @dbus.service.method("org.bluez.Agent", - in_signature="os", out_signature="") - def Authorize(self, device, uuid): - print "Authorize (%s, %s)" % (device, uuid) - - @dbus.service.method("org.bluez.Agent", - in_signature="o", out_signature="s") - def RequestPinCode(self, device): - print "RequestPinCode (%s)" % (device) - return raw_input("Enter PIN Code: ") - - @dbus.service.method("org.bluez.Agent", - in_signature="o", out_signature="u") - def RequestPasskey(self, device): - print "RequestPasskey (%s)" % (device) - passkey = raw_input("Enter passkey: ") - return dbus.UInt32(passkey) - - @dbus.service.method("org.bluez.Agent", - in_signature="ou", out_signature="") - def DisplayPasskey(self, device, passkey): - print "DisplayPasskey (%s, %d)" % (device, passkey) - - @dbus.service.method("org.bluez.Agent", - in_signature="ou", out_signature="") - def RequestConfirmation(self, device, passkey): - print "RequestConfirmation (%s, %d)" % (device, passkey) - confirm = raw_input("Confirm passkey (yes/no): ") - if (confirm == "yes"): - return - raise Rejected("Passkey doesn't match") - - @dbus.service.method("org.bluez.Agent", - in_signature="s", out_signature="") - def ConfirmModeChange(self, mode): - print "ConfirmModeChange (%s)" % (mode) - - @dbus.service.method("org.bluez.Agent", - in_signature="", out_signature="") - def Cancel(self): - print "Cancel" - -def create_device_reply(device): - print "New device (%s)" % (device) - mainloop.quit() - -def create_device_error(error): - print "Creating device failed: %s" % (error) - mainloop.quit() - -if __name__ == '__main__': - dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) - - bus = dbus.SystemBus() - manager = dbus.Interface(bus.get_object("org.bluez", "/"), - "org.bluez.Manager") - - if len(sys.argv) > 1: - path = manager.FindAdapter(sys.argv[1]) - else: - path = manager.DefaultAdapter() - - adapter = dbus.Interface(bus.get_object("org.bluez", path), - "org.bluez.Adapter") - - path = "/test/agent" - agent = Agent(bus, path) - - mainloop = gobject.MainLoop() - - if len(sys.argv) > 2: - if len(sys.argv) > 3: - device = adapter.FindDevice(sys.argv[2]) - adapter.RemoveDevice(device) - - agent.set_exit_on_release(False) - adapter.CreatePairedDevice(sys.argv[2], path, "DisplayYesNo", - reply_handler=create_device_reply, - error_handler=create_device_error) - else: - adapter.RegisterAgent(path, "DisplayYesNo") - print "Agent registered" - - mainloop.run() - - #adapter.UnregisterAgent(path) - #print "Agent unregistered" diff --git a/src/simple-service b/src/simple-service deleted file mode 100755 index 5279a3a6..00000000 --- a/src/simple-service +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/python - -import sys -import time -import dbus - -xml = ' \ -<?xml version="1.0" encoding="UTF-8" ?> \ -<record> \ - <attribute id="0x0001"> \ - <sequence> \ - <uuid value="0x1101"/> \ - </sequence> \ - </attribute> \ - \ - <attribute id="0x0002"> \ - <uint32 value="0"/> \ - </attribute> \ - \ - <attribute id="0x0003"> \ - <uuid value="00001101-0000-1000-8000-00805f9b34fb"/> \ - </attribute> \ - \ - <attribute id="0x0004"> \ - <sequence> \ - <sequence> \ - <uuid value="0x0100"/> \ - </sequence> \ - <sequence> \ - <uuid value="0x0003"/> \ - <uint8 value="23"/> \ - </sequence> \ - </sequence> \ - </attribute> \ - \ - <attribute id="0x0005"> \ - <sequence> \ - <uuid value="0x1002"/> \ - </sequence> \ - </attribute> \ - \ - <attribute id="0x0006"> \ - <sequence> \ - <uint16 value="0x656e"/> \ - <uint16 value="0x006a"/> \ - <uint16 value="0x0100"/> \ - </sequence> \ - </attribute> \ - \ - <attribute id="0x0007"> \ - <uint32 value="0"/> \ - </attribute> \ - \ - <attribute id="0x0008"> \ - <uint8 value="0xff"/> \ - </attribute> \ - \ - <attribute id="0x0009"> \ - <sequence> \ - <sequence> \ - <uuid value="0x1101"/> \ - <uint16 value="0x0100"/> \ - </sequence> \ - </sequence> \ - </attribute> \ - \ - <attribute id="0x000a"> \ - <url value="http://www.bluez.org/"/> \ - </attribute> \ - \ - <attribute id="0x000b"> \ - <url value="http://www.bluez.org/"/> \ - </attribute> \ - \ - <attribute id="0x000c"> \ - <url value="http://www.bluez.org/"/> \ - </attribute> \ - \ - <attribute id="0x0100"> \ - <text value="Serial Port"/> \ - </attribute> \ - \ - <attribute id="0x0101"> \ - <text value="Serial Port Service"/> \ - </attribute> \ - \ - <attribute id="0x0102"> \ - <text value="BlueZ"/> \ - </attribute> \ - \ - <attribute id="0x0200"> \ - <sequence> \ - <uint16 value="0x0100"/> \ - </sequence> \ - </attribute> \ - \ - <attribute id="0x0201"> \ - <uint32 value="0"/> \ - </attribute> \ -</record> \ -' - -bus = dbus.SystemBus() -manager = dbus.Interface(bus.get_object("org.bluez", "/"), - "org.bluez.Manager") - -if len(sys.argv) > 1: - path = manager.FindAdapter(sys.argv[1]) -else: - path = manager.DefaultAdapter() - -adapter = dbus.Interface(bus.get_object("org.bluez", path), - "org.bluez.Adapter") - -handle = adapter.AddServiceRecord(xml) - -print "Service record with handle 0x%04x added" % (handle) - -print "Press CTRL-C to remove service record" - -try: - time.sleep(1000) - print "Terminating session" -except: - pass - -adapter.RemoveServiceRecord(dbus.UInt32(handle)) diff --git a/src/telephony.c b/src/telephony.c deleted file mode 100644 index f68b97de..00000000 --- a/src/telephony.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * BlueZ - Bluetooth protocol stack for Linux - * - * Copyright (C) 2004-2008 Marcel Holtmann <marcel@holtmann.org> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glib.h> - -#include "telephony.h" - -static GSList *drivers = NULL; - -int bt_telephony_register_driver(struct bt_telephony_driver *driver) -{ - drivers = g_slist_append(drivers, driver); - - return 0; -} - -void bt_telephony_unregister_driver(struct bt_telephony_driver *driver) -{ - drivers = g_slist_remove(drivers, driver); -} diff --git a/src/telephony.h b/src/telephony.h deleted file mode 100644 index b360a621..00000000 --- a/src/telephony.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * BlueZ - Bluetooth protocol stack for Linux - * - * Copyright (C) 2004-2008 Marcel Holtmann <marcel@holtmann.org> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -struct bt_telephony_driver { - const char *name; -}; diff --git a/src/test-adapter b/src/test-adapter deleted file mode 100755 index 2ec8adef..00000000 --- a/src/test-adapter +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/python - -import sys -import dbus -import time - -bus = dbus.SystemBus() - -manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.bluez.Manager") - -adapter = dbus.Interface(bus.get_object("org.bluez", manager.DefaultAdapter()), - "org.bluez.Adapter") - -if (len(sys.argv) < 2): - print "Usage: %s <command>" % (sys.argv[0]) - print "" - print " address" - print " name [name]" - print " mode [mode]" - print " requestmode <mode>" - print " discoverabletimeout [timeout]" - print " periodicdiscovery [on/off]" - print " addservicerecord <file>" - sys.exit(1) - -if (sys.argv[1] == "address"): - properties = adapter.GetProperties() - print properties["Address"] - sys.exit(0) - -if (sys.argv[1] == "name"): - if (len(sys.argv) < 3): - properties = adapter.GetProperties() - print properties["Name"] - else: - adapter.SetProperty("Name", sys.argv[2]) - sys.exit(0) - -if (sys.argv[1] == "mode"): - if (len(sys.argv) < 3): - properties = adapter.GetProperties() - print properties["Mode"] - else: - adapter.SetProperty("Mode", sys.argv[2]) - sys.exit(0) - -if (sys.argv[1] == "requestmode"): - if (len(sys.argv) < 3): - print "Need mode parameter" - else: - adapter.RequestMode(sys.argv[2]) - sys.exit(0) - -if (sys.argv[1] == "discoverabletimeout"): - if (len(sys.argv) < 3): - properties = adapter.GetProperties() - print properties["DiscoverableTimeout"] - else: - timeout = dbus.UInt32(sys.argv[2]) - adapter.SetProperty("DiscoverableTimeout", timeout) - sys.exit(0) - -if (sys.argv[1] == "periodicdiscovery"): - if (len(sys.argv) < 3): - properties = adapter.GetProperties() - print properties["PeriodicDiscovery"] - else: - if (sys.argv[2] == "on"): - value = dbus.Boolean(1) - elif (sys.argv[2] == "off"): - value = dbus.Boolean(0) - else: - value = dbus.Boolean(sys.argv[2]) - adapter.SetProperty("PeriodicDiscovery", value) - time.sleep(120) - sys.exit(0) - -if (sys.argv[1] == "addservicerecord"): - if (len(sys.argv) < 3): - print "Need file parameter" - else: - f = open(sys.argv[2]) - record = f.read() - f.close() - handle = adapter.AddServiceRecord(record) - print "0x%x" % (handle) - time.sleep(120) - sys.exit(0) - -print "Unknown command" -sys.exit(1) diff --git a/src/test-device b/src/test-device deleted file mode 100755 index f8f2d14a..00000000 --- a/src/test-device +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/python - -import sys -import dbus -import re - -bus = dbus.SystemBus() - -manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.bluez.Manager") - -adapter = dbus.Interface(bus.get_object("org.bluez", manager.DefaultAdapter()), - "org.bluez.Adapter") - -if (len(sys.argv) < 2): - print "Usage: %s <command>" % (sys.argv[0]) - print "" - print " list" - print " create <address>" - print " remove <address|path>" - print " discover <address> [pattern]" - print " class <address>" - print " name <address>" - print " alias <address> [alias]" - print " trusted <address> [yes/no]" - sys.exit(1) - -if (sys.argv[1] == "list"): - list = adapter.ListDevices() - print list - sys.exit(0) - -if (sys.argv[1] == "create"): - if (len(sys.argv) < 3): - print "Need address parameter" - else: - device = adapter.CreateDevice(sys.argv[2]) - print device - sys.exit(0) - -if (sys.argv[1] == "remove"): - if (len(sys.argv) < 3): - print "Need address or object path parameter" - else: - try: - path = adapter.FindDevice(sys.argv[2]) - except: - path = sys.argv[2] - adapter.RemoveDevice(path) - sys.exit(0) - -if (sys.argv[1] == "discover"): - if (len(sys.argv) < 3): - print "Need address parameter" - else: - path = adapter.FindDevice(sys.argv[2]) - device = dbus.Interface(bus.get_object("org.bluez", path), - "org.bluez.Device") - if (len(sys.argv) < 4): - pattern = "" - else: - pattern = sys.argv[3] - services = device.DiscoverServices(pattern); - for key in services.keys(): - p = re.compile(">.*?<") - xml = p.sub("><", services[key].replace("\n", "")) - print "[ 0x%5x ]" % (key) - print xml - print - sys.exit(0) - -if (sys.argv[1] == "class"): - if (len(sys.argv) < 3): - print "Need address parameter" - else: - path = adapter.FindDevice(sys.argv[2]) - device = dbus.Interface(bus.get_object("org.bluez", path), - "org.bluez.Device") - properties = device.GetProperties() - print "0x%06x" % (properties["Class"]) - sys.exit(0) - -if (sys.argv[1] == "name"): - if (len(sys.argv) < 3): - print "Need address parameter" - else: - path = adapter.FindDevice(sys.argv[2]) - device = dbus.Interface(bus.get_object("org.bluez", path), - "org.bluez.Device") - properties = device.GetProperties() - print properties["Name"] - sys.exit(0) - -if (sys.argv[1] == "alias"): - if (len(sys.argv) < 3): - print "Need address parameter" - else: - path = adapter.FindDevice(sys.argv[2]) - device = dbus.Interface(bus.get_object("org.bluez", path), - "org.bluez.Device") - if (len(sys.argv) < 4): - properties = device.GetProperties() - print properties["Alias"] - else: - device.SetProperty("Alias", sys.argv[3]) - sys.exit(0) - -if (sys.argv[1] == "trusted"): - if (len(sys.argv) < 3): - print "Need address parameter" - else: - path = adapter.FindDevice(sys.argv[2]) - device = dbus.Interface(bus.get_object("org.bluez", path), - "org.bluez.Device") - if (len(sys.argv) < 4): - properties = device.GetProperties() - print properties["Trusted"] - else: - if (sys.argv[3] == "yes"): - value = dbus.Boolean(1) - elif (sys.argv[3] == "no"): - value = dbus.Boolean(0) - else: - value = dbus.Boolean(sys.argv[3]) - device.SetProperty("Trusted", value) - sys.exit(0) - -print "Unknown command" -sys.exit(1) diff --git a/src/test-discovery b/src/test-discovery deleted file mode 100755 index 874de66f..00000000 --- a/src/test-discovery +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/python - -import gobject - -import dbus -import dbus.mainloop.glib - -def device_found(address, properties): - print "[ " + address + " ]" - - for key in properties.keys(): - value = properties[key] - if (key == "Class"): - print " %s = 0x%06x" % (key, value) - else: - print " %s = %s" % (key, value) - -def discovery_completed(): - mainloop.quit() - -if __name__ == '__main__': - dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) - - bus = dbus.SystemBus() - manager = dbus.Interface(bus.get_object("org.bluez", "/"), - "org.bluez.Manager") - - path = manager.DefaultAdapter() - adapter = dbus.Interface(bus.get_object("org.bluez", path), - "org.bluez.Adapter") - - bus.add_signal_receiver(device_found, - dbus_interface = "org.bluez.Adapter", - signal_name = "DeviceFound") - - bus.add_signal_receiver(discovery_completed, - dbus_interface = "org.bluez.Adapter", - signal_name = "DiscoveryCompleted") - - adapter.DiscoverDevices() - - mainloop = gobject.MainLoop() - mainloop.run() diff --git a/src/test-manager b/src/test-manager deleted file mode 100755 index 759b6a48..00000000 --- a/src/test-manager +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/python - -import gobject - -import dbus -import dbus.mainloop.glib - -def adapter_added(path): - print "Adapter with path %s added" % (path) - -def adapter_removed(path): - print "Adapter with path %s removed" % (path) - -if __name__ == "__main__": - dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) - - bus = dbus.SystemBus() - - manager = dbus.Interface(bus.get_object('org.bluez', '/org/bluez'), - 'org.bluez.Manager') - - manager.connect_to_signal("AdapterAdded", adapter_added) - - manager.connect_to_signal("AdapterRemoved", adapter_removed) - - mainloop = gobject.MainLoop() - mainloop.run() |