aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-06-01 13:30:32 +0000
committerChristian Grothoff <christian@grothoff.org>2014-06-01 13:30:32 +0000
commit87436dc094f656a0f96752063b30b46bb123328e (patch)
tree19d54eeb2140b19bccb61c4d257bbfe48f9d7544
parentba35f9d50322d6dd3398b2b0feb035a6732360b1 (diff)
downloadgnunet-gtk-87436dc094f656a0f96752063b30b46bb123328e.tar.gz
gnunet-gtk-87436dc094f656a0f96752063b30b46bb123328e.zip
-fix crashes, simplify code
-rw-r--r--contrib/gnunet_conversation_gtk_main_window.glade25
-rw-r--r--src/conversation/gnunet-conversation-gtk_contacts.c7
-rw-r--r--src/conversation/gnunet-conversation-gtk_egos.c5
-rw-r--r--src/conversation/gnunet-conversation-gtk_phone.c75
4 files changed, 33 insertions, 79 deletions
diff --git a/contrib/gnunet_conversation_gtk_main_window.glade b/contrib/gnunet_conversation_gtk_main_window.glade
index 31028399..3fa116ef 100644
--- a/contrib/gnunet_conversation_gtk_main_window.glade
+++ b/contrib/gnunet_conversation_gtk_main_window.glade
@@ -1,7 +1,6 @@
1<?xml version="1.0" encoding="UTF-8"?> 1<?xml version="1.0" encoding="UTF-8"?>
2<!-- Generated with glade 3.18.3 -->
3<interface> 2<interface>
4 <requires lib="gtk+" version="3.0"/> 3 <!-- interface-requires gtk+ 3.0 -->
5 <object class="GtkListStore" id="gnunet_conversation_gtk_active_calls_liststore"> 4 <object class="GtkListStore" id="gnunet_conversation_gtk_active_calls_liststore">
6 <columns> 5 <columns>
7 <!-- column-name caller_id --> 6 <!-- column-name caller_id -->
@@ -22,12 +21,12 @@
22 <column type="gint"/> 21 <column type="gint"/>
23 </columns> 22 </columns>
24 </object> 23 </object>
25 <object class="GtkListStore" id="gnunet_conversation_gtk_caller_id_zone_liststore"> 24 <object class="GtkListStore" id="gnunet_conversation_gtk_contacts_liststore">
26 <columns> 25 <columns>
27 <!-- column-name ego_name --> 26 <!-- column-name contact_name -->
27 <column type="gchararray"/>
28 <!-- column-name contact_type -->
28 <column type="gchararray"/> 29 <column type="gchararray"/>
29 <!-- column-name ego -->
30 <column type="gpointer"/>
31 </columns> 30 </columns>
32 </object> 31 </object>
33 <object class="GtkListStore" id="gnunet_conversation_gtk_contacts_zone_liststore"> 32 <object class="GtkListStore" id="gnunet_conversation_gtk_contacts_zone_liststore">
@@ -99,6 +98,7 @@
99 </child> 98 </child>
100 <child> 99 <child>
101 <object class="GtkMenuItem" id="gnunet_conversation_gtk_view_menu"> 100 <object class="GtkMenuItem" id="gnunet_conversation_gtk_view_menu">
101 <property name="use_action_appearance">False</property>
102 <property name="visible">True</property> 102 <property name="visible">True</property>
103 <property name="can_focus">False</property> 103 <property name="can_focus">False</property>
104 <property name="label" translatable="yes">_View</property> 104 <property name="label" translatable="yes">_View</property>
@@ -109,6 +109,7 @@
109 <property name="can_focus">False</property> 109 <property name="can_focus">False</property>
110 <child> 110 <child>
111 <object class="GtkCheckMenuItem" id="gnunet_conversation_gtk_view_history_checkmenuitem"> 111 <object class="GtkCheckMenuItem" id="gnunet_conversation_gtk_view_history_checkmenuitem">
112 <property name="use_action_appearance">False</property>
112 <property name="visible">True</property> 113 <property name="visible">True</property>
113 <property name="can_focus">False</property> 114 <property name="can_focus">False</property>
114 <property name="label" translatable="yes">_History</property> 115 <property name="label" translatable="yes">_History</property>
@@ -118,6 +119,7 @@
118 </child> 119 </child>
119 <child> 120 <child>
120 <object class="GtkCheckMenuItem" id="gnunet_conversation_gtk_view_log_checkmenuitem"> 121 <object class="GtkCheckMenuItem" id="gnunet_conversation_gtk_view_log_checkmenuitem">
122 <property name="use_action_appearance">False</property>
121 <property name="visible">True</property> 123 <property name="visible">True</property>
122 <property name="can_focus">False</property> 124 <property name="can_focus">False</property>
123 <property name="label" translatable="yes">_Logs</property> 125 <property name="label" translatable="yes">_Logs</property>
@@ -281,6 +283,7 @@
281 <property name="visible">True</property> 283 <property name="visible">True</property>
282 <property name="can_focus">True</property> 284 <property name="can_focus">True</property>
283 <property name="receives_default">True</property> 285 <property name="receives_default">True</property>
286 <property name="use_action_appearance">False</property>
284 <property name="use_underline">True</property> 287 <property name="use_underline">True</property>
285 <property name="use_stock">True</property> 288 <property name="use_stock">True</property>
286 <signal name="clicked" handler="gnunet_conversation_gtk_call_button_clicked_cb" swapped="no"/> 289 <signal name="clicked" handler="gnunet_conversation_gtk_call_button_clicked_cb" swapped="no"/>
@@ -299,6 +302,7 @@
299 <property name="sensitive">False</property> 302 <property name="sensitive">False</property>
300 <property name="can_focus">True</property> 303 <property name="can_focus">True</property>
301 <property name="receives_default">True</property> 304 <property name="receives_default">True</property>
305 <property name="use_action_appearance">False</property>
302 <property name="use_stock">True</property> 306 <property name="use_stock">True</property>
303 <signal name="clicked" handler="GNUNET_CONVERSATION_GTK_on_pause_clicked" swapped="no"/> 307 <signal name="clicked" handler="GNUNET_CONVERSATION_GTK_on_pause_clicked" swapped="no"/>
304 </object> 308 </object>
@@ -316,6 +320,7 @@
316 <property name="sensitive">False</property> 320 <property name="sensitive">False</property>
317 <property name="can_focus">True</property> 321 <property name="can_focus">True</property>
318 <property name="receives_default">True</property> 322 <property name="receives_default">True</property>
323 <property name="use_action_appearance">False</property>
319 <property name="use_stock">True</property> 324 <property name="use_stock">True</property>
320 <signal name="clicked" handler="GNUNET_CONVERSATION_GTK_on_hangup_clicked" swapped="no"/> 325 <signal name="clicked" handler="GNUNET_CONVERSATION_GTK_on_hangup_clicked" swapped="no"/>
321 </object> 326 </object>
@@ -422,6 +427,7 @@
422 <property name="sensitive">False</property> 427 <property name="sensitive">False</property>
423 <property name="can_focus">True</property> 428 <property name="can_focus">True</property>
424 <property name="receives_default">True</property> 429 <property name="receives_default">True</property>
430 <property name="use_action_appearance">False</property>
425 <property name="xalign">0.4699999988079071</property> 431 <property name="xalign">0.4699999988079071</property>
426 <signal name="clicked" handler="GNUNET_CONVERSATION_GTK_use_current_button_clicked" swapped="no"/> 432 <signal name="clicked" handler="GNUNET_CONVERSATION_GTK_use_current_button_clicked" swapped="no"/>
427 </object> 433 </object>
@@ -440,6 +446,7 @@
440 <property name="sensitive">False</property> 446 <property name="sensitive">False</property>
441 <property name="can_focus">True</property> 447 <property name="can_focus">True</property>
442 <property name="receives_default">True</property> 448 <property name="receives_default">True</property>
449 <property name="use_action_appearance">False</property>
443 <signal name="clicked" handler="GNUNET_CONVERSATION_GTK_on_accept_clicked" swapped="no"/> 450 <signal name="clicked" handler="GNUNET_CONVERSATION_GTK_on_accept_clicked" swapped="no"/>
444 </object> 451 </object>
445 <packing> 452 <packing>
@@ -457,6 +464,7 @@
457 <property name="sensitive">False</property> 464 <property name="sensitive">False</property>
458 <property name="can_focus">True</property> 465 <property name="can_focus">True</property>
459 <property name="receives_default">True</property> 466 <property name="receives_default">True</property>
467 <property name="use_action_appearance">False</property>
460 <signal name="clicked" handler="GNUNET_CONVERSATION_GTK_on_resume_clicked" swapped="no"/> 468 <signal name="clicked" handler="GNUNET_CONVERSATION_GTK_on_resume_clicked" swapped="no"/>
461 </object> 469 </object>
462 <packing> 470 <packing>
@@ -474,6 +482,7 @@
474 <property name="sensitive">False</property> 482 <property name="sensitive">False</property>
475 <property name="can_focus">True</property> 483 <property name="can_focus">True</property>
476 <property name="receives_default">True</property> 484 <property name="receives_default">True</property>
485 <property name="use_action_appearance">False</property>
477 </object> 486 </object>
478 <packing> 487 <packing>
479 <property name="expand">False</property> 488 <property name="expand">False</property>
@@ -492,7 +501,7 @@
492 </child> 501 </child>
493 </object> 502 </object>
494 <packing> 503 <packing>
495 <property name="expand">False</property> 504 <property name="expand">True</property>
496 <property name="fill">True</property> 505 <property name="fill">True</property>
497 <property name="position">2</property> 506 <property name="position">2</property>
498 </packing> 507 </packing>
@@ -579,7 +588,7 @@
579 <object class="GtkTreeView" id="gnunet_conversation_gtk_contact_list_treeview"> 588 <object class="GtkTreeView" id="gnunet_conversation_gtk_contact_list_treeview">
580 <property name="visible">True</property> 589 <property name="visible">True</property>
581 <property name="can_focus">True</property> 590 <property name="can_focus">True</property>
582 <property name="model"/> 591 <property name="model">gnunet_conversation_gtk_contacts_liststore</property>
583 <property name="headers_clickable">False</property> 592 <property name="headers_clickable">False</property>
584 <property name="search_column">0</property> 593 <property name="search_column">0</property>
585 <signal name="row-activated" handler="gnunet_conversation_gtk_contact_list_treeview_row_activated_cb" swapped="no"/> 594 <signal name="row-activated" handler="gnunet_conversation_gtk_contact_list_treeview_row_activated_cb" swapped="no"/>
diff --git a/src/conversation/gnunet-conversation-gtk_contacts.c b/src/conversation/gnunet-conversation-gtk_contacts.c
index e8bb80d6..01c674df 100644
--- a/src/conversation/gnunet-conversation-gtk_contacts.c
+++ b/src/conversation/gnunet-conversation-gtk_contacts.c
@@ -116,6 +116,13 @@ gnunet_conversation_gtk_contact_list_treeview_row_activated_cb (GtkTreeView *tr
116} 116}
117 117
118 118
119void
120gnunet_conversation_gtk_contact_list_value_renderer_edited_cb ()
121{
122 GNUNET_break (0); // not implemented
123}
124
125
119/** 126/**
120 * Process a record that was stored or modified the namestore by 127 * Process a record that was stored or modified the namestore by
121 * adding/modifying/removing it in the liststore. 128 * adding/modifying/removing it in the liststore.
diff --git a/src/conversation/gnunet-conversation-gtk_egos.c b/src/conversation/gnunet-conversation-gtk_egos.c
index 5136a938..9c6cc432 100644
--- a/src/conversation/gnunet-conversation-gtk_egos.c
+++ b/src/conversation/gnunet-conversation-gtk_egos.c
@@ -104,6 +104,11 @@ identity_cb (void *cls,
104 GtkTreePath *path; 104 GtkTreePath *path;
105 GtkComboBox *cb; 105 GtkComboBox *cb;
106 106
107 if (NULL == ctx)
108 {
109 /* end of initial iteration, ignore */
110 return;
111 }
107 rr = *ctx; 112 rr = *ctx;
108 if (NULL == rr) 113 if (NULL == rr)
109 { 114 {
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 */