summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--HACKING18
-rw-r--r--README13
-rw-r--r--src/gnomebt-controller-test.c145
4 files changed, 161 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 4990b725..326feb40 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,7 @@
* python/Makefile.am: small tidyups
* configure.in, Makefile.am: stop compilation of orbit/ subdir
* python/manager.py: remove Bonobo use, use new gnomebt.controller module
+ * README, HACKING: freshen up to reflect removal of Bonobo component
2003-09-27 Bastien Nocera <hadess@hadess.net>
diff --git a/HACKING b/HACKING
index c6a7a893..39f0afd0 100644
--- a/HACKING
+++ b/HACKING
@@ -4,12 +4,11 @@ This is mostly incomplete.
Directory layout
================
-src/ : home for the GNOME_Bluetooth_Manager Bonobo component, and
- libgnomebt, a library for helper functions for the GNOME Bluetooth
- subsystem
+src/ : home libgnomebt, which comprises helper classes, and the
+ GnomebtController class, the main point of access for the
+ GNOME Bluetooth subsystem
python/ : Python tools, including bindings for iconlist from libegg.
obex/ : OBEX send and receive tools
-orbit/ : Type library for the Bonobo component
nautilus/ : Context-menu extension for Nautilus
libegg/ : Bits from libegg we need
pixmaps/ : Graphics
@@ -19,12 +18,11 @@ ui/ : Glade files and other UI components
Architectural notes
===================
-The bonobo component is intended to encapsulate the subsystem: client programs
-should use the component. This enables the system to change while preserving
-some guarantee of API compatibility.
+The GnomebtController class is intended to encapsulate the subsystem:
+client programs should use this object. This enables the system to change
+while preserving some guarantee of API compatibility.
Don't hit the gconf prefs directly: the layout of these may change without
-warning. The bonobo IDL is a contract however, and will never change in a
-backwards incompatible mannger.
-
+warning. The GnomebtController class is a contract however, and will never
+change in a backwards incompatible manner within a major version release.
diff --git a/README b/README
index 78ea6fb9..b2b7bd83 100644
--- a/README
+++ b/README
@@ -7,12 +7,12 @@ project.
The software is in its early stages right now.
-This package contains a Bonobo server to control Bluetooth devices,
-and a simple GUI to explore which devices are available
-(gnome-bluetooth-admin). An OBEX server is available,
+This package contains a controller class, GnomebtController, to control
+Bluetooth devices, and a simple GUI to explore which devices are
+available (gnome-bluetooth-manager). An OBEX server is available,
gnome-obex-server. This will receive files sent via Bluetooth to your
PC, and save them in your home directory. The program gnome-obex-send
-enables you to send files. It is used by the Nautilus component --
+enables you to send files. It is used by the Nautilus component --
select the files you want to send and choose "Send via Bluetooth..."
from the context menu.
@@ -29,6 +29,7 @@ You need:
* These GNOME 2 packages:
gobject-2.0 libgnomeui-2.0 >= 1.110.0 libbonobo-2.0
- bonobo-activation-2.0 gconf-2.0 gob2
+ bonobo-activation-2.0 gconf-2.0 gob2 pygtk-2.2 python2.2/2.3
- -- Edd Dumbill <edd@usefulinc.com>, Sat Jun 7 17:08:07 BST 2003
+ -- Edd Dumbill <edd@usefulinc.com>
+ Thu Oct 30 19:12:10 GMT 2003
diff --git a/src/gnomebt-controller-test.c b/src/gnomebt-controller-test.c
new file mode 100644
index 00000000..c5dac5f5
--- /dev/null
+++ b/src/gnomebt-controller-test.c
@@ -0,0 +1,145 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <glib-object.h>
+#include <unistd.h>
+
+#include "gnomebt-controller.h"
+
+#include <bluetooth/sdp.h>
+
+/* change this to a device you know works */
+
+#define TBDADDR "00:80:37:2A:B6:BC"
+
+static void status_callback(GnomebtController *bc,
+ gint field,
+ gpointer data) {
+
+ printf("got status %d\n", field);
+}
+
+static void add_device_callback(GnomebtController *bc,
+ gchar* name,
+ gpointer data) {
+
+ printf("got device %s\n", name);
+}
+
+static void device_name_callback(GnomebtController *bc,
+ gchar* device,
+ gchar* name,
+ gpointer data) {
+
+ printf("device %s is called %s\n", device, name);
+}
+
+static void add_device_service_callback(GnomebtController *bc,
+ gchar *addr, gchar *name,
+ guint clsid, guint channel,
+ gpointer data)
+{
+ printf("device %s (%s) has service %d channel %d\n",
+ addr, name, clsid, channel);
+}
+
+
+int main(int argc, char **argv)
+{
+ GnomebtController *bc;
+ GSList *services, *item, *chans, *devices;
+ int num;
+ gchar *devname;
+ FILE *f;
+
+ g_type_init();
+
+ bc=gnomebt_controller_new();
+
+ /* these are our own signal handlers. note that the
+ * gnomebt_controller has some too for the same signals,
+ * which update the gconf registry with cached information
+ */
+
+ g_signal_connect (G_OBJECT(bc), "status_change",
+ G_CALLBACK(status_callback), NULL);
+ g_signal_connect (G_OBJECT(bc), "add_device",
+ G_CALLBACK(add_device_callback), NULL);
+ g_signal_connect (G_OBJECT(bc), "device_name",
+ G_CALLBACK(device_name_callback), NULL);
+ g_signal_connect (G_OBJECT(bc), "add_device_service",
+ G_CALLBACK(add_device_service_callback),
+ NULL);
+
+ btctl_controller_list_rfcomm_connections(BTCTL_CONTROLLER(bc));
+
+ printf("Connection to " TBDADDR " %d\n",
+ btctl_controller_get_established_rfcomm_connection(BTCTL_CONTROLLER(bc), TBDADDR, 0));
+
+ btctl_controller_discover_devices(BTCTL_CONTROLLER(bc));
+
+ printf("Looking to see what channel OPUSH is on " TBDADDR "\n");
+
+ btctl_controller_scan_for_service(BTCTL_CONTROLLER(bc), TBDADDR, 0x1105);
+
+ printf("Examining " TBDADDR ", name %s class %x\n",
+ gnomebt_controller_get_device_name(bc, TBDADDR),
+ gnomebt_controller_get_device_class(bc, TBDADDR));
+
+
+ printf("Services supported:\n");
+
+ services = gnomebt_controller_services_for_device (bc, TBDADDR);
+ for (item=services; item != NULL; item = g_slist_next (item)) {
+ GnomebtServiceDesc *desc = (GnomebtServiceDesc *)item->data;
+ printf (" Service ID: %x\n", desc->id);
+ for (chans=desc->channels; chans!=NULL; chans = g_slist_next (chans)) {
+ printf (" Channel: %d\n", (guint) chans->data);
+ }
+ }
+ gnomebt_controller_service_list_free (bc, services);
+
+ chans = gnomebt_controller_channels_for_service (bc, TBDADDR, 0x1101);
+ printf ("Channels for Service ID: %x\n", 0x1101);
+ for ( ; chans!=NULL; chans = g_slist_next (chans)) {
+ printf (" Channel: %d\n", (guint) chans->data);
+ }
+
+ printf ("Known devices:\n");
+ for (devices = gnomebt_controller_known_devices (bc); devices != NULL; devices = g_slist_next (devices)) {
+ GnomebtDeviceDesc *dd = (GnomebtDeviceDesc *)devices->data;
+ printf ("Name %s Address %s Class %x\n",
+ dd->name, dd->bdaddr, dd->deviceclass);
+ }
+ gnomebt_controller_device_desc_list_free (bc, devices);
+
+ printf ("Known devices that are phones:\n");
+ for (devices = gnomebt_controller_known_devices_of_class (bc, GNOMEBT_MAJOR_PHONE ); devices != NULL; devices = g_slist_next (devices)) {
+ GnomebtDeviceDesc *dd = (GnomebtDeviceDesc *)devices->data;
+ printf ("Name %s Address %s Class %x\n",
+ dd->name, dd->bdaddr, dd->deviceclass);
+ }
+ gnomebt_controller_device_desc_list_free (bc, devices);
+
+ printf ("Testing RFCOMM\n");
+
+ num = gnomebt_controller_connect_rfcomm_port_by_service (bc, TBDADDR,
+ DIALUP_NET_SVCLASS_ID);
+
+ printf ("Connected dialup on channel %d\n", num);
+ printf ("Now sending data to /dev/rfcomm%d\n", num);
+ devname=g_strdup_printf("/dev/rfcomm%d", num);
+ f=fopen(devname, "wb");
+ g_free(devname);
+ if (f) {
+ fprintf (f, "foo");
+ fclose(f);
+ } else {
+ printf("open failed\n");
+ }
+
+ g_object_unref(bc);
+
+ return 0;
+}