aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhark <hark@puscii.nl>2014-02-11 18:31:06 +0000
committerhark <hark@puscii.nl>2014-02-11 18:31:06 +0000
commit9fd08ef369df785098379f30b67f44191469312c (patch)
treebdb13cc11b2c8070326d7f92a3fbf75be47d5213
parentfd4b0dfcdbd65cf69b5ce3d57eaf24ff05ed10f8 (diff)
downloadgnunet-gtk-9fd08ef369df785098379f30b67f44191469312c.tar.gz
gnunet-gtk-9fd08ef369df785098379f30b67f44191469312c.zip
handle multiple incoming calls
-rw-r--r--contrib/gnunet_conversation_gtk_main_window.glade150
-rw-r--r--src/conversation/gnunet-conversation-gtk.c595
-rw-r--r--src/conversation/gnunet-conversation-gtk.h71
3 files changed, 580 insertions, 236 deletions
diff --git a/contrib/gnunet_conversation_gtk_main_window.glade b/contrib/gnunet_conversation_gtk_main_window.glade
index d36b755b..f60f391e 100644
--- a/contrib/gnunet_conversation_gtk_main_window.glade
+++ b/contrib/gnunet_conversation_gtk_main_window.glade
@@ -1,6 +1,7 @@
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="GtkAction" id="action1"/>
4 <object class="GtkWindow" id="GNUNET_GTK_conversation_window"> 5 <object class="GtkWindow" id="GNUNET_GTK_conversation_window">
5 <property name="can_focus">False</property> 6 <property name="can_focus">False</property>
6 <property name="events">GDK_BUTTON_PRESS_MASK | GDK_STRUCTURE_MASK</property> 7 <property name="events">GDK_BUTTON_PRESS_MASK | GDK_STRUCTURE_MASK</property>
@@ -139,7 +140,20 @@
139 </packing> 140 </packing>
140 </child> 141 </child>
141 <child> 142 <child>
142 <placeholder/> 143 <object class="GtkButton" id="GNUNET_GTK_conversation_test_button_two">
144 <property name="label" translatable="yes">test 2</property>
145 <property name="use_action_appearance">False</property>
146 <property name="visible">True</property>
147 <property name="can_focus">True</property>
148 <property name="receives_default">True</property>
149 <property name="use_action_appearance">False</property>
150 <signal name="clicked" handler="GNUNET_CONVERSATION_GTK_test_button_two" swapped="no"/>
151 </object>
152 <packing>
153 <property name="expand">False</property>
154 <property name="fill">True</property>
155 <property name="position">2</property>
156 </packing>
143 </child> 157 </child>
144 <child> 158 <child>
145 <placeholder/> 159 <placeholder/>
@@ -280,7 +294,9 @@
280 <property name="enable_search">False</property> 294 <property name="enable_search">False</property>
281 <property name="search_column">0</property> 295 <property name="search_column">0</property>
282 <child internal-child="selection"> 296 <child internal-child="selection">
283 <object class="GtkTreeSelection" id="treeview-selection2"/> 297 <object class="GtkTreeSelection" id="GNUNET_CONVERSATION_GTK_active_calls_selection">
298 <signal name="changed" handler="GNUNET_CONVERSATION_GTK_on_active_calls_selection_changed" swapped="no"/>
299 </object>
284 </child> 300 </child>
285 <child> 301 <child>
286 <object class="GtkTreeViewColumn" id="caller_numColumn"> 302 <object class="GtkTreeViewColumn" id="caller_numColumn">
@@ -300,10 +316,34 @@
300 </object> 316 </object>
301 </child> 317 </child>
302 <child> 318 <child>
319 <object class="GtkTreeViewColumn" id="GNUNET_CONVERSATION_GTK_caller_typeColumn">
320 <property name="title" translatable="yes">type</property>
321 <child>
322 <object class="GtkCellRendererText" id="GNUNET_CONVERSATION_GTK_active_calls_type"/>
323 <attributes>
324 <attribute name="markup">3</attribute>
325 <attribute name="text">3</attribute>
326 </attributes>
327 </child>
328 </object>
329 </child>
330 <child>
331 <object class="GtkTreeViewColumn" id="caller_stateColumn">
332 <property name="title" translatable="yes">state</property>
333 <child>
334 <object class="GtkCellRendererText" id="GNUNET_CONVERSATION_GTK_active_calls_state"/>
335 <attributes>
336 <attribute name="markup">4</attribute>
337 <attribute name="text">4</attribute>
338 </attributes>
339 </child>
340 </object>
341 </child>
342 <child>
303 <object class="GtkTreeViewColumn" id="caller_idColumn"> 343 <object class="GtkTreeViewColumn" id="caller_idColumn">
304 <property name="title" translatable="yes">Caller ID</property> 344 <property name="title" translatable="yes">Caller ID</property>
305 <child> 345 <child>
306 <object class="GtkCellRendererText" id="GNUNET_CONVERSATION_GTK_event_window_renderer1"/> 346 <object class="GtkCellRendererText" id="GNUNET_CONVERSATION_GTK_active_calls_id"/>
307 <attributes> 347 <attributes>
308 <attribute name="text">0</attribute> 348 <attribute name="text">0</attribute>
309 </attributes> 349 </attributes>
@@ -346,15 +386,14 @@
346 </packing> 386 </packing>
347 </child> 387 </child>
348 <child> 388 <child>
349 <object class="GtkButton" id="GNUNET_GTK_conversation_call_button"> 389 <object class="GtkButton" id="GNUNET_GTK_conversation_use_current_button">
350 <property name="label" translatable="yes">call</property> 390 <property name="label" translatable="yes">&gt;contact</property>
351 <property name="use_action_appearance">False</property> 391 <property name="use_action_appearance">False</property>
352 <property name="visible">True</property> 392 <property name="visible">True</property>
353 <property name="can_focus">True</property> 393 <property name="can_focus">True</property>
354 <property name="receives_default">True</property> 394 <property name="receives_default">True</property>
355 <property name="use_action_appearance">False</property> 395 <property name="use_action_appearance">False</property>
356 <property name="use_underline">True</property> 396 <signal name="clicked" handler="GNUNET_CONVERSATION_GTK_on_current_clicked" swapped="no"/>
357 <signal name="clicked" handler="GNUNET_CONVERSATION_GTK_on_call_clicked" swapped="no"/>
358 </object> 397 </object>
359 <packing> 398 <packing>
360 <property name="expand">False</property> 399 <property name="expand">False</property>
@@ -363,6 +402,22 @@
363 </packing> 402 </packing>
364 </child> 403 </child>
365 <child> 404 <child>
405 <object class="GtkButton" id="GNUNET_GTK_conversation_accept_button">
406 <property name="label" translatable="yes">accept</property>
407 <property name="use_action_appearance">False</property>
408 <property name="visible">True</property>
409 <property name="can_focus">True</property>
410 <property name="receives_default">True</property>
411 <property name="use_action_appearance">False</property>
412 <signal name="clicked" handler="GNUNET_CONVERSATION_GTK_on_accept_clicked" swapped="no"/>
413 </object>
414 <packing>
415 <property name="expand">False</property>
416 <property name="fill">True</property>
417 <property name="position">2</property>
418 </packing>
419 </child>
420 <child>
366 <object class="GtkButton" id="GNUNET_GTK_conversation_hangup_button"> 421 <object class="GtkButton" id="GNUNET_GTK_conversation_hangup_button">
367 <property name="label" translatable="yes">hangup</property> 422 <property name="label" translatable="yes">hangup</property>
368 <property name="use_action_appearance">False</property> 423 <property name="use_action_appearance">False</property>
@@ -375,12 +430,12 @@
375 <packing> 430 <packing>
376 <property name="expand">False</property> 431 <property name="expand">False</property>
377 <property name="fill">True</property> 432 <property name="fill">True</property>
378 <property name="position">2</property> 433 <property name="position">3</property>
379 </packing> 434 </packing>
380 </child> 435 </child>
381 <child> 436 <child>
382 <object class="GtkButton" id="GNUNET_GTK_conversation_pause_button"> 437 <object class="GtkButton" id="GNUNET_GTK_conversation_pause_button">
383 <property name="label" translatable="yes">pause call</property> 438 <property name="label" translatable="yes">pause</property>
384 <property name="use_action_appearance">False</property> 439 <property name="use_action_appearance">False</property>
385 <property name="visible">True</property> 440 <property name="visible">True</property>
386 <property name="can_focus">True</property> 441 <property name="can_focus">True</property>
@@ -395,10 +450,20 @@
395 </packing> 450 </packing>
396 </child> 451 </child>
397 <child> 452 <child>
398 <placeholder/> 453 <object class="GtkButton" id="GNUNET_GTK_conversation_resume_button">
399 </child> 454 <property name="label" translatable="yes">resume</property>
400 <child> 455 <property name="use_action_appearance">False</property>
401 <placeholder/> 456 <property name="visible">True</property>
457 <property name="can_focus">True</property>
458 <property name="receives_default">True</property>
459 <property name="use_action_appearance">False</property>
460 <signal name="clicked" handler="GNUNET_CONVERSATION_GTK_on_resume_clicked" swapped="no"/>
461 </object>
462 <packing>
463 <property name="expand">False</property>
464 <property name="fill">True</property>
465 <property name="position">5</property>
466 </packing>
402 </child> 467 </child>
403 </object> 468 </object>
404 <packing> 469 <packing>
@@ -418,20 +483,7 @@
418 </packing> 483 </packing>
419 </child> 484 </child>
420 <child> 485 <child>
421 <object class="GtkButton" id="GNUNET_GTK_conversation_use_current_button"> 486 <placeholder/>
422 <property name="label" translatable="yes">Add address of currently selected call</property>
423 <property name="use_action_appearance">False</property>
424 <property name="visible">True</property>
425 <property name="can_focus">True</property>
426 <property name="receives_default">True</property>
427 <property name="use_action_appearance">False</property>
428 <signal name="clicked" handler="GNUNET_CONVERSATION_GTK_on_current_clicked" swapped="no"/>
429 </object>
430 <packing>
431 <property name="expand">False</property>
432 <property name="fill">True</property>
433 <property name="position">3</property>
434 </packing>
435 </child> 487 </child>
436 </object> 488 </object>
437 <packing> 489 <packing>
@@ -604,7 +656,22 @@
604 </packing> 656 </packing>
605 </child> 657 </child>
606 <child> 658 <child>
607 <placeholder/> 659 <object class="GtkButton" id="GNUNET_GTK_conversation_call_button">
660 <property name="label" translatable="yes">call</property>
661 <property name="use_action_appearance">False</property>
662 <property name="visible">True</property>
663 <property name="can_focus">True</property>
664 <property name="receives_default">True</property>
665 <property name="use_action_appearance">False</property>
666 <property name="use_underline">True</property>
667 <signal name="clicked" handler="GNUNET_CONVERSATION_GTK_on_call_clicked" swapped="no"/>
668 </object>
669 <packing>
670 <property name="left_attach">0</property>
671 <property name="top_attach">0</property>
672 <property name="width">1</property>
673 <property name="height">1</property>
674 </packing>
608 </child> 675 </child>
609 </object> 676 </object>
610 <packing> 677 <packing>
@@ -780,6 +847,10 @@
780 <column type="gpointer"/> 847 <column type="gpointer"/>
781 <!-- column-name caller_num --> 848 <!-- column-name caller_num -->
782 <column type="gint"/> 849 <column type="gint"/>
850 <!-- column-name caller_type -->
851 <column type="gint"/>
852 <!-- column-name caller_state -->
853 <column type="gint"/>
783 </columns> 854 </columns>
784 </object> 855 </object>
785 <object class="GtkListStore" id="gnunet_conversation_gtk_contacts_liststore"> 856 <object class="GtkListStore" id="gnunet_conversation_gtk_contacts_liststore">
@@ -790,12 +861,6 @@
790 <column type="gchararray"/> 861 <column type="gchararray"/>
791 </columns> 862 </columns>
792 </object> 863 </object>
793 <object class="GtkTreeStore" id="gnunet_conversation_gtk_contacts_treestore">
794 <columns>
795 <!-- column-name contactName -->
796 <column type="gchararray"/>
797 </columns>
798 </object>
799 <object class="GtkListStore" id="gnunet_conversation_gtk_contacts_zone_liststore"> 864 <object class="GtkListStore" id="gnunet_conversation_gtk_contacts_zone_liststore">
800 <columns> 865 <columns>
801 <!-- column-name ego_name --> 866 <!-- column-name ego_name -->
@@ -803,17 +868,6 @@
803 <!-- column-name ego --> 868 <!-- column-name ego -->
804 <column type="gpointer"/> 869 <column type="gpointer"/>
805 </columns> 870 </columns>
806 <data>
807 <row>
808 <col id="0" translatable="yes">not working yet</col>
809 </row>
810 </data>
811 </object>
812 <object class="GtkTreeStore" id="gnunet_conversation_gtk_contacts_zone_treestore">
813 <columns>
814 <!-- column-name zone -->
815 <column type="gchararray"/>
816 </columns>
817 </object> 871 </object>
818 <object class="GtkListStore" id="gnunet_conversation_gtk_history_liststore"> 872 <object class="GtkListStore" id="gnunet_conversation_gtk_history_liststore">
819 <columns> 873 <columns>
@@ -825,7 +879,6 @@
825 <column type="gchararray"/> 879 <column type="gchararray"/>
826 </columns> 880 </columns>
827 </object> 881 </object>
828 <object class="GtkTreeStore" id="gnunet_conversation_gtk_history_treestore"/>
829 <object class="GtkListStore" id="gnunet_conversation_gtk_outgoing_zone_liststore"> 882 <object class="GtkListStore" id="gnunet_conversation_gtk_outgoing_zone_liststore">
830 <columns> 883 <columns>
831 <!-- column-name ego_name --> 884 <!-- column-name ego_name -->
@@ -833,10 +886,5 @@
833 <!-- column-name ego --> 886 <!-- column-name ego -->
834 <column type="gpointer"/> 887 <column type="gpointer"/>
835 </columns> 888 </columns>
836 <data>
837 <row>
838 <col id="0" translatable="yes">Outgoing identity, doesn't work yet.</col>
839 </row>
840 </data>
841 </object> 889 </object>
842</interface> 890</interface>
diff --git a/src/conversation/gnunet-conversation-gtk.c b/src/conversation/gnunet-conversation-gtk.c
index 9a2dd5a7..fd3318ee 100644
--- a/src/conversation/gnunet-conversation-gtk.c
+++ b/src/conversation/gnunet-conversation-gtk.c
@@ -49,6 +49,9 @@
49 49
50#define LOG(format, ...) log_message(g_strdup_printf (format, ## __VA_ARGS__)) 50#define LOG(format, ...) log_message(g_strdup_printf (format, ## __VA_ARGS__))
51 51
52struct GNUNET_CONVERSATION_Caller *caller_selected = NULL;
53//caller_selected = NULL;
54
52/** 55/**
53 * Get an object from the main window. 56 * Get an object from the main window.
54 * 57 *
@@ -129,6 +132,42 @@ update_status (const gchar * message)
129 132
130 133
131} 134}
135/*
136 * set_status_icon
137 *
138 * available icons:
139 * gnunet-conversation-gtk-tray-pending
140 * gnunet-conversation-gtk-tray-available
141 * gnunet-conversation-gtk-tray-offline
142 * gnunet-conversation-gtk-tray-call-pending
143 * gnunet-conversation-gtk-tray-call-ringing
144 * gnunet-conversation-gtk-tray-call-active
145 * gnunet-conversation-gtk-tray-call-suspended
146 * gnunet-conversation-gtk-tray-call-incoming
147 *
148 */
149
150void
151set_status_icon (const char *icon_name)
152{
153 GtkWindow *main_window;
154 GtkImage *status_icon;
155
156
157
158 main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window"));
159
160 status_icon = GTK_IMAGE (get_object ("GNUNET_GTK_status_icon"));
161
162 gtk_image_set_from_icon_name (status_icon, icon_name, GTK_ICON_SIZE_BUTTON);
163
164 //LOG (_("Tray icon changed to: `%s' "), icon_name);
165
166
167
168 GNUNET_GTK_tray_icon_change (icon_name, "gnunet-conversation-gtk-status");
169}
170
132 171
133/* 172/*
134 * adds a item to the call history 173 * adds a item to the call history
@@ -188,20 +227,6 @@ set_button_text (const char *button_name, const char *label)
188} 227}
189 228
190/* 229/*
191 * set infobar text
192 */
193//
194//void
195//set_infobar_text (const gchar * text)
196//{
197// GtkLabel *infolabel;
198//
199// infolabel = GTK_LABEL(get_object ("GNUNET_GTK_new_call_label"));
200// log_message ("setting infobar text");
201// gtk_label_set_text (infolabel, text);
202//}
203//
204/*
205 * disable button 230 * disable button
206 */ 231 */
207 232
@@ -229,35 +254,84 @@ enable_button (const char *button_name)
229 gtk_widget_show (button); 254 gtk_widget_show (button);
230} 255}
231 256
232/* 257/**
233 * show infobar 258 * set call state of a incoming call
234 */
235//
236//void
237//show_infobar ()
238//{
239// GtkWidget *infobar;
240//
241// infobar = GTK_WIDGET(get_object ("GNUNET_GTK_conversation_infobar"));
242//
243// gtk_widget_show (infobar);
244//}
245//
246/*
247 * hide infobar
248 */ 259 */
249// 260static void
250//void 261set_incoming_call_state(struct GNUNET_CONVERSATION_Caller *caller, int state)
251//hide_infobar () 262{
252//{ 263 // struct CallList *cl = cls;
253// //GtkInfoBar *infobar; 264// struct GNUNET_CONVERSATION_Caller caller;
254// GtkWidget *infobar; 265 gint row_count = 0;
255// 266 GtkTreeIter gtkiter;
256// infobar = GTK_WIDGET(get_object ("GNUNET_GTK_conversation_infobar")); 267 gint valid = 0;
257// 268 //FPRINTF (stderr,"set incoming call state:%u caller: ",state);
258// gtk_widget_hide (infobar); 269
259//} 270 LOG (_("set incoming call state:%u caller: "),state);
260// 271
272 valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), &gtkiter );
273
274 if (!valid)
275 GNUNET_break(0);
276
277 while (valid)
278 {
279 gchar *cl_caller_id;
280 gint cl_caller_num;
281 gpointer cl_caller;
282// gint new_state;
283 //FPRINTF (stderr,"loop:: valid:%u \n",valid);
284
285 gtk_tree_model_get ( GTK_TREE_MODEL( active_liststore ), &gtkiter,
286 AL_caller, &cl_caller,
287 AL_caller_id,&cl_caller_id,
288 AL_caller_num,&cl_caller_num
289 ,-1);
290 /*
291 enum {
292 CT_active,
293 CT_suspended,
294 CT_ringing,
295 CT_dead,
296 CT_hangup,
297 CT_rejected
298};
299*/
300 if (caller == cl_caller)
301 {
302 //LOG (_("setting state for call:%u row: %u state: %u"),cl_caller_num,row_count,state);
303
304 switch (state)
305 {
306 case CT_hangup:
307 LOG("remove line cause hangup");
308 gtk_list_store_remove(active_liststore,&gtkiter);
309 break;
310
311 case CT_rejected:
312 LOG("remove line cause rejected");
313 gtk_list_store_remove(active_liststore,&gtkiter);
314 break;
315
316 default:
317
318 gtk_list_store_set(active_liststore, &gtkiter,
319 AL_caller_state, state,
320 -1);
321 break;
322
323 }//end switch
324 }//endif
325
326 g_free (cl_caller_id);
327 row_count++;
328 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), &gtkiter);
329
330 }//end while
331
332
333
334}
261 335
262 336
263 337
@@ -275,55 +349,125 @@ phone_event_handler (void *cls, enum GNUNET_CONVERSATION_PhoneEventCode code,
275 struct GNUNET_CONVERSATION_Caller *caller, 349 struct GNUNET_CONVERSATION_Caller *caller,
276 const char *caller_id) 350 const char *caller_id)
277{ 351{
278 struct CallList *cl; 352
353 //gtk
354 GtkTreeIter gtkiter;
355 GtkTreeIter gtkiter1;
356 gboolean valid;
357
279 358
280 switch (code) 359 switch (code)
281 { 360 {
282 case GNUNET_CONVERSATION_EC_PHONE_RING: 361 case GNUNET_CONVERSATION_EC_PHONE_RING:
362 //increment call #
363 caller_num_gen++;
364
283 365
284 LOG (_("A Incoming call from `%s' on line %u\n"), caller_id, 366 LOG (_("A Incoming call from `%s' with number %u\n"), caller_id,
285 caller_num_gen); 367 caller_num_gen);
286 368
287 369 //old
288 //UPDATE_INFOBAR (_("Incoming call from `%s' on line %u\n"), caller_id, 370 struct CallList *cl;
289 // caller_num_gen);
290
291 //show_infobar ();
292 // TODO: make sound
293 371
294 cl = GNUNET_new (struct CallList); 372 cl = GNUNET_new (struct CallList);
295
296 cl->caller = caller; 373 cl->caller = caller;
297 cl->caller_id = GNUNET_strdup (caller_id); 374 cl->caller_id = GNUNET_strdup (caller_id);
298 cl->caller_num = caller_num_gen++; 375 cl->caller_num = caller_num_gen;
299 GNUNET_CONTAINER_DLL_insert (cl_head, cl_tail, cl); 376 GNUNET_CONTAINER_DLL_insert (cl_head, cl_tail, cl);
300 callerName = caller_id; 377 //gtk
301 //strncpy (&callerName, &caller_id, 50); 378 gtk_list_store_append (active_liststore, &gtkiter);
302 //callerName[52] = '\0'; 379
303 quick_message ("der is een beller", caller_id); 380 gtk_list_store_set (active_liststore, &gtkiter,
381 AL_caller_id, caller_id,
382 AL_caller, caller,
383 AL_caller_num, caller_num_gen,
384 AL_caller_state, CT_ringing,
385 AL_caller_type, CALL_IN
386 ,-1);
387
388
389 //What is this callername thing?
390// strncpy (&callerName, &caller_id, 50);
391// callerName[52] = '\0';
392
393 //TODO:new call notification, should be passed a reference to the call
394 //TODO: rename: quick_message to call_notification(caller);
395// quick_message ("der is een beller", caller_id);
396 // TODO: make sound
304 397
305 break; 398 break;
306 399
307 case GNUNET_CONVERSATION_EC_PHONE_HUNG_UP: 400 case GNUNET_CONVERSATION_EC_PHONE_HUNG_UP:
401 //FPRINTF(stderr,"GNUNET_CONVERSATION_EC_PHONE_HUNG_UP:");
402 //gtk
403
404 valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), &gtkiter1 );
405
406 if (!valid)
407 GNUNET_break(0);
408
409 while (valid)
410 {
411 /* Walk through the list, reading each row */
412 //FPRINTF(stderr,"GNUNET_CONVERSATION_EC_PHONE_HUNG_UP: while valid");
413
414 gchar *str_data;
415 gint int_data;
416 gpointer cl_caller;
417
418 gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), &gtkiter1,
419 AL_caller, &cl_caller,
420 AL_caller_id,&str_data,
421 AL_caller_num,&int_data,-1);
422 if (caller == cl_caller)
423 {
424
425 LOG (_("phone hung up:%s number: %u "), str_data,int_data);
426 set_incoming_call_state(caller,CT_rejected);
427 break ;
428 }
429 g_free (str_data);
430 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), &gtkiter1);
431 }
432
433
434
435 //gcl_active = NULL;
436 phone_state = PS_LISTEN;
437 //add to call history list
438 //history_add(CH_HANGUP, cl->caller_id);
439
440
441 ///END gtk
442
443 //old
444 /*
308 for (cl = cl_head; NULL != cl; cl = cl->next) 445 for (cl = cl_head; NULL != cl; cl = cl->next)
309 if (caller == cl->caller) 446 if (caller == cl->caller)
310 break; 447 break;
448
311 if (NULL == cl) 449 if (NULL == cl)
312 { 450 {
313 GNUNET_break (0); 451 GNUNET_break (0);
314 return; 452 return;
315 } 453 }
454
316 LOG (_("Call from `%s' terminated\n"), cl->caller_id); 455 LOG (_("Call from `%s' terminated\n"), cl->caller_id);
317 history_add(3, cl->caller_id); 456
457
318 GNUNET_CONTAINER_DLL_remove (cl_head, cl_tail, cl); 458 GNUNET_CONTAINER_DLL_remove (cl_head, cl_tail, cl);
319 GNUNET_free (cl->caller_id); 459 GNUNET_free (cl->caller_id);
460
461 //
320 if (cl == cl_active) 462 if (cl == cl_active)
321 { 463 {
322 cl_active = NULL; 464 cl_active = NULL;
323 phone_state = PS_LISTEN; 465 phone_state = PS_LISTEN;
324 } 466 }
325 GNUNET_free (cl); 467 GNUNET_free (cl);
326 gtk_widget_destroy (GTK_WIDGET (dialog)); 468 */
469 //destroy call accept dialog
470 //gtk_widget_destroy (GTK_WIDGET (dialog));
327 break; 471 break;
328 472
329 } 473 }
@@ -345,10 +489,12 @@ caller_event_handler (void *cls, enum GNUNET_CONVERSATION_CallerEventCode code)
345 { 489 {
346 case GNUNET_CONVERSATION_EC_CALLER_SUSPEND: 490 case GNUNET_CONVERSATION_EC_CALLER_SUSPEND:
347 update_state (); 491 update_state ();
492 set_incoming_call_state(cls,CT_suspended);
348 LOG (_("Call from `%s' suspended by other user\n"), cl->caller_id); 493 LOG (_("Call from `%s' suspended by other user\n"), cl->caller_id);
349 break; 494 break;
350 case GNUNET_CONVERSATION_EC_CALLER_RESUME: 495 case GNUNET_CONVERSATION_EC_CALLER_RESUME:
351 update_state (); 496 update_state ();
497 set_incoming_call_state(cls,CT_active);
352 LOG (_("Call from `%s' resumed by other user\n"), cl->caller_id); 498 LOG (_("Call from `%s' resumed by other user\n"), cl->caller_id);
353 break; 499 break;
354 } 500 }
@@ -476,7 +622,7 @@ do_call (const char *arg)
476 /* ok to call */ 622 /* ok to call */
477 break; 623 break;
478 } 624 }
479 GNUNET_free_non_null (peer_name); 625 //GNUNET_free_non_null (peer_name);
480 peer_name = GNUNET_strdup (arg); 626 peer_name = GNUNET_strdup (arg);
481 LOG (_("now calling: %s"), peer_name); 627 LOG (_("now calling: %s"), peer_name);
482 call_state = CS_RESOLVING; 628 call_state = CS_RESOLVING;
@@ -496,7 +642,7 @@ do_call (const char *arg)
496 * @param args arguments given to the command 642 * @param args arguments given to the command
497 */ 643 */
498static void 644static void
499do_accept (const char *args) 645do_accept (struct GNUNET_CONVERSATION_Caller *sel_caller)
500{ 646{
501 struct CallList *cl; 647 struct CallList *cl;
502 char buf[32]; 648 char buf[32];
@@ -523,39 +669,44 @@ do_accept (const char *args)
523 case PS_ERROR: 669 case PS_ERROR:
524 GNUNET_break (0); 670 GNUNET_break (0);
525 break; 671 break;
526 } 672 }//endswitch
673
674/*
527 cl = cl_head; 675 cl = cl_head;
528 if (NULL == cl) 676 if (NULL == cl)
529 { 677 {
530 LOG (_("There is no incoming call to accept here!\n")); 678 LOG (_("There is no incoming call to accept here!\n"));
531 return; 679 return;
532 } 680 }
533 if ((NULL != cl->next) || (NULL != args)) 681 if (NULL != cl->next)
534 { 682 {
535 for (cl = cl_head; NULL != cl; cl = cl->next) 683 for (cl = cl_head; NULL != cl; cl = cl->next)
536 { 684 {
537 GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num); 685 GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num);
538 if (0 == strcmp (buf, args))
539 break;
540 } 686 }
541 } 687 }
542 if (NULL == cl) 688 if (NULL == cl)
543 { 689 {
544 LOG (_("There is no incoming call `%s' to accept right now!\n"), args); 690 LOG (_("There is no incoming call to accept right now!(NULL == cl) \n"));
545 return; 691 return;
546 } 692 }
547 693
548 GNUNET_CONTAINER_DLL_remove (cl_head, 694 GNUNET_CONTAINER_DLL_remove (cl_head,
549 cl_tail, 695 cl_tail,
550 cl); 696 cl);
551 cl_active = cl; 697 cl_active = cl;
552 GNUNET_free_non_null (peer_name); 698 GNUNET_free_non_null (peer_name);
553 peer_name = GNUNET_strdup (cl->caller_id); 699 peer_name = GNUNET_strdup (cl->caller_id);
700 */
701
554 phone_state = PS_ACCEPTED; 702 phone_state = PS_ACCEPTED;
555 GNUNET_CONVERSATION_caller_pick_up (cl->caller, &caller_event_handler, cl, 703 set_incoming_call_state(sel_caller,CT_active);
704
705
706 GNUNET_CONVERSATION_caller_pick_up (sel_caller, &caller_event_handler, cl,
556 speaker, mic); 707 speaker, mic);
557 708
558 history_add (CH_ACCEPTED, peer_name); 709 history_add (CH_ACCEPTED, peer_name);
559 710
560} 711}
561 712
@@ -571,7 +722,7 @@ do_accept (const char *args)
571 * @param args arguments given to the command 722 * @param args arguments given to the command
572 */ 723 */
573static void 724static void
574do_status (const char *args) 725do_status ()
575{ 726{
576 struct CallList *cl; 727 struct CallList *cl;
577 728
@@ -581,13 +732,13 @@ do_status (const char *args)
581 UPDATE_STATUS (_ 732 UPDATE_STATUS (_
582 ("We are currently trying to locate the private key for the ego `%s'."), 733 ("We are currently trying to locate the private key for the ego `%s'."),
583 ego_name); 734 ego_name);
584 set_status_icon ("gnunet-conversation-tray-pending"); 735 set_status_icon ("gnunet-conversation-gtk-tray-pending");
585 break; 736 break;
586 case PS_LISTEN: 737 case PS_LISTEN:
587 UPDATE_STATUS (_ 738 UPDATE_STATUS (_
588 ("We are listening for incoming calls for ego `%s' on line %u."), 739 ("We are listening for incoming calls for ego `%s' on line %u."),
589 ego_name, line); 740 ego_name, line);
590 set_status_icon ("gnunet-conversation-tray-available"); 741 set_status_icon ("gnunet-conversation-gtk-tray-available");
591 742
592 break; 743 break;
593 case PS_ACCEPTED: 744 case PS_ACCEPTED:
@@ -610,22 +761,22 @@ do_status (const char *args)
610 UPDATE_STATUS (_ 761 UPDATE_STATUS (_
611 ("We are trying to find the network address to call `%s'."), 762 ("We are trying to find the network address to call `%s'."),
612 peer_name); 763 peer_name);
613 set_status_icon ("gnunet-conversation-tray-call-pending"); 764 set_status_icon ("gnunet-conversation-gtk-tray-call-pending");
614 765
615 break; 766 break;
616 case CS_RINGING: 767 case CS_RINGING:
617 UPDATE_STATUS (_("We are calling `%s', his phone should be ringing."), 768 UPDATE_STATUS (_("We are calling `%s', his phone should be ringing."),
618 peer_name); 769 peer_name);
619 set_status_icon ("gnunet-conversation-tray-call-ringing"); 770 set_status_icon ("gnunet-conversation-gtk-tray-call-ringing");
620 771
621 break; 772 break;
622 case CS_CONNECTED: 773 case CS_CONNECTED:
623 UPDATE_STATUS (_("You are having a conversation with `%s'."), peer_name); 774 UPDATE_STATUS (_("You are having a conversation with `%s'."), peer_name);
624 set_status_icon ("gnunet-conversation-tray-call-active"); 775 set_status_icon ("gnunet-conversation-gtk-tray-call-active");
625 776
626 break; 777 break;
627 case CS_SUSPENDED: 778 case CS_SUSPENDED:
628 set_status_icon ("gnunet-conversation-tray-call-suspended"); 779 set_status_icon ("gnunet-conversation-gtk-tray-call-suspended");
629 780
630 /* ok to accept incoming call right now */ 781 /* ok to accept incoming call right now */
631 break; 782 break;
@@ -633,7 +784,7 @@ do_status (const char *args)
633 } 784 }
634 if ((NULL != cl_head) && ((cl_head != cl_active) || (cl_head != cl_tail))) 785 if ((NULL != cl_head) && ((cl_head != cl_active) || (cl_head != cl_tail)))
635 { 786 {
636 set_status_icon ("gnunet-conversation-tray-call-incoming"); 787 set_status_icon ("gnunet-conversation-gtk-tray-call-incoming");
637 788
638 for (cl = cl_head; NULL != cl; cl = cl->next) 789 for (cl = cl_head; NULL != cl; cl = cl->next)
639 { 790 {
@@ -653,8 +804,10 @@ do_status (const char *args)
653 */ 804 */
654 805
655static void 806static void
656do_suspend (const char *args) 807do_suspend (struct GNUNET_CONVERSATION_Caller *sel_caller)
657{ 808{
809
810/*
658 if (NULL != call) 811 if (NULL != call)
659 { 812 {
660 switch (call_state) 813 switch (call_state)
@@ -670,20 +823,26 @@ do_suspend (const char *args)
670 return; 823 return;
671 } 824 }
672 } 825 }
826*/
673 switch (phone_state) 827 switch (phone_state)
674 { 828 {
675 case PS_LOOKUP_EGO: 829 case PS_LOOKUP_EGO:
676 case PS_LISTEN: 830 case PS_LISTEN:
677 case PS_ERROR: 831 case PS_ERROR:
678 LOG ("%s", _("There is no call that could be suspended right now.")); 832 LOG ("%s", _(" There is no call that could be suspended right now."));
679 return; 833 return;
680 case PS_ACCEPTED: 834 case PS_ACCEPTED:
681 /* expected state, do rejection logic */ 835 /* expected state, do rejection logic */
682 break; 836 break;
683 } 837 }
684 GNUNET_assert (NULL != cl_active); 838
685 GNUNET_CONVERSATION_caller_suspend (cl_active->caller); 839// GNUNET_assert (NULL != cl_active);
686 cl_active = NULL; 840
841 set_incoming_call_state(sel_caller,CT_suspended);
842 GNUNET_CONVERSATION_caller_suspend (sel_caller);
843
844// cl_active = NULL;
845
687 phone_state = PS_LISTEN; 846 phone_state = PS_LISTEN;
688} 847}
689 848
@@ -694,7 +853,7 @@ do_suspend (const char *args)
694 * @param args arguments given to the command 853 * @param args arguments given to the command
695 */ 854 */
696static void 855static void
697do_resume (const char *args) 856do_resume (struct GNUNET_CONVERSATION_Caller *sel_caller)
698{ 857{
699 struct CallList *cl; 858 struct CallList *cl;
700 char buf[32]; 859 char buf[32];
@@ -728,6 +887,7 @@ do_resume (const char *args)
728 peer_name); 887 peer_name);
729 return; 888 return;
730 } 889 }
890
731 GNUNET_assert (NULL == cl_active); 891 GNUNET_assert (NULL == cl_active);
732 cl = cl_head; 892 cl = cl_head;
733 if (NULL == cl) 893 if (NULL == cl)
@@ -735,22 +895,23 @@ do_resume (const char *args)
735 LOG (_("There is no incoming call to resume here!")); 895 LOG (_("There is no incoming call to resume here!"));
736 return; 896 return;
737 } 897 }
738 if ((NULL != cl->next) || (NULL != args)) 898 if (NULL != cl->next)
739 { 899 {
740 for (cl = cl_head; NULL != cl; cl = cl->next) 900 for (cl = cl_head; NULL != cl; cl = cl->next)
741 { 901 {
742 GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num); 902 GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num);
743 if (0 == strcmp (buf, args))
744 break;
745 } 903 }
746 } 904 }
747 if (NULL == cl) 905 if (NULL == cl)
748 { 906 {
749 LOG (_("There is no incoming call `%s' to resume right now!"), args); 907 LOG (_("There is no incoming call to resume right now! (null == cl)"));
750 return; 908 return;
751 } 909 }
752 cl_active = cl; 910 cl_active = cl;
753 GNUNET_CONVERSATION_caller_resume (cl_active->caller, speaker, mic); 911
912 set_incoming_call_state(sel_caller,CT_active);
913
914 GNUNET_CONVERSATION_caller_resume (sel_caller, speaker, mic);
754 phone_state = PS_ACCEPTED; 915 phone_state = PS_ACCEPTED;
755} 916}
756 917
@@ -761,10 +922,12 @@ do_resume (const char *args)
761 * @param args arguments given to the command 922 * @param args arguments given to the command
762 */ 923 */
763static void 924static void
764do_reject (const char *args) 925do_reject (struct GNUNET_CONVERSATION_Caller *sel_caller)
765{ 926{
766 struct CallList *cl; 927 struct CallList *cl;
767 char buf[32]; 928 char buf[32];
929 LOG("do reject");
930// set_incoming_call_state(sel_caller,CT_rejected);
768 931
769 if (NULL != call) 932 if (NULL != call)
770 { 933 {
@@ -780,6 +943,7 @@ do_reject (const char *args)
780 return; 943 return;
781 case PS_LISTEN: 944 case PS_LISTEN:
782 /* look for active incoming calls to refuse */ 945 /* look for active incoming calls to refuse */
946 /*
783 cl = cl_head; 947 cl = cl_head;
784 if (NULL == cl) 948 if (NULL == cl)
785 { 949 {
@@ -800,22 +964,32 @@ do_reject (const char *args)
800 LOG (_("There is no incoming call `%s' to refuse right now!\n"), args); 964 LOG (_("There is no incoming call `%s' to refuse right now!\n"), args);
801 return; 965 return;
802 } 966 }
803 GNUNET_CONVERSATION_caller_hang_up (cl->caller); 967 */
968 //GNUNET_CONVERSATION_caller_hang_up (cl->caller);
969 set_incoming_call_state(sel_caller,CT_rejected);
970 GNUNET_CONVERSATION_caller_hang_up(sel_caller);
971
972 /*
804 GNUNET_CONTAINER_DLL_remove (cl_head, cl_tail, cl); 973 GNUNET_CONTAINER_DLL_remove (cl_head, cl_tail, cl);
805 peer_name = GNUNET_strdup (cl->caller_id); 974 peer_name = GNUNET_strdup (cl->caller_id);
806 GNUNET_free (cl->caller_id); 975 GNUNET_free (cl->caller_id);
807 GNUNET_free (cl); 976 GNUNET_free (cl);
977 */
808// caller_num_gen--; 978// caller_num_gen--;
809 break; 979 break;
810 case PS_ACCEPTED: 980 case PS_ACCEPTED:
811 /* expected state, do rejection logic */ 981 /* expected state, do rejection logic */
812 history_add (CH_REJECTED, peer_name); 982 history_add (CH_REJECTED, peer_name);
983 /*
813 GNUNET_assert (NULL != cl_active); 984 GNUNET_assert (NULL != cl_active);
814 GNUNET_CONVERSATION_caller_hang_up (cl_active->caller); 985 GNUNET_CONVERSATION_caller_hang_up (cl_active->caller);
815 GNUNET_free (cl_active->caller_id); 986 GNUNET_free (cl_active->caller_id);
816 GNUNET_free (cl_active); 987 GNUNET_free (cl_active);
817 GNUNET_assert (caller_num_gen > 0); 988 GNUNET_assert (caller_num_gen > 0);
818// caller_num_gen--; 989// caller_num_gen--;
990 */
991 set_incoming_call_state(sel_caller,CT_hangup);
992 GNUNET_CONVERSATION_caller_hang_up(sel_caller);
819 cl_active = NULL; 993 cl_active = NULL;
820 phone_state = PS_LISTEN; 994 phone_state = PS_LISTEN;
821 break; 995 break;
@@ -982,12 +1156,11 @@ identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
982 { 1156 {
983 GNUNET_IDENTITY_ego_get_public_key (ego, &pk); 1157 GNUNET_IDENTITY_ego_get_public_key (ego, &pk);
984 s = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk); 1158 s = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk);
985 fprintf (stdout, "%s \n", name); 1159// fprintf (stdout, "%s \n", name);
986 gtk_list_store_insert_with_values (zone_liststore, 1160// gtk_list_store_insert_with_values (zone_liststore,
987 &iter, -1, 1161// &iter, -1,
988 0, name, 1162// 0, name,
989 1, ego, 1163// -1);
990 -1);
991 } 1164 }
992 1165
993 1166
@@ -997,7 +1170,7 @@ identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
997 { 1170 {
998 if (verbose) 1171 if (verbose)
999 LOG (_("Name of our ego changed to `%s'\n"), name); 1172 LOG (_("Name of our ego changed to `%s'\n"), name);
1000 GNUNET_free (ego_name); 1173 //GNUNET_free (ego_name);
1001 ego_name = GNUNET_strdup (name); 1174 ego_name = GNUNET_strdup (name);
1002 return; 1175 return;
1003 } 1176 }
@@ -1112,7 +1285,7 @@ GNUNET_GTK_conversation_quit_cb (GObject * object, gpointer user_data)
1112 GNUNET_MICROPHONE_destroy (mic); 1285 GNUNET_MICROPHONE_destroy (mic);
1113 mic = NULL; 1286 mic = NULL;
1114 ego_name = NULL; 1287 ego_name = NULL;
1115 GNUNET_free_non_null (peer_name); 1288 //GNUNET_free_non_null (peer_name);
1116 phone_state = PS_ERROR; 1289 phone_state = PS_ERROR;
1117 1290
1118 GNUNET_SCHEDULER_shutdown (); 1291 GNUNET_SCHEDULER_shutdown ();
@@ -1275,6 +1448,7 @@ main (int argc, char *const *argv)
1275 * @param caller_id 1448 * @param caller_id
1276 */ 1449 */
1277 1450
1451/*
1278void 1452void
1279quick_message (gchar * message, const char *caller_id) 1453quick_message (gchar * message, const char *caller_id)
1280{ 1454{
@@ -1309,10 +1483,10 @@ quick_message (gchar * message, const char *caller_id)
1309 case GTK_RESPONSE_ACCEPT: 1483 case GTK_RESPONSE_ACCEPT:
1310 do_status (""); 1484 do_status ("");
1311 gtk_widget_destroy (GTK_WIDGET (dialog)); 1485 gtk_widget_destroy (GTK_WIDGET (dialog));
1312 do_accept ("0"); 1486// do_accept ("0");
1313 break; 1487 break;
1314 case GTK_RESPONSE_REJECT: 1488 case GTK_RESPONSE_REJECT:
1315 do_reject ("0"); 1489// do_reject (caller_selected);
1316 do_status (""); 1490 do_status ("");
1317 gtk_widget_destroy (GTK_WIDGET (dialog)); 1491 gtk_widget_destroy (GTK_WIDGET (dialog));
1318 break; 1492 break;
@@ -1324,7 +1498,7 @@ quick_message (gchar * message, const char *caller_id)
1324 1498
1325 1499
1326} 1500}
1327 1501*/
1328 1502
1329 1503
1330 1504
@@ -1346,8 +1520,8 @@ GNUNET_CONVERSATION_GTK_on_call_clicked ()
1346// FPRINTF (stderr, _("calling: %s \n"), to_addr ); 1520// FPRINTF (stderr, _("calling: %s \n"), to_addr );
1347 1521
1348 do_call (to_addr); 1522 do_call (to_addr);
1349 disable_button ("GNUNET_GTK_conversation_accept_button"); 1523 //disable_button ("GNUNET_GTK_conversation_accept_button");
1350 do_status (""); 1524 do_status ();
1351// free(to_addr); 1525// free(to_addr);
1352} 1526}
1353 1527
@@ -1357,14 +1531,18 @@ GNUNET_CONVERSATION_GTK_on_call_clicked ()
1357void 1531void
1358GNUNET_CONVERSATION_GTK_on_hangup_clicked () 1532GNUNET_CONVERSATION_GTK_on_hangup_clicked ()
1359{ 1533{
1360 //update_status()disable_button("GNUNET_CONVERSATION_GTK_call_button"); 1534 //update_status()
1535 //disable_button("GNUNET_CONVERSATION_GTK_call_button");
1536 //FPRINTF (stderr, "hangup clicked \n");
1361 1537
1362 enable_button ("GNUNET_GTK_conversation_call_button"); 1538// enable_button ("GNUNET_GTK_conversation_call_button");
1363 1539
1364 1540
1365 //FPRINTF (stderr, "hangup clicked \n"); 1541 //FPRINTF (stderr, "hangup clicked \n");
1366 do_reject (NULL); 1542
1367 do_status (""); 1543 do_reject (caller_selected);
1544
1545 do_status ();
1368 //history_add(3,peer_name); 1546 //history_add(3,peer_name);
1369} 1547}
1370 1548
@@ -1374,8 +1552,8 @@ GNUNET_CONVERSATION_GTK_on_hangup_clicked ()
1374void 1552void
1375GNUNET_CONVERSATION_GTK_on_accept_clicked () 1553GNUNET_CONVERSATION_GTK_on_accept_clicked ()
1376{ 1554{
1377 FPRINTF (stderr, "accept clicked \n"); 1555 //FPRINTF (stderr, "accept clicked \n");
1378 do_accept (0); 1556 do_accept (caller_selected);
1379 // hide_infobar (); 1557 // hide_infobar ();
1380} 1558}
1381 1559
@@ -1387,7 +1565,7 @@ void
1387GNUNET_CONVERSATION_GTK_on_reject_clicked () 1565GNUNET_CONVERSATION_GTK_on_reject_clicked ()
1388{ 1566{
1389 LOG ("reject clicked \n"); 1567 LOG ("reject clicked \n");
1390 do_reject ("0"); 1568 do_reject (caller_selected);
1391} 1569}
1392 1570
1393/** 1571/**
@@ -1397,7 +1575,7 @@ void
1397GNUNET_CONVERSATION_GTK_on_pause_clicked () 1575GNUNET_CONVERSATION_GTK_on_pause_clicked ()
1398{ 1576{
1399// GtkEntry *entry; 1577// GtkEntry *entry;
1400 do_suspend ("0"); 1578 do_suspend (caller_selected);
1401 //FPRINTF (stderr, "pause clicked \n"); 1579 //FPRINTF (stderr, "pause clicked \n");
1402 //do_pause(""); 1580 //do_pause("");
1403 // entry = GTK_ENTRY((get_object ("GNUNET_GTK_conversation_address"))); 1581 // entry = GTK_ENTRY((get_object ("GNUNET_GTK_conversation_address")));
@@ -1413,7 +1591,7 @@ void
1413GNUNET_CONVERSATION_GTK_on_resume_clicked () 1591GNUNET_CONVERSATION_GTK_on_resume_clicked ()
1414{ 1592{
1415 //FPRINTF (stderr, "reject clicked \n"); 1593 //FPRINTF (stderr, "reject clicked \n");
1416 do_resume (""); 1594 do_resume (caller_selected);
1417} 1595}
1418 1596
1419/** 1597/**
@@ -1425,7 +1603,7 @@ GNUNET_CONVERSATION_GTK_on_status_clicked ()
1425 1603
1426 1604
1427// do_accept("0"); 1605// do_accept("0");
1428 do_status (" "); 1606 do_status ();
1429 //quick_message('hee blaaat you have a call from blaat'); 1607 //quick_message('hee blaaat you have a call from blaat');
1430} 1608}
1431 1609
@@ -1455,9 +1633,9 @@ add_contact (const gchar * name, const gchar * address)
1455 rd.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; // always set to relative for testing purposes 1633 rd.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; // always set to relative for testing purposes
1456 rde->flags |= GNUNET_GNSRECORD_RF_PRIVATE; 1634 rde->flags |= GNUNET_GNSRECORD_RF_PRIVATE;
1457 rde->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; 1635 rde->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
1458 FPRINTF (stderr, "adding\n"); 1636 //FPRINTF (stderr, "adding\n");
1459 FPRINTF (stderr, "name: %s\n", name); 1637 //FPRINTF (stderr, "name: %s\n", name);
1460 FPRINTF (stderr, "address: %s\n", address); 1638 //FPRINTF (stderr, "address: %s\n", address);
1461 if (GNUNET_OK != 1639 if (GNUNET_OK !=
1462 GNUNET_GNSRECORD_string_to_value (65536, address, &data, &data_size)) 1640 GNUNET_GNSRECORD_string_to_value (65536, address, &data, &data_size))
1463 { 1641 {
@@ -1509,7 +1687,7 @@ GNUNET_CONVERSATION_GTK_on_remove_clicked (GtkButton * button,
1509 if (gtk_tree_selection_get_selected (selection, &model, &iter)) 1687 if (gtk_tree_selection_get_selected (selection, &model, &iter))
1510 { 1688 {
1511 gtk_tree_model_get (model, &iter, 0, &name, -1); 1689 gtk_tree_model_get (model, &iter, 0, &name, -1);
1512 FPRINTF (stderr, "selected %s \n", name); 1690 //FPRINTF (stderr, "selected %s \n", name);
1513 main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window")); 1691 main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window"));
1514 confirm = 1692 confirm =
1515 GTK_DIALOG (gtk_dialog_new_with_buttons 1693 GTK_DIALOG (gtk_dialog_new_with_buttons
@@ -1566,7 +1744,7 @@ GNUNET_CONVERSATION_GTK_row_activated ()
1566 gchar *callAddress; 1744 gchar *callAddress;
1567 gchar *type; 1745 gchar *type;
1568 1746
1569 FPRINTF (stderr, "row activated \n"); 1747// FPRINTF (stderr, "row activated \n");
1570 1748
1571 GtkTreeSelection *selection; 1749 GtkTreeSelection *selection;
1572 1750
@@ -1577,9 +1755,9 @@ GNUNET_CONVERSATION_GTK_row_activated ()
1577 1755
1578 gtk_tree_selection_get_selected (selection, &contacts_treemodel, &iterA); 1756 gtk_tree_selection_get_selected (selection, &contacts_treemodel, &iterA);
1579 gtk_tree_model_get (contacts_treemodel, &iterA, 0, &name, 1, &type, -1); 1757 gtk_tree_model_get (contacts_treemodel, &iterA, 0, &name, 1, &type, -1);
1580 g_print ("ego name %s\n", ego_name); 1758// g_print ("ego name %s\n", ego_name);
1581 g_print ("selected row is: %s\n", name); 1759// g_print ("selected row is: %s\n", name);
1582 g_print ("selected rowtype is: %s\n", type); 1760// g_print ("selected rowtype is: %s\n", type);
1583 1761
1584 1762
1585 g_print ("type @row active%s", type); 1763 g_print ("type @row active%s", type);
@@ -1602,41 +1780,6 @@ GNUNET_CONVERSATION_GTK_row_activated ()
1602} 1780}
1603 1781
1604/* 1782/*
1605 * set_status_icon
1606 *
1607 * available icons:
1608 * gnunet-conversation-tray-pending
1609 * gnunet-conversation-tray-available
1610 * gnunet-conversation-tray-offline
1611 * gnunet-conversation-tray-call-pending
1612 * gnunet-conversation-tray-call-ringing
1613 * gnunet-conversation-tray-call-active
1614 * gnunet-conversation-tray-call-suspended
1615 * gnunet-conversation-tray-call-incoming
1616 *
1617 */
1618
1619void
1620set_status_icon (const char *icon_name)
1621{
1622 GtkWindow *main_window;
1623 GtkImage *status_icon;
1624
1625
1626
1627 main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window"));
1628
1629 status_icon = GTK_IMAGE (get_object ("GNUNET_GTK_status_icon"));
1630
1631 gtk_image_set_from_icon_name (status_icon, icon_name, GTK_ICON_SIZE_BUTTON);
1632
1633 LOG (_("Tray icon changed to: `%s' "), icon_name);
1634
1635
1636
1637 GNUNET_GTK_tray_icon_change (icon_name, "gnunet-conversation-gtk-status");
1638}
1639
1640static void 1783static void
1641print_ego (void *cls, 1784print_ego (void *cls,
1642 struct GNUNET_IDENTITY_Ego *ego, 1785 struct GNUNET_IDENTITY_Ego *ego,
@@ -1650,7 +1793,7 @@ print_ego (void *cls,
1650 fprintf (stdout, "%s \n", identifier); 1793 fprintf (stdout, "%s \n", identifier);
1651// GNUNET_free (s); 1794// GNUNET_free (s);
1652} 1795}
1653 1796*/
1654 1797
1655/* end of gnunet-conversation-gtk.c */ 1798/* end of gnunet-conversation-gtk.c */
1656void 1799void
@@ -1665,30 +1808,28 @@ GNUNET_contact_test ()
1665// struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc; 1808// struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc;
1666// edc = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginEnvironment); 1809// edc = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginEnvironment);
1667*/ 1810*/
1668// GtkTreeIter iter;
1669// char *caller_id = "testje";
1670// int caller_num = 10;
1671
1672 /*
1673 * active_liststore:
1674 * 0: *gchar caller_id
1675 * 1: pointer caller
1676 * 2: gint caller_num
1677 */
1678/*
1679 gtk_list_store_append (active_liststore, &iter);
1680 1811
1812 GtkTreeIter iter;
1813 char *caller_id = "testje";
1814 int caller_num = 10;
1815
1816enum {
1817 AL_caller_id, // *gchar
1818 AL_caller, // *
1819 AL_caller_num //gint
1820};
1821
1822 gtk_list_store_append (active_liststore, &iter);
1681 gtk_list_store_set (active_liststore, &iter, 2, caller_num, 0, caller_id, -1); 1823 gtk_list_store_set (active_liststore, &iter, 2, caller_num, 0, caller_id, -1);
1682 1824
1683 gtk_list_store_insert_with_values (zone_liststore, 1825 gtk_list_store_insert_with_values (zone_liststore,
1684 &iter, -1, 1826 &iter, -1,
1685 0, "test", 1827 0, "test",
1686 -1); 1828 -1);
1687*/
1688// static struct GNUNET_IDENTITY_Handle *sh; 1829// static struct GNUNET_IDENTITY_Handle *sh;
1689// GNUNET_IDENTITY_disconnect (id); 1830// GNUNET_IDENTITY_disconnect (id);
1690// &print_ego; 1831// &print_ego;
1691 //sh = GNUNET_IDENTITY_connect (cfg, &print_ego, NULL); 1832//sh = GNUNET_IDENTITY_connect (cfg, &print_ego, NULL);
1692// GNUNET_NAMESTORE_zone_iterator_next(list_it); 1833// GNUNET_NAMESTORE_zone_iterator_next(list_it);
1693} 1834}
1694 1835
@@ -1715,7 +1856,6 @@ gnunet_conversation_gtk_contacts_zone_combobox_changed_cb (GtkComboBox *widget,
1715 char *tempName; 1856 char *tempName;
1716 struct GNUNET_CRYPTO_EcdsaPrivateKey temp_zone_pkey; 1857 struct GNUNET_CRYPTO_EcdsaPrivateKey temp_zone_pkey;
1717 1858
1718
1719 gtk_combo_box_get_active_iter(widget, &contacts_zone_iter); 1859 gtk_combo_box_get_active_iter(widget, &contacts_zone_iter);
1720 1860
1721 gtk_tree_model_get (GTK_TREE_MODEL (zone_liststore), 1861 gtk_tree_model_get (GTK_TREE_MODEL (zone_liststore),
@@ -1740,3 +1880,114 @@ gnunet_conversation_gtk_contacts_zone_combobox_changed_cb (GtkComboBox *widget,
1740 1880
1741} 1881}
1742 1882
1883/*
1884 * @brief print info for currently selected call
1885 */
1886void
1887print_call_info()
1888{
1889 GtkTreeIter gtkiter;
1890 gboolean valid;
1891 gint row_count = 0;
1892
1893 //LOG("test");
1894 valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), &gtkiter );
1895
1896 if (!valid)
1897 GNUNET_break(0);
1898
1899 while (valid)
1900 {
1901 gchar *str_data;
1902 gint int_data;
1903 gpointer cl_caller;
1904
1905 gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), &gtkiter,
1906 AL_caller, &cl_caller,
1907 AL_caller_id,&str_data,
1908 AL_caller_num,&int_data,-1);
1909 if (caller_selected == cl_caller)
1910 {
1911 // LOG (_("info for active call:%s number: %u row: %u"), str_data,int_data,row_count);
1912 //break ;
1913 }
1914 g_free (str_data);
1915 row_count++;
1916 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), &gtkiter);
1917 }
1918
1919
1920
1921}
1922
1923/*
1924 * @brief executed when selecting a call
1925 */
1926
1927void
1928GNUNET_CONVERSATION_GTK_on_active_calls_selection_changed()
1929{
1930 gchar *caller_id;
1931 gpointer cl_caller;
1932 GtkTreeSelection *active_selection;
1933 GtkTreeIter gcl_selected;
1934// active_liststore_selection = get_object("GNUNET_CONVERSATION_GTK_active_calls_selection");
1935
1936 active_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (active_treeview));
1937
1938
1939 if (gtk_tree_selection_get_selected(active_selection,NULL,&gcl_selected))
1940 {
1941
1942 gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), &gcl_selected,
1943 AL_caller, &cl_caller,
1944 AL_caller_id, &caller_id,
1945 -1);
1946
1947 caller_selected = cl_caller;
1948
1949 //LOG("SELECTION: %s ",caller_id);
1950 print_call_info();
1951
1952 }
1953}
1954/*
1955 * @brief active call list type data function
1956 */
1957void
1958 active_calls_type_data_function (GtkTreeViewColumn *col,
1959 GtkCellRenderer *renderer,
1960 GtkTreeModel *model,
1961 GtkTreeIter *iter,
1962 gpointer user_data)
1963 {
1964 gint state;
1965 gchar buf[20];
1966
1967 //gtk_tree_model_get(model, iter, AL_caller_state, &state, -1);
1968
1969 //g_snprintf(buf, sizeof(buf), "state: %u", state);
1970
1971 //g_object_set(renderer, "text", buf, NULL);
1972 }
1973
1974
1975/*
1976 * @brief second test button
1977 */
1978void
1979GNUNET_CONVERSATION_GTK_test_button_two()
1980{
1981 GtkTreeViewColumn *column;
1982 GtkCellRenderer *cell;
1983
1984 //LOG("test");
1985// treeview = get_object("gnunet_conversation_gtk_active_calls_treeview");
1986 column = get_object("GNUNET_CONVERSATION_GTK_caller_typeColumn");
1987 cell = gtk_cell_renderer_text_new();
1988 //cell = get_object("GNUNET_CONVERSATION_GTK_active_calls_type");
1989 gtk_tree_view_column_set_cell_data_func(column, cell, active_calls_type_data_function, NULL, NULL );
1990
1991}
1992
1993
diff --git a/src/conversation/gnunet-conversation-gtk.h b/src/conversation/gnunet-conversation-gtk.h
index 770fc6dc..d40f960f 100644
--- a/src/conversation/gnunet-conversation-gtk.h
+++ b/src/conversation/gnunet-conversation-gtk.h
@@ -38,7 +38,48 @@
38 38
39#define LOG(format, ...) log_message(g_strdup_printf (format, ## __VA_ARGS__)) 39#define LOG(format, ...) log_message(g_strdup_printf (format, ## __VA_ARGS__))
40 40
41#define MAX_TO_ADDR 124 41
42
43/**
44 * List of active calls
45 */
46 static GtkListStore *active_liststore;
47
48 /**
49 * List of active calls
50 */
51 static GtkTreeView *active_treeview;
52
53
54/*
55 * active calls treevieuw columns
56 */
57
58enum {
59 AL_caller_id, //*gchar
60 AL_caller, //*
61 AL_caller_num, //gint
62 AL_caller_type, //gint
63 AL_caller_state //gint
64};
65/**
66 * callerstate (state of incoming call)
67 */
68enum {
69 CT_active,
70 CT_suspended,
71 CT_ringing,
72 CT_dead,
73 CT_hangup,
74 CT_rejected
75};
76/**
77 * type of call
78 */
79enum {
80 CALL_IN,
81 CALL_OUT
82};
42 83
43 84
44/** 85/**
@@ -47,7 +88,7 @@
47 * @return configuration handle 88 * @return configuration handle
48 */ 89 */
49const struct GNUNET_CONFIGURATION_Handle * 90const struct GNUNET_CONFIGURATION_Handle *
50GIG_get_configuration (void); 91GIG_get_configuration ();
51 92
52 93
53/** 94/**
@@ -155,6 +196,11 @@ struct CallList
155 struct GNUNET_CONVERSATION_Caller *caller; 196 struct GNUNET_CONVERSATION_Caller *caller;
156 197
157 /** 198 /**
199 * Handle to call currently selected in list
200 */
201 struct GNUNET_CONVERSATION_Caller *caller_selected;
202
203 /**
158 * String identifying the caller. 204 * String identifying the caller.
159 */ 205 */
160 char *caller_id; 206 char *caller_id;
@@ -177,21 +223,31 @@ static struct GNUNET_CONVERSATION_Phone *phone;
177 * Call handle (for active outgoing call). 223 * Call handle (for active outgoing call).
178 */ 224 */
179static struct GNUNET_CONVERSATION_Call *call; 225static struct GNUNET_CONVERSATION_Call *call;
226//static struct GtkTreeIter gcall;
180 227
181/** 228/**
182 * Caller handle (for active incoming call). 229 * Caller handle (for active incoming call).
183 */ 230 */
184static struct CallList *cl_active; 231static struct CallList *cl_active;
232//static GtkTreeIter gcl_active;
185 233
186/** 234/**
187 * Head of calls waiting to be accepted. 235 * Head of calls waiting to be accepted.
188 */ 236 */
189static struct CallList *cl_head; 237static struct CallList *cl_head;
238//gtk
239//static GtkTreeIter gcl_head;
240
241/**
242 * currently selected call
243 */
244//static GtkTreeIter gcl_selected;
190 245
191/** 246/**
192 * Tail of calls waiting to be accepted. 247 * Tail of calls waiting to be accepted.
193 */ 248 */
194static struct CallList *cl_tail; 249static struct CallList *cl_tail;
250//static GtkTreeIter gcl_tail;
195 251
196/** 252/**
197 * Desired phone line. 253 * Desired phone line.
@@ -296,17 +352,6 @@ static void
296identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, 352identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
297 const char *name); 353 const char *name);
298 354
299/**
300 * List of active calls
301 */
302static GtkListStore *active_liststore;
303
304/**
305 * List of active calls
306 */
307static GtkTreeView *active_treeview;
308
309
310 355
311/** 356/**
312 * List of contacts (records). 357 * List of contacts (records).