diff options
Diffstat (limited to 'src/conversation/gnunet-conversation-gtk.c')
-rw-r--r-- | src/conversation/gnunet-conversation-gtk.c | 595 |
1 files changed, 423 insertions, 172 deletions
diff --git a/src/conversation/gnunet-conversation-gtk.c b/src/conversation/gnunet-conversation-gtk.c index 9a2dd5a7..fd3318ee 100644 --- a/src/conversation/gnunet-conversation-gtk.c +++ b/src/conversation/gnunet-conversation-gtk.c | |||
@@ -49,6 +49,9 @@ | |||
49 | 49 | ||
50 | #define LOG(format, ...) log_message(g_strdup_printf (format, ## __VA_ARGS__)) | 50 | #define LOG(format, ...) log_message(g_strdup_printf (format, ## __VA_ARGS__)) |
51 | 51 | ||
52 | struct GNUNET_CONVERSATION_Caller *caller_selected = NULL; | ||
53 | //caller_selected = NULL; | ||
54 | |||
52 | /** | 55 | /** |
53 | * Get an object from the main window. | 56 | * Get an object from the main window. |
54 | * | 57 | * |
@@ -129,6 +132,42 @@ update_status (const gchar * message) | |||
129 | 132 | ||
130 | 133 | ||
131 | } | 134 | } |
135 | /* | ||
136 | * set_status_icon | ||
137 | * | ||
138 | * available icons: | ||
139 | * gnunet-conversation-gtk-tray-pending | ||
140 | * gnunet-conversation-gtk-tray-available | ||
141 | * gnunet-conversation-gtk-tray-offline | ||
142 | * gnunet-conversation-gtk-tray-call-pending | ||
143 | * gnunet-conversation-gtk-tray-call-ringing | ||
144 | * gnunet-conversation-gtk-tray-call-active | ||
145 | * gnunet-conversation-gtk-tray-call-suspended | ||
146 | * gnunet-conversation-gtk-tray-call-incoming | ||
147 | * | ||
148 | */ | ||
149 | |||
150 | void | ||
151 | set_status_icon (const char *icon_name) | ||
152 | { | ||
153 | GtkWindow *main_window; | ||
154 | GtkImage *status_icon; | ||
155 | |||
156 | |||
157 | |||
158 | main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window")); | ||
159 | |||
160 | status_icon = GTK_IMAGE (get_object ("GNUNET_GTK_status_icon")); | ||
161 | |||
162 | gtk_image_set_from_icon_name (status_icon, icon_name, GTK_ICON_SIZE_BUTTON); | ||
163 | |||
164 | //LOG (_("Tray icon changed to: `%s' "), icon_name); | ||
165 | |||
166 | |||
167 | |||
168 | GNUNET_GTK_tray_icon_change (icon_name, "gnunet-conversation-gtk-status"); | ||
169 | } | ||
170 | |||
132 | 171 | ||
133 | /* | 172 | /* |
134 | * adds a item to the call history | 173 | * adds a item to the call history |
@@ -188,20 +227,6 @@ set_button_text (const char *button_name, const char *label) | |||
188 | } | 227 | } |
189 | 228 | ||
190 | /* | 229 | /* |
191 | * set infobar text | ||
192 | */ | ||
193 | // | ||
194 | //void | ||
195 | //set_infobar_text (const gchar * text) | ||
196 | //{ | ||
197 | // GtkLabel *infolabel; | ||
198 | // | ||
199 | // infolabel = GTK_LABEL(get_object ("GNUNET_GTK_new_call_label")); | ||
200 | // log_message ("setting infobar text"); | ||
201 | // gtk_label_set_text (infolabel, text); | ||
202 | //} | ||
203 | // | ||
204 | /* | ||
205 | * disable button | 230 | * disable button |
206 | */ | 231 | */ |
207 | 232 | ||
@@ -229,35 +254,84 @@ enable_button (const char *button_name) | |||
229 | gtk_widget_show (button); | 254 | gtk_widget_show (button); |
230 | } | 255 | } |
231 | 256 | ||
232 | /* | 257 | /** |
233 | * show infobar | 258 | * set call state of a incoming call |
234 | */ | ||
235 | // | ||
236 | //void | ||
237 | //show_infobar () | ||
238 | //{ | ||
239 | // GtkWidget *infobar; | ||
240 | // | ||
241 | // infobar = GTK_WIDGET(get_object ("GNUNET_GTK_conversation_infobar")); | ||
242 | // | ||
243 | // gtk_widget_show (infobar); | ||
244 | //} | ||
245 | // | ||
246 | /* | ||
247 | * hide infobar | ||
248 | */ | 259 | */ |
249 | // | 260 | static void |
250 | //void | 261 | set_incoming_call_state(struct GNUNET_CONVERSATION_Caller *caller, int state) |
251 | //hide_infobar () | 262 | { |
252 | //{ | 263 | // struct CallList *cl = cls; |
253 | // //GtkInfoBar *infobar; | 264 | // struct GNUNET_CONVERSATION_Caller caller; |
254 | // GtkWidget *infobar; | 265 | gint row_count = 0; |
255 | // | 266 | GtkTreeIter gtkiter; |
256 | // infobar = GTK_WIDGET(get_object ("GNUNET_GTK_conversation_infobar")); | 267 | gint valid = 0; |
257 | // | 268 | //FPRINTF (stderr,"set incoming call state:%u caller: ",state); |
258 | // gtk_widget_hide (infobar); | 269 | |
259 | //} | 270 | LOG (_("set incoming call state:%u caller: "),state); |
260 | // | 271 | |
272 | valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), >kiter ); | ||
273 | |||
274 | if (!valid) | ||
275 | GNUNET_break(0); | ||
276 | |||
277 | while (valid) | ||
278 | { | ||
279 | gchar *cl_caller_id; | ||
280 | gint cl_caller_num; | ||
281 | gpointer cl_caller; | ||
282 | // gint new_state; | ||
283 | //FPRINTF (stderr,"loop:: valid:%u \n",valid); | ||
284 | |||
285 | gtk_tree_model_get ( GTK_TREE_MODEL( active_liststore ), >kiter, | ||
286 | AL_caller, &cl_caller, | ||
287 | AL_caller_id,&cl_caller_id, | ||
288 | AL_caller_num,&cl_caller_num | ||
289 | ,-1); | ||
290 | /* | ||
291 | enum { | ||
292 | CT_active, | ||
293 | CT_suspended, | ||
294 | CT_ringing, | ||
295 | CT_dead, | ||
296 | CT_hangup, | ||
297 | CT_rejected | ||
298 | }; | ||
299 | */ | ||
300 | if (caller == cl_caller) | ||
301 | { | ||
302 | //LOG (_("setting state for call:%u row: %u state: %u"),cl_caller_num,row_count,state); | ||
303 | |||
304 | switch (state) | ||
305 | { | ||
306 | case CT_hangup: | ||
307 | LOG("remove line cause hangup"); | ||
308 | gtk_list_store_remove(active_liststore,>kiter); | ||
309 | break; | ||
310 | |||
311 | case CT_rejected: | ||
312 | LOG("remove line cause rejected"); | ||
313 | gtk_list_store_remove(active_liststore,>kiter); | ||
314 | break; | ||
315 | |||
316 | default: | ||
317 | |||
318 | gtk_list_store_set(active_liststore, >kiter, | ||
319 | AL_caller_state, state, | ||
320 | -1); | ||
321 | break; | ||
322 | |||
323 | }//end switch | ||
324 | }//endif | ||
325 | |||
326 | g_free (cl_caller_id); | ||
327 | row_count++; | ||
328 | valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), >kiter); | ||
329 | |||
330 | }//end while | ||
331 | |||
332 | |||
333 | |||
334 | } | ||
261 | 335 | ||
262 | 336 | ||
263 | 337 | ||
@@ -275,55 +349,125 @@ phone_event_handler (void *cls, enum GNUNET_CONVERSATION_PhoneEventCode code, | |||
275 | struct GNUNET_CONVERSATION_Caller *caller, | 349 | struct GNUNET_CONVERSATION_Caller *caller, |
276 | const char *caller_id) | 350 | const char *caller_id) |
277 | { | 351 | { |
278 | struct CallList *cl; | 352 | |
353 | //gtk | ||
354 | GtkTreeIter gtkiter; | ||
355 | GtkTreeIter gtkiter1; | ||
356 | gboolean valid; | ||
357 | |||
279 | 358 | ||
280 | switch (code) | 359 | switch (code) |
281 | { | 360 | { |
282 | case GNUNET_CONVERSATION_EC_PHONE_RING: | 361 | case GNUNET_CONVERSATION_EC_PHONE_RING: |
362 | //increment call # | ||
363 | caller_num_gen++; | ||
364 | |||
283 | 365 | ||
284 | LOG (_("A Incoming call from `%s' on line %u\n"), caller_id, | 366 | LOG (_("A Incoming call from `%s' with number %u\n"), caller_id, |
285 | caller_num_gen); | 367 | caller_num_gen); |
286 | 368 | ||
287 | 369 | //old | |
288 | //UPDATE_INFOBAR (_("Incoming call from `%s' on line %u\n"), caller_id, | 370 | struct CallList *cl; |
289 | // caller_num_gen); | ||
290 | |||
291 | //show_infobar (); | ||
292 | // TODO: make sound | ||
293 | 371 | ||
294 | cl = GNUNET_new (struct CallList); | 372 | cl = GNUNET_new (struct CallList); |
295 | |||
296 | cl->caller = caller; | 373 | cl->caller = caller; |
297 | cl->caller_id = GNUNET_strdup (caller_id); | 374 | cl->caller_id = GNUNET_strdup (caller_id); |
298 | cl->caller_num = caller_num_gen++; | 375 | cl->caller_num = caller_num_gen; |
299 | GNUNET_CONTAINER_DLL_insert (cl_head, cl_tail, cl); | 376 | GNUNET_CONTAINER_DLL_insert (cl_head, cl_tail, cl); |
300 | callerName = caller_id; | 377 | //gtk |
301 | //strncpy (&callerName, &caller_id, 50); | 378 | gtk_list_store_append (active_liststore, >kiter); |
302 | //callerName[52] = '\0'; | 379 | |
303 | quick_message ("der is een beller", caller_id); | 380 | gtk_list_store_set (active_liststore, >kiter, |
381 | AL_caller_id, caller_id, | ||
382 | AL_caller, caller, | ||
383 | AL_caller_num, caller_num_gen, | ||
384 | AL_caller_state, CT_ringing, | ||
385 | AL_caller_type, CALL_IN | ||
386 | ,-1); | ||
387 | |||
388 | |||
389 | //What is this callername thing? | ||
390 | // strncpy (&callerName, &caller_id, 50); | ||
391 | // callerName[52] = '\0'; | ||
392 | |||
393 | //TODO:new call notification, should be passed a reference to the call | ||
394 | //TODO: rename: quick_message to call_notification(caller); | ||
395 | // quick_message ("der is een beller", caller_id); | ||
396 | // TODO: make sound | ||
304 | 397 | ||
305 | break; | 398 | break; |
306 | 399 | ||
307 | case GNUNET_CONVERSATION_EC_PHONE_HUNG_UP: | 400 | case GNUNET_CONVERSATION_EC_PHONE_HUNG_UP: |
401 | //FPRINTF(stderr,"GNUNET_CONVERSATION_EC_PHONE_HUNG_UP:"); | ||
402 | //gtk | ||
403 | |||
404 | valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), >kiter1 ); | ||
405 | |||
406 | if (!valid) | ||
407 | GNUNET_break(0); | ||
408 | |||
409 | while (valid) | ||
410 | { | ||
411 | /* Walk through the list, reading each row */ | ||
412 | //FPRINTF(stderr,"GNUNET_CONVERSATION_EC_PHONE_HUNG_UP: while valid"); | ||
413 | |||
414 | gchar *str_data; | ||
415 | gint int_data; | ||
416 | gpointer cl_caller; | ||
417 | |||
418 | gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), >kiter1, | ||
419 | AL_caller, &cl_caller, | ||
420 | AL_caller_id,&str_data, | ||
421 | AL_caller_num,&int_data,-1); | ||
422 | if (caller == cl_caller) | ||
423 | { | ||
424 | |||
425 | LOG (_("phone hung up:%s number: %u "), str_data,int_data); | ||
426 | set_incoming_call_state(caller,CT_rejected); | ||
427 | break ; | ||
428 | } | ||
429 | g_free (str_data); | ||
430 | valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), >kiter1); | ||
431 | } | ||
432 | |||
433 | |||
434 | |||
435 | //gcl_active = NULL; | ||
436 | phone_state = PS_LISTEN; | ||
437 | //add to call history list | ||
438 | //history_add(CH_HANGUP, cl->caller_id); | ||
439 | |||
440 | |||
441 | ///END gtk | ||
442 | |||
443 | //old | ||
444 | /* | ||
308 | for (cl = cl_head; NULL != cl; cl = cl->next) | 445 | for (cl = cl_head; NULL != cl; cl = cl->next) |
309 | if (caller == cl->caller) | 446 | if (caller == cl->caller) |
310 | break; | 447 | break; |
448 | |||
311 | if (NULL == cl) | 449 | if (NULL == cl) |
312 | { | 450 | { |
313 | GNUNET_break (0); | 451 | GNUNET_break (0); |
314 | return; | 452 | return; |
315 | } | 453 | } |
454 | |||
316 | LOG (_("Call from `%s' terminated\n"), cl->caller_id); | 455 | LOG (_("Call from `%s' terminated\n"), cl->caller_id); |
317 | history_add(3, cl->caller_id); | 456 | |
457 | |||
318 | GNUNET_CONTAINER_DLL_remove (cl_head, cl_tail, cl); | 458 | GNUNET_CONTAINER_DLL_remove (cl_head, cl_tail, cl); |
319 | GNUNET_free (cl->caller_id); | 459 | GNUNET_free (cl->caller_id); |
460 | |||
461 | // | ||
320 | if (cl == cl_active) | 462 | if (cl == cl_active) |
321 | { | 463 | { |
322 | cl_active = NULL; | 464 | cl_active = NULL; |
323 | phone_state = PS_LISTEN; | 465 | phone_state = PS_LISTEN; |
324 | } | 466 | } |
325 | GNUNET_free (cl); | 467 | GNUNET_free (cl); |
326 | gtk_widget_destroy (GTK_WIDGET (dialog)); | 468 | */ |
469 | //destroy call accept dialog | ||
470 | //gtk_widget_destroy (GTK_WIDGET (dialog)); | ||
327 | break; | 471 | break; |
328 | 472 | ||
329 | } | 473 | } |
@@ -345,10 +489,12 @@ caller_event_handler (void *cls, enum GNUNET_CONVERSATION_CallerEventCode code) | |||
345 | { | 489 | { |
346 | case GNUNET_CONVERSATION_EC_CALLER_SUSPEND: | 490 | case GNUNET_CONVERSATION_EC_CALLER_SUSPEND: |
347 | update_state (); | 491 | update_state (); |
492 | set_incoming_call_state(cls,CT_suspended); | ||
348 | LOG (_("Call from `%s' suspended by other user\n"), cl->caller_id); | 493 | LOG (_("Call from `%s' suspended by other user\n"), cl->caller_id); |
349 | break; | 494 | break; |
350 | case GNUNET_CONVERSATION_EC_CALLER_RESUME: | 495 | case GNUNET_CONVERSATION_EC_CALLER_RESUME: |
351 | update_state (); | 496 | update_state (); |
497 | set_incoming_call_state(cls,CT_active); | ||
352 | LOG (_("Call from `%s' resumed by other user\n"), cl->caller_id); | 498 | LOG (_("Call from `%s' resumed by other user\n"), cl->caller_id); |
353 | break; | 499 | break; |
354 | } | 500 | } |
@@ -476,7 +622,7 @@ do_call (const char *arg) | |||
476 | /* ok to call */ | 622 | /* ok to call */ |
477 | break; | 623 | break; |
478 | } | 624 | } |
479 | GNUNET_free_non_null (peer_name); | 625 | //GNUNET_free_non_null (peer_name); |
480 | peer_name = GNUNET_strdup (arg); | 626 | peer_name = GNUNET_strdup (arg); |
481 | LOG (_("now calling: %s"), peer_name); | 627 | LOG (_("now calling: %s"), peer_name); |
482 | call_state = CS_RESOLVING; | 628 | call_state = CS_RESOLVING; |
@@ -496,7 +642,7 @@ do_call (const char *arg) | |||
496 | * @param args arguments given to the command | 642 | * @param args arguments given to the command |
497 | */ | 643 | */ |
498 | static void | 644 | static void |
499 | do_accept (const char *args) | 645 | do_accept (struct GNUNET_CONVERSATION_Caller *sel_caller) |
500 | { | 646 | { |
501 | struct CallList *cl; | 647 | struct CallList *cl; |
502 | char buf[32]; | 648 | char buf[32]; |
@@ -523,39 +669,44 @@ do_accept (const char *args) | |||
523 | case PS_ERROR: | 669 | case PS_ERROR: |
524 | GNUNET_break (0); | 670 | GNUNET_break (0); |
525 | break; | 671 | break; |
526 | } | 672 | }//endswitch |
673 | |||
674 | /* | ||
527 | cl = cl_head; | 675 | cl = cl_head; |
528 | if (NULL == cl) | 676 | if (NULL == cl) |
529 | { | 677 | { |
530 | LOG (_("There is no incoming call to accept here!\n")); | 678 | LOG (_("There is no incoming call to accept here!\n")); |
531 | return; | 679 | return; |
532 | } | 680 | } |
533 | if ((NULL != cl->next) || (NULL != args)) | 681 | if (NULL != cl->next) |
534 | { | 682 | { |
535 | for (cl = cl_head; NULL != cl; cl = cl->next) | 683 | for (cl = cl_head; NULL != cl; cl = cl->next) |
536 | { | 684 | { |
537 | GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num); | 685 | GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num); |
538 | if (0 == strcmp (buf, args)) | ||
539 | break; | ||
540 | } | 686 | } |
541 | } | 687 | } |
542 | if (NULL == cl) | 688 | if (NULL == cl) |
543 | { | 689 | { |
544 | LOG (_("There is no incoming call `%s' to accept right now!\n"), args); | 690 | LOG (_("There is no incoming call to accept right now!(NULL == cl) \n")); |
545 | return; | 691 | return; |
546 | } | 692 | } |
547 | 693 | ||
548 | GNUNET_CONTAINER_DLL_remove (cl_head, | 694 | GNUNET_CONTAINER_DLL_remove (cl_head, |
549 | cl_tail, | 695 | cl_tail, |
550 | cl); | 696 | cl); |
551 | cl_active = cl; | 697 | cl_active = cl; |
552 | GNUNET_free_non_null (peer_name); | 698 | GNUNET_free_non_null (peer_name); |
553 | peer_name = GNUNET_strdup (cl->caller_id); | 699 | peer_name = GNUNET_strdup (cl->caller_id); |
700 | */ | ||
701 | |||
554 | phone_state = PS_ACCEPTED; | 702 | phone_state = PS_ACCEPTED; |
555 | GNUNET_CONVERSATION_caller_pick_up (cl->caller, &caller_event_handler, cl, | 703 | set_incoming_call_state(sel_caller,CT_active); |
704 | |||
705 | |||
706 | GNUNET_CONVERSATION_caller_pick_up (sel_caller, &caller_event_handler, cl, | ||
556 | speaker, mic); | 707 | speaker, mic); |
557 | 708 | ||
558 | history_add (CH_ACCEPTED, peer_name); | 709 | history_add (CH_ACCEPTED, peer_name); |
559 | 710 | ||
560 | } | 711 | } |
561 | 712 | ||
@@ -571,7 +722,7 @@ do_accept (const char *args) | |||
571 | * @param args arguments given to the command | 722 | * @param args arguments given to the command |
572 | */ | 723 | */ |
573 | static void | 724 | static void |
574 | do_status (const char *args) | 725 | do_status () |
575 | { | 726 | { |
576 | struct CallList *cl; | 727 | struct CallList *cl; |
577 | 728 | ||
@@ -581,13 +732,13 @@ do_status (const char *args) | |||
581 | UPDATE_STATUS (_ | 732 | UPDATE_STATUS (_ |
582 | ("We are currently trying to locate the private key for the ego `%s'."), | 733 | ("We are currently trying to locate the private key for the ego `%s'."), |
583 | ego_name); | 734 | ego_name); |
584 | set_status_icon ("gnunet-conversation-tray-pending"); | 735 | set_status_icon ("gnunet-conversation-gtk-tray-pending"); |
585 | break; | 736 | break; |
586 | case PS_LISTEN: | 737 | case PS_LISTEN: |
587 | UPDATE_STATUS (_ | 738 | UPDATE_STATUS (_ |
588 | ("We are listening for incoming calls for ego `%s' on line %u."), | 739 | ("We are listening for incoming calls for ego `%s' on line %u."), |
589 | ego_name, line); | 740 | ego_name, line); |
590 | set_status_icon ("gnunet-conversation-tray-available"); | 741 | set_status_icon ("gnunet-conversation-gtk-tray-available"); |
591 | 742 | ||
592 | break; | 743 | break; |
593 | case PS_ACCEPTED: | 744 | case PS_ACCEPTED: |
@@ -610,22 +761,22 @@ do_status (const char *args) | |||
610 | UPDATE_STATUS (_ | 761 | UPDATE_STATUS (_ |
611 | ("We are trying to find the network address to call `%s'."), | 762 | ("We are trying to find the network address to call `%s'."), |
612 | peer_name); | 763 | peer_name); |
613 | set_status_icon ("gnunet-conversation-tray-call-pending"); | 764 | set_status_icon ("gnunet-conversation-gtk-tray-call-pending"); |
614 | 765 | ||
615 | break; | 766 | break; |
616 | case CS_RINGING: | 767 | case CS_RINGING: |
617 | UPDATE_STATUS (_("We are calling `%s', his phone should be ringing."), | 768 | UPDATE_STATUS (_("We are calling `%s', his phone should be ringing."), |
618 | peer_name); | 769 | peer_name); |
619 | set_status_icon ("gnunet-conversation-tray-call-ringing"); | 770 | set_status_icon ("gnunet-conversation-gtk-tray-call-ringing"); |
620 | 771 | ||
621 | break; | 772 | break; |
622 | case CS_CONNECTED: | 773 | case CS_CONNECTED: |
623 | UPDATE_STATUS (_("You are having a conversation with `%s'."), peer_name); | 774 | UPDATE_STATUS (_("You are having a conversation with `%s'."), peer_name); |
624 | set_status_icon ("gnunet-conversation-tray-call-active"); | 775 | set_status_icon ("gnunet-conversation-gtk-tray-call-active"); |
625 | 776 | ||
626 | break; | 777 | break; |
627 | case CS_SUSPENDED: | 778 | case CS_SUSPENDED: |
628 | set_status_icon ("gnunet-conversation-tray-call-suspended"); | 779 | set_status_icon ("gnunet-conversation-gtk-tray-call-suspended"); |
629 | 780 | ||
630 | /* ok to accept incoming call right now */ | 781 | /* ok to accept incoming call right now */ |
631 | break; | 782 | break; |
@@ -633,7 +784,7 @@ do_status (const char *args) | |||
633 | } | 784 | } |
634 | if ((NULL != cl_head) && ((cl_head != cl_active) || (cl_head != cl_tail))) | 785 | if ((NULL != cl_head) && ((cl_head != cl_active) || (cl_head != cl_tail))) |
635 | { | 786 | { |
636 | set_status_icon ("gnunet-conversation-tray-call-incoming"); | 787 | set_status_icon ("gnunet-conversation-gtk-tray-call-incoming"); |
637 | 788 | ||
638 | for (cl = cl_head; NULL != cl; cl = cl->next) | 789 | for (cl = cl_head; NULL != cl; cl = cl->next) |
639 | { | 790 | { |
@@ -653,8 +804,10 @@ do_status (const char *args) | |||
653 | */ | 804 | */ |
654 | 805 | ||
655 | static void | 806 | static void |
656 | do_suspend (const char *args) | 807 | do_suspend (struct GNUNET_CONVERSATION_Caller *sel_caller) |
657 | { | 808 | { |
809 | |||
810 | /* | ||
658 | if (NULL != call) | 811 | if (NULL != call) |
659 | { | 812 | { |
660 | switch (call_state) | 813 | switch (call_state) |
@@ -670,20 +823,26 @@ do_suspend (const char *args) | |||
670 | return; | 823 | return; |
671 | } | 824 | } |
672 | } | 825 | } |
826 | */ | ||
673 | switch (phone_state) | 827 | switch (phone_state) |
674 | { | 828 | { |
675 | case PS_LOOKUP_EGO: | 829 | case PS_LOOKUP_EGO: |
676 | case PS_LISTEN: | 830 | case PS_LISTEN: |
677 | case PS_ERROR: | 831 | case PS_ERROR: |
678 | LOG ("%s", _("There is no call that could be suspended right now.")); | 832 | LOG ("%s", _(" There is no call that could be suspended right now.")); |
679 | return; | 833 | return; |
680 | case PS_ACCEPTED: | 834 | case PS_ACCEPTED: |
681 | /* expected state, do rejection logic */ | 835 | /* expected state, do rejection logic */ |
682 | break; | 836 | break; |
683 | } | 837 | } |
684 | GNUNET_assert (NULL != cl_active); | 838 | |
685 | GNUNET_CONVERSATION_caller_suspend (cl_active->caller); | 839 | // GNUNET_assert (NULL != cl_active); |
686 | cl_active = NULL; | 840 | |
841 | set_incoming_call_state(sel_caller,CT_suspended); | ||
842 | GNUNET_CONVERSATION_caller_suspend (sel_caller); | ||
843 | |||
844 | // cl_active = NULL; | ||
845 | |||
687 | phone_state = PS_LISTEN; | 846 | phone_state = PS_LISTEN; |
688 | } | 847 | } |
689 | 848 | ||
@@ -694,7 +853,7 @@ do_suspend (const char *args) | |||
694 | * @param args arguments given to the command | 853 | * @param args arguments given to the command |
695 | */ | 854 | */ |
696 | static void | 855 | static void |
697 | do_resume (const char *args) | 856 | do_resume (struct GNUNET_CONVERSATION_Caller *sel_caller) |
698 | { | 857 | { |
699 | struct CallList *cl; | 858 | struct CallList *cl; |
700 | char buf[32]; | 859 | char buf[32]; |
@@ -728,6 +887,7 @@ do_resume (const char *args) | |||
728 | peer_name); | 887 | peer_name); |
729 | return; | 888 | return; |
730 | } | 889 | } |
890 | |||
731 | GNUNET_assert (NULL == cl_active); | 891 | GNUNET_assert (NULL == cl_active); |
732 | cl = cl_head; | 892 | cl = cl_head; |
733 | if (NULL == cl) | 893 | if (NULL == cl) |
@@ -735,22 +895,23 @@ do_resume (const char *args) | |||
735 | LOG (_("There is no incoming call to resume here!")); | 895 | LOG (_("There is no incoming call to resume here!")); |
736 | return; | 896 | return; |
737 | } | 897 | } |
738 | if ((NULL != cl->next) || (NULL != args)) | 898 | if (NULL != cl->next) |
739 | { | 899 | { |
740 | for (cl = cl_head; NULL != cl; cl = cl->next) | 900 | for (cl = cl_head; NULL != cl; cl = cl->next) |
741 | { | 901 | { |
742 | GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num); | 902 | GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num); |
743 | if (0 == strcmp (buf, args)) | ||
744 | break; | ||
745 | } | 903 | } |
746 | } | 904 | } |
747 | if (NULL == cl) | 905 | if (NULL == cl) |
748 | { | 906 | { |
749 | LOG (_("There is no incoming call `%s' to resume right now!"), args); | 907 | LOG (_("There is no incoming call to resume right now! (null == cl)")); |
750 | return; | 908 | return; |
751 | } | 909 | } |
752 | cl_active = cl; | 910 | cl_active = cl; |
753 | GNUNET_CONVERSATION_caller_resume (cl_active->caller, speaker, mic); | 911 | |
912 | set_incoming_call_state(sel_caller,CT_active); | ||
913 | |||
914 | GNUNET_CONVERSATION_caller_resume (sel_caller, speaker, mic); | ||
754 | phone_state = PS_ACCEPTED; | 915 | phone_state = PS_ACCEPTED; |
755 | } | 916 | } |
756 | 917 | ||
@@ -761,10 +922,12 @@ do_resume (const char *args) | |||
761 | * @param args arguments given to the command | 922 | * @param args arguments given to the command |
762 | */ | 923 | */ |
763 | static void | 924 | static void |
764 | do_reject (const char *args) | 925 | do_reject (struct GNUNET_CONVERSATION_Caller *sel_caller) |
765 | { | 926 | { |
766 | struct CallList *cl; | 927 | struct CallList *cl; |
767 | char buf[32]; | 928 | char buf[32]; |
929 | LOG("do reject"); | ||
930 | // set_incoming_call_state(sel_caller,CT_rejected); | ||
768 | 931 | ||
769 | if (NULL != call) | 932 | if (NULL != call) |
770 | { | 933 | { |
@@ -780,6 +943,7 @@ do_reject (const char *args) | |||
780 | return; | 943 | return; |
781 | case PS_LISTEN: | 944 | case PS_LISTEN: |
782 | /* look for active incoming calls to refuse */ | 945 | /* look for active incoming calls to refuse */ |
946 | /* | ||
783 | cl = cl_head; | 947 | cl = cl_head; |
784 | if (NULL == cl) | 948 | if (NULL == cl) |
785 | { | 949 | { |
@@ -800,22 +964,32 @@ do_reject (const char *args) | |||
800 | LOG (_("There is no incoming call `%s' to refuse right now!\n"), args); | 964 | LOG (_("There is no incoming call `%s' to refuse right now!\n"), args); |
801 | return; | 965 | return; |
802 | } | 966 | } |
803 | GNUNET_CONVERSATION_caller_hang_up (cl->caller); | 967 | */ |
968 | //GNUNET_CONVERSATION_caller_hang_up (cl->caller); | ||
969 | set_incoming_call_state(sel_caller,CT_rejected); | ||
970 | GNUNET_CONVERSATION_caller_hang_up(sel_caller); | ||
971 | |||
972 | /* | ||
804 | GNUNET_CONTAINER_DLL_remove (cl_head, cl_tail, cl); | 973 | GNUNET_CONTAINER_DLL_remove (cl_head, cl_tail, cl); |
805 | peer_name = GNUNET_strdup (cl->caller_id); | 974 | peer_name = GNUNET_strdup (cl->caller_id); |
806 | GNUNET_free (cl->caller_id); | 975 | GNUNET_free (cl->caller_id); |
807 | GNUNET_free (cl); | 976 | GNUNET_free (cl); |
977 | */ | ||
808 | // caller_num_gen--; | 978 | // caller_num_gen--; |
809 | break; | 979 | break; |
810 | case PS_ACCEPTED: | 980 | case PS_ACCEPTED: |
811 | /* expected state, do rejection logic */ | 981 | /* expected state, do rejection logic */ |
812 | history_add (CH_REJECTED, peer_name); | 982 | history_add (CH_REJECTED, peer_name); |
983 | /* | ||
813 | GNUNET_assert (NULL != cl_active); | 984 | GNUNET_assert (NULL != cl_active); |
814 | GNUNET_CONVERSATION_caller_hang_up (cl_active->caller); | 985 | GNUNET_CONVERSATION_caller_hang_up (cl_active->caller); |
815 | GNUNET_free (cl_active->caller_id); | 986 | GNUNET_free (cl_active->caller_id); |
816 | GNUNET_free (cl_active); | 987 | GNUNET_free (cl_active); |
817 | GNUNET_assert (caller_num_gen > 0); | 988 | GNUNET_assert (caller_num_gen > 0); |
818 | // caller_num_gen--; | 989 | // caller_num_gen--; |
990 | */ | ||
991 | set_incoming_call_state(sel_caller,CT_hangup); | ||
992 | GNUNET_CONVERSATION_caller_hang_up(sel_caller); | ||
819 | cl_active = NULL; | 993 | cl_active = NULL; |
820 | phone_state = PS_LISTEN; | 994 | phone_state = PS_LISTEN; |
821 | break; | 995 | break; |
@@ -982,12 +1156,11 @@ identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, | |||
982 | { | 1156 | { |
983 | GNUNET_IDENTITY_ego_get_public_key (ego, &pk); | 1157 | GNUNET_IDENTITY_ego_get_public_key (ego, &pk); |
984 | s = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk); | 1158 | s = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk); |
985 | fprintf (stdout, "%s \n", name); | 1159 | // fprintf (stdout, "%s \n", name); |
986 | gtk_list_store_insert_with_values (zone_liststore, | 1160 | // gtk_list_store_insert_with_values (zone_liststore, |
987 | &iter, -1, | 1161 | // &iter, -1, |
988 | 0, name, | 1162 | // 0, name, |
989 | 1, ego, | 1163 | // -1); |
990 | -1); | ||
991 | } | 1164 | } |
992 | 1165 | ||
993 | 1166 | ||
@@ -997,7 +1170,7 @@ identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, | |||
997 | { | 1170 | { |
998 | if (verbose) | 1171 | if (verbose) |
999 | LOG (_("Name of our ego changed to `%s'\n"), name); | 1172 | LOG (_("Name of our ego changed to `%s'\n"), name); |
1000 | GNUNET_free (ego_name); | 1173 | //GNUNET_free (ego_name); |
1001 | ego_name = GNUNET_strdup (name); | 1174 | ego_name = GNUNET_strdup (name); |
1002 | return; | 1175 | return; |
1003 | } | 1176 | } |
@@ -1112,7 +1285,7 @@ GNUNET_GTK_conversation_quit_cb (GObject * object, gpointer user_data) | |||
1112 | GNUNET_MICROPHONE_destroy (mic); | 1285 | GNUNET_MICROPHONE_destroy (mic); |
1113 | mic = NULL; | 1286 | mic = NULL; |
1114 | ego_name = NULL; | 1287 | ego_name = NULL; |
1115 | GNUNET_free_non_null (peer_name); | 1288 | //GNUNET_free_non_null (peer_name); |
1116 | phone_state = PS_ERROR; | 1289 | phone_state = PS_ERROR; |
1117 | 1290 | ||
1118 | GNUNET_SCHEDULER_shutdown (); | 1291 | GNUNET_SCHEDULER_shutdown (); |
@@ -1275,6 +1448,7 @@ main (int argc, char *const *argv) | |||
1275 | * @param caller_id | 1448 | * @param caller_id |
1276 | */ | 1449 | */ |
1277 | 1450 | ||
1451 | /* | ||
1278 | void | 1452 | void |
1279 | quick_message (gchar * message, const char *caller_id) | 1453 | quick_message (gchar * message, const char *caller_id) |
1280 | { | 1454 | { |
@@ -1309,10 +1483,10 @@ quick_message (gchar * message, const char *caller_id) | |||
1309 | case GTK_RESPONSE_ACCEPT: | 1483 | case GTK_RESPONSE_ACCEPT: |
1310 | do_status (""); | 1484 | do_status (""); |
1311 | gtk_widget_destroy (GTK_WIDGET (dialog)); | 1485 | gtk_widget_destroy (GTK_WIDGET (dialog)); |
1312 | do_accept ("0"); | 1486 | // do_accept ("0"); |
1313 | break; | 1487 | break; |
1314 | case GTK_RESPONSE_REJECT: | 1488 | case GTK_RESPONSE_REJECT: |
1315 | do_reject ("0"); | 1489 | // do_reject (caller_selected); |
1316 | do_status (""); | 1490 | do_status (""); |
1317 | gtk_widget_destroy (GTK_WIDGET (dialog)); | 1491 | gtk_widget_destroy (GTK_WIDGET (dialog)); |
1318 | break; | 1492 | break; |
@@ -1324,7 +1498,7 @@ quick_message (gchar * message, const char *caller_id) | |||
1324 | 1498 | ||
1325 | 1499 | ||
1326 | } | 1500 | } |
1327 | 1501 | */ | |
1328 | 1502 | ||
1329 | 1503 | ||
1330 | 1504 | ||
@@ -1346,8 +1520,8 @@ GNUNET_CONVERSATION_GTK_on_call_clicked () | |||
1346 | // FPRINTF (stderr, _("calling: %s \n"), to_addr ); | 1520 | // FPRINTF (stderr, _("calling: %s \n"), to_addr ); |
1347 | 1521 | ||
1348 | do_call (to_addr); | 1522 | do_call (to_addr); |
1349 | disable_button ("GNUNET_GTK_conversation_accept_button"); | 1523 | //disable_button ("GNUNET_GTK_conversation_accept_button"); |
1350 | do_status (""); | 1524 | do_status (); |
1351 | // free(to_addr); | 1525 | // free(to_addr); |
1352 | } | 1526 | } |
1353 | 1527 | ||
@@ -1357,14 +1531,18 @@ GNUNET_CONVERSATION_GTK_on_call_clicked () | |||
1357 | void | 1531 | void |
1358 | GNUNET_CONVERSATION_GTK_on_hangup_clicked () | 1532 | GNUNET_CONVERSATION_GTK_on_hangup_clicked () |
1359 | { | 1533 | { |
1360 | //update_status()disable_button("GNUNET_CONVERSATION_GTK_call_button"); | 1534 | //update_status() |
1535 | //disable_button("GNUNET_CONVERSATION_GTK_call_button"); | ||
1536 | //FPRINTF (stderr, "hangup clicked \n"); | ||
1361 | 1537 | ||
1362 | enable_button ("GNUNET_GTK_conversation_call_button"); | 1538 | // enable_button ("GNUNET_GTK_conversation_call_button"); |
1363 | 1539 | ||
1364 | 1540 | ||
1365 | //FPRINTF (stderr, "hangup clicked \n"); | 1541 | //FPRINTF (stderr, "hangup clicked \n"); |
1366 | do_reject (NULL); | 1542 | |
1367 | do_status (""); | 1543 | do_reject (caller_selected); |
1544 | |||
1545 | do_status (); | ||
1368 | //history_add(3,peer_name); | 1546 | //history_add(3,peer_name); |
1369 | } | 1547 | } |
1370 | 1548 | ||
@@ -1374,8 +1552,8 @@ GNUNET_CONVERSATION_GTK_on_hangup_clicked () | |||
1374 | void | 1552 | void |
1375 | GNUNET_CONVERSATION_GTK_on_accept_clicked () | 1553 | GNUNET_CONVERSATION_GTK_on_accept_clicked () |
1376 | { | 1554 | { |
1377 | FPRINTF (stderr, "accept clicked \n"); | 1555 | //FPRINTF (stderr, "accept clicked \n"); |
1378 | do_accept (0); | 1556 | do_accept (caller_selected); |
1379 | // hide_infobar (); | 1557 | // hide_infobar (); |
1380 | } | 1558 | } |
1381 | 1559 | ||
@@ -1387,7 +1565,7 @@ void | |||
1387 | GNUNET_CONVERSATION_GTK_on_reject_clicked () | 1565 | GNUNET_CONVERSATION_GTK_on_reject_clicked () |
1388 | { | 1566 | { |
1389 | LOG ("reject clicked \n"); | 1567 | LOG ("reject clicked \n"); |
1390 | do_reject ("0"); | 1568 | do_reject (caller_selected); |
1391 | } | 1569 | } |
1392 | 1570 | ||
1393 | /** | 1571 | /** |
@@ -1397,7 +1575,7 @@ void | |||
1397 | GNUNET_CONVERSATION_GTK_on_pause_clicked () | 1575 | GNUNET_CONVERSATION_GTK_on_pause_clicked () |
1398 | { | 1576 | { |
1399 | // GtkEntry *entry; | 1577 | // GtkEntry *entry; |
1400 | do_suspend ("0"); | 1578 | do_suspend (caller_selected); |
1401 | //FPRINTF (stderr, "pause clicked \n"); | 1579 | //FPRINTF (stderr, "pause clicked \n"); |
1402 | //do_pause(""); | 1580 | //do_pause(""); |
1403 | // entry = GTK_ENTRY((get_object ("GNUNET_GTK_conversation_address"))); | 1581 | // entry = GTK_ENTRY((get_object ("GNUNET_GTK_conversation_address"))); |
@@ -1413,7 +1591,7 @@ void | |||
1413 | GNUNET_CONVERSATION_GTK_on_resume_clicked () | 1591 | GNUNET_CONVERSATION_GTK_on_resume_clicked () |
1414 | { | 1592 | { |
1415 | //FPRINTF (stderr, "reject clicked \n"); | 1593 | //FPRINTF (stderr, "reject clicked \n"); |
1416 | do_resume (""); | 1594 | do_resume (caller_selected); |
1417 | } | 1595 | } |
1418 | 1596 | ||
1419 | /** | 1597 | /** |
@@ -1425,7 +1603,7 @@ GNUNET_CONVERSATION_GTK_on_status_clicked () | |||
1425 | 1603 | ||
1426 | 1604 | ||
1427 | // do_accept("0"); | 1605 | // do_accept("0"); |
1428 | do_status (" "); | 1606 | do_status (); |
1429 | //quick_message('hee blaaat you have a call from blaat'); | 1607 | //quick_message('hee blaaat you have a call from blaat'); |
1430 | } | 1608 | } |
1431 | 1609 | ||
@@ -1455,9 +1633,9 @@ add_contact (const gchar * name, const gchar * address) | |||
1455 | rd.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; // always set to relative for testing purposes | 1633 | rd.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; // always set to relative for testing purposes |
1456 | rde->flags |= GNUNET_GNSRECORD_RF_PRIVATE; | 1634 | rde->flags |= GNUNET_GNSRECORD_RF_PRIVATE; |
1457 | rde->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; | 1635 | rde->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; |
1458 | FPRINTF (stderr, "adding\n"); | 1636 | //FPRINTF (stderr, "adding\n"); |
1459 | FPRINTF (stderr, "name: %s\n", name); | 1637 | //FPRINTF (stderr, "name: %s\n", name); |
1460 | FPRINTF (stderr, "address: %s\n", address); | 1638 | //FPRINTF (stderr, "address: %s\n", address); |
1461 | if (GNUNET_OK != | 1639 | if (GNUNET_OK != |
1462 | GNUNET_GNSRECORD_string_to_value (65536, address, &data, &data_size)) | 1640 | GNUNET_GNSRECORD_string_to_value (65536, address, &data, &data_size)) |
1463 | { | 1641 | { |
@@ -1509,7 +1687,7 @@ GNUNET_CONVERSATION_GTK_on_remove_clicked (GtkButton * button, | |||
1509 | if (gtk_tree_selection_get_selected (selection, &model, &iter)) | 1687 | if (gtk_tree_selection_get_selected (selection, &model, &iter)) |
1510 | { | 1688 | { |
1511 | gtk_tree_model_get (model, &iter, 0, &name, -1); | 1689 | gtk_tree_model_get (model, &iter, 0, &name, -1); |
1512 | FPRINTF (stderr, "selected %s \n", name); | 1690 | //FPRINTF (stderr, "selected %s \n", name); |
1513 | main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window")); | 1691 | main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window")); |
1514 | confirm = | 1692 | confirm = |
1515 | GTK_DIALOG (gtk_dialog_new_with_buttons | 1693 | GTK_DIALOG (gtk_dialog_new_with_buttons |
@@ -1566,7 +1744,7 @@ GNUNET_CONVERSATION_GTK_row_activated () | |||
1566 | gchar *callAddress; | 1744 | gchar *callAddress; |
1567 | gchar *type; | 1745 | gchar *type; |
1568 | 1746 | ||
1569 | FPRINTF (stderr, "row activated \n"); | 1747 | // FPRINTF (stderr, "row activated \n"); |
1570 | 1748 | ||
1571 | GtkTreeSelection *selection; | 1749 | GtkTreeSelection *selection; |
1572 | 1750 | ||
@@ -1577,9 +1755,9 @@ GNUNET_CONVERSATION_GTK_row_activated () | |||
1577 | 1755 | ||
1578 | gtk_tree_selection_get_selected (selection, &contacts_treemodel, &iterA); | 1756 | gtk_tree_selection_get_selected (selection, &contacts_treemodel, &iterA); |
1579 | gtk_tree_model_get (contacts_treemodel, &iterA, 0, &name, 1, &type, -1); | 1757 | gtk_tree_model_get (contacts_treemodel, &iterA, 0, &name, 1, &type, -1); |
1580 | g_print ("ego name %s\n", ego_name); | 1758 | // g_print ("ego name %s\n", ego_name); |
1581 | g_print ("selected row is: %s\n", name); | 1759 | // g_print ("selected row is: %s\n", name); |
1582 | g_print ("selected rowtype is: %s\n", type); | 1760 | // g_print ("selected rowtype is: %s\n", type); |
1583 | 1761 | ||
1584 | 1762 | ||
1585 | g_print ("type @row active%s", type); | 1763 | g_print ("type @row active%s", type); |
@@ -1602,41 +1780,6 @@ GNUNET_CONVERSATION_GTK_row_activated () | |||
1602 | } | 1780 | } |
1603 | 1781 | ||
1604 | /* | 1782 | /* |
1605 | * set_status_icon | ||
1606 | * | ||
1607 | * available icons: | ||
1608 | * gnunet-conversation-tray-pending | ||
1609 | * gnunet-conversation-tray-available | ||
1610 | * gnunet-conversation-tray-offline | ||
1611 | * gnunet-conversation-tray-call-pending | ||
1612 | * gnunet-conversation-tray-call-ringing | ||
1613 | * gnunet-conversation-tray-call-active | ||
1614 | * gnunet-conversation-tray-call-suspended | ||
1615 | * gnunet-conversation-tray-call-incoming | ||
1616 | * | ||
1617 | */ | ||
1618 | |||
1619 | void | ||
1620 | set_status_icon (const char *icon_name) | ||
1621 | { | ||
1622 | GtkWindow *main_window; | ||
1623 | GtkImage *status_icon; | ||
1624 | |||
1625 | |||
1626 | |||
1627 | main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window")); | ||
1628 | |||
1629 | status_icon = GTK_IMAGE (get_object ("GNUNET_GTK_status_icon")); | ||
1630 | |||
1631 | gtk_image_set_from_icon_name (status_icon, icon_name, GTK_ICON_SIZE_BUTTON); | ||
1632 | |||
1633 | LOG (_("Tray icon changed to: `%s' "), icon_name); | ||
1634 | |||
1635 | |||
1636 | |||
1637 | GNUNET_GTK_tray_icon_change (icon_name, "gnunet-conversation-gtk-status"); | ||
1638 | } | ||
1639 | |||
1640 | static void | 1783 | static void |
1641 | print_ego (void *cls, | 1784 | print_ego (void *cls, |
1642 | struct GNUNET_IDENTITY_Ego *ego, | 1785 | struct GNUNET_IDENTITY_Ego *ego, |
@@ -1650,7 +1793,7 @@ print_ego (void *cls, | |||
1650 | fprintf (stdout, "%s \n", identifier); | 1793 | fprintf (stdout, "%s \n", identifier); |
1651 | // GNUNET_free (s); | 1794 | // GNUNET_free (s); |
1652 | } | 1795 | } |
1653 | 1796 | */ | |
1654 | 1797 | ||
1655 | /* end of gnunet-conversation-gtk.c */ | 1798 | /* end of gnunet-conversation-gtk.c */ |
1656 | void | 1799 | void |
@@ -1665,30 +1808,28 @@ GNUNET_contact_test () | |||
1665 | // struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc; | 1808 | // struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc; |
1666 | // edc = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginEnvironment); | 1809 | // edc = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginEnvironment); |
1667 | */ | 1810 | */ |
1668 | // GtkTreeIter iter; | ||
1669 | // char *caller_id = "testje"; | ||
1670 | // int caller_num = 10; | ||
1671 | |||
1672 | /* | ||
1673 | * active_liststore: | ||
1674 | * 0: *gchar caller_id | ||
1675 | * 1: pointer caller | ||
1676 | * 2: gint caller_num | ||
1677 | */ | ||
1678 | /* | ||
1679 | gtk_list_store_append (active_liststore, &iter); | ||
1680 | 1811 | ||
1812 | GtkTreeIter iter; | ||
1813 | char *caller_id = "testje"; | ||
1814 | int caller_num = 10; | ||
1815 | |||
1816 | enum { | ||
1817 | AL_caller_id, // *gchar | ||
1818 | AL_caller, // * | ||
1819 | AL_caller_num //gint | ||
1820 | }; | ||
1821 | |||
1822 | gtk_list_store_append (active_liststore, &iter); | ||
1681 | gtk_list_store_set (active_liststore, &iter, 2, caller_num, 0, caller_id, -1); | 1823 | gtk_list_store_set (active_liststore, &iter, 2, caller_num, 0, caller_id, -1); |
1682 | 1824 | ||
1683 | gtk_list_store_insert_with_values (zone_liststore, | 1825 | gtk_list_store_insert_with_values (zone_liststore, |
1684 | &iter, -1, | 1826 | &iter, -1, |
1685 | 0, "test", | 1827 | 0, "test", |
1686 | -1); | 1828 | -1); |
1687 | */ | ||
1688 | // static struct GNUNET_IDENTITY_Handle *sh; | 1829 | // static struct GNUNET_IDENTITY_Handle *sh; |
1689 | // GNUNET_IDENTITY_disconnect (id); | 1830 | // GNUNET_IDENTITY_disconnect (id); |
1690 | // &print_ego; | 1831 | // &print_ego; |
1691 | //sh = GNUNET_IDENTITY_connect (cfg, &print_ego, NULL); | 1832 | //sh = GNUNET_IDENTITY_connect (cfg, &print_ego, NULL); |
1692 | // GNUNET_NAMESTORE_zone_iterator_next(list_it); | 1833 | // GNUNET_NAMESTORE_zone_iterator_next(list_it); |
1693 | } | 1834 | } |
1694 | 1835 | ||
@@ -1715,7 +1856,6 @@ gnunet_conversation_gtk_contacts_zone_combobox_changed_cb (GtkComboBox *widget, | |||
1715 | char *tempName; | 1856 | char *tempName; |
1716 | struct GNUNET_CRYPTO_EcdsaPrivateKey temp_zone_pkey; | 1857 | struct GNUNET_CRYPTO_EcdsaPrivateKey temp_zone_pkey; |
1717 | 1858 | ||
1718 | |||
1719 | gtk_combo_box_get_active_iter(widget, &contacts_zone_iter); | 1859 | gtk_combo_box_get_active_iter(widget, &contacts_zone_iter); |
1720 | 1860 | ||
1721 | gtk_tree_model_get (GTK_TREE_MODEL (zone_liststore), | 1861 | gtk_tree_model_get (GTK_TREE_MODEL (zone_liststore), |
@@ -1740,3 +1880,114 @@ gnunet_conversation_gtk_contacts_zone_combobox_changed_cb (GtkComboBox *widget, | |||
1740 | 1880 | ||
1741 | } | 1881 | } |
1742 | 1882 | ||
1883 | /* | ||
1884 | * @brief print info for currently selected call | ||
1885 | */ | ||
1886 | void | ||
1887 | print_call_info() | ||
1888 | { | ||
1889 | GtkTreeIter gtkiter; | ||
1890 | gboolean valid; | ||
1891 | gint row_count = 0; | ||
1892 | |||
1893 | //LOG("test"); | ||
1894 | valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), >kiter ); | ||
1895 | |||
1896 | if (!valid) | ||
1897 | GNUNET_break(0); | ||
1898 | |||
1899 | while (valid) | ||
1900 | { | ||
1901 | gchar *str_data; | ||
1902 | gint int_data; | ||
1903 | gpointer cl_caller; | ||
1904 | |||
1905 | gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), >kiter, | ||
1906 | AL_caller, &cl_caller, | ||
1907 | AL_caller_id,&str_data, | ||
1908 | AL_caller_num,&int_data,-1); | ||
1909 | if (caller_selected == cl_caller) | ||
1910 | { | ||
1911 | // LOG (_("info for active call:%s number: %u row: %u"), str_data,int_data,row_count); | ||
1912 | //break ; | ||
1913 | } | ||
1914 | g_free (str_data); | ||
1915 | row_count++; | ||
1916 | valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), >kiter); | ||
1917 | } | ||
1918 | |||
1919 | |||
1920 | |||
1921 | } | ||
1922 | |||
1923 | /* | ||
1924 | * @brief executed when selecting a call | ||
1925 | */ | ||
1926 | |||
1927 | void | ||
1928 | GNUNET_CONVERSATION_GTK_on_active_calls_selection_changed() | ||
1929 | { | ||
1930 | gchar *caller_id; | ||
1931 | gpointer cl_caller; | ||
1932 | GtkTreeSelection *active_selection; | ||
1933 | GtkTreeIter gcl_selected; | ||
1934 | // active_liststore_selection = get_object("GNUNET_CONVERSATION_GTK_active_calls_selection"); | ||
1935 | |||
1936 | active_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (active_treeview)); | ||
1937 | |||
1938 | |||
1939 | if (gtk_tree_selection_get_selected(active_selection,NULL,&gcl_selected)) | ||
1940 | { | ||
1941 | |||
1942 | gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), &gcl_selected, | ||
1943 | AL_caller, &cl_caller, | ||
1944 | AL_caller_id, &caller_id, | ||
1945 | -1); | ||
1946 | |||
1947 | caller_selected = cl_caller; | ||
1948 | |||
1949 | //LOG("SELECTION: %s ",caller_id); | ||
1950 | print_call_info(); | ||
1951 | |||
1952 | } | ||
1953 | } | ||
1954 | /* | ||
1955 | * @brief active call list type data function | ||
1956 | */ | ||
1957 | void | ||
1958 | active_calls_type_data_function (GtkTreeViewColumn *col, | ||
1959 | GtkCellRenderer *renderer, | ||
1960 | GtkTreeModel *model, | ||
1961 | GtkTreeIter *iter, | ||
1962 | gpointer user_data) | ||
1963 | { | ||
1964 | gint state; | ||
1965 | gchar buf[20]; | ||
1966 | |||
1967 | //gtk_tree_model_get(model, iter, AL_caller_state, &state, -1); | ||
1968 | |||
1969 | //g_snprintf(buf, sizeof(buf), "state: %u", state); | ||
1970 | |||
1971 | //g_object_set(renderer, "text", buf, NULL); | ||
1972 | } | ||
1973 | |||
1974 | |||
1975 | /* | ||
1976 | * @brief second test button | ||
1977 | */ | ||
1978 | void | ||
1979 | GNUNET_CONVERSATION_GTK_test_button_two() | ||
1980 | { | ||
1981 | GtkTreeViewColumn *column; | ||
1982 | GtkCellRenderer *cell; | ||
1983 | |||
1984 | //LOG("test"); | ||
1985 | // treeview = get_object("gnunet_conversation_gtk_active_calls_treeview"); | ||
1986 | column = get_object("GNUNET_CONVERSATION_GTK_caller_typeColumn"); | ||
1987 | cell = gtk_cell_renderer_text_new(); | ||
1988 | //cell = get_object("GNUNET_CONVERSATION_GTK_active_calls_type"); | ||
1989 | gtk_tree_view_column_set_cell_data_func(column, cell, active_calls_type_data_function, NULL, NULL ); | ||
1990 | |||
1991 | } | ||
1992 | |||
1993 | |||