aboutsummaryrefslogtreecommitdiff
path: root/src/conversation/gnunet-conversation-gtk_phone.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/conversation/gnunet-conversation-gtk_phone.c')
-rw-r--r--src/conversation/gnunet-conversation-gtk_phone.c75
1 files changed, 4 insertions, 71 deletions
diff --git a/src/conversation/gnunet-conversation-gtk_phone.c b/src/conversation/gnunet-conversation-gtk_phone.c
index 210c8c56..95275615 100644
--- a/src/conversation/gnunet-conversation-gtk_phone.c
+++ b/src/conversation/gnunet-conversation-gtk_phone.c
@@ -99,33 +99,6 @@ enum TypeOfConversation
99 99
100 100
101/** 101/**
102 * Possible states of the phone.
103 */
104enum PhoneState
105{
106 /**
107 * We're waiting for the user to select a caller ID.
108 */
109 PS_LOOKUP_EGO,
110
111 /**
112 * We're listening for calls
113 */
114 PS_LISTEN,
115
116 /**
117 * We accepted an incoming phone call.
118 */
119 PS_ACCEPTED,
120
121 /**
122 * Internal error
123 */
124 PS_ERROR
125};
126
127
128/**
129 * States for current incoming call. 102 * States for current incoming call.
130 */ 103 */
131enum InCallState 104enum InCallState
@@ -298,11 +271,6 @@ static struct GNUNET_SPEAKER_Handle *speaker;
298 */ 271 */
299static struct GNUNET_MICROPHONE_Handle *mic; 272static struct GNUNET_MICROPHONE_Handle *mic;
300 273
301/**
302 * Our phone's current state.
303 */
304static enum PhoneState phone_state;
305
306 274
307/** 275/**
308 * Counts the number of incoming calls we have had so far. 276 * Counts the number of incoming calls we have had so far.
@@ -427,8 +395,7 @@ do_status ()
427 return; 395 return;
428 } 396 }
429 if ( (NULL == active_in) && 397 if ( (NULL == active_in) &&
430 (NULL == active_out) && 398 (NULL == active_out) )
431 (PS_LISTEN == phone_state) )
432 { 399 {
433 GCG_update_status_bar ("%s", 400 GCG_update_status_bar ("%s",
434 _("We are listening for incoming calls")); 401 _("We are listening for incoming calls"));
@@ -448,7 +415,7 @@ check_call_sensitivity ()
448{ 415{
449 gboolean sens; 416 gboolean sens;
450 417
451 sens = (PS_LISTEN == phone_state); 418 sens = (NULL == active_in) && (NULL == active_out);
452 if (0 == strlen (gtk_entry_get_text (address_entry))) 419 if (0 == strlen (gtk_entry_get_text (address_entry)))
453 sens = FALSE; 420 sens = FALSE;
454 gtk_widget_set_sensitive (b_call, sens); 421 gtk_widget_set_sensitive (b_call, sens);
@@ -750,7 +717,6 @@ phone_event_handler (void *cls,
750 &iter); 717 &iter);
751 } 718 }
752 GNUNET_break (valid); 719 GNUNET_break (valid);
753 phone_state = PS_LISTEN;
754 break; 720 break;
755 } 721 }
756 do_status(); 722 do_status();
@@ -860,14 +826,12 @@ GNUNET_CONVERSATION_GTK_on_accept_clicked (GtkButton *button,
860 GtkTreeModel *model; 826 GtkTreeModel *model;
861 827
862 if ( (NULL != active_in) || 828 if ( (NULL != active_in) ||
863 (NULL != active_out) || 829 (NULL != active_out) )
864 (PS_LISTEN != phone_state) )
865 { 830 {
866 /* accept button should not have been sensitive! */ 831 /* accept button should not have been sensitive! */
867 GNUNET_break (0); 832 GNUNET_break (0);
868 return; 833 return;
869 } 834 }
870 phone_state = PS_ACCEPTED;
871 sel = gtk_tree_view_get_selection (active_treeview); 835 sel = gtk_tree_view_get_selection (active_treeview);
872 if (! gtk_tree_selection_get_selected (sel, 836 if (! gtk_tree_selection_get_selected (sel,
873 &model, 837 &model,
@@ -887,7 +851,6 @@ GNUNET_CONVERSATION_GTK_on_accept_clicked (GtkButton *button,
887 GNUNET_break (0); 851 GNUNET_break (0);
888 return; 852 return;
889 } 853 }
890 phone_state = PS_ACCEPTED;
891 active_in = ic; 854 active_in = ic;
892 set_incoming_call_state (ic, 855 set_incoming_call_state (ic,
893 IN_STATE_CONNECTED); 856 IN_STATE_CONNECTED);
@@ -950,7 +913,6 @@ GNUNET_CONVERSATION_GTK_on_reject_clicked (GtkButton *button,
950 set_incoming_call_state (ic, 913 set_incoming_call_state (ic,
951 IN_STATE_NONE); 914 IN_STATE_NONE);
952 destroy_in (ic); 915 destroy_in (ic);
953 phone_state = PS_LISTEN; /* FIXME: or error... */
954 do_status (); 916 do_status ();
955 return; 917 return;
956 } 918 }
@@ -970,7 +932,6 @@ GNUNET_CONVERSATION_GTK_on_reject_clicked (GtkButton *button,
970 set_outgoing_call_state (oc, 932 set_outgoing_call_state (oc,
971 OUT_STATE_NONE); 933 OUT_STATE_NONE);
972 destroy_out (oc); 934 destroy_out (oc);
973 phone_state = PS_LISTEN; /* FIXME: or error... */
974 do_status (); 935 do_status ();
975 return; 936 return;
976 } 937 }
@@ -1018,9 +979,7 @@ GNUNET_CONVERSATION_GTK_on_resume_clicked (GtkButton *button,
1018 GtkTreeModel *model; 979 GtkTreeModel *model;
1019 980
1020 if ( (NULL != active_in) || 981 if ( (NULL != active_in) ||
1021 (NULL != active_out) || 982 (NULL != active_out) )
1022 (! (PS_LISTEN == phone_state) ||
1023 (PS_ERROR == phone_state) ) )
1024 { 983 {
1025 /* resume button should have been inactive */ 984 /* resume button should have been inactive */
1026 GNUNET_break(0); 985 GNUNET_break(0);
@@ -1043,7 +1002,6 @@ GNUNET_CONVERSATION_GTK_on_resume_clicked (GtkButton *button,
1043 -1); 1002 -1);
1044 if (NULL != ic) 1003 if (NULL != ic)
1045 { 1004 {
1046 phone_state = PS_ACCEPTED;
1047 active_in = ic; 1005 active_in = ic;
1048 set_incoming_call_state (ic, 1006 set_incoming_call_state (ic,
1049 IN_STATE_CONNECTED); 1007 IN_STATE_CONNECTED);
@@ -1058,7 +1016,6 @@ GNUNET_CONVERSATION_GTK_on_resume_clicked (GtkButton *button,
1058 } 1016 }
1059 if (NULL != oc) 1017 if (NULL != oc)
1060 { 1018 {
1061 phone_state = PS_ACCEPTED;
1062 active_out = oc; 1019 active_out = oc;
1063 GNUNET_CONVERSATION_call_resume (oc->call, 1020 GNUNET_CONVERSATION_call_resume (oc->call,
1064 speaker, mic); 1021 speaker, mic);
@@ -1127,7 +1084,6 @@ GNUNET_CONVERSATION_GTK_on_pause_clicked (GtkButton *button,
1127 set_outgoing_call_state (active_out, 1084 set_outgoing_call_state (active_out,
1128 os); 1085 os);
1129 active_out = NULL; 1086 active_out = NULL;
1130 phone_state = PS_LISTEN;
1131 gtk_widget_hide (b_suspend); 1087 gtk_widget_hide (b_suspend);
1132 gtk_widget_hide (b_hangup); 1088 gtk_widget_hide (b_hangup);
1133 gtk_widget_show (b_call); 1089 gtk_widget_show (b_call);
@@ -1143,7 +1099,6 @@ GNUNET_CONVERSATION_GTK_on_pause_clicked (GtkButton *button,
1143 { 1099 {
1144 /* incoming */ 1100 /* incoming */
1145 GNUNET_CONVERSATION_caller_suspend (active_in->caller); 1101 GNUNET_CONVERSATION_caller_suspend (active_in->caller);
1146 phone_state = PS_LISTEN;
1147 is = active_in->state; 1102 is = active_in->state;
1148 switch (active_in->state) 1103 switch (active_in->state)
1149 { 1104 {
@@ -1228,7 +1183,6 @@ GNUNET_CONVERSATION_GTK_on_hangup_clicked (GtkButton *button,
1228 IN_STATE_NONE); 1183 IN_STATE_NONE);
1229 destroy_in (active_in); 1184 destroy_in (active_in);
1230 active_in = NULL; 1185 active_in = NULL;
1231 phone_state = PS_LISTEN;
1232 gtk_widget_hide (b_suspend); 1186 gtk_widget_hide (b_suspend);
1233 gtk_widget_hide (b_hangup); 1187 gtk_widget_hide (b_hangup);
1234 gtk_widget_show (b_call); 1188 gtk_widget_show (b_call);
@@ -1460,23 +1414,6 @@ GSC_PHONE_make_call (const char *arg)
1460 arg); 1414 arg);
1461 return; 1415 return;
1462 } 1416 }
1463 switch (phone_state)
1464 {
1465 case PS_LOOKUP_EGO:
1466 GCG_log ("%s\n",
1467 _("Caller ID unavailable, cannot initiate call."));
1468 return;
1469 case PS_LISTEN:
1470 /* ok to call! */
1471 break;
1472 case PS_ACCEPTED:
1473 /* `call` should be non-NULL */
1474 GNUNET_break (0);
1475 return;
1476 case PS_ERROR:
1477 /* ok to call, we got an ego just could not init the phone */
1478 break;
1479 }
1480 call_counter++; 1417 call_counter++;
1481 oc = GNUNET_new (struct OutgoingCall); 1418 oc = GNUNET_new (struct OutgoingCall);
1482 oc->peer_name = GNUNET_strdup (arg); 1419 oc->peer_name = GNUNET_strdup (arg);
@@ -1578,7 +1515,6 @@ gnunet_conversation_gtk_ego_combobox_changed_cb (GtkComboBox *widget,
1578 GCG_log ("%s\n", 1515 GCG_log ("%s\n",
1579 _("No ego selected, phone is now down.")); 1516 _("No ego selected, phone is now down."));
1580 GCG_set_status_icon ("gnunet-conversation-gtk-tray-pending"); 1517 GCG_set_status_icon ("gnunet-conversation-gtk-tray-pending");
1581 phone_state = PS_LOOKUP_EGO;
1582 check_call_sensitivity (); 1518 check_call_sensitivity ();
1583 return; 1519 return;
1584 } 1520 }
@@ -1594,7 +1530,6 @@ gnunet_conversation_gtk_ego_combobox_changed_cb (GtkComboBox *widget,
1594 GCG_log ("%s", 1530 GCG_log ("%s",
1595 _("Failed to setup phone (internal error)\n")); 1531 _("Failed to setup phone (internal error)\n"));
1596 GCG_set_status_icon ("gnunet-conversation-offline"); 1532 GCG_set_status_icon ("gnunet-conversation-offline");
1597 phone_state = PS_ERROR;
1598 check_call_sensitivity (); 1533 check_call_sensitivity ();
1599 return; 1534 return;
1600 } 1535 }
@@ -1603,7 +1538,6 @@ gnunet_conversation_gtk_ego_combobox_changed_cb (GtkComboBox *widget,
1603 /* FIXME: publish record to GNS! */ 1538 /* FIXME: publish record to GNS! */
1604 GCG_log ("%s\n", 1539 GCG_log ("%s\n",
1605 _("Phone active")); 1540 _("Phone active"));
1606 phone_state = PS_LISTEN;
1607 check_call_sensitivity (); 1541 check_call_sensitivity ();
1608 do_status(); 1542 do_status();
1609} 1543}
@@ -1672,7 +1606,6 @@ GCG_PHONE_shutdown ()
1672 speaker = NULL; 1606 speaker = NULL;
1673 GNUNET_MICROPHONE_destroy (mic); 1607 GNUNET_MICROPHONE_destroy (mic);
1674 mic = NULL; 1608 mic = NULL;
1675 phone_state = PS_ERROR;
1676} 1609}
1677 1610
1678/* end of gnunet-conversation-gtk_phone.c */ 1611/* end of gnunet-conversation-gtk_phone.c */