comparison src/bluetooth/bluetooth.c @ 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 528d19a2ea3d
children 9e9293b87392
comparison
equal deleted inserted replaced
2863:dd8b44fbfd6f 2867:dc22e3d2e56e
22 #include "bluetooth.h" 22 #include "bluetooth.h"
23 #include "marshal.h" 23 #include "marshal.h"
24 #include "gui.h" 24 #include "gui.h"
25 #include "scan_gui.h" 25 #include "scan_gui.h"
26 #include "agent.h" 26 #include "agent.h"
27 #include <audacious/plugin.h>
27 #define DEBUG 1 28 #define DEBUG 1
28 static gboolean plugin_active = FALSE,exiting=FALSE; 29 static gboolean plugin_active = FALSE,exiting=FALSE;
29 GList * current_device = NULL; 30 GList * current_device = NULL;
30 gint config = 0; 31 gint config = 0;
31 gint devices_no = 0; 32 gint devices_no = 0;
42 static void print_results(void); 43 static void print_results(void);
43 static void discovery_completed(DBusGProxy *object, gpointer user_data); 44 static void discovery_completed(DBusGProxy *object, gpointer user_data);
44 void discover_devices(void); 45 void discover_devices(void);
45 void disconnect_dbus_signals(void); 46 void disconnect_dbus_signals(void);
46 static void show_restart_dialog(void); 47 static void show_restart_dialog(void);
47 48 static void remove_bonding();
48 GeneralPlugin bluetooth_gp = 49 GeneralPlugin bluetooth_gp =
49 { 50 {
50 .description = "Bluetooth audio support", 51 .description = "Bluetooth audio support",
51 .init = bluetooth_init, 52 .init = bluetooth_init,
52 .about = bt_about, 53 .about = bt_about,
70 if (config ==1 ) 71 if (config ==1 )
71 { 72 {
72 close_window(); 73 close_window();
73 config =0; 74 config =0;
74 } 75 }
76 remove_bonding();
75 if(discover_finish == 2) { 77 if(discover_finish == 2) {
76 dbus_g_connection_flush (bus); 78 dbus_g_connection_flush (bus);
77 dbus_g_connection_unref(bus); 79 dbus_g_connection_unref(bus);
78 disconnect_dbus_signals(); 80 disconnect_dbus_signals();
79 81
116 dbus_g_connection_flush (bus); 118 dbus_g_connection_flush (bus);
117 dbus_g_connection_unref(bus); 119 dbus_g_connection_unref(bus);
118 audio_devices = NULL; 120 audio_devices = NULL;
119 //g_list_free(current_device); 121 //g_list_free(current_device);
120 } 122 }
121 123 static void remove_bonding()
124 {
125 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);
126 dbus_g_proxy_call(obj,"RemoveBonding",NULL,G_TYPE_STRING,"00:0D:3C:B1:1C:7A",G_TYPE_INVALID,G_TYPE_INVALID);
127
128 }
122 void refresh_call(void) 129 void refresh_call(void)
123 { 130 {
124 printf("refresh function called\n"); 131 printf("refresh function called\n");
125 disconnect_dbus_signals(); 132 disconnect_dbus_signals();
126 clean_devices_list(); 133 clean_devices_list();
170 home = g_get_home_dir(); 177 home = g_get_home_dir();
171 file_name = g_strconcat(home,"/.asoundrc",NULL); 178 file_name = g_strconcat(home,"/.asoundrc",NULL);
172 temp_file_name = g_strconcat(home,"/temp_bt",NULL); 179 temp_file_name = g_strconcat(home,"/temp_bt",NULL);
173 file = fopen(file_name,"r"); 180 file = fopen(file_name,"r");
174 temp_file = fopen(temp_file_name,"w"); 181 temp_file = fopen(temp_file_name,"w");
175 /* hardcoded address TO REMOVE after testing */
176 // current_address = "00:0D:3C:B1:1C:7A";
177 device_line = g_strdup_printf("device %s\n",current_address); 182 device_line = g_strdup_printf("device %s\n",current_address);
178 if ( file != NULL ) 183 if ( file != NULL )
179 { 184 {
180 while ( fgets ( line, sizeof line, file ) != NULL ) 185 while ( fgets ( line, sizeof line, file ) != NULL )
181 { 186 {
217 222
218 223
219 } 224 }
220 static void show_restart_dialog() 225 static void show_restart_dialog()
221 { 226 {
222 static GtkWidget *window = NULL; 227 static GtkWidget *window = NULL;
223 GtkWidget *dialog; 228 GtkWidget *dialog;
224 dialog = gtk_message_dialog_new (GTK_WINDOW (window), 229 dialog = gtk_message_dialog_new (GTK_WINDOW (window),
225 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, 230 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
226 GTK_MESSAGE_INFO, 231 GTK_MESSAGE_INFO,
227 GTK_BUTTONS_OK, 232 GTK_BUTTONS_OK,
228 "Please restart the player to apply the bluetooth audio settings!"); 233 "Please restart the player to apply the bluetooth audio settings!");
229 gtk_dialog_run (GTK_DIALOG (dialog)); 234 gtk_dialog_run (GTK_DIALOG (dialog));
230 gtk_widget_destroy (dialog); 235 gtk_widget_destroy (dialog);
231 } 236 }
232 237
233 static void remote_device_found(DBusGProxy *object, char *address, const unsigned int class, const int rssi, gpointer user_data) 238 static void remote_device_found(DBusGProxy *object, char *address, const unsigned int class, const int rssi, gpointer user_data)
234 { 239 {
235 int found_in_list=FALSE; 240 int found_in_list=FALSE;