changeset 2867:dc22e3d2e56e

fixed bonding an allready bonded device bug
author Paula Stanciu <paula.stanciu@gmail.com>
date Thu, 07 Aug 2008 12:11:09 +0300
parents dd8b44fbfd6f
children 9e9293b87392
files src/bluetooth/Makefile src/bluetooth/agent.c src/bluetooth/bluetooth.c src/bluetooth/bluetooth.h
diffstat 4 files changed, 27 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/bluetooth/Makefile	Mon Aug 04 06:49:41 2008 +0300
+++ b/src/bluetooth/Makefile	Thu Aug 07 12:11:09 2008 +0300
@@ -1,9 +1,8 @@
 PLUGIN = bluetooth${PLUGIN_SUFFIX}
 
-SRCS = bluetooth.c gui.c marshal.c scan_gui.c agent.c
+SRCS = bluetooth.c gui.c marshal.c scan_gui.c agent.c 
 include ../../buildsys.mk
 include ../../extra.mk
-
 plugindir := ${plugindir}/${GENERAL_PLUGIN_DIR}
 CFLAGS += ${PLUGIN_CFLAGS}
 CPPFLAGS += ${PLUGIN_CPPFLAGS} ${BEEP_DEFINES} ${MOWGLI_CFLAGS} ${DBUS_CFLAGS} ${GTK_CFLAGS} ${GLIB_CFLAGS} ${DBUS_GLIB_CFLAGS} ${PANGO_CFLAGS} -I../../intl -I../.. ${BLUEZ_CFLAGS}
--- a/src/bluetooth/agent.c	Mon Aug 04 06:49:41 2008 +0300
+++ b/src/bluetooth/agent.c	Thu Aug 07 12:11:09 2008 +0300
@@ -199,6 +199,7 @@
         GError *error;
         error = g_error_new(AGENT_ERROR, AGENT_ERROR_REJECT,
                 "Pairing request rejected");
+        printf("passkey error\n");
         dbus_g_method_return_error(input->context, error);
     }
 
@@ -339,10 +340,11 @@
     /* translators: Whether to grant access to a particular service
      * to the device mentioned */
 
-    //	g_signal_connect(G_OBJECT(dialog), "response",
-    //				G_CALLBACK(auth_callback), input);
+   /* 	g_signal_connect(G_OBJECT(dialog), "response",
+    				G_CALLBACK(auth_callback), input);
 
-    //enable_blinking();
+    enable_blinking();
+    */
 }
 
 typedef struct {
@@ -392,9 +394,6 @@
     g_printf("new passkey agent \n");
     return agent;
 }
-
-
-
 static gboolean passkey_agent_request(PasskeyAgent *agent,
         const char *path, const char *address,
         DBusGMethodInvocation *context)
@@ -816,6 +815,7 @@
 	text = g_strdup_printf(_("Removed bonding with %s"), device);
 
 	g_free(device);
+    printf("bonding removed");
 
 //	show_notification(adapter ? adapter : _("Bluetooth device"),
 //						text, NULL, 6000, NULL);
--- a/src/bluetooth/bluetooth.c	Mon Aug 04 06:49:41 2008 +0300
+++ b/src/bluetooth/bluetooth.c	Thu Aug 07 12:11:09 2008 +0300
@@ -24,6 +24,7 @@
 #include "gui.h"
 #include "scan_gui.h"
 #include "agent.h"
+#include <audacious/plugin.h>
 #define DEBUG 1
 static gboolean plugin_active = FALSE,exiting=FALSE;
 GList * current_device = NULL;
@@ -44,7 +45,7 @@
 void discover_devices(void);
 void disconnect_dbus_signals(void);
 static void show_restart_dialog(void);
-
+static void remove_bonding();
 GeneralPlugin bluetooth_gp =
 {
     .description = "Bluetooth audio support",
@@ -72,6 +73,7 @@
         close_window();
         config =0;
     }
+    remove_bonding();
     if(discover_finish == 2) {
         dbus_g_connection_flush (bus);
         dbus_g_connection_unref(bus);
@@ -118,7 +120,12 @@
     audio_devices = NULL;
     //g_list_free(current_device);
 }
+static void remove_bonding()
+{
+    dbus_g_object_register_marshaller(marshal_VOID__STRING_UINT_INT, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INT, G_TYPE_INVALID);
+    dbus_g_proxy_call(obj,"RemoveBonding",NULL,G_TYPE_STRING,"00:0D:3C:B1:1C:7A",G_TYPE_INVALID,G_TYPE_INVALID); 
 
+}
 void refresh_call(void)
 {
     printf("refresh function called\n");
@@ -172,8 +179,6 @@
     temp_file_name = g_strconcat(home,"/temp_bt",NULL);
     file = fopen(file_name,"r");
     temp_file = fopen(temp_file_name,"w");
-    /* hardcoded address TO REMOVE after testing */
-    //   current_address = "00:0D:3C:B1:1C:7A";
     device_line = g_strdup_printf("device %s\n",current_address);
     if ( file != NULL )
     {
@@ -219,15 +224,15 @@
 }
 static void show_restart_dialog()
 {
-static GtkWidget *window = NULL;
- GtkWidget *dialog;
-  dialog = gtk_message_dialog_new (GTK_WINDOW (window),
-				   GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-				   GTK_MESSAGE_INFO,
-				   GTK_BUTTONS_OK,
-				   "Please restart the player to apply the bluetooth audio settings!");
-   gtk_dialog_run (GTK_DIALOG (dialog));
-   gtk_widget_destroy (dialog);
+    static GtkWidget *window = NULL;
+    GtkWidget *dialog;
+    dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+            GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+            GTK_MESSAGE_INFO,
+            GTK_BUTTONS_OK,
+            "Please restart the player to apply the bluetooth audio settings!");
+    gtk_dialog_run (GTK_DIALOG (dialog));
+    gtk_widget_destroy (dialog);
 }
 
 static void remote_device_found(DBusGProxy *object, char *address, const unsigned int class, const int rssi, gpointer user_data)
--- a/src/bluetooth/bluetooth.h	Mon Aug 04 06:49:41 2008 +0300
+++ b/src/bluetooth/bluetooth.h	Thu Aug 07 12:11:09 2008 +0300
@@ -28,7 +28,9 @@
 #include <dbus/dbus-glib.h>
 #include <glib-object.h>
 #include <stdio.h>
-
+#include <audacious/configdb.h>
+#include <audacious/i18n.h>
+#include <audacious/util.h>
 #include "gui.h"
 typedef struct {
     guint class;