Mercurial > audlegacy-plugins
comparison src/bluetooth/bluetooth.c @ 2916:223822ba79f2
writing bonded device to the config file so it can be unbounded at start-up when
the player doesn't stop normaly
author | Paula Stanciu <paula.stanciu@gmail.com> |
---|---|
date | Sat, 16 Aug 2008 21:46:08 +0300 |
parents | 35773e919dba |
children | acfa92d9ff5e |
comparison
equal
deleted
inserted
replaced
2915:703cd5256849 | 2916:223822ba79f2 |
---|---|
42 static void print_results(void); | 42 static void print_results(void); |
43 static void discovery_completed(DBusGProxy *object, gpointer user_data); | 43 static void discovery_completed(DBusGProxy *object, gpointer user_data); |
44 void discover_devices(void); | 44 void discover_devices(void); |
45 void disconnect_dbus_signals(void); | 45 void disconnect_dbus_signals(void); |
46 /*static void show_restart_dialog(void); */ | 46 /*static void show_restart_dialog(void); */ |
47 static void remove_bonding(); | 47 static void remove_bonding(gchar* device); |
48 GeneralPlugin bluetooth_gp = | 48 GeneralPlugin bluetooth_gp = |
49 { | 49 { |
50 .description = "Bluetooth audio support", | 50 .description = "Bluetooth audio support", |
51 .init = bluetooth_init, | 51 .init = bluetooth_init, |
52 .about = bt_about, | 52 .about = bt_about, |
59 void bluetooth_init ( void ) | 59 void bluetooth_init ( void ) |
60 { | 60 { |
61 audio_devices = NULL; | 61 audio_devices = NULL; |
62 bus = NULL; | 62 bus = NULL; |
63 obj = NULL; | 63 obj = NULL; |
64 gchar* bonded_addr="zz"; | |
64 discover_devices(); | 65 discover_devices(); |
66 mcs_handle_t *cfgfile ; | |
67 cfgfile = aud_cfg_db_open(); | |
68 if(!aud_cfg_db_get_string(cfgfile, "BLUETOOTH_PLUGIN", "bonded", | |
69 &bonded_addr)) | |
70 return; | |
71 if(bonded_addr!=NULL && g_strcmp0(bonded_addr,"no")!=0) | |
72 { | |
73 remove_bonding(bonded_addr); | |
74 } | |
75 aud_cfg_db_close(cfgfile); | |
76 | |
65 } | 77 } |
66 | 78 |
67 void bluetooth_cleanup ( void ) | 79 void bluetooth_cleanup ( void ) |
68 { | 80 { |
69 printf("bluetooth: exit\n"); | 81 printf("bluetooth: exit\n"); |
70 if (config ==1 ) | 82 if (config ==1 ) |
71 { | 83 { |
72 close_window(); | 84 close_window(); |
73 config =0; | 85 config =0; |
74 } | 86 } |
75 remove_bonding(); | 87 remove_bonding(bonded_dev); |
76 if(discover_finish == 2) { | 88 if(discover_finish == 2) { |
77 dbus_g_connection_flush (bus); | 89 dbus_g_connection_flush (bus); |
78 dbus_g_connection_unref(bus); | 90 dbus_g_connection_unref(bus); |
79 disconnect_dbus_signals(); | 91 disconnect_dbus_signals(); |
80 | 92 |
125 dbus_g_connection_flush (bus); | 137 dbus_g_connection_flush (bus); |
126 dbus_g_connection_unref(bus); | 138 dbus_g_connection_unref(bus); |
127 audio_devices = NULL; | 139 audio_devices = NULL; |
128 //g_list_free(current_device); | 140 //g_list_free(current_device); |
129 } | 141 } |
130 static void remove_bonding() | 142 static void remove_bonding(gchar *device) |
131 { | 143 { |
144 printf("remove_bonding call\n"); | |
132 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); | 145 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); |
133 dbus_g_proxy_call(obj,"RemoveBonding",NULL,G_TYPE_STRING,bonded_dev,G_TYPE_INVALID,G_TYPE_INVALID); | 146 dbus_g_proxy_call(obj,"RemoveBonding",NULL,G_TYPE_STRING,device,G_TYPE_INVALID,G_TYPE_INVALID); |
134 | 147 |
135 } | 148 } |
136 void refresh_call(void) | 149 void refresh_call(void) |
137 { | 150 { |
138 printf("refresh function called\n"); | 151 printf("refresh function called\n"); |
149 printf("Scanning please wait!\n"); | 162 printf("Scanning please wait!\n"); |
150 } | 163 } |
151 | 164 |
152 gpointer connect_call_th(void) | 165 gpointer connect_call_th(void) |
153 { | 166 { |
154 | |
155 //I will have to enable the audio service if necessary | 167 //I will have to enable the audio service if necessary |
156 | 168 run_agents(); |
157 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); | 169 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); |
158 run_agents(); | |
159 dbus_g_proxy_call(obj,"CreateBonding",NULL,G_TYPE_STRING,current_address,G_TYPE_INVALID,G_TYPE_INVALID); | 170 dbus_g_proxy_call(obj,"CreateBonding",NULL,G_TYPE_STRING,current_address,G_TYPE_INVALID,G_TYPE_INVALID); |
160 return NULL; | 171 |
161 } | 172 return NULL; |
173 } | |
174 | |
162 void connect_call(void) | 175 void connect_call(void) |
163 { close_call(); | 176 { |
177 close_call(); | |
164 close_window(); | 178 close_window(); |
165 show_scan(1); | 179 show_scan(1); |
166 remove_bonding(); | |
167 current_address = g_strdup(((DeviceData*)(selected_dev->data))->address); | 180 current_address = g_strdup(((DeviceData*)(selected_dev->data))->address); |
168 connect_th = g_thread_create((GThreadFunc)connect_call_th,NULL,TRUE,NULL) ; | 181 connect_th = g_thread_create((GThreadFunc)connect_call_th,NULL,TRUE,NULL) ; |
169 | |
170 } | 182 } |
171 | 183 |
172 | 184 |
173 void play_call() | 185 void play_call() |
174 { | 186 { |
224 aud_cfg_db_close(cfgfile); | 236 aud_cfg_db_close(cfgfile); |
225 | 237 |
226 printf("play callback\n"); | 238 printf("play callback\n"); |
227 close_window(); | 239 close_window(); |
228 aud_output_plugin_cleanup(); | 240 aud_output_plugin_cleanup(); |
229 audacious_drct_stop(); | 241 // audacious_drct_stop(); |
230 audacious_drct_play(); | 242 audacious_drct_play(); |
231 | 243 |
232 | 244 |
233 } | 245 } |
234 /*static void show_restart_dialog() | 246 /*static void show_restart_dialog() |