aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-05-26 19:38:06 +0000
committerChristian Grothoff <christian@grothoff.org>2014-05-26 19:38:06 +0000
commit9fbe9f83123950dd368833c6204c9e90a24e1502 (patch)
treed90e08eef06010159fbfc439456768d76cf86469
parent7ec81c574e3b6420523dd6797232bea1cfb64c65 (diff)
downloadgnunet-gtk-9fbe9f83123950dd368833c6204c9e90a24e1502.tar.gz
gnunet-gtk-9fbe9f83123950dd368833c6204c9e90a24e1502.zip
-phone indentation cleanup
-rw-r--r--src/conversation/gnunet-conversation-gtk_phone.c514
1 files changed, 208 insertions, 306 deletions
diff --git a/src/conversation/gnunet-conversation-gtk_phone.c b/src/conversation/gnunet-conversation-gtk_phone.c
index 5ac64302..c9eba075 100644
--- a/src/conversation/gnunet-conversation-gtk_phone.c
+++ b/src/conversation/gnunet-conversation-gtk_phone.c
@@ -383,7 +383,7 @@ print_call_info ()
383 * @brief sets caller_selected, and enables or disables the active call list buttons 383 * @brief sets caller_selected, and enables or disables the active call list buttons
384 */ 384 */
385static void 385static void
386update_active_call_list_buttons() 386update_active_call_list_buttons ()
387{ 387{
388 gchar *caller_id; 388 gchar *caller_id;
389 gpointer cl_caller; 389 gpointer cl_caller;
@@ -534,7 +534,7 @@ gnunet_conversation_gtk_active_calls_treeview_selection_changed_cb ()
534 534
535 535
536static void 536static void
537disable_list_buttons() 537disable_list_buttons ()
538{ 538{
539 gtk_widget_set_sensitive (b_add_contact, FALSE); 539 gtk_widget_set_sensitive (b_add_contact, FALSE);
540 gtk_widget_set_sensitive (b_accept, FALSE); 540 gtk_widget_set_sensitive (b_accept, FALSE);
@@ -547,7 +547,7 @@ disable_list_buttons()
547/** 547/**
548 * set state of outgoing call 548 * set state of outgoing call
549 */ 549 */
550void 550static void
551set_outgoing_call_state (struct GNUNET_CONVERSATION_Call *call, 551set_outgoing_call_state (struct GNUNET_CONVERSATION_Call *call,
552 int state) 552 int state)
553{ 553{
@@ -555,9 +555,8 @@ set_outgoing_call_state (struct GNUNET_CONVERSATION_Call *call,
555 gint valid = 0; 555 gint valid = 0;
556 gint cl_type; 556 gint cl_type;
557 557
558 GCG_log("set state to: %u", state); 558 valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (active_liststore),
559 valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), &gtkiter); 559 &gtkiter);
560
561 if (!valid) 560 if (!valid)
562 GNUNET_break(0); 561 GNUNET_break(0);
563 while (valid) 562 while (valid)
@@ -660,13 +659,12 @@ set_outgoing_call_state (struct GNUNET_CONVERSATION_Call *call,
660 AL_caller_state, state, 659 AL_caller_state, state,
661 -1); 660 -1);
662 break; 661 break;
663 }//end switch 662 }
664 }//end call=cl_call 663 }
665 } //end cl_type 664 }
666 g_free (cl_caller_id); 665 g_free (cl_caller_id);
667 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), &gtkiter); 666 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), &gtkiter);
668 667 }
669 }//end while
670 GCG_update_status_bar (""); 668 GCG_update_status_bar ("");
671} 669}
672 670
@@ -680,61 +678,51 @@ set_incoming_call_state (struct GNUNET_CONVERSATION_Caller *caller,
680{ 678{
681 GtkTreeIter gtkiter; 679 GtkTreeIter gtkiter;
682 gint valid = 0; 680 gint valid = 0;
683 //FPRINTF (stderr,"set incoming call state:%u caller: ",state);
684
685// GCG_log (_("set incoming call state:%u caller: "),state);
686 681
687 valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), &gtkiter ); 682 valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), &gtkiter );
683 if (!valid)
684 GNUNET_break(0);
685 while (valid)
686 {
687 gchar *cl_caller_id;
688 gint cl_caller_num;
689 gpointer cl_caller;
688 690
689 if (!valid) 691 gtk_tree_model_get (GTK_TREE_MODEL (active_liststore ),
690 GNUNET_break(0); 692 &gtkiter,
691 693 AL_caller, &cl_caller,
692 while (valid) 694 AL_caller_id, &cl_caller_id,
695 AL_caller_num, &cl_caller_num,
696 -1);
697 if (caller == cl_caller)
693 { 698 {
694 gchar *cl_caller_id; 699 switch (state)
695 gint cl_caller_num;
696 gpointer cl_caller;
697
698 gtk_tree_model_get ( GTK_TREE_MODEL( active_liststore ), &gtkiter,
699 AL_caller, &cl_caller,
700 AL_caller_id,&cl_caller_id,
701 AL_caller_num,&cl_caller_num
702 ,-1);
703
704 if (caller == cl_caller)
705 { 700 {
706 //GCG_log (_("setting state for call:%u row: %u state: %u"),cl_caller_num,row_count,state); 701 case CT_hangup:
707 702 //GCG_log("remove line cause hangup");
708 switch (state) 703 gtk_list_store_remove (active_liststore,
709 { 704 &gtkiter);
710 case CT_hangup: 705 disable_list_buttons ();
711 //GCG_log("remove line cause hangup"); 706 break;
712 gtk_list_store_remove(active_liststore,&gtkiter); 707 case CT_rejected:
713 disable_list_buttons(); 708 //GCG_log("remove line cause rejected");
714 709 gtk_list_store_remove (active_liststore,
715 break; 710 &gtkiter);
716 711 disable_list_buttons ();
717 case CT_rejected: 712 break;
718 //GCG_log("remove line cause rejected"); 713 default:
719 gtk_list_store_remove(active_liststore,&gtkiter); 714 gtk_list_store_set (active_liststore,
720 disable_list_buttons(); 715 &gtkiter,
721 716 AL_caller_state, state,
722 break; 717 -1);
723 default: 718 break;
724 719 }
725 gtk_list_store_set(active_liststore, &gtkiter, 720 }
726 AL_caller_state, state, 721 g_free (cl_caller_id);
727 -1); 722 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore),
728 break; 723 &gtkiter);
729 724 }
730 }//end switch 725 GCG_update_status_bar("");
731 }//endif
732
733 g_free (cl_caller_id);
734 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), &gtkiter);
735
736 }//end while
737 GCG_update_status_bar("");
738} 726}
739 727
740 728
@@ -755,79 +743,61 @@ phone_event_handler (void *cls,
755 GtkTreeIter gtkiter; 743 GtkTreeIter gtkiter;
756 GtkTreeIter gtkiter1; 744 GtkTreeIter gtkiter1;
757 gboolean valid; 745 gboolean valid;
746 struct CallList *cl;
758 747
759 switch (code) 748 switch (code)
760 { 749 {
761 case GNUNET_CONVERSATION_EC_PHONE_RING: 750 case GNUNET_CONVERSATION_EC_PHONE_RING:
762 //increment call #
763 caller_num_gen++; 751 caller_num_gen++;
764
765
766 GCG_log (_("A Incoming call from `%s' with number %u\n"), 752 GCG_log (_("A Incoming call from `%s' with number %u\n"),
767 caller_id, 753 caller_id,
768 caller_num_gen); 754 caller_num_gen);
769
770 //old
771 struct CallList *cl;
772
773 cl = GNUNET_new (struct CallList); 755 cl = GNUNET_new (struct CallList);
774 cl->caller = caller; 756 cl->caller = caller;
775 cl->caller_id = GNUNET_strdup (caller_id); 757 cl->caller_id = GNUNET_strdup (caller_id);
776 cl->caller_num = caller_num_gen; 758 cl->caller_num = caller_num_gen;
777 GNUNET_CONTAINER_DLL_insert (cl_head, cl_tail, cl); 759 GNUNET_CONTAINER_DLL_insert (cl_head, cl_tail, cl);
778 //gtk 760 gtk_list_store_append (active_liststore,
779 gtk_list_store_append (active_liststore, &gtkiter); 761 &gtkiter);
780 762 gtk_list_store_set (active_liststore,
781 gtk_list_store_set (active_liststore, &gtkiter, 763 &gtkiter,
782 AL_caller_id, caller_id, 764 AL_caller_id, caller_id,
783 AL_caller, caller, 765 AL_caller, caller,
784 AL_caller_num, caller_num_gen, 766 AL_caller_num, caller_num_gen,
785 AL_caller_state, CT_ringing, 767 AL_caller_state, CT_ringing,
786 AL_type, CALL_IN 768 AL_type, CALL_IN,
787 ,-1); 769 -1);
788
789
790 break; 770 break;
791
792 case GNUNET_CONVERSATION_EC_PHONE_HUNG_UP: 771 case GNUNET_CONVERSATION_EC_PHONE_HUNG_UP:
793 //gtk
794
795 valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), &gtkiter1 ); 772 valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), &gtkiter1 );
796
797 if (!valid) 773 if (!valid)
798 GNUNET_break(0); 774 GNUNET_break(0);
799
800 while (valid) 775 while (valid)
801 { 776 {
802 //FPRINTF(stderr,"GNUNET_CONVERSATION_EC_PHONE_HUNG_UP: while valid");
803
804 gchar *str_data; 777 gchar *str_data;
805 gint int_data; 778 gint int_data;
806 gpointer cl_caller; 779 gpointer cl_caller;
807 780
808 gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), &gtkiter1, 781 gtk_tree_model_get (GTK_TREE_MODEL(active_liststore),
782 &gtkiter1,
809 AL_caller, &cl_caller, 783 AL_caller, &cl_caller,
810 AL_caller_id,&str_data, 784 AL_caller_id, &str_data,
811 AL_caller_num,&int_data,-1); 785 AL_caller_num, &int_data,
786 -1);
812 if (caller == cl_caller) 787 if (caller == cl_caller)
813 { 788 {
814 789 GCG_log (_("phone hung up:%s number: %u "),
815 GCG_log (_("phone hung up:%s number: %u "), str_data,int_data); 790 str_data,
816 set_incoming_call_state(caller,CT_rejected); 791 int_data);
817 break ; 792 set_incoming_call_state (caller,
793 CT_rejected);
794 break;
818 } 795 }
819 g_free (str_data); 796 g_free (str_data);
820 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), &gtkiter1); 797 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), &gtkiter1);
821 } 798 }
822
823
824
825 phone_state = PS_LISTEN; 799 phone_state = PS_LISTEN;
826 //add to call history list
827 //history_add(CH_HANGUP, cl->caller_id);
828
829 break; 800 break;
830
831 } 801 }
832 do_status(); 802 do_status();
833} 803}
@@ -843,34 +813,29 @@ static void
843caller_event_handler (void *cls, 813caller_event_handler (void *cls,
844 enum GNUNET_CONVERSATION_CallerEventCode code) 814 enum GNUNET_CONVERSATION_CallerEventCode code)
845{ 815{
816 struct CallList *cl = cls;
846 817
847 if (cls == NULL) 818 if (NULL == cl)
848 { 819 {
849 GCG_log("caller_event_handler: cls == NULL"); 820 GNUNET_break (0);
850 GNUNET_break(0); 821 return;
851 } 822 }
852 else 823 switch (code)
853 { 824 {
854 struct CallList *cl = cls; 825 case GNUNET_CONVERSATION_EC_CALLER_SUSPEND:
855 826 //TODO: should this be cls? not cl->caller
856 switch (code) 827 set_incoming_call_state(cl->caller,CT_suspended);
857 { 828 GCG_log (_("Call from `%s' suspended by other user\n"), cl->caller_id);
858 case GNUNET_CONVERSATION_EC_CALLER_SUSPEND: 829 break;
859 //TODO: should this be cls? not cl->caller 830 case GNUNET_CONVERSATION_EC_CALLER_RESUME:
860 set_incoming_call_state(cl->caller,CT_suspended); 831 set_incoming_call_state(cl->caller,CT_active);
861 GCG_log (_("Call from `%s' suspended by other user\n"), cl->caller_id); 832 GCG_log (_("Call from `%s' resumed by other user\n"), cl->caller_id);
862 break; 833 break;
863 case GNUNET_CONVERSATION_EC_CALLER_RESUME:
864 set_incoming_call_state(cl->caller,CT_active);
865 GCG_log (_("Call from `%s' resumed by other user\n"), cl->caller_id);
866 break;
867 }
868 } 834 }
869 do_status(); 835 do_status();
870} 836}
871 837
872 838
873
874/** 839/**
875 * Start our phone. 840 * Start our phone.
876 */ 841 */
@@ -924,57 +889,49 @@ call_event_handler (void *cls,
924{ 889{
925 //struct OutgoingCallClosure *cl = cls; 890 //struct OutgoingCallClosure *cl = cls;
926 891
927 //GCG_log("call event handler code: %u num: %u", code, cl->call_num); 892 set_outgoing_call_state (NULL, code);
928 893 switch (code)
929 //if (cls == NULL){ 894 {
930 set_outgoing_call_state(NULL, code); 895 case GNUNET_CONVERSATION_EC_CALL_RINGING:
931 //GNUNET_break(0); 896 GNUNET_break (CS_RESOLVING == call_state);
932 //} else 897 GCG_log (_("Resolved address of `%s'. Now ringing other party."),
933 //{ 898 peer_name);
934 switch (code) 899 // set_outgoing_call_state(cls, CT_ringing);
935 { 900 call_state = CS_RINGING;
936 case GNUNET_CONVERSATION_EC_CALL_RINGING: 901 break;
937 GNUNET_break (CS_RESOLVING == call_state); 902 case GNUNET_CONVERSATION_EC_CALL_PICKED_UP:
938 GCG_log (_("Resolved address of `%s'. Now ringing other party."), 903 GNUNET_break (CS_RINGING == call_state);
939 peer_name); 904 GCG_log (_("Connection established to `%s'."),
940 // set_outgoing_call_state(cls, CT_ringing); 905 peer_name);
941 call_state = CS_RINGING; 906 call_state = CS_CONNECTED;
942 break; 907 break;
943 case GNUNET_CONVERSATION_EC_CALL_PICKED_UP: 908 case GNUNET_CONVERSATION_EC_CALL_GNS_FAIL:
944 GNUNET_break (CS_RINGING == call_state); 909 GNUNET_break (CS_RESOLVING == call_state);
945 GCG_log (_("Connection established to `%s'."), 910 GCG_log (_("Failed to resolve %s in current zone."),
946 peer_name); 911 peer_name);
947 call_state = CS_CONNECTED; 912 call = NULL;
948 break; 913 break;
949 case GNUNET_CONVERSATION_EC_CALL_GNS_FAIL: 914 case GNUNET_CONVERSATION_EC_CALL_HUNG_UP:
950 GNUNET_break (CS_RESOLVING == call_state); 915 GCG_log ("%s", _("Call terminated"));
951 GCG_log (_("Failed to resolve %s in current zone."), 916 call = NULL;
952 peer_name); 917 break;
953 call = NULL; 918 case GNUNET_CONVERSATION_EC_CALL_SUSPENDED:
954 break; 919 GNUNET_break (CS_CONNECTED == call_state);
955 case GNUNET_CONVERSATION_EC_CALL_HUNG_UP: 920 GCG_log (_("Connection to `%s' suspended (by other user)\n"),
956 GCG_log ("%s", _("Call terminated")); 921 peer_name);
957 call = NULL; 922 break;
958 break; 923 case GNUNET_CONVERSATION_EC_CALL_RESUMED:
959 case GNUNET_CONVERSATION_EC_CALL_SUSPENDED: 924 GNUNET_break (CS_CONNECTED == call_state);
960 GNUNET_break (CS_CONNECTED == call_state); 925 GCG_log (_("Connection to `%s' resumed (by other user)\n"),
961 GCG_log (_("Connection to `%s' suspended (by other user)\n"), 926 peer_name);
962 peer_name); 927 break;
963 break; 928 case GNUNET_CONVERSATION_EC_CALL_ERROR:
964 case GNUNET_CONVERSATION_EC_CALL_RESUMED: 929 GCG_log ("GNUNET_CONVERSATION_EC_CALL_ERROR %s",
965 GNUNET_break (CS_CONNECTED == call_state); 930 peer_name);
966 GCG_log (_("Connection to `%s' resumed (by other user)\n"), 931 }
967 peer_name);
968 break;
969 case GNUNET_CONVERSATION_EC_CALL_ERROR:
970 GCG_log ("GNUNET_CONVERSATION_EC_CALL_ERROR %s",
971 peer_name);
972 }
973 //}
974} 932}
975 933
976 934
977
978/** 935/**
979 * Initiating a new call 936 * Initiating a new call
980 * 937 *
@@ -985,6 +942,7 @@ GSC_PHONE_make_call (const char *arg)
985{ 942{
986 GtkEntry *address_entry; 943 GtkEntry *address_entry;
987 struct GNUNET_IDENTITY_Ego *caller_id; 944 struct GNUNET_IDENTITY_Ego *caller_id;
945 GtkTreeIter gtkiter;
988 946
989 address_entry = GTK_ENTRY (GCG_get_main_window_object ("GNUNET_GTK_conversation_address")); 947 address_entry = GTK_ENTRY (GCG_get_main_window_object ("GNUNET_GTK_conversation_address"));
990 gtk_entry_set_text (address_entry, 948 gtk_entry_set_text (address_entry,
@@ -1038,25 +996,21 @@ GSC_PHONE_make_call (const char *arg)
1038 //call = newcall; 996 //call = newcall;
1039 997
1040 // add call to active call list 998 // add call to active call list
1041 GtkTreeIter gtkiter;
1042
1043 gtk_list_store_append (active_liststore, &gtkiter);
1044
1045 gtk_list_store_set (active_liststore, &gtkiter,
1046 AL_caller_id, peer_name,
1047 AL_caller, NULL,
1048 AL_caller_num, NULL,
1049 AL_caller_state, CT_other,
1050 AL_type, CALL_OUT,
1051 AL_call, call,
1052 AL_call_num, call_counter,
1053 AL_call_state, CS_RESOLVING,
1054 -1
1055 );
1056
1057 999
1000 gtk_list_store_append (active_liststore,
1001 &gtkiter);
1002 gtk_list_store_set (active_liststore, &gtkiter,
1003 AL_caller_id, peer_name,
1004 AL_caller, NULL,
1005 AL_caller_num, NULL,
1006 AL_caller_state, CT_other,
1007 AL_type, CALL_OUT,
1008 AL_call, call,
1009 AL_call_num, call_counter,
1010 AL_call_state, CS_RESOLVING,
1011 -1 );
1058 GCG_update_status_bar (_("We are calling `%s', his phone should be ringing."), 1012 GCG_update_status_bar (_("We are calling `%s', his phone should be ringing."),
1059 peer_name); 1013 peer_name);
1060 GCG_HISTORY_add (CH_OUTGOING, 1014 GCG_HISTORY_add (CH_OUTGOING,
1061 peer_name); 1015 peer_name);
1062} 1016}
@@ -1071,10 +1025,9 @@ static void
1071do_accept (struct GNUNET_CONVERSATION_Caller *sel_caller) 1025do_accept (struct GNUNET_CONVERSATION_Caller *sel_caller)
1072{ 1026{
1073 struct CallList *cl; 1027 struct CallList *cl;
1074 //char buf[32];
1075
1076 1028
1077 if ((NULL != call) && (CS_SUSPENDED != call_state)) 1029 if ( (NULL != call) &&
1030 (CS_SUSPENDED != call_state) )
1078 { 1031 {
1079 GCG_log (_("You are calling someone else already, hang up first!\n")); 1032 GCG_log (_("You are calling someone else already, hang up first!\n"));
1080 GNUNET_break(0); 1033 GNUNET_break(0);
@@ -1097,7 +1050,7 @@ do_accept (struct GNUNET_CONVERSATION_Caller *sel_caller)
1097 case PS_ERROR: 1050 case PS_ERROR:
1098 GNUNET_break (0); 1051 GNUNET_break (0);
1099 break; 1052 break;
1100 }//endswitch 1053 }
1101 1054
1102 phone_state = PS_ACCEPTED; 1055 phone_state = PS_ACCEPTED;
1103 set_incoming_call_state(sel_caller,CT_active); 1056 set_incoming_call_state(sel_caller,CT_active);
@@ -1119,51 +1072,32 @@ do_accept (struct GNUNET_CONVERSATION_Caller *sel_caller)
1119 1072
1120/** 1073/**
1121 * Suspending a call 1074 * Suspending a call
1122 *
1123 * @param args arguments given to the command
1124 */ 1075 */
1125static void 1076static void
1126do_suspend () 1077do_suspend ()
1127{ 1078{
1128 /* 1079 if ( (NULL != call_selected) &&
1129 switch (phone_state) 1080 (NULL != caller_selected) )
1130 { 1081 {
1131 case PS_LOOKUP_EGO: 1082 GNUNET_break(0);
1132 case PS_LISTEN:
1133 case PS_ERROR:
1134 GCG_log ("%s", _(" There is no call that could be suspended right now. (PS_ERROR)"));
1135 return; 1083 return;
1136 case PS_ACCEPTED:
1137 // expected state, do rejection logic
1138 break;
1139 } 1084 }
1140 */ 1085 if (NULL != call_selected)
1141 if (call_selected != NULL && caller_selected != NULL)
1142 { 1086 {
1143 GCG_log("this shoud not be possible"); 1087 /* outgoing */
1144 GNUNET_break(0); 1088 GNUNET_CONVERSATION_call_suspend (call_selected);
1089 set_outgoing_call_state(call_selected,CT_suspended);
1090 return;
1145 } 1091 }
1146 else 1092 if (NULL != caller_selected)
1147 { 1093 {
1148 // outgoing 1094 /* incoming */
1149 if (NULL != call_selected) 1095 GNUNET_CONVERSATION_caller_suspend (caller_selected);
1150 { 1096 set_incoming_call_state(caller_selected,CT_suspended);
1151 GNUNET_CONVERSATION_call_suspend (call_selected); 1097 phone_state = PS_LISTEN;
1152 set_outgoing_call_state(call_selected,CT_suspended); 1098 return;
1153
1154 return;
1155 }
1156
1157 // incoming
1158 if (NULL != caller_selected)
1159 {
1160 GNUNET_CONVERSATION_caller_suspend (caller_selected);
1161 set_incoming_call_state(caller_selected,CT_suspended);
1162 phone_state = PS_LISTEN;
1163 return;
1164
1165 }
1166 } 1099 }
1100 GNUNET_break (0);
1167} 1101}
1168 1102
1169 1103
@@ -1175,53 +1109,42 @@ do_suspend ()
1175static void 1109static void
1176do_resume () 1110do_resume ()
1177{ 1111{
1178 1112 switch (phone_state)
1179 switch (phone_state)
1180 { 1113 {
1181 case PS_LOOKUP_EGO: 1114 case PS_LOOKUP_EGO:
1182 case PS_ERROR: 1115 case PS_ERROR:
1183 GCG_log ("%s", _("There is no call that could be resumed right now.(PS_ERROR)")); 1116 GCG_log ("%s",
1117 _("There is no call that could be resumed right now.(PS_ERROR)"));
1184 return; 1118 return;
1185 case PS_LISTEN: 1119 case PS_LISTEN:
1186 break; 1120 break;
1187 case PS_ACCEPTED: 1121 case PS_ACCEPTED:
1188 GCG_log (_("Already talking with `%s', cannot resume a call right now."), 1122 GCG_log (_("Already talking with `%s', cannot resume a call right now."),
1189 peer_name); 1123 peer_name);
1190 return; 1124 return;
1191 } 1125 }
1192//// 1126 if ( (NULL != call_selected) &&
1193 if (call_selected != NULL && caller_selected != NULL) 1127 (NULL != caller_selected) )
1194 { 1128 {
1195 GCG_log("this shoud not be possible"); 1129 GNUNET_break(0);
1196 GNUNET_break(0); 1130 return;
1197 return;
1198 } 1131 }
1199 else 1132 if (NULL != call_selected)
1200 { 1133 {
1201 1134 /* outgoing */
1202 // outgoing 1135 GNUNET_CONVERSATION_call_resume (call_selected, speaker, mic);
1203 if (NULL != call_selected) 1136 set_outgoing_call_state(call_selected,CT_active);
1204 { 1137 return;
1205 GNUNET_CONVERSATION_call_resume (call_selected, speaker, mic);
1206 set_outgoing_call_state(call_selected,CT_active);
1207
1208 return;
1209 }
1210
1211 // incoming
1212 if (NULL != caller_selected)
1213 {
1214 GNUNET_CONVERSATION_caller_resume (caller_selected, speaker, mic);
1215 set_incoming_call_state(caller_selected,CT_active);
1216 phone_state = PS_ACCEPTED;
1217 return;
1218
1219 }
1220 GNUNET_break(0);
1221 } 1138 }
1222 1139 if (NULL != caller_selected)
1223// 1140 {
1224//// 1141 /* incoming */
1142 GNUNET_CONVERSATION_caller_resume (caller_selected, speaker, mic);
1143 set_incoming_call_state(caller_selected,CT_active);
1144 phone_state = PS_ACCEPTED;
1145 return;
1146 }
1147 GNUNET_break(0);
1225} 1148}
1226 1149
1227 1150
@@ -1233,42 +1156,31 @@ do_resume ()
1233static void 1156static void
1234do_reject () 1157do_reject ()
1235{ 1158{
1236 if (call_selected == NULL && caller_selected == NULL) 1159 if ( (NULL == call_selected) &&
1160 (NULL == caller_selected) )
1237 { 1161 {
1238 GNUNET_break(0); 1162 GNUNET_break(0);
1163 return;
1239 } 1164 }
1240 else 1165 if (NULL != call_selected)
1241 { 1166 {
1242 // if selected call is outgoing, stop it 1167 /* if selected call is outgoing, stop it */
1243 if (NULL != call_selected) 1168 set_outgoing_call_state (call_selected, CT_hangup);
1244 { 1169 GNUNET_CONVERSATION_call_stop (call);
1245 set_outgoing_call_state(call_selected,CT_hangup); 1170 call = NULL;
1246 1171 call_selected = NULL;
1247 GNUNET_CONVERSATION_call_stop(call); 1172 return;
1248 //GNUNET_CONVERSATION_call_stop (call_selected); 1173 }
1249 1174 if (NULL != caller_selected)
1250 call = NULL; 1175 {
1251 call_selected = NULL; 1176 /* if selected call is incoming, hang it up */
1252 return; 1177 set_incoming_call_state (caller_selected,CT_hangup);
1253 } 1178 GNUNET_CONVERSATION_caller_hang_up (caller_selected);
1254 else 1179 phone_state = PS_LISTEN;
1255 { 1180 caller_selected = NULL;
1256 // if selected call is incoming, hang it up 1181 return;
1257 if (NULL != caller_selected)
1258 {
1259 set_incoming_call_state(caller_selected,CT_hangup);
1260 //FPRINTF(stderr,"hangup: %u", caller_selected);
1261 GNUNET_CONVERSATION_caller_hang_up(caller_selected);
1262 //cl_active = NULL;
1263 phone_state = PS_LISTEN;
1264 caller_selected = NULL;
1265 }
1266 else
1267 {
1268 GNUNET_break(0);
1269 }
1270 }
1271 } 1182 }
1183 GNUNET_break (0);
1272} 1184}
1273 1185
1274 1186
@@ -1278,26 +1190,26 @@ do_reject ()
1278void 1190void
1279GNUNET_CONVERSATION_GTK_on_hangup_clicked () 1191GNUNET_CONVERSATION_GTK_on_hangup_clicked ()
1280{ 1192{
1281
1282 do_reject (); 1193 do_reject ();
1283
1284 do_status (); 1194 do_status ();
1285 //history_add(3,peer_name);
1286} 1195}
1287 1196
1197
1288/** 1198/**
1289 * accept clicked 1199 * accept clicked
1290 */ 1200 */
1291void 1201void
1292GNUNET_CONVERSATION_GTK_on_accept_clicked () 1202GNUNET_CONVERSATION_GTK_on_accept_clicked ()
1293{ 1203{
1294 if (caller_selected != NULL) 1204 if (NULL != caller_selected)
1295 { 1205 {
1296 do_accept (caller_selected); 1206 do_accept (caller_selected);
1297 } else {
1298 GNUNET_break(0);
1299 } 1207 }
1300 do_status(); 1208 else
1209 {
1210 GNUNET_break(0);
1211 }
1212 do_status ();
1301} 1213}
1302 1214
1303 1215
@@ -1308,7 +1220,7 @@ void
1308GNUNET_CONVERSATION_GTK_on_reject_clicked () 1220GNUNET_CONVERSATION_GTK_on_reject_clicked ()
1309{ 1221{
1310 do_reject (); 1222 do_reject ();
1311 do_status(); 1223 do_status ();
1312} 1224}
1313 1225
1314 1226
@@ -1331,7 +1243,6 @@ GNUNET_CONVERSATION_GTK_use_current_button_clicked (GtkButton *button,
1331} 1243}
1332 1244
1333 1245
1334
1335/** 1246/**
1336 * pause clicked 1247 * pause clicked
1337 */ 1248 */
@@ -1339,7 +1250,7 @@ void
1339GNUNET_CONVERSATION_GTK_on_pause_clicked () 1250GNUNET_CONVERSATION_GTK_on_pause_clicked ()
1340{ 1251{
1341 do_suspend (); 1252 do_suspend ();
1342 do_status(); 1253 do_status ();
1343} 1254}
1344 1255
1345/** 1256/**
@@ -1349,15 +1260,6 @@ void
1349GNUNET_CONVERSATION_GTK_on_resume_clicked () 1260GNUNET_CONVERSATION_GTK_on_resume_clicked ()
1350{ 1261{
1351 do_resume (); 1262 do_resume ();
1352 do_status();
1353}
1354
1355/**
1356 * status clicked
1357 */
1358void
1359GNUNET_CONVERSATION_GTK_on_status_clicked ()
1360{
1361 do_status (); 1263 do_status ();
1362} 1264}
1363 1265