diff options
Diffstat (limited to 'src/conversation/gnunet-conversation-gtk_phone.c')
-rw-r--r-- | src/conversation/gnunet-conversation-gtk_phone.c | 252 |
1 files changed, 145 insertions, 107 deletions
diff --git a/src/conversation/gnunet-conversation-gtk_phone.c b/src/conversation/gnunet-conversation-gtk_phone.c index 95275615..22f2e2af 100644 --- a/src/conversation/gnunet-conversation-gtk_phone.c +++ b/src/conversation/gnunet-conversation-gtk_phone.c | |||
@@ -38,45 +38,50 @@ | |||
38 | enum ActiveCallsTreeViewColumns | 38 | enum ActiveCallsTreeViewColumns |
39 | { | 39 | { |
40 | /** | 40 | /** |
41 | * A `gchar *` | 41 | * A `gchar *` giving the name of the remote user. |
42 | */ | 42 | */ |
43 | GCG_PHONE_LS_CALLER_ID, | 43 | GCG_PHONE_LS_REMOTE_USER_NAME, |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * A `struct IncomingCall *` | 46 | * A `struct IncomingCall *` for incoming calls, otherwise NULL. |
47 | */ | 47 | */ |
48 | GCG_PHONE_LS_CALLER, | 48 | GCG_PHONE_LS_INCOMING_CALL, |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * A `gint`. | 51 | * A `gint` uniquely identifying the call to the user. |
52 | */ | 52 | */ |
53 | GCG_PHONE_LS_CALLER_NUM, | 53 | GCG_PHONE_LS_NUMBER, |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * A `gint` for a `enum TypeOfConversation` (FIXME: remove?) | 56 | * A `gint` for a `enum TypeOfConversation`. |
57 | */ | 57 | */ |
58 | GCG_PHONE_LS_TYPE, | 58 | GCG_PHONE_LS_TYPE, |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * A `gint` for a `enum InCallState` (FIXME: replace with char *!) | 61 | * A `gint` for a `enum InCallState`. |
62 | */ | 62 | */ |
63 | GCG_PHONE_LS_CALLER_STATE, | 63 | GCG_PHONE_LS_IN_CALL_STATE, |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * A `struct OutgoingCall *`. | 66 | * A `struct OutgoingCall *` for outgoing calls, otherwise NULL. |
67 | */ | 67 | */ |
68 | GCG_PHONE_LS_CALL, | 68 | GCG_PHONE_LS_OUTGOING_CALL, |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * A `gint` for a `enum OutCallState` (FIXME: replace with char *, | 71 | * A `gint` for a `enum OutCallState`. |
72 | * combine with #GCG_PHONE_LS_CALLER_STATE). | ||
73 | */ | 72 | */ |
74 | GCG_PHONE_LS_CALL_STATE, | 73 | GCG_PHONE_LS_OUT_CALL_STATE, |
75 | 74 | ||
76 | /** | 75 | /** |
77 | * A `gint`. FIXME: combine with #GCG_PHONE_LS_CALLER_NUM! | 76 | * A `gchararray` describing the state of the call. |
78 | */ | 77 | */ |
79 | GCG_PHONE_LS_CALL_NUM | 78 | GCG_PHONE_LS_STATE_NAME, |
79 | |||
80 | /** | ||
81 | * A `GdkPixbuf` visualizing the state of the call. | ||
82 | * Not yet used. | ||
83 | */ | ||
84 | GCG_PHONE_LS_STATE_PIXBUF | ||
80 | 85 | ||
81 | }; | 86 | }; |
82 | 87 | ||
@@ -158,7 +163,7 @@ enum OutCallState | |||
158 | /** | 163 | /** |
159 | * This phone call is currently active. | 164 | * This phone call is currently active. |
160 | */ | 165 | */ |
161 | OUT_STATE_ACTIVE, | 166 | OUT_STATE_CONNECTED, |
162 | 167 | ||
163 | /** | 168 | /** |
164 | * This phone call is currently suspended by local. | 169 | * This phone call is currently suspended by local. |
@@ -202,7 +207,7 @@ struct IncomingCall | |||
202 | /** | 207 | /** |
203 | * Unique number of the caller. | 208 | * Unique number of the caller. |
204 | */ | 209 | */ |
205 | unsigned int caller_num; | 210 | guint caller_num; |
206 | 211 | ||
207 | /** | 212 | /** |
208 | * State for this call. | 213 | * State for this call. |
@@ -236,7 +241,7 @@ struct OutgoingCall | |||
236 | /** | 241 | /** |
237 | * Unique number of the caller. | 242 | * Unique number of the caller. |
238 | */ | 243 | */ |
239 | unsigned int caller_num; | 244 | guint caller_num; |
240 | 245 | ||
241 | /** | 246 | /** |
242 | * State for this call. | 247 | * State for this call. |
@@ -273,14 +278,9 @@ static struct GNUNET_MICROPHONE_Handle *mic; | |||
273 | 278 | ||
274 | 279 | ||
275 | /** | 280 | /** |
276 | * Counts the number of incoming calls we have had so far. | 281 | * Counts the number of incoming or outgoing calls we have had so far. |
277 | */ | 282 | */ |
278 | static unsigned int caller_num_gen; | 283 | static guint caller_num_gen; |
279 | |||
280 | /** | ||
281 | * Unique number of call (outgoing) | ||
282 | */ | ||
283 | static unsigned int call_counter; | ||
284 | 284 | ||
285 | /** | 285 | /** |
286 | * Number of incoming calls that are currently ringing. | 286 | * Number of incoming calls that are currently ringing. |
@@ -340,6 +340,70 @@ static GtkEntry *address_entry; | |||
340 | 340 | ||
341 | 341 | ||
342 | /** | 342 | /** |
343 | * Convert in call state to human readable string. | ||
344 | * | ||
345 | * @param is state to convert | ||
346 | * @return human readable description | ||
347 | */ | ||
348 | static const char * | ||
349 | in_call_state_to_string (enum InCallState is) | ||
350 | { | ||
351 | switch (is) | ||
352 | { | ||
353 | case IN_STATE_NONE: | ||
354 | return _("none"); | ||
355 | case IN_STATE_RINGING: | ||
356 | return _("ringing"); | ||
357 | case IN_STATE_CONNECTED: | ||
358 | return _("connected"); | ||
359 | case IN_STATE_SUSPENDED_LOCAL: | ||
360 | return _("suspended"); | ||
361 | case IN_STATE_SUSPENDED_REMOTE: | ||
362 | return _("on hold"); | ||
363 | case IN_STATE_SUSPENDED_BOTH: | ||
364 | return _("suspended and on hold"); | ||
365 | default: | ||
366 | GNUNET_break (0); | ||
367 | break; | ||
368 | } | ||
369 | return NULL; | ||
370 | } | ||
371 | |||
372 | |||
373 | /** | ||
374 | * Convert out call state to human readable string. | ||
375 | * | ||
376 | * @param os state to convert | ||
377 | * @return human readable description | ||
378 | */ | ||
379 | static const char * | ||
380 | out_call_state_to_string (enum OutCallState os) | ||
381 | { | ||
382 | switch (os) | ||
383 | { | ||
384 | case OUT_STATE_NONE: | ||
385 | return _("none"); | ||
386 | case OUT_STATE_RESOLVING: | ||
387 | return _("resolving"); | ||
388 | case OUT_STATE_RINGING: | ||
389 | return _("ringing"); | ||
390 | case OUT_STATE_CONNECTED: | ||
391 | return _("connected"); | ||
392 | case OUT_STATE_SUSPENDED_LOCAL: | ||
393 | return _("suspended"); | ||
394 | case OUT_STATE_SUSPENDED_REMOTE: | ||
395 | return _("on hold"); | ||
396 | case OUT_STATE_SUSPENDED_BOTH: | ||
397 | return _("suspended and on hold"); | ||
398 | default: | ||
399 | GNUNET_break (0); | ||
400 | break; | ||
401 | } | ||
402 | return NULL; | ||
403 | } | ||
404 | |||
405 | |||
406 | /** | ||
343 | * Free data structure associated with an incoming call. | 407 | * Free data structure associated with an incoming call. |
344 | * | 408 | * |
345 | * @param ic incoming call to free | 409 | * @param ic incoming call to free |
@@ -453,9 +517,9 @@ update_call_buttons (GtkTreeSelection *sel) | |||
453 | gtk_tree_model_get (model, | 517 | gtk_tree_model_get (model, |
454 | &iter, | 518 | &iter, |
455 | GCG_PHONE_LS_TYPE, &type, | 519 | GCG_PHONE_LS_TYPE, &type, |
456 | GCG_PHONE_LS_CALL_STATE, &out_state, | 520 | GCG_PHONE_LS_OUT_CALL_STATE, &out_state, |
457 | GCG_PHONE_LS_CALLER_STATE, &in_state, | 521 | GCG_PHONE_LS_IN_CALL_STATE, &in_state, |
458 | GCG_PHONE_LS_CALLER, &ic, | 522 | GCG_PHONE_LS_INCOMING_CALL, &ic, |
459 | -1); | 523 | -1); |
460 | switch ((enum TypeOfConversation) type) | 524 | switch ((enum TypeOfConversation) type) |
461 | { | 525 | { |
@@ -513,7 +577,7 @@ update_call_buttons (GtkTreeSelection *sel) | |||
513 | gtk_widget_set_sensitive (b_accept, ! in_call); | 577 | gtk_widget_set_sensitive (b_accept, ! in_call); |
514 | gtk_widget_set_sensitive (b_refuse, FALSE); | 578 | gtk_widget_set_sensitive (b_refuse, FALSE); |
515 | gtk_widget_set_sensitive (b_resume, ! in_call); | 579 | gtk_widget_set_sensitive (b_resume, ! in_call); |
516 | case OUT_STATE_ACTIVE: | 580 | case OUT_STATE_CONNECTED: |
517 | gtk_widget_set_sensitive (b_add_contact, TRUE); | 581 | gtk_widget_set_sensitive (b_add_contact, TRUE); |
518 | gtk_widget_set_sensitive (b_accept, FALSE); | 582 | gtk_widget_set_sensitive (b_accept, FALSE); |
519 | gtk_widget_set_sensitive (b_refuse, FALSE); | 583 | gtk_widget_set_sensitive (b_refuse, FALSE); |
@@ -586,7 +650,7 @@ set_outgoing_call_state (struct OutgoingCall *oc, | |||
586 | break; | 650 | break; |
587 | case OUT_STATE_RINGING: | 651 | case OUT_STATE_RINGING: |
588 | break; | 652 | break; |
589 | case OUT_STATE_ACTIVE: | 653 | case OUT_STATE_CONNECTED: |
590 | break; | 654 | break; |
591 | case OUT_STATE_SUSPENDED_LOCAL: | 655 | case OUT_STATE_SUSPENDED_LOCAL: |
592 | break; | 656 | break; |
@@ -597,7 +661,8 @@ set_outgoing_call_state (struct OutgoingCall *oc, | |||
597 | } | 661 | } |
598 | gtk_list_store_set (active_liststore, | 662 | gtk_list_store_set (active_liststore, |
599 | &iter, | 663 | &iter, |
600 | GCG_PHONE_LS_CALL_STATE, state, | 664 | GCG_PHONE_LS_OUT_CALL_STATE, state, |
665 | GCG_PHONE_LS_STATE_NAME, out_call_state_to_string (state), | ||
601 | -1); | 666 | -1); |
602 | update_call_buttons (gtk_tree_view_get_selection (active_treeview)); | 667 | update_call_buttons (gtk_tree_view_get_selection (active_treeview)); |
603 | } | 668 | } |
@@ -641,7 +706,8 @@ set_incoming_call_state (struct IncomingCall *ic, | |||
641 | } | 706 | } |
642 | gtk_list_store_set (active_liststore, | 707 | gtk_list_store_set (active_liststore, |
643 | &iter, | 708 | &iter, |
644 | GCG_PHONE_LS_CALLER_STATE, state, | 709 | GCG_PHONE_LS_IN_CALL_STATE, state, |
710 | GCG_PHONE_LS_STATE_NAME, in_call_state_to_string (state), | ||
645 | -1); | 711 | -1); |
646 | update_call_buttons (gtk_tree_view_get_selection (active_treeview)); | 712 | update_call_buttons (gtk_tree_view_get_selection (active_treeview)); |
647 | } | 713 | } |
@@ -672,15 +738,17 @@ phone_event_handler (void *cls, | |||
672 | in_ring_counter++; | 738 | in_ring_counter++; |
673 | ic = GNUNET_new (struct IncomingCall); | 739 | ic = GNUNET_new (struct IncomingCall); |
674 | ic->caller = caller; | 740 | ic->caller = caller; |
741 | ic->state = IN_STATE_RINGING; | ||
675 | ic->caller_id = GNUNET_strdup (caller_id); | 742 | ic->caller_id = GNUNET_strdup (caller_id); |
676 | ic->caller_num = caller_num_gen++; | 743 | ic->caller_num = caller_num_gen++; |
677 | gtk_list_store_insert_with_values (active_liststore, | 744 | gtk_list_store_insert_with_values (active_liststore, |
678 | &iter, | 745 | &iter, |
679 | -1, | 746 | -1, |
680 | GCG_PHONE_LS_CALLER_ID, caller_id, | 747 | GCG_PHONE_LS_REMOTE_USER_NAME, caller_id, |
681 | GCG_PHONE_LS_CALLER, ic, | 748 | GCG_PHONE_LS_INCOMING_CALL, ic, |
682 | GCG_PHONE_LS_CALLER_NUM, caller_num_gen, | 749 | GCG_PHONE_LS_NUMBER, ic->caller_num, |
683 | GCG_PHONE_LS_CALLER_STATE, IN_STATE_RINGING, | 750 | GCG_PHONE_LS_IN_CALL_STATE, ic->state, |
751 | GCG_PHONE_LS_STATE_NAME, in_call_state_to_string (ic->state), | ||
684 | GCG_PHONE_LS_TYPE, CALL_IN, | 752 | GCG_PHONE_LS_TYPE, CALL_IN, |
685 | -1); | 753 | -1); |
686 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (active_liststore), | 754 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (active_liststore), |
@@ -690,7 +758,7 @@ phone_event_handler (void *cls, | |||
690 | gtk_tree_path_free (path); | 758 | gtk_tree_path_free (path); |
691 | GCG_log (_("A Incoming call from `%s' with number %u\n"), | 759 | GCG_log (_("A Incoming call from `%s' with number %u\n"), |
692 | caller_id, | 760 | caller_id, |
693 | caller_num_gen); | 761 | ic->caller_num); |
694 | break; | 762 | break; |
695 | case GNUNET_CONVERSATION_EC_PHONE_HUNG_UP: | 763 | case GNUNET_CONVERSATION_EC_PHONE_HUNG_UP: |
696 | GNUNET_break (in_ring_counter > 0); | 764 | GNUNET_break (in_ring_counter > 0); |
@@ -702,7 +770,7 @@ phone_event_handler (void *cls, | |||
702 | { | 770 | { |
703 | gtk_tree_model_get (GTK_TREE_MODEL (active_liststore), | 771 | gtk_tree_model_get (GTK_TREE_MODEL (active_liststore), |
704 | &iter, | 772 | &iter, |
705 | GCG_PHONE_LS_CALLER, &ic, | 773 | GCG_PHONE_LS_INCOMING_CALL, &ic, |
706 | -1); | 774 | -1); |
707 | if (caller == ic->caller) | 775 | if (caller == ic->caller) |
708 | { | 776 | { |
@@ -843,7 +911,7 @@ GNUNET_CONVERSATION_GTK_on_accept_clicked (GtkButton *button, | |||
843 | } | 911 | } |
844 | gtk_tree_model_get (model, | 912 | gtk_tree_model_get (model, |
845 | &iter, | 913 | &iter, |
846 | GCG_PHONE_LS_CALLER, &ic, | 914 | GCG_PHONE_LS_INCOMING_CALL, &ic, |
847 | -1); | 915 | -1); |
848 | if (NULL == ic) | 916 | if (NULL == ic) |
849 | { | 917 | { |
@@ -854,7 +922,7 @@ GNUNET_CONVERSATION_GTK_on_accept_clicked (GtkButton *button, | |||
854 | active_in = ic; | 922 | active_in = ic; |
855 | set_incoming_call_state (ic, | 923 | set_incoming_call_state (ic, |
856 | IN_STATE_CONNECTED); | 924 | IN_STATE_CONNECTED); |
857 | GCG_update_status_bar (_("Started a conversation with `%s'.\n"), | 925 | GCG_update_status_bar (_("Started a conversation with `%s'."), |
858 | ic->caller_id); | 926 | ic->caller_id); |
859 | GCG_set_status_icon ("gnunet-conversation-call-active"); | 927 | GCG_set_status_icon ("gnunet-conversation-call-active"); |
860 | GNUNET_CONVERSATION_caller_pick_up (ic->caller, | 928 | GNUNET_CONVERSATION_caller_pick_up (ic->caller, |
@@ -893,8 +961,8 @@ GNUNET_CONVERSATION_GTK_on_reject_clicked (GtkButton *button, | |||
893 | } | 961 | } |
894 | gtk_tree_model_get (model, | 962 | gtk_tree_model_get (model, |
895 | &iter, | 963 | &iter, |
896 | GCG_PHONE_LS_CALLER, &ic, | 964 | GCG_PHONE_LS_INCOMING_CALL, &ic, |
897 | GCG_PHONE_LS_CALL, &oc, | 965 | GCG_PHONE_LS_OUTGOING_CALL, &oc, |
898 | -1); | 966 | -1); |
899 | if (NULL != ic) | 967 | if (NULL != ic) |
900 | { | 968 | { |
@@ -906,7 +974,7 @@ GNUNET_CONVERSATION_GTK_on_reject_clicked (GtkButton *button, | |||
906 | } | 974 | } |
907 | GNUNET_break (in_ring_counter > 0); | 975 | GNUNET_break (in_ring_counter > 0); |
908 | in_ring_counter--; | 976 | in_ring_counter--; |
909 | GCG_update_status_bar (_("Rejected conversation with `%s'.\n"), | 977 | GCG_update_status_bar (_("Rejected conversation with `%s'."), |
910 | ic->caller_id); | 978 | ic->caller_id); |
911 | GCG_HISTORY_add (GCG_HISTORY_TYPE_REJECTED, | 979 | GCG_HISTORY_add (GCG_HISTORY_TYPE_REJECTED, |
912 | ic->caller_id); | 980 | ic->caller_id); |
@@ -925,7 +993,7 @@ GNUNET_CONVERSATION_GTK_on_reject_clicked (GtkButton *button, | |||
925 | GNUNET_break (0); | 993 | GNUNET_break (0); |
926 | return; | 994 | return; |
927 | } | 995 | } |
928 | GCG_update_status_bar (_("Terminated suspended conversation with `%s'.\n"), | 996 | GCG_update_status_bar (_("Terminated suspended conversation with `%s'."), |
929 | oc->peer_name); | 997 | oc->peer_name); |
930 | GCG_HISTORY_add (GCG_HISTORY_TYPE_HANGUP, | 998 | GCG_HISTORY_add (GCG_HISTORY_TYPE_HANGUP, |
931 | oc->peer_name); | 999 | oc->peer_name); |
@@ -956,8 +1024,6 @@ GNUNET_CONVERSATION_GTK_use_current_button_clicked (GtkButton *button, | |||
956 | const gchar *target; | 1024 | const gchar *target; |
957 | 1025 | ||
958 | target = gtk_entry_get_text (address_entry); | 1026 | target = gtk_entry_get_text (address_entry); |
959 | gtk_entry_set_text (address_entry, | ||
960 | "FIXME"); | ||
961 | #endif | 1027 | #endif |
962 | } | 1028 | } |
963 | 1029 | ||
@@ -997,15 +1063,15 @@ GNUNET_CONVERSATION_GTK_on_resume_clicked (GtkButton *button, | |||
997 | } | 1063 | } |
998 | gtk_tree_model_get (model, | 1064 | gtk_tree_model_get (model, |
999 | &iter, | 1065 | &iter, |
1000 | GCG_PHONE_LS_CALLER, &ic, | 1066 | GCG_PHONE_LS_INCOMING_CALL, &ic, |
1001 | GCG_PHONE_LS_CALL, &oc, | 1067 | GCG_PHONE_LS_OUTGOING_CALL, &oc, |
1002 | -1); | 1068 | -1); |
1003 | if (NULL != ic) | 1069 | if (NULL != ic) |
1004 | { | 1070 | { |
1005 | active_in = ic; | 1071 | active_in = ic; |
1006 | set_incoming_call_state (ic, | 1072 | set_incoming_call_state (ic, |
1007 | IN_STATE_CONNECTED); | 1073 | IN_STATE_CONNECTED); |
1008 | GCG_update_status_bar (_("Resumed conversation with `%s'.\n"), | 1074 | GCG_update_status_bar (_("Resumed conversation with `%s'."), |
1009 | ic->caller_id); | 1075 | ic->caller_id); |
1010 | GCG_set_status_icon ("gnunet-conversation-call-active"); | 1076 | GCG_set_status_icon ("gnunet-conversation-call-active"); |
1011 | GNUNET_CONVERSATION_caller_resume (ic->caller, | 1077 | GNUNET_CONVERSATION_caller_resume (ic->caller, |
@@ -1020,7 +1086,7 @@ GNUNET_CONVERSATION_GTK_on_resume_clicked (GtkButton *button, | |||
1020 | GNUNET_CONVERSATION_call_resume (oc->call, | 1086 | GNUNET_CONVERSATION_call_resume (oc->call, |
1021 | speaker, mic); | 1087 | speaker, mic); |
1022 | set_outgoing_call_state (oc, | 1088 | set_outgoing_call_state (oc, |
1023 | OUT_STATE_ACTIVE); | 1089 | OUT_STATE_CONNECTED); |
1024 | // GCG_HISTORY_add (GCG_HISTORY_TYPE_RESUMED, ic->caller_id); | 1090 | // GCG_HISTORY_add (GCG_HISTORY_TYPE_RESUMED, ic->caller_id); |
1025 | do_status (); | 1091 | do_status (); |
1026 | return; | 1092 | return; |
@@ -1064,7 +1130,7 @@ GNUNET_CONVERSATION_GTK_on_pause_clicked (GtkButton *button, | |||
1064 | case OUT_STATE_RINGING: | 1130 | case OUT_STATE_RINGING: |
1065 | GNUNET_assert (0); | 1131 | GNUNET_assert (0); |
1066 | break; | 1132 | break; |
1067 | case OUT_STATE_ACTIVE: | 1133 | case OUT_STATE_CONNECTED: |
1068 | os = OUT_STATE_SUSPENDED_LOCAL; | 1134 | os = OUT_STATE_SUSPENDED_LOCAL; |
1069 | break; | 1135 | break; |
1070 | case OUT_STATE_SUSPENDED_LOCAL: | 1136 | case OUT_STATE_SUSPENDED_LOCAL: |
@@ -1229,7 +1295,7 @@ call_event_handler (void *cls, | |||
1229 | break; | 1295 | break; |
1230 | case GNUNET_CONVERSATION_EC_CALL_PICKED_UP: | 1296 | case GNUNET_CONVERSATION_EC_CALL_PICKED_UP: |
1231 | GNUNET_break (OUT_STATE_RINGING == oc->state); | 1297 | GNUNET_break (OUT_STATE_RINGING == oc->state); |
1232 | set_outgoing_call_state (oc, OUT_STATE_ACTIVE); | 1298 | set_outgoing_call_state (oc, OUT_STATE_CONNECTED); |
1233 | GNUNET_break (active_out == oc); | 1299 | GNUNET_break (active_out == oc); |
1234 | gtk_widget_set_sensitive (b_suspend, TRUE); | 1300 | gtk_widget_set_sensitive (b_suspend, TRUE); |
1235 | GCG_log (_("Connection established to `%s'."), | 1301 | GCG_log (_("Connection established to `%s'."), |
@@ -1285,7 +1351,7 @@ call_event_handler (void *cls, | |||
1285 | case OUT_STATE_RINGING: | 1351 | case OUT_STATE_RINGING: |
1286 | GNUNET_assert (0); | 1352 | GNUNET_assert (0); |
1287 | break; | 1353 | break; |
1288 | case OUT_STATE_ACTIVE: | 1354 | case OUT_STATE_CONNECTED: |
1289 | os = OUT_STATE_SUSPENDED_REMOTE; | 1355 | os = OUT_STATE_SUSPENDED_REMOTE; |
1290 | break; | 1356 | break; |
1291 | case OUT_STATE_SUSPENDED_LOCAL: | 1357 | case OUT_STATE_SUSPENDED_LOCAL: |
@@ -1319,14 +1385,14 @@ call_event_handler (void *cls, | |||
1319 | case OUT_STATE_RINGING: | 1385 | case OUT_STATE_RINGING: |
1320 | GNUNET_assert (0); | 1386 | GNUNET_assert (0); |
1321 | break; | 1387 | break; |
1322 | case OUT_STATE_ACTIVE: | 1388 | case OUT_STATE_CONNECTED: |
1323 | GNUNET_assert (0); | 1389 | GNUNET_assert (0); |
1324 | break; | 1390 | break; |
1325 | case OUT_STATE_SUSPENDED_LOCAL: | 1391 | case OUT_STATE_SUSPENDED_LOCAL: |
1326 | GNUNET_assert (0); | 1392 | GNUNET_assert (0); |
1327 | break; | 1393 | break; |
1328 | case OUT_STATE_SUSPENDED_REMOTE: | 1394 | case OUT_STATE_SUSPENDED_REMOTE: |
1329 | os = OUT_STATE_ACTIVE; | 1395 | os = OUT_STATE_CONNECTED; |
1330 | break; | 1396 | break; |
1331 | case OUT_STATE_SUSPENDED_BOTH: | 1397 | case OUT_STATE_SUSPENDED_BOTH: |
1332 | os = OUT_STATE_SUSPENDED_LOCAL; | 1398 | os = OUT_STATE_SUSPENDED_LOCAL; |
@@ -1338,7 +1404,7 @@ call_event_handler (void *cls, | |||
1338 | GCG_log (_("Connection to `%s' resumed by remote\n"), | 1404 | GCG_log (_("Connection to `%s' resumed by remote\n"), |
1339 | oc->peer_name); | 1405 | oc->peer_name); |
1340 | set_outgoing_call_state (oc, os); | 1406 | set_outgoing_call_state (oc, os); |
1341 | if (OUT_STATE_ACTIVE == os) | 1407 | if (OUT_STATE_CONNECTED == os) |
1342 | { | 1408 | { |
1343 | GCG_update_status_bar (_("Talking to `%s'."), | 1409 | GCG_update_status_bar (_("Talking to `%s'."), |
1344 | oc->peer_name); | 1410 | oc->peer_name); |
@@ -1374,50 +1440,35 @@ call_event_handler (void *cls, | |||
1374 | 1440 | ||
1375 | 1441 | ||
1376 | /** | 1442 | /** |
1377 | * Initiate a new call. | 1443 | * The "connect" button was clicked. Initiate a call! |
1378 | * | 1444 | * |
1379 | * @param arg address of the user to call | 1445 | * @param button the button |
1446 | * @param user_data builder (unused) | ||
1380 | */ | 1447 | */ |
1381 | void | 1448 | void |
1382 | GSC_PHONE_make_call (const char *arg) | 1449 | gnunet_conversation_gtk_call_button_clicked_cb (GtkButton *button, |
1450 | gpointer user_data) | ||
1451 | |||
1383 | { | 1452 | { |
1384 | struct GNUNET_IDENTITY_Ego *caller_id; | 1453 | struct GNUNET_IDENTITY_Ego *caller_id; |
1385 | GtkTreePath *path; | 1454 | GtkTreePath *path; |
1386 | GtkTreeIter iter; | 1455 | GtkTreeIter iter; |
1387 | struct OutgoingCall *oc; | 1456 | struct OutgoingCall *oc; |
1457 | const char *arg; | ||
1388 | 1458 | ||
1389 | gtk_entry_set_text (address_entry, | 1459 | arg = gtk_entry_get_text (address_entry); |
1390 | arg); | ||
1391 | caller_id = GCG_EGOS_get_selected_ego (); | 1460 | caller_id = GCG_EGOS_get_selected_ego (); |
1392 | if (NULL == caller_id) | 1461 | if ( (NULL == caller_id) || |
1393 | { | 1462 | (NULL != active_out) || |
1394 | /* can happen if user activated address in phone book | 1463 | (NULL != active_in) ) |
1395 | while our phone was still down (no ego selected) */ | ||
1396 | GCG_log (_("Caller ID unavailable, cannot initiate call to `%s'.\n"), | ||
1397 | arg); | ||
1398 | return; | ||
1399 | } | ||
1400 | if (NULL != active_out) | ||
1401 | { | ||
1402 | if (0 == strcmp (active_out->peer_name, | ||
1403 | arg)) | ||
1404 | return; /* user likely simply clicked a bit too often, ignore */ | ||
1405 | GCG_log (_("You are on the phone with `%s', suspend or hang up before trying to call `%s'!\n"), | ||
1406 | active_out->peer_name, | ||
1407 | arg); | ||
1408 | return; | ||
1409 | } | ||
1410 | if (NULL != active_in) | ||
1411 | { | 1464 | { |
1412 | GCG_log (_("You are on the phone with `%s', suspend or hang up before trying to call `%s'!\n"), | 1465 | GNUNET_break (0); |
1413 | active_in->caller_id, | ||
1414 | arg); | ||
1415 | return; | 1466 | return; |
1416 | } | 1467 | } |
1417 | call_counter++; | ||
1418 | oc = GNUNET_new (struct OutgoingCall); | 1468 | oc = GNUNET_new (struct OutgoingCall); |
1419 | oc->peer_name = GNUNET_strdup (arg); | 1469 | oc->peer_name = GNUNET_strdup (arg); |
1420 | oc->state = OUT_STATE_RESOLVING; | 1470 | oc->state = OUT_STATE_RESOLVING; |
1471 | oc->caller_num = caller_num_gen++; | ||
1421 | oc->call = | 1472 | oc->call = |
1422 | GNUNET_CONVERSATION_call_start (GCG_get_configuration (), | 1473 | GNUNET_CONVERSATION_call_start (GCG_get_configuration (), |
1423 | caller_id, | 1474 | caller_id, |
@@ -1427,14 +1478,15 @@ GSC_PHONE_make_call (const char *arg) | |||
1427 | gtk_list_store_insert_with_values (active_liststore, | 1478 | gtk_list_store_insert_with_values (active_liststore, |
1428 | &iter, | 1479 | &iter, |
1429 | -1, | 1480 | -1, |
1430 | GCG_PHONE_LS_CALLER_ID, oc->peer_name, | 1481 | GCG_PHONE_LS_REMOTE_USER_NAME, oc->peer_name, |
1431 | GCG_PHONE_LS_CALLER, NULL, | 1482 | GCG_PHONE_LS_INCOMING_CALL, NULL, |
1432 | GCG_PHONE_LS_CALLER_NUM, 0, | 1483 | GCG_PHONE_LS_NUMBER, oc->caller_num, |
1433 | GCG_PHONE_LS_CALLER_STATE, IN_STATE_NONE, | 1484 | GCG_PHONE_LS_IN_CALL_STATE, IN_STATE_NONE, |
1434 | GCG_PHONE_LS_TYPE, CALL_OUT, | 1485 | GCG_PHONE_LS_TYPE, CALL_OUT, |
1435 | GCG_PHONE_LS_CALL, oc, | 1486 | GCG_PHONE_LS_OUTGOING_CALL, oc, |
1436 | GCG_PHONE_LS_CALL_NUM, call_counter, | 1487 | GCG_PHONE_LS_OUT_CALL_STATE, oc->state, |
1437 | GCG_PHONE_LS_CALL_STATE, OUT_STATE_RESOLVING, | 1488 | GCG_PHONE_LS_STATE_NAME, out_call_state_to_string (oc->state), |
1489 | |||
1438 | -1); | 1490 | -1); |
1439 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (active_liststore), | 1491 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (active_liststore), |
1440 | &iter); | 1492 | &iter); |
@@ -1461,20 +1513,6 @@ GSC_PHONE_make_call (const char *arg) | |||
1461 | 1513 | ||
1462 | 1514 | ||
1463 | /** | 1515 | /** |
1464 | * The "connect" button was clicked. Initiate a call! | ||
1465 | * | ||
1466 | * @param button the button | ||
1467 | * @param user_data builder (unused) | ||
1468 | */ | ||
1469 | void | ||
1470 | gnunet_conversation_gtk_call_button_clicked_cb (GtkButton *button, | ||
1471 | gpointer user_data) | ||
1472 | { | ||
1473 | GSC_PHONE_make_call (gtk_entry_get_text (address_entry)); | ||
1474 | } | ||
1475 | |||
1476 | |||
1477 | /** | ||
1478 | * The user has changed the address entry. Consider activating the | 1516 | * The user has changed the address entry. Consider activating the |
1479 | * "call" button. | 1517 | * "call" button. |
1480 | * | 1518 | * |
@@ -1526,7 +1564,7 @@ gnunet_conversation_gtk_ego_combobox_changed_cb (GtkComboBox *widget, | |||
1526 | if (NULL == phone) | 1564 | if (NULL == phone) |
1527 | { | 1565 | { |
1528 | GCG_update_status_bar ("%s", | 1566 | GCG_update_status_bar ("%s", |
1529 | _("Failed to setup phone (internal error)\n")); | 1567 | _("Failed to setup phone (internal error)")); |
1530 | GCG_log ("%s", | 1568 | GCG_log ("%s", |
1531 | _("Failed to setup phone (internal error)\n")); | 1569 | _("Failed to setup phone (internal error)\n")); |
1532 | GCG_set_status_icon ("gnunet-conversation-offline"); | 1570 | GCG_set_status_icon ("gnunet-conversation-offline"); |