[gnome-bluetooth/gnome-3-10] lib: Add DisplayPinCode support



commit c6de322f92736e6a58e927047d8820457280257b
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Nov 15 20:48:38 2013 +0100

    lib: Add DisplayPinCode support
    
    https://bugzilla.gnome.org/show_bug.cgi?id=712387

 lib/bluetooth-agent.c       |   49 +++++++++++++++++++++++++++++++++++++++++++
 lib/bluetooth-agent.h       |    5 ++++
 lib/gnome-bluetooth.symbols |    1 +
 3 files changed, 55 insertions(+), 0 deletions(-)
---
diff --git a/lib/bluetooth-agent.c b/lib/bluetooth-agent.c
index 92ccb45..ddc9d20 100644
--- a/lib/bluetooth-agent.c
+++ b/lib/bluetooth-agent.c
@@ -53,6 +53,10 @@ static const gchar introspection_xml[] =
 "      <arg type='u' name='passkey' direction='in'/>"
 "      <arg type='y' name='entered' direction='in'/>"
 "    </method>"
+"    <method name='DisplayPinCode'>"
+"      <arg type='o' name='device' direction='in'/>"
+"      <arg type='s' name='pincode' direction='in'/>"
+"    </method>"
 "    <method name='RequestConfirmation'>"
 "      <arg type='o' name='device' direction='in'/>"
 "      <arg type='u' name='passkey' direction='in'/>"
@@ -88,6 +92,9 @@ struct _BluetoothAgentPrivate {
        BluetoothAgentDisplayFunc display_func;
        gpointer display_data;
 
+       BluetoothAgentDisplayPinCodeFunc display_pincode_func;
+       gpointer display_pincode_data;
+
        BluetoothAgentPasskeyFunc passkey_func;
        gpointer passkey_data;
 
@@ -181,6 +188,28 @@ static gboolean bluetooth_agent_display_passkey(BluetoothAgent *agent,
        return TRUE;
 }
 
+static gboolean bluetooth_agent_display_pincode(BluetoothAgent *agent,
+                                               const char *path, const char *pincode,
+                                               GDBusMethodInvocation *invocation)
+{
+       BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
+       GDBusProxy *device;
+
+       if (priv->display_pincode_func == NULL)
+               return FALSE;
+
+       device = get_device_from_path(path);
+       if (device == NULL)
+               return FALSE;
+
+       priv->display_pincode_func(invocation, device, pincode,
+                                  priv->display_data);
+
+       g_object_unref(device);
+
+       return TRUE;
+}
+
 static gboolean bluetooth_agent_request_confirmation(BluetoothAgent *agent,
                                        const char *path, guint passkey,
                                                GDBusMethodInvocation *invocation)
@@ -364,6 +393,13 @@ handle_method_call (GDBusConnection       *connection,
                g_variant_get (parameters, "(ouy)", &path, &passkey, &entered);
                bluetooth_agent_display_passkey (agent, path, passkey, entered, invocation);
                g_free (path);
+       } else if (g_strcmp0 (method_name, "DisplayPinCode") == 0) {
+               char *path;
+               char *pincode;
+
+               g_variant_get (parameters, "(os)", &path, &pincode);
+               bluetooth_agent_display_pincode (agent, path, pincode, invocation);
+               g_free (path);
        } else if (g_strcmp0 (method_name, "RequestConfirmation") == 0) {
                char *path;
                guint32 passkey;
@@ -552,6 +588,19 @@ void bluetooth_agent_set_display_func(BluetoothAgent *agent,
        priv->display_data = data;
 }
 
+void bluetooth_agent_set_display_pincode_func(BluetoothAgent *agent,
+                               BluetoothAgentDisplayPinCodeFunc func, gpointer data)
+{
+       BluetoothAgentPrivate *priv;
+
+       g_return_if_fail (BLUETOOTH_IS_AGENT (agent));
+
+       priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
+
+       priv->display_pincode_func = func;
+       priv->display_pincode_data = data;
+}
+
 void bluetooth_agent_set_confirm_func(BluetoothAgent *agent,
                                BluetoothAgentConfirmFunc func, gpointer data)
 {
diff --git a/lib/bluetooth-agent.h b/lib/bluetooth-agent.h
index 1c0fbf4..6f0d5e6 100644
--- a/lib/bluetooth-agent.h
+++ b/lib/bluetooth-agent.h
@@ -66,6 +66,9 @@ typedef gboolean (*BluetoothAgentPasskeyFunc) (GDBusMethodInvocation *invocation
 typedef gboolean (*BluetoothAgentDisplayFunc) (GDBusMethodInvocation *invocation,
                                        GDBusProxy *device, guint passkey,
                                                guint entered, gpointer data);
+typedef gboolean (*BluetoothAgentDisplayPinCodeFunc) (GDBusMethodInvocation *invocation,
+                                                     GDBusProxy *device, const char *pincode,
+                                                     gpointer data);
 typedef gboolean (*BluetoothAgentConfirmFunc) (GDBusMethodInvocation *invocation,
                                        GDBusProxy *device, guint passkey,
                                                                gpointer data);
@@ -83,6 +86,8 @@ void bluetooth_agent_set_passkey_func(BluetoothAgent *agent,
                                BluetoothAgentPasskeyFunc func, gpointer data);
 void bluetooth_agent_set_display_func(BluetoothAgent *agent,
                                BluetoothAgentDisplayFunc func, gpointer data);
+void bluetooth_agent_set_display_pincode_func(BluetoothAgent *agent,
+                               BluetoothAgentDisplayPinCodeFunc func, gpointer data);
 void bluetooth_agent_set_confirm_func(BluetoothAgent *agent,
                                BluetoothAgentConfirmFunc func, gpointer data);
 void bluetooth_agent_set_authorize_func(BluetoothAgent *agent,
diff --git a/lib/gnome-bluetooth.symbols b/lib/gnome-bluetooth.symbols
index e2ff0c2..6d7af64 100644
--- a/lib/gnome-bluetooth.symbols
+++ b/lib/gnome-bluetooth.symbols
@@ -66,5 +66,6 @@ bluetooth_agent_set_cancel_func
 bluetooth_agent_error_quark
 bluetooth_agent_set_authorize_func
 bluetooth_agent_set_display_func
+bluetooth_agent_set_display_pincode_func
 bluetooth_agent_set_authorize_service_func
 bluetooth_agent_setup


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]