diff options
Diffstat (limited to 'src/conversation/gnunet-conversation-gtk.c')
-rw-r--r-- | src/conversation/gnunet-conversation-gtk.c | 952 |
1 files changed, 581 insertions, 371 deletions
diff --git a/src/conversation/gnunet-conversation-gtk.c b/src/conversation/gnunet-conversation-gtk.c index 897ba078..4ae137d5 100644 --- a/src/conversation/gnunet-conversation-gtk.c +++ b/src/conversation/gnunet-conversation-gtk.c | |||
@@ -30,6 +30,8 @@ | |||
30 | 30 | ||
31 | 31 | ||
32 | struct GNUNET_CONVERSATION_Caller *caller_selected = NULL; | 32 | struct GNUNET_CONVERSATION_Caller *caller_selected = NULL; |
33 | struct GNUNET_CONVERSATION_Call *call_selected = NULL; | ||
34 | |||
33 | /************* | 35 | /************* |
34 | * common * | 36 | * common * |
35 | *************/ | 37 | *************/ |
@@ -76,17 +78,17 @@ static int tray_only; | |||
76 | * Current state of iterating elements for the client. | 78 | * Current state of iterating elements for the client. |
77 | * NULL if we are not currently iterating. | 79 | * NULL if we are not currently iterating. |
78 | */ | 80 | */ |
79 | struct GNUNET_CONTAINER_MultiHashMapIterator *iter; | 81 | static struct GNUNET_CONTAINER_MultiHashMapIterator *iter; |
80 | 82 | ||
81 | /** | 83 | /** |
82 | *name of the incomming caller pkey or record name if known | 84 | *name of the incomming caller pkey or record name if known |
83 | */ | 85 | */ |
84 | char *callerName; | 86 | static char *callerName; |
85 | 87 | ||
86 | /** | 88 | /** |
87 | * peer id of a contact | 89 | * peer id of a contact |
88 | */ | 90 | */ |
89 | char *peer_id; | 91 | static char *peer_id; |
90 | 92 | ||
91 | /** | 93 | /** |
92 | * List of active calls | 94 | * List of active calls |
@@ -101,7 +103,7 @@ static GtkTreeView *active_treeview; | |||
101 | /** | 103 | /** |
102 | * List of incoming calls | 104 | * List of incoming calls |
103 | */ | 105 | */ |
104 | struct CallList | 106 | static struct CallList |
105 | { | 107 | { |
106 | 108 | ||
107 | /** | 109 | /** |
@@ -130,11 +132,16 @@ struct CallList | |||
130 | char *caller_id; | 132 | char *caller_id; |
131 | 133 | ||
132 | /** | 134 | /** |
133 | * Unique number of the call. | 135 | * Unique number of the caller. |
134 | */ | 136 | */ |
135 | unsigned int caller_num; | 137 | unsigned int caller_num; |
136 | 138 | ||
137 | }; | 139 | }; |
140 | /** | ||
141 | * Unique number of call (outgoing) | ||
142 | */ | ||
143 | unsigned int call_counter; | ||
144 | |||
138 | 145 | ||
139 | /** | 146 | /** |
140 | * Phone handle | 147 | * Phone handle |
@@ -212,6 +219,9 @@ static unsigned int caller_num_gen; | |||
212 | */ | 219 | */ |
213 | static char *address; | 220 | static char *address; |
214 | 221 | ||
222 | GtkWidget *b_contact, *b_accept, *b_hangup, *b_suspend, *b_resume; | ||
223 | |||
224 | |||
215 | /******************* | 225 | /******************* |
216 | * identity select * | 226 | * identity select * |
217 | *******************/ | 227 | *******************/ |
@@ -280,20 +290,123 @@ GNUNET_CONVERSATION_GTK_log_message (const char *message) | |||
280 | 290 | ||
281 | } | 291 | } |
282 | 292 | ||
283 | |||
284 | /** | 293 | /** |
285 | * does nothing | 294 | * update status |
295 | * | ||
296 | * @param message Message to put in statusbar | ||
286 | */ | 297 | */ |
287 | 298 | ||
288 | void | 299 | static void |
289 | update_state () | 300 | update_status (const gchar * message) |
290 | { | 301 | { |
291 | // LOG('update_state called',NULL); | 302 | |
303 | GtkStatusbar *status_bar; | ||
304 | guint status_bar_context; | ||
305 | |||
306 | gchar *buff; | ||
307 | |||
308 | status_bar = GTK_STATUSBAR (get_object ("GNUNET_GTK_conversation_statusbar")); | ||
309 | status_bar_context = gtk_statusbar_get_context_id (status_bar, "blaat"); | ||
310 | |||
311 | |||
312 | buff = g_strdup_printf ("%s", message); | ||
313 | |||
314 | gtk_statusbar_push (GTK_STATUSBAR (status_bar), | ||
315 | GPOINTER_TO_INT (status_bar_context), buff); | ||
316 | g_free (buff); | ||
317 | |||
318 | GNUNET_CONVERSATION_GTK_on_active_calls_selection_changed(); | ||
319 | |||
320 | |||
292 | } | 321 | } |
322 | |||
323 | |||
324 | /** | ||
325 | * update statusbar | ||
326 | * | ||
327 | * @param args arguments given to the command | ||
328 | */ | ||
329 | static void | ||
330 | do_status () | ||
331 | { | ||
332 | struct CallList *cl; | ||
333 | |||
334 | switch (phone_state) | ||
335 | { | ||
336 | case PS_LOOKUP_EGO: | ||
337 | UPDATE_STATUS (_ | ||
338 | ("We are currently trying to locate the private key for the ego `%s'."), | ||
339 | ego_name); | ||
340 | set_status_icon ("gnunet-conversation-gtk-tray-pending"); | ||
341 | break; | ||
342 | case PS_LISTEN: | ||
343 | UPDATE_STATUS (_ | ||
344 | ("We are listening for incoming calls for ego `%s' on line %u."), | ||
345 | ego_name, line); | ||
346 | set_status_icon ("gnunet-conversation-gtk-tray-available"); | ||
347 | |||
348 | break; | ||
349 | case PS_ACCEPTED: | ||
350 | UPDATE_STATUS (_("You are having a conversation with `%s'.\n"), peer_name); | ||
351 | set_status_icon ("gnunet-conversation-call-active"); | ||
352 | |||
353 | break; | ||
354 | case PS_ERROR: | ||
355 | UPDATE_STATUS (_ | ||
356 | ("We had an internal error setting up our phone line. You can still make calls.")); | ||
357 | set_status_icon ("gnunet-conversation-offline"); | ||
358 | |||
359 | break; | ||
360 | } | ||
361 | if (NULL != call) | ||
362 | { | ||
363 | switch (call_state) | ||
364 | { | ||
365 | case CS_RESOLVING: | ||
366 | UPDATE_STATUS (_ | ||
367 | ("We are trying to find the network address to call `%s'."), | ||
368 | peer_name); | ||
369 | set_status_icon ("gnunet-conversation-gtk-tray-call-pending"); | ||
370 | |||
371 | break; | ||
372 | case CS_RINGING: | ||
373 | UPDATE_STATUS (_("We are calling `%s', his phone should be ringing."), | ||
374 | peer_name); | ||
375 | set_status_icon ("gnunet-conversation-gtk-tray-call-ringing"); | ||
376 | |||
377 | break; | ||
378 | case CS_CONNECTED: | ||
379 | UPDATE_STATUS (_("You are having a conversation with `%s'."), peer_name); | ||
380 | set_status_icon ("gnunet-conversation-gtk-tray-call-active"); | ||
381 | |||
382 | break; | ||
383 | case CS_SUSPENDED: | ||
384 | set_status_icon ("gnunet-conversation-gtk-tray-call-suspended"); | ||
385 | |||
386 | /* ok to accept incoming call right now */ | ||
387 | break; | ||
388 | } | ||
389 | } | ||
390 | if ((NULL != cl_head) && ((cl_head != cl_active) || (cl_head != cl_tail))) | ||
391 | { | ||
392 | set_status_icon ("gnunet-conversation-gtk-tray-call-incoming"); | ||
393 | |||
394 | for (cl = cl_head; NULL != cl; cl = cl->next) | ||
395 | { | ||
396 | if (cl == cl_active) | ||
397 | continue; | ||
398 | //UPDATE_STATUS (_("#%u: `%s'"), cl->caller_num, cl->caller_id); | ||
399 | // LOG ("%s", _("Calls waiting:")); | ||
400 | } | ||
401 | } | ||
402 | } | ||
403 | |||
404 | |||
405 | |||
293 | /* | 406 | /* |
294 | * @brief print info for currently selected call | 407 | * @brief print info for currently selected call |
295 | */ | 408 | */ |
296 | void | 409 | static void |
297 | print_call_info() | 410 | print_call_info() |
298 | { | 411 | { |
299 | GtkTreeIter gtkiter; | 412 | GtkTreeIter gtkiter; |
@@ -310,11 +423,14 @@ print_call_info() | |||
310 | gchar *str_data; | 423 | gchar *str_data; |
311 | gint int_data; | 424 | gint int_data; |
312 | gpointer cl_caller; | 425 | gpointer cl_caller; |
313 | 426 | gpointer cl_call; | |
427 | |||
314 | gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), >kiter, | 428 | gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), >kiter, |
315 | AL_caller, &cl_caller, | 429 | AL_caller, &cl_caller, |
316 | AL_caller_id,&str_data, | 430 | AL_caller_id, &str_data, |
317 | AL_caller_num,&int_data,-1); | 431 | AL_caller_num, &int_data, |
432 | AL_call, &cl_call, | ||
433 | -1); | ||
318 | if (caller_selected == cl_caller) | 434 | if (caller_selected == cl_caller) |
319 | { | 435 | { |
320 | // LOG (_("info for active call:%s number: %u row: %u"), str_data,int_data,row_count); | 436 | // LOG (_("info for active call:%s number: %u row: %u"), str_data,int_data,row_count); |
@@ -322,6 +438,11 @@ print_call_info() | |||
322 | // FPRINTF(stderr,"cal addr: %s\n",currentlySelectedCallAddress); | 438 | // FPRINTF(stderr,"cal addr: %s\n",currentlySelectedCallAddress); |
323 | break ; | 439 | break ; |
324 | } | 440 | } |
441 | if (call_selected == cl_call) | ||
442 | { | ||
443 | LOG (_("info for active outgoing call:%s number: %u row: %u"), str_data,int_data,row_count); | ||
444 | break; | ||
445 | } | ||
325 | g_free (str_data); | 446 | g_free (str_data); |
326 | row_count++; | 447 | row_count++; |
327 | valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), >kiter); | 448 | valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), >kiter); |
@@ -336,41 +457,65 @@ print_call_info() | |||
336 | /* | 457 | /* |
337 | * @brief sets caller_selected, and enables or disables the active call list buttons | 458 | * @brief sets caller_selected, and enables or disables the active call list buttons |
338 | */ | 459 | */ |
339 | void | 460 | static void |
340 | update_active_call_list_buttons() | 461 | update_active_call_list_buttons() |
341 | { | 462 | { |
342 | gchar *caller_id; | 463 | gchar *caller_id; |
343 | gpointer cl_caller; | 464 | gpointer cl_caller; |
465 | gpointer cl_call; | ||
344 | gint cl_caller_state; | 466 | gint cl_caller_state; |
467 | gint cl_type; | ||
345 | //gint cl_caller_type; | 468 | //gint cl_caller_type; |
346 | GtkTreeSelection *active_selection; | 469 | GtkTreeSelection *active_selection; |
347 | GtkTreeIter gcl_selected; | 470 | GtkTreeIter gcl_selected; |
348 | // active_liststore_selection = get_object(ml,"GNUNET_CONVERSATION_GTK_active_calls_selection"); | 471 | // active_liststore_selection = get_object(ml,"GNUNET_CONVERSATION_GTK_active_calls_selection"); |
349 | 472 | ||
473 | // reset references to selected call/caller | ||
474 | //caller_selected = NULL; | ||
475 | //call_selected = NULL; | ||
476 | LOG("reset caller selected"); | ||
350 | active_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (active_treeview)); | 477 | active_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (active_treeview)); |
351 | 478 | ||
352 | 479 | ||
353 | if (gtk_tree_selection_get_selected(active_selection,NULL,&gcl_selected)) | 480 | if (gtk_tree_selection_get_selected(active_selection,NULL,&gcl_selected)) |
354 | { | 481 | { |
355 | 482 | ||
356 | gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), &gcl_selected, | 483 | // get selected call |
357 | AL_caller, &cl_caller, | 484 | gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), &gcl_selected, |
485 | AL_caller, &cl_caller, // reference to incoming call | ||
358 | AL_caller_id, &caller_id, | 486 | AL_caller_id, &caller_id, |
359 | AL_caller_state, &cl_caller_state, | 487 | AL_caller_state, &cl_caller_state, |
488 | AL_type, &cl_type, | ||
489 | AL_call, &cl_call, // reference to outgoing call | ||
360 | -1); | 490 | -1); |
361 | |||
362 | caller_selected = cl_caller; | ||
363 | 491 | ||
364 | gtk_widget_show(GTK_WIDGET(get_object("GNUNET_GTK_conversation_active_call_list_buttons" ))); | 492 | // check if selected call is a incoming or outgoing call |
493 | switch (cl_type) | ||
494 | { | ||
495 | case CALL_IN: | ||
496 | call_selected = NULL; | ||
497 | caller_selected = cl_caller; | ||
498 | if (caller_selected == NULL){ | ||
499 | GNUNET_break(0); | ||
500 | } | ||
365 | 501 | ||
502 | break; | ||
503 | case CALL_OUT: | ||
504 | caller_selected = NULL; | ||
505 | call_selected = cl_call; | ||
506 | LOG("outgoing selected"); | ||
507 | if (call_selected == NULL){ | ||
508 | GNUNET_break(0); | ||
509 | } | ||
510 | break; | ||
511 | default: | ||
512 | GNUNET_break(0); | ||
513 | break; | ||
514 | } | ||
366 | 515 | ||
367 | // make global? | 516 | |
368 | GtkWidget *b_contact, *b_accept, *b_hangup, *b_suspend, *b_resume; | 517 | |
369 | b_contact = GTK_WIDGET (get_object ("GNUNET_GTK_conversation_use_current_button")); | 518 | gtk_widget_show(GTK_WIDGET(get_object("GNUNET_GTK_conversation_active_call_list_buttons" ))); |
370 | b_accept = GTK_WIDGET (get_object ("GNUNET_GTK_conversation_accept_button")); | ||
371 | b_hangup = GTK_WIDGET (get_object ("GNUNET_GTK_conversation_hangup_button")); | ||
372 | b_suspend = GTK_WIDGET (get_object ("GNUNET_GTK_conversation_suspend_button")); | ||
373 | b_resume = GTK_WIDGET (get_object ("GNUNET_GTK_conversation_resume_button")); | ||
374 | 519 | ||
375 | LOG("caller state: %u phone_state: %u",cl_caller_state, phone_state); | 520 | LOG("caller state: %u phone_state: %u",cl_caller_state, phone_state); |
376 | 521 | ||
@@ -436,10 +581,21 @@ update_active_call_list_buttons() | |||
436 | LOG("enable resume button"); | 581 | LOG("enable resume button"); |
437 | gtk_widget_set_sensitive(b_resume, 1); | 582 | gtk_widget_set_sensitive(b_resume, 1); |
438 | }else{ | 583 | }else{ |
439 | LOG("disable resume button"); | 584 | LOG("do not disable resume button (for test)"); |
440 | gtk_widget_set_sensitive(b_resume, 0); | 585 | gtk_widget_set_sensitive(b_resume, 1); |
441 | } | 586 | } |
442 | break; | 587 | break; |
588 | case CT_other: | ||
589 | //add to phonebook | ||
590 | //LOG("CT_rejected "); | ||
591 | gtk_widget_set_sensitive(b_contact, 1); | ||
592 | gtk_widget_set_sensitive(b_accept, 1); | ||
593 | gtk_widget_set_sensitive(b_hangup, 1); | ||
594 | gtk_widget_set_sensitive(b_suspend, 1); | ||
595 | gtk_widget_set_sensitive(b_resume,1); | ||
596 | |||
597 | break; | ||
598 | |||
443 | default: | 599 | default: |
444 | GNUNET_break(0); | 600 | GNUNET_break(0); |
445 | break; | 601 | break; |
@@ -457,8 +613,6 @@ update_active_call_list_buttons() | |||
457 | 613 | ||
458 | } //end function | 614 | } //end function |
459 | 615 | ||
460 | |||
461 | |||
462 | /* | 616 | /* |
463 | * @brief executed when selecting a different item in active call list | 617 | * @brief executed when selecting a different item in active call list |
464 | */ | 618 | */ |
@@ -470,36 +624,18 @@ GNUNET_CONVERSATION_GTK_on_active_calls_selection_changed() | |||
470 | } | 624 | } |
471 | 625 | ||
472 | 626 | ||
473 | |||
474 | /** | ||
475 | * update status | ||
476 | * | ||
477 | * @param message Message to put in statusbar | ||
478 | */ | ||
479 | |||
480 | void | 627 | void |
481 | update_status (const gchar * message) | 628 | disable_list_buttons() |
482 | { | 629 | { |
483 | 630 | gtk_widget_set_sensitive(b_contact, 0); | |
484 | GtkStatusbar *status_bar; | 631 | gtk_widget_set_sensitive(b_accept, 0); |
485 | guint status_bar_context; | 632 | gtk_widget_set_sensitive(b_hangup, 0); |
486 | 633 | gtk_widget_set_sensitive(b_suspend, 0); | |
487 | gchar *buff; | 634 | gtk_widget_set_sensitive(b_resume, 0); |
488 | 635 | } | |
489 | status_bar = GTK_STATUSBAR (get_object ("GNUNET_GTK_conversation_statusbar")); | ||
490 | status_bar_context = gtk_statusbar_get_context_id (status_bar, "blaat"); | ||
491 | 636 | ||
492 | 637 | ||
493 | buff = g_strdup_printf ("%s", message); | ||
494 | 638 | ||
495 | gtk_statusbar_push (GTK_STATUSBAR (status_bar), | ||
496 | GPOINTER_TO_INT (status_bar_context), buff); | ||
497 | g_free (buff); | ||
498 | |||
499 | GNUNET_CONVERSATION_GTK_on_active_calls_selection_changed(); | ||
500 | |||
501 | |||
502 | } | ||
503 | /* | 639 | /* |
504 | * set_status_icon | 640 | * set_status_icon |
505 | * | 641 | * |
@@ -575,14 +711,162 @@ enable_button (const char *button_name) | |||
575 | } | 711 | } |
576 | 712 | ||
577 | /** | 713 | /** |
714 | * set state of outgoing call | ||
715 | */ | ||
716 | set_outgoing_call_state(struct GNUNET_CONVERSATION_Call *call, int state) | ||
717 | { | ||
718 | LOG("set state to: %u", state); | ||
719 | GtkTreeIter gtkiter; | ||
720 | gint valid = 0; | ||
721 | gint cl_type; | ||
722 | //FPRINTF (stderr,"set incoming call state:%u caller: ",state); | ||
723 | |||
724 | // LOG (_("set incoming call state:%u caller: "),state); | ||
725 | |||
726 | valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), >kiter ); | ||
727 | |||
728 | if (!valid) | ||
729 | GNUNET_break(0); | ||
730 | |||
731 | while (valid) | ||
732 | { | ||
733 | gchar *cl_caller_id; | ||
734 | gint cl_caller_num; | ||
735 | gpointer cl_call; | ||
736 | |||
737 | gtk_tree_model_get ( GTK_TREE_MODEL( active_liststore ), >kiter, | ||
738 | AL_call, &cl_call, | ||
739 | AL_caller_id,&cl_caller_id, | ||
740 | AL_caller_num,&cl_caller_num, | ||
741 | AL_type, &cl_type, | ||
742 | -1); | ||
743 | |||
744 | if (cl_type == CALL_OUT) { | ||
745 | |||
746 | if (call == NULL) // function called by phone event handler | ||
747 | { | ||
748 | LOG("event handler"); | ||
749 | gtk_list_store_set(active_liststore, >kiter, | ||
750 | AL_call_state, state, | ||
751 | -1); | ||
752 | switch (state) | ||
753 | { | ||
754 | |||
755 | /** | ||
756 | * We are the caller and are now ringing the other party (GNS lookup | ||
757 | * succeeded). | ||
758 | */ | ||
759 | case GNUNET_CONVERSATION_EC_CALL_RINGING: | ||
760 | |||
761 | break; | ||
762 | |||
763 | /** | ||
764 | * We are the caller and are now ready to talk as the callee picked up. | ||
765 | */ | ||
766 | case GNUNET_CONVERSATION_EC_CALL_PICKED_UP: | ||
767 | break; | ||
768 | /** | ||
769 | * We are the caller and failed to locate a phone record in GNS. | ||
770 | * After this invocation, the respective call handle will be | ||
771 | * automatically destroyed and the client must no longer call | ||
772 | * #GNUNET_CONVERSATION_call_stop or any other function on the | ||
773 | * call object. | ||
774 | */ | ||
775 | case GNUNET_CONVERSATION_EC_CALL_GNS_FAIL: | ||
776 | gtk_list_store_remove(active_liststore,>kiter); | ||
777 | disable_list_buttons(); | ||
778 | break; | ||
779 | |||
780 | /** | ||
781 | * We are the caller and the callee called | ||
782 | * #GNUNET_CONVERSATION_caller_hang_up. After this invocation, the | ||
783 | * respective call handle will be automatically destroyed and the | ||
784 | * client must no longer call #GNUNET_CONVERSATION_call_stop. | ||
785 | */ | ||
786 | case GNUNET_CONVERSATION_EC_CALL_HUNG_UP: | ||
787 | gtk_list_store_remove(active_liststore,>kiter); | ||
788 | disable_list_buttons(); | ||
789 | break; | ||
790 | |||
791 | /** | ||
792 | * We are the caller and the callee suspended the call. Note that | ||
793 | * both sides can independently suspend and resume calls; a call is | ||
794 | * only "working" of both sides are active. | ||
795 | */ | ||
796 | case GNUNET_CONVERSATION_EC_CALL_SUSPENDED: | ||
797 | break; | ||
798 | |||
799 | /** | ||
800 | * We are the caller and the callee suspended the call. Note that | ||
801 | * both sides can independently suspend and resume calls; a call is | ||
802 | * only "working" of both sides are active. | ||
803 | */ | ||
804 | case GNUNET_CONVERSATION_EC_CALL_RESUMED: | ||
805 | break; | ||
806 | |||
807 | /** | ||
808 | * We had an error handing the call, and are now restarting it | ||
809 | * (back to lookup). This happens, for example, if the peer | ||
810 | * is restarted during a call. | ||
811 | */ | ||
812 | case GNUNET_CONVERSATION_EC_CALL_ERROR: | ||
813 | break; | ||
814 | |||
815 | default: | ||
816 | break; | ||
817 | } | ||
818 | |||
819 | |||
820 | |||
821 | |||
822 | |||
823 | |||
824 | } | ||
825 | else if (call == cl_call) // function called for specific call | ||
826 | { | ||
827 | //LOG (_("setting state for call:%u row: %u state: %u"),cl_caller_num,row_count,state); | ||
828 | |||
829 | switch (state) | ||
830 | { | ||
831 | case CT_hangup: | ||
832 | //LOG("remove line cause hangup"); | ||
833 | gtk_list_store_remove(active_liststore,>kiter); | ||
834 | disable_list_buttons(); | ||
835 | break; | ||
836 | |||
837 | case CT_rejected: | ||
838 | //LOG("remove line cause rejected"); | ||
839 | gtk_list_store_remove(active_liststore,>kiter); | ||
840 | disable_list_buttons(); | ||
841 | break; | ||
842 | default: | ||
843 | |||
844 | gtk_list_store_set(active_liststore, >kiter, | ||
845 | AL_caller_state, state, | ||
846 | -1); | ||
847 | break; | ||
848 | |||
849 | }//end switch | ||
850 | }//end call=cl_call | ||
851 | } //end cl_type | ||
852 | g_free (cl_caller_id); | ||
853 | valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), >kiter); | ||
854 | |||
855 | }//end while | ||
856 | |||
857 | //update statsbar | ||
858 | update_status(""); | ||
859 | |||
860 | |||
861 | |||
862 | } | ||
863 | |||
864 | /** | ||
578 | * set call state of a incoming call | 865 | * set call state of a incoming call |
579 | */ | 866 | */ |
580 | static void | 867 | static void |
581 | set_incoming_call_state(struct GNUNET_CONVERSATION_Caller *caller, int state) | 868 | set_incoming_call_state(struct GNUNET_CONVERSATION_Caller *caller, int state) |
582 | { | 869 | { |
583 | // struct CallList *cl = cls; | ||
584 | // struct GNUNET_CONVERSATION_Caller caller; | ||
585 | gint row_count = 0; | ||
586 | GtkTreeIter gtkiter; | 870 | GtkTreeIter gtkiter; |
587 | gint valid = 0; | 871 | gint valid = 0; |
588 | //FPRINTF (stderr,"set incoming call state:%u caller: ",state); | 872 | //FPRINTF (stderr,"set incoming call state:%u caller: ",state); |
@@ -599,24 +883,13 @@ set_incoming_call_state(struct GNUNET_CONVERSATION_Caller *caller, int state) | |||
599 | gchar *cl_caller_id; | 883 | gchar *cl_caller_id; |
600 | gint cl_caller_num; | 884 | gint cl_caller_num; |
601 | gpointer cl_caller; | 885 | gpointer cl_caller; |
602 | // gint new_state; | ||
603 | //FPRINTF (stderr,"loop:: valid:%u \n",valid); | ||
604 | 886 | ||
605 | gtk_tree_model_get ( GTK_TREE_MODEL( active_liststore ), >kiter, | 887 | gtk_tree_model_get ( GTK_TREE_MODEL( active_liststore ), >kiter, |
606 | AL_caller, &cl_caller, | 888 | AL_caller, &cl_caller, |
607 | AL_caller_id,&cl_caller_id, | 889 | AL_caller_id,&cl_caller_id, |
608 | AL_caller_num,&cl_caller_num | 890 | AL_caller_num,&cl_caller_num |
609 | ,-1); | 891 | ,-1); |
610 | /* | 892 | |
611 | enum { | ||
612 | CT_active, | ||
613 | CT_suspended, | ||
614 | CT_ringing, | ||
615 | CT_dead, | ||
616 | CT_hangup, | ||
617 | CT_rejected | ||
618 | }; | ||
619 | */ | ||
620 | if (caller == cl_caller) | 893 | if (caller == cl_caller) |
621 | { | 894 | { |
622 | //LOG (_("setting state for call:%u row: %u state: %u"),cl_caller_num,row_count,state); | 895 | //LOG (_("setting state for call:%u row: %u state: %u"),cl_caller_num,row_count,state); |
@@ -626,11 +899,15 @@ set_incoming_call_state(struct GNUNET_CONVERSATION_Caller *caller, int state) | |||
626 | case CT_hangup: | 899 | case CT_hangup: |
627 | //LOG("remove line cause hangup"); | 900 | //LOG("remove line cause hangup"); |
628 | gtk_list_store_remove(active_liststore,>kiter); | 901 | gtk_list_store_remove(active_liststore,>kiter); |
902 | disable_list_buttons(); | ||
903 | |||
629 | break; | 904 | break; |
630 | 905 | ||
631 | case CT_rejected: | 906 | case CT_rejected: |
632 | //LOG("remove line cause rejected"); | 907 | //LOG("remove line cause rejected"); |
633 | gtk_list_store_remove(active_liststore,>kiter); | 908 | gtk_list_store_remove(active_liststore,>kiter); |
909 | disable_list_buttons(); | ||
910 | |||
634 | break; | 911 | break; |
635 | default: | 912 | default: |
636 | 913 | ||
@@ -643,7 +920,6 @@ set_incoming_call_state(struct GNUNET_CONVERSATION_Caller *caller, int state) | |||
643 | }//endif | 920 | }//endif |
644 | 921 | ||
645 | g_free (cl_caller_id); | 922 | g_free (cl_caller_id); |
646 | row_count++; | ||
647 | valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), >kiter); | 923 | valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), >kiter); |
648 | 924 | ||
649 | }//end while | 925 | }//end while |
@@ -703,7 +979,7 @@ phone_event_handler (void *cls, enum GNUNET_CONVERSATION_PhoneEventCode code, | |||
703 | AL_caller, caller, | 979 | AL_caller, caller, |
704 | AL_caller_num, caller_num_gen, | 980 | AL_caller_num, caller_num_gen, |
705 | AL_caller_state, CT_ringing, | 981 | AL_caller_state, CT_ringing, |
706 | AL_caller_type, CALL_IN | 982 | AL_type, CALL_IN |
707 | ,-1); | 983 | ,-1); |
708 | 984 | ||
709 | 985 | ||
@@ -749,6 +1025,7 @@ phone_event_handler (void *cls, enum GNUNET_CONVERSATION_PhoneEventCode code, | |||
749 | break; | 1025 | break; |
750 | 1026 | ||
751 | } | 1027 | } |
1028 | do_status(); | ||
752 | } | 1029 | } |
753 | 1030 | ||
754 | 1031 | ||
@@ -761,19 +1038,27 @@ phone_event_handler (void *cls, enum GNUNET_CONVERSATION_PhoneEventCode code, | |||
761 | static void | 1038 | static void |
762 | caller_event_handler (void *cls, enum GNUNET_CONVERSATION_CallerEventCode code) | 1039 | caller_event_handler (void *cls, enum GNUNET_CONVERSATION_CallerEventCode code) |
763 | { | 1040 | { |
764 | struct CallList *cl = cls; | ||
765 | 1041 | ||
766 | switch (code) | 1042 | if (cls == NULL){ |
767 | { | 1043 | LOG("caller_event_handler: cls == NULL"); |
768 | case GNUNET_CONVERSATION_EC_CALLER_SUSPEND: | 1044 | GNUNET_break(0); |
769 | set_incoming_call_state(cls,CT_suspended); | 1045 | } else { |
770 | LOG (_("Call from `%s' suspended by other user\n"), cl->caller_id); | 1046 | struct CallList *cl = cls; |
771 | break; | 1047 | |
772 | case GNUNET_CONVERSATION_EC_CALLER_RESUME: | 1048 | switch (code) |
773 | set_incoming_call_state(cls,CT_active); | 1049 | { |
774 | LOG (_("Call from `%s' resumed by other user\n"), cl->caller_id); | 1050 | case GNUNET_CONVERSATION_EC_CALLER_SUSPEND: |
775 | break; | 1051 | //TODO: should this be cls? not cl->caller |
1052 | set_incoming_call_state(cl->caller,CT_suspended); | ||
1053 | LOG (_("Call from `%s' suspended by other user\n"), cl->caller_id); | ||
1054 | break; | ||
1055 | case GNUNET_CONVERSATION_EC_CALLER_RESUME: | ||
1056 | set_incoming_call_state(cl->caller,CT_active); | ||
1057 | LOG (_("Call from `%s' resumed by other user\n"), cl->caller_id); | ||
1058 | break; | ||
1059 | } | ||
776 | } | 1060 | } |
1061 | do_status(); | ||
777 | } | 1062 | } |
778 | 1063 | ||
779 | 1064 | ||
@@ -784,7 +1069,7 @@ static void | |||
784 | start_phone () | 1069 | start_phone () |
785 | { | 1070 | { |
786 | struct GNUNET_GNSRECORD_Data rd; | 1071 | struct GNUNET_GNSRECORD_Data rd; |
787 | 1072 | GtkLabel *label; | |
788 | if (NULL == caller_id) | 1073 | if (NULL == caller_id) |
789 | { | 1074 | { |
790 | LOG (_("Ego `%s' no longer available, phone is now down.\n"), ego_name); | 1075 | LOG (_("Ego `%s' no longer available, phone is now down.\n"), ego_name); |
@@ -811,10 +1096,14 @@ start_phone () | |||
811 | 1096 | ||
812 | LOG (_("address: `%s' \n"), address); | 1097 | LOG (_("address: `%s' \n"), address); |
813 | 1098 | ||
1099 | label = GTK_LABEL(get_object("GNUNET_CONVERSATION_GTK_my_address")); | ||
1100 | gtk_label_set_text(label, address); | ||
1101 | |||
814 | if (verbose) | 1102 | if (verbose) |
815 | LOG (_("Phone active on line %u\n"), (unsigned int) line); | 1103 | LOG (_("Phone active on line %u\n"), (unsigned int) line); |
816 | phone_state = PS_LISTEN; | 1104 | phone_state = PS_LISTEN; |
817 | } | 1105 | } |
1106 | do_status(); | ||
818 | } | 1107 | } |
819 | 1108 | ||
820 | 1109 | ||
@@ -827,38 +1116,50 @@ start_phone () | |||
827 | static void | 1116 | static void |
828 | call_event_handler (void *cls, enum GNUNET_CONVERSATION_CallEventCode code) | 1117 | call_event_handler (void *cls, enum GNUNET_CONVERSATION_CallEventCode code) |
829 | { | 1118 | { |
830 | switch (code) | 1119 | //struct OutgoingCallClosure *cl = cls; |
831 | { | 1120 | |
832 | case GNUNET_CONVERSATION_EC_CALL_RINGING: | 1121 | //LOG("call event handler code: %u num: %u", code, cl->call_num); |
833 | GNUNET_break (CS_RESOLVING == call_state); | 1122 | |
834 | LOG (_("Resolved address of `%s'. Now ringing other party."), peer_name); | 1123 | //if (cls == NULL){ |
835 | call_state = CS_RINGING; | 1124 | set_outgoing_call_state(NULL, code); |
836 | break; | 1125 | //GNUNET_break(0); |
837 | case GNUNET_CONVERSATION_EC_CALL_PICKED_UP: | 1126 | //} else |
838 | GNUNET_break (CS_RINGING == call_state); | 1127 | //{ |
839 | LOG (_("Connection established to `%s'"), peer_name); | 1128 | switch (code) |
840 | call_state = CS_CONNECTED; | 1129 | { |
841 | break; | 1130 | case GNUNET_CONVERSATION_EC_CALL_RINGING: |
842 | case GNUNET_CONVERSATION_EC_CALL_GNS_FAIL: | 1131 | GNUNET_break (CS_RESOLVING == call_state); |
843 | GNUNET_break (CS_RESOLVING == call_state); | 1132 | LOG (_("Resolved address of `%s'. Now ringing other party."), peer_name); |
844 | LOG (_("Failed to resolve %s in ego `%s'"), peer_name, ego_name); | 1133 | // set_outgoing_call_state(cls, CT_ringing); |
845 | call = NULL; | 1134 | |
846 | break; | 1135 | call_state = CS_RINGING; |
847 | case GNUNET_CONVERSATION_EC_CALL_HUNG_UP: | 1136 | break; |
848 | LOG ("%s", _("Call terminated")); | 1137 | case GNUNET_CONVERSATION_EC_CALL_PICKED_UP: |
849 | call = NULL; | 1138 | GNUNET_break (CS_RINGING == call_state); |
850 | break; | 1139 | LOG (_("Connection established to `%s'"), peer_name); |
851 | case GNUNET_CONVERSATION_EC_CALL_SUSPENDED: | 1140 | call_state = CS_CONNECTED; |
852 | GNUNET_break (CS_CONNECTED == call_state); | 1141 | break; |
853 | LOG (_("Connection to `%s' suspended (by other user)\n"), peer_name); | 1142 | case GNUNET_CONVERSATION_EC_CALL_GNS_FAIL: |
854 | break; | 1143 | GNUNET_break (CS_RESOLVING == call_state); |
855 | case GNUNET_CONVERSATION_EC_CALL_RESUMED: | 1144 | LOG (_("Failed to resolve %s in ego `%s'"), peer_name, ego_name); |
856 | GNUNET_break (CS_CONNECTED == call_state); | 1145 | call = NULL; |
857 | LOG (_("Connection to `%s' resumed (by other user)\n"), peer_name); | 1146 | break; |
858 | break; | 1147 | case GNUNET_CONVERSATION_EC_CALL_HUNG_UP: |
859 | case GNUNET_CONVERSATION_EC_CALL_ERROR: | 1148 | LOG ("%s", _("Call terminated")); |
860 | LOG ("GNUNET_CONVERSATION_EC_CALL_ERROR %s", peer_name); | 1149 | call = NULL; |
861 | } | 1150 | break; |
1151 | case GNUNET_CONVERSATION_EC_CALL_SUSPENDED: | ||
1152 | GNUNET_break (CS_CONNECTED == call_state); | ||
1153 | LOG (_("Connection to `%s' suspended (by other user)\n"), peer_name); | ||
1154 | break; | ||
1155 | case GNUNET_CONVERSATION_EC_CALL_RESUMED: | ||
1156 | GNUNET_break (CS_CONNECTED == call_state); | ||
1157 | LOG (_("Connection to `%s' resumed (by other user)\n"), peer_name); | ||
1158 | break; | ||
1159 | case GNUNET_CONVERSATION_EC_CALL_ERROR: | ||
1160 | LOG ("GNUNET_CONVERSATION_EC_CALL_ERROR %s", peer_name); | ||
1161 | } | ||
1162 | //} | ||
862 | } | 1163 | } |
863 | 1164 | ||
864 | 1165 | ||
@@ -893,6 +1194,7 @@ do_call (const char *arg) | |||
893 | LOG (_ | 1194 | LOG (_ |
894 | ("You are answering call from `%s', hang up or suspend that call first!\n"), | 1195 | ("You are answering call from `%s', hang up or suspend that call first!\n"), |
895 | peer_name); | 1196 | peer_name); |
1197 | GNUNET_break(0); | ||
896 | return; | 1198 | return; |
897 | case PS_ERROR: | 1199 | case PS_ERROR: |
898 | /* ok to call */ | 1200 | /* ok to call */ |
@@ -903,9 +1205,31 @@ do_call (const char *arg) | |||
903 | LOG (_("now calling: %s"), peer_name); | 1205 | LOG (_("now calling: %s"), peer_name); |
904 | call_state = CS_RESOLVING; | 1206 | call_state = CS_RESOLVING; |
905 | GNUNET_assert (NULL == call); | 1207 | GNUNET_assert (NULL == call); |
1208 | |||
1209 | call_counter++; | ||
906 | call = | 1210 | call = |
907 | GNUNET_CONVERSATION_call_start (cfg, caller_id, arg, speaker, mic, | 1211 | GNUNET_CONVERSATION_call_start (cfg, caller_id, arg, speaker, mic, |
908 | &call_event_handler, NULL); | 1212 | &call_event_handler, NULL); |
1213 | //call = newcall; | ||
1214 | |||
1215 | // add call to active call list | ||
1216 | GtkTreeIter gtkiter; | ||
1217 | |||
1218 | gtk_list_store_append (active_liststore, >kiter); | ||
1219 | |||
1220 | gtk_list_store_set (active_liststore, >kiter, | ||
1221 | AL_caller_id, peer_name, | ||
1222 | AL_caller, NULL, | ||
1223 | AL_caller_num, NULL, | ||
1224 | AL_caller_state, CT_other, | ||
1225 | AL_type, CALL_OUT, | ||
1226 | AL_call, call, | ||
1227 | AL_call_num, call_counter, | ||
1228 | AL_call_state, CS_RESOLVING, | ||
1229 | -1 | ||
1230 | ); | ||
1231 | |||
1232 | |||
909 | UPDATE_STATUS (_("We are calling `%s', his phone should be ringing."), | 1233 | UPDATE_STATUS (_("We are calling `%s', his phone should be ringing."), |
910 | peer_name); | 1234 | peer_name); |
911 | GNUNET_CONVERSATION_GTK_history_add (CH_OUTGOING, peer_name); | 1235 | GNUNET_CONVERSATION_GTK_history_add (CH_OUTGOING, peer_name); |
@@ -927,6 +1251,7 @@ do_accept (struct GNUNET_CONVERSATION_Caller *sel_caller) | |||
927 | if ((NULL != call) && (CS_SUSPENDED != call_state)) | 1251 | if ((NULL != call) && (CS_SUSPENDED != call_state)) |
928 | { | 1252 | { |
929 | LOG (_("You are calling someone else already, hang up first!\n")); | 1253 | LOG (_("You are calling someone else already, hang up first!\n")); |
1254 | GNUNET_break(0); | ||
930 | return; | 1255 | return; |
931 | } | 1256 | } |
932 | switch (phone_state) | 1257 | switch (phone_state) |
@@ -941,45 +1266,18 @@ do_accept (struct GNUNET_CONVERSATION_Caller *sel_caller) | |||
941 | LOG (_ | 1266 | LOG (_ |
942 | ("You are answering call from `%s', hang up or suspend that call first!\n"), | 1267 | ("You are answering call from `%s', hang up or suspend that call first!\n"), |
943 | peer_name); | 1268 | peer_name); |
1269 | GNUNET_break(0); | ||
944 | return; | 1270 | return; |
945 | case PS_ERROR: | 1271 | case PS_ERROR: |
946 | GNUNET_break (0); | 1272 | GNUNET_break (0); |
947 | break; | 1273 | break; |
948 | }//endswitch | 1274 | }//endswitch |
949 | 1275 | ||
950 | /* | ||
951 | cl = cl_head; | ||
952 | if (NULL == cl) | ||
953 | { | ||
954 | LOG (_("There is no incoming call to accept here!\n")); | ||
955 | return; | ||
956 | } | ||
957 | if (NULL != cl->next) | ||
958 | { | ||
959 | for (cl = cl_head; NULL != cl; cl = cl->next) | ||
960 | { | ||
961 | GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num); | ||
962 | } | ||
963 | } | ||
964 | if (NULL == cl) | ||
965 | { | ||
966 | LOG (_("There is no incoming call to accept right now!(NULL == cl) \n")); | ||
967 | return; | ||
968 | } | ||
969 | |||
970 | GNUNET_CONTAINER_DLL_remove (cl_head, | ||
971 | cl_tail, | ||
972 | cl); | ||
973 | cl_active = cl; | ||
974 | GNUNET_free_non_null (peer_name); | ||
975 | peer_name = GNUNET_strdup (cl->caller_id); | ||
976 | */ | ||
977 | |||
978 | phone_state = PS_ACCEPTED; | 1276 | phone_state = PS_ACCEPTED; |
979 | set_incoming_call_state(sel_caller,CT_active); | 1277 | set_incoming_call_state(sel_caller,CT_active); |
980 | 1278 | ||
981 | 1279 | ||
982 | cl = NULL; | 1280 | cl = sel_caller; |
983 | GNUNET_CONVERSATION_caller_pick_up (sel_caller, &caller_event_handler, cl, | 1281 | GNUNET_CONVERSATION_caller_pick_up (sel_caller, &caller_event_handler, cl, |
984 | speaker, mic); | 1282 | speaker, mic); |
985 | 1283 | ||
@@ -993,86 +1291,6 @@ do_accept (struct GNUNET_CONVERSATION_Caller *sel_caller) | |||
993 | 1291 | ||
994 | 1292 | ||
995 | 1293 | ||
996 | /** | ||
997 | * update statusbar | ||
998 | * | ||
999 | * @param args arguments given to the command | ||
1000 | */ | ||
1001 | static void | ||
1002 | do_status () | ||
1003 | { | ||
1004 | struct CallList *cl; | ||
1005 | |||
1006 | switch (phone_state) | ||
1007 | { | ||
1008 | case PS_LOOKUP_EGO: | ||
1009 | UPDATE_STATUS (_ | ||
1010 | ("We are currently trying to locate the private key for the ego `%s'."), | ||
1011 | ego_name); | ||
1012 | set_status_icon ("gnunet-conversation-gtk-tray-pending"); | ||
1013 | break; | ||
1014 | case PS_LISTEN: | ||
1015 | UPDATE_STATUS (_ | ||
1016 | ("We are listening for incoming calls for ego `%s' on line %u."), | ||
1017 | ego_name, line); | ||
1018 | set_status_icon ("gnunet-conversation-gtk-tray-available"); | ||
1019 | |||
1020 | break; | ||
1021 | case PS_ACCEPTED: | ||
1022 | UPDATE_STATUS (_("You are having a conversation with `%s'.\n"), peer_name); | ||
1023 | set_status_icon ("gnunet-conversation-call-active"); | ||
1024 | |||
1025 | break; | ||
1026 | case PS_ERROR: | ||
1027 | UPDATE_STATUS (_ | ||
1028 | ("We had an internal error setting up our phone line. You can still make calls.")); | ||
1029 | set_status_icon ("gnunet-conversation-offline"); | ||
1030 | |||
1031 | break; | ||
1032 | } | ||
1033 | if (NULL != call) | ||
1034 | { | ||
1035 | switch (call_state) | ||
1036 | { | ||
1037 | case CS_RESOLVING: | ||
1038 | UPDATE_STATUS (_ | ||
1039 | ("We are trying to find the network address to call `%s'."), | ||
1040 | peer_name); | ||
1041 | set_status_icon ("gnunet-conversation-gtk-tray-call-pending"); | ||
1042 | |||
1043 | break; | ||
1044 | case CS_RINGING: | ||
1045 | UPDATE_STATUS (_("We are calling `%s', his phone should be ringing."), | ||
1046 | peer_name); | ||
1047 | set_status_icon ("gnunet-conversation-gtk-tray-call-ringing"); | ||
1048 | |||
1049 | break; | ||
1050 | case CS_CONNECTED: | ||
1051 | UPDATE_STATUS (_("You are having a conversation with `%s'."), peer_name); | ||
1052 | set_status_icon ("gnunet-conversation-gtk-tray-call-active"); | ||
1053 | |||
1054 | break; | ||
1055 | case CS_SUSPENDED: | ||
1056 | set_status_icon ("gnunet-conversation-gtk-tray-call-suspended"); | ||
1057 | |||
1058 | /* ok to accept incoming call right now */ | ||
1059 | break; | ||
1060 | } | ||
1061 | } | ||
1062 | if ((NULL != cl_head) && ((cl_head != cl_active) || (cl_head != cl_tail))) | ||
1063 | { | ||
1064 | set_status_icon ("gnunet-conversation-gtk-tray-call-incoming"); | ||
1065 | |||
1066 | for (cl = cl_head; NULL != cl; cl = cl->next) | ||
1067 | { | ||
1068 | if (cl == cl_active) | ||
1069 | continue; | ||
1070 | //UPDATE_STATUS (_("#%u: `%s'"), cl->caller_num, cl->caller_id); | ||
1071 | // LOG ("%s", _("Calls waiting:")); | ||
1072 | } | ||
1073 | } | ||
1074 | } | ||
1075 | |||
1076 | 1294 | ||
1077 | /** | 1295 | /** |
1078 | * Suspending a call | 1296 | * Suspending a call |
@@ -1081,44 +1299,49 @@ do_status () | |||
1081 | */ | 1299 | */ |
1082 | 1300 | ||
1083 | static void | 1301 | static void |
1084 | do_suspend (struct GNUNET_CONVERSATION_Caller *sel_caller) | 1302 | do_suspend () |
1085 | { | 1303 | { |
1086 | 1304 | ||
1087 | /* | 1305 | /* |
1088 | if (NULL != call) | ||
1089 | { | ||
1090 | switch (call_state) | ||
1091 | { | ||
1092 | case CS_RESOLVING: | ||
1093 | case CS_RINGING: | ||
1094 | case CS_SUSPENDED: | ||
1095 | LOG ("%s", _("There is no call that could be suspended right now.")); | ||
1096 | return; | ||
1097 | case CS_CONNECTED: | ||
1098 | call_state = CS_SUSPENDED; | ||
1099 | GNUNET_CONVERSATION_call_suspend (call); | ||
1100 | return; | ||
1101 | } | ||
1102 | } | ||
1103 | */ | ||
1104 | switch (phone_state) | 1306 | switch (phone_state) |
1105 | { | 1307 | { |
1106 | case PS_LOOKUP_EGO: | 1308 | case PS_LOOKUP_EGO: |
1107 | case PS_LISTEN: | 1309 | case PS_LISTEN: |
1108 | case PS_ERROR: | 1310 | case PS_ERROR: |
1109 | LOG ("%s", _(" There is no call that could be suspended right now.")); | 1311 | LOG ("%s", _(" There is no call that could be suspended right now. (PS_ERROR)")); |
1110 | return; | 1312 | return; |
1111 | case PS_ACCEPTED: | 1313 | case PS_ACCEPTED: |
1112 | /* expected state, do rejection logic */ | 1314 | // expected state, do rejection logic |
1113 | break; | 1315 | break; |
1114 | } | 1316 | } |
1317 | */ | ||
1318 | if (call_selected != NULL && caller_selected != NULL) | ||
1319 | { | ||
1320 | LOG("this shoud not be possible"); | ||
1321 | GNUNET_break(0); | ||
1322 | } | ||
1323 | else | ||
1324 | { | ||
1115 | 1325 | ||
1116 | // GNUNET_assert (NULL != cl_active); | 1326 | // outgoing |
1117 | 1327 | if (NULL != call_selected) | |
1118 | GNUNET_CONVERSATION_caller_suspend (sel_caller); | 1328 | { |
1119 | phone_state = PS_LISTEN; | 1329 | GNUNET_CONVERSATION_call_suspend (call_selected); |
1120 | set_incoming_call_state(sel_caller,CT_suspended); | 1330 | set_outgoing_call_state(call_selected,CT_suspended); |
1331 | |||
1332 | return; | ||
1333 | } | ||
1121 | 1334 | ||
1335 | // incoming | ||
1336 | if (NULL != caller_selected) | ||
1337 | { | ||
1338 | GNUNET_CONVERSATION_caller_suspend (caller_selected); | ||
1339 | set_incoming_call_state(caller_selected,CT_suspended); | ||
1340 | phone_state = PS_LISTEN; | ||
1341 | return; | ||
1342 | |||
1343 | } | ||
1344 | } | ||
1122 | } | 1345 | } |
1123 | 1346 | ||
1124 | 1347 | ||
@@ -1128,32 +1351,14 @@ do_suspend (struct GNUNET_CONVERSATION_Caller *sel_caller) | |||
1128 | * @param args arguments given to the command | 1351 | * @param args arguments given to the command |
1129 | */ | 1352 | */ |
1130 | static void | 1353 | static void |
1131 | do_resume (struct GNUNET_CONVERSATION_Caller *sel_caller) | 1354 | do_resume () |
1132 | { | 1355 | { |
1133 | //struct CallList *cl; | 1356 | |
1134 | //char buf[32]; | 1357 | switch (phone_state) |
1135 | /* | ||
1136 | if (NULL != call) | ||
1137 | { | ||
1138 | switch (call_state) | ||
1139 | { | ||
1140 | case CS_RESOLVING: | ||
1141 | case CS_RINGING: | ||
1142 | case CS_CONNECTED: | ||
1143 | LOG ("%s", _("There is no call that could be resumed right now.")); | ||
1144 | return; | ||
1145 | case CS_SUSPENDED: | ||
1146 | call_state = CS_CONNECTED; | ||
1147 | GNUNET_CONVERSATION_call_resume (call, speaker, mic); | ||
1148 | return; | ||
1149 | } | ||
1150 | } | ||
1151 | */ | ||
1152 | switch (phone_state) | ||
1153 | { | 1358 | { |
1154 | case PS_LOOKUP_EGO: | 1359 | case PS_LOOKUP_EGO: |
1155 | case PS_ERROR: | 1360 | case PS_ERROR: |
1156 | LOG ("%s", _("There is no call that could be resumed right now.")); | 1361 | LOG ("%s", _("There is no call that could be resumed right now.(PS_ERROR)")); |
1157 | return; | 1362 | return; |
1158 | case PS_LISTEN: | 1363 | case PS_LISTEN: |
1159 | break; | 1364 | break; |
@@ -1162,32 +1367,39 @@ do_resume (struct GNUNET_CONVERSATION_Caller *sel_caller) | |||
1162 | peer_name); | 1367 | peer_name); |
1163 | return; | 1368 | return; |
1164 | } | 1369 | } |
1165 | /* | 1370 | //// |
1166 | GNUNET_assert (NULL == cl_active); | 1371 | if (call_selected != NULL && caller_selected != NULL) |
1167 | cl = cl_head; | ||
1168 | if (NULL == cl) | ||
1169 | { | ||
1170 | LOG (_("There is no incoming call to resume here!")); | ||
1171 | return; | ||
1172 | } | ||
1173 | if (NULL != cl->next) | ||
1174 | { | 1372 | { |
1175 | for (cl = cl_head; NULL != cl; cl = cl->next) | 1373 | LOG("this shoud not be possible"); |
1176 | { | 1374 | GNUNET_break(0); |
1177 | GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num); | 1375 | return; |
1178 | } | ||
1179 | } | 1376 | } |
1180 | if (NULL == cl) | 1377 | else |
1181 | { | 1378 | { |
1182 | LOG (_("There is no incoming call to resume right now! (null == cl)")); | 1379 | |
1183 | return; | 1380 | // outgoing |
1381 | if (NULL != call_selected) | ||
1382 | { | ||
1383 | GNUNET_CONVERSATION_call_resume (call_selected, speaker, mic); | ||
1384 | set_outgoing_call_state(call_selected,CT_active); | ||
1385 | |||
1386 | return; | ||
1387 | } | ||
1388 | |||
1389 | // incoming | ||
1390 | if (NULL != caller_selected) | ||
1391 | { | ||
1392 | GNUNET_CONVERSATION_caller_resume (caller_selected, speaker, mic); | ||
1393 | set_incoming_call_state(caller_selected,CT_active); | ||
1394 | phone_state = PS_ACCEPTED; | ||
1395 | return; | ||
1396 | |||
1397 | } | ||
1398 | GNUNET_break(0); | ||
1184 | } | 1399 | } |
1185 | cl_active = cl; | 1400 | |
1186 | */ | 1401 | // |
1187 | 1402 | //// | |
1188 | GNUNET_CONVERSATION_caller_resume (sel_caller, speaker, mic); | ||
1189 | set_incoming_call_state(sel_caller,CT_active); | ||
1190 | phone_state = PS_ACCEPTED; | ||
1191 | } | 1403 | } |
1192 | 1404 | ||
1193 | 1405 | ||
@@ -1197,79 +1409,39 @@ do_resume (struct GNUNET_CONVERSATION_Caller *sel_caller) | |||
1197 | * @param args arguments given to the command | 1409 | * @param args arguments given to the command |
1198 | */ | 1410 | */ |
1199 | static void | 1411 | static void |
1200 | do_reject (struct GNUNET_CONVERSATION_Caller *sel_caller) | 1412 | do_reject () |
1201 | { | 1413 | { |
1202 | //struct CallList *cl; | 1414 | |
1203 | //char buf[32]; | 1415 | if (call_selected == NULL && caller_selected == NULL){ |
1416 | GNUNET_break(0); | ||
1417 | }else { | ||
1204 | 1418 | ||
1205 | /* | 1419 | // if selected call is outgoing, stop it |
1206 | if (NULL != call) | 1420 | if (NULL != call_selected) |
1207 | { | 1421 | { |
1208 | GNUNET_CONVERSATION_call_stop (call); | 1422 | set_outgoing_call_state(call_selected,CT_hangup); |
1423 | |||
1424 | GNUNET_CONVERSATION_call_stop(call); | ||
1425 | //GNUNET_CONVERSATION_call_stop (call_selected); | ||
1426 | |||
1209 | call = NULL; | 1427 | call = NULL; |
1428 | call_selected = NULL; | ||
1210 | return; | 1429 | return; |
1211 | } | 1430 | } else |
1212 | */ | 1431 | |
1213 | switch (phone_state) | 1432 | // if selected call is incoming, hang it up |
1433 | if (NULL != caller_selected) | ||
1214 | { | 1434 | { |
1215 | case PS_LOOKUP_EGO: | 1435 | set_incoming_call_state(caller_selected,CT_hangup); |
1216 | case PS_ERROR: | 1436 | //FPRINTF(stderr,"hangup: %u", caller_selected); |
1217 | LOG ("%s", _("There is no call that could be cancelled right now.\n")); | 1437 | GNUNET_CONVERSATION_caller_hang_up(caller_selected); |
1218 | return; | ||
1219 | case PS_LISTEN: | ||
1220 | /* look for active incoming calls to refuse */ | ||
1221 | /* | ||
1222 | cl = cl_head; | ||
1223 | if (NULL == cl) | ||
1224 | { | ||
1225 | LOG (_("There is no incoming call to refuse here!\n")); | ||
1226 | return; | ||
1227 | } | ||
1228 | if ((NULL != cl->next) || (NULL != args)) | ||
1229 | { | ||
1230 | for (cl = cl_head; NULL != cl; cl = cl->next) | ||
1231 | { | ||
1232 | GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num); | ||
1233 | if (0 == strcmp (buf, args)) | ||
1234 | break; | ||
1235 | } | ||
1236 | } | ||
1237 | if (NULL == cl) | ||
1238 | { | ||
1239 | LOG (_("There is no incoming call `%s' to refuse right now!\n"), args); | ||
1240 | return; | ||
1241 | } | ||
1242 | */ | ||
1243 | //GNUNET_CONVERSATION_caller_hang_up (cl->caller); | ||
1244 | set_incoming_call_state(sel_caller,CT_rejected); | ||
1245 | GNUNET_CONVERSATION_caller_hang_up(sel_caller); | ||
1246 | |||
1247 | /* | ||
1248 | GNUNET_CONTAINER_DLL_remove (cl_head, cl_tail, cl); | ||
1249 | peer_name = GNUNET_strdup (cl->caller_id); | ||
1250 | GNUNET_free (cl->caller_id); | ||
1251 | GNUNET_free (cl); | ||
1252 | */ | ||
1253 | // caller_num_gen--; | ||
1254 | break; | ||
1255 | case PS_ACCEPTED: | ||
1256 | /* expected state, do rejection logic */ | ||
1257 | GNUNET_CONVERSATION_GTK_history_add (CH_REJECTED, peer_name); | ||
1258 | /* | ||
1259 | GNUNET_assert (NULL != cl_active); | ||
1260 | GNUNET_CONVERSATION_caller_hang_up (cl_active->caller); | ||
1261 | GNUNET_free (cl_active->caller_id); | ||
1262 | GNUNET_free (cl_active); | ||
1263 | GNUNET_assert (caller_num_gen > 0); | ||
1264 | // caller_num_gen--; | ||
1265 | */ | ||
1266 | set_incoming_call_state(sel_caller,CT_hangup); | ||
1267 | GNUNET_CONVERSATION_caller_hang_up(sel_caller); | ||
1268 | //cl_active = NULL; | 1438 | //cl_active = NULL; |
1269 | phone_state = PS_LISTEN; | 1439 | phone_state = PS_LISTEN; |
1270 | break; | 1440 | caller_selected = NULL; |
1441 | } else { | ||
1442 | GNUNET_break(0); | ||
1271 | } | 1443 | } |
1272 | 1444 | } | |
1273 | } | 1445 | } |
1274 | 1446 | ||
1275 | 1447 | ||
@@ -1289,9 +1461,26 @@ static void | |||
1289 | identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, | 1461 | identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, |
1290 | const char *name) | 1462 | const char *name) |
1291 | { | 1463 | { |
1292 | // struct GNUNET_CRYPTO_EcdsaPublicKey pk; | 1464 | |
1293 | // char *s; | 1465 | struct GNUNET_CRYPTO_EcdsaPublicKey pk; |
1294 | // GtkTreeIter iter; | 1466 | char *s; |
1467 | GtkTreeIter iter; | ||
1468 | |||
1469 | if (NULL != ego) | ||
1470 | { | ||
1471 | GNUNET_IDENTITY_ego_get_public_key (ego, &pk); | ||
1472 | s = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk); | ||
1473 | fprintf (stderr, "main identity_cb: %s \n", name); | ||
1474 | |||
1475 | |||
1476 | gtk_list_store_insert_with_values (zone_liststore, | ||
1477 | &iter, -1, | ||
1478 | 0, name, | ||
1479 | 1, ego, | ||
1480 | -1); | ||
1481 | |||
1482 | } | ||
1483 | |||
1295 | 1484 | ||
1296 | if (NULL == name) | 1485 | if (NULL == name) |
1297 | return; | 1486 | return; |
@@ -1312,11 +1501,11 @@ identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, | |||
1312 | caller_id = NULL; | 1501 | caller_id = NULL; |
1313 | return; | 1502 | return; |
1314 | } | 1503 | } |
1504 | |||
1315 | caller_id = ego; | 1505 | caller_id = ego; |
1506 | |||
1507 | // do not remove this, it tells the phone which line to use | ||
1316 | GNUNET_CONFIGURATION_set_value_number (cfg, "CONVERSATION", "LINE", line); | 1508 | GNUNET_CONFIGURATION_set_value_number (cfg, "CONVERSATION", "LINE", line); |
1317 | //zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (caller_id); | ||
1318 | // ns = GNUNET_NAMESTORE_connect (cfg); | ||
1319 | |||
1320 | 1509 | ||
1321 | if (NULL == phone) | 1510 | if (NULL == phone) |
1322 | start_phone(); | 1511 | start_phone(); |
@@ -1405,6 +1594,7 @@ GNUNET_GTK_conversation_quit_cb (GObject * object, gpointer user_data) | |||
1405 | // ns = NULL; | 1594 | // ns = NULL; |
1406 | //} | 1595 | //} |
1407 | GNUNET_CONVERSATION_GTK_CONTACTS_shutdown(); | 1596 | GNUNET_CONVERSATION_GTK_CONTACTS_shutdown(); |
1597 | |||
1408 | GNUNET_SPEAKER_destroy (speaker); | 1598 | GNUNET_SPEAKER_destroy (speaker); |
1409 | speaker = NULL; | 1599 | speaker = NULL; |
1410 | GNUNET_MICROPHONE_destroy (mic); | 1600 | GNUNET_MICROPHONE_destroy (mic); |
@@ -1487,6 +1677,15 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1487 | speaker = GNUNET_SPEAKER_create_from_hardware (GIG_get_configuration ()); | 1677 | speaker = GNUNET_SPEAKER_create_from_hardware (GIG_get_configuration ()); |
1488 | mic = GNUNET_MICROPHONE_create_from_hardware (GIG_get_configuration ()); | 1678 | mic = GNUNET_MICROPHONE_create_from_hardware (GIG_get_configuration ()); |
1489 | 1679 | ||
1680 | b_contact = GTK_WIDGET (get_object ("GNUNET_GTK_conversation_use_current_button")); | ||
1681 | b_accept = GTK_WIDGET (get_object ("GNUNET_GTK_conversation_accept_button")); | ||
1682 | b_hangup = GTK_WIDGET (get_object ("GNUNET_GTK_conversation_hangup_button")); | ||
1683 | b_suspend = GTK_WIDGET (get_object ("GNUNET_GTK_conversation_suspend_button")); | ||
1684 | b_resume = GTK_WIDGET (get_object ("GNUNET_GTK_conversation_resume_button")); | ||
1685 | |||
1686 | |||
1687 | |||
1688 | |||
1490 | if (NULL == ego_name) | 1689 | if (NULL == ego_name) |
1491 | { | 1690 | { |
1492 | ego_name = "phone-ego"; | 1691 | ego_name = "phone-ego"; |
@@ -1560,7 +1759,9 @@ GNUNET_CONVERSATION_GTK_on_call_clicked () | |||
1560 | void | 1759 | void |
1561 | GNUNET_CONVERSATION_GTK_on_hangup_clicked () | 1760 | GNUNET_CONVERSATION_GTK_on_hangup_clicked () |
1562 | { | 1761 | { |
1563 | do_reject (caller_selected); | 1762 | |
1763 | do_reject (); | ||
1764 | |||
1564 | do_status (); | 1765 | do_status (); |
1565 | //history_add(3,peer_name); | 1766 | //history_add(3,peer_name); |
1566 | } | 1767 | } |
@@ -1571,7 +1772,13 @@ GNUNET_CONVERSATION_GTK_on_hangup_clicked () | |||
1571 | void | 1772 | void |
1572 | GNUNET_CONVERSATION_GTK_on_accept_clicked () | 1773 | GNUNET_CONVERSATION_GTK_on_accept_clicked () |
1573 | { | 1774 | { |
1775 | if (caller_selected != NULL) | ||
1776 | { | ||
1574 | do_accept (caller_selected); | 1777 | do_accept (caller_selected); |
1778 | } else { | ||
1779 | GNUNET_break(0); | ||
1780 | } | ||
1781 | do_status(); | ||
1575 | } | 1782 | } |
1576 | 1783 | ||
1577 | 1784 | ||
@@ -1581,7 +1788,8 @@ GNUNET_CONVERSATION_GTK_on_accept_clicked () | |||
1581 | void | 1788 | void |
1582 | GNUNET_CONVERSATION_GTK_on_reject_clicked () | 1789 | GNUNET_CONVERSATION_GTK_on_reject_clicked () |
1583 | { | 1790 | { |
1584 | do_reject (caller_selected); | 1791 | do_reject (); |
1792 | do_status(); | ||
1585 | } | 1793 | } |
1586 | 1794 | ||
1587 | /** | 1795 | /** |
@@ -1590,7 +1798,8 @@ GNUNET_CONVERSATION_GTK_on_reject_clicked () | |||
1590 | void | 1798 | void |
1591 | GNUNET_CONVERSATION_GTK_on_pause_clicked () | 1799 | GNUNET_CONVERSATION_GTK_on_pause_clicked () |
1592 | { | 1800 | { |
1593 | do_suspend (caller_selected); | 1801 | do_suspend (); |
1802 | do_status(); | ||
1594 | } | 1803 | } |
1595 | 1804 | ||
1596 | /** | 1805 | /** |
@@ -1599,7 +1808,8 @@ GNUNET_CONVERSATION_GTK_on_pause_clicked () | |||
1599 | void | 1808 | void |
1600 | GNUNET_CONVERSATION_GTK_on_resume_clicked () | 1809 | GNUNET_CONVERSATION_GTK_on_resume_clicked () |
1601 | { | 1810 | { |
1602 | do_resume (caller_selected); | 1811 | do_resume (); |
1812 | do_status(); | ||
1603 | } | 1813 | } |
1604 | 1814 | ||
1605 | /** | 1815 | /** |