aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhark <hark@puscii.nl>2014-01-30 17:29:08 +0000
committerhark <hark@puscii.nl>2014-01-30 17:29:08 +0000
commit9313c4b0e9f540697fd462119267ef119848a931 (patch)
tree1365ac5f015df0ba330c380cf6bfa56f314bc79f
parent6d23b12b8d7f9a5630b4a651650bc7b813ea3bb4 (diff)
downloadgnunet-gtk-9313c4b0e9f540697fd462119267ef119848a931.tar.gz
gnunet-gtk-9313c4b0e9f540697fd462119267ef119848a931.zip
different tray icons on different phone states
-rw-r--r--contrib/gnunet_conversation_gtk_main_window.glade28
-rw-r--r--src/conversation/gnunet-conversation-gtk.c431
-rw-r--r--src/conversation/gnunet-conversation-gtk.h12
3 files changed, 265 insertions, 206 deletions
diff --git a/contrib/gnunet_conversation_gtk_main_window.glade b/contrib/gnunet_conversation_gtk_main_window.glade
index ee3484d0..2672f308 100644
--- a/contrib/gnunet_conversation_gtk_main_window.glade
+++ b/contrib/gnunet_conversation_gtk_main_window.glade
@@ -1,14 +1,6 @@
1<?xml version="1.0" encoding="UTF-8"?> 1<?xml version="1.0" encoding="UTF-8"?>
2<interface> 2<interface>
3 <!-- interface-requires gtk+ 3.0 --> 3 <!-- interface-requires gtk+ 3.0 -->
4 <object class="GtkListStore" id="gnunet_conversation_gtk_contacts_liststore">
5 <columns>
6 <!-- column-name contactName -->
7 <column type="gchararray"/>
8 <!-- column-name contactType -->
9 <column type="gchararray"/>
10 </columns>
11 </object>
12 <object class="GtkWindow" id="GNUNET_GTK_conversation_window"> 4 <object class="GtkWindow" id="GNUNET_GTK_conversation_window">
13 <property name="can_focus">False</property> 5 <property name="can_focus">False</property>
14 <property name="events">GDK_BUTTON_PRESS_MASK | GDK_STRUCTURE_MASK</property> 6 <property name="events">GDK_BUTTON_PRESS_MASK | GDK_STRUCTURE_MASK</property>
@@ -147,7 +139,17 @@
147 </packing> 139 </packing>
148 </child> 140 </child>
149 <child> 141 <child>
150 <placeholder/> 142 <object class="GtkImage" id="GNUNET_GTK_status_icon">
143 <property name="visible">True</property>
144 <property name="can_focus">False</property>
145 <property name="tooltip_text" translatable="yes">Status indicator</property>
146 <property name="icon_name">bluefish</property>
147 </object>
148 <packing>
149 <property name="expand">False</property>
150 <property name="fill">True</property>
151 <property name="position">2</property>
152 </packing>
151 </child> 153 </child>
152 <child> 154 <child>
153 <placeholder/> 155 <placeholder/>
@@ -422,6 +424,14 @@
422 </object> 424 </object>
423 </child> 425 </child>
424 </object> 426 </object>
427 <object class="GtkListStore" id="gnunet_conversation_gtk_contacts_liststore">
428 <columns>
429 <!-- column-name contactName -->
430 <column type="gchararray"/>
431 <!-- column-name contactType -->
432 <column type="gchararray"/>
433 </columns>
434 </object>
425 <object class="GtkTreeStore" id="gnunet_conversation_gtk_contacts_treestore"> 435 <object class="GtkTreeStore" id="gnunet_conversation_gtk_contacts_treestore">
426 <columns> 436 <columns>
427 <!-- column-name contactName --> 437 <!-- column-name contactName -->
diff --git a/src/conversation/gnunet-conversation-gtk.c b/src/conversation/gnunet-conversation-gtk.c
index 61abfe23..c20a77e4 100644
--- a/src/conversation/gnunet-conversation-gtk.c
+++ b/src/conversation/gnunet-conversation-gtk.c
@@ -78,9 +78,9 @@ log_message (const char *message)
78 GtkTextIter iter; 78 GtkTextIter iter;
79 gchar *fmsg; 79 gchar *fmsg;
80 80
81 log_view = GTK_TEXT_VIEW(get_object ("GNUNET_GTK_conversation_log")); 81 log_view = GTK_TEXT_VIEW (get_object ("GNUNET_GTK_conversation_log"));
82 82
83 logbuff = GTK_TEXT_BUFFER(gtk_text_view_get_buffer (log_view)); 83 logbuff = GTK_TEXT_BUFFER (gtk_text_view_get_buffer (log_view));
84 84
85 fmsg = g_strdup_printf (" %s \n", message); 85 fmsg = g_strdup_printf (" %s \n", message);
86 86
@@ -117,7 +117,7 @@ update_status (const gchar * message)
117 117
118 gchar *buff; 118 gchar *buff;
119 119
120 status_bar = GTK_STATUSBAR(get_object ("GNUNET_GTK_conversation_statusbar")); 120 status_bar = GTK_STATUSBAR (get_object ("GNUNET_GTK_conversation_statusbar"));
121 status_bar_context = gtk_statusbar_get_context_id (status_bar, "blaat"); 121 status_bar_context = gtk_statusbar_get_context_id (status_bar, "blaat");
122 122
123 123
@@ -146,24 +146,24 @@ history_add (int type, char *contactName)
146 146
147 switch (type) 147 switch (type)
148 { 148 {
149 case CH_ACCEPTED: 149 case CH_ACCEPTED:
150 event = "Accepted"; 150 event = "Accepted";
151 break; 151 break;
152 case CH_REJECTED: 152 case CH_REJECTED:
153 event = "Rejected"; 153 event = "Rejected";
154 break; 154 break;
155 case CH_OUTGOING: 155 case CH_OUTGOING:
156 event = "Outgoing"; 156 event = "Outgoing";
157 break; 157 break;
158 case CH_HANGUP: 158 case CH_HANGUP:
159 event = "Hangup"; 159 event = "Hangup";
160 break; 160 break;
161 case CH_MISSED: 161 case CH_MISSED:
162 event = "Missed"; 162 event = "Missed";
163 break; 163 break;
164 default: 164 default:
165 event = "UNKNOWN"; 165 event = "UNKNOWN";
166 break; 166 break;
167 } 167 }
168 time (&t); 168 time (&t);
169 gtk_list_store_append (history_liststore, &iter); 169 gtk_list_store_append (history_liststore, &iter);
@@ -183,7 +183,7 @@ set_button_text (const char *button_name, const char *label)
183 //GtkButton *button; 183 //GtkButton *button;
184 GtkWidget *button; 184 GtkWidget *button;
185 185
186 button = GTK_WIDGET(get_object (button_name)); 186 button = GTK_WIDGET (get_object (button_name));
187 gtk_widget_hide (button); 187 gtk_widget_hide (button);
188} 188}
189 189
@@ -211,7 +211,7 @@ disable_button (const char *button_name)
211 //GtkButton *button; 211 //GtkButton *button;
212 GtkWidget *button; 212 GtkWidget *button;
213 213
214 button = GTK_WIDGET(get_object (button_name)); 214 button = GTK_WIDGET (get_object (button_name));
215 gtk_widget_hide (button); 215 gtk_widget_hide (button);
216} 216}
217 217
@@ -225,7 +225,7 @@ enable_button (const char *button_name)
225 //GtkButton *button; 225 //GtkButton *button;
226 GtkWidget *button; 226 GtkWidget *button;
227 227
228 button = GTK_WIDGET(get_object (button_name)); 228 button = GTK_WIDGET (get_object (button_name));
229 gtk_widget_show (button); 229 gtk_widget_show (button);
230} 230}
231 231
@@ -322,7 +322,7 @@ phone_event_handler (void *cls, enum GNUNET_CONVERSATION_PhoneEventCode code,
322 phone_state = PS_LISTEN; 322 phone_state = PS_LISTEN;
323 } 323 }
324 GNUNET_free (cl); 324 GNUNET_free (cl);
325 gtk_widget_destroy (GTK_WIDGET(dialog)); 325 gtk_widget_destroy (GTK_WIDGET (dialog));
326 break; 326 break;
327 327
328 } 328 }
@@ -484,8 +484,8 @@ do_call (const char *arg)
484 GNUNET_CONVERSATION_call_start (cfg, caller_id, arg, speaker, mic, 484 GNUNET_CONVERSATION_call_start (cfg, caller_id, arg, speaker, mic,
485 &call_event_handler, NULL); 485 &call_event_handler, NULL);
486 UPDATE_STATUS (_("We are calling `%s', his phone should be ringing."), 486 UPDATE_STATUS (_("We are calling `%s', his phone should be ringing."),
487 peer_name); 487 peer_name);
488 history_add(2,peer_name); 488 history_add (CH_ACCEPTED, peer_name);
489} 489}
490 490
491 491
@@ -513,7 +513,7 @@ do_accept (const char *args)
513 break; 513 break;
514 case PS_LISTEN: 514 case PS_LISTEN:
515 /* this is the expected state */ 515 /* this is the expected state */
516 break; 516 break;
517 case PS_ACCEPTED: 517 case PS_ACCEPTED:
518 LOG (_ 518 LOG (_
519 ("You are answering call from `%s', hang up or suspend that call first!\n"), 519 ("You are answering call from `%s', hang up or suspend that call first!\n"),
@@ -543,14 +543,14 @@ do_accept (const char *args)
543 LOG (_("There is no incoming call `%s' to accept right now!\n"), args); 543 LOG (_("There is no incoming call `%s' to accept right now!\n"), args);
544 return; 544 return;
545 } 545 }
546 cl_active = cl; 546 cl_active = cl;
547 GNUNET_free_non_null (peer_name); 547 GNUNET_free_non_null (peer_name);
548 peer_name = GNUNET_strdup (cl->caller_id); 548 peer_name = GNUNET_strdup (cl->caller_id);
549 phone_state = PS_ACCEPTED; 549 phone_state = PS_ACCEPTED;
550 GNUNET_CONVERSATION_caller_pick_up (cl->caller, &caller_event_handler, cl, 550 GNUNET_CONVERSATION_caller_pick_up (cl->caller, &caller_event_handler, cl,
551 speaker, mic); 551 speaker, mic);
552 552
553 history_add (0, peer_name); 553 history_add (CH_ACCEPTED, peer_name);
554 554
555} 555}
556 556
@@ -576,19 +576,25 @@ do_status (const char *args)
576 UPDATE_STATUS (_ 576 UPDATE_STATUS (_
577 ("We are currently trying to locate the private key for the ego `%s'."), 577 ("We are currently trying to locate the private key for the ego `%s'."),
578 ego_name); 578 ego_name);
579 579 set_status_icon ("gnunet-conversation-tray-pending");
580 break; 580 break;
581 case PS_LISTEN: 581 case PS_LISTEN:
582 UPDATE_STATUS (_ 582 UPDATE_STATUS (_
583 ("We are listening for incoming calls for ego `%s' on line %u."), 583 ("We are listening for incoming calls for ego `%s' on line %u."),
584 ego_name, line); 584 ego_name, line);
585 set_status_icon ("gnunet-conversation-tray-available");
586
585 break; 587 break;
586 case PS_ACCEPTED: 588 case PS_ACCEPTED:
587 UPDATE_STATUS (_("You are having a conversation with `%s'.\n"), peer_name); 589 UPDATE_STATUS (_("You are having a conversation with `%s'.\n"), peer_name);
590 set_status_icon ("gnunet-conversation-call-active");
591
588 break; 592 break;
589 case PS_ERROR: 593 case PS_ERROR:
590 UPDATE_STATUS (_ 594 UPDATE_STATUS (_
591 ("We had an internal error setting up our phone line. You can still make calls.")); 595 ("We had an internal error setting up our phone line. You can still make calls."));
596 set_status_icon ("gnunet-conversation-offline");
597
592 break; 598 break;
593 } 599 }
594 if (NULL != call) 600 if (NULL != call)
@@ -599,22 +605,30 @@ do_status (const char *args)
599 UPDATE_STATUS (_ 605 UPDATE_STATUS (_
600 ("We are trying to find the network address to call `%s'."), 606 ("We are trying to find the network address to call `%s'."),
601 peer_name); 607 peer_name);
608 set_status_icon ("gnunet-conversation-tray-call-pending");
609
602 break; 610 break;
603 case CS_RINGING: 611 case CS_RINGING:
604 UPDATE_STATUS (_("We are calling `%s', his phone should be ringing."), 612 UPDATE_STATUS (_("We are calling `%s', his phone should be ringing."),
605 peer_name); 613 peer_name);
614 set_status_icon ("gnunet-conversation-tray-call-ringing");
615
606 break; 616 break;
607 case CS_CONNECTED: 617 case CS_CONNECTED:
608 UPDATE_STATUS (_("You are having a conversation with `%s'."), 618 UPDATE_STATUS (_("You are having a conversation with `%s'."), peer_name);
609 peer_name); 619 set_status_icon ("gnunet-conversation-tray-call-active");
620
610 break; 621 break;
611 case CS_SUSPENDED: 622 case CS_SUSPENDED:
623 set_status_icon ("gnunet-conversation-tray-call-suspended");
624
612 /* ok to accept incoming call right now */ 625 /* ok to accept incoming call right now */
613 break; 626 break;
614 } 627 }
615 } 628 }
616 if ((NULL != cl_head) && ((cl_head != cl_active) || (cl_head != cl_tail))) 629 if ((NULL != cl_head) && ((cl_head != cl_active) || (cl_head != cl_tail)))
617 { 630 {
631 set_status_icon ("gnunet-conversation-tray-call-incoming");
618 632
619 for (cl = cl_head; NULL != cl; cl = cl->next) 633 for (cl = cl_head; NULL != cl; cl = cl->next)
620 { 634 {
@@ -789,14 +803,15 @@ do_reject (const char *args)
789 break; 803 break;
790 case PS_ACCEPTED: 804 case PS_ACCEPTED:
791 /* expected state, do rejection logic */ 805 /* expected state, do rejection logic */
806 history_add (CH_REJECTED, peer_name);
792 GNUNET_assert (NULL != cl_active); 807 GNUNET_assert (NULL != cl_active);
793 GNUNET_CONVERSATION_caller_hang_up (cl_active->caller); 808 GNUNET_CONVERSATION_caller_hang_up (cl_active->caller);
794 GNUNET_free (cl_active); 809 GNUNET_free (cl_active);
810
795// cl_active = NULL; 811// cl_active = NULL;
796 phone_state = PS_LISTEN; 812 phone_state = PS_LISTEN;
797 break; 813 break;
798 } 814 }
799 history_add (1, peer_name);
800 815
801} 816}
802 817
@@ -902,7 +917,7 @@ static void
902add_continuation (void *cls, int32_t success, const char *emsg) 917add_continuation (void *cls, int32_t success, const char *emsg)
903{ 918{
904 919
905 struct GNUNET_NAMESTORE_QueueEntry **qe = cls; 920 struct GNUNET_NAMESTORE_QueueEntry **qe = cls;
906 921
907 *qe = NULL; 922 *qe = NULL;
908 if (GNUNET_YES != success) 923 if (GNUNET_YES != success)
@@ -927,26 +942,20 @@ add_continuation (void *cls, int32_t success, const char *emsg)
927 * @param emsg NULL on success, otherwise an error message 942 * @param emsg NULL on success, otherwise an error message
928 */ 943 */
929static void 944static void
930del_continuation (void *cls, 945del_continuation (void *cls, int32_t success, const char *emsg)
931 int32_t success,
932 const char *emsg)
933{ 946{
934 del_qe = NULL; 947 del_qe = NULL;
935 if (GNUNET_NO == success) 948 if (GNUNET_NO == success)
936 { 949 {
937 fprintf (stderr, 950 fprintf (stderr, _("Deleting record failed, record does not exist%s%s\n"),
938 _("Deleting record failed, record does not exist%s%s\n"), 951 (NULL != emsg) ? ": " : "", (NULL != emsg) ? emsg : "");
939 (NULL != emsg) ? ": " : "",
940 (NULL != emsg) ? emsg : "");
941 } 952 }
942 if (GNUNET_SYSERR == success) 953 if (GNUNET_SYSERR == success)
943 { 954 {
944 fprintf (stderr, 955 fprintf (stderr, _("Deleting record failed%s%s\n"),
945 _("Deleting record failed%s%s\n"), 956 (NULL != emsg) ? ": " : "", (NULL != emsg) ? emsg : "");
946 (NULL != emsg) ? ": " : "",
947 (NULL != emsg) ? emsg : "");
948 } 957 }
949 // test_finished (); 958 // test_finished ();
950} 959}
951 960
952 961
@@ -1024,7 +1033,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1024{ 1033{
1025 1034
1026//TODO: make this work 1035//TODO: make this work
1027 //struct OperationContext *oc; 1036 //struct OperationContext *oc;
1028 1037
1029/* 1038/*
1030 GIG_advertise_shutdown_ (); 1039 GIG_advertise_shutdown_ ();
@@ -1123,7 +1132,8 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1123 /* setup main window */ 1132 /* setup main window */
1124 main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window")); 1133 main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window"));
1125 main_window = 1134 main_window =
1126 GTK_WIDGET(GNUNET_GTK_plug_me ("GNUNET_CONVERSATION_GTK_PLUG", GTK_WIDGET(main_window))); 1135 GTK_WIDGET (GNUNET_GTK_plug_me
1136 ("GNUNET_CONVERSATION_GTK_PLUG", GTK_WIDGET (main_window)));
1127 gtk_window_set_default_size (main_window, 300, 700); 1137 gtk_window_set_default_size (main_window, 300, 700);
1128 contacts_liststore = 1138 contacts_liststore =
1129 GTK_LIST_STORE (get_object 1139 GTK_LIST_STORE (get_object
@@ -1151,13 +1161,14 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1151 1161
1152 if (NULL == getenv ("GNUNET_CONVERSATION_GTK_PLUG")) 1162 if (NULL == getenv ("GNUNET_CONVERSATION_GTK_PLUG"))
1153 GNUNET_GTK_tray_icon_create (ml, GTK_WINDOW (main_window), 1163 GNUNET_GTK_tray_icon_create (ml, GTK_WINDOW (main_window),
1154 "gnunet-gtk" /* FIXME: different icon? */ , 1164 "gnunet-conversation-gtk"
1165 /* FIXME: different icon? */ ,
1155 "gnunet-conversation-gtk"); 1166 "gnunet-conversation-gtk");
1156 1167
1157 /* make GUI visible */ 1168 /* make GUI visible */
1158 if (!tray_only) 1169 if (!tray_only)
1159 { 1170 {
1160 gtk_widget_show (GTK_WIDGET(main_window)); 1171 gtk_widget_show (GTK_WIDGET (main_window));
1161 gtk_window_present (GTK_WINDOW (main_window)); 1172 gtk_window_present (GTK_WINDOW (main_window));
1162 } 1173 }
1163 1174
@@ -1172,8 +1183,8 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1172 cfg = GIG_get_configuration (); 1183 cfg = GIG_get_configuration ();
1173//cfg = GNUNET_CONFIGURATION_dup (c); 1184//cfg = GNUNET_CONFIGURATION_dup (c);
1174 1185
1175 speaker = GNUNET_SPEAKER_create_from_hardware (GIG_get_configuration()); 1186 speaker = GNUNET_SPEAKER_create_from_hardware (GIG_get_configuration ());
1176 mic = GNUNET_MICROPHONE_create_from_hardware (GIG_get_configuration()); 1187 mic = GNUNET_MICROPHONE_create_from_hardware (GIG_get_configuration ());
1177 1188
1178 if (NULL == ego_name) 1189 if (NULL == ego_name)
1179 { 1190 {
@@ -1236,51 +1247,49 @@ main (int argc, char *const *argv)
1236void 1247void
1237quick_message (gchar * message, const char *caller_id) 1248quick_message (gchar * message, const char *caller_id)
1238{ 1249{
1239 GtkWidget *caller_name, *notification, *content_area; 1250 GtkWidget *caller_name, *notification, *content_area;
1240 GtkWidget *dialog; 1251 GtkWidget *dialog;
1241 GtkWindow *main_window; 1252 GtkWindow *main_window;
1242 main_window = GTK_WINDOW(get_object("GNUNET_GTK_conversation_window")); 1253
1243 // Create the widgets 1254 main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window"));
1244 1255 // Create the widgets
1245 1256
1246 dialog = gtk_dialog_new_with_buttons ("Incoming call!", 1257
1247 main_window, 1258 dialog =
1248 GTK_DIALOG_DESTROY_WITH_PARENT, 1259 gtk_dialog_new_with_buttons ("Incoming call!", main_window,
1249 _("Accept call"), 1260 GTK_DIALOG_DESTROY_WITH_PARENT,
1250 GTK_RESPONSE_ACCEPT, 1261 _("Accept call"), GTK_RESPONSE_ACCEPT,
1251 _("Reject call"), 1262 _("Reject call"), GTK_RESPONSE_REJECT,
1252 GTK_RESPONSE_REJECT, 1263 _("Decide later"), GTK_RESPONSE_CANCEL,
1253 _("Decide later"), 1264 NULL);
1254 GTK_RESPONSE_CANCEL, 1265 content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
1255 1266
1256 NULL); 1267
1257 content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); 1268 notification = gtk_label_new ("Incoming call from:");
1258 1269 caller_name = gtk_label_new (caller_id);
1259 1270
1260 notification = gtk_label_new ("Incoming call from:"); 1271 // Add the labels, and show everything we've added to the dialog
1261 caller_name = gtk_label_new (caller_id); 1272 gtk_container_add (GTK_CONTAINER (content_area), notification);
1262 1273 gtk_container_add (GTK_CONTAINER (content_area), caller_name);
1263 // Add the labels, and show everything we've added to the dialog 1274 gtk_widget_show_all (GTK_WIDGET (dialog));
1264 gtk_container_add (GTK_CONTAINER (content_area), notification); 1275
1265 gtk_container_add (GTK_CONTAINER (content_area), caller_name); 1276 switch (gtk_dialog_run (GTK_DIALOG (dialog)))
1266 gtk_widget_show_all (GTK_WIDGET(dialog)); 1277 {
1267 1278 case GTK_RESPONSE_ACCEPT:
1268 switch(gtk_dialog_run(GTK_DIALOG(dialog))){ 1279 do_status ("");
1269 case GTK_RESPONSE_ACCEPT : 1280 gtk_widget_destroy (GTK_WIDGET (dialog));
1270 do_status(""); 1281 do_accept ("0");
1271 gtk_widget_destroy(GTK_WIDGET(dialog)); 1282 break;
1272 do_accept("0"); 1283 case GTK_RESPONSE_REJECT:
1273 break; 1284 do_reject ("0");
1274 case GTK_RESPONSE_REJECT : 1285 do_status ("");
1275 do_reject("0"); 1286 gtk_widget_destroy (GTK_WIDGET (dialog));
1276 do_status(""); 1287 break;
1277 gtk_widget_destroy(GTK_WIDGET(dialog)); 1288 case GTK_RESPONSE_CANCEL:
1278 break; 1289 do_status ("");
1279 case GTK_RESPONSE_CANCEL : 1290 gtk_widget_destroy (GTK_WIDGET (dialog));
1280 do_status(""); 1291 break;
1281 gtk_widget_destroy(GTK_WIDGET(dialog)); 1292 }
1282 break;
1283 }
1284 1293
1285 1294
1286} 1295}
@@ -1336,7 +1345,7 @@ GNUNET_CONVERSATION_GTK_on_accept_clicked ()
1336{ 1345{
1337 FPRINTF (stderr, "accept clicked \n"); 1346 FPRINTF (stderr, "accept clicked \n");
1338 do_accept (0); 1347 do_accept (0);
1339 // hide_infobar (); 1348 // hide_infobar ();
1340} 1349}
1341 1350
1342 1351
@@ -1357,7 +1366,7 @@ void
1357GNUNET_CONVERSATION_GTK_on_pause_clicked () 1366GNUNET_CONVERSATION_GTK_on_pause_clicked ()
1358{ 1367{
1359// GtkEntry *entry; 1368// GtkEntry *entry;
1360do_suspend("0"); 1369 do_suspend ("0");
1361 //FPRINTF (stderr, "pause clicked \n"); 1370 //FPRINTF (stderr, "pause clicked \n");
1362 //do_pause(""); 1371 //do_pause("");
1363 // entry = GTK_ENTRY((get_object ("GNUNET_GTK_conversation_address"))); 1372 // entry = GTK_ENTRY((get_object ("GNUNET_GTK_conversation_address")));
@@ -1395,7 +1404,8 @@ GNUNET_CONVERSATION_GTK_on_status_clicked ()
1395 * @param name 1404 * @param name
1396 * @param address 1405 * @param address
1397 */ 1406 */
1398void add_contact(const gchar *name, const gchar *address) 1407void
1408add_contact (const gchar * name, const gchar * address)
1399{ 1409{
1400// memmove(&address+1,&address+51,1); 1410// memmove(&address+1,&address+51,1);
1401 GtkTreeIter iter; 1411 GtkTreeIter iter;
@@ -1405,8 +1415,11 @@ void add_contact(const gchar *name, const gchar *address)
1405 static size_t data_size; 1415 static size_t data_size;
1406 struct GNUNET_CRYPTO_EcdsaPublicKey pkey; 1416 struct GNUNET_CRYPTO_EcdsaPublicKey pkey;
1407 1417
1418 FPRINTF (stderr, 'address: %s', address);
1419 FPRINTF (stderr, 'address-len: %i', strlen (address));
1420
1408 GNUNET_CRYPTO_ecdsa_public_key_from_string (address, strlen (address), &pkey); 1421 GNUNET_CRYPTO_ecdsa_public_key_from_string (address, strlen (address), &pkey);
1409 rde=&rd; 1422 rde = &rd;
1410 zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (caller_id); 1423 zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (caller_id);
1411 rd.data = &pkey; 1424 rd.data = &pkey;
1412 rd.data_size = sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey); 1425 rd.data_size = sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey);
@@ -1418,26 +1431,18 @@ void add_contact(const gchar *name, const gchar *address)
1418 FPRINTF (stderr, "name: %s\n", name); 1431 FPRINTF (stderr, "name: %s\n", name);
1419 FPRINTF (stderr, "address: %s\n", address); 1432 FPRINTF (stderr, "address: %s\n", address);
1420 if (GNUNET_OK != 1433 if (GNUNET_OK !=
1421 GNUNET_GNSRECORD_string_to_value (65536, 1434 GNUNET_GNSRECORD_string_to_value (65536, address, &data, &data_size))
1422 address, 1435 {
1423 &data, 1436 FPRINTF (stderr, "invalid address\n");
1424 &data_size)) 1437 }
1425 {
1426 FPRINTF (stderr, "invalid address\n");
1427 }
1428 else 1438 else
1429 { 1439 {
1430 add_qe = 1440 add_qe =
1431 GNUNET_NAMESTORE_records_store (ns, 1441 GNUNET_NAMESTORE_records_store (ns, &zone_pkey, name, 1, rde,
1432 &zone_pkey, 1442 &add_continuation, &add_qe);
1433 name, 1443 gtk_list_store_append (contacts_liststore, &iter);
1434 1, 1444 gtk_list_store_set (contacts_liststore, &iter, 1, "PKEY", 0, name, -1);
1435 rde, 1445 }
1436 &add_continuation,
1437 &add_qe);
1438 gtk_list_store_append (contacts_liststore, &iter);
1439 gtk_list_store_set (contacts_liststore, &iter, 1, "PKEY", 0, name, -1);
1440 }
1441} 1446}
1442 1447
1443/* 1448/*
@@ -1455,47 +1460,51 @@ GNUNET_CONVERSATION_GTK_on_add_clicked (GtkButton * button,
1455 //unused: *anotherArea, *labelName, *labelAddres *caller_name 1460 //unused: *anotherArea, *labelName, *labelAddres *caller_name
1456 1461
1457 GtkLabel *notification; 1462 GtkLabel *notification;
1463
1458// GtkHBox *content_area; 1464// GtkHBox *content_area;
1459 GtkContainer *content_area; 1465 GtkContainer *content_area;
1460 GtkButton *currentCheckButton; 1466 GtkButton *currentCheckButton;
1461 GtkEntry *nameEntry, *addressEntry; 1467 GtkEntry *nameEntry, *addressEntry;
1462 GtkDialog *dialog; 1468 GtkDialog *dialog;
1463 GtkWindow *main_window; 1469 GtkWindow *main_window;
1464 1470
1465 currentCheckButton = 1471 currentCheckButton =
1466 GTK_BUTTON(gtk_button_new_with_label ("use currently incoming addres")); 1472 GTK_BUTTON (gtk_button_new_with_label ("use currently incoming addres"));
1467 1473
1468 nameEntry = GTK_ENTRY(gtk_entry_new ()); 1474 nameEntry = gtk_entry_new ();
1469 gtk_entry_set_text (nameEntry, "Name of contact"); 1475 gtk_entry_set_text (nameEntry, "Name");
1470 addressEntry = GTK_ENTRY(gtk_entry_new ()); 1476 addressEntry = gtk_entry_new ();
1471 gtk_entry_set_text (addressEntry, "Address of contact"); 1477 gtk_entry_set_text (addressEntry, "Address");
1472 1478
1473 main_window = GTK_WINDOW(get_object ("GNUNET_GTK_conversation_window")); 1479 main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window"));
1474 1480
1475 dialog = 1481 dialog =
1476 GTK_DIALOG(gtk_dialog_new_with_buttons ("Adding contact", main_window, 1482 GTK_DIALOG (gtk_dialog_new_with_buttons
1477 GTK_DIALOG_DESTROY_WITH_PARENT, 1483 ("Adding contact", main_window,
1478 _("Add contact"), GTK_RESPONSE_ACCEPT, 1484 GTK_DIALOG_DESTROY_WITH_PARENT, _("Add contact"),
1479 _("Cancel"), GTK_RESPONSE_CANCEL, NULL)); 1485 GTK_RESPONSE_ACCEPT, _("Cancel"), GTK_RESPONSE_CANCEL,
1480 gtk_dialog_add_action_widget (dialog, GTK_WIDGET(currentCheckButton), GTK_RESPONSE_OK); 1486 NULL));
1487 gtk_dialog_add_action_widget (dialog, GTK_WIDGET (currentCheckButton),
1488 GTK_RESPONSE_OK);
1481// FPRINTF (stderr, "response id : %u", response_id); 1489// FPRINTF (stderr, "response id : %u", response_id);
1482// g_signal_connect (GTK_BUTTON (currentCheckButton), "clicked", 1490// g_signal_connect (GTK_BUTTON (currentCheckButton), "clicked",
1483// G_CALLBACK (use_current_incoming_address), NULL); 1491// G_CALLBACK (use_current_incoming_address), NULL);
1484 1492
1485 1493
1486 gtk_dialog_add_action_widget (dialog, GTK_WIDGET(nameEntry), 2); 1494 gtk_dialog_add_action_widget (dialog, GTK_WIDGET (nameEntry), 2);
1487 gtk_dialog_add_action_widget (dialog, GTK_WIDGET(addressEntry), 3); 1495 gtk_dialog_add_action_widget (dialog, GTK_WIDGET (addressEntry), 3);
1488 1496
1489 content_area = GTK_CONTAINER(gtk_dialog_get_content_area (GTK_DIALOG (dialog))); 1497 content_area =
1498 GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog)));
1490 1499
1491 1500
1492 notification = GTK_LABEL(gtk_label_new ("Adding contact")); 1501 notification = GTK_LABEL (gtk_label_new ("Adding contact"));
1493// caller_name = gtk_label_new (caller_id); 1502// caller_name = gtk_label_new (caller_id);
1494 1503
1495 // Add the labels, and show everything we've added to the dialog 1504 // Add the labels, and show everything we've added to the dialog
1496 gtk_container_add (GTK_CONTAINER (content_area), GTK_WIDGET(notification)); 1505 gtk_container_add (GTK_CONTAINER (content_area), GTK_WIDGET (notification));
1497// gtk_container_add (GTK_CONTAINER (content_area), caller_name); 1506// gtk_container_add (GTK_CONTAINER (content_area), caller_name);
1498 gtk_widget_show_all (GTK_WIDGET(dialog)); 1507 gtk_widget_show_all (GTK_WIDGET (dialog));
1499 1508
1500 switch (gtk_dialog_run (dialog)) 1509 switch (gtk_dialog_run (dialog))
1501 { 1510 {
@@ -1503,20 +1512,22 @@ GNUNET_CONVERSATION_GTK_on_add_clicked (GtkButton * button,
1503 do_status (""); 1512 do_status ("");
1504 add_contact (gtk_entry_get_text (nameEntry), 1513 add_contact (gtk_entry_get_text (nameEntry),
1505 gtk_entry_get_text (addressEntry)); 1514 gtk_entry_get_text (addressEntry));
1506 gtk_widget_destroy (GTK_WIDGET(dialog)); 1515 gtk_widget_destroy (GTK_WIDGET (dialog));
1507 break; 1516 break;
1508 case GTK_RESPONSE_CANCEL: 1517 case GTK_RESPONSE_CANCEL:
1509 FPRINTF (stderr, "cancel clicked"); 1518 FPRINTF (stderr, "cancel clicked");
1510 do_status (""); 1519 do_status ("");
1511 gtk_widget_destroy (GTK_WIDGET(dialog)); 1520 FPRINTF (stderr, 'use_current: callername: %s', callerName);
1521
1522
1523 gtk_widget_destroy (GTK_WIDGET (dialog));
1512 break; 1524 break;
1513 case GTK_RESPONSE_OK: 1525 case GTK_RESPONSE_OK:
1514 //use_current_incoming_address(); 1526 //use_current_incoming_address();
1515 gtk_entry_set_text (GTK_ENTRY(addressEntry), callerName); 1527 gtk_entry_set_text (GTK_ENTRY (addressEntry), callerName);
1516 add_contact (gtk_entry_get_text (nameEntry), 1528 add_contact (gtk_entry_get_text (nameEntry), callerName);
1517 callerName);
1518// add_contact(gtk_entry_get_text(nameEntry),memmove(&callerName,&callerName+52,1)); 1529// add_contact(gtk_entry_get_text(nameEntry),memmove(&callerName,&callerName+52,1));
1519 gtk_widget_destroy (GTK_WIDGET(dialog)); 1530 gtk_widget_destroy (GTK_WIDGET (dialog));
1520 1531
1521// memmove(&address+1,&address+51,1); 1532// memmove(&address+1,&address+51,1);
1522 break; 1533 break;
@@ -1527,51 +1538,51 @@ GNUNET_CONVERSATION_GTK_on_add_clicked (GtkButton * button,
1527 1538
1528void 1539void
1529GNUNET_CONVERSATION_GTK_on_remove_clicked (GtkButton * button, 1540GNUNET_CONVERSATION_GTK_on_remove_clicked (GtkButton * button,
1530 gpointer * user_data) 1541 gpointer * user_data)
1531{ 1542{
1532 GtkTreeSelection *selection; 1543 GtkTreeSelection *selection;
1533 GtkTreeModel *model; 1544 GtkTreeModel *model;
1534 GtkTreeIter iter; 1545 GtkTreeIter iter;
1535 GtkDialog *confirm; 1546 GtkDialog *confirm;
1536 GtkWindow *main_window; 1547 GtkWindow *main_window;
1537 GtkLabel *notification; 1548 GtkLabel *notification;
1538 GtkHBox *content_area; 1549 GtkHBox *content_area;
1539 1550
1540 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(contacts_treeview)); 1551 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (contacts_treeview));
1541 if (gtk_tree_selection_get_selected(selection, &model, &iter)) 1552 if (gtk_tree_selection_get_selected (selection, &model, &iter))
1542 { 1553 {
1543 gtk_tree_model_get (model, &iter, 0, &name, -1); 1554 gtk_tree_model_get (model, &iter, 0, &name, -1);
1544 FPRINTF(stderr, "selected %s \n", name); 1555 FPRINTF (stderr, "selected %s \n", name);
1545 main_window = GTK_WINDOW(get_object ("GNUNET_GTK_conversation_window")); 1556 main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window"));
1546 confirm = 1557 confirm =
1547 GTK_DIALOG(gtk_dialog_new_with_buttons ("Removing contact", main_window, 1558 GTK_DIALOG (gtk_dialog_new_with_buttons
1548 GTK_DIALOG_DESTROY_WITH_PARENT, 1559 ("Removing contact", main_window,
1549 _("Yes"), GTK_RESPONSE_ACCEPT, 1560 GTK_DIALOG_DESTROY_WITH_PARENT, _("Yes"),
1550 _("No"), GTK_RESPONSE_CANCEL, NULL)); 1561 GTK_RESPONSE_ACCEPT, _("No"), GTK_RESPONSE_CANCEL, NULL));
1551 content_area = GTK_CONTAINER(gtk_dialog_get_content_area (GTK_DIALOG (confirm))); 1562 content_area =
1552 notification = GTK_LABEL(gtk_label_new ("Do you really want to remove this contact?")); 1563 GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (confirm)));
1553 gtk_container_add (GTK_CONTAINER (content_area), GTK_WIDGET(notification)); 1564 notification =
1554 gtk_widget_show_all (GTK_WIDGET(confirm)); 1565 GTK_LABEL (gtk_label_new
1555 switch (gtk_dialog_run(confirm)) 1566 ("Do you really want to remove this contact?"));
1556 { 1567 gtk_container_add (GTK_CONTAINER (content_area), GTK_WIDGET (notification));
1557 case GTK_RESPONSE_ACCEPT: 1568 gtk_widget_show_all (GTK_WIDGET (confirm));
1558 zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (caller_id); 1569 switch (gtk_dialog_run (confirm))
1559 del_qe = GNUNET_NAMESTORE_records_store (ns, 1570 {
1560 &zone_pkey, 1571 case GTK_RESPONSE_ACCEPT:
1561 name, 1572 zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (caller_id);
1562 0, NULL, 1573 del_qe =
1563 &del_continuation, 1574 GNUNET_NAMESTORE_records_store (ns, &zone_pkey, name, 0, NULL,
1564 NULL); 1575 &del_continuation, NULL);
1565 gtk_list_store_remove(contacts_liststore, &iter); 1576 gtk_list_store_remove (contacts_liststore, &iter);
1566 gtk_widget_destroy (GTK_WIDGET(confirm)); 1577 gtk_widget_destroy (GTK_WIDGET (confirm));
1567 break; 1578 break;
1568 case GTK_RESPONSE_CANCEL: 1579 case GTK_RESPONSE_CANCEL:
1569 FPRINTF(stderr, "not removing \n"); 1580 FPRINTF (stderr, "not removing \n");
1570 gtk_widget_destroy (GTK_WIDGET(confirm)); 1581 gtk_widget_destroy (GTK_WIDGET (confirm));
1571 break; 1582 break;
1572 } 1583 }
1573 1584
1574 } 1585 }
1575} 1586}
1576 1587
1577 1588
@@ -1621,12 +1632,48 @@ GNUNET_CONVERSATION_GTK_row_activated ()
1621 do_call (callAddress); 1632 do_call (callAddress);
1622} 1633}
1623 1634
1635/*
1636 * set_status_icon
1637 *
1638 * available icons:
1639 * gnunet-conversation-tray-pending
1640 * gnunet-conversation-tray-available
1641 * gnunet-conversation-tray-offline
1642 * gnunet-conversation-tray-call-pending
1643 * gnunet-conversation-tray-call-ringing
1644 * gnunet-conversation-tray-call-active
1645 * gnunet-conversation-tray-call-suspended
1646 * gnunet-conversation-tray-call-incoming
1647 *
1648 */
1649
1650void
1651set_status_icon (const char *icon_name)
1652{
1653 GtkWindow *main_window;
1654 GtkImage *status_icon;
1655
1656
1657
1658 main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window"));
1659
1660 status_icon = GTK_IMAGE (get_object ("GNUNET_GTK_status_icon"));
1661
1662 gtk_image_set_from_icon_name (status_icon, icon_name, GTK_ICON_SIZE_BUTTON);
1663
1664 GNUNET_GTK_tray_icon_change (ml, GTK_WINDOW (main_window), icon_name,
1665 "gnunet-conversation-gtk-status");
1666}
1667
1668
1624/* end of gnunet-conversation-gtk.c */ 1669/* end of gnunet-conversation-gtk.c */
1625void GNUNET_contact_test() 1670void
1671GNUNET_contact_test ()
1626{ 1672{
1627 history_add(0,"test"); 1673
1628 history_add(1,"test"); 1674 history_add (0, "test");
1629 history_add(2,"test"); 1675 history_add (1, "test");
1630 history_add(3,"test"); 1676 history_add (2, "test");
1631 history_add(4,"test"); 1677 history_add (3, "test");
1678 history_add (4, "test");
1632} 1679}
diff --git a/src/conversation/gnunet-conversation-gtk.h b/src/conversation/gnunet-conversation-gtk.h
index ea3306c1..e4907361 100644
--- a/src/conversation/gnunet-conversation-gtk.h
+++ b/src/conversation/gnunet-conversation-gtk.h
@@ -124,11 +124,11 @@ enum CallState
124 124
125enum CallHistoryType 125enum CallHistoryType
126{ 126{
127 CH_ACCEPTED, 127 CH_ACCEPTED,
128 CH_REJECTED, 128 CH_REJECTED,
129 CH_OUTGOING, 129 CH_OUTGOING,
130 CH_HANGUP, 130 CH_HANGUP,
131 CH_MISSED 131 CH_MISSED
132}; 132};
133 133
134 134
@@ -197,6 +197,7 @@ static struct CallList *cl_tail;
197 * Desired phone line. 197 * Desired phone line.
198 */ 198 */
199static unsigned int line; 199static unsigned int line;
200
200//static unsigned int line1; 201//static unsigned int line1;
201 202
202/** 203/**
@@ -213,6 +214,7 @@ static struct GNUNET_MICROPHONE_Handle *mic;
213 * Our configurations. 214 * Our configurations.
214 */ 215 */
215static struct GNUNET_CONFIGURATION_Handle *cfg; 216static struct GNUNET_CONFIGURATION_Handle *cfg;
217
216//static struct GNUNET_CONFIGURATION_Handle *cfg1; 218//static struct GNUNET_CONFIGURATION_Handle *cfg1;
217//static struct GNUNET_CONFIGURATION_Handle *cfg2; 219//static struct GNUNET_CONFIGURATION_Handle *cfg2;
218 220