comparison src/bluetooth/agent.c @ 2884:4128ae5633e4

disable play button while pairing - some cleanups
author Paula Stanciu <paula.stanciu@gmail.com>
date Sat, 09 Aug 2008 20:46:49 +0300
parents 15754379dbd5
children 35773e919dba
comparison
equal deleted inserted replaced
2883:67d527114af5 2884:4128ae5633e4
25 #include <glib/gprintf.h> 25 #include <glib/gprintf.h>
26 #include "bluetooth.h" 26 #include "bluetooth.h"
27 #include "agent.h" 27 #include "agent.h"
28 #include "gui.h" 28 #include "gui.h"
29 29
30 #define PASSKEY_AGENT_PATH "/org/bluez/audacious_passkey" 30 #define PASSKEY_AGENT_PATH "/org/bluez/passkey_agent"
31 #define AUTH_AGENT_PATH "/org/bluez/audacious_auth" 31 #define AUTH_AGENT_PATH "/org/bluez/auth_agent"
32 32
33 static GtkWidget *agent_window = NULL; 33 static GtkWidget *agent_window = NULL;
34 static GtkWidget *window_box = NULL; 34 static GtkWidget *window_box = NULL;
35 static GtkWidget *top_box = NULL; 35 static GtkWidget *top_box = NULL;
36 static GtkWidget *middle_box = NULL; 36 static GtkWidget *middle_box = NULL;
202 printf("passkey error\n"); 202 printf("passkey error\n");
203 dbus_g_method_return_error(input->context, error); 203 dbus_g_method_return_error(input->context, error);
204 } 204 }
205 205
206 input_free(input); 206 input_free(input);
207 } 207 printf("return\n");
208 208 }
209 /*static void confirm_callback(gint response, gpointer user_data) 209
210 {
211 struct input_data *input = user_data;
212
213 if (response != GTK_RESPONSE_YES) {
214 GError *error;
215 error = g_error_new(AGENT_ERROR, AGENT_ERROR_REJECT,
216 "Confirmation request rejected");
217 dbus_g_method_return_error(input->context, error);
218 } else
219 dbus_g_method_return(input->context);
220
221 input_free(input);
222 }
223 */
224 /*
225 static void set_trusted(struct input_data *input)
226 {
227 DBusGProxy *object;
228 //aways set trusted -- we dont have yet an active button -
229 //maybe I'll add one
230 object = dbus_g_proxy_new_for_name(connection, "org.bluez",
231 input->path, "org.bluez.Adapter");
232
233 dbus_g_proxy_call(object, "SetTrusted", NULL,
234 G_TYPE_STRING, input->address, G_TYPE_INVALID,
235 G_TYPE_INVALID);
236 }
237 */
238 /*
239 static void auth_callback(gint response, gpointer user_data)
240 {
241
242 struct input_data *input = user_data;
243
244 if (response == GTK_RESPONSE_YES) {
245 set_trusted(input);
246 dbus_g_method_return(input->context);
247 } else {
248 GError *error;
249 error = g_error_new(AGENT_ERROR, AGENT_ERROR_REJECT,
250 "Authorization request rejected");
251 dbus_g_method_return_error(input->context, error);
252 }
253
254 input_free(input);
255 }
256 */
257 210
258 static void passkey_dialog(const char *path, const char *address, 211 static void passkey_dialog(const char *path, const char *address,
259 const gchar *device, DBusGMethodInvocation *context) 212 const gchar *device, DBusGMethodInvocation *context)
260 { 213 {
261 struct input_data *input; 214 struct input_data *input;
267 input->path = g_strdup(path); 220 input->path = g_strdup(path);
268 input->address = g_strdup(address); 221 input->address = g_strdup(address);
269 222
270 input->context = context; 223 input->context = context;
271 224
272
273
274 /*
275 g_signal_connect(G_OBJECT(entry), "changed",
276 G_CALLBACK(changed_callback), input);
277
278
279 g_signal_connect(G_OBJECT(button), "toggled",
280 G_CALLBACK(toggled_callback), input);
281
282 gtk_container_add(GTK_CONTAINER(vbox), button);
283
284 input_list = g_list_append(input_list, input);
285
286 g_signal_connect(G_OBJECT(dialog), "response",
287 G_CALLBACK(passkey_callback), input);
288
289 enable_blinking();
290 */
291 printf("passkey callback\n");
292 passkey_callback(GTK_RESPONSE_ACCEPT,input); 225 passkey_callback(GTK_RESPONSE_ACCEPT,input);
293 226
294 227
295 } 228 }
296 229
297 static void confirm_dialog(const char *path, const char *address, 230 static void confirm_dialog(const char *path, const char *address,
298 const char *value, const gchar *device, 231 const char *value, const gchar *device,
299 DBusGMethodInvocation *context) 232 DBusGMethodInvocation *context)
300 { 233 {
301 struct input_data *input; 234 printf("confirm dialog \n");
235 struct input_data *input;
302 236
303 input = g_try_malloc0(sizeof(*input)); 237 input = g_try_malloc0(sizeof(*input));
304 if (!input) 238 if (!input)
305 return; 239 return;
306 240
307 input->path = g_strdup(path); 241 input->path = g_strdup(path);
308 input->address = g_strdup(address); 242 input->address = g_strdup(address);
309 243
310 input->context = context; 244 input->context = context;
311
312 printf("confirm dialog\n");
313 // g_signal_connect(G_OBJECT(dialog), "response", 245 // g_signal_connect(G_OBJECT(dialog), "response",
314 // G_CALLBACK(confirm_callback), input); 246 // G_CALLBACK(confirm_callback), input);
315 247
316 //enable_blinking(); 248 //enable_blinking();
317 } 249 }
435 367
436 static gboolean passkey_agent_confirm(PasskeyAgent *agent, 368 static gboolean passkey_agent_confirm(PasskeyAgent *agent,
437 const char *path, const char *address, 369 const char *path, const char *address,
438 const char *value, DBusGMethodInvocation *context) 370 const char *value, DBusGMethodInvocation *context)
439 { 371 {
372 printf("passkey agent confirm \n");
440 DBusGProxy *object; 373 DBusGProxy *object;
441 const char *adapter = NULL, *name = NULL; 374 const char *adapter = NULL, *name = NULL;
442 gchar *device, *line; 375 gchar *device, *line;
443 376
444 object = dbus_g_proxy_new_for_name(connection, "org.bluez", 377 object = dbus_g_proxy_new_for_name(connection, "org.bluez",
474 } 407 }
475 408
476 static gboolean passkey_agent_cancel(PasskeyAgent *agent, 409 static gboolean passkey_agent_cancel(PasskeyAgent *agent,
477 const char *path, const char *address, GError **error) 410 const char *path, const char *address, GError **error)
478 { 411 {
412 printf("passkey agent cancel \n");
479 GList *list; 413 GList *list;
480 GError *result; 414 GError *result;
481 struct input_data *input; 415 struct input_data *input;
482 416
483 input = g_try_malloc0(sizeof(*input)); 417 input = g_try_malloc0(sizeof(*input));
510 return TRUE; 444 return TRUE;
511 } 445 }
512 446
513 static gboolean passkey_agent_release(PasskeyAgent *agent, GError **error) 447 static gboolean passkey_agent_release(PasskeyAgent *agent, GError **error)
514 { 448 {
449 printf("pass agent release \n");
515 registered_passkey = 0; 450 registered_passkey = 0;
516 451
517 return TRUE; 452 return TRUE;
518 } 453 }
519 454
568 503
569 static gboolean auth_agent_authorize(PasskeyAgent *agent, 504 static gboolean auth_agent_authorize(PasskeyAgent *agent,
570 const char *path, const char *address, const char *service, 505 const char *path, const char *address, const char *service,
571 const char *uuid, DBusGMethodInvocation *context) 506 const char *uuid, DBusGMethodInvocation *context)
572 { 507 {
508 printf("auth agent authorize \n");
573 DBusGProxy *object; 509 DBusGProxy *object;
574 const char *adapter = NULL, *name = NULL; 510 const char *adapter = NULL, *name = NULL;
575 gchar *device, *profile, *line; 511 gchar *device, *profile, *line;
576 512
577 if (auto_authorize == TRUE) { 513 if (auto_authorize == TRUE) {
715 registered_auth = 0; 651 registered_auth = 0;
716 } 652 }
717 653
718 int setup_agents(DBusGConnection *conn) 654 int setup_agents(DBusGConnection *conn)
719 { 655 {
656 printf("setup agents\n");
720 void *agent; 657 void *agent;
721 658
722 connection = dbus_g_connection_ref(conn); 659 connection = dbus_g_connection_ref(conn);
723 660
724 dbus_g_object_type_install_info(PASSKEY_AGENT_OBJECT_TYPE, 661 dbus_g_object_type_install_info(PASSKEY_AGENT_OBJECT_TYPE,
737 return 0; 674 return 0;
738 } 675 }
739 676
740 void cleanup_agents(void) 677 void cleanup_agents(void)
741 { 678 {
679 printf("clean up agents \n");
742 unregister_agents(); 680 unregister_agents();
743 681
744 dbus_g_connection_unref(connection); 682 dbus_g_connection_unref(connection);
745 } 683 }
746 684