* [Bluez-devel] Wizard patch
@ 2008-06-27 19:05 Michael Terry
2008-06-27 19:18 ` Michael Terry
` (3 more replies)
0 siblings, 4 replies; 30+ messages in thread
From: Michael Terry @ 2008-06-27 19:05 UTC (permalink / raw)
To: bluez-devel
[-- Attachment #1.1.1: Type: text/plain, Size: 3168 bytes --]
Hello, all!
I have attached a patch against 0.27 (it applies cleanly against CVS) to
complete the wizard in the bluez-gnome source tree.
Here's what my patch does in summary, details below:
Wizard dialog shows list of device types we know how to handle (only
mouse/keyboard/headset right now). Then, it tries to connect to the
appropriate bluetooth dbus service and trust the device. Basically the
same code steps the Properties -> Services tab does, but more
wizardy. :)
I made changes to cleanup the wizard interface (removed a couple of
pages that had low signal/noise ratio) and made several of the
bluetooth_client capable of giving feedback about the operation via a
callback.
Details of changes:
applet/main.c:
Uncomments code to add a menu item for the wizard.
common/bluetooth-device-selection.c:
Fixes broken code to set current filter programmatically.
common/client.[ch]:
setup_services():
Note presence of audio and input services on startup
bluetooth_client_get_name():
Gets user-visible device name for a path
bluetooth_client_available_services():
Returns a mask of the device types supported by services the client
knows about. Not actually used by the rest of my code, but it seemed
possibly useful to one day not show unsupported device types in the
wizard if we wanted to.
bluetooth_client_cancel_call():
Cancels an async call for a particular adapter/address combo. This is
slightly janky because it only allows for one call at a time per pair,
but that's all that we ever need right now.
connect_to_service():
Handles service-specific calls to initiate a device connection. Stuff
like CreateSecureDevice or CreateHeadset.
bluetooth_client_connect():
Kicks off a call to connect_to_service
bluetooth_client_create_bonding():
bluetooth_client_remove_bonding():
bluetooth_client_set_trusted():
bluetooth_client_remove_trust():
Modified to allow callbacks
common/dbus.xml:
Add input.CreateSecureDevice and audio.CreateHeadset
properties/adapter.c:
Update a few calls to client functions do to above prototype changes
wizard/agent.[ch]:
Mostly a copy of applet/agent.c, except:
it only holds passkey code (no auth code)
it shows dialogs immediately wrt a parent window
wizard/main.c:
Comment out intro and info pages -- I think the intro page just gets in
the user's way and there was no content in info page, and even if there
was, it would probably also just get in user's way.
I added a pulsing progress bar to the pairing page to give some
feedback.
I changed wording from 'setup' and 'pair' to 'connect'. I figure that
is more user-friendly (since no real setting up is done by user and they
probably think in terms of connecting to devices not pairing with them).
Pairing process is two-step: bluetooth_client_connect followed by
bluetooth_client_set_trusted.
Show an error if either step fails.
Connect to agent code to display a password prompt immediately in front
of user instead of via bluetooth applet.
wizard/Makefile.am:
Install bluetooth-wizard and add agent.[ch]
Thanks!
-mt
[-- Attachment #1.1.2: Type: text/x-patch, Size: 46882 bytes --]
diff -rupN bluez-gnome-0.27.orig/applet/main.c bluez-gnome-0.27/applet/main.c
--- bluez-gnome-0.27.orig/applet/main.c 2008-06-27 14:12:49.000000000 -0400
+++ bluez-gnome-0.27/applet/main.c 2008-06-27 14:13:05.000000000 -0400
@@ -625,7 +625,6 @@ static void sendto_callback(GObject *wid
g_printerr("Couldn't execute command: %s\n", command);
}
-#if 0
static void wizard_callback(GObject *widget, gpointer user_data)
{
const char *command = "bluetooth-wizard --singleton";
@@ -633,7 +632,6 @@ static void wizard_callback(GObject *wid
if (!g_spawn_command_line_async(command, NULL))
g_printerr("Couldn't execute command: %s\n", command);
}
-#endif
static void activate_callback(GObject *widget, gpointer user_data)
{
@@ -697,17 +695,15 @@ static GtkWidget *create_popupmenu(void)
menuitem_browse = item;
-#if 0
item = gtk_separator_menu_item_new();
gtk_widget_show(item);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
- item = gtk_menu_item_new_with_label(_("Setup New Device"));
+ item = gtk_menu_item_new_with_label(_("Connect New Device..."));
g_signal_connect(item, "activate",
G_CALLBACK(wizard_callback), NULL);
gtk_widget_show(item);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-#endif
return menu;
}
diff -rupN bluez-gnome-0.27.orig/common/bluetooth-device-selection.c bluez-gnome-0.27/common/bluetooth-device-selection.c
--- bluez-gnome-0.27.orig/common/bluetooth-device-selection.c 2008-06-27 14:12:49.000000000 -0400
+++ bluez-gnome-0.27/common/bluetooth-device-selection.c 2008-06-27 14:13:05.000000000 -0400
@@ -90,6 +90,15 @@ bluetooth_device_category_to_string (int
}
}
+static int
+int_log2(int v)
+{
+ unsigned rv = 0;
+ while (v >>= 1)
+ rv++;
+ return rv;
+}
+
static void
name_to_text (GtkTreeViewColumn *column, GtkCellRenderer *cell,
GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
@@ -591,7 +600,7 @@ bluetooth_device_selection_init(Bluetoot
}
g_signal_connect (G_OBJECT (priv->device_type), "changed",
G_CALLBACK(filter_type_changed_cb), self);
- gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), priv->device_type_filter);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), int_log2(priv->device_type_filter));
if (priv->show_device_type) {
gtk_widget_show (priv->device_type_label);
gtk_widget_show (priv->device_type);
@@ -665,7 +674,7 @@ bluetooth_device_selection_set_property
break;
case PROP_DEVICE_TYPE_FILTER:
priv->device_type_filter = g_value_get_int (value);
- gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), priv->device_type_filter >> 1);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), int_log2(priv->device_type_filter));
break;
case PROP_DEVICE_CATEGORY_FILTER:
priv->device_category_filter = g_value_get_int (value);
@@ -751,7 +760,7 @@ bluetooth_device_selection_class_init (B
NULL, NULL, TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS(klass),
PROP_DEVICE_TYPE_FILTER, g_param_spec_int ("device-type-filter", NULL, NULL,
- 0, BLUETOOTH_TYPE_NUM_TYPES, 0, G_PARAM_READWRITE));
+ 1, 1 << (BLUETOOTH_TYPE_NUM_TYPES-1), 1, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS(klass),
PROP_DEVICE_CATEGORY_FILTER, g_param_spec_int ("device-category-filter", NULL, NULL,
0, BLUETOOTH_CATEGORY_NUM_CATEGORIES, 0, G_PARAM_READWRITE));
diff -rupN bluez-gnome-0.27.orig/common/client.c bluez-gnome-0.27/common/client.c
--- bluez-gnome-0.27.orig/common/client.c 2008-06-27 14:12:49.000000000 -0400
+++ bluez-gnome-0.27/common/client.c 2008-06-27 14:13:05.000000000 -0400
@@ -48,6 +48,8 @@ struct _BluetoothClientPrivate {
DBusGConnection *conn;
DBusGProxy *manager_object;
+ DBusGProxy *input_service;
+ DBusGProxy *audio_service;
GtkTreeStore *store;
gchar *default_adapter;
};
@@ -935,6 +937,33 @@ static void setup_manager(BluetoothClien
g_error_free(error);
}
+static void setup_services(BluetoothClient *client)
+{
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ gchar *busname = NULL;
+
+ priv->input_service = NULL;
+ priv->audio_service = NULL;
+
+ if (dbus_g_proxy_call(priv->manager_object, "ActivateService", NULL,
+ G_TYPE_STRING, "input", G_TYPE_INVALID,
+ G_TYPE_STRING, &busname, G_TYPE_INVALID)) {
+ priv->input_service = dbus_g_proxy_new_for_name(priv->conn, busname,
+ "/org/bluez/input",
+ "org.bluez.input.Manager");
+ g_free(busname);
+ }
+
+ if (dbus_g_proxy_call(priv->manager_object, "ActivateService", NULL,
+ G_TYPE_STRING, "audio", G_TYPE_INVALID,
+ G_TYPE_STRING, &busname, G_TYPE_INVALID)) {
+ priv->audio_service = dbus_g_proxy_new_for_name(priv->conn, busname,
+ "/org/bluez/audio",
+ "org.bluez.audio.Manager");
+ g_free(busname);
+ }
+}
+
static void name_owner_changed(DBusGProxy *object, const char *name,
const char *prev, const char *new, gpointer user_data)
{
@@ -984,6 +1013,8 @@ static void bluetooth_client_finalize(GO
g_free(priv->default_adapter);
g_object_unref(G_OBJECT(priv->store));
g_object_unref (priv->manager_object);
+ g_object_unref (priv->input_service);
+ g_object_unref (priv->audio_service);
}
static void bluetooth_client_init(BluetoothClient *client)
@@ -1000,6 +1031,8 @@ static void bluetooth_client_init(Blueto
setup_dbus(client);
setup_manager(client);
+
+ setup_services(client);
}
static void bluetooth_client_set_property(GObject *object, guint prop_id,
@@ -1085,6 +1118,50 @@ BluetoothClient *bluetooth_client_new(vo
}
}
+const gchar *bluetooth_client_get_name(BluetoothClient *self, const gchar *adapter)
+{
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(self);
+ GtkTreeIter iter;
+ gboolean cont;
+
+ if (adapter == NULL)
+ adapter = priv->default_adapter;
+
+ if (adapter == NULL)
+ return FALSE;
+
+ cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store), &iter);
+
+ while (cont == TRUE) {
+ gchar *path;
+ gchar *name;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+ COLUMN_PATH, &path,
+ COLUMN_NAME, &name, -1);
+
+ if (g_ascii_strcasecmp(path, adapter) == 0)
+ return g_strdup(name);
+
+ cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
+ }
+
+ return NULL;
+}
+
+int bluetooth_client_available_services(BluetoothClient *client)
+{
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ int rv = 0;
+
+ if (priv->input_service)
+ rv |= BLUETOOTH_TYPE_MOUSE | BLUETOOTH_TYPE_KEYBOARD;
+ if (priv->audio_service)
+ rv |= BLUETOOTH_TYPE_HEADSET;
+
+ return rv;
+}
+
gboolean bluetooth_client_register_passkey_agent(BluetoothClient *client,
const char *path, const char *address, const void *info)
{
@@ -1112,13 +1189,7 @@ gboolean bluetooth_client_register_passk
return TRUE;
}
-static void create_bonding_reply(DBusGProxy *proxy,
- GError *error, gpointer userdata)
-{
- //g_printf("create bonding reply\n");
-}
-
-gboolean bluetooth_client_create_bonding(BluetoothClient *client,
+gboolean bluetooth_client_cancel_call(BluetoothClient *client,
gchar *adapter, const gchar *address)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
@@ -1142,9 +1213,14 @@ gboolean bluetooth_client_create_bonding
COLUMN_OBJECT, &object, -1);
if (g_ascii_strcasecmp(path, adapter) == 0) {
- adapter_create_bonding_async(object, address,
- create_bonding_reply, NULL);
- return TRUE;
+ DBusGProxyCall *call;
+ call = (DBusGProxyCall *)g_object_get_data(G_OBJECT(object), "call");
+ if (call != NULL) {
+ dbus_g_proxy_cancel_call(object, call);
+ g_object_set_data(G_OBJECT(object), "call", NULL);
+ return TRUE;
+ }
+ return FALSE;
}
cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
@@ -1153,14 +1229,48 @@ gboolean bluetooth_client_create_bonding
return FALSE;
}
-static void remove_bonding_reply(DBusGProxy *proxy,
- GError *error, gpointer userdata)
+static void call_reply(DBusGProxy *proxy,
+ GError *error, gpointer userdata)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*) userdata;
+ g_object_set_data(G_OBJECT(proxy), "call", NULL);
+ if (data) {
+ (*(bluetooth_client_call_reply)data->cb) (error, data->userdata);
+ g_free(data);
+ }
+ if (error)
+ g_error_free(error);
+}
+
+static void call_reply_s(DBusGProxy *proxy, char *s,
+ GError *error, gpointer userdata)
{
- //g_printf("remove bonding reply\n");
+ call_reply(proxy, error, userdata);
}
-gboolean bluetooth_client_remove_bonding(BluetoothClient *client,
- gchar *adapter, const gchar *address)
+static gboolean connect_to_service(BluetoothClient *client, DBusGProxy *object,
+ const gchar *address, guint type,
+ gpointer userdata)
+{
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ DBusGProxyCall *call = NULL;
+
+ /* Special case the few types we can handle */
+ if (type == BLUETOOTH_TYPE_MOUSE || type == BLUETOOTH_TYPE_KEYBOARD)
+ call = input_create_secure_device_async(priv->input_service, address,
+ call_reply_s, userdata);
+ else if (type == BLUETOOTH_TYPE_HEADSET)
+ call = audio_create_headset_async(priv->audio_service, address,
+ call_reply_s, userdata);
+
+ g_object_set_data(G_OBJECT(object), "call", call);
+ return call != NULL;
+}
+
+gboolean bluetooth_client_connect(BluetoothClient *client, guint type,
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
GtkTreeIter iter;
@@ -1183,9 +1293,36 @@ gboolean bluetooth_client_remove_bonding
COLUMN_OBJECT, &object, -1);
if (g_ascii_strcasecmp(path, adapter) == 0) {
- adapter_remove_bonding_async(object, address,
- remove_bonding_reply, NULL);
- return TRUE;
+ DBusGAsyncData *stuff;
+ gboolean cont;
+ GtkTreeIter child;
+
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+
+ // If caller didn't specify a forced type, determine it from device info
+ if (type == 0 || type == BLUETOOTH_TYPE_ANY) {
+ cont = gtk_tree_model_iter_children(GTK_TREE_MODEL(priv->store),
+ &child, &iter);
+
+ while (cont == TRUE) {
+ gchar *value;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &child,
+ COLUMN_ADDRESS, &value, -1);
+
+ if (g_ascii_strcasecmp(address, value) == 0) {
+ gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &child,
+ COLUMN_TYPE, &type, -1);
+ break;
+ }
+
+ cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &child);
+ }
+ }
+
+ return connect_to_service(client, object, address, type, stuff);
}
cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
@@ -1194,14 +1331,53 @@ gboolean bluetooth_client_remove_bonding
return FALSE;
}
-static void set_trusted_reply(DBusGProxy *proxy,
- GError *error, gpointer userdata)
+gboolean bluetooth_client_create_bonding(BluetoothClient *client,
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
{
- //g_printf("set trusted reply\n");
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ GtkTreeIter iter;
+ gboolean cont;
+
+ if (adapter == NULL)
+ adapter = priv->default_adapter;
+
+ if (adapter == NULL)
+ return FALSE;
+
+ cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store), &iter);
+
+ while (cont == TRUE) {
+ DBusGProxy *object;
+ gchar *path;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+ COLUMN_PATH, &path,
+ COLUMN_OBJECT, &object, -1);
+
+ if (g_ascii_strcasecmp(path, adapter) == 0) {
+ DBusGProxyCall *call;
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ call = adapter_create_bonding_async(object, address,
+ call_reply, stuff);
+ g_object_set_data(G_OBJECT(object), "call", call);
+ return call != NULL;
+ }
+
+ cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
+ }
+
+ return FALSE;
}
-gboolean bluetooth_client_set_trusted(BluetoothClient *client,
- gchar *adapter, const gchar *address)
+gboolean bluetooth_client_remove_bonding(BluetoothClient *client,
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
GtkTreeIter iter;
@@ -1224,8 +1400,14 @@ gboolean bluetooth_client_set_trusted(Bl
COLUMN_OBJECT, &object, -1);
if (g_ascii_strcasecmp(path, adapter) == 0) {
- adapter_set_trusted_async(object, address,
- set_trusted_reply, NULL);
+ DBusGProxyCall *call;
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ call = adapter_remove_bonding_async(object, address,
+ call_reply, stuff);
+ g_object_set_data(G_OBJECT(object), "call", call);
return TRUE;
}
@@ -1235,14 +1417,53 @@ gboolean bluetooth_client_set_trusted(Bl
return FALSE;
}
-static void remove_trust_reply(DBusGProxy *proxy,
- GError *error, gpointer userdata)
+gboolean bluetooth_client_set_trusted(BluetoothClient *client,
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
{
- //g_printf("remove trust reply\n");
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ GtkTreeIter iter;
+ gboolean cont;
+
+ if (adapter == NULL)
+ adapter = priv->default_adapter;
+
+ if (adapter == NULL)
+ return FALSE;
+
+ cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store), &iter);
+
+ while (cont == TRUE) {
+ DBusGProxy *object;
+ gchar *path;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+ COLUMN_PATH, &path,
+ COLUMN_OBJECT, &object, -1);
+
+ if (g_ascii_strcasecmp(path, adapter) == 0) {
+ DBusGProxyCall *call;
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ call = adapter_set_trusted_async(object, address,
+ call_reply, stuff);
+ g_object_set_data(G_OBJECT(object), "call", call);
+ return TRUE;
+ }
+
+ cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
+ }
+
+ return FALSE;
}
gboolean bluetooth_client_remove_trust(BluetoothClient *client,
- gchar *adapter, const gchar *address)
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
GtkTreeIter iter;
@@ -1265,8 +1486,14 @@ gboolean bluetooth_client_remove_trust(B
COLUMN_OBJECT, &object, -1);
if (g_ascii_strcasecmp(path, adapter) == 0) {
- adapter_remove_trust_async(object, address,
- remove_trust_reply, NULL);
+ DBusGProxyCall *call;
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ call = adapter_remove_trust_async(object, address,
+ call_reply, stuff);
+ g_object_set_data(G_OBJECT(object), "call", call);
return TRUE;
}
diff -rupN bluez-gnome-0.27.orig/common/client.h bluez-gnome-0.27/common/client.h
--- bluez-gnome-0.27.orig/common/client.h 2008-06-27 14:12:49.000000000 -0400
+++ bluez-gnome-0.27/common/client.h 2008-06-27 14:13:05.000000000 -0400
@@ -99,14 +99,34 @@ const gchar *bluetooth_type_to_string(gu
gboolean bluetooth_client_register_passkey_agent(BluetoothClient *self,
const char *path, const char *address, const void *info);
-gboolean bluetooth_client_create_bonding(BluetoothClient *self,
+typedef void (*bluetooth_client_call_reply) (GError *error, gpointer data);
+
+int bluetooth_client_available_services(BluetoothClient *self);
+
+gboolean bluetooth_client_cancel_call(BluetoothClient *self,
gchar *adapter, const gchar *address);
+gboolean bluetooth_client_connect(BluetoothClient *self, guint type, // set to non-ANY to force a certain type connection -- useful for dumb devices
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
+gboolean bluetooth_client_create_bonding(BluetoothClient *self,
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
gboolean bluetooth_client_remove_bonding(BluetoothClient *self,
- gchar *adapter, const gchar *address);
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
gboolean bluetooth_client_set_trusted(BluetoothClient *self,
- gchar *adapter, const gchar *address);
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
gboolean bluetooth_client_remove_trust(BluetoothClient *self,
- gchar *adapter, const gchar *address);
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
+
+const gchar *bluetooth_client_get_name(BluetoothClient *self, const gchar *adapter);
gboolean bluetooth_client_disconnect(BluetoothClient *self,
gchar *adapter, const gchar *address);
diff -rupN bluez-gnome-0.27.orig/common/dbus.xml bluez-gnome-0.27/common/dbus.xml
--- bluez-gnome-0.27.orig/common/dbus.xml 2008-06-27 14:12:49.000000000 -0400
+++ bluez-gnome-0.27/common/dbus.xml 2008-06-27 14:13:05.000000000 -0400
@@ -98,4 +98,20 @@
<arg type="s" name="address"/>
</method>
</interface>
+
+ <interface name="input">
+ <method name="CreateSecureDevice">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="s" name="address"/>
+ <arg type="s" direction="out"/>
+ </method>
+ </interface>
+
+ <interface name="audio">
+ <method name="CreateHeadset">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="s" name="address"/>
+ <arg type="s" direction="out"/>
+ </method>
+ </interface>
</node>
diff -rupN bluez-gnome-0.27.orig/properties/adapter.c bluez-gnome-0.27/properties/adapter.c
--- bluez-gnome-0.27.orig/properties/adapter.c 2008-06-27 14:12:49.000000000 -0400
+++ bluez-gnome-0.27/properties/adapter.c 2008-06-27 14:13:05.000000000 -0400
@@ -317,7 +317,7 @@ static void delete_callback(GtkWidget *b
gtk_tree_model_get(model, &iter, COLUMN_ADDRESS, &address, -1);
if (show_confirm_dialog() == TRUE)
- bluetooth_client_remove_bonding(client, adapter->path, address);
+ bluetooth_client_remove_bonding(client, adapter->path, address, NULL, NULL);
g_free(address);
}
@@ -338,9 +338,9 @@ static void trusted_callback(GtkWidget *
COLUMN_TRUSTED, &trusted, -1);
if (trusted == FALSE)
- bluetooth_client_set_trusted(client, adapter->path, address);
+ bluetooth_client_set_trusted(client, adapter->path, address, NULL, NULL);
else
- bluetooth_client_remove_trust(client, adapter->path, address);
+ bluetooth_client_remove_trust(client, adapter->path, address, NULL, NULL);
g_free(address);
}
diff -rupN bluez-gnome-0.27.orig/wizard/agent.c bluez-gnome-0.27/wizard/agent.c
--- bluez-gnome-0.27.orig/wizard/agent.c 1969-12-31 19:00:00.000000000 -0500
+++ bluez-gnome-0.27/wizard/agent.c 2008-06-27 14:13:05.000000000 -0400
@@ -0,0 +1,504 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2005-2008 Marcel Holtmann <marcel@holtmann.org>
+ * Copyright (C) 2006-2007 Bastien Nocera <hadess@hadess.net>
+ *
+ *
+ * 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 <dbus/dbus-glib.h>
+
+#include <glib/gi18n.h>
+
+#include <gtk/gtk.h>
+
+#include "agent.h"
+
+#define PASSKEY_AGENT_PATH "/org/bluez/passkey"
+
+static GtkWidget *main_dialog;
+
+typedef enum {
+ AGENT_ERROR_REJECT
+} AgentError;
+
+#define AGENT_ERROR (agent_error_quark())
+
+#define AGENT_ERROR_TYPE (agent_error_get_type())
+
+static GQuark agent_error_quark(void)
+{
+ static GQuark quark = 0;
+ if (!quark)
+ quark = g_quark_from_static_string("agent");
+
+ return quark;
+}
+
+#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
+
+static GList *input_list = NULL;
+
+struct input_data {
+ char *path;
+ char *address;
+ char *service;
+ char *uuid;
+ DBusGMethodInvocation *context;
+ GtkWidget *dialog;
+ GtkWidget *button;
+ GtkWidget *entry;
+};
+
+static gint input_compare(gconstpointer a, gconstpointer b)
+{
+ struct input_data *a_data = (struct input_data *) a;
+ struct input_data *b_data = (struct input_data *) b;
+
+ return g_ascii_strcasecmp(a_data->address, b_data->address);
+}
+
+static void input_free(struct input_data *input)
+{
+ gtk_widget_destroy(input->dialog);
+
+ g_free(input->uuid);
+ g_free(input->service);
+ g_free(input->address);
+ g_free(input->path);
+ g_free(input);
+}
+
+static void passkey_callback(GtkWidget *dialog,
+ gint response, gpointer user_data)
+{
+ struct input_data *input = user_data;
+
+ if (response == GTK_RESPONSE_ACCEPT) {
+ const char *passkey;
+ passkey = gtk_entry_get_text(GTK_ENTRY(input->entry));
+ dbus_g_method_return(input->context, passkey);
+ } else {
+ GError *error;
+ error = g_error_new(AGENT_ERROR, AGENT_ERROR_REJECT,
+ "Pairing request rejected");
+ dbus_g_method_return_error(input->context, error);
+ }
+
+ input_free(input);
+}
+
+static void changed_callback(GtkWidget *editable, gpointer user_data)
+{
+ struct input_data *input = user_data;
+ const gchar *text;
+
+ text = gtk_entry_get_text(GTK_ENTRY(input->entry));
+
+ gtk_widget_set_sensitive(input->button, *text != '\0' ? TRUE : FALSE);
+}
+
+static void toggled_callback(GtkWidget *button, gpointer user_data)
+{
+ struct input_data *input = user_data;
+ gboolean mode;
+
+ mode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
+
+ gtk_entry_set_visibility(GTK_ENTRY(input->entry), mode);
+}
+
+static void passkey_dialog(const char *path, const char *address,
+ const gchar *device, DBusGMethodInvocation *context)
+{
+ GtkWidget *dialog;
+ GtkWidget *button;
+ GtkWidget *image;
+ GtkWidget *label;
+ GtkWidget *entry;
+ GtkWidget *table;
+ GtkWidget *vbox;
+ struct input_data *input;
+ gchar *markup;
+
+ input = g_try_malloc0(sizeof(*input));
+ if (!input)
+ return;
+
+ input->path = g_strdup(path);
+ input->address = g_strdup(address);
+
+ input->context = context;
+
+ dialog = gtk_dialog_new();
+
+ gtk_window_set_title(GTK_WINDOW(dialog), _("Authentication request"));
+
+ gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
+
+ gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
+
+ gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
+
+ gtk_window_set_urgency_hint(GTK_WINDOW(dialog), TRUE);
+
+ gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
+
+ gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(main_dialog));
+
+ input->dialog = dialog;
+
+ button = gtk_dialog_add_button(GTK_DIALOG(dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
+
+ button = gtk_dialog_add_button(GTK_DIALOG(dialog),
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT);
+
+ gtk_widget_grab_default(button);
+
+ gtk_widget_set_sensitive(button, FALSE);
+
+ input->button = button;
+
+ table = gtk_table_new(5, 2, FALSE);
+
+ gtk_table_set_row_spacings(GTK_TABLE(table), 4);
+ gtk_table_set_col_spacings(GTK_TABLE(table), 20);
+
+ gtk_container_set_border_width(GTK_CONTAINER(table), 12);
+
+ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
+
+ image = gtk_image_new_from_icon_name(GTK_STOCK_DIALOG_AUTHENTICATION,
+ GTK_ICON_SIZE_DIALOG);
+
+ gtk_misc_set_alignment(GTK_MISC(image), 0.0, 0.0);
+
+ gtk_table_attach(GTK_TABLE(table), image, 0, 1, 0, 5,
+ GTK_SHRINK, GTK_FILL, 0, 0);
+
+ vbox = gtk_vbox_new(FALSE, 6);
+
+ label = gtk_label_new(_("Pairing request for device:"));
+
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+
+ gtk_container_add(GTK_CONTAINER(vbox), label);
+
+ gtk_table_attach(GTK_TABLE(table), vbox, 1, 2, 0, 1,
+ GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+
+ label = gtk_label_new(NULL);
+
+ markup = g_strdup_printf("<b>%s</b>", device);
+ gtk_label_set_markup(GTK_LABEL(label), markup);
+ g_free(markup);
+
+ gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
+
+ gtk_label_set_selectable(GTK_LABEL(label), TRUE);
+
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+
+ gtk_widget_set_size_request(GTK_WIDGET(label), 280, -1);
+
+ gtk_container_add(GTK_CONTAINER(vbox), label);
+
+ vbox = gtk_vbox_new(FALSE, 6);
+
+ label = gtk_label_new(_("Enter passkey for authentication:"));
+
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+
+ gtk_container_add(GTK_CONTAINER(vbox), label);
+
+ gtk_table_attach(GTK_TABLE(table), vbox, 1, 2, 2, 3,
+ GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+
+ entry = gtk_entry_new();
+
+ gtk_entry_set_max_length(GTK_ENTRY(entry), 16);
+
+ gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
+
+ gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
+
+ input->entry = entry;
+
+ g_signal_connect(G_OBJECT(entry), "changed",
+ G_CALLBACK(changed_callback), input);
+
+ gtk_container_add(GTK_CONTAINER(vbox), entry);
+
+ button = gtk_check_button_new_with_label(_("Show input"));
+
+ g_signal_connect(G_OBJECT(button), "toggled",
+ G_CALLBACK(toggled_callback), input);
+
+ gtk_container_add(GTK_CONTAINER(vbox), button);
+
+ input_list = g_list_append(input_list, input);
+ gtk_widget_show_all(dialog);
+ gtk_window_present(GTK_WINDOW(dialog));
+
+ g_signal_connect(G_OBJECT(dialog), "response",
+ G_CALLBACK(passkey_callback), input);
+}
+
+static void confirm_callback(GtkWidget *dialog,
+ gint response, gpointer user_data)
+{
+ struct input_data *input = user_data;
+
+ if (response != GTK_RESPONSE_YES) {
+ GError *error;
+ error = g_error_new(AGENT_ERROR, AGENT_ERROR_REJECT,
+ "Confirmation request rejected");
+ dbus_g_method_return_error(input->context, error);
+ } else
+ dbus_g_method_return(input->context);
+
+ input_free(input);
+}
+
+static void confirm_dialog(const char *path, const char *address,
+ const char *value, const gchar *device,
+ DBusGMethodInvocation *context)
+{
+ GtkWidget *dialog;
+ GtkWidget *button;
+ GtkWidget *image;
+ GtkWidget *label;
+ GtkWidget *table;
+ GtkWidget *vbox;
+ gchar *markup;
+ struct input_data *input;
+
+ input = g_try_malloc0(sizeof(*input));
+ if (!input)
+ return;
+
+ input->path = g_strdup(path);
+ input->address = g_strdup(address);
+
+ input->context = context;
+
+ dialog = gtk_dialog_new();
+
+ gtk_window_set_title(GTK_WINDOW(dialog), _("Confirmation request"));
+
+ gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
+
+ gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
+
+ gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
+
+ gtk_window_set_urgency_hint(GTK_WINDOW(dialog), TRUE);
+
+ gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
+
+ gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(main_dialog));
+
+ input->dialog = dialog;
+
+ button = gtk_dialog_add_button(GTK_DIALOG(dialog),
+ GTK_STOCK_NO, GTK_RESPONSE_NO);
+
+ button = gtk_dialog_add_button(GTK_DIALOG(dialog),
+ GTK_STOCK_YES, GTK_RESPONSE_YES);
+
+ table = gtk_table_new(5, 2, FALSE);
+
+ gtk_table_set_row_spacings(GTK_TABLE(table), 4);
+ gtk_table_set_col_spacings(GTK_TABLE(table), 20);
+
+ gtk_container_set_border_width(GTK_CONTAINER(table), 12);
+
+ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
+
+ image = gtk_image_new_from_icon_name(GTK_STOCK_DIALOG_AUTHENTICATION,
+ GTK_ICON_SIZE_DIALOG);
+
+ gtk_misc_set_alignment(GTK_MISC(image), 0.0, 0.0);
+
+ gtk_table_attach(GTK_TABLE(table), image, 0, 1, 0, 5,
+ GTK_SHRINK, GTK_FILL, 0, 0);
+
+ vbox = gtk_vbox_new(FALSE, 6);
+ label = gtk_label_new(_("Pairing request for device:"));
+
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+
+ gtk_container_add(GTK_CONTAINER(vbox), label);
+
+ gtk_table_attach(GTK_TABLE(table), vbox, 1, 2, 0, 1,
+ GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+
+ label = gtk_label_new(NULL);
+
+ markup = g_strdup_printf("<b>%s</b>", device);
+ gtk_label_set_markup(GTK_LABEL(label), markup);
+ g_free(markup);
+
+ gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
+
+ gtk_label_set_selectable(GTK_LABEL(label), TRUE);
+
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+
+ gtk_widget_set_size_request(GTK_WIDGET(label), 280, -1);
+
+ gtk_container_add(GTK_CONTAINER(vbox), label);
+
+ vbox = gtk_vbox_new(FALSE, 6);
+
+ label = gtk_label_new(_("Confirm value for authentication:"));
+
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+
+ gtk_container_add(GTK_CONTAINER(vbox), label);
+
+ gtk_table_attach(GTK_TABLE(table), vbox, 1, 2, 2, 3,
+ GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+
+ label = gtk_label_new(NULL);
+
+ markup = g_strdup_printf("<b>%s</b>\n", value);
+
+ gtk_label_set_markup(GTK_LABEL(label), markup);
+
+ g_free(markup);
+
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+
+ gtk_container_add(GTK_CONTAINER(vbox), label);
+
+ input_list = g_list_append(input_list, input);
+ gtk_widget_show_all(dialog);
+ gtk_window_present(GTK_WINDOW(dialog));
+
+ g_signal_connect(G_OBJECT(dialog), "response",
+ G_CALLBACK(confirm_callback), input);
+}
+
+static gboolean passkey_agent_request(GObject *agent,
+ const char *path, const char *address,
+ DBusGMethodInvocation *context)
+{
+ BluetoothClient *client = BLUETOOTH_CLIENT(agent);
+ const char *name = NULL;
+ gchar *device;
+
+ name = bluetooth_client_get_name(client, path);
+
+ if (name) {
+ if (g_strrstr(name, address))
+ device = g_strdup(name);
+ else
+ device = g_strdup_printf("%s (%s)", name, address);
+ } else
+ device = g_strdup(address);
+
+ passkey_dialog(path, address, device, context);
+
+ g_free(device);
+ return TRUE;
+}
+
+static gboolean passkey_agent_confirm(GObject *agent,
+ const char *path, const char *address,
+ const char *value, DBusGMethodInvocation *context)
+{
+ BluetoothClient *client = BLUETOOTH_CLIENT(agent);
+ const char *name = NULL;
+ gchar *device;
+
+ name = bluetooth_client_get_name(client, path);
+
+ if (name) {
+ if (g_strrstr(name, address))
+ device = g_strdup(name);
+ else
+ device = g_strdup_printf("%s (%s)", name, address);
+ } else
+ device = g_strdup(address);
+
+ confirm_dialog(path, address, value, device, context);
+
+ g_free(device);
+ return TRUE;
+}
+
+static gboolean passkey_agent_cancel(GObject *agent,
+ const char *path, const char *address, GError **error)
+{
+ GList *list;
+ GError *result;
+ struct input_data *input;
+
+ input = g_try_malloc0(sizeof(*input));
+ if (!input)
+ return FALSE;
+
+ input->path = g_strdup(path);
+ input->address = g_strdup(address);
+
+ list = g_list_find_custom(input_list, input, input_compare);
+
+ g_free(input->address);
+ g_free(input->path);
+ g_free(input);
+
+ if (!list || !list->data)
+ return FALSE;
+
+ input = list->data;
+
+ result = g_error_new(AGENT_ERROR, AGENT_ERROR_REJECT,
+ "Agent callback canceled");
+
+ dbus_g_method_return_error(input->context, result);
+
+ input_free(input);
+
+ return TRUE;
+}
+
+static gboolean passkey_agent_release(GObject *agent, GError **error)
+{
+ return TRUE;
+}
+
+#include "passkey-agent-glue.h"
+
+void set_agent_parent_window(GtkWidget *window)
+{
+ main_dialog = window;
+}
+
+gboolean register_agent(BluetoothClient *client,
+ const char *path, const char *address)
+{
+ return bluetooth_client_register_passkey_agent(client, path, address, &dbus_glib_passkey_agent_object_info);
+}
+
diff -rupN bluez-gnome-0.27.orig/wizard/agent.h bluez-gnome-0.27/wizard/agent.h
--- bluez-gnome-0.27.orig/wizard/agent.h 1969-12-31 19:00:00.000000000 -0500
+++ bluez-gnome-0.27/wizard/agent.h 2008-06-27 14:13:05.000000000 -0400
@@ -0,0 +1,30 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2005-2008 Marcel Holtmann <marcel@holtmann.org>
+ * Copyright (C) 2006-2007 Bastien Nocera <hadess@hadess.net>
+ *
+ *
+ * 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
+ *
+ */
+
+#include <gtk/gtk.h>
+#include "client.h"
+
+void set_agent_parent_window(GtkWidget *window);
+int register_agent(BluetoothClient *client, const char *path, const char *address);
+
diff -rupN bluez-gnome-0.27.orig/wizard/main.c bluez-gnome-0.27/wizard/main.c
--- bluez-gnome-0.27.orig/wizard/main.c 2008-06-27 14:12:49.000000000 -0400
+++ bluez-gnome-0.27/wizard/main.c 2008-06-27 14:21:41.000000000 -0400
@@ -32,6 +32,7 @@
#include <gtk/gtk.h>
#include "client.h"
+#include "agent.h"
#include "dbus-glue.h"
@@ -41,93 +42,141 @@
static gboolean singleton = FALSE;
static BluetoothClient *client;
+static DBusGProxyCall *call = NULL;
static gchar *address = NULL;
-static gchar *passkey = "123456";
+static GtkWidget *page_prev = NULL;
static GtkWidget *page_search = NULL;
-static GtkWidget *page_info = NULL;
static GtkWidget *page_pairing = NULL;
+static GtkWidget *page_info = NULL;
static GtkWidget *page_summary = NULL;
+static int page_summary_num = 0;
-static GtkWidget *label_pairing = NULL;
-static GtkWidget *label_passkey = NULL;
+static GtkWidget *pairing_progress = NULL;
+static guint pairing_progress_timeout = 0;
+static GtkWidget *pairing_message = NULL;
+static GSList *type_group = NULL;
static GtkWidget *selector = NULL;
-static gboolean passkey_agent_request(GObject *agent,
- const char *path, const char *address,
- DBusGMethodInvocation *context)
-{
- const char *value = passkey;
-
- /* Apple Wireless and Mighty Mouse */
- if (g_str_has_prefix(address, "00:0A:95:") == TRUE ||
- g_str_has_prefix(address, "00:14:51:") == TRUE)
- value = "0000";
-
- dbus_g_method_return(context, value);
+static void close_callback(GtkWidget *assistant, gpointer data)
+{
+ gtk_widget_destroy(assistant);
- return TRUE;
+ gtk_main_quit();
}
-static gboolean passkey_agent_cancel(GObject *agent,
- const char *path, const char *address, GError **error)
+static void cancel_callback(GtkWidget *assistant, gpointer data)
{
- return TRUE;
+ gtk_widget_destroy(assistant);
+
+ gtk_main_quit();
}
-static gboolean passkey_agent_release(GObject *agent, GError **error)
+static gint selected_type(void)
{
- return TRUE;
+ GSList *iter;
+ for (iter = type_group; iter; iter = iter->next) {
+ GtkToggleButton *button = GTK_TOGGLE_BUTTON(iter->data);
+ if (gtk_toggle_button_get_active(button)) {
+ gpointer data = g_object_get_data(G_OBJECT(button), "bluez-type");
+ return GPOINTER_TO_INT(data);
+ }
+ }
+ return BLUETOOTH_TYPE_ANY;
}
+
+static void show_pairing_error(GError *error)
+{
+ gchar *msg;
+ const gchar *errmsg;
+
+ gtk_widget_hide(pairing_progress);
+ if (pairing_progress_timeout > 0) {
+ g_source_remove(pairing_progress_timeout);
+ pairing_progress_timeout = 0;
+ }
-#include "passkey-agent-glue.h"
+ if (!error)
+ errmsg = _("Could not contact bluetooth service");
+ else
+ errmsg = error->message;
-#if 0
-static gint page_forward(gint current_page, gpointer data)
-{
- return current_page + 1;
+ msg = g_strdup_printf("<b>%s</b>\n\n%s", _("Cannot connect to device:"), errmsg);
+ gtk_label_set_markup(GTK_LABEL(pairing_message), msg);
+ gtk_widget_show(pairing_message);
+ g_free(msg);
}
-#endif
-static void close_callback(GtkWidget *assistant, gpointer data)
+static void trusted_callback(GError *error, gpointer data)
{
- gtk_widget_destroy(assistant);
+ GtkAssistant *assistant = GTK_ASSISTANT(data);
- gtk_main_quit();
+ gtk_widget_hide(pairing_progress);
+ if (pairing_progress_timeout > 0) {
+ g_source_remove(pairing_progress_timeout);
+ pairing_progress_timeout = 0;
+ }
+
+ if (error) {
+ show_pairing_error(error);
+ }
+ else {
+ gtk_assistant_set_page_complete(assistant, page_pairing, TRUE);
+ gtk_assistant_set_current_page(assistant, page_summary_num); // jump to summary
+ }
}
-static void cancel_callback(GtkWidget *assistant, gpointer data)
+static void connect_callback(GError *error, gpointer data)
{
- gtk_widget_destroy(assistant);
+ if (error ||
+ !bluetooth_client_set_trusted(client, NULL, address, trusted_callback, data))
+ show_pairing_error(error);
+}
- gtk_main_quit();
+static gboolean pulse_progress(gpointer data)
+{
+ gtk_progress_bar_pulse(GTK_PROGRESS_BAR(pairing_progress));
+ return TRUE;
}
static void prepare_callback(GtkWidget *assistant,
GtkWidget *page, gpointer data)
{
+ gboolean complete = TRUE;
+
if (page == page_search) {
+ gint type = selected_type();
+ g_object_set(G_OBJECT(selector), "device-type-filter", type, NULL);
bluetooth_device_selection_start_discovery(BLUETOOTH_DEVICE_SELECTION(selector));
- return;
+ if (address)
+ bluetooth_client_cancel_call(client, NULL, address);
+ complete = address != NULL;
}
-
- if (page == page_pairing) {
+ else if (page == page_pairing) {
bluetooth_client_cancel_discovery(client, NULL);
- bluetooth_client_register_passkey_agent(client,
- "/org/bluez/applet", address,
- &dbus_glib_passkey_agent_object_info);
-
- bluetooth_client_create_bonding(client, NULL, address);
-
- gtk_label_set_markup(GTK_LABEL(label_pairing), address);
- gtk_label_set_markup(GTK_LABEL(label_passkey), passkey);
- return;
+ register_agent(client, "/org/bluez/applet", address);
+
+ if (page_prev == page_search) {
+ pairing_progress_timeout = g_timeout_add(100, pulse_progress, pairing_progress);
+ gtk_widget_show(pairing_progress);
+ gtk_widget_hide(pairing_message);
+ complete = FALSE;
+ if (!bluetooth_client_connect(client, selected_type(), NULL, address,
+ connect_callback, assistant))
+ show_pairing_error(NULL);
+ }
+ }
+
+ if (page != page_pairing && pairing_progress_timeout > 0) {
+ g_source_remove(pairing_progress_timeout);
+ pairing_progress_timeout = 0;
}
- gtk_assistant_set_page_complete(GTK_ASSISTANT(assistant), page, TRUE);
+ gtk_assistant_set_page_complete(GTK_ASSISTANT(assistant), page, complete);
+ page_prev = page;
}
static GtkWidget *create_vbox(GtkWidget *assistant, GtkAssistantPageType type,
@@ -238,55 +287,39 @@ static void create_type(GtkWidget *assis
vbox = create_vbox(assistant, GTK_ASSISTANT_PAGE_CONTENT,
_("Device type"),
- _("Select the type of device you want to setup"));
-
- button = gtk_radio_button_new_with_label(group, _("Mouse"));
-
- group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
- //gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
+ _("Select the type of device you want to connect"));
+ button = gtk_radio_button_new_with_label(NULL, _("Mouse"));
+ g_object_set_data(G_OBJECT(button),
+ "bluez-type", GINT_TO_POINTER(BLUETOOTH_TYPE_MOUSE));
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
- button = gtk_radio_button_new_with_label(group, _("Keyboard"));
-
- group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
- //gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
-
+ button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), _("Keyboard"));
+ g_object_set_data(G_OBJECT(button),
+ "bluez-type", GINT_TO_POINTER(BLUETOOTH_TYPE_KEYBOARD));
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
- button = gtk_radio_button_new_with_label(group, _("Mobile phone"));
-
- group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
- gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
-
+#if 0
+ button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), _("Mobile phone"));
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
- button = gtk_radio_button_new_with_label(group, _("Printer"));
-
- group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
- gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
-
+ button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), _("Printer"));
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
+#endif
- button = gtk_radio_button_new_with_label(group, _("Headset"));
-
- group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
- gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
-
+ button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), _("Headset"));
+ g_object_set_data(G_OBJECT(button),
+ "bluez-type", GINT_TO_POINTER(BLUETOOTH_TYPE_HEADSET));
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
- button = gtk_radio_button_new_with_label(group, _("Any device"));
-
- group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
-
+#if 0
+ button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), _("Any device"));
+ g_object_set_data(G_OBJECT(button),
+ "bluez-type", GINT_TO_POINTER(BLUETOOTH_TYPE_ANY));
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
+#endif
+
+ type_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
}
static void select_callback(BluetoothDeviceSelection *sel,
@@ -310,7 +343,7 @@ static void create_search(GtkWidget *ass
vbox = create_vbox(assistant, GTK_ASSISTANT_PAGE_CONTENT,
_("Device search"),
- _("Select the device you want to setup"));
+ _("Select the device you want to connect"));
selector = bluetooth_device_selection_new(NULL);
@@ -349,26 +382,27 @@ static void create_pairing(GtkWidget *as
{
GtkWidget *vbox;
GtkWidget *label;
+ GtkWidget *progress;
vbox = create_vbox(assistant, GTK_ASSISTANT_PAGE_CONTENT,
- _("Device pairing"),
- _("Pairing with new device"));
-
- label = gtk_label_new(NULL);
+ _("Device connection"),
+ _("Connecting with new device"));
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
+ progress = gtk_progress_bar_new();
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), progress, FALSE, TRUE, 0);
- label_pairing = label;
+ pairing_progress = progress;
label = gtk_label_new(NULL);
+ gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
+ gtk_label_set_selectable(GTK_LABEL(label), TRUE);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
- label_passkey = label;
+ pairing_message = label;
page_pairing = vbox;
}
@@ -381,6 +415,8 @@ static void create_summary(GtkWidget *as
_("Summary"),
_("Succesfully configured new device"));
+ page_summary_num = gtk_assistant_get_n_pages(GTK_ASSISTANT(assistant)) - 1;
+
page_summary = vbox;
}
@@ -401,13 +437,13 @@ static GtkWidget *create_wizard(void)
page_forward, NULL, NULL);
#endif
- create_intro(assistant);
+ /*create_intro(assistant);*/
create_type(assistant);
create_search(assistant);
- create_info(assistant);
+ /*create_info(assistant);*/
create_pairing(assistant);
@@ -465,6 +501,7 @@ int main(int argc, char *argv[])
client = bluetooth_client_new();
window = create_wizard();
+ set_agent_parent_window(window);
bluetooth_instance_set_window(instance, GTK_WINDOW(window));
diff -rupN bluez-gnome-0.27.orig/wizard/Makefile.am bluez-gnome-0.27/wizard/Makefile.am
--- bluez-gnome-0.27.orig/wizard/Makefile.am 2008-06-27 14:12:49.000000000 -0400
+++ bluez-gnome-0.27/wizard/Makefile.am 2008-06-27 14:13:05.000000000 -0400
@@ -1,7 +1,7 @@
noinst_PROGRAMS = bluetooth-wizard
-bluetooth_wizard_SOURCES = main.c
+bluetooth_wizard_SOURCES = main.c agent.c agent.h
bluetooth_wizard_LDADD = @GTK_LIBS@ @DBUS_LIBS@ \
$(top_builddir)/common/libcommon.a
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 247 bytes --]
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
[-- Attachment #3: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-27 19:05 [Bluez-devel] Wizard patch Michael Terry
@ 2008-06-27 19:18 ` Michael Terry
2008-06-27 19:38 ` David Stockwell
` (2 subsequent siblings)
3 siblings, 0 replies; 30+ messages in thread
From: Michael Terry @ 2008-06-27 19:18 UTC (permalink / raw)
To: BlueZ development
[-- Attachment #1.1.1: Type: text/plain, Size: 72 bytes --]
Whoops, here's a fixed patch that actually installs the binary.
-mt
[-- Attachment #1.1.2: Type: text/x-patch, Size: 47144 bytes --]
diff -rupN bluez-gnome-0.27.orig/applet/main.c bluez-gnome-0.27/applet/main.c
--- bluez-gnome-0.27.orig/applet/main.c 2008-06-27 14:12:49.000000000 -0400
+++ bluez-gnome-0.27/applet/main.c 2008-06-27 14:13:05.000000000 -0400
@@ -625,7 +625,6 @@ static void sendto_callback(GObject *wid
g_printerr("Couldn't execute command: %s\n", command);
}
-#if 0
static void wizard_callback(GObject *widget, gpointer user_data)
{
const char *command = "bluetooth-wizard --singleton";
@@ -633,7 +632,6 @@ static void wizard_callback(GObject *wid
if (!g_spawn_command_line_async(command, NULL))
g_printerr("Couldn't execute command: %s\n", command);
}
-#endif
static void activate_callback(GObject *widget, gpointer user_data)
{
@@ -697,17 +695,15 @@ static GtkWidget *create_popupmenu(void)
menuitem_browse = item;
-#if 0
item = gtk_separator_menu_item_new();
gtk_widget_show(item);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
- item = gtk_menu_item_new_with_label(_("Setup New Device"));
+ item = gtk_menu_item_new_with_label(_("Connect New Device..."));
g_signal_connect(item, "activate",
G_CALLBACK(wizard_callback), NULL);
gtk_widget_show(item);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-#endif
return menu;
}
diff -rupN bluez-gnome-0.27.orig/common/bluetooth-device-selection.c bluez-gnome-0.27/common/bluetooth-device-selection.c
--- bluez-gnome-0.27.orig/common/bluetooth-device-selection.c 2008-06-27 14:12:49.000000000 -0400
+++ bluez-gnome-0.27/common/bluetooth-device-selection.c 2008-06-27 14:13:05.000000000 -0400
@@ -90,6 +90,15 @@ bluetooth_device_category_to_string (int
}
}
+static int
+int_log2(int v)
+{
+ unsigned rv = 0;
+ while (v >>= 1)
+ rv++;
+ return rv;
+}
+
static void
name_to_text (GtkTreeViewColumn *column, GtkCellRenderer *cell,
GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
@@ -591,7 +600,7 @@ bluetooth_device_selection_init(Bluetoot
}
g_signal_connect (G_OBJECT (priv->device_type), "changed",
G_CALLBACK(filter_type_changed_cb), self);
- gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), priv->device_type_filter);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), int_log2(priv->device_type_filter));
if (priv->show_device_type) {
gtk_widget_show (priv->device_type_label);
gtk_widget_show (priv->device_type);
@@ -665,7 +674,7 @@ bluetooth_device_selection_set_property
break;
case PROP_DEVICE_TYPE_FILTER:
priv->device_type_filter = g_value_get_int (value);
- gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), priv->device_type_filter >> 1);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), int_log2(priv->device_type_filter));
break;
case PROP_DEVICE_CATEGORY_FILTER:
priv->device_category_filter = g_value_get_int (value);
@@ -751,7 +760,7 @@ bluetooth_device_selection_class_init (B
NULL, NULL, TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS(klass),
PROP_DEVICE_TYPE_FILTER, g_param_spec_int ("device-type-filter", NULL, NULL,
- 0, BLUETOOTH_TYPE_NUM_TYPES, 0, G_PARAM_READWRITE));
+ 1, 1 << (BLUETOOTH_TYPE_NUM_TYPES-1), 1, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS(klass),
PROP_DEVICE_CATEGORY_FILTER, g_param_spec_int ("device-category-filter", NULL, NULL,
0, BLUETOOTH_CATEGORY_NUM_CATEGORIES, 0, G_PARAM_READWRITE));
diff -rupN bluez-gnome-0.27.orig/common/client.c bluez-gnome-0.27/common/client.c
--- bluez-gnome-0.27.orig/common/client.c 2008-06-27 14:12:49.000000000 -0400
+++ bluez-gnome-0.27/common/client.c 2008-06-27 14:13:05.000000000 -0400
@@ -48,6 +48,8 @@ struct _BluetoothClientPrivate {
DBusGConnection *conn;
DBusGProxy *manager_object;
+ DBusGProxy *input_service;
+ DBusGProxy *audio_service;
GtkTreeStore *store;
gchar *default_adapter;
};
@@ -935,6 +937,33 @@ static void setup_manager(BluetoothClien
g_error_free(error);
}
+static void setup_services(BluetoothClient *client)
+{
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ gchar *busname = NULL;
+
+ priv->input_service = NULL;
+ priv->audio_service = NULL;
+
+ if (dbus_g_proxy_call(priv->manager_object, "ActivateService", NULL,
+ G_TYPE_STRING, "input", G_TYPE_INVALID,
+ G_TYPE_STRING, &busname, G_TYPE_INVALID)) {
+ priv->input_service = dbus_g_proxy_new_for_name(priv->conn, busname,
+ "/org/bluez/input",
+ "org.bluez.input.Manager");
+ g_free(busname);
+ }
+
+ if (dbus_g_proxy_call(priv->manager_object, "ActivateService", NULL,
+ G_TYPE_STRING, "audio", G_TYPE_INVALID,
+ G_TYPE_STRING, &busname, G_TYPE_INVALID)) {
+ priv->audio_service = dbus_g_proxy_new_for_name(priv->conn, busname,
+ "/org/bluez/audio",
+ "org.bluez.audio.Manager");
+ g_free(busname);
+ }
+}
+
static void name_owner_changed(DBusGProxy *object, const char *name,
const char *prev, const char *new, gpointer user_data)
{
@@ -984,6 +1013,8 @@ static void bluetooth_client_finalize(GO
g_free(priv->default_adapter);
g_object_unref(G_OBJECT(priv->store));
g_object_unref (priv->manager_object);
+ g_object_unref (priv->input_service);
+ g_object_unref (priv->audio_service);
}
static void bluetooth_client_init(BluetoothClient *client)
@@ -1000,6 +1031,8 @@ static void bluetooth_client_init(Blueto
setup_dbus(client);
setup_manager(client);
+
+ setup_services(client);
}
static void bluetooth_client_set_property(GObject *object, guint prop_id,
@@ -1085,6 +1118,50 @@ BluetoothClient *bluetooth_client_new(vo
}
}
+const gchar *bluetooth_client_get_name(BluetoothClient *self, const gchar *adapter)
+{
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(self);
+ GtkTreeIter iter;
+ gboolean cont;
+
+ if (adapter == NULL)
+ adapter = priv->default_adapter;
+
+ if (adapter == NULL)
+ return FALSE;
+
+ cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store), &iter);
+
+ while (cont == TRUE) {
+ gchar *path;
+ gchar *name;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+ COLUMN_PATH, &path,
+ COLUMN_NAME, &name, -1);
+
+ if (g_ascii_strcasecmp(path, adapter) == 0)
+ return g_strdup(name);
+
+ cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
+ }
+
+ return NULL;
+}
+
+int bluetooth_client_available_services(BluetoothClient *client)
+{
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ int rv = 0;
+
+ if (priv->input_service)
+ rv |= BLUETOOTH_TYPE_MOUSE | BLUETOOTH_TYPE_KEYBOARD;
+ if (priv->audio_service)
+ rv |= BLUETOOTH_TYPE_HEADSET;
+
+ return rv;
+}
+
gboolean bluetooth_client_register_passkey_agent(BluetoothClient *client,
const char *path, const char *address, const void *info)
{
@@ -1112,13 +1189,7 @@ gboolean bluetooth_client_register_passk
return TRUE;
}
-static void create_bonding_reply(DBusGProxy *proxy,
- GError *error, gpointer userdata)
-{
- //g_printf("create bonding reply\n");
-}
-
-gboolean bluetooth_client_create_bonding(BluetoothClient *client,
+gboolean bluetooth_client_cancel_call(BluetoothClient *client,
gchar *adapter, const gchar *address)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
@@ -1142,9 +1213,14 @@ gboolean bluetooth_client_create_bonding
COLUMN_OBJECT, &object, -1);
if (g_ascii_strcasecmp(path, adapter) == 0) {
- adapter_create_bonding_async(object, address,
- create_bonding_reply, NULL);
- return TRUE;
+ DBusGProxyCall *call;
+ call = (DBusGProxyCall *)g_object_get_data(G_OBJECT(object), "call");
+ if (call != NULL) {
+ dbus_g_proxy_cancel_call(object, call);
+ g_object_set_data(G_OBJECT(object), "call", NULL);
+ return TRUE;
+ }
+ return FALSE;
}
cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
@@ -1153,14 +1229,48 @@ gboolean bluetooth_client_create_bonding
return FALSE;
}
-static void remove_bonding_reply(DBusGProxy *proxy,
- GError *error, gpointer userdata)
+static void call_reply(DBusGProxy *proxy,
+ GError *error, gpointer userdata)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*) userdata;
+ g_object_set_data(G_OBJECT(proxy), "call", NULL);
+ if (data) {
+ (*(bluetooth_client_call_reply)data->cb) (error, data->userdata);
+ g_free(data);
+ }
+ if (error)
+ g_error_free(error);
+}
+
+static void call_reply_s(DBusGProxy *proxy, char *s,
+ GError *error, gpointer userdata)
{
- //g_printf("remove bonding reply\n");
+ call_reply(proxy, error, userdata);
}
-gboolean bluetooth_client_remove_bonding(BluetoothClient *client,
- gchar *adapter, const gchar *address)
+static gboolean connect_to_service(BluetoothClient *client, DBusGProxy *object,
+ const gchar *address, guint type,
+ gpointer userdata)
+{
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ DBusGProxyCall *call = NULL;
+
+ /* Special case the few types we can handle */
+ if (type == BLUETOOTH_TYPE_MOUSE || type == BLUETOOTH_TYPE_KEYBOARD)
+ call = input_create_secure_device_async(priv->input_service, address,
+ call_reply_s, userdata);
+ else if (type == BLUETOOTH_TYPE_HEADSET)
+ call = audio_create_headset_async(priv->audio_service, address,
+ call_reply_s, userdata);
+
+ g_object_set_data(G_OBJECT(object), "call", call);
+ return call != NULL;
+}
+
+gboolean bluetooth_client_connect(BluetoothClient *client, guint type,
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
GtkTreeIter iter;
@@ -1183,9 +1293,36 @@ gboolean bluetooth_client_remove_bonding
COLUMN_OBJECT, &object, -1);
if (g_ascii_strcasecmp(path, adapter) == 0) {
- adapter_remove_bonding_async(object, address,
- remove_bonding_reply, NULL);
- return TRUE;
+ DBusGAsyncData *stuff;
+ gboolean cont;
+ GtkTreeIter child;
+
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+
+ // If caller didn't specify a forced type, determine it from device info
+ if (type == 0 || type == BLUETOOTH_TYPE_ANY) {
+ cont = gtk_tree_model_iter_children(GTK_TREE_MODEL(priv->store),
+ &child, &iter);
+
+ while (cont == TRUE) {
+ gchar *value;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &child,
+ COLUMN_ADDRESS, &value, -1);
+
+ if (g_ascii_strcasecmp(address, value) == 0) {
+ gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &child,
+ COLUMN_TYPE, &type, -1);
+ break;
+ }
+
+ cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &child);
+ }
+ }
+
+ return connect_to_service(client, object, address, type, stuff);
}
cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
@@ -1194,14 +1331,53 @@ gboolean bluetooth_client_remove_bonding
return FALSE;
}
-static void set_trusted_reply(DBusGProxy *proxy,
- GError *error, gpointer userdata)
+gboolean bluetooth_client_create_bonding(BluetoothClient *client,
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
{
- //g_printf("set trusted reply\n");
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ GtkTreeIter iter;
+ gboolean cont;
+
+ if (adapter == NULL)
+ adapter = priv->default_adapter;
+
+ if (adapter == NULL)
+ return FALSE;
+
+ cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store), &iter);
+
+ while (cont == TRUE) {
+ DBusGProxy *object;
+ gchar *path;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+ COLUMN_PATH, &path,
+ COLUMN_OBJECT, &object, -1);
+
+ if (g_ascii_strcasecmp(path, adapter) == 0) {
+ DBusGProxyCall *call;
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ call = adapter_create_bonding_async(object, address,
+ call_reply, stuff);
+ g_object_set_data(G_OBJECT(object), "call", call);
+ return call != NULL;
+ }
+
+ cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
+ }
+
+ return FALSE;
}
-gboolean bluetooth_client_set_trusted(BluetoothClient *client,
- gchar *adapter, const gchar *address)
+gboolean bluetooth_client_remove_bonding(BluetoothClient *client,
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
GtkTreeIter iter;
@@ -1224,8 +1400,14 @@ gboolean bluetooth_client_set_trusted(Bl
COLUMN_OBJECT, &object, -1);
if (g_ascii_strcasecmp(path, adapter) == 0) {
- adapter_set_trusted_async(object, address,
- set_trusted_reply, NULL);
+ DBusGProxyCall *call;
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ call = adapter_remove_bonding_async(object, address,
+ call_reply, stuff);
+ g_object_set_data(G_OBJECT(object), "call", call);
return TRUE;
}
@@ -1235,14 +1417,53 @@ gboolean bluetooth_client_set_trusted(Bl
return FALSE;
}
-static void remove_trust_reply(DBusGProxy *proxy,
- GError *error, gpointer userdata)
+gboolean bluetooth_client_set_trusted(BluetoothClient *client,
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
{
- //g_printf("remove trust reply\n");
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ GtkTreeIter iter;
+ gboolean cont;
+
+ if (adapter == NULL)
+ adapter = priv->default_adapter;
+
+ if (adapter == NULL)
+ return FALSE;
+
+ cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store), &iter);
+
+ while (cont == TRUE) {
+ DBusGProxy *object;
+ gchar *path;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+ COLUMN_PATH, &path,
+ COLUMN_OBJECT, &object, -1);
+
+ if (g_ascii_strcasecmp(path, adapter) == 0) {
+ DBusGProxyCall *call;
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ call = adapter_set_trusted_async(object, address,
+ call_reply, stuff);
+ g_object_set_data(G_OBJECT(object), "call", call);
+ return TRUE;
+ }
+
+ cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
+ }
+
+ return FALSE;
}
gboolean bluetooth_client_remove_trust(BluetoothClient *client,
- gchar *adapter, const gchar *address)
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
GtkTreeIter iter;
@@ -1265,8 +1486,14 @@ gboolean bluetooth_client_remove_trust(B
COLUMN_OBJECT, &object, -1);
if (g_ascii_strcasecmp(path, adapter) == 0) {
- adapter_remove_trust_async(object, address,
- remove_trust_reply, NULL);
+ DBusGProxyCall *call;
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ call = adapter_remove_trust_async(object, address,
+ call_reply, stuff);
+ g_object_set_data(G_OBJECT(object), "call", call);
return TRUE;
}
diff -rupN bluez-gnome-0.27.orig/common/client.h bluez-gnome-0.27/common/client.h
--- bluez-gnome-0.27.orig/common/client.h 2008-06-27 14:12:49.000000000 -0400
+++ bluez-gnome-0.27/common/client.h 2008-06-27 14:13:05.000000000 -0400
@@ -99,14 +99,34 @@ const gchar *bluetooth_type_to_string(gu
gboolean bluetooth_client_register_passkey_agent(BluetoothClient *self,
const char *path, const char *address, const void *info);
-gboolean bluetooth_client_create_bonding(BluetoothClient *self,
+typedef void (*bluetooth_client_call_reply) (GError *error, gpointer data);
+
+int bluetooth_client_available_services(BluetoothClient *self);
+
+gboolean bluetooth_client_cancel_call(BluetoothClient *self,
gchar *adapter, const gchar *address);
+gboolean bluetooth_client_connect(BluetoothClient *self, guint type, // set to non-ANY to force a certain type connection -- useful for dumb devices
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
+gboolean bluetooth_client_create_bonding(BluetoothClient *self,
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
gboolean bluetooth_client_remove_bonding(BluetoothClient *self,
- gchar *adapter, const gchar *address);
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
gboolean bluetooth_client_set_trusted(BluetoothClient *self,
- gchar *adapter, const gchar *address);
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
gboolean bluetooth_client_remove_trust(BluetoothClient *self,
- gchar *adapter, const gchar *address);
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
+
+const gchar *bluetooth_client_get_name(BluetoothClient *self, const gchar *adapter);
gboolean bluetooth_client_disconnect(BluetoothClient *self,
gchar *adapter, const gchar *address);
diff -rupN bluez-gnome-0.27.orig/common/dbus.xml bluez-gnome-0.27/common/dbus.xml
--- bluez-gnome-0.27.orig/common/dbus.xml 2008-06-27 14:12:49.000000000 -0400
+++ bluez-gnome-0.27/common/dbus.xml 2008-06-27 14:13:05.000000000 -0400
@@ -98,4 +98,20 @@
<arg type="s" name="address"/>
</method>
</interface>
+
+ <interface name="input">
+ <method name="CreateSecureDevice">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="s" name="address"/>
+ <arg type="s" direction="out"/>
+ </method>
+ </interface>
+
+ <interface name="audio">
+ <method name="CreateHeadset">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="s" name="address"/>
+ <arg type="s" direction="out"/>
+ </method>
+ </interface>
</node>
diff -rupN bluez-gnome-0.27.orig/properties/adapter.c bluez-gnome-0.27/properties/adapter.c
--- bluez-gnome-0.27.orig/properties/adapter.c 2008-06-27 14:12:49.000000000 -0400
+++ bluez-gnome-0.27/properties/adapter.c 2008-06-27 14:13:05.000000000 -0400
@@ -317,7 +317,7 @@ static void delete_callback(GtkWidget *b
gtk_tree_model_get(model, &iter, COLUMN_ADDRESS, &address, -1);
if (show_confirm_dialog() == TRUE)
- bluetooth_client_remove_bonding(client, adapter->path, address);
+ bluetooth_client_remove_bonding(client, adapter->path, address, NULL, NULL);
g_free(address);
}
@@ -338,9 +338,9 @@ static void trusted_callback(GtkWidget *
COLUMN_TRUSTED, &trusted, -1);
if (trusted == FALSE)
- bluetooth_client_set_trusted(client, adapter->path, address);
+ bluetooth_client_set_trusted(client, adapter->path, address, NULL, NULL);
else
- bluetooth_client_remove_trust(client, adapter->path, address);
+ bluetooth_client_remove_trust(client, adapter->path, address, NULL, NULL);
g_free(address);
}
diff -rupN bluez-gnome-0.27.orig/wizard/agent.c bluez-gnome-0.27/wizard/agent.c
--- bluez-gnome-0.27.orig/wizard/agent.c 1969-12-31 19:00:00.000000000 -0500
+++ bluez-gnome-0.27/wizard/agent.c 2008-06-27 14:13:05.000000000 -0400
@@ -0,0 +1,504 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2005-2008 Marcel Holtmann <marcel@holtmann.org>
+ * Copyright (C) 2006-2007 Bastien Nocera <hadess@hadess.net>
+ *
+ *
+ * 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 <dbus/dbus-glib.h>
+
+#include <glib/gi18n.h>
+
+#include <gtk/gtk.h>
+
+#include "agent.h"
+
+#define PASSKEY_AGENT_PATH "/org/bluez/passkey"
+
+static GtkWidget *main_dialog;
+
+typedef enum {
+ AGENT_ERROR_REJECT
+} AgentError;
+
+#define AGENT_ERROR (agent_error_quark())
+
+#define AGENT_ERROR_TYPE (agent_error_get_type())
+
+static GQuark agent_error_quark(void)
+{
+ static GQuark quark = 0;
+ if (!quark)
+ quark = g_quark_from_static_string("agent");
+
+ return quark;
+}
+
+#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
+
+static GList *input_list = NULL;
+
+struct input_data {
+ char *path;
+ char *address;
+ char *service;
+ char *uuid;
+ DBusGMethodInvocation *context;
+ GtkWidget *dialog;
+ GtkWidget *button;
+ GtkWidget *entry;
+};
+
+static gint input_compare(gconstpointer a, gconstpointer b)
+{
+ struct input_data *a_data = (struct input_data *) a;
+ struct input_data *b_data = (struct input_data *) b;
+
+ return g_ascii_strcasecmp(a_data->address, b_data->address);
+}
+
+static void input_free(struct input_data *input)
+{
+ gtk_widget_destroy(input->dialog);
+
+ g_free(input->uuid);
+ g_free(input->service);
+ g_free(input->address);
+ g_free(input->path);
+ g_free(input);
+}
+
+static void passkey_callback(GtkWidget *dialog,
+ gint response, gpointer user_data)
+{
+ struct input_data *input = user_data;
+
+ if (response == GTK_RESPONSE_ACCEPT) {
+ const char *passkey;
+ passkey = gtk_entry_get_text(GTK_ENTRY(input->entry));
+ dbus_g_method_return(input->context, passkey);
+ } else {
+ GError *error;
+ error = g_error_new(AGENT_ERROR, AGENT_ERROR_REJECT,
+ "Pairing request rejected");
+ dbus_g_method_return_error(input->context, error);
+ }
+
+ input_free(input);
+}
+
+static void changed_callback(GtkWidget *editable, gpointer user_data)
+{
+ struct input_data *input = user_data;
+ const gchar *text;
+
+ text = gtk_entry_get_text(GTK_ENTRY(input->entry));
+
+ gtk_widget_set_sensitive(input->button, *text != '\0' ? TRUE : FALSE);
+}
+
+static void toggled_callback(GtkWidget *button, gpointer user_data)
+{
+ struct input_data *input = user_data;
+ gboolean mode;
+
+ mode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
+
+ gtk_entry_set_visibility(GTK_ENTRY(input->entry), mode);
+}
+
+static void passkey_dialog(const char *path, const char *address,
+ const gchar *device, DBusGMethodInvocation *context)
+{
+ GtkWidget *dialog;
+ GtkWidget *button;
+ GtkWidget *image;
+ GtkWidget *label;
+ GtkWidget *entry;
+ GtkWidget *table;
+ GtkWidget *vbox;
+ struct input_data *input;
+ gchar *markup;
+
+ input = g_try_malloc0(sizeof(*input));
+ if (!input)
+ return;
+
+ input->path = g_strdup(path);
+ input->address = g_strdup(address);
+
+ input->context = context;
+
+ dialog = gtk_dialog_new();
+
+ gtk_window_set_title(GTK_WINDOW(dialog), _("Authentication request"));
+
+ gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
+
+ gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
+
+ gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
+
+ gtk_window_set_urgency_hint(GTK_WINDOW(dialog), TRUE);
+
+ gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
+
+ gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(main_dialog));
+
+ input->dialog = dialog;
+
+ button = gtk_dialog_add_button(GTK_DIALOG(dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
+
+ button = gtk_dialog_add_button(GTK_DIALOG(dialog),
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT);
+
+ gtk_widget_grab_default(button);
+
+ gtk_widget_set_sensitive(button, FALSE);
+
+ input->button = button;
+
+ table = gtk_table_new(5, 2, FALSE);
+
+ gtk_table_set_row_spacings(GTK_TABLE(table), 4);
+ gtk_table_set_col_spacings(GTK_TABLE(table), 20);
+
+ gtk_container_set_border_width(GTK_CONTAINER(table), 12);
+
+ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
+
+ image = gtk_image_new_from_icon_name(GTK_STOCK_DIALOG_AUTHENTICATION,
+ GTK_ICON_SIZE_DIALOG);
+
+ gtk_misc_set_alignment(GTK_MISC(image), 0.0, 0.0);
+
+ gtk_table_attach(GTK_TABLE(table), image, 0, 1, 0, 5,
+ GTK_SHRINK, GTK_FILL, 0, 0);
+
+ vbox = gtk_vbox_new(FALSE, 6);
+
+ label = gtk_label_new(_("Pairing request for device:"));
+
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+
+ gtk_container_add(GTK_CONTAINER(vbox), label);
+
+ gtk_table_attach(GTK_TABLE(table), vbox, 1, 2, 0, 1,
+ GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+
+ label = gtk_label_new(NULL);
+
+ markup = g_strdup_printf("<b>%s</b>", device);
+ gtk_label_set_markup(GTK_LABEL(label), markup);
+ g_free(markup);
+
+ gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
+
+ gtk_label_set_selectable(GTK_LABEL(label), TRUE);
+
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+
+ gtk_widget_set_size_request(GTK_WIDGET(label), 280, -1);
+
+ gtk_container_add(GTK_CONTAINER(vbox), label);
+
+ vbox = gtk_vbox_new(FALSE, 6);
+
+ label = gtk_label_new(_("Enter passkey for authentication:"));
+
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+
+ gtk_container_add(GTK_CONTAINER(vbox), label);
+
+ gtk_table_attach(GTK_TABLE(table), vbox, 1, 2, 2, 3,
+ GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+
+ entry = gtk_entry_new();
+
+ gtk_entry_set_max_length(GTK_ENTRY(entry), 16);
+
+ gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
+
+ gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
+
+ input->entry = entry;
+
+ g_signal_connect(G_OBJECT(entry), "changed",
+ G_CALLBACK(changed_callback), input);
+
+ gtk_container_add(GTK_CONTAINER(vbox), entry);
+
+ button = gtk_check_button_new_with_label(_("Show input"));
+
+ g_signal_connect(G_OBJECT(button), "toggled",
+ G_CALLBACK(toggled_callback), input);
+
+ gtk_container_add(GTK_CONTAINER(vbox), button);
+
+ input_list = g_list_append(input_list, input);
+ gtk_widget_show_all(dialog);
+ gtk_window_present(GTK_WINDOW(dialog));
+
+ g_signal_connect(G_OBJECT(dialog), "response",
+ G_CALLBACK(passkey_callback), input);
+}
+
+static void confirm_callback(GtkWidget *dialog,
+ gint response, gpointer user_data)
+{
+ struct input_data *input = user_data;
+
+ if (response != GTK_RESPONSE_YES) {
+ GError *error;
+ error = g_error_new(AGENT_ERROR, AGENT_ERROR_REJECT,
+ "Confirmation request rejected");
+ dbus_g_method_return_error(input->context, error);
+ } else
+ dbus_g_method_return(input->context);
+
+ input_free(input);
+}
+
+static void confirm_dialog(const char *path, const char *address,
+ const char *value, const gchar *device,
+ DBusGMethodInvocation *context)
+{
+ GtkWidget *dialog;
+ GtkWidget *button;
+ GtkWidget *image;
+ GtkWidget *label;
+ GtkWidget *table;
+ GtkWidget *vbox;
+ gchar *markup;
+ struct input_data *input;
+
+ input = g_try_malloc0(sizeof(*input));
+ if (!input)
+ return;
+
+ input->path = g_strdup(path);
+ input->address = g_strdup(address);
+
+ input->context = context;
+
+ dialog = gtk_dialog_new();
+
+ gtk_window_set_title(GTK_WINDOW(dialog), _("Confirmation request"));
+
+ gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
+
+ gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
+
+ gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
+
+ gtk_window_set_urgency_hint(GTK_WINDOW(dialog), TRUE);
+
+ gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
+
+ gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(main_dialog));
+
+ input->dialog = dialog;
+
+ button = gtk_dialog_add_button(GTK_DIALOG(dialog),
+ GTK_STOCK_NO, GTK_RESPONSE_NO);
+
+ button = gtk_dialog_add_button(GTK_DIALOG(dialog),
+ GTK_STOCK_YES, GTK_RESPONSE_YES);
+
+ table = gtk_table_new(5, 2, FALSE);
+
+ gtk_table_set_row_spacings(GTK_TABLE(table), 4);
+ gtk_table_set_col_spacings(GTK_TABLE(table), 20);
+
+ gtk_container_set_border_width(GTK_CONTAINER(table), 12);
+
+ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
+
+ image = gtk_image_new_from_icon_name(GTK_STOCK_DIALOG_AUTHENTICATION,
+ GTK_ICON_SIZE_DIALOG);
+
+ gtk_misc_set_alignment(GTK_MISC(image), 0.0, 0.0);
+
+ gtk_table_attach(GTK_TABLE(table), image, 0, 1, 0, 5,
+ GTK_SHRINK, GTK_FILL, 0, 0);
+
+ vbox = gtk_vbox_new(FALSE, 6);
+ label = gtk_label_new(_("Pairing request for device:"));
+
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+
+ gtk_container_add(GTK_CONTAINER(vbox), label);
+
+ gtk_table_attach(GTK_TABLE(table), vbox, 1, 2, 0, 1,
+ GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+
+ label = gtk_label_new(NULL);
+
+ markup = g_strdup_printf("<b>%s</b>", device);
+ gtk_label_set_markup(GTK_LABEL(label), markup);
+ g_free(markup);
+
+ gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
+
+ gtk_label_set_selectable(GTK_LABEL(label), TRUE);
+
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+
+ gtk_widget_set_size_request(GTK_WIDGET(label), 280, -1);
+
+ gtk_container_add(GTK_CONTAINER(vbox), label);
+
+ vbox = gtk_vbox_new(FALSE, 6);
+
+ label = gtk_label_new(_("Confirm value for authentication:"));
+
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+
+ gtk_container_add(GTK_CONTAINER(vbox), label);
+
+ gtk_table_attach(GTK_TABLE(table), vbox, 1, 2, 2, 3,
+ GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+
+ label = gtk_label_new(NULL);
+
+ markup = g_strdup_printf("<b>%s</b>\n", value);
+
+ gtk_label_set_markup(GTK_LABEL(label), markup);
+
+ g_free(markup);
+
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+
+ gtk_container_add(GTK_CONTAINER(vbox), label);
+
+ input_list = g_list_append(input_list, input);
+ gtk_widget_show_all(dialog);
+ gtk_window_present(GTK_WINDOW(dialog));
+
+ g_signal_connect(G_OBJECT(dialog), "response",
+ G_CALLBACK(confirm_callback), input);
+}
+
+static gboolean passkey_agent_request(GObject *agent,
+ const char *path, const char *address,
+ DBusGMethodInvocation *context)
+{
+ BluetoothClient *client = BLUETOOTH_CLIENT(agent);
+ const char *name = NULL;
+ gchar *device;
+
+ name = bluetooth_client_get_name(client, path);
+
+ if (name) {
+ if (g_strrstr(name, address))
+ device = g_strdup(name);
+ else
+ device = g_strdup_printf("%s (%s)", name, address);
+ } else
+ device = g_strdup(address);
+
+ passkey_dialog(path, address, device, context);
+
+ g_free(device);
+ return TRUE;
+}
+
+static gboolean passkey_agent_confirm(GObject *agent,
+ const char *path, const char *address,
+ const char *value, DBusGMethodInvocation *context)
+{
+ BluetoothClient *client = BLUETOOTH_CLIENT(agent);
+ const char *name = NULL;
+ gchar *device;
+
+ name = bluetooth_client_get_name(client, path);
+
+ if (name) {
+ if (g_strrstr(name, address))
+ device = g_strdup(name);
+ else
+ device = g_strdup_printf("%s (%s)", name, address);
+ } else
+ device = g_strdup(address);
+
+ confirm_dialog(path, address, value, device, context);
+
+ g_free(device);
+ return TRUE;
+}
+
+static gboolean passkey_agent_cancel(GObject *agent,
+ const char *path, const char *address, GError **error)
+{
+ GList *list;
+ GError *result;
+ struct input_data *input;
+
+ input = g_try_malloc0(sizeof(*input));
+ if (!input)
+ return FALSE;
+
+ input->path = g_strdup(path);
+ input->address = g_strdup(address);
+
+ list = g_list_find_custom(input_list, input, input_compare);
+
+ g_free(input->address);
+ g_free(input->path);
+ g_free(input);
+
+ if (!list || !list->data)
+ return FALSE;
+
+ input = list->data;
+
+ result = g_error_new(AGENT_ERROR, AGENT_ERROR_REJECT,
+ "Agent callback canceled");
+
+ dbus_g_method_return_error(input->context, result);
+
+ input_free(input);
+
+ return TRUE;
+}
+
+static gboolean passkey_agent_release(GObject *agent, GError **error)
+{
+ return TRUE;
+}
+
+#include "passkey-agent-glue.h"
+
+void set_agent_parent_window(GtkWidget *window)
+{
+ main_dialog = window;
+}
+
+gboolean register_agent(BluetoothClient *client,
+ const char *path, const char *address)
+{
+ return bluetooth_client_register_passkey_agent(client, path, address, &dbus_glib_passkey_agent_object_info);
+}
+
diff -rupN bluez-gnome-0.27.orig/wizard/agent.h bluez-gnome-0.27/wizard/agent.h
--- bluez-gnome-0.27.orig/wizard/agent.h 1969-12-31 19:00:00.000000000 -0500
+++ bluez-gnome-0.27/wizard/agent.h 2008-06-27 14:13:05.000000000 -0400
@@ -0,0 +1,30 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2005-2008 Marcel Holtmann <marcel@holtmann.org>
+ * Copyright (C) 2006-2007 Bastien Nocera <hadess@hadess.net>
+ *
+ *
+ * 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
+ *
+ */
+
+#include <gtk/gtk.h>
+#include "client.h"
+
+void set_agent_parent_window(GtkWidget *window);
+int register_agent(BluetoothClient *client, const char *path, const char *address);
+
diff -rupN bluez-gnome-0.27.orig/wizard/main.c bluez-gnome-0.27/wizard/main.c
--- bluez-gnome-0.27.orig/wizard/main.c 2008-06-27 14:12:49.000000000 -0400
+++ bluez-gnome-0.27/wizard/main.c 2008-06-27 14:21:41.000000000 -0400
@@ -32,6 +32,7 @@
#include <gtk/gtk.h>
#include "client.h"
+#include "agent.h"
#include "dbus-glue.h"
@@ -41,93 +42,141 @@
static gboolean singleton = FALSE;
static BluetoothClient *client;
+static DBusGProxyCall *call = NULL;
static gchar *address = NULL;
-static gchar *passkey = "123456";
+static GtkWidget *page_prev = NULL;
static GtkWidget *page_search = NULL;
-static GtkWidget *page_info = NULL;
static GtkWidget *page_pairing = NULL;
+static GtkWidget *page_info = NULL;
static GtkWidget *page_summary = NULL;
+static int page_summary_num = 0;
-static GtkWidget *label_pairing = NULL;
-static GtkWidget *label_passkey = NULL;
+static GtkWidget *pairing_progress = NULL;
+static guint pairing_progress_timeout = 0;
+static GtkWidget *pairing_message = NULL;
+static GSList *type_group = NULL;
static GtkWidget *selector = NULL;
-static gboolean passkey_agent_request(GObject *agent,
- const char *path, const char *address,
- DBusGMethodInvocation *context)
-{
- const char *value = passkey;
-
- /* Apple Wireless and Mighty Mouse */
- if (g_str_has_prefix(address, "00:0A:95:") == TRUE ||
- g_str_has_prefix(address, "00:14:51:") == TRUE)
- value = "0000";
-
- dbus_g_method_return(context, value);
+static void close_callback(GtkWidget *assistant, gpointer data)
+{
+ gtk_widget_destroy(assistant);
- return TRUE;
+ gtk_main_quit();
}
-static gboolean passkey_agent_cancel(GObject *agent,
- const char *path, const char *address, GError **error)
+static void cancel_callback(GtkWidget *assistant, gpointer data)
{
- return TRUE;
+ gtk_widget_destroy(assistant);
+
+ gtk_main_quit();
}
-static gboolean passkey_agent_release(GObject *agent, GError **error)
+static gint selected_type(void)
{
- return TRUE;
+ GSList *iter;
+ for (iter = type_group; iter; iter = iter->next) {
+ GtkToggleButton *button = GTK_TOGGLE_BUTTON(iter->data);
+ if (gtk_toggle_button_get_active(button)) {
+ gpointer data = g_object_get_data(G_OBJECT(button), "bluez-type");
+ return GPOINTER_TO_INT(data);
+ }
+ }
+ return BLUETOOTH_TYPE_ANY;
}
+
+static void show_pairing_error(GError *error)
+{
+ gchar *msg;
+ const gchar *errmsg;
+
+ gtk_widget_hide(pairing_progress);
+ if (pairing_progress_timeout > 0) {
+ g_source_remove(pairing_progress_timeout);
+ pairing_progress_timeout = 0;
+ }
-#include "passkey-agent-glue.h"
+ if (!error)
+ errmsg = _("Could not contact bluetooth service");
+ else
+ errmsg = error->message;
-#if 0
-static gint page_forward(gint current_page, gpointer data)
-{
- return current_page + 1;
+ msg = g_strdup_printf("<b>%s</b>\n\n%s", _("Cannot connect to device:"), errmsg);
+ gtk_label_set_markup(GTK_LABEL(pairing_message), msg);
+ gtk_widget_show(pairing_message);
+ g_free(msg);
}
-#endif
-static void close_callback(GtkWidget *assistant, gpointer data)
+static void trusted_callback(GError *error, gpointer data)
{
- gtk_widget_destroy(assistant);
+ GtkAssistant *assistant = GTK_ASSISTANT(data);
- gtk_main_quit();
+ gtk_widget_hide(pairing_progress);
+ if (pairing_progress_timeout > 0) {
+ g_source_remove(pairing_progress_timeout);
+ pairing_progress_timeout = 0;
+ }
+
+ if (error) {
+ show_pairing_error(error);
+ }
+ else {
+ gtk_assistant_set_page_complete(assistant, page_pairing, TRUE);
+ gtk_assistant_set_current_page(assistant, page_summary_num); // jump to summary
+ }
}
-static void cancel_callback(GtkWidget *assistant, gpointer data)
+static void connect_callback(GError *error, gpointer data)
{
- gtk_widget_destroy(assistant);
+ if (error ||
+ !bluetooth_client_set_trusted(client, NULL, address, trusted_callback, data))
+ show_pairing_error(error);
+}
- gtk_main_quit();
+static gboolean pulse_progress(gpointer data)
+{
+ gtk_progress_bar_pulse(GTK_PROGRESS_BAR(pairing_progress));
+ return TRUE;
}
static void prepare_callback(GtkWidget *assistant,
GtkWidget *page, gpointer data)
{
+ gboolean complete = TRUE;
+
if (page == page_search) {
+ gint type = selected_type();
+ g_object_set(G_OBJECT(selector), "device-type-filter", type, NULL);
bluetooth_device_selection_start_discovery(BLUETOOTH_DEVICE_SELECTION(selector));
- return;
+ if (address)
+ bluetooth_client_cancel_call(client, NULL, address);
+ complete = address != NULL;
}
-
- if (page == page_pairing) {
+ else if (page == page_pairing) {
bluetooth_client_cancel_discovery(client, NULL);
- bluetooth_client_register_passkey_agent(client,
- "/org/bluez/applet", address,
- &dbus_glib_passkey_agent_object_info);
-
- bluetooth_client_create_bonding(client, NULL, address);
-
- gtk_label_set_markup(GTK_LABEL(label_pairing), address);
- gtk_label_set_markup(GTK_LABEL(label_passkey), passkey);
- return;
+ register_agent(client, "/org/bluez/applet", address);
+
+ if (page_prev == page_search) {
+ pairing_progress_timeout = g_timeout_add(100, pulse_progress, pairing_progress);
+ gtk_widget_show(pairing_progress);
+ gtk_widget_hide(pairing_message);
+ complete = FALSE;
+ if (!bluetooth_client_connect(client, selected_type(), NULL, address,
+ connect_callback, assistant))
+ show_pairing_error(NULL);
+ }
+ }
+
+ if (page != page_pairing && pairing_progress_timeout > 0) {
+ g_source_remove(pairing_progress_timeout);
+ pairing_progress_timeout = 0;
}
- gtk_assistant_set_page_complete(GTK_ASSISTANT(assistant), page, TRUE);
+ gtk_assistant_set_page_complete(GTK_ASSISTANT(assistant), page, complete);
+ page_prev = page;
}
static GtkWidget *create_vbox(GtkWidget *assistant, GtkAssistantPageType type,
@@ -238,55 +287,39 @@ static void create_type(GtkWidget *assis
vbox = create_vbox(assistant, GTK_ASSISTANT_PAGE_CONTENT,
_("Device type"),
- _("Select the type of device you want to setup"));
-
- button = gtk_radio_button_new_with_label(group, _("Mouse"));
-
- group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
- //gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
+ _("Select the type of device you want to connect"));
+ button = gtk_radio_button_new_with_label(NULL, _("Mouse"));
+ g_object_set_data(G_OBJECT(button),
+ "bluez-type", GINT_TO_POINTER(BLUETOOTH_TYPE_MOUSE));
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
- button = gtk_radio_button_new_with_label(group, _("Keyboard"));
-
- group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
- //gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
-
+ button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), _("Keyboard"));
+ g_object_set_data(G_OBJECT(button),
+ "bluez-type", GINT_TO_POINTER(BLUETOOTH_TYPE_KEYBOARD));
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
- button = gtk_radio_button_new_with_label(group, _("Mobile phone"));
-
- group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
- gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
-
+#if 0
+ button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), _("Mobile phone"));
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
- button = gtk_radio_button_new_with_label(group, _("Printer"));
-
- group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
- gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
-
+ button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), _("Printer"));
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
+#endif
- button = gtk_radio_button_new_with_label(group, _("Headset"));
-
- group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
- gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
-
+ button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), _("Headset"));
+ g_object_set_data(G_OBJECT(button),
+ "bluez-type", GINT_TO_POINTER(BLUETOOTH_TYPE_HEADSET));
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
- button = gtk_radio_button_new_with_label(group, _("Any device"));
-
- group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
-
+#if 0
+ button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), _("Any device"));
+ g_object_set_data(G_OBJECT(button),
+ "bluez-type", GINT_TO_POINTER(BLUETOOTH_TYPE_ANY));
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
+#endif
+
+ type_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
}
static void select_callback(BluetoothDeviceSelection *sel,
@@ -310,7 +343,7 @@ static void create_search(GtkWidget *ass
vbox = create_vbox(assistant, GTK_ASSISTANT_PAGE_CONTENT,
_("Device search"),
- _("Select the device you want to setup"));
+ _("Select the device you want to connect"));
selector = bluetooth_device_selection_new(NULL);
@@ -349,26 +382,27 @@ static void create_pairing(GtkWidget *as
{
GtkWidget *vbox;
GtkWidget *label;
+ GtkWidget *progress;
vbox = create_vbox(assistant, GTK_ASSISTANT_PAGE_CONTENT,
- _("Device pairing"),
- _("Pairing with new device"));
-
- label = gtk_label_new(NULL);
+ _("Device connection"),
+ _("Connecting with new device"));
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
+ progress = gtk_progress_bar_new();
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), progress, FALSE, TRUE, 0);
- label_pairing = label;
+ pairing_progress = progress;
label = gtk_label_new(NULL);
+ gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
+ gtk_label_set_selectable(GTK_LABEL(label), TRUE);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
- label_passkey = label;
+ pairing_message = label;
page_pairing = vbox;
}
@@ -381,6 +415,8 @@ static void create_summary(GtkWidget *as
_("Summary"),
_("Succesfully configured new device"));
+ page_summary_num = gtk_assistant_get_n_pages(GTK_ASSISTANT(assistant)) - 1;
+
page_summary = vbox;
}
@@ -401,13 +437,13 @@ static GtkWidget *create_wizard(void)
page_forward, NULL, NULL);
#endif
- create_intro(assistant);
+ /*create_intro(assistant);*/
create_type(assistant);
create_search(assistant);
- create_info(assistant);
+ /*create_info(assistant);*/
create_pairing(assistant);
@@ -465,6 +501,7 @@ int main(int argc, char *argv[])
client = bluetooth_client_new();
window = create_wizard();
+ set_agent_parent_window(window);
bluetooth_instance_set_window(instance, GTK_WINDOW(window));
diff -rupN bluez-gnome-0.27.orig/wizard/Makefile.am bluez-gnome-0.27/wizard/Makefile.am
--- bluez-gnome-0.27.orig/wizard/Makefile.am 2008-06-27 14:12:49.000000000 -0400
+++ bluez-gnome-0.27/wizard/Makefile.am 2008-06-27 14:13:05.000000000 -0400
@@ -1,7 +1,7 @@
-noinst_PROGRAMS = bluetooth-wizard
+bin_PROGRAMS = bluetooth-wizard
-bluetooth_wizard_SOURCES = main.c
+bluetooth_wizard_SOURCES = main.c agent.c agent.h
bluetooth_wizard_LDADD = @GTK_LIBS@ @DBUS_LIBS@ \
$(top_builddir)/common/libcommon.a
@@ -13,7 +13,7 @@ AM_CFLAGS = @DBUS_CFLAGS@ @GTK_CFLAGS@
INCLUDES = -I$(top_srcdir)/common -I$(top_builddir)/common
-noinst_MANS = bluetooth-wizard.1
+man_MANS = bluetooth-wizard.1
EXTRA_DIST = $(noinst_MANS)
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 247 bytes --]
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
[-- Attachment #3: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-27 19:05 [Bluez-devel] Wizard patch Michael Terry
2008-06-27 19:18 ` Michael Terry
@ 2008-06-27 19:38 ` David Stockwell
2008-06-27 19:42 ` Michael Terry
2008-06-27 22:23 ` Marcel Holtmann
2008-06-27 22:44 ` Bastien Nocera
3 siblings, 1 reply; 30+ messages in thread
From: David Stockwell @ 2008-06-27 19:38 UTC (permalink / raw)
To: BlueZ development
Is this version working against the old DBus interface, the new, experimental interface, or does it matter?
DS
----- Original Message -----
From: "Michael Terry" <michael.terry@canonical.com>
To: <bluez-devel@lists.sourceforge.net>
Sent: Friday, June 27, 2008 2:05 PM
Subject: [Bluez-devel] Wizard patch
Hello, all!
I have attached a patch against 0.27 (it applies cleanly against CVS) to
complete the wizard in the bluez-gnome source tree.
Here's what my patch does in summary, details below:
Wizard dialog shows list of device types we know how to handle (only
mouse/keyboard/headset right now). Then, it tries to connect to the
appropriate bluetooth dbus service and trust the device. Basically the
same code steps the Properties -> Services tab does, but more
wizardy. :)
I made changes to cleanup the wizard interface (removed a couple of
pages that had low signal/noise ratio) and made several of the
bluetooth_client capable of giving feedback about the operation via a
callback.
Details of changes:
applet/main.c:
Uncomments code to add a menu item for the wizard.
common/bluetooth-device-selection.c:
Fixes broken code to set current filter programmatically.
common/client.[ch]:
setup_services():
Note presence of audio and input services on startup
bluetooth_client_get_name():
Gets user-visible device name for a path
bluetooth_client_available_services():
Returns a mask of the device types supported by services the client
knows about. Not actually used by the rest of my code, but it seemed
possibly useful to one day not show unsupported device types in the
wizard if we wanted to.
bluetooth_client_cancel_call():
Cancels an async call for a particular adapter/address combo. This is
slightly janky because it only allows for one call at a time per pair,
but that's all that we ever need right now.
connect_to_service():
Handles service-specific calls to initiate a device connection. Stuff
like CreateSecureDevice or CreateHeadset.
bluetooth_client_connect():
Kicks off a call to connect_to_service
bluetooth_client_create_bonding():
bluetooth_client_remove_bonding():
bluetooth_client_set_trusted():
bluetooth_client_remove_trust():
Modified to allow callbacks
common/dbus.xml:
Add input.CreateSecureDevice and audio.CreateHeadset
properties/adapter.c:
Update a few calls to client functions do to above prototype changes
wizard/agent.[ch]:
Mostly a copy of applet/agent.c, except:
it only holds passkey code (no auth code)
it shows dialogs immediately wrt a parent window
wizard/main.c:
Comment out intro and info pages -- I think the intro page just gets in
the user's way and there was no content in info page, and even if there
was, it would probably also just get in user's way.
I added a pulsing progress bar to the pairing page to give some
feedback.
I changed wording from 'setup' and 'pair' to 'connect'. I figure that
is more user-friendly (since no real setting up is done by user and they
probably think in terms of connecting to devices not pairing with them).
Pairing process is two-step: bluetooth_client_connect followed by
bluetooth_client_set_trusted.
Show an error if either step fails.
Connect to agent code to display a password prompt immediately in front
of user instead of via bluetooth applet.
wizard/Makefile.am:
Install bluetooth-wizard and add agent.[ch]
Thanks!
-mt
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-27 19:38 ` David Stockwell
@ 2008-06-27 19:42 ` Michael Terry
2008-06-27 22:24 ` Marcel Holtmann
0 siblings, 1 reply; 30+ messages in thread
From: Michael Terry @ 2008-06-27 19:42 UTC (permalink / raw)
To: BlueZ development
[-- Attachment #1.1: Type: text/plain, Size: 444 bytes --]
On Fri, 2008-06-27 at 14:38 -0500, David Stockwell wrote:
> Is this version working against the old DBus interface, the new, experimental interface, or does it matter?
The old DBus interface. I don't know about the new interface.
It shouldn't matter much. The important stuff was UI changes. The new
dbus stuff was added in common/client, so if and when that gets ported
to our new interface overlords, my changes will too.
-mt
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 247 bytes --]
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
[-- Attachment #3: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-27 19:05 [Bluez-devel] Wizard patch Michael Terry
2008-06-27 19:18 ` Michael Terry
2008-06-27 19:38 ` David Stockwell
@ 2008-06-27 22:23 ` Marcel Holtmann
2008-06-30 12:51 ` Michael Terry
` (3 more replies)
2008-06-27 22:44 ` Bastien Nocera
3 siblings, 4 replies; 30+ messages in thread
From: Marcel Holtmann @ 2008-06-27 22:23 UTC (permalink / raw)
To: BlueZ development
Hi Michael,
> I have attached a patch against 0.27 (it applies cleanly against CVS) to
> complete the wizard in the bluez-gnome source tree.
>
> Here's what my patch does in summary, details below:
> Wizard dialog shows list of device types we know how to handle (only
> mouse/keyboard/headset right now). Then, it tries to connect to the
> appropriate bluetooth dbus service and trust the device. Basically the
> same code steps the Properties -> Services tab does, but more
> wizardy. :)
>
> I made changes to cleanup the wizard interface (removed a couple of
> pages that had low signal/noise ratio) and made several of the
> bluetooth_client capable of giving feedback about the operation via a
> callback.
looks nice. However you have to break this up into pieces for. Sent
small patches and I can quickly review and commit them.
Regards
Marcel
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-27 19:42 ` Michael Terry
@ 2008-06-27 22:24 ` Marcel Holtmann
0 siblings, 0 replies; 30+ messages in thread
From: Marcel Holtmann @ 2008-06-27 22:24 UTC (permalink / raw)
To: BlueZ development
Hi Michael,
> > Is this version working against the old DBus interface, the new, experimental interface, or does it matter?
>
> The old DBus interface. I don't know about the new interface.
>
> It shouldn't matter much. The important stuff was UI changes. The new
> dbus stuff was added in common/client, so if and when that gets ported
> to our new interface overlords, my changes will too.
it is not that simple, but I will look into that at some point.
Regards
Marcel
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-27 19:05 [Bluez-devel] Wizard patch Michael Terry
` (2 preceding siblings ...)
2008-06-27 22:23 ` Marcel Holtmann
@ 2008-06-27 22:44 ` Bastien Nocera
[not found] ` <031301c8da4d$0bce3720$6701a8c0@freqonedev>
3 siblings, 1 reply; 30+ messages in thread
From: Bastien Nocera @ 2008-06-27 22:44 UTC (permalink / raw)
To: BlueZ development
On Fri, 2008-06-27 at 15:05 -0400, Michael Terry wrote:
> Hello, all!
>
> I have attached a patch against 0.27 (it applies cleanly against CVS) to
> complete the wizard in the bluez-gnome source tree.
- item = gtk_menu_item_new_with_label(_("Setup New Device"));
+ item = gtk_menu_item_new_with_label(_("Connect New Device..."));
This is wrong, as we'll probably want to plug in more setup for future
device types. For example, when adding a phone, we'll want to check
whether it supports SyncML, and automatically set it up in the sync
program.
The setup_services() service call shouldn't be needed, as all the
services are enabled by default.
In bluetooth_client_available_services(), you also need to add joypads,
and every other input devices to that list.
+ // If caller didn't specify a forced type, determine it from device
info
Don't use C++-style comments.
I personally don't really like adding setup calls in client.c, which
should really only be used for discovery.
The rest looks alright to me, looking over it quickly.
Cheers
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-27 22:23 ` Marcel Holtmann
@ 2008-06-30 12:51 ` Michael Terry
2008-06-30 12:57 ` Marcel Holtmann
2008-06-30 13:15 ` Michael Terry
` (2 subsequent siblings)
3 siblings, 1 reply; 30+ messages in thread
From: Michael Terry @ 2008-06-30 12:51 UTC (permalink / raw)
To: BlueZ development
[-- Attachment #1.1.1: Type: text/plain, Size: 448 bytes --]
Hi, Marcel!
On Sat, 2008-06-28 at 00:23 +0200, Marcel Holtmann wrote:
> looks nice. However you have to break this up into pieces for. Sent
> small patches and I can quickly review and commit them.
Here's one such piece of my wizard patch. It simply fixes the "device-type-filter" property to do something reasonable when set (namely, you give it a BLUETOOTH_TYPE and it sets the right index in the combo).
More patches coming.
-mt
[-- Attachment #1.1.2: selector.diff --]
[-- Type: text/x-patch, Size: 2231 bytes --]
diff -rupN bluez-gnome-0.27.orig/common/bluetooth-device-selection.c bluez-gnome-0.27/common/bluetooth-device-selection.c
--- bluez-gnome-0.27.orig/common/bluetooth-device-selection.c 2008-06-27 14:12:49.000000000 -0400
+++ bluez-gnome-0.27/common/bluetooth-device-selection.c 2008-06-27 14:13:05.000000000 -0400
@@ -90,6 +90,15 @@ bluetooth_device_category_to_string (int
}
}
+static int
+int_log2(int v)
+{
+ unsigned rv = 0;
+ while (v >>= 1)
+ rv++;
+ return rv;
+}
+
static void
name_to_text (GtkTreeViewColumn *column, GtkCellRenderer *cell,
GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
@@ -591,7 +600,7 @@ bluetooth_device_selection_init(Bluetoot
}
g_signal_connect (G_OBJECT (priv->device_type), "changed",
G_CALLBACK(filter_type_changed_cb), self);
- gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), priv->device_type_filter);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), int_log2(priv->device_type_filter));
if (priv->show_device_type) {
gtk_widget_show (priv->device_type_label);
gtk_widget_show (priv->device_type);
@@ -665,7 +674,7 @@ bluetooth_device_selection_set_property
break;
case PROP_DEVICE_TYPE_FILTER:
priv->device_type_filter = g_value_get_int (value);
- gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), priv->device_type_filter >> 1);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), int_log2(priv->device_type_filter));
break;
case PROP_DEVICE_CATEGORY_FILTER:
priv->device_category_filter = g_value_get_int (value);
@@ -751,7 +760,7 @@ bluetooth_device_selection_class_init (B
NULL, NULL, TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS(klass),
PROP_DEVICE_TYPE_FILTER, g_param_spec_int ("device-type-filter", NULL, NULL,
- 0, BLUETOOTH_TYPE_NUM_TYPES, 0, G_PARAM_READWRITE));
+ 1, 1 << (BLUETOOTH_TYPE_NUM_TYPES-1), 1, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS(klass),
PROP_DEVICE_CATEGORY_FILTER, g_param_spec_int ("device-category-filter", NULL, NULL,
0, BLUETOOTH_CATEGORY_NUM_CATEGORIES, 0, G_PARAM_READWRITE));
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 247 bytes --]
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
[-- Attachment #3: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-30 12:51 ` Michael Terry
@ 2008-06-30 12:57 ` Marcel Holtmann
2008-06-30 13:20 ` Michael Terry
0 siblings, 1 reply; 30+ messages in thread
From: Marcel Holtmann @ 2008-06-30 12:57 UTC (permalink / raw)
To: BlueZ development
Hi Michael,
> On Sat, 2008-06-28 at 00:23 +0200, Marcel Holtmann wrote:
> > looks nice. However you have to break this up into pieces for. Sent
> > small patches and I can quickly review and commit them.
>
> Here's one such piece of my wizard patch. It simply fixes the "device-type-filter" property to do something reasonable when set (namely, you give it a BLUETOOTH_TYPE and it sets the right index in the combo).
please use the coding style that is present in the file you are working
on. This includes whitespaces and indentation.
> More patches coming.
Send them over.
Regards
Marcel
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
[not found] ` <1214813891.4435.149.camel@cookie.hadess.net>
@ 2008-06-30 13:15 ` David Stockwell
2008-06-30 22:27 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 30+ messages in thread
From: David Stockwell @ 2008-06-30 13:15 UTC (permalink / raw)
To: BlueZ development
----- Original Message -----
From: "Bastien Nocera" <hadess@hadess.net>
To: "David Stockwell" <dstockwell@frequency-one.com>
Sent: Monday, June 30, 2008 3:18 AM
Subject: Re: [Bluez-devel] Wizard patch
> On Sun, 2008-06-29 at 20:03 -0500, David Stockwell wrote:
>> Out of curiosity, why not use C++ style (//) comments? Do you prefer
>> the older /*...*/ comments? Or is there some other reason.
>
> C++-style comments are for temporary comments. Almost all C codebases
> refuse to have C++-style comments in permanent code.
Fair enough. Also the case that C-compilers sometimes do not handle //
comments.
>
>> FWIW, it seems to me that most of the code (e.g, the DBus code) is
>> almost completely uncommented...hence very hard to figure out how
>> it actually works, or even how it is intended to work.
>
> There's documentation for D-Bus in */*.txt in bluez-utils. If the
> documentation isn't good enough, either send questions asking for
> clarifications, or patches.
I read the docs and when the code works as expected it is good enough.
However, I have had a number of problems making the code work (partially
implemented "experimental" 4.x features in release 3.33 and before).
Also, figuring out how to handle some of the formats (e.g., the "dict"
with variant) are a bit hard to figure out without a code example. SO,
I often have to dig into the actual code and figure out just what is
going on.
>
> BTW, could you please: reply to the list, quote properly, not
> top-post,
> and make sure lines are cut to 72 chars in length. I know it's hard
> using Outlook...
>
OK, I normally respond to the list (note that I have not contacted you
before, and will not again), but had a couple of questions about the
stylistic points you raised, which I had not seen before.
I think you will also see that this is plain text, cut to 72 chars.
Easy to do.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-27 22:23 ` Marcel Holtmann
2008-06-30 12:51 ` Michael Terry
@ 2008-06-30 13:15 ` Michael Terry
2008-06-30 14:06 ` Marcel Holtmann
2008-06-30 13:51 ` Michael Terry
2008-06-30 15:48 ` Michael Terry
3 siblings, 1 reply; 30+ messages in thread
From: Michael Terry @ 2008-06-30 13:15 UTC (permalink / raw)
To: BlueZ development
[-- Attachment #1.1.1: Type: text/plain, Size: 787 bytes --]
On Sat, 2008-06-28 at 00:23 +0200, Marcel Holtmann wrote:
> looks nice. However you have to break this up into pieces for. Sent
> small patches and I can quickly review and commit them.
Here's a patch to add callback support to many of the common/client
calls.
It also adds a new function: bluetooth_client_cancel_call(). This
cancels the last client call made for the given adapter/address.
Admittedly, it would be fancier if, for example,
bluetooth_client_create_bonding() gave back a handle which could be used
to cancel its call, rather than just keeping track of the last one.
But the cancel-last-call style was simpler and sufficient for the
wizard's purposes and presumably sufficient for others' purposes (by
virtue of the lack of canceling before).
-mt
[-- Attachment #1.1.2: callback.diff --]
[-- Type: text/x-patch, Size: 9501 bytes --]
Index: common/client.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/client.c,v
retrieving revision 1.44
diff -u -p -r1.44 client.c
--- common/client.c 12 Mar 2008 21:03:38 -0000 1.44
+++ common/client.c 30 Jun 2008 13:05:05 -0000
@@ -1112,14 +1112,29 @@ gboolean bluetooth_client_register_passk
return TRUE;
}
-static void create_bonding_reply(DBusGProxy *proxy,
+static void call_reply(DBusGProxy *proxy,
GError *error, gpointer userdata)
{
- //g_printf("create bonding reply\n");
+ DBusGAsyncData *data = (DBusGAsyncData*) userdata;
+ g_object_set_data(G_OBJECT(proxy), "call", NULL);
+ if (data) {
+ (*(bluetooth_client_call_reply)data->cb) (error, data->userdata);
+ g_free(data);
+ }
+ if (error)
+ g_error_free(error);
+}
+
+static void call_reply_s(DBusGProxy *proxy, char *s,
+ GError *error, gpointer userdata)
+{
+ call_reply(proxy, error, userdata);
}
gboolean bluetooth_client_create_bonding(BluetoothClient *client,
- gchar *adapter, const gchar *address)
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
GtkTreeIter iter;
@@ -1142,9 +1157,15 @@ gboolean bluetooth_client_create_bonding
COLUMN_OBJECT, &object, -1);
if (g_ascii_strcasecmp(path, adapter) == 0) {
- adapter_create_bonding_async(object, address,
- create_bonding_reply, NULL);
- return TRUE;
+ DBusGProxyCall *call;
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ call = adapter_create_bonding_async(object, address,
+ call_reply, stuff);
+ g_object_set_data(G_OBJECT(object), "call", call);
+ return call != NULL;
}
cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
@@ -1153,14 +1174,10 @@ gboolean bluetooth_client_create_bonding
return FALSE;
}
-static void remove_bonding_reply(DBusGProxy *proxy,
- GError *error, gpointer userdata)
-{
- //g_printf("remove bonding reply\n");
-}
-
gboolean bluetooth_client_remove_bonding(BluetoothClient *client,
- gchar *adapter, const gchar *address)
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
GtkTreeIter iter;
@@ -1183,8 +1200,14 @@ gboolean bluetooth_client_remove_bonding
COLUMN_OBJECT, &object, -1);
if (g_ascii_strcasecmp(path, adapter) == 0) {
- adapter_remove_bonding_async(object, address,
- remove_bonding_reply, NULL);
+ DBusGProxyCall *call;
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ call = adapter_remove_bonding_async(object, address,
+ call_reply, stuff);
+ g_object_set_data(G_OBJECT(object), "call", call);
return TRUE;
}
@@ -1194,14 +1217,10 @@ gboolean bluetooth_client_remove_bonding
return FALSE;
}
-static void set_trusted_reply(DBusGProxy *proxy,
- GError *error, gpointer userdata)
-{
- //g_printf("set trusted reply\n");
-}
-
gboolean bluetooth_client_set_trusted(BluetoothClient *client,
- gchar *adapter, const gchar *address)
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
GtkTreeIter iter;
@@ -1224,8 +1243,14 @@ gboolean bluetooth_client_set_trusted(Bl
COLUMN_OBJECT, &object, -1);
if (g_ascii_strcasecmp(path, adapter) == 0) {
- adapter_set_trusted_async(object, address,
- set_trusted_reply, NULL);
+ DBusGProxyCall *call;
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ call = adapter_set_trusted_async(object, address,
+ call_reply, stuff);
+ g_object_set_data(G_OBJECT(object), "call", call);
return TRUE;
}
@@ -1235,14 +1260,10 @@ gboolean bluetooth_client_set_trusted(Bl
return FALSE;
}
-static void remove_trust_reply(DBusGProxy *proxy,
- GError *error, gpointer userdata)
-{
- //g_printf("remove trust reply\n");
-}
-
gboolean bluetooth_client_remove_trust(BluetoothClient *client,
- gchar *adapter, const gchar *address)
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
GtkTreeIter iter;
@@ -1265,8 +1286,14 @@ gboolean bluetooth_client_remove_trust(B
COLUMN_OBJECT, &object, -1);
if (g_ascii_strcasecmp(path, adapter) == 0) {
- adapter_remove_trust_async(object, address,
- remove_trust_reply, NULL);
+ DBusGProxyCall *call;
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ call = adapter_remove_trust_async(object, address,
+ call_reply, stuff);
+ g_object_set_data(G_OBJECT(object), "call", call);
return TRUE;
}
@@ -1386,6 +1413,46 @@ gboolean bluetooth_client_cancel_discove
return FALSE;
}
+gboolean bluetooth_client_cancel_call(BluetoothClient *client,
+ gchar *adapter, const gchar *address)
+{
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ GtkTreeIter iter;
+ gboolean cont;
+
+ if (adapter == NULL)
+ adapter = priv->default_adapter;
+
+ if (adapter == NULL)
+ return FALSE;
+
+ cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store), &iter);
+
+ while (cont == TRUE) {
+ DBusGProxy *object;
+ gchar *path;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+ COLUMN_PATH, &path,
+ COLUMN_OBJECT, &object, -1);
+
+ if (g_ascii_strcasecmp(path, adapter) == 0) {
+ DBusGProxyCall *call;
+ call = (DBusGProxyCall *)g_object_get_data(G_OBJECT(object), "call");
+ if (call != NULL) {
+ dbus_g_proxy_cancel_call(object, call);
+ g_object_set_data(G_OBJECT(object), "call", NULL);
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+ cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
+ }
+
+ return FALSE;
+}
+
GtkTreeModel *bluetooth_client_get_model(BluetoothClient *client)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
Index: common/client.h
===================================================================
RCS file: /cvsroot/bluez/gnome/common/client.h,v
retrieving revision 1.24
diff -u -p -r1.24 client.h
--- common/client.h 6 Mar 2008 10:54:29 -0000 1.24
+++ common/client.h 30 Jun 2008 13:05:05 -0000
@@ -99,14 +99,26 @@ const gchar *bluetooth_type_to_string(gu
gboolean bluetooth_client_register_passkey_agent(BluetoothClient *self,
const char *path, const char *address, const void *info);
-gboolean bluetooth_client_create_bonding(BluetoothClient *self,
+typedef void (*bluetooth_client_call_reply) (GError *error, gpointer data);
+
+gboolean bluetooth_client_cancel_call(BluetoothClient *self,
gchar *adapter, const gchar *address);
+gboolean bluetooth_client_create_bonding(BluetoothClient *self,
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
gboolean bluetooth_client_remove_bonding(BluetoothClient *self,
- gchar *adapter, const gchar *address);
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
gboolean bluetooth_client_set_trusted(BluetoothClient *self,
- gchar *adapter, const gchar *address);
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
gboolean bluetooth_client_remove_trust(BluetoothClient *self,
- gchar *adapter, const gchar *address);
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
gboolean bluetooth_client_disconnect(BluetoothClient *self,
gchar *adapter, const gchar *address);
Index: properties/adapter.c
===================================================================
RCS file: /cvsroot/bluez/gnome/properties/adapter.c,v
retrieving revision 1.22
diff -u -p -r1.22 adapter.c
--- properties/adapter.c 11 Feb 2008 14:34:37 -0000 1.22
+++ properties/adapter.c 30 Jun 2008 13:05:06 -0000
@@ -317,7 +317,7 @@ static void delete_callback(GtkWidget *b
gtk_tree_model_get(model, &iter, COLUMN_ADDRESS, &address, -1);
if (show_confirm_dialog() == TRUE)
- bluetooth_client_remove_bonding(client, adapter->path, address);
+ bluetooth_client_remove_bonding(client, adapter->path, address, NULL, NULL);
g_free(address);
}
@@ -338,9 +338,9 @@ static void trusted_callback(GtkWidget *
COLUMN_TRUSTED, &trusted, -1);
if (trusted == FALSE)
- bluetooth_client_set_trusted(client, adapter->path, address);
+ bluetooth_client_set_trusted(client, adapter->path, address, NULL, NULL);
else
- bluetooth_client_remove_trust(client, adapter->path, address);
+ bluetooth_client_remove_trust(client, adapter->path, address, NULL, NULL);
g_free(address);
}
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 247 bytes --]
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
[-- Attachment #3: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-30 12:57 ` Marcel Holtmann
@ 2008-06-30 13:20 ` Michael Terry
2008-06-30 14:07 ` Marcel Holtmann
0 siblings, 1 reply; 30+ messages in thread
From: Michael Terry @ 2008-06-30 13:20 UTC (permalink / raw)
To: BlueZ development
[-- Attachment #1.1.1: Type: text/plain, Size: 320 bytes --]
On Mon, 2008-06-30 at 14:57 +0200, Marcel Holtmann wrote:
> please use the coding style that is present in the file you are
> working
> on. This includes whitespaces and indentation.
Sure. I thought I did, but I missed a tab, which is what I assume you
were referring to?
Tab-complete patch attached.
-mt
[-- Attachment #1.1.2: selector2.diff --]
[-- Type: text/x-patch, Size: 2307 bytes --]
Index: common/bluetooth-device-selection.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/bluetooth-device-selection.c,v
retrieving revision 1.23
diff -u -p -r1.23 bluetooth-device-selection.c
--- common/bluetooth-device-selection.c 30 Jun 2008 07:59:29 -0000 1.23
+++ common/bluetooth-device-selection.c 30 Jun 2008 13:17:43 -0000
@@ -91,6 +91,15 @@ bluetooth_device_category_to_string (int
}
}
+static int
+int_log2(int v)
+{
+ int rv = 0;
+ while (v >>= 1)
+ rv++;
+ return rv;
+}
+
static void
name_to_text (GtkTreeViewColumn *column, GtkCellRenderer *cell,
GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
@@ -609,7 +618,7 @@ bluetooth_device_selection_init(Bluetoot
}
g_signal_connect (G_OBJECT (priv->device_type), "changed",
G_CALLBACK(filter_type_changed_cb), self);
- gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), priv->device_type_filter);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), int_log2(priv->device_type_filter));
if (priv->show_device_type) {
gtk_widget_show (priv->device_type_label);
gtk_widget_show (priv->device_type);
@@ -696,7 +705,7 @@ bluetooth_device_selection_set_property
break;
case PROP_DEVICE_TYPE_FILTER:
priv->device_type_filter = g_value_get_int (value);
- gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), priv->device_type_filter >> 1);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), int_log2(priv->device_type_filter));
break;
case PROP_DEVICE_CATEGORY_FILTER:
priv->device_category_filter = g_value_get_int (value);
@@ -788,7 +797,7 @@ bluetooth_device_selection_class_init (B
NULL, NULL, TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS(klass),
PROP_DEVICE_TYPE_FILTER, g_param_spec_int ("device-type-filter", NULL, NULL,
- 0, BLUETOOTH_TYPE_NUM_TYPES, 0, G_PARAM_READWRITE));
+ 1, 1 << (BLUETOOTH_TYPE_NUM_TYPES-1), 1, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS(klass),
PROP_DEVICE_CATEGORY_FILTER, g_param_spec_int ("device-category-filter", NULL, NULL,
0, BLUETOOTH_CATEGORY_NUM_CATEGORIES, 0, G_PARAM_READWRITE));
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 247 bytes --]
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
[-- Attachment #3: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-27 22:23 ` Marcel Holtmann
2008-06-30 12:51 ` Michael Terry
2008-06-30 13:15 ` Michael Terry
@ 2008-06-30 13:51 ` Michael Terry
2008-06-30 19:58 ` Michael Terry
2008-07-01 1:16 ` Marcel Holtmann
2008-06-30 15:48 ` Michael Terry
3 siblings, 2 replies; 30+ messages in thread
From: Michael Terry @ 2008-06-30 13:51 UTC (permalink / raw)
To: BlueZ development
[-- Attachment #1.1.1: Type: text/plain, Size: 971 bytes --]
On Sat, 2008-06-28 at 00:23 +0200, Marcel Holtmann wrote:
> looks nice. However you have to break this up into pieces for. Sent
> small patches and I can quickly review and commit them.
Here's a patch to add support for connecting to devices via the client code. This patch depends on the callback patch.
It finds known services on startup (in setup_services()). Bastien
suggested that we don't need to call setup_services() since those
services are enabled by default, but I'm not quite sure what he meant.
We need to call it to get the service bus IDs so that we can then get
DBusGProxies for them.
It adds the function bluetooth_client_available_services() which gives
back a type mask for services that were detected. Basically which
devices are likely to succeed from a bluetooth_client_connect() call.
bluetooth_client_connect() does device-specific connection handling.
It only handles a few types right now (input and headset).
-mt
[-- Attachment #1.1.2: services.diff --]
[-- Type: text/x-patch, Size: 7428 bytes --]
diff -upr ../bluez-gnome-callback/common/client.c ./common/client.c
--- ../bluez-gnome-callback/common/client.c 2008-06-30 09:04:57.000000000 -0400
+++ ./common/client.c 2008-06-30 09:35:52.000000000 -0400
@@ -48,6 +48,8 @@ struct _BluetoothClientPrivate {
DBusGConnection *conn;
DBusGProxy *manager_object;
+ DBusGProxy *input_service;
+ DBusGProxy *audio_service;
GtkTreeStore *store;
gchar *default_adapter;
};
@@ -935,6 +937,33 @@ static void setup_manager(BluetoothClien
g_error_free(error);
}
+static void setup_services(BluetoothClient *client)
+{
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ gchar *busname = NULL;
+
+ priv->input_service = NULL;
+ priv->audio_service = NULL;
+
+ if (dbus_g_proxy_call(priv->manager_object, "ActivateService", NULL,
+ G_TYPE_STRING, "input", G_TYPE_INVALID,
+ G_TYPE_STRING, &busname, G_TYPE_INVALID)) {
+ priv->input_service = dbus_g_proxy_new_for_name(priv->conn, busname,
+ "/org/bluez/input",
+ "org.bluez.input.Manager");
+ g_free(busname);
+ }
+
+ if (dbus_g_proxy_call(priv->manager_object, "ActivateService", NULL,
+ G_TYPE_STRING, "audio", G_TYPE_INVALID,
+ G_TYPE_STRING, &busname, G_TYPE_INVALID)) {
+ priv->audio_service = dbus_g_proxy_new_for_name(priv->conn, busname,
+ "/org/bluez/audio",
+ "org.bluez.audio.Manager");
+ g_free(busname);
+ }
+}
+
static void name_owner_changed(DBusGProxy *object, const char *name,
const char *prev, const char *new, gpointer user_data)
{
@@ -984,6 +1013,8 @@ static void bluetooth_client_finalize(GO
g_free(priv->default_adapter);
g_object_unref(G_OBJECT(priv->store));
g_object_unref (priv->manager_object);
+ g_object_unref (priv->input_service);
+ g_object_unref (priv->audio_service);
}
static void bluetooth_client_init(BluetoothClient *client)
@@ -1000,6 +1031,8 @@ static void bluetooth_client_init(Blueto
setup_dbus(client);
setup_manager(client);
+
+ setup_services(client);
}
static void bluetooth_client_set_property(GObject *object, guint prop_id,
@@ -1085,6 +1118,19 @@ BluetoothClient *bluetooth_client_new(vo
}
}
+int bluetooth_client_available_services(BluetoothClient *client)
+{
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ int rv = 0;
+
+ if (priv->input_service)
+ rv |= BLUETOOTH_TYPE_INPUT;
+ if (priv->audio_service)
+ rv |= BLUETOOTH_TYPE_HEADSET;
+
+ return rv;
+}
+
gboolean bluetooth_client_register_passkey_agent(BluetoothClient *client,
const char *path, const char *address, const void *info)
{
@@ -1131,6 +1177,89 @@ static void call_reply_s(DBusGProxy *pro
call_reply(proxy, error, userdata);
}
+static gboolean connect_to_service(BluetoothClient *client, DBusGProxy *object,
+ const gchar *address, guint type,
+ gpointer userdata)
+{
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ DBusGProxyCall *call = NULL;
+
+ /* Special case the few types we can handle */
+ if (type & BLUETOOTH_TYPE_INPUT)
+ call = input_create_secure_device_async(priv->input_service, address,
+ call_reply_s, userdata);
+ else if (type & BLUETOOTH_TYPE_HEADSET)
+ call = audio_create_headset_async(priv->audio_service, address,
+ call_reply_s, userdata);
+
+ g_object_set_data(G_OBJECT(object), "call", call);
+ return call != NULL;
+}
+
+gboolean bluetooth_client_connect(BluetoothClient *client, guint type,
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
+{
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ GtkTreeIter iter;
+ gboolean cont;
+
+ if (adapter == NULL)
+ adapter = priv->default_adapter;
+
+ if (adapter == NULL)
+ return FALSE;
+
+ cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store), &iter);
+
+ while (cont == TRUE) {
+ DBusGProxy *object;
+ gchar *path;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+ COLUMN_PATH, &path,
+ COLUMN_OBJECT, &object, -1);
+
+ if (g_ascii_strcasecmp(path, adapter) == 0) {
+ DBusGAsyncData *stuff;
+ gboolean cont;
+ GtkTreeIter child;
+
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+
+ /* If caller didn't specify a forced type, determine it from device info */
+ if (type == 0 || type == BLUETOOTH_TYPE_ANY) {
+ cont = gtk_tree_model_iter_children(GTK_TREE_MODEL(priv->store),
+ &child, &iter);
+
+ while (cont == TRUE) {
+ gchar *value;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &child,
+ COLUMN_ADDRESS, &value, -1);
+
+ if (g_ascii_strcasecmp(address, value) == 0) {
+ gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &child,
+ COLUMN_TYPE, &type, -1);
+ break;
+ }
+
+ cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &child);
+ }
+ }
+
+ return connect_to_service(client, object, address, type, stuff);
+ }
+
+ cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
+ }
+
+ return FALSE;
+}
+
gboolean bluetooth_client_create_bonding(BluetoothClient *client,
gchar *adapter, const gchar *address,
bluetooth_client_call_reply callback,
diff -upr ../bluez-gnome-callback/common/client.h ./common/client.h
--- ../bluez-gnome-callback/common/client.h 2008-06-30 09:03:44.000000000 -0400
+++ ./common/client.h 2008-06-30 09:43:13.000000000 -0400
@@ -101,8 +101,16 @@ gboolean bluetooth_client_register_passk
typedef void (*bluetooth_client_call_reply) (GError *error, gpointer data);
+int bluetooth_client_available_services(BluetoothClient *self);
+
gboolean bluetooth_client_cancel_call(BluetoothClient *self,
gchar *adapter, const gchar *address);
+
+/* Set 'type' to non-zero to force a certain type connection -- useful for dumb devices */
+gboolean bluetooth_client_connect(BluetoothClient *self, guint type,
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
gboolean bluetooth_client_create_bonding(BluetoothClient *self,
gchar *adapter, const gchar *address,
bluetooth_client_call_reply callback,
diff -upr ../bluez-gnome-callback/common/dbus.xml ./common/dbus.xml
--- ../bluez-gnome-callback/common/dbus.xml 2008-06-30 08:55:31.000000000 -0400
+++ ./common/dbus.xml 2008-06-30 09:38:59.000000000 -0400
@@ -98,4 +98,20 @@
<arg type="s" name="address"/>
</method>
</interface>
+
+ <interface name="input">
+ <method name="CreateSecureDevice">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="s" name="address"/>
+ <arg type="s" direction="out"/>
+ </method>
+ </interface>
+
+ <interface name="audio">
+ <method name="CreateHeadset">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="s" name="address"/>
+ <arg type="s" direction="out"/>
+ </method>
+ </interface>
</node>
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 247 bytes --]
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
[-- Attachment #3: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-30 13:15 ` Michael Terry
@ 2008-06-30 14:06 ` Marcel Holtmann
2008-06-30 15:57 ` Michael Terry
0 siblings, 1 reply; 30+ messages in thread
From: Marcel Holtmann @ 2008-06-30 14:06 UTC (permalink / raw)
To: BlueZ development
Hi Michael,
> > looks nice. However you have to break this up into pieces for. Sent
> > small patches and I can quickly review and commit them.
>
> Here's a patch to add callback support to many of the common/client
> calls.
>
> It also adds a new function: bluetooth_client_cancel_call(). This
> cancels the last client call made for the given adapter/address.
>
> Admittedly, it would be fancier if, for example,
> bluetooth_client_create_bonding() gave back a handle which could be used
> to cancel its call, rather than just keeping track of the last one.
it only makes sense for the create bonding call, because the others
can't really be canceled. So my proposal is to leave the others out of
this change and implement create_bonding and cancel_bonding.
Regards
Marcel
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-30 13:20 ` Michael Terry
@ 2008-06-30 14:07 ` Marcel Holtmann
0 siblings, 0 replies; 30+ messages in thread
From: Marcel Holtmann @ 2008-06-30 14:07 UTC (permalink / raw)
To: BlueZ development
Hi Michael,
> > please use the coding style that is present in the file you are
> > working
> > on. This includes whitespaces and indentation.
>
> Sure. I thought I did, but I missed a tab, which is what I assume you
> were referring to?
>
> Tab-complete patch attached.
there was one SOMETHING-1 where you should have done SOMETHING - 1. I
fixed that and the patch has been committed.
Regards
Marcel
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-27 22:23 ` Marcel Holtmann
` (2 preceding siblings ...)
2008-06-30 13:51 ` Michael Terry
@ 2008-06-30 15:48 ` Michael Terry
2008-07-01 1:24 ` Marcel Holtmann
3 siblings, 1 reply; 30+ messages in thread
From: Michael Terry @ 2008-06-30 15:48 UTC (permalink / raw)
To: BlueZ development
[-- Attachment #1.1.1: Type: text/plain, Size: 980 bytes --]
On Sat, 2008-06-28 at 00:23 +0200, Marcel Holtmann wrote:
> looks nice. However you have to break this up into pieces for. Sent
> small patches and I can quickly review and commit them.
And here's the actual wizard UI patch. It's a bit large, but not
terribly break-down-able.
It adds the passkey code for the UI and modifies the UI a bit, as I
mentioned in previous emails.
It also adds a call to the client code to get an address's user-visible
name from its path.
Bastien suggested that the applet label to launch the wizard should
continue to be "Setup" and not "Connect" because we may want to do more
setup for certain device types in the future. That may be true, but
some of that would be automatic (like the SyncML example he cited) and
so wouldn't be visible from the user's perspective.
Even if we did add a page for some sort of device configuration, I
maintain that the overriding user metaphor will be connecting not
configuring.
-mt
[-- Attachment #1.1.2: wizard-ui.diff --]
[-- Type: text/x-patch, Size: 27573 bytes --]
diff -uprN ../bluez-gnome-services/applet/main.c ./applet/main.c
--- ../bluez-gnome-services/applet/main.c 2008-06-30 09:27:23.000000000 -0400
+++ ./applet/main.c 2008-06-30 09:56:45.000000000 -0400
@@ -625,7 +625,6 @@ static void sendto_callback(GObject *wid
g_printerr("Couldn't execute command: %s\n", command);
}
-#if 0
static void wizard_callback(GObject *widget, gpointer user_data)
{
const char *command = "bluetooth-wizard --singleton";
@@ -633,7 +632,6 @@ static void wizard_callback(GObject *wid
if (!g_spawn_command_line_async(command, NULL))
g_printerr("Couldn't execute command: %s\n", command);
}
-#endif
static void activate_callback(GObject *widget, gpointer user_data)
{
@@ -697,17 +695,15 @@ static GtkWidget *create_popupmenu(void)
menuitem_browse = item;
-#if 0
item = gtk_separator_menu_item_new();
gtk_widget_show(item);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
- item = gtk_menu_item_new_with_label(_("Setup New Device"));
+ item = gtk_menu_item_new_with_label(_("Connect New Device..."));
g_signal_connect(item, "activate",
G_CALLBACK(wizard_callback), NULL);
gtk_widget_show(item);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-#endif
return menu;
}
diff -uprN ../bluez-gnome-services/common/client.c ./common/client.c
--- ../bluez-gnome-services/common/client.c 2008-06-30 09:35:52.000000000 -0400
+++ ./common/client.c 2008-06-30 09:58:23.000000000 -0400
@@ -1118,6 +1118,37 @@ BluetoothClient *bluetooth_client_new(vo
}
}
+gchar *bluetooth_client_get_name(BluetoothClient *self, const gchar *adapter)
+{
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(self);
+ GtkTreeIter iter;
+ gboolean cont;
+
+ if (adapter == NULL)
+ adapter = priv->default_adapter;
+
+ if (adapter == NULL)
+ return NULL;
+
+ cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store), &iter);
+
+ while (cont == TRUE) {
+ gchar *path;
+ gchar *name;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+ COLUMN_PATH, &path,
+ COLUMN_NAME, &name, -1);
+
+ if (g_ascii_strcasecmp(path, adapter) == 0)
+ return g_strdup(name);
+
+ cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
+ }
+
+ return NULL;
+}
+
int bluetooth_client_available_services(BluetoothClient *client)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
diff -uprN ../bluez-gnome-services/common/client.h ./common/client.h
--- ../bluez-gnome-services/common/client.h 2008-06-30 09:44:06.000000000 -0400
+++ ./common/client.h 2008-06-30 09:58:19.000000000 -0400
@@ -135,6 +135,8 @@ gboolean bluetooth_client_discover_devic
gboolean bluetooth_client_cancel_discovery(BluetoothClient *self, gchar *adapter);
+gchar *bluetooth_client_get_name(BluetoothClient *self, const gchar *adapter);
+
GtkTreeModel *bluetooth_client_get_model(BluetoothClient *self);
GtkTreeModel *bluetooth_client_get_model_simple(BluetoothClient *self);
GtkTreeModel *bluetooth_client_get_model_adapter_list(BluetoothClient *self);
diff -uprN ../bluez-gnome-services/wizard/agent.c ./wizard/agent.c
--- ../bluez-gnome-services/wizard/agent.c 1969-12-31 19:00:00.000000000 -0500
+++ ./wizard/agent.c 2008-06-30 10:01:52.000000000 -0400
@@ -0,0 +1,340 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2005-2008 Marcel Holtmann <marcel@holtmann.org>
+ * Copyright (C) 2006-2007 Bastien Nocera <hadess@hadess.net>
+ *
+ *
+ * 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 <dbus/dbus-glib.h>
+
+#include <glib/gi18n.h>
+
+#include <gtk/gtk.h>
+
+#include "agent.h"
+
+static GtkWidget *main_dialog;
+
+typedef enum {
+ AGENT_ERROR_REJECT
+} AgentError;
+
+#define AGENT_ERROR (agent_error_quark())
+
+#define AGENT_ERROR_TYPE (agent_error_get_type())
+
+static GQuark agent_error_quark(void)
+{
+ static GQuark quark = 0;
+ if (!quark)
+ quark = g_quark_from_static_string("agent");
+
+ return quark;
+}
+
+static GList *input_list = NULL;
+
+struct input_data {
+ char *path;
+ char *address;
+ char *service;
+ char *uuid;
+ DBusGMethodInvocation *context;
+ GtkWidget *dialog;
+ GtkWidget *button;
+ GtkWidget *entry;
+};
+
+static gint input_compare(gconstpointer a, gconstpointer b)
+{
+ struct input_data *a_data = (struct input_data *) a;
+ struct input_data *b_data = (struct input_data *) b;
+
+ return g_ascii_strcasecmp(a_data->address, b_data->address);
+}
+
+static void input_free(struct input_data *input)
+{
+ gtk_widget_destroy(input->dialog);
+
+ g_free(input->uuid);
+ g_free(input->service);
+ g_free(input->address);
+ g_free(input->path);
+ g_free(input);
+}
+
+static void passkey_callback(GtkWidget *dialog,
+ gint response, gpointer user_data)
+{
+ struct input_data *input = user_data;
+
+ if (response == GTK_RESPONSE_ACCEPT) {
+ const char *passkey;
+ passkey = gtk_entry_get_text(GTK_ENTRY(input->entry));
+ dbus_g_method_return(input->context, passkey);
+ } else {
+ GError *error;
+ error = g_error_new(AGENT_ERROR, AGENT_ERROR_REJECT,
+ _("Pairing request rejected"));
+ dbus_g_method_return_error(input->context, error);
+ }
+
+ input_free(input);
+}
+
+static void changed_callback(GtkWidget *editable, gpointer user_data)
+{
+ struct input_data *input = user_data;
+ const gchar *text;
+
+ text = gtk_entry_get_text(GTK_ENTRY(input->entry));
+
+ gtk_widget_set_sensitive(input->button, *text != '\0' ? TRUE : FALSE);
+}
+
+static void toggled_callback(GtkWidget *button, gpointer user_data)
+{
+ struct input_data *input = user_data;
+ gboolean mode;
+
+ mode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
+
+ gtk_entry_set_visibility(GTK_ENTRY(input->entry), mode);
+}
+
+static void passkey_dialog(const char *path, const char *address,
+ const gchar *device, DBusGMethodInvocation *context)
+{
+ GtkWidget *dialog;
+ GtkWidget *button;
+ GtkWidget *image;
+ GtkWidget *label;
+ GtkWidget *entry;
+ GtkWidget *table;
+ GtkWidget *vbox;
+ struct input_data *input;
+ gchar *markup;
+
+ input = g_try_malloc0(sizeof(*input));
+ if (!input)
+ return;
+
+ input->path = g_strdup(path);
+ input->address = g_strdup(address);
+
+ input->context = context;
+
+ dialog = gtk_dialog_new();
+
+ gtk_window_set_title(GTK_WINDOW(dialog), _("Authentication request"));
+
+ gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
+
+ gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
+
+ gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
+
+ gtk_window_set_urgency_hint(GTK_WINDOW(dialog), TRUE);
+
+ gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
+
+ gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(main_dialog));
+
+ input->dialog = dialog;
+
+ button = gtk_dialog_add_button(GTK_DIALOG(dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
+
+ button = gtk_dialog_add_button(GTK_DIALOG(dialog),
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT);
+
+ gtk_widget_grab_default(button);
+
+ gtk_widget_set_sensitive(button, FALSE);
+
+ input->button = button;
+
+ table = gtk_table_new(5, 2, FALSE);
+
+ gtk_table_set_row_spacings(GTK_TABLE(table), 4);
+ gtk_table_set_col_spacings(GTK_TABLE(table), 20);
+
+ gtk_container_set_border_width(GTK_CONTAINER(table), 12);
+
+ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
+
+ image = gtk_image_new_from_icon_name(GTK_STOCK_DIALOG_AUTHENTICATION,
+ GTK_ICON_SIZE_DIALOG);
+
+ gtk_misc_set_alignment(GTK_MISC(image), 0.0, 0.0);
+
+ gtk_table_attach(GTK_TABLE(table), image, 0, 1, 0, 5,
+ GTK_SHRINK, GTK_FILL, 0, 0);
+
+ vbox = gtk_vbox_new(FALSE, 6);
+
+ label = gtk_label_new(_("Pairing request for device:"));
+
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+
+ gtk_container_add(GTK_CONTAINER(vbox), label);
+
+ gtk_table_attach(GTK_TABLE(table), vbox, 1, 2, 0, 1,
+ GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+
+ label = gtk_label_new(NULL);
+
+ markup = g_strdup_printf("<b>%s</b>", device);
+ gtk_label_set_markup(GTK_LABEL(label), markup);
+ g_free(markup);
+
+ gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
+
+ gtk_label_set_selectable(GTK_LABEL(label), TRUE);
+
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+
+ gtk_widget_set_size_request(GTK_WIDGET(label), 280, -1);
+
+ gtk_container_add(GTK_CONTAINER(vbox), label);
+
+ vbox = gtk_vbox_new(FALSE, 6);
+
+ label = gtk_label_new(_("Enter passkey for authentication:"));
+
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+
+ gtk_container_add(GTK_CONTAINER(vbox), label);
+
+ gtk_table_attach(GTK_TABLE(table), vbox, 1, 2, 2, 3,
+ GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+
+ entry = gtk_entry_new();
+
+ gtk_entry_set_max_length(GTK_ENTRY(entry), 16);
+
+ gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
+
+ gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
+
+ input->entry = entry;
+
+ g_signal_connect(G_OBJECT(entry), "changed",
+ G_CALLBACK(changed_callback), input);
+
+ gtk_container_add(GTK_CONTAINER(vbox), entry);
+
+ button = gtk_check_button_new_with_label(_("Show input"));
+
+ g_signal_connect(G_OBJECT(button), "toggled",
+ G_CALLBACK(toggled_callback), input);
+
+ gtk_container_add(GTK_CONTAINER(vbox), button);
+
+ input_list = g_list_append(input_list, input);
+ gtk_widget_show_all(dialog);
+ gtk_window_present(GTK_WINDOW(dialog));
+
+ g_signal_connect(G_OBJECT(dialog), "response",
+ G_CALLBACK(passkey_callback), input);
+}
+
+static gboolean passkey_agent_request(GObject *agent,
+ const char *path, const char *address,
+ DBusGMethodInvocation *context)
+{
+ BluetoothClient *client = BLUETOOTH_CLIENT(agent);
+ const char *name = NULL;
+ gchar *device;
+
+ name = bluetooth_client_get_name(client, path);
+
+ if (name) {
+ if (g_strrstr(name, address))
+ device = g_strdup(name);
+ else
+ device = g_strdup_printf("%s (%s)", name, address);
+ } else
+ device = g_strdup(address);
+
+ passkey_dialog(path, address, device, context);
+
+ g_free(device);
+ return TRUE;
+}
+
+static gboolean passkey_agent_cancel(GObject *agent,
+ const char *path, const char *address, GError **error)
+{
+ GList *list;
+ GError *result;
+ struct input_data *input;
+
+ input = g_try_malloc0(sizeof(*input));
+ if (!input)
+ return FALSE;
+
+ input->path = g_strdup(path);
+ input->address = g_strdup(address);
+
+ list = g_list_find_custom(input_list, input, input_compare);
+
+ g_free(input->address);
+ g_free(input->path);
+ g_free(input);
+
+ if (!list || !list->data)
+ return FALSE;
+
+ input = list->data;
+
+ result = g_error_new(AGENT_ERROR, AGENT_ERROR_REJECT,
+ _("Agent callback canceled"));
+
+ dbus_g_method_return_error(input->context, result);
+
+ input_free(input);
+
+ return TRUE;
+}
+
+static gboolean passkey_agent_release(GObject *agent, GError **error)
+{
+ return TRUE;
+}
+
+#include "passkey-agent-glue.h"
+
+void set_agent_parent_window(GtkWidget *window)
+{
+ main_dialog = window;
+}
+
+gboolean register_agent(BluetoothClient *client,
+ const char *path, const char *address)
+{
+ return bluetooth_client_register_passkey_agent(client, path, address, &dbus_glib_passkey_agent_object_info);
+}
+
diff -uprN ../bluez-gnome-services/wizard/agent.h ./wizard/agent.h
--- ../bluez-gnome-services/wizard/agent.h 1969-12-31 19:00:00.000000000 -0500
+++ ./wizard/agent.h 2008-06-30 09:56:45.000000000 -0400
@@ -0,0 +1,30 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2005-2008 Marcel Holtmann <marcel@holtmann.org>
+ * Copyright (C) 2006-2007 Bastien Nocera <hadess@hadess.net>
+ *
+ *
+ * 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
+ *
+ */
+
+#include <gtk/gtk.h>
+#include "client.h"
+
+void set_agent_parent_window(GtkWidget *window);
+int register_agent(BluetoothClient *client, const char *path, const char *address);
+
diff -uprN ../bluez-gnome-services/wizard/main.c ./wizard/main.c
--- ../bluez-gnome-services/wizard/main.c 2008-06-30 09:27:23.000000000 -0400
+++ ./wizard/main.c 2008-06-30 10:04:29.000000000 -0400
@@ -32,6 +32,7 @@
#include <gtk/gtk.h>
#include "client.h"
+#include "agent.h"
#include "dbus-glue.h"
@@ -41,93 +42,140 @@
static gboolean singleton = FALSE;
static BluetoothClient *client;
+static DBusGProxyCall *call = NULL;
static gchar *address = NULL;
-static gchar *passkey = "123456";
+static GtkWidget *page_prev = NULL;
static GtkWidget *page_search = NULL;
-static GtkWidget *page_info = NULL;
static GtkWidget *page_pairing = NULL;
+static GtkWidget *page_info = NULL;
static GtkWidget *page_summary = NULL;
+static int page_summary_num = 0;
-static GtkWidget *label_pairing = NULL;
-static GtkWidget *label_passkey = NULL;
+static GtkWidget *pairing_progress = NULL;
+static guint pairing_progress_timeout = 0;
+static GtkWidget *pairing_message = NULL;
+static GSList *type_group = NULL;
static GtkWidget *selector = NULL;
-static gboolean passkey_agent_request(GObject *agent,
- const char *path, const char *address,
- DBusGMethodInvocation *context)
-{
- const char *value = passkey;
-
- /* Apple Wireless and Mighty Mouse */
- if (g_str_has_prefix(address, "00:0A:95:") == TRUE ||
- g_str_has_prefix(address, "00:14:51:") == TRUE)
- value = "0000";
-
- dbus_g_method_return(context, value);
+static void close_callback(GtkWidget *assistant, gpointer data)
+{
+ gtk_widget_destroy(assistant);
- return TRUE;
+ gtk_main_quit();
}
-static gboolean passkey_agent_cancel(GObject *agent,
- const char *path, const char *address, GError **error)
+static void cancel_callback(GtkWidget *assistant, gpointer data)
{
- return TRUE;
+ gtk_widget_destroy(assistant);
+
+ gtk_main_quit();
}
-static gboolean passkey_agent_release(GObject *agent, GError **error)
+static gint selected_type(void)
{
- return TRUE;
+ GSList *iter;
+ for (iter = type_group; iter; iter = iter->next) {
+ GtkToggleButton *button = GTK_TOGGLE_BUTTON(iter->data);
+ if (gtk_toggle_button_get_active(button)) {
+ gpointer data = g_object_get_data(G_OBJECT(button), "bluez-type");
+ return GPOINTER_TO_INT(data);
+ }
+ }
+ return BLUETOOTH_TYPE_ANY;
}
+
+static void show_pairing_error(GError *error)
+{
+ gchar *msg;
+ const gchar *errmsg;
-#include "passkey-agent-glue.h"
+ gtk_widget_hide(pairing_progress);
+ if (pairing_progress_timeout > 0) {
+ g_source_remove(pairing_progress_timeout);
+ pairing_progress_timeout = 0;
+ }
-#if 0
-static gint page_forward(gint current_page, gpointer data)
-{
- return current_page + 1;
+ if (!error)
+ errmsg = _("Could not contact bluetooth service");
+ else
+ errmsg = error->message;
+
+ msg = g_strdup_printf("<b>%s</b>\n\n%s", _("Cannot connect to device:"), errmsg);
+ gtk_label_set_markup(GTK_LABEL(pairing_message), msg);
+ gtk_widget_show(pairing_message);
+ g_free(msg);
}
-#endif
-static void close_callback(GtkWidget *assistant, gpointer data)
+static void trusted_callback(GError *error, gpointer data)
{
- gtk_widget_destroy(assistant);
+ GtkAssistant *assistant = GTK_ASSISTANT(data);
- gtk_main_quit();
+ gtk_widget_hide(pairing_progress);
+ if (pairing_progress_timeout > 0) {
+ g_source_remove(pairing_progress_timeout);
+ pairing_progress_timeout = 0;
+ }
+
+ if (error) {
+ show_pairing_error(error);
+ }
+ else {
+ gtk_assistant_set_page_complete(assistant, page_pairing, TRUE);
+ gtk_assistant_set_current_page(assistant, page_summary_num); /* jump to summary */
+ }
}
-static void cancel_callback(GtkWidget *assistant, gpointer data)
+static void connect_callback(GError *error, gpointer data)
{
- gtk_widget_destroy(assistant);
+ if (error || !bluetooth_client_set_trusted(client, NULL, address, trusted_callback, data))
+ show_pairing_error(error);
+}
- gtk_main_quit();
+static gboolean pulse_progress(gpointer data)
+{
+ gtk_progress_bar_pulse(GTK_PROGRESS_BAR(pairing_progress));
+ return TRUE;
}
static void prepare_callback(GtkWidget *assistant,
GtkWidget *page, gpointer data)
{
+ gboolean complete = TRUE;
+
if (page == page_search) {
+ gint type = selected_type();
+ g_object_set(G_OBJECT(selector), "device-type-filter", type, NULL);
bluetooth_device_selection_start_discovery(BLUETOOTH_DEVICE_SELECTION(selector));
- return;
+ if (address)
+ bluetooth_client_cancel_call(client, NULL, address);
+ complete = address != NULL;
}
-
- if (page == page_pairing) {
+ else if (page == page_pairing) {
bluetooth_client_cancel_discovery(client, NULL);
- bluetooth_client_register_passkey_agent(client,
- "/org/bluez/applet", address,
- &dbus_glib_passkey_agent_object_info);
-
- bluetooth_client_create_bonding(client, NULL, address);
-
- gtk_label_set_markup(GTK_LABEL(label_pairing), address);
- gtk_label_set_markup(GTK_LABEL(label_passkey), passkey);
- return;
+ register_agent(client, "/org/bluez/applet", address);
+
+ if (page_prev == page_search) {
+ pairing_progress_timeout = g_timeout_add(100, pulse_progress, pairing_progress);
+ gtk_widget_show(pairing_progress);
+ gtk_widget_hide(pairing_message);
+ complete = FALSE;
+ if (!bluetooth_client_connect(client, selected_type(), NULL, address,
+ connect_callback, assistant))
+ show_pairing_error(NULL);
+ }
+ }
+
+ if (page != page_pairing && pairing_progress_timeout > 0) {
+ g_source_remove(pairing_progress_timeout);
+ pairing_progress_timeout = 0;
}
- gtk_assistant_set_page_complete(GTK_ASSISTANT(assistant), page, TRUE);
+ gtk_assistant_set_page_complete(GTK_ASSISTANT(assistant), page, complete);
+ page_prev = page;
}
static GtkWidget *create_vbox(GtkWidget *assistant, GtkAssistantPageType type,
@@ -180,56 +228,6 @@ static GtkWidget *create_vbox(GtkWidget
return vbox;
}
-static void create_intro(GtkWidget *assistant)
-{
- GtkWidget *vbox;
- GtkWidget *label;
- GtkWidget *combo;
- GtkTreeModel *model;
- GtkCellRenderer *renderer;
-
- vbox = create_vbox(assistant, GTK_ASSISTANT_PAGE_INTRO,
- _("Introduction"),
- _("Welcome to the Bluetooth device setup wizard"));
-
- label = gtk_label_new(NULL);
-
- gtk_label_set_markup(GTK_LABEL(label), _("The device wizard will "
- "walk you through the process of configuring "
- "Bluetooth enabled devices for use with this "
- "computer.\n\n"));
-
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
-
- gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
-
- gtk_widget_set_size_request(GTK_WIDGET(label), 380, -1);
-
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
-
- combo = gtk_combo_box_new();
-
- model = bluetooth_client_get_model_adapter_list(client);
-
- gtk_combo_box_set_model(GTK_COMBO_BOX(combo), model);
-
- g_object_unref(model);
-
- gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
-
- gtk_cell_layout_clear(GTK_CELL_LAYOUT(combo));
-
- renderer = gtk_cell_renderer_text_new();
-
- gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE);
-
- gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer,
- "text", COLUMN_NAME, NULL);
-
- if (gtk_tree_model_iter_n_children(model, NULL) > 1)
- gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 0);
-}
-
static void create_type(GtkWidget *assistant)
{
GtkWidget *vbox;
@@ -238,55 +236,24 @@ static void create_type(GtkWidget *assis
vbox = create_vbox(assistant, GTK_ASSISTANT_PAGE_CONTENT,
_("Device type"),
- _("Select the type of device you want to setup"));
-
- button = gtk_radio_button_new_with_label(group, _("Mouse"));
-
- group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
- //gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
+ _("Select the type of device you want to connect"));
+ button = gtk_radio_button_new_with_label(NULL, _("Mouse"));
+ g_object_set_data(G_OBJECT(button),
+ "bluez-type", GINT_TO_POINTER(BLUETOOTH_TYPE_MOUSE));
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
- button = gtk_radio_button_new_with_label(group, _("Keyboard"));
-
- group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
- //gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
-
+ button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), _("Keyboard"));
+ g_object_set_data(G_OBJECT(button),
+ "bluez-type", GINT_TO_POINTER(BLUETOOTH_TYPE_KEYBOARD));
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
- button = gtk_radio_button_new_with_label(group, _("Mobile phone"));
-
- group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
- gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
-
- gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
-
- button = gtk_radio_button_new_with_label(group, _("Printer"));
-
- group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
- gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
-
- gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
-
- button = gtk_radio_button_new_with_label(group, _("Headset"));
-
- group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
- gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
-
+ button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), _("Headset"));
+ g_object_set_data(G_OBJECT(button),
+ "bluez-type", GINT_TO_POINTER(BLUETOOTH_TYPE_HEADSET));
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
- button = gtk_radio_button_new_with_label(group, _("Any device"));
-
- group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
-
- gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
+ type_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
}
static void select_callback(BluetoothDeviceSelection *sel,
@@ -310,7 +277,7 @@ static void create_search(GtkWidget *ass
vbox = create_vbox(assistant, GTK_ASSISTANT_PAGE_CONTENT,
_("Device search"),
- _("Select the device you want to setup"));
+ _("Select the device you want to connect"));
selector = bluetooth_device_selection_new(NULL);
@@ -327,48 +294,31 @@ static void create_search(GtkWidget *ass
page_search = vbox;
}
-static void create_info(GtkWidget *assistant)
-{
- GtkWidget *vbox;
- GtkWidget *label;
-
- vbox = create_vbox(assistant, GTK_ASSISTANT_PAGE_CONTENT,
- _("Device information"),
- _("Gathering information about device"));
-
- label = gtk_label_new(NULL);
-
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
-
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
-
- page_info = vbox;
-}
-
static void create_pairing(GtkWidget *assistant)
{
GtkWidget *vbox;
GtkWidget *label;
+ GtkWidget *progress;
vbox = create_vbox(assistant, GTK_ASSISTANT_PAGE_CONTENT,
- _("Device pairing"),
- _("Pairing with new device"));
+ _("Device connection"),
+ _("Connecting with new device"));
- label = gtk_label_new(NULL);
+ progress = gtk_progress_bar_new();
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), progress, FALSE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
-
- label_pairing = label;
+ pairing_progress = progress;
label = gtk_label_new(NULL);
+ gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
+ gtk_label_set_selectable(GTK_LABEL(label), TRUE);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
- label_passkey = label;
+ pairing_message = label;
page_pairing = vbox;
}
@@ -381,6 +331,8 @@ static void create_summary(GtkWidget *as
_("Summary"),
_("Succesfully configured new device"));
+ page_summary_num = gtk_assistant_get_n_pages(GTK_ASSISTANT(assistant)) - 1;
+
page_summary = vbox;
}
@@ -401,14 +353,10 @@ static GtkWidget *create_wizard(void)
page_forward, NULL, NULL);
#endif
- create_intro(assistant);
-
create_type(assistant);
create_search(assistant);
- create_info(assistant);
-
create_pairing(assistant);
create_summary(assistant);
@@ -465,6 +413,7 @@ int main(int argc, char *argv[])
client = bluetooth_client_new();
window = create_wizard();
+ set_agent_parent_window(window);
bluetooth_instance_set_window(instance, GTK_WINDOW(window));
diff -uprN ../bluez-gnome-services/wizard/Makefile.am ./wizard/Makefile.am
--- ../bluez-gnome-services/wizard/Makefile.am 2008-06-30 09:27:23.000000000 -0400
+++ ./wizard/Makefile.am 2008-06-30 10:02:35.000000000 -0400
@@ -1,7 +1,7 @@
-noinst_PROGRAMS = bluetooth-wizard
+bin_PROGRAMS = bluetooth-wizard
-bluetooth_wizard_SOURCES = main.c
+bluetooth_wizard_SOURCES = main.c agent.c agent.h
bluetooth_wizard_LDADD = @GTK_LIBS@ @DBUS_LIBS@ \
$(top_builddir)/common/libcommon.a
@@ -13,8 +13,8 @@ AM_CFLAGS = @DBUS_CFLAGS@ @GTK_CFLAGS@
INCLUDES = -I$(top_srcdir)/common -I$(top_builddir)/common
-noinst_MANS = bluetooth-wizard.1
+man_MANS = bluetooth-wizard.1
-EXTRA_DIST = $(noinst_MANS)
+EXTRA_DIST = $(man_MANS)
MAINTAINERCLEANFILES = Makefile.in
diff -upr ../bluez-gnome-services/po/POTFILES.in ./po/POTFILES.in
--- ../bluez-gnome-services/po/POTFILES.in 2008-06-30 09:27:23.000000000 -0400
+++ ./po/POTFILES.in 2008-06-30 11:34:33.000000000 -0400
@@ -22,3 +22,5 @@ analyzer/dialog.c
analyzer/tracer.c
analyzer/bluetooth-analyzer.desktop.in
analyzer/bluetooth-manager.xml.in
+wizard/agent.c
+wizard/main.c
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 247 bytes --]
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
[-- Attachment #3: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-30 14:06 ` Marcel Holtmann
@ 2008-06-30 15:57 ` Michael Terry
2008-06-30 16:03 ` Marcel Holtmann
0 siblings, 1 reply; 30+ messages in thread
From: Michael Terry @ 2008-06-30 15:57 UTC (permalink / raw)
To: BlueZ development
[-- Attachment #1.1: Type: text/plain, Size: 1294 bytes --]
On Mon, 2008-06-30 at 16:06 +0200, Marcel Holtmann wrote:
> > It also adds a new function: bluetooth_client_cancel_call(). This
> > cancels the last client call made for the given adapter/address.
[snip]
> it only makes sense for the create bonding call, because the others
> can't really be canceled. So my proposal is to leave the others out of
> this change and implement create_bonding and cancel_bonding.
Except that one of my other patches adds a new cancelable function
_connect(). So we would need maybe specific cancel_bonding and
cancel_connect functions.
But why can't the others be canceled? Just on the assumption that the
DBus communication will be so fast as to not really allow time for
canceling? Or that by the time you send the message, it's all said and
done anyway? I don't understand the nitty gritty details of dbus async
communication.
I figured that as a matter of principle, if you have an async API like
this, it ought to allow for canceling because the very nature of async
suggests a period of time in which your program is doing other things,
one of which could conceivably trigger a cancel.
But I agree it's largely a moot case for something like _remove_trust().
I just figured it would be cleaner to do the set of them.
-mt
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 247 bytes --]
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
[-- Attachment #3: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-30 15:57 ` Michael Terry
@ 2008-06-30 16:03 ` Marcel Holtmann
2008-06-30 18:53 ` Michael Terry
0 siblings, 1 reply; 30+ messages in thread
From: Marcel Holtmann @ 2008-06-30 16:03 UTC (permalink / raw)
To: BlueZ development
Hi Michael,
> > > It also adds a new function: bluetooth_client_cancel_call(). This
> > > cancels the last client call made for the given adapter/address.
> [snip]
> > it only makes sense for the create bonding call, because the others
> > can't really be canceled. So my proposal is to leave the others out of
> > this change and implement create_bonding and cancel_bonding.
>
> Except that one of my other patches adds a new cancelable function
> _connect(). So we would need maybe specific cancel_bonding and
> cancel_connect functions.
sounds good to me. The bonding case is special since it can only do one
at a time.
> But why can't the others be canceled? Just on the assumption that the
> DBus communication will be so fast as to not really allow time for
> canceling? Or that by the time you send the message, it's all said and
> done anyway? I don't understand the nitty gritty details of dbus async
> communication.
>
> I figured that as a matter of principle, if you have an async API like
> this, it ought to allow for canceling because the very nature of async
> suggests a period of time in which your program is doing other things,
> one of which could conceivably trigger a cancel.
It will give you no advantage whatsoever. So not worth it.
Regards
Marcel
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-30 16:03 ` Marcel Holtmann
@ 2008-06-30 18:53 ` Michael Terry
2008-07-01 1:10 ` Marcel Holtmann
0 siblings, 1 reply; 30+ messages in thread
From: Michael Terry @ 2008-06-30 18:53 UTC (permalink / raw)
To: BlueZ development
[-- Attachment #1.1.1: Type: text/plain, Size: 451 bytes --]
On Mon, 2008-06-30 at 18:03 +0200, Marcel Holtmann wrote:
> > Except that one of my other patches adds a new cancelable function
> > _connect(). So we would need maybe specific cancel_bonding and
> > cancel_connect functions.
>
> sounds good to me. The bonding case is special since it can only do one
> at a time.
OK, attached is callback2.diff, which only allows canceling a create_bonding call. Updated other patches to follow.
-mt
[-- Attachment #1.1.2: callback2.diff --]
[-- Type: text/x-patch, Size: 10249 bytes --]
Index: common/client.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/client.c,v
retrieving revision 1.44
diff -u -p -r1.44 client.c
--- common/client.c 12 Mar 2008 21:03:38 -0000 1.44
+++ common/client.c 30 Jun 2008 18:53:08 -0000
@@ -1112,14 +1112,29 @@ gboolean bluetooth_client_register_passk
return TRUE;
}
+static void call_reply(DBusGProxy *proxy,
+ GError *error, gpointer userdata)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*) userdata;
+ if (data) {
+ (*(bluetooth_client_call_reply)data->cb) (error, data->userdata);
+ g_free(data);
+ }
+ if (error)
+ g_error_free(error);
+}
+
static void create_bonding_reply(DBusGProxy *proxy,
GError *error, gpointer userdata)
{
- //g_printf("create bonding reply\n");
+ g_object_set_data(G_OBJECT(proxy), "bonding-call", NULL);
+ call_reply(proxy, error, userdata);
}
gboolean bluetooth_client_create_bonding(BluetoothClient *client,
- gchar *adapter, const gchar *address)
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
GtkTreeIter iter;
@@ -1142,9 +1157,15 @@ gboolean bluetooth_client_create_bonding
COLUMN_OBJECT, &object, -1);
if (g_ascii_strcasecmp(path, adapter) == 0) {
- adapter_create_bonding_async(object, address,
- create_bonding_reply, NULL);
- return TRUE;
+ DBusGProxyCall *call;
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ call = adapter_create_bonding_async(object, address,
+ create_bonding_reply, stuff);
+ g_object_set_data(G_OBJECT(object), "bonding-call", call);
+ return call != NULL;
}
cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
@@ -1153,14 +1174,10 @@ gboolean bluetooth_client_create_bonding
return FALSE;
}
-static void remove_bonding_reply(DBusGProxy *proxy,
- GError *error, gpointer userdata)
-{
- //g_printf("remove bonding reply\n");
-}
-
gboolean bluetooth_client_remove_bonding(BluetoothClient *client,
- gchar *adapter, const gchar *address)
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
GtkTreeIter iter;
@@ -1183,9 +1200,14 @@ gboolean bluetooth_client_remove_bonding
COLUMN_OBJECT, &object, -1);
if (g_ascii_strcasecmp(path, adapter) == 0) {
- adapter_remove_bonding_async(object, address,
- remove_bonding_reply, NULL);
- return TRUE;
+ DBusGProxyCall *call;
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ call = adapter_remove_bonding_async(object, address,
+ call_reply, stuff);
+ return call != NULL;
}
cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
@@ -1194,14 +1216,10 @@ gboolean bluetooth_client_remove_bonding
return FALSE;
}
-static void set_trusted_reply(DBusGProxy *proxy,
- GError *error, gpointer userdata)
-{
- //g_printf("set trusted reply\n");
-}
-
gboolean bluetooth_client_set_trusted(BluetoothClient *client,
- gchar *adapter, const gchar *address)
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
GtkTreeIter iter;
@@ -1224,9 +1242,14 @@ gboolean bluetooth_client_set_trusted(Bl
COLUMN_OBJECT, &object, -1);
if (g_ascii_strcasecmp(path, adapter) == 0) {
- adapter_set_trusted_async(object, address,
- set_trusted_reply, NULL);
- return TRUE;
+ DBusGProxyCall *call;
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ call = adapter_set_trusted_async(object, address,
+ call_reply, stuff);
+ return call != NULL;
}
cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
@@ -1235,14 +1258,10 @@ gboolean bluetooth_client_set_trusted(Bl
return FALSE;
}
-static void remove_trust_reply(DBusGProxy *proxy,
- GError *error, gpointer userdata)
-{
- //g_printf("remove trust reply\n");
-}
-
gboolean bluetooth_client_remove_trust(BluetoothClient *client,
- gchar *adapter, const gchar *address)
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
GtkTreeIter iter;
@@ -1265,9 +1284,14 @@ gboolean bluetooth_client_remove_trust(B
COLUMN_OBJECT, &object, -1);
if (g_ascii_strcasecmp(path, adapter) == 0) {
- adapter_remove_trust_async(object, address,
- remove_trust_reply, NULL);
- return TRUE;
+ DBusGProxyCall *call;
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ call = adapter_remove_trust_async(object, address,
+ call_reply, stuff);
+ return call != NULL;
}
cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
@@ -1386,6 +1410,46 @@ gboolean bluetooth_client_cancel_discove
return FALSE;
}
+gboolean bluetooth_client_cancel_bonding(BluetoothClient *client,
+ gchar *adapter, const gchar *address)
+{
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ GtkTreeIter iter;
+ gboolean cont;
+
+ if (adapter == NULL)
+ adapter = priv->default_adapter;
+
+ if (adapter == NULL)
+ return FALSE;
+
+ cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store), &iter);
+
+ while (cont == TRUE) {
+ DBusGProxy *object;
+ gchar *path;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+ COLUMN_PATH, &path,
+ COLUMN_OBJECT, &object, -1);
+
+ if (g_ascii_strcasecmp(path, adapter) == 0) {
+ DBusGProxyCall *call;
+ call = (DBusGProxyCall *)g_object_get_data(G_OBJECT(object), "bonding-call");
+ if (call != NULL) {
+ dbus_g_proxy_cancel_call(object, call);
+ g_object_set_data(G_OBJECT(object), "bonding-call", NULL);
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+ cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
+ }
+
+ return FALSE;
+}
+
GtkTreeModel *bluetooth_client_get_model(BluetoothClient *client)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
Index: common/client.h
===================================================================
RCS file: /cvsroot/bluez/gnome/common/client.h,v
retrieving revision 1.24
diff -u -p -r1.24 client.h
--- common/client.h 6 Mar 2008 10:54:29 -0000 1.24
+++ common/client.h 30 Jun 2008 18:53:08 -0000
@@ -99,14 +99,26 @@ const gchar *bluetooth_type_to_string(gu
gboolean bluetooth_client_register_passkey_agent(BluetoothClient *self,
const char *path, const char *address, const void *info);
+typedef void (*bluetooth_client_call_reply) (GError *error, gpointer data);
+
gboolean bluetooth_client_create_bonding(BluetoothClient *self,
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
+gboolean bluetooth_client_cancel_bonding(BluetoothClient *self,
gchar *adapter, const gchar *address);
gboolean bluetooth_client_remove_bonding(BluetoothClient *self,
- gchar *adapter, const gchar *address);
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
gboolean bluetooth_client_set_trusted(BluetoothClient *self,
- gchar *adapter, const gchar *address);
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
gboolean bluetooth_client_remove_trust(BluetoothClient *self,
- gchar *adapter, const gchar *address);
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
gboolean bluetooth_client_disconnect(BluetoothClient *self,
gchar *adapter, const gchar *address);
Index: properties/adapter.c
===================================================================
RCS file: /cvsroot/bluez/gnome/properties/adapter.c,v
retrieving revision 1.22
diff -u -p -r1.22 adapter.c
--- properties/adapter.c 11 Feb 2008 14:34:37 -0000 1.22
+++ properties/adapter.c 30 Jun 2008 18:53:08 -0000
@@ -317,7 +317,7 @@ static void delete_callback(GtkWidget *b
gtk_tree_model_get(model, &iter, COLUMN_ADDRESS, &address, -1);
if (show_confirm_dialog() == TRUE)
- bluetooth_client_remove_bonding(client, adapter->path, address);
+ bluetooth_client_remove_bonding(client, adapter->path, address, NULL, NULL);
g_free(address);
}
@@ -338,9 +338,9 @@ static void trusted_callback(GtkWidget *
COLUMN_TRUSTED, &trusted, -1);
if (trusted == FALSE)
- bluetooth_client_set_trusted(client, adapter->path, address);
+ bluetooth_client_set_trusted(client, adapter->path, address, NULL, NULL);
else
- bluetooth_client_remove_trust(client, adapter->path, address);
+ bluetooth_client_remove_trust(client, adapter->path, address, NULL, NULL);
g_free(address);
}
Index: wizard/main.c
===================================================================
RCS file: /cvsroot/bluez/gnome/wizard/main.c,v
retrieving revision 1.31
diff -u -p -r1.31 main.c
--- wizard/main.c 6 Jun 2008 15:08:32 -0000 1.31
+++ wizard/main.c 30 Jun 2008 18:53:08 -0000
@@ -120,7 +120,7 @@ static void prepare_callback(GtkWidget *
"/org/bluez/applet", address,
&dbus_glib_passkey_agent_object_info);
- bluetooth_client_create_bonding(client, NULL, address);
+ bluetooth_client_create_bonding(client, NULL, address, NULL, NULL);
gtk_label_set_markup(GTK_LABEL(label_pairing), address);
gtk_label_set_markup(GTK_LABEL(label_passkey), passkey);
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 247 bytes --]
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
[-- Attachment #3: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-30 13:51 ` Michael Terry
@ 2008-06-30 19:58 ` Michael Terry
2008-06-30 20:01 ` Michael Terry
2008-07-01 1:16 ` Marcel Holtmann
1 sibling, 1 reply; 30+ messages in thread
From: Michael Terry @ 2008-06-30 19:58 UTC (permalink / raw)
To: BlueZ development
[-- Attachment #1.1: Type: text/plain, Size: 541 bytes --]
On Mon, 2008-06-30 at 09:51 -0400, Michael Terry wrote:
> On Sat, 2008-06-28 at 00:23 +0200, Marcel Holtmann wrote:
> > looks nice. However you have to break this up into pieces for. Sent
> > small patches and I can quickly review and commit them.
>
> Here's a patch to add support for connecting to devices via the client code. This patch depends on the callback patch.
Here's an updated services patch, to go along with the changes in callback2.diff. I'll wait to provide an updated wizard-ui.diff until I get feedback.
-mt
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 247 bytes --]
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
[-- Attachment #3: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-30 19:58 ` Michael Terry
@ 2008-06-30 20:01 ` Michael Terry
2008-06-30 20:38 ` Bastien Nocera
2008-06-30 20:42 ` Mario Limonciello
0 siblings, 2 replies; 30+ messages in thread
From: Michael Terry @ 2008-06-30 20:01 UTC (permalink / raw)
To: BlueZ development
[-- Attachment #1.1.1: Type: text/plain, Size: 317 bytes --]
On Mon, 2008-06-30 at 15:58 -0400, Michael Terry wrote:
> Here's an updated services patch, to go along with the changes in callback2.diff. I'll wait to provide an updated wizard-ui.diff until I get feedback.
Guh, I need that plugin that warns me about not attaching files. :)
Actually attached now.
-mt
[-- Attachment #1.1.2: services2.diff --]
[-- Type: text/x-patch, Size: 9448 bytes --]
diff -rup ../bluez-gnome-callback/common/client.c ./common/client.c
--- ../bluez-gnome-callback/common/client.c 2008-06-30 14:57:48.000000000 -0400
+++ ./common/client.c 2008-06-30 15:40:26.000000000 -0400
@@ -48,6 +48,8 @@ struct _BluetoothClientPrivate {
DBusGConnection *conn;
DBusGProxy *manager_object;
+ DBusGProxy *input_service;
+ DBusGProxy *audio_service;
GtkTreeStore *store;
gchar *default_adapter;
};
@@ -935,6 +937,33 @@ static void setup_manager(BluetoothClien
g_error_free(error);
}
+static void setup_services(BluetoothClient *client)
+{
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ gchar *busname = NULL;
+
+ priv->input_service = NULL;
+ priv->audio_service = NULL;
+
+ if (dbus_g_proxy_call(priv->manager_object, "FindService", NULL,
+ G_TYPE_STRING, "input", G_TYPE_INVALID,
+ G_TYPE_STRING, &busname, G_TYPE_INVALID)) {
+ priv->input_service = dbus_g_proxy_new_for_name(priv->conn, busname,
+ "/org/bluez/input",
+ "org.bluez.input.Manager");
+ g_free(busname);
+ }
+
+ if (dbus_g_proxy_call(priv->manager_object, "FindService", NULL,
+ G_TYPE_STRING, "audio", G_TYPE_INVALID,
+ G_TYPE_STRING, &busname, G_TYPE_INVALID)) {
+ priv->audio_service = dbus_g_proxy_new_for_name(priv->conn, busname,
+ "/org/bluez/audio",
+ "org.bluez.audio.Manager");
+ g_free(busname);
+ }
+}
+
static void name_owner_changed(DBusGProxy *object, const char *name,
const char *prev, const char *new, gpointer user_data)
{
@@ -984,6 +1013,8 @@ static void bluetooth_client_finalize(GO
g_free(priv->default_adapter);
g_object_unref(G_OBJECT(priv->store));
g_object_unref (priv->manager_object);
+ g_object_unref (priv->input_service);
+ g_object_unref (priv->audio_service);
}
static void bluetooth_client_init(BluetoothClient *client)
@@ -1000,6 +1031,8 @@ static void bluetooth_client_init(Blueto
setup_dbus(client);
setup_manager(client);
+
+ setup_services(client);
}
static void bluetooth_client_set_property(GObject *object, guint prop_id,
@@ -1085,6 +1118,19 @@ BluetoothClient *bluetooth_client_new(vo
}
}
+int bluetooth_client_available_services(BluetoothClient *client)
+{
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ int rv = 0;
+
+ if (priv->input_service)
+ rv |= BLUETOOTH_TYPE_INPUT;
+ if (priv->audio_service)
+ rv |= BLUETOOTH_TYPE_HEADSET;
+
+ return rv;
+}
+
gboolean bluetooth_client_register_passkey_agent(BluetoothClient *client,
const char *path, const char *address, const void *info)
{
@@ -1124,6 +1170,13 @@ static void call_reply(DBusGProxy *proxy
g_error_free(error);
}
+static void connect_reply(DBusGProxy *proxy, char *s,
+ GError *error, gpointer userdata)
+{
+ g_object_set_data(G_OBJECT(proxy), "connect-call", NULL);
+ call_reply(proxy, error, userdata);
+}
+
static void create_bonding_reply(DBusGProxy *proxy,
GError *error, gpointer userdata)
{
@@ -1131,6 +1184,89 @@ static void create_bonding_reply(DBusGPr
call_reply(proxy, error, userdata);
}
+static gboolean connect_to_service(BluetoothClient *client, DBusGProxy *object,
+ const gchar *address, guint type,
+ gpointer userdata)
+{
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ DBusGProxyCall *call = NULL;
+
+ /* Special case the few types we can handle */
+ if (type & BLUETOOTH_TYPE_INPUT)
+ call = input_create_secure_device_async(priv->input_service, address,
+ connect_reply, userdata);
+ else if (type & BLUETOOTH_TYPE_HEADSET)
+ call = audio_create_headset_async(priv->audio_service, address,
+ connect_reply, userdata);
+
+ g_object_set_data(G_OBJECT(object), "connect-call", call);
+ return call != NULL;
+}
+
+gboolean bluetooth_client_connect(BluetoothClient *client, guint type,
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
+{
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ GtkTreeIter iter;
+ gboolean cont;
+
+ if (adapter == NULL)
+ adapter = priv->default_adapter;
+
+ if (adapter == NULL)
+ return FALSE;
+
+ cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store), &iter);
+
+ while (cont == TRUE) {
+ DBusGProxy *object;
+ gchar *path;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+ COLUMN_PATH, &path,
+ COLUMN_OBJECT, &object, -1);
+
+ if (g_ascii_strcasecmp(path, adapter) == 0) {
+ DBusGAsyncData *stuff;
+ gboolean cont;
+ GtkTreeIter child;
+
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+
+ /* If caller didn't specify a forced type, determine it from device info */
+ if (type == 0 || type == BLUETOOTH_TYPE_ANY) {
+ cont = gtk_tree_model_iter_children(GTK_TREE_MODEL(priv->store),
+ &child, &iter);
+
+ while (cont == TRUE) {
+ gchar *value;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &child,
+ COLUMN_ADDRESS, &value, -1);
+
+ if (g_ascii_strcasecmp(address, value) == 0) {
+ gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &child,
+ COLUMN_TYPE, &type, -1);
+ break;
+ }
+
+ cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &child);
+ }
+ }
+
+ return connect_to_service(client, object, address, type, stuff);
+ }
+
+ cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
+ }
+
+ return FALSE;
+}
+
gboolean bluetooth_client_create_bonding(BluetoothClient *client,
gchar *adapter, const gchar *address,
bluetooth_client_call_reply callback,
@@ -1410,8 +1546,8 @@ gboolean bluetooth_client_cancel_discove
return FALSE;
}
-gboolean bluetooth_client_cancel_bonding(BluetoothClient *client,
- gchar *adapter, const gchar *address)
+static gboolean bluetooth_client_cancel_call(BluetoothClient *client,
+ gchar *adapter, const gchar *address, const gchar *call_id)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
GtkTreeIter iter;
@@ -1435,10 +1571,10 @@ gboolean bluetooth_client_cancel_bonding
if (g_ascii_strcasecmp(path, adapter) == 0) {
DBusGProxyCall *call;
- call = (DBusGProxyCall *)g_object_get_data(G_OBJECT(object), "bonding-call");
+ call = (DBusGProxyCall *)g_object_get_data(G_OBJECT(object), call_id);
if (call != NULL) {
dbus_g_proxy_cancel_call(object, call);
- g_object_set_data(G_OBJECT(object), "bonding-call", NULL);
+ g_object_set_data(G_OBJECT(object), call_id, NULL);
return TRUE;
}
return FALSE;
@@ -1450,6 +1586,18 @@ gboolean bluetooth_client_cancel_bonding
return FALSE;
}
+gboolean bluetooth_client_cancel_bonding(BluetoothClient *client,
+ gchar *adapter, const gchar *address)
+{
+ return bluetooth_client_cancel_call(client, adapter, address, "bonding-call");
+}
+
+gboolean bluetooth_client_cancel_connect(BluetoothClient *client,
+ gchar *adapter, const gchar *address)
+{
+ return bluetooth_client_cancel_call(client, adapter, address, "connect-call");
+}
+
GtkTreeModel *bluetooth_client_get_model(BluetoothClient *client)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
diff -rup ../bluez-gnome-callback/common/client.h ./common/client.h
--- ../bluez-gnome-callback/common/client.h 2008-06-30 14:43:21.000000000 -0400
+++ ./common/client.h 2008-06-30 14:56:51.000000000 -0400
@@ -107,6 +107,15 @@ gboolean bluetooth_client_create_bonding
gpointer data);
gboolean bluetooth_client_cancel_bonding(BluetoothClient *self,
gchar *adapter, const gchar *address);
+
+/* Set 'type' to non-zero to force a certain type connection -- useful for dumb devices */
+gboolean bluetooth_client_connect(BluetoothClient *self, guint type,
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
+gboolean bluetooth_client_cancel_connect(BluetoothClient *self,
+ gchar *adapter, const gchar *address);
+
gboolean bluetooth_client_remove_bonding(BluetoothClient *self,
gchar *adapter, const gchar *address,
bluetooth_client_call_reply callback,
diff -rup ../bluez-gnome-callback/common/dbus.xml ./common/dbus.xml
--- ../bluez-gnome-callback/common/dbus.xml 2008-06-30 08:55:31.000000000 -0400
+++ ./common/dbus.xml 2008-06-30 14:55:56.000000000 -0400
@@ -98,4 +98,20 @@
<arg type="s" name="address"/>
</method>
</interface>
+
+ <interface name="input">
+ <method name="CreateSecureDevice">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="s" name="address"/>
+ <arg type="s" direction="out"/>
+ </method>
+ </interface>
+
+ <interface name="audio">
+ <method name="CreateHeadset">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="s" name="address"/>
+ <arg type="s" direction="out"/>
+ </method>
+ </interface>
</node>
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 247 bytes --]
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
[-- Attachment #3: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-30 20:01 ` Michael Terry
@ 2008-06-30 20:38 ` Bastien Nocera
2008-06-30 20:42 ` Mario Limonciello
1 sibling, 0 replies; 30+ messages in thread
From: Bastien Nocera @ 2008-06-30 20:38 UTC (permalink / raw)
To: BlueZ development
On Mon, 2008-06-30 at 16:01 -0400, Michael Terry wrote:
> On Mon, 2008-06-30 at 15:58 -0400, Michael Terry wrote:
> > Here's an updated services patch, to go along with the changes in
> callback2.diff. I'll wait to provide an updated wizard-ui.diff until
> I get feedback.
>
> Guh, I need that plugin that warns me about not attaching files. :)
Edit->Plugins->Attachment Reminder in Evo.
> Actually attached now.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-30 20:01 ` Michael Terry
2008-06-30 20:38 ` Bastien Nocera
@ 2008-06-30 20:42 ` Mario Limonciello
1 sibling, 0 replies; 30+ messages in thread
From: Mario Limonciello @ 2008-06-30 20:42 UTC (permalink / raw)
To: BlueZ development
[-- Attachment #1.1: Type: text/plain, Size: 1200 bytes --]
Michael:
If you decide to move away from evolution, here's for t-bird:
https://addons.mozilla.org/en-US/thunderbird/addon/5759
Regards
Michael Terry wrote:
> On Mon, 2008-06-30 at 15:58 -0400, Michael Terry wrote:
>
>> Here's an updated services patch, to go along with the changes in callback2.diff. I'll wait to provide an updated wizard-ui.diff until I get feedback.
>>
>
> Guh, I need that plugin that warns me about not attaching files. :)
>
> Actually attached now.
>
> -mt
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> ------------------------------------------------------------------------
>
> _______________________________________________
> Bluez-devel mailing list
> Bluez-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bluez-devel
--
Mario Limonciello
*Dell | Linux Engineering*
mario_limonciello@dell.com
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
[-- Attachment #2: Type: text/plain, Size: 247 bytes --]
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
[-- Attachment #3: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-30 13:15 ` David Stockwell
@ 2008-06-30 22:27 ` Luiz Augusto von Dentz
2008-07-01 18:56 ` David Stockwell
0 siblings, 1 reply; 30+ messages in thread
From: Luiz Augusto von Dentz @ 2008-06-30 22:27 UTC (permalink / raw)
To: BlueZ development
Hello David,
> I read the docs and when the code works as expected it is good enough.
> However, I have had a number of problems making the code work (partially
> implemented "experimental" 4.x features in release 3.33 and before).
You should first understand that the documentation in doc/ are dbus
specifications, they are not normal method calls or gobject signals.
You seems to be confused by using dbus-glib and not really knowing
what dbus is doing, we don't document how to use the API in terms of
language bindings, because it is open to the application developer to
choose between the bindings and the binding itself should document how
it map the different signatures.
> Also, figuring out how to handle some of the formats (e.g., the "dict"
> with variant) are a bit hard to figure out without a code example. SO,
> I often have to dig into the actual code and figure out just what is
> going on.
See my point here, just because dbus-glib maps the signature a{sv}
(that is the real "dict") to a GHashTable using a GValue doesn't mean
any other binding will do the same. It's up to the binding to provides
this kind of documentation not the dbus API which should not be tied
to a single binding.
This tutorial should cover what you want:
http://dbus.freedesktop.org/doc/dbus-tutorial.html
-- =
Luiz Augusto von Dentz
Engenheiro de Computa=E7=E3o
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-30 18:53 ` Michael Terry
@ 2008-07-01 1:10 ` Marcel Holtmann
2008-07-09 14:28 ` Michael Terry
0 siblings, 1 reply; 30+ messages in thread
From: Marcel Holtmann @ 2008-07-01 1:10 UTC (permalink / raw)
To: BlueZ development
Hi Michael,
> > > Except that one of my other patches adds a new cancelable function
> > > _connect(). So we would need maybe specific cancel_bonding and
> > > cancel_connect functions.
> >
> > sounds good to me. The bonding case is special since it can only do one
> > at a time.
>
> OK, attached is callback2.diff, which only allows canceling a create_bonding call. Updated other patches to follow.
please only change create_bonding and leave the others alone. Also you
cast a little bit too much for my taste. For example void pointers need
to extra cast.
Regards
Marcel
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-30 13:51 ` Michael Terry
2008-06-30 19:58 ` Michael Terry
@ 2008-07-01 1:16 ` Marcel Holtmann
1 sibling, 0 replies; 30+ messages in thread
From: Marcel Holtmann @ 2008-07-01 1:16 UTC (permalink / raw)
To: BlueZ development
SGkgTWljaGFlbCwKCj4gPiBsb29rcyBuaWNlLiBIb3dldmVyIHlvdSBoYXZlIHRvIGJyZWFrIHRo
aXMgdXAgaW50byBwaWVjZXMgZm9yLiBTZW50Cj4gPiBzbWFsbCBwYXRjaGVzIGFuZCBJIGNhbiBx
dWlja2x5IHJldmlldyBhbmQgY29tbWl0IHRoZW0uCj4gCj4gSGVyZSdzIGEgcGF0Y2ggdG8gYWRk
IHN1cHBvcnQgZm9yIGNvbm5lY3RpbmcgdG8gZGV2aWNlcyB2aWEgdGhlIGNsaWVudCBjb2RlLiAg
VGhpcyBwYXRjaCBkZXBlbmRzIG9uIHRoZSBjYWxsYmFjayBwYXRjaC4KPiAKPiBJdCBmaW5kcyBr
bm93biBzZXJ2aWNlcyBvbiBzdGFydHVwIChpbiBzZXR1cF9zZXJ2aWNlcygpKS4gIEJhc3RpZW4K
PiBzdWdnZXN0ZWQgdGhhdCB3ZSBkb24ndCBuZWVkIHRvIGNhbGwgc2V0dXBfc2VydmljZXMoKSBz
aW5jZSB0aG9zZQo+IHNlcnZpY2VzIGFyZSBlbmFibGVkIGJ5IGRlZmF1bHQsIGJ1dCBJJ20gbm90
IHF1aXRlIHN1cmUgd2hhdCBoZSBtZWFudC4KPiBXZSBuZWVkIHRvIGNhbGwgaXQgdG8gZ2V0IHRo
ZSBzZXJ2aWNlIGJ1cyBJRHMgc28gdGhhdCB3ZSBjYW4gdGhlbiBnZXQKPiBEQnVzR1Byb3hpZXMg
Zm9yIHRoZW0uCgpzbyBzdGFydGluZyB3aXRoIGJsdWV6LXV0aWxzLTMuMzMgZXZlcnl0aGluZyBp
cyBhIHBsdWdpbiBhbmQgd2lsbCBiZQphdmFpbGFibGUgdW5kZXIgdGhlIG9yZy5ibHVleiBzZXJ2
aWNlIG5hbWUuIFNvIHdlIGNvdWxkIHNpbXBseSBpZ25vcmUKdGhpcyBhbmQgZmFpbCB0aGUgb3Ro
ZXIgY2FzZXMuCgpJZiB5b3Ugd2FubmEgY2hlY2sgYXZhaWxhYmxlIHNlcnZpY2VzIHRoZW4geW91
IHNob3VsZCB1c2UgTGlzdFNlcnZpY2VzCmFuZCByZXRyaWV2ZSB0aGUgc2VydmljZSBvYmplY3Rz
LiBPbiB0aGVzZSBvYmplY3RzIHlvdSBjYW4gYWxzbyBjYWxsCkdldEJ1c05hbWUgdG8gZ2V0IHRo
ZSBidXMgbmFtZSBvZiB0aGUgc2VydmljZS4gVGhpcyB3aWxsIHRoZW4gb25seSB3b3JrCmZvciBh
Y3RpdmF0ZWQgc2VydmljZXMsIGJ1dCB0aGF0IGlzIGFjdHVhbGx5IGZpbmUuIFRoZSBkaXN0cm9z
IGVuYWJsZQp0aGVtIGJ5IGRlZmF1bHQgYW55d2F5IG9yIHRoZXkgYXJlIHBsdWdpbnMgYW5kIGxv
YWRlZCBhbGwgdGhlbS4KCj4gSXQgYWRkcyB0aGUgZnVuY3Rpb24gYmx1ZXRvb3RoX2NsaWVudF9h
dmFpbGFibGVfc2VydmljZXMoKSB3aGljaCBnaXZlcwo+IGJhY2sgYSB0eXBlIG1hc2sgZm9yIHNl
cnZpY2VzIHRoYXQgd2VyZSBkZXRlY3RlZC4gIEJhc2ljYWxseSB3aGljaAo+IGRldmljZXMgYXJl
IGxpa2VseSB0byBzdWNjZWVkIGZyb20gYSBibHVldG9vdGhfY2xpZW50X2Nvbm5lY3QoKSBjYWxs
Lgo+IAo+IO+7v2JsdWV0b290aF9jbGllbnRfY29ubmVjdCgpIGRvZXMgZGV2aWNlLXNwZWNpZmlj
IGNvbm5lY3Rpb24gaGFuZGxpbmcuCj4gSXQgb25seSBoYW5kbGVzIGEgZmV3IHR5cGVzIHJpZ2h0
IG5vdyAoaW5wdXQgYW5kIGhlYWRzZXQpLgoKUGxlYXNlIHN0b3AgdXNpbmcgdGhlIHZhcmlhYmxl
IG5hbWUgcnYgZm9yIHJldHVybiB2YWx1ZS4gRWl0aGVyIHVzZSBlcnIKb3IgY2FsbCBpdCByZXN1
bHQgb3Igc29tZXRoaW5nLgoKUmVnYXJkcwoKTWFyY2VsCgoKCi0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KQ2hl
Y2sgb3V0IHRoZSBuZXcgU291cmNlRm9yZ2UubmV0IE1hcmtldHBsYWNlLgpJdCdzIHRoZSBiZXN0
IHBsYWNlIHRvIGJ1eSBvciBzZWxsIHNlcnZpY2VzIGZvcgpqdXN0IGFib3V0IGFueXRoaW5nIE9w
ZW4gU291cmNlLgpodHRwOi8vc291cmNlZm9yZ2UubmV0L3NlcnZpY2VzL2J1eS9pbmRleC5waHAK
X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KQmx1ZXotZGV2
ZWwgbWFpbGluZyBsaXN0CkJsdWV6LWRldmVsQGxpc3RzLnNvdXJjZWZvcmdlLm5ldApodHRwczov
L2xpc3RzLnNvdXJjZWZvcmdlLm5ldC9saXN0cy9saXN0aW5mby9ibHVlei1kZXZlbAo=
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-30 15:48 ` Michael Terry
@ 2008-07-01 1:24 ` Marcel Holtmann
0 siblings, 0 replies; 30+ messages in thread
From: Marcel Holtmann @ 2008-07-01 1:24 UTC (permalink / raw)
To: BlueZ development
Hi Michael,
> > looks nice. However you have to break this up into pieces for. Sent
> > small patches and I can quickly review and commit them.
>
> And here's the actual wizard UI patch. It's a bit large, but not
> terribly break-down-able.
first of all the bluetooth_client_get_name part should be a separate
patch.
Then the modification to the applet code to show the extra entry can be
a separate patch, too.
Same goes for the part where you actually enable the installation of the
bluetooth-wizard program.
Leave these all out, because I don't bother and we will apply them once
the UI change is committed.
> It adds the passkey code for the UI and modifies the UI a bit, as I
> mentioned in previous emails.
Lets do the UI changes without the passkey stuff. We should get the
wizard working. If no device specific passkey is provided, it will fall
back to the applet anyway and that is fine for the first step.
I also don't like that you copy the agent.[ch] files. This needs some
extra thinking and hence first the UI and then the agent part.
> Bastien suggested that the applet label to launch the wizard should
> continue to be "Setup" and not "Connect" because we may want to do more
> setup for certain device types in the future. That may be true, but
> some of that would be automatic (like the SyncML example he cited) and
> so wouldn't be visible from the user's perspective.
I am for "Setup. Using "Connect" is wrong here. If you wanna connect to
a previously setup device, then we have to add shortcuts to the applet
menu to do so.
Regards
Marcel
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-06-30 22:27 ` Luiz Augusto von Dentz
@ 2008-07-01 18:56 ` David Stockwell
0 siblings, 0 replies; 30+ messages in thread
From: David Stockwell @ 2008-07-01 18:56 UTC (permalink / raw)
To: BlueZ development
Hello David,
>>Hello Luis
> I read the docs and when the code works as expected it is good enough.
> However, I have had a number of problems making the code work =
> (partially
> implemented "experimental" 4.x features in release 3.33 and before).
You should first understand that the documentation in doc/ are dbus
specifications, they are not normal method calls or gobject signals.
You seems to be confused by using dbus-glib and not really knowing
what dbus is doing, we don't document how to use the API in terms of
language bindings, because it is open to the application developer to
choose between the bindings and the binding itself should document how
it map the different signatures.
>> REPLY (sorry, but Outlook SUX)
>> I appreciate that fact. I also recognize that Python does an awful =
>> lot for the user, and that perhaps I could develop all of this in =
>> Python...but at this point, I am choosing to use C/C++ and hence, =
>> must use the GLib binding.
>> Really, my comment was about the fact that some of the features =
>> documented in the /doc directory are not quite working, and in fact =
>> are still coming into existance. As a result, when I run into a =
>> problem I cannot figure out what is really going on (is it my code, =
>> or is it something missing in Bluez) without digging through the =
>> Bluez source. Which has very little documentation (even at the file =
>> level). Again, when everything is working, the doc files will be =
>> fine. Just, for now, they are not quite enough.
>> The question you may be asking is why I do not just develop to the =
>> 3.x API? Why would I do that when in just a few months I would have =
>> to throw all of that away? (See: bluez-gnome).
> Also, figuring out how to handle some of the formats (e.g., the "dict"
> with variant) are a bit hard to figure out without a code example. =
> SO,
> I often have to dig into the actual code and figure out just what is
> going on.
See my point here, just because dbus-glib maps the signature a{sv}
(that is the real "dict") to a GHashTable using a GValue doesn't mean
any other binding will do the same. It's up to the binding to provides
this kind of documentation not the dbus API which should not be tied
to a single binding.
>> Got it, frankly the Glib binding docs are not very complete. As with =
>> most programs, the documentation handles the most simplistic cases, =
>> and ignores the fact that someone might Actually Want To Use It. I =
>> did find the DBUS Test directory and got a lot of help from seeing =
>> how the validation tests were coded.
This tutorial should cover what you want:
http://dbus.freedesktop.org/doc/dbus-tutorial.html
>> I have read this tutorial in detail and understood it. However, the =
>> coverage was still inadequate for a{sv} (dict) and array{string} =
>> ({as}). At one point, I also had problems with object paths, but =
>> again, with Marcel giving me a hint as to the proper incantation, I =
>> was able to work that out.
>> That said, after finding a few more-complex code examples (especially =
>> the validation code), I have now figured the structures out. =
>> Everything I need to do for now is (apparently) working, and now I am =
>> moving on to getting SSP going between Bluez and my device =
>> (programmed with the CSR BT stack).
>> Thanks again for your response.
-- =
Luiz Augusto von Dentz
Engenheiro de Computa=E7=E3o
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-07-01 1:10 ` Marcel Holtmann
@ 2008-07-09 14:28 ` Michael Terry
2008-08-19 17:33 ` Michael Terry
0 siblings, 1 reply; 30+ messages in thread
From: Michael Terry @ 2008-07-09 14:28 UTC (permalink / raw)
To: BlueZ development
[-- Attachment #1.1.1: Type: text/plain, Size: 417 bytes --]
Hello, Marcel.
On Tue, 2008-07-01 at 03:10 +0200, Marcel Holtmann wrote:
> please only change create_bonding and leave the others alone. Also you
> cast a little bit too much for my taste. For example void pointers
> need
> to extra cast.
Attached is callback3.diff which only modifies create_bonding.
I'm not sure which casts you felt were unnecessary. I don't think I
cast any void pointers.
-mt
[-- Attachment #1.1.2: callback3.diff --]
[-- Type: text/x-patch, Size: 4781 bytes --]
Index: common/client.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/client.c,v
retrieving revision 1.44
diff -u -p -r1.44 client.c
--- common/client.c 12 Mar 2008 21:03:38 -0000 1.44
+++ common/client.c 9 Jul 2008 14:23:38 -0000
@@ -1115,11 +1115,20 @@ gboolean bluetooth_client_register_passk
static void create_bonding_reply(DBusGProxy *proxy,
GError *error, gpointer userdata)
{
- //g_printf("create bonding reply\n");
+ DBusGAsyncData *data = (DBusGAsyncData*) userdata;
+ g_object_set_data(G_OBJECT(proxy), "bonding-call", NULL);
+ if (data && data->cb) {
+ (*(bluetooth_client_call_reply)data->cb) (error, data->userdata);
+ g_free(data);
+ }
+ if (error)
+ g_error_free(error);
}
gboolean bluetooth_client_create_bonding(BluetoothClient *client,
- gchar *adapter, const gchar *address)
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer userdata)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
GtkTreeIter iter;
@@ -1142,9 +1151,15 @@ gboolean bluetooth_client_create_bonding
COLUMN_OBJECT, &object, -1);
if (g_ascii_strcasecmp(path, adapter) == 0) {
- adapter_create_bonding_async(object, address,
- create_bonding_reply, NULL);
- return TRUE;
+ DBusGProxyCall *call;
+ DBusGAsyncData *stuff;
+ stuff = g_new(DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK(callback);
+ stuff->userdata = userdata;
+ call = adapter_create_bonding_async(object, address,
+ create_bonding_reply, stuff);
+ g_object_set_data(G_OBJECT(object), "bonding-call", call);
+ return call != NULL;
}
cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
@@ -1386,6 +1401,46 @@ gboolean bluetooth_client_cancel_discove
return FALSE;
}
+gboolean bluetooth_client_cancel_bonding(BluetoothClient *client,
+ gchar *adapter, const gchar *address)
+{
+ BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+ GtkTreeIter iter;
+ gboolean cont;
+
+ if (adapter == NULL)
+ adapter = priv->default_adapter;
+
+ if (adapter == NULL)
+ return FALSE;
+
+ cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store), &iter);
+
+ while (cont == TRUE) {
+ DBusGProxy *object;
+ gchar *path;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+ COLUMN_PATH, &path,
+ COLUMN_OBJECT, &object, -1);
+
+ if (g_ascii_strcasecmp(path, adapter) == 0) {
+ DBusGProxyCall *call;
+ call = (DBusGProxyCall *)g_object_get_data(G_OBJECT(object), "bonding-call");
+ if (call != NULL) {
+ dbus_g_proxy_cancel_call(object, call);
+ g_object_set_data(G_OBJECT(object), "bonding-call", NULL);
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+ cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
+ }
+
+ return FALSE;
+}
+
GtkTreeModel *bluetooth_client_get_model(BluetoothClient *client)
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
Index: common/client.h
===================================================================
RCS file: /cvsroot/bluez/gnome/common/client.h,v
retrieving revision 1.24
diff -u -p -r1.24 client.h
--- common/client.h 6 Mar 2008 10:54:29 -0000 1.24
+++ common/client.h 9 Jul 2008 14:23:38 -0000
@@ -99,7 +99,13 @@ const gchar *bluetooth_type_to_string(gu
gboolean bluetooth_client_register_passkey_agent(BluetoothClient *self,
const char *path, const char *address, const void *info);
+typedef void (*bluetooth_client_call_reply) (GError *error, gpointer data);
+
gboolean bluetooth_client_create_bonding(BluetoothClient *self,
+ gchar *adapter, const gchar *address,
+ bluetooth_client_call_reply callback,
+ gpointer data);
+gboolean bluetooth_client_cancel_bonding(BluetoothClient *self,
gchar *adapter, const gchar *address);
gboolean bluetooth_client_remove_bonding(BluetoothClient *self,
gchar *adapter, const gchar *address);
Index: wizard/main.c
===================================================================
RCS file: /cvsroot/bluez/gnome/wizard/main.c,v
retrieving revision 1.31
diff -u -p -r1.31 main.c
--- wizard/main.c 6 Jun 2008 15:08:32 -0000 1.31
+++ wizard/main.c 9 Jul 2008 14:23:38 -0000
@@ -120,7 +120,7 @@ static void prepare_callback(GtkWidget *
"/org/bluez/applet", address,
&dbus_glib_passkey_agent_object_info);
- bluetooth_client_create_bonding(client, NULL, address);
+ bluetooth_client_create_bonding(client, NULL, address, NULL, NULL);
gtk_label_set_markup(GTK_LABEL(label_pairing), address);
gtk_label_set_markup(GTK_LABEL(label_passkey), passkey);
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 347 bytes --]
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
[-- Attachment #3: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Bluez-devel] Wizard patch
2008-07-09 14:28 ` Michael Terry
@ 2008-08-19 17:33 ` Michael Terry
0 siblings, 0 replies; 30+ messages in thread
From: Michael Terry @ 2008-08-19 17:33 UTC (permalink / raw)
To: BlueZ development
[-- Attachment #1.1: Type: text/plain, Size: 1179 bytes --]
Poke!
This has been languishing here for a over a month. Could it please get reviewed, so I can post the rest of the wizard patches?
-mt
On Wed, 2008-07-09 at 10:28 -0400, Michael Terry wrote:
> Hello, Marcel.
>
> On Tue, 2008-07-01 at 03:10 +0200, Marcel Holtmann wrote:
> > please only change create_bonding and leave the others alone. Also you
> > cast a little bit too much for my taste. For example void pointers
> > need
> > to extra cast.
>
> Attached is callback3.diff which only modifies create_bonding.
>
> I'm not sure which casts you felt were unnecessary. I don't think I
> cast any void pointers.
>
> -mt
> -------------------------------------------------------------------------
> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
> Studies have shown that voting for your favorite open source project,
> along with a healthy diet, reduces your potential for chronic lameness
> and boredom. Vote Now at http://www.sourceforge.net/community/cca08
> _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 363 bytes --]
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
[-- Attachment #3: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2008-08-19 17:33 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-27 19:05 [Bluez-devel] Wizard patch Michael Terry
2008-06-27 19:18 ` Michael Terry
2008-06-27 19:38 ` David Stockwell
2008-06-27 19:42 ` Michael Terry
2008-06-27 22:24 ` Marcel Holtmann
2008-06-27 22:23 ` Marcel Holtmann
2008-06-30 12:51 ` Michael Terry
2008-06-30 12:57 ` Marcel Holtmann
2008-06-30 13:20 ` Michael Terry
2008-06-30 14:07 ` Marcel Holtmann
2008-06-30 13:15 ` Michael Terry
2008-06-30 14:06 ` Marcel Holtmann
2008-06-30 15:57 ` Michael Terry
2008-06-30 16:03 ` Marcel Holtmann
2008-06-30 18:53 ` Michael Terry
2008-07-01 1:10 ` Marcel Holtmann
2008-07-09 14:28 ` Michael Terry
2008-08-19 17:33 ` Michael Terry
2008-06-30 13:51 ` Michael Terry
2008-06-30 19:58 ` Michael Terry
2008-06-30 20:01 ` Michael Terry
2008-06-30 20:38 ` Bastien Nocera
2008-06-30 20:42 ` Mario Limonciello
2008-07-01 1:16 ` Marcel Holtmann
2008-06-30 15:48 ` Michael Terry
2008-07-01 1:24 ` Marcel Holtmann
2008-06-27 22:44 ` Bastien Nocera
[not found] ` <031301c8da4d$0bce3720$6701a8c0@freqonedev>
[not found] ` <1214813891.4435.149.camel@cookie.hadess.net>
2008-06-30 13:15 ` David Stockwell
2008-06-30 22:27 ` Luiz Augusto von Dentz
2008-07-01 18:56 ` David Stockwell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox