# HG changeset patch # User Paula Stanciu # Date 1217270919 -10800 # Node ID 671cdfc2d62d33c8ee65aec55f807a30f00e8bdb # Parent 3d7f01edb388006a709736199116f5757ad1000b Basic pairing interface diff -r 3d7f01edb388 -r 671cdfc2d62d src/bluetooth/agent.c --- a/src/bluetooth/agent.c Sun Jul 27 22:15:41 2008 +0300 +++ b/src/bluetooth/agent.c Mon Jul 28 21:48:39 2008 +0300 @@ -24,6 +24,7 @@ #include #include "bluetooth.h" +#include "agent.h" #include "gui.h" #define PASSKEY_AGENT_PATH "/org/bluez/audacious_passkey" @@ -42,7 +43,7 @@ static char* passkey; static GList *adapter_list = NULL; DBusGProxy *pair_obj = NULL; -static gint bonding_finish=0; + static DBusGConnection *connection; struct adapter_data { @@ -1073,6 +1074,7 @@ void run_agents() { + bonding_finish =0; setup_agents(bus); //to add the bounding signals // register_agents(); diff -r 3d7f01edb388 -r 671cdfc2d62d src/bluetooth/agent.h --- a/src/bluetooth/agent.h Sun Jul 27 22:15:41 2008 +0300 +++ b/src/bluetooth/agent.h Mon Jul 28 21:48:39 2008 +0300 @@ -25,6 +25,7 @@ #include #include #include +gint bonding_finish; void run_agents(void); int setup_agents(DBusGConnection *conn); void cleanup_agents(void); diff -r 3d7f01edb388 -r 671cdfc2d62d src/bluetooth/bluetooth.c --- a/src/bluetooth/bluetooth.c Sun Jul 27 22:15:41 2008 +0300 +++ b/src/bluetooth/bluetooth.c Mon Jul 28 21:48:39 2008 +0300 @@ -87,12 +87,12 @@ if(discover_finish == 2){ if (devices_no == 0){ printf("no devs!\n"); - show_scan(); + show_scan(0); show_no_devices(); }else results_ui(); } - else show_scan(); + else show_scan(0); printf("end of bt_cfg\n"); } @@ -123,25 +123,12 @@ discover_devices(); close_window(); - show_scan(); + show_scan(0); } else printf("Scanning please wait!\n"); } -void bounding_created(gchar* address) -{ - printf("Signal BoundingCreated : %s\n",address); - -} - -void bounding_removed(gchar* address) -{ - printf("Signal: BoundingRemoved: %s\n",address); - -} - - gpointer connect_call_th(void) { @@ -154,7 +141,10 @@ } void connect_call(void) { - connect_th = g_thread_create((GThreadFunc)connect_call_th,NULL,TRUE,NULL) ; + connect_th = g_thread_create((GThreadFunc)connect_call_th,NULL,TRUE,NULL) ; + close_call(); + close_window(); + show_scan(1); } diff -r 3d7f01edb388 -r 671cdfc2d62d src/bluetooth/gui.h --- a/src/bluetooth/gui.h Sun Jul 27 22:15:41 2008 +0300 +++ b/src/bluetooth/gui.h Mon Jul 28 21:48:39 2008 +0300 @@ -22,5 +22,6 @@ GList *selected_dev ; void refresh_tree(void); void results_ui(); +void close_call(void); diff -r 3d7f01edb388 -r 671cdfc2d62d src/bluetooth/scan_gui.c --- a/src/bluetooth/scan_gui.c Sun Jul 27 22:15:41 2008 +0300 +++ b/src/bluetooth/scan_gui.c Mon Jul 28 21:48:39 2008 +0300 @@ -18,6 +18,7 @@ #include "scan_gui.h" #include "bluetooth.h" +#include "agent.h" static GtkWidget *window = NULL; static GtkWidget *winbox; static GtkWidget *scanbox; @@ -28,6 +29,8 @@ static GtkWidget *progress_bar; static GtkWidget *rescan_buttton; static GtkWidget *close_button; +static gint usage=0; + gpointer progress() { for(;;){ @@ -35,16 +38,34 @@ gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progress_bar)); } sleep(1); - if(discover_finish == 2 ) { + if(usage == 0){ + if(discover_finish == 2 ) { if(window){ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bar),1); } return 0; } + }else + { + if(bonding_finish == 1 ) { + if(window){ + gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bar),1); + show_pairing_ok(); + } + return 0; + } + } } return 0; } +void show_pairing_ok() +{ + if(window ){ + gtk_label_set_text(GTK_LABEL(scan_label),_("Bonding finish!")); + } +} + void show_no_devices(){ if(window ){ gtk_label_set_text(GTK_LABEL(scan_label),_("No devices found!")); @@ -60,10 +81,15 @@ } -void show_scan() +void show_scan(gint use) { GThread *th1; gchar *filename; + usage = use; + /* + * 0 - discovery + * 1 - pairing + */ if (!window) { window = gtk_window_new (GTK_WINDOW_TOPLEVEL); @@ -84,20 +110,25 @@ bluetooth_img = gtk_image_new_from_file(filename); gtk_image_set_pixel_size(GTK_IMAGE(bluetooth_img),-1); gtk_container_add(GTK_CONTAINER(scanbox),bluetooth_img); + if(usage == 0){ + scan_label = gtk_label_new_with_mnemonic(_("Scanning...")); + }else + { + scan_label = gtk_label_new_with_mnemonic(_("Pairing...")); + } - scan_label = gtk_label_new_with_mnemonic(_("Scanning...")); gtk_container_add(GTK_CONTAINER(scanbox),scan_label); progress_bar = gtk_progress_bar_new(); gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progress_bar)); gtk_container_add(GTK_CONTAINER(progressbox),progress_bar); th1 = g_thread_create((GThreadFunc)progress, NULL,TRUE,NULL); - /* I have to add a button for Rescan when there are - * no devices found and not currently scanning - */ buttonsbox = gtk_hbox_new(FALSE,2); gtk_container_set_border_width(GTK_CONTAINER(buttonsbox),2); gtk_container_add(GTK_CONTAINER(progressbox),buttonsbox); + /* I have to modify the rescan button with a play one + * and treat the case when the bounding is not ok + */ rescan_buttton = gtk_button_new_with_mnemonic(_("Rescan")); g_signal_connect(rescan_buttton,"clicked",G_CALLBACK (refresh_call),NULL); diff -r 3d7f01edb388 -r 671cdfc2d62d src/bluetooth/scan_gui.h --- a/src/bluetooth/scan_gui.h Sun Jul 27 22:15:41 2008 +0300 +++ b/src/bluetooth/scan_gui.h Mon Jul 28 21:48:39 2008 +0300 @@ -18,7 +18,7 @@ #include #include -void show_scan(); +void show_scan(gint use); void show_no_devices(); void destroy_scan_window(); void close_window();