aboutsummaryrefslogtreecommitdiff
path: root/src/conversation/gnunet-conversation-gtk.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/conversation/gnunet-conversation-gtk.c')
-rw-r--r--src/conversation/gnunet-conversation-gtk.c1232
1 files changed, 566 insertions, 666 deletions
diff --git a/src/conversation/gnunet-conversation-gtk.c b/src/conversation/gnunet-conversation-gtk.c
index d3e1954f..481c2d61 100644
--- a/src/conversation/gnunet-conversation-gtk.c
+++ b/src/conversation/gnunet-conversation-gtk.c
@@ -24,66 +24,11 @@
24 * @author yids 24 * @author yids
25 * @author hark 25 * @author hark
26 */ 26 */
27#include "gnunet-conversation-gtk_common.h" 27#include "gnunet-conversation-gtk.h"
28#include "gnunet-conversation-gtk_history.h" 28#include "gnunet-conversation-gtk_history.h"
29#include "gnunet-conversation-gtk_contacts.h" 29#include "gnunet-conversation-gtk_contacts.h"
30 30
31 31
32struct GNUNET_CONVERSATION_Caller *caller_selected = NULL;
33struct GNUNET_CONVERSATION_Call *call_selected = NULL;
34
35/*************
36 * common *
37 *************/
38/**
39 * * Handle to our main loop.
40 * */
41static struct GNUNET_GTK_MainLoop *ml;
42
43/**
44 * Get our configuration.
45 *
46 * @return configuration handle
47 */
48const struct GNUNET_CONFIGURATION_Handle *
49GIG_get_configuration ();
50
51/**
52 * Our configurations.
53 */
54static struct GNUNET_CONFIGURATION_Handle *cfg;
55
56/**
57 * Name of our ego.
58 */
59static char *ego_name;
60
61/**
62 * Be verbose.
63 */
64static int verbose = 1;
65
66
67/**
68 * Should gnunet-identity-gtk start in tray mode?
69 */
70static int tray_only;
71
72
73/*************
74 * phone *
75 *************/
76
77/**
78 * List of active calls
79 */
80static GtkListStore *active_liststore;
81
82/**
83 * List of active calls
84 */
85static GtkTreeView *active_treeview;
86
87/** 32/**
88 * List of incoming calls 33 * List of incoming calls
89 */ 34 */
@@ -121,13 +66,59 @@ struct CallList
121 unsigned int caller_num; 66 unsigned int caller_num;
122 67
123}; 68};
124 /**
125 * Unique number of call (outgoing)
126 */
127 unsigned int call_counter;
128 69
129 70
130/** 71/**
72 *
73 */
74static struct GNUNET_CONVERSATION_Caller *caller_selected;
75
76/**
77 *
78 */
79static struct GNUNET_CONVERSATION_Call *call_selected;
80
81/**
82 * Handle to our main loop.
83 */
84static struct GNUNET_GTK_MainLoop *ml;
85
86/**
87 * Our configurations.
88 */
89static struct GNUNET_CONFIGURATION_Handle *cfg;
90
91/**
92 * Name of our ego.
93 */
94static char *ego_name;
95
96/**
97 * Be verbose.
98 */
99static int verbose = 1;
100
101/**
102 * Should gnunet-identity-gtk start in tray mode?
103 */
104static int tray_only;
105
106/**
107 * List of active calls
108 */
109static GtkListStore *active_liststore;
110
111/**
112 * List of active calls
113 */
114static GtkTreeView *active_treeview;
115
116/**
117 * Unique number of call (outgoing)
118 */
119static unsigned int call_counter;
120
121/**
131 * Phone handle 122 * Phone handle
132 */ 123 */
133static struct GNUNET_CONVERSATION_Phone *phone; 124static struct GNUNET_CONVERSATION_Phone *phone;
@@ -160,7 +151,6 @@ static unsigned int line;
160/** 151/**
161 * debug box enabled 152 * debug box enabled
162 */ 153 */
163
164static unsigned int debug_box_enabled; 154static unsigned int debug_box_enabled;
165 155
166/** 156/**
@@ -203,13 +193,15 @@ static unsigned int caller_num_gen;
203 */ 193 */
204static char *address; 194static char *address;
205 195
206GtkWidget *b_contact, *b_accept, *b_hangup, *b_suspend, *b_resume; 196static GtkWidget *b_contact;
197
198static GtkWidget *b_accept;
207 199
200static GtkWidget *b_hangup;
208 201
209/******************* 202static GtkWidget *b_suspend;
210 * identity select *
211 *******************/
212 203
204static GtkWidget *b_resume;
213 205
214/** 206/**
215 * list of zones 207 * list of zones
@@ -217,23 +209,17 @@ GtkWidget *b_contact, *b_accept, *b_hangup, *b_suspend, *b_resume;
217static GtkListStore *zone_liststore; 209static GtkListStore *zone_liststore;
218 210
219/** 211/**
220 * zone tree model
221 */
222//static GtkTreeModel *zone_treemodel;
223
224/**
225 * Our ego. 212 * Our ego.
226 */ 213 */
227static struct GNUNET_IDENTITY_Ego *caller_id; 214static struct GNUNET_IDENTITY_Ego *caller_id;
228 215
229 216
230void GNUNET_CONVERSATION_GTK_on_active_calls_selection_changed (); 217void
218GNUNET_CONVERSATION_GTK_on_active_calls_selection_changed (void);
231 219
232void set_status_icon (const char *icon_name);
233 220
234/************ 221static void
235 * extern's * 222set_status_icon (const char *icon_name);
236 * **********/
237 223
238 224
239/** 225/**
@@ -242,109 +228,102 @@ void set_status_icon (const char *icon_name);
242 * @param name name of the object 228 * @param name name of the object
243 * @return NULL on error 229 * @return NULL on error
244 */ 230 */
245extern GObject * 231GObject *
246GNUNET_CONVERSATION_GTK_get_main_window_object (const char *name) 232GCG_get_main_window_object (const char *name)
247{ 233{
248 return GNUNET_GTK_main_loop_get_object (ml, name); 234 return GNUNET_GTK_main_loop_get_object (ml, name);
249} 235}
250 236
251 237
252/** 238/**
253 * log a message to gtk log textbuffer 239 * log a message to gtk log textbuffer
254 * @param Message to be logged 240 *
241 * @param message format string for message to be logged
242 * @param ... arguments for the format string
255 */ 243 */
256 244void
257extern void 245GCG_log (const char *message,
258GNUNET_CONVERSATION_GTK_log_message (const char *message) 246 ...)
259{ 247{
260 //
261 // log
262 //
263 GtkTextBuffer *logbuff; 248 GtkTextBuffer *logbuff;
264 GtkTextView *log_view; 249 GtkTextView *log_view;
265 GtkTextIter iter; 250 GtkTextIter iter;
266 gchar *fmsg; 251 gchar *fmsg;
252 va_list ap;
267 253
268 log_view = GTK_TEXT_VIEW (get_object ("GNUNET_GTK_conversation_log")); 254 log_view = GTK_TEXT_VIEW (GCG_get_main_window_object ("GNUNET_GTK_conversation_log"));
269
270 logbuff = GTK_TEXT_BUFFER (gtk_text_view_get_buffer (log_view)); 255 logbuff = GTK_TEXT_BUFFER (gtk_text_view_get_buffer (log_view));
271 256 va_start (ap, message);
272 fmsg = g_strdup_printf (" %s \n", message); 257 fmsg = g_strdup_vprintf (message,
273 258 ap);
274 gtk_text_buffer_get_start_iter (logbuff, &iter); 259 va_end (ap);
275 260 gtk_text_buffer_get_start_iter (logbuff,
276 gtk_text_buffer_insert (logbuff, &iter, fmsg, -1); 261 &iter);
262 gtk_text_buffer_insert (logbuff,
263 &iter,
264 fmsg,
265 -1);
277 g_free (fmsg); 266 g_free (fmsg);
278
279
280} 267}
281 268
269
282/** 270/**
283 * update status 271 * update status bar
284 * 272 *
285 * @param message Message to put in statusbar 273 * @param message format string for message to put in statusbar
274 * @param ... arguments for the format string
286 */ 275 */
287 276void
288static void 277GCG_update_status (const gchar *message,
289update_status (const gchar * message) 278 ...)
290{ 279{
291
292 GtkStatusbar *status_bar; 280 GtkStatusbar *status_bar;
293 guint status_bar_context; 281 guint status_bar_context;
294
295 gchar *buff; 282 gchar *buff;
283 va_list ap;
296 284
297 status_bar = GTK_STATUSBAR (get_object ("GNUNET_GTK_conversation_statusbar")); 285 status_bar = GTK_STATUSBAR (GCG_get_main_window_object ("GNUNET_GTK_conversation_statusbar"));
298 status_bar_context = gtk_statusbar_get_context_id (status_bar, "blaat"); 286 status_bar_context = gtk_statusbar_get_context_id (status_bar, "blaat");
299 287 va_start (ap, message);
300 288 buff = g_strdup_vprintf (message,
301 buff = g_strdup_printf ("%s", message); 289 ap);
302 290 va_end (ap);
303 gtk_statusbar_push (GTK_STATUSBAR (status_bar), 291 gtk_statusbar_push (GTK_STATUSBAR (status_bar),
304 GPOINTER_TO_INT (status_bar_context), buff); 292 GPOINTER_TO_INT (status_bar_context), buff);
305 g_free (buff); 293 g_free (buff);
306 294 GNUNET_CONVERSATION_GTK_on_active_calls_selection_changed (); // FIXME: why do this here?
307 GNUNET_CONVERSATION_GTK_on_active_calls_selection_changed();
308
309
310} 295}
311 296
312 297
313/** 298/**
314 * update statusbar 299 * update status based on current phone state.
315 * 300 *
316 * @param args arguments given to the command 301 * @param args arguments given to the command
317 */ 302 */
318static void 303static void
319do_status () 304do_status ()
320{ 305{
321 struct CallList *cl;
322
323 switch (phone_state) 306 switch (phone_state)
324 { 307 {
325 case PS_LOOKUP_EGO: 308 case PS_LOOKUP_EGO:
326 UPDATE_STATUS (_ 309 GCG_update_status (_("We are currently trying to locate the private key for the ego `%s'."),
327 ("We are currently trying to locate the private key for the ego `%s'."), 310 ego_name);
328 ego_name);
329 set_status_icon ("gnunet-conversation-gtk-tray-pending"); 311 set_status_icon ("gnunet-conversation-gtk-tray-pending");
330 break; 312 break;
331 case PS_LISTEN: 313 case PS_LISTEN:
332 UPDATE_STATUS (_ 314 GCG_update_status (_("We are listening for incoming calls for ego `%s' on line %u."),
333 ("We are listening for incoming calls for ego `%s' on line %u."), 315 ego_name,
334 ego_name, line); 316 line);
335 set_status_icon ("gnunet-conversation-gtk-tray-available"); 317 set_status_icon ("gnunet-conversation-gtk-tray-available");
336
337 break; 318 break;
338 case PS_ACCEPTED: 319 case PS_ACCEPTED:
339 UPDATE_STATUS (_("You are having a conversation with `%s'.\n"), peer_name); 320 GCG_update_status (_("You are having a conversation with `%s'.\n"),
321 peer_name);
340 set_status_icon ("gnunet-conversation-call-active"); 322 set_status_icon ("gnunet-conversation-call-active");
341
342 break; 323 break;
343 case PS_ERROR: 324 case PS_ERROR:
344 UPDATE_STATUS (_ 325 GCG_update_status (_("We had an internal error setting up our phone line. You can still make calls."));
345 ("We had an internal error setting up our phone line. You can still make calls."));
346 set_status_icon ("gnunet-conversation-offline"); 326 set_status_icon ("gnunet-conversation-offline");
347
348 break; 327 break;
349 } 328 }
350 if (NULL != call) 329 if (NULL != call)
@@ -352,282 +331,252 @@ do_status ()
352 switch (call_state) 331 switch (call_state)
353 { 332 {
354 case CS_RESOLVING: 333 case CS_RESOLVING:
355 UPDATE_STATUS (_ 334 GCG_update_status (_("We are trying to find the network address to call `%s'."),
356 ("We are trying to find the network address to call `%s'."), 335 peer_name);
357 peer_name);
358 set_status_icon ("gnunet-conversation-gtk-tray-call-pending"); 336 set_status_icon ("gnunet-conversation-gtk-tray-call-pending");
359
360 break; 337 break;
361 case CS_RINGING: 338 case CS_RINGING:
362 UPDATE_STATUS (_("We are calling `%s', his phone should be ringing."), 339 GCG_update_status (_("We are calling `%s', his phone should be ringing."),
363 peer_name); 340 peer_name);
364 set_status_icon ("gnunet-conversation-gtk-tray-call-ringing"); 341 set_status_icon ("gnunet-conversation-gtk-tray-call-ringing");
365
366 break; 342 break;
367 case CS_CONNECTED: 343 case CS_CONNECTED:
368 UPDATE_STATUS (_("You are having a conversation with `%s'."), peer_name); 344 GCG_update_status (_("You are having a conversation with `%s'."),
345 peer_name);
369 set_status_icon ("gnunet-conversation-gtk-tray-call-active"); 346 set_status_icon ("gnunet-conversation-gtk-tray-call-active");
370
371 break; 347 break;
372 case CS_SUSPENDED: 348 case CS_SUSPENDED:
349 GCG_update_status (_("Conversation suspended, you can accept or initiate another call now."),
350 peer_name);
373 set_status_icon ("gnunet-conversation-gtk-tray-call-suspended"); 351 set_status_icon ("gnunet-conversation-gtk-tray-call-suspended");
374
375 /* ok to accept incoming call right now */
376 break; 352 break;
377 } 353 }
378 } 354 }
379 if ((NULL != cl_head) && ((cl_head != cl_active) || (cl_head != cl_tail))) 355 if ( ( (NULL == call) ||
380 { 356 (CS_SUSPENDED == call_state) ) &&
357 (NULL != cl_head) &&
358 ( (cl_head != cl_active) ||
359 (cl_head != cl_tail) ) )
381 set_status_icon ("gnunet-conversation-gtk-tray-call-incoming"); 360 set_status_icon ("gnunet-conversation-gtk-tray-call-incoming");
382
383 for (cl = cl_head; NULL != cl; cl = cl->next)
384 {
385 if (cl == cl_active)
386 continue;
387 //UPDATE_STATUS (_("#%u: `%s'"), cl->caller_num, cl->caller_id);
388// LOG ("%s", _("Calls waiting:"));
389 }
390 }
391} 361}
392 362
393 363
394 364/**
395/*
396 * @brief print info for currently selected call 365 * @brief print info for currently selected call
397 */ 366 */
398static void 367static void
399print_call_info() 368print_call_info ()
400{ 369{
401 GtkTreeIter gtkiter; 370 GtkTreeIter gtkiter;
402 gboolean valid; 371 gboolean valid;
403 gint row_count = 0; 372 gint row_count = 0;
404 373
405 valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), &gtkiter ); 374 valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (active_liststore),
406 375 &gtkiter);
407 if (!valid) 376 if (! valid)
408 GNUNET_break(0); 377 GNUNET_break(0);
409
410 while (valid)
411 {
412 gchar *str_data;
413 gint int_data;
414 gpointer cl_caller;
415 gpointer cl_call;
416 378
417 gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), &gtkiter, 379 while (valid)
418 AL_caller, &cl_caller, 380 {
419 AL_caller_id, &str_data, 381 gchar *str_data;
420 AL_caller_num, &int_data, 382 gint int_data;
421 AL_call, &cl_call, 383 gpointer cl_caller;
422 -1); 384 gpointer cl_call;
423 if (caller_selected == cl_caller) 385
424 { 386 gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), &gtkiter,
425 // LOG (_("info for active call:%s number: %u row: %u"), str_data,int_data,row_count); 387 AL_caller, &cl_caller,
426 currentlySelectedCallAddress = str_data; 388 AL_caller_id, &str_data,
427// FPRINTF(stderr,"cal addr: %s\n",currentlySelectedCallAddress); 389 AL_caller_num, &int_data,
428 break ; 390 AL_call, &cl_call,
429 } 391 -1);
430 if (call_selected == cl_call) 392 if (caller_selected == cl_caller)
431 { 393 {
432 LOG (_("info for active outgoing call:%s number: %u row: %u"), str_data,int_data,row_count); 394 currentlySelectedCallAddress = str_data;
433 break; 395 break;
434 } 396 }
397 if (call_selected == cl_call)
398 {
399 GCG_log (_("info for active outgoing call:%s number: %u row: %u"),
400 str_data,
401 int_data,
402 row_count);
403 break;
404 }
435 g_free (str_data); 405 g_free (str_data);
436 row_count++; 406 row_count++;
437 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), &gtkiter); 407 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), &gtkiter);
438 } 408 }
439
440
441
442} 409}
443 410
444 411
445 412/**
446/*
447 * @brief sets caller_selected, and enables or disables the active call list buttons 413 * @brief sets caller_selected, and enables or disables the active call list buttons
448 */ 414 */
449static void 415static void
450update_active_call_list_buttons() 416update_active_call_list_buttons()
451{ 417{
452 gchar *caller_id; 418 gchar *caller_id;
453 gpointer cl_caller; 419 gpointer cl_caller;
454 gpointer cl_call; 420 gpointer cl_call;
455 gint cl_caller_state; 421 gint cl_caller_state;
456 gint cl_type; 422 gint cl_type;
457 //gint cl_caller_type; 423 //gint cl_caller_type;
458 GtkTreeSelection *active_selection; 424 GtkTreeSelection *active_selection;
459 GtkTreeIter gcl_selected; 425 GtkTreeIter gcl_selected;
460// active_liststore_selection = get_object(ml,"GNUNET_CONVERSATION_GTK_active_calls_selection"); 426 // active_liststore_selection = GCG_get_main_window_object(ml,"GNUNET_CONVERSATION_GTK_active_calls_selection");
461 427
462 // reset references to selected call/caller 428 // reset references to selected call/caller
463 //caller_selected = NULL; 429 //caller_selected = NULL;
464 //call_selected = NULL; 430 //call_selected = NULL;
465 LOG("reset caller selected"); 431 GCG_log("reset caller selected");
466 active_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (active_treeview)); 432 active_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (active_treeview));
467 433 if (gtk_tree_selection_get_selected (active_selection,
468 434 NULL,
469 if (gtk_tree_selection_get_selected(active_selection,NULL,&gcl_selected)) 435 &gcl_selected))
470 { 436 {
471 437 // get selected call
472 // get selected call 438 gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), &gcl_selected,
473 gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), &gcl_selected, 439 AL_caller, &cl_caller, // reference to incoming call
474 AL_caller, &cl_caller, // reference to incoming call 440 AL_caller_id, &caller_id,
475 AL_caller_id, &caller_id, 441 AL_caller_state, &cl_caller_state,
476 AL_caller_state, &cl_caller_state, 442 AL_type, &cl_type,
477 AL_type, &cl_type, 443 AL_call, &cl_call, // reference to outgoing call
478 AL_call, &cl_call, // reference to outgoing call 444 -1);
479 -1); 445 // check if selected call is a incoming or outgoing call
480 446 switch (cl_type)
481 // check if selected call is a incoming or outgoing call 447 {
482 switch (cl_type) 448 case CALL_IN:
483 { 449 call_selected = NULL;
484 case CALL_IN: 450 caller_selected = cl_caller;
485 call_selected = NULL; 451 GNUNET_break (NULL != caller_selected);
486 caller_selected = cl_caller; 452 break;
487 if (caller_selected == NULL){ 453 case CALL_OUT:
488 GNUNET_break(0); 454 caller_selected = NULL;
489 } 455 call_selected = cl_call;
490 456 GCG_log("outgoing selected");
491 break; 457 GNUNET_break (NULL != call_selected);
492 case CALL_OUT: 458 break;
493 caller_selected = NULL; 459 default:
494 call_selected = cl_call; 460 GNUNET_break(0);
495 LOG("outgoing selected"); 461 break;
496 if (call_selected == NULL){ 462 }
497 GNUNET_break(0); 463 gtk_widget_show(GTK_WIDGET(GCG_get_main_window_object("GNUNET_GTK_conversation_active_call_list_buttons")));
498 } 464 GCG_log("caller state: %u phone_state: %u",
499 break; 465 cl_caller_state,
500 default: 466 phone_state);
501 GNUNET_break(0); 467 switch (cl_caller_state)
502 break; 468 {
503 } 469 /* buttons:
504 470 * contact
505 471 * accept
506 472 * hangup
507 gtk_widget_show(GTK_WIDGET(get_object("GNUNET_GTK_conversation_active_call_list_buttons" ))); 473 * suspend
508 474 * resume
509 LOG("caller state: %u phone_state: %u",cl_caller_state, phone_state); 475 *
510 476 * TODO: check if there is incoming or outgoing call,
511 switch (cl_caller_state) 477 * disable resume and accept buttons.
512 { 478 * or suspend that other call
513 /* buttons: 479 */
514 * contact 480 case CT_active:
515 * accept 481 // hangup, pause
516 * hangup 482 //GCG_log("CT_active state: %u ",cl_caller_state);
517 * suspend 483 gtk_widget_set_sensitive (b_contact, TRUE);
518 * resume 484 gtk_widget_set_sensitive (b_accept, FALSE);
519 * 485 gtk_widget_set_sensitive (b_hangup, TRUE);
520 * TODO: check if there is incoming or outgoing call, 486 gtk_widget_set_sensitive (b_suspend, TRUE);
521 * disable resume and accept buttons. 487 gtk_widget_set_sensitive (b_resume, FALSE);
522 * or suspend that other call 488 break;
523 */ 489 case CT_ringing:
524 490 // pickup, phonebook
525 case CT_active: 491 //GCG_log("CT_ring show button");
526 // hangup, pause 492 gtk_widget_set_sensitive (b_contact, TRUE);
527 //LOG("CT_active state: %u ",cl_caller_state); 493 if (phone_state == PS_LISTEN)
528 gtk_widget_set_sensitive(b_contact, 1); 494 {
529 gtk_widget_set_sensitive(b_accept, 0); 495 gtk_widget_set_sensitive (b_accept, TRUE);
530 gtk_widget_set_sensitive(b_hangup, 1); 496 }
531 gtk_widget_set_sensitive(b_suspend, 1); 497 else
532 gtk_widget_set_sensitive(b_resume, 0); 498 {
533 break; 499 gtk_widget_set_sensitive (b_accept, FALSE);
534 case CT_ringing: 500 }
535 // pickup, phonebook 501 gtk_widget_set_sensitive (b_hangup, FALSE);
536 //LOG("CT_ring show button"); 502 gtk_widget_set_sensitive (b_suspend, FALSE);
537 gtk_widget_set_sensitive(b_contact, 1); 503 gtk_widget_set_sensitive (b_resume, FALSE);
538 if (phone_state == PS_LISTEN) 504 break;
539 { 505 case CT_rejected:
540 gtk_widget_set_sensitive(b_accept, 1); 506 //add to phonebook
541 }else{ 507 //GCG_log("CT_rejected ");
542 gtk_widget_set_sensitive(b_accept, 0); 508 gtk_widget_set_sensitive (b_contact, TRUE);
543 } 509 gtk_widget_set_sensitive (b_accept, FALSE);
544 510 gtk_widget_set_sensitive (b_hangup, FALSE);
545 511 gtk_widget_set_sensitive (b_suspend, FALSE);
546 gtk_widget_set_sensitive(b_hangup, 0); 512 gtk_widget_set_sensitive (b_resume, FALSE);
547 gtk_widget_set_sensitive(b_suspend, 0); 513 break;
548 gtk_widget_set_sensitive(b_resume, 0); 514 case CT_suspended:
549 break; 515 // resume, hangup
550 case CT_rejected: 516 //GCG_log("CT_suspended ");
551 //add to phonebook 517 gtk_widget_set_sensitive (b_contact, TRUE);
552 //LOG("CT_rejected "); 518 gtk_widget_set_sensitive (b_accept, FALSE);
553 gtk_widget_set_sensitive(b_contact, 1); 519 gtk_widget_set_sensitive (b_hangup, TRUE);
554 gtk_widget_set_sensitive(b_accept, 0); 520 gtk_widget_set_sensitive (b_suspend, FALSE);
555 gtk_widget_set_sensitive(b_hangup, 0); 521 if (phone_state == PS_LISTEN)
556 gtk_widget_set_sensitive(b_suspend, 0); 522 {
557 gtk_widget_set_sensitive(b_resume, 0); 523 GCG_log("enable resume button");
558 524 gtk_widget_set_sensitive (b_resume, TRUE);
559 break; 525 }
560 case CT_suspended: 526 else
561 // resume, hangup 527 {
562 //LOG("CT_suspended "); 528 GCG_log("do not disable resume button (for test)");
563 gtk_widget_set_sensitive(b_contact, 1 ); 529 gtk_widget_set_sensitive (b_resume, TRUE);
564 gtk_widget_set_sensitive(b_accept, 0); 530 }
565 gtk_widget_set_sensitive(b_hangup, 1); 531 break;
566 gtk_widget_set_sensitive(b_suspend, 0); 532 case CT_other:
567 533 //add to phonebook
568 if (phone_state == PS_LISTEN) 534 //GCG_log("CT_rejected ");
569 { 535 gtk_widget_set_sensitive (b_contact, TRUE);
570 LOG("enable resume button"); 536 gtk_widget_set_sensitive (b_accept, TRUE);
571 gtk_widget_set_sensitive(b_resume, 1); 537 gtk_widget_set_sensitive (b_hangup, TRUE);
572 }else{ 538 gtk_widget_set_sensitive (b_suspend, TRUE);
573 LOG("do not disable resume button (for test)"); 539 gtk_widget_set_sensitive (b_resume, TRUE);
574 gtk_widget_set_sensitive(b_resume, 1); 540 break;
575 }
576 break;
577 case CT_other:
578 //add to phonebook
579 //LOG("CT_rejected ");
580 gtk_widget_set_sensitive(b_contact, 1);
581 gtk_widget_set_sensitive(b_accept, 1);
582 gtk_widget_set_sensitive(b_hangup, 1);
583 gtk_widget_set_sensitive(b_suspend, 1);
584 gtk_widget_set_sensitive(b_resume,1);
585
586 break;
587 541
588 default: 542 default:
589 GNUNET_break(0); 543 GNUNET_break(0);
590 break; 544 break;
591 } 545 }
592 print_call_info(); 546 print_call_info();
593 } 547 }
594 else 548 else
595 { 549 {
596 550 GCG_log("nothing selected");
597 LOG("nothing selected"); 551 //gtk_widget_hide(GTK_WIDGET(GCG_get_main_window_object("GNUNET_GTK_conversation_active_call_list_buttons" )));
598 552 }
599 //gtk_widget_hide(GTK_WIDGET(get_object("GNUNET_GTK_conversation_active_call_list_buttons" ))); 553}
600
601 }
602 554
603} //end function
604 555
605/* 556/**
606 * @brief executed when selecting a different item in active call list 557 * @brief executed when selecting a different item in active call list
607 */ 558 */
608
609void 559void
610GNUNET_CONVERSATION_GTK_on_active_calls_selection_changed() 560GNUNET_CONVERSATION_GTK_on_active_calls_selection_changed()
611{ 561{
612 update_active_call_list_buttons(); 562 update_active_call_list_buttons();
613} 563}
614 564
615 565
616void 566void
617disable_list_buttons() 567disable_list_buttons()
618{ 568{
619 gtk_widget_set_sensitive(b_contact, 0); 569 gtk_widget_set_sensitive (b_contact, FALSE);
620 gtk_widget_set_sensitive(b_accept, 0); 570 gtk_widget_set_sensitive (b_accept, FALSE);
621 gtk_widget_set_sensitive(b_hangup, 0); 571 gtk_widget_set_sensitive (b_hangup, FALSE);
622 gtk_widget_set_sensitive(b_suspend, 0); 572 gtk_widget_set_sensitive (b_suspend, FALSE);
623 gtk_widget_set_sensitive(b_resume, 0); 573 gtk_widget_set_sensitive (b_resume, FALSE);
624} 574}
625 575
626 576
627 577/**
628/*
629 * set_status_icon 578 * set_status_icon
630 * 579 *
631 * available icons: 580 * available icons:
632 * gnunet-conversation-gtk-tray-pending 581 * gnunet-conversation-gtk-tray-pending
633 * gnunet-conversation-gtk-tray-available 582 * gnunet-conversation-gtk-tray-available
@@ -639,122 +588,113 @@ disable_list_buttons()
639 * gnunet-conversation-gtk-tray-call-incoming 588 * gnunet-conversation-gtk-tray-call-incoming
640 * 589 *
641 */ 590 */
642
643void 591void
644set_status_icon (const char *icon_name) 592set_status_icon (const char *icon_name)
645{ 593{
646 GtkImage *status_icon; 594 GtkImage *status_icon;
647 595
648 status_icon = GTK_IMAGE (get_object ("GNUNET_GTK_status_icon")); 596 status_icon = GTK_IMAGE (GCG_get_main_window_object ("GNUNET_GTK_status_icon"));
649 597 gtk_image_set_from_icon_name (status_icon,
650 gtk_image_set_from_icon_name (status_icon, icon_name, GTK_ICON_SIZE_BUTTON); 598 icon_name,
651 599 GTK_ICON_SIZE_BUTTON);
652 //LOG (_("Tray icon changed to: `%s' "), icon_name); 600 GNUNET_GTK_tray_icon_change (icon_name,
653 601 "gnunet-conversation-gtk-status");
654 GNUNET_GTK_tray_icon_change (icon_name, "gnunet-conversation-gtk-status");
655} 602}
656 603
657 604
658/* 605/**
659 * set button text 606 * set button text
607 *
660 * @param button_name name of button 608 * @param button_name name of button
661 * @param label label on the button 609 * @param label label on the button
662 */ 610 */
663
664void 611void
665set_button_text (const char *button_name, const char *label) 612set_button_text (const char *button_name,
613 const char *label)
666{ 614{
667 //GtkButton *button;
668 GtkWidget *button; 615 GtkWidget *button;
669 616
670 button = GTK_WIDGET (get_object (button_name)); 617 button = GTK_WIDGET (GCG_get_main_window_object (button_name));
671 gtk_widget_hide (button); 618 gtk_widget_hide (button);
672} 619}
673 620
674/* 621
622/**
675 * disable button 623 * disable button
676 */ 624 */
677
678void 625void
679disable_button (const char *button_name) 626disable_button (const char *button_name)
680{ 627{
681 //GtkButton *button;
682 GtkWidget *button; 628 GtkWidget *button;
683 629
684 button = GTK_WIDGET (get_object (button_name)); 630 button = GTK_WIDGET (GCG_get_main_window_object (button_name));
685 gtk_widget_hide (button); 631 gtk_widget_hide (button);
686} 632}
687 633
688/* 634
635/**
689 * enable button 636 * enable button
690 */ 637 */
691
692void 638void
693enable_button (const char *button_name) 639enable_button (const char *button_name)
694{ 640{
695 //GtkButton *button; 641 //GtkButton *button;
696 GtkWidget *button; 642 GtkWidget *button;
697 643
698 button = GTK_WIDGET (get_object (button_name)); 644 button = GTK_WIDGET (GCG_get_main_window_object (button_name));
699 gtk_widget_show (button); 645 gtk_widget_show (button);
700} 646}
701 647
648
702/** 649/**
703 * set state of outgoing call 650 * set state of outgoing call
704 */ 651 */
705void 652void
706set_outgoing_call_state(struct GNUNET_CONVERSATION_Call *call, int state) 653set_outgoing_call_state (struct GNUNET_CONVERSATION_Call *call,
654 int state)
707{ 655{
708 LOG("set state to: %u", state);
709 GtkTreeIter gtkiter; 656 GtkTreeIter gtkiter;
710 gint valid = 0; 657 gint valid = 0;
711 gint cl_type; 658 gint cl_type;
712 //FPRINTF (stderr,"set incoming call state:%u caller: ",state);
713
714// LOG (_("set incoming call state:%u caller: "),state);
715
716 valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), &gtkiter );
717
718 if (!valid)
719 GNUNET_break(0);
720
721 while (valid)
722 {
723 gchar *cl_caller_id;
724 gint cl_caller_num;
725 gpointer cl_call;
726 659
727 gtk_tree_model_get ( GTK_TREE_MODEL( active_liststore ), &gtkiter, 660 GCG_log("set state to: %u", state);
728 AL_call, &cl_call, 661 valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), &gtkiter);
729 AL_caller_id,&cl_caller_id,
730 AL_caller_num,&cl_caller_num,
731 AL_type, &cl_type,
732 -1);
733 662
734 if (cl_type == CALL_OUT) { 663 if (!valid)
735 664 GNUNET_break(0);
736 if (call == NULL) // function called by phone event handler 665 while (valid)
737 { 666 {
738 LOG("event handler"); 667 gchar *cl_caller_id;
739 gtk_list_store_set(active_liststore, &gtkiter, 668 gint cl_caller_num;
740 AL_call_state, state, 669 gpointer cl_call;
741 -1); 670
742 switch (state) 671 gtk_tree_model_get ( GTK_TREE_MODEL( active_liststore ), &gtkiter,
743 { 672 AL_call, &cl_call,
744 673 AL_caller_id,&cl_caller_id,
674 AL_caller_num,&cl_caller_num,
675 AL_type, &cl_type,
676 -1);
677 if (cl_type == CALL_OUT)
678 {
679 if (call == NULL) // function called by phone event handler
680 {
681 GCG_log("event handler");
682 gtk_list_store_set(active_liststore, &gtkiter,
683 AL_call_state, state,
684 -1);
685 switch (state)
686 {
745 /** 687 /**
746 * We are the caller and are now ringing the other party (GNS lookup 688 * We are the caller and are now ringing the other party (GNS lookup
747 * succeeded). 689 * succeeded).
748 */ 690 */
749 case GNUNET_CONVERSATION_EC_CALL_RINGING: 691 case GNUNET_CONVERSATION_EC_CALL_RINGING:
750 692 break;
751 break;
752
753 /** 693 /**
754 * We are the caller and are now ready to talk as the callee picked up. 694 * We are the caller and are now ready to talk as the callee picked up.
755 */ 695 */
756 case GNUNET_CONVERSATION_EC_CALL_PICKED_UP: 696 case GNUNET_CONVERSATION_EC_CALL_PICKED_UP:
757 break; 697 break;
758 /** 698 /**
759 * We are the caller and failed to locate a phone record in GNS. 699 * We are the caller and failed to locate a phone record in GNS.
760 * After this invocation, the respective call handle will be 700 * After this invocation, the respective call handle will be
@@ -762,119 +702,102 @@ set_outgoing_call_state(struct GNUNET_CONVERSATION_Call *call, int state)
762 * #GNUNET_CONVERSATION_call_stop or any other function on the 702 * #GNUNET_CONVERSATION_call_stop or any other function on the
763 * call object. 703 * call object.
764 */ 704 */
765 case GNUNET_CONVERSATION_EC_CALL_GNS_FAIL: 705 case GNUNET_CONVERSATION_EC_CALL_GNS_FAIL:
766 gtk_list_store_remove(active_liststore,&gtkiter); 706 gtk_list_store_remove(active_liststore,&gtkiter);
767 disable_list_buttons(); 707 disable_list_buttons();
768 break; 708 break;
769
770 /** 709 /**
771 * We are the caller and the callee called 710 * We are the caller and the callee called
772 * #GNUNET_CONVERSATION_caller_hang_up. After this invocation, the 711 * #GNUNET_CONVERSATION_caller_hang_up. After this invocation, the
773 * respective call handle will be automatically destroyed and the 712 * respective call handle will be automatically destroyed and the
774 * client must no longer call #GNUNET_CONVERSATION_call_stop. 713 * client must no longer call #GNUNET_CONVERSATION_call_stop.
775 */ 714 */
776 case GNUNET_CONVERSATION_EC_CALL_HUNG_UP: 715 case GNUNET_CONVERSATION_EC_CALL_HUNG_UP:
777 gtk_list_store_remove(active_liststore,&gtkiter); 716 gtk_list_store_remove(active_liststore,&gtkiter);
778 disable_list_buttons(); 717 disable_list_buttons();
779 break; 718 break;
780
781 /** 719 /**
782 * We are the caller and the callee suspended the call. Note that 720 * We are the caller and the callee suspended the call. Note that
783 * both sides can independently suspend and resume calls; a call is 721 * both sides can independently suspend and resume calls; a call is
784 * only "working" of both sides are active. 722 * only "working" of both sides are active.
785 */ 723 */
786 case GNUNET_CONVERSATION_EC_CALL_SUSPENDED: 724 case GNUNET_CONVERSATION_EC_CALL_SUSPENDED:
787 break; 725 break;
788
789 /** 726 /**
790 * We are the caller and the callee suspended the call. Note that 727 * We are the caller and the callee suspended the call. Note that
791 * both sides can independently suspend and resume calls; a call is 728 * both sides can independently suspend and resume calls; a call is
792 * only "working" of both sides are active. 729 * only "working" of both sides are active.
793 */ 730 */
794 case GNUNET_CONVERSATION_EC_CALL_RESUMED: 731 case GNUNET_CONVERSATION_EC_CALL_RESUMED:
795 break; 732 break;
796
797 /** 733 /**
798 * We had an error handing the call, and are now restarting it 734 * We had an error handing the call, and are now restarting it
799 * (back to lookup). This happens, for example, if the peer 735 * (back to lookup). This happens, for example, if the peer
800 * is restarted during a call. 736 * is restarted during a call.
801 */ 737 */
802 case GNUNET_CONVERSATION_EC_CALL_ERROR: 738 case GNUNET_CONVERSATION_EC_CALL_ERROR:
803 break; 739 break;
804 740 default:
805 default: 741 break;
806 break; 742 }
807 } 743 }
808 744 else if (call == cl_call) // function called for specific call
809 745 {
810 746 //GCG_log (_("setting state for call:%u row: %u state: %u"),cl_caller_num,row_count,state);
811
812
813
814 }
815 else if (call == cl_call) // function called for specific call
816 {
817 //LOG (_("setting state for call:%u row: %u state: %u"),cl_caller_num,row_count,state);
818
819 switch (state)
820 {
821 case CT_hangup:
822 //LOG("remove line cause hangup");
823 gtk_list_store_remove(active_liststore,&gtkiter);
824 disable_list_buttons();
825 break;
826
827 case CT_rejected:
828 //LOG("remove line cause rejected");
829 gtk_list_store_remove(active_liststore,&gtkiter);
830 disable_list_buttons();
831 break;
832 default:
833
834 gtk_list_store_set(active_liststore, &gtkiter,
835 AL_caller_state, state,
836 -1);
837 break;
838
839 }//end switch
840 }//end call=cl_call
841 } //end cl_type
842 g_free (cl_caller_id);
843 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), &gtkiter);
844
845 }//end while
846
847 //update statsbar
848 update_status("");
849
850 747
748 switch (state)
749 {
750 case CT_hangup:
751 //GCG_log("remove line cause hangup");
752 gtk_list_store_remove(active_liststore,&gtkiter);
753 disable_list_buttons();
754 break;
755 case CT_rejected:
756 //GCG_log("remove line cause rejected");
757 gtk_list_store_remove(active_liststore,&gtkiter);
758 disable_list_buttons();
759 break;
760 default:
761 gtk_list_store_set(active_liststore, &gtkiter,
762 AL_caller_state, state,
763 -1);
764 break;
765 }//end switch
766 }//end call=cl_call
767 } //end cl_type
768 g_free (cl_caller_id);
769 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), &gtkiter);
851 770
771 }//end while
772 GCG_update_status ("");
852} 773}
853 774
775
854/** 776/**
855 * set call state of a incoming call 777 * set call state of a incoming call
856 */ 778 */
857static void 779static void
858set_incoming_call_state(struct GNUNET_CONVERSATION_Caller *caller, int state) 780set_incoming_call_state (struct GNUNET_CONVERSATION_Caller *caller,
781 int state)
859{ 782{
860 GtkTreeIter gtkiter; 783 GtkTreeIter gtkiter;
861 gint valid = 0; 784 gint valid = 0;
862 //FPRINTF (stderr,"set incoming call state:%u caller: ",state); 785 //FPRINTF (stderr,"set incoming call state:%u caller: ",state);
863 786
864// LOG (_("set incoming call state:%u caller: "),state); 787// GCG_log (_("set incoming call state:%u caller: "),state);
865 788
866 valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), &gtkiter ); 789 valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), &gtkiter );
867 790
868 if (!valid) 791 if (!valid)
869 GNUNET_break(0); 792 GNUNET_break(0);
870 793
871 while (valid) 794 while (valid)
872 { 795 {
873 gchar *cl_caller_id; 796 gchar *cl_caller_id;
874 gint cl_caller_num; 797 gint cl_caller_num;
875 gpointer cl_caller; 798 gpointer cl_caller;
876 799
877 gtk_tree_model_get ( GTK_TREE_MODEL( active_liststore ), &gtkiter, 800 gtk_tree_model_get ( GTK_TREE_MODEL( active_liststore ), &gtkiter,
878 AL_caller, &cl_caller, 801 AL_caller, &cl_caller,
879 AL_caller_id,&cl_caller_id, 802 AL_caller_id,&cl_caller_id,
880 AL_caller_num,&cl_caller_num 803 AL_caller_num,&cl_caller_num
@@ -882,47 +805,41 @@ set_incoming_call_state(struct GNUNET_CONVERSATION_Caller *caller, int state)
882 805
883 if (caller == cl_caller) 806 if (caller == cl_caller)
884 { 807 {
885 //LOG (_("setting state for call:%u row: %u state: %u"),cl_caller_num,row_count,state); 808 //GCG_log (_("setting state for call:%u row: %u state: %u"),cl_caller_num,row_count,state);
886 809
887 switch (state) 810 switch (state)
888 { 811 {
889 case CT_hangup: 812 case CT_hangup:
890 //LOG("remove line cause hangup"); 813 //GCG_log("remove line cause hangup");
891 gtk_list_store_remove(active_liststore,&gtkiter); 814 gtk_list_store_remove(active_liststore,&gtkiter);
892 disable_list_buttons(); 815 disable_list_buttons();
893 816
894 break; 817 break;
895 818
896 case CT_rejected: 819 case CT_rejected:
897 //LOG("remove line cause rejected"); 820 //GCG_log("remove line cause rejected");
898 gtk_list_store_remove(active_liststore,&gtkiter); 821 gtk_list_store_remove(active_liststore,&gtkiter);
899 disable_list_buttons(); 822 disable_list_buttons();
900 823
901 break; 824 break;
902 default: 825 default:
903 826
904 gtk_list_store_set(active_liststore, &gtkiter, 827 gtk_list_store_set(active_liststore, &gtkiter,
905 AL_caller_state, state, 828 AL_caller_state, state,
906 -1); 829 -1);
907 break; 830 break;
908 831
909 }//end switch 832 }//end switch
910 }//endif 833 }//endif
911 834
912 g_free (cl_caller_id); 835 g_free (cl_caller_id);
913 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), &gtkiter); 836 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), &gtkiter);
914
915 }//end while
916
917 //update statsbar
918 update_status("");
919
920 837
838 }//end while
839 GCG_update_status("");
921} 840}
922 841
923 842
924
925
926/** 843/**
927 * Function called with an event emitted by a phone. 844 * Function called with an event emitted by a phone.
928 * 845 *
@@ -932,27 +849,25 @@ set_incoming_call_state(struct GNUNET_CONVERSATION_Caller *caller, int state)
932 * @param caller_id name of the caller in GNS 849 * @param caller_id name of the caller in GNS
933 */ 850 */
934static void 851static void
935phone_event_handler (void *cls, enum GNUNET_CONVERSATION_PhoneEventCode code, 852phone_event_handler (void *cls,
853 enum GNUNET_CONVERSATION_PhoneEventCode code,
936 struct GNUNET_CONVERSATION_Caller *caller, 854 struct GNUNET_CONVERSATION_Caller *caller,
937 const char *caller_id) 855 const char *caller_id)
938{ 856{
939 857 GtkTreeIter gtkiter;
940 //gtk 858 GtkTreeIter gtkiter1;
941 GtkTreeIter gtkiter; 859 gboolean valid;
942 GtkTreeIter gtkiter1;
943 gboolean valid;
944
945 860
946 switch (code) 861 switch (code)
947 { 862 {
948 case GNUNET_CONVERSATION_EC_PHONE_RING: 863 case GNUNET_CONVERSATION_EC_PHONE_RING:
949 //increment call # 864 //increment call #
950 caller_num_gen++; 865 caller_num_gen++;
951 866
952 867
953 LOG (_("A Incoming call from `%s' with number %u\n"), caller_id, 868 GCG_log (_("A Incoming call from `%s' with number %u\n"), caller_id,
954 caller_num_gen); 869 caller_num_gen);
955 870
956 //old 871 //old
957 struct CallList *cl; 872 struct CallList *cl;
958 873
@@ -961,15 +876,15 @@ phone_event_handler (void *cls, enum GNUNET_CONVERSATION_PhoneEventCode code,
961 cl->caller_id = GNUNET_strdup (caller_id); 876 cl->caller_id = GNUNET_strdup (caller_id);
962 cl->caller_num = caller_num_gen; 877 cl->caller_num = caller_num_gen;
963 GNUNET_CONTAINER_DLL_insert (cl_head, cl_tail, cl); 878 GNUNET_CONTAINER_DLL_insert (cl_head, cl_tail, cl);
964 //gtk 879 //gtk
965 gtk_list_store_append (active_liststore, &gtkiter); 880 gtk_list_store_append (active_liststore, &gtkiter);
966 881
967 gtk_list_store_set (active_liststore, &gtkiter, 882 gtk_list_store_set (active_liststore, &gtkiter,
968 AL_caller_id, caller_id, 883 AL_caller_id, caller_id,
969 AL_caller, caller, 884 AL_caller, caller,
970 AL_caller_num, caller_num_gen, 885 AL_caller_num, caller_num_gen,
971 AL_caller_state, CT_ringing, 886 AL_caller_state, CT_ringing,
972 AL_type, CALL_IN 887 AL_type, CALL_IN
973 ,-1); 888 ,-1);
974 889
975 890
@@ -977,12 +892,12 @@ phone_event_handler (void *cls, enum GNUNET_CONVERSATION_PhoneEventCode code,
977 892
978 case GNUNET_CONVERSATION_EC_PHONE_HUNG_UP: 893 case GNUNET_CONVERSATION_EC_PHONE_HUNG_UP:
979 //gtk 894 //gtk
980 895
981 valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), &gtkiter1 ); 896 valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( active_liststore ), &gtkiter1 );
982 897
983 if (!valid) 898 if (!valid)
984 GNUNET_break(0); 899 GNUNET_break(0);
985 900
986 while (valid) 901 while (valid)
987 { 902 {
988 //FPRINTF(stderr,"GNUNET_CONVERSATION_EC_PHONE_HUNG_UP: while valid"); 903 //FPRINTF(stderr,"GNUNET_CONVERSATION_EC_PHONE_HUNG_UP: while valid");
@@ -990,28 +905,28 @@ phone_event_handler (void *cls, enum GNUNET_CONVERSATION_PhoneEventCode code,
990 gchar *str_data; 905 gchar *str_data;
991 gint int_data; 906 gint int_data;
992 gpointer cl_caller; 907 gpointer cl_caller;
993 908
994 gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), &gtkiter1, 909 gtk_tree_model_get (GTK_TREE_MODEL(active_liststore), &gtkiter1,
995 AL_caller, &cl_caller, 910 AL_caller, &cl_caller,
996 AL_caller_id,&str_data, 911 AL_caller_id,&str_data,
997 AL_caller_num,&int_data,-1); 912 AL_caller_num,&int_data,-1);
998 if (caller == cl_caller) 913 if (caller == cl_caller)
999 { 914 {
1000 915
1001 LOG (_("phone hung up:%s number: %u "), str_data,int_data); 916 GCG_log (_("phone hung up:%s number: %u "), str_data,int_data);
1002 set_incoming_call_state(caller,CT_rejected); 917 set_incoming_call_state(caller,CT_rejected);
1003 break ; 918 break ;
1004 } 919 }
1005 g_free (str_data); 920 g_free (str_data);
1006 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), &gtkiter1); 921 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(active_liststore), &gtkiter1);
1007 } 922 }
1008 923
1009 924
1010 925
1011 phone_state = PS_LISTEN; 926 phone_state = PS_LISTEN;
1012 //add to call history list 927 //add to call history list
1013 //history_add(CH_HANGUP, cl->caller_id); 928 //history_add(CH_HANGUP, cl->caller_id);
1014 929
1015 break; 930 break;
1016 931
1017 } 932 }
@@ -1026,25 +941,29 @@ phone_event_handler (void *cls, enum GNUNET_CONVERSATION_PhoneEventCode code,
1026 * @param code type of the event issued by the caller 941 * @param code type of the event issued by the caller
1027 */ 942 */
1028static void 943static void
1029caller_event_handler (void *cls, enum GNUNET_CONVERSATION_CallerEventCode code) 944caller_event_handler (void *cls,
945 enum GNUNET_CONVERSATION_CallerEventCode code)
1030{ 946{
1031 947
1032 if (cls == NULL){ 948 if (cls == NULL)
1033 LOG("caller_event_handler: cls == NULL"); 949 {
1034 GNUNET_break(0); 950 GCG_log("caller_event_handler: cls == NULL");
1035 } else { 951 GNUNET_break(0);
952 }
953 else
954 {
1036 struct CallList *cl = cls; 955 struct CallList *cl = cls;
1037 956
1038 switch (code) 957 switch (code)
1039 { 958 {
1040 case GNUNET_CONVERSATION_EC_CALLER_SUSPEND: 959 case GNUNET_CONVERSATION_EC_CALLER_SUSPEND:
1041 //TODO: should this be cls? not cl->caller 960 //TODO: should this be cls? not cl->caller
1042 set_incoming_call_state(cl->caller,CT_suspended); 961 set_incoming_call_state(cl->caller,CT_suspended);
1043 LOG (_("Call from `%s' suspended by other user\n"), cl->caller_id); 962 GCG_log (_("Call from `%s' suspended by other user\n"), cl->caller_id);
1044 break; 963 break;
1045 case GNUNET_CONVERSATION_EC_CALLER_RESUME: 964 case GNUNET_CONVERSATION_EC_CALLER_RESUME:
1046 set_incoming_call_state(cl->caller,CT_active); 965 set_incoming_call_state(cl->caller,CT_active);
1047 LOG (_("Call from `%s' resumed by other user\n"), cl->caller_id); 966 GCG_log (_("Call from `%s' resumed by other user\n"), cl->caller_id);
1048 break; 967 break;
1049 } 968 }
1050 } 969 }
@@ -1062,7 +981,7 @@ start_phone ()
1062 GtkLabel *label; 981 GtkLabel *label;
1063 if (NULL == caller_id) 982 if (NULL == caller_id)
1064 { 983 {
1065 LOG (_("Ego `%s' no longer available, phone is now down.\n"), ego_name); 984 GCG_log (_("Ego `%s' no longer available, phone is now down.\n"), ego_name);
1066 phone_state = PS_LOOKUP_EGO; 985 phone_state = PS_LOOKUP_EGO;
1067 return; 986 return;
1068 } 987 }
@@ -1073,7 +992,7 @@ start_phone ()
1073 /* FIXME: get record and print full GNS record info later here... */ 992 /* FIXME: get record and print full GNS record info later here... */
1074 if (NULL == phone) 993 if (NULL == phone)
1075 { 994 {
1076 LOG ("%s", _("Failed to setup phone (internal error)\n")); 995 GCG_log ("%s", _("Failed to setup phone (internal error)\n"));
1077 phone_state = PS_ERROR; 996 phone_state = PS_ERROR;
1078 } 997 }
1079 else 998 else
@@ -1084,13 +1003,14 @@ start_phone ()
1084 GNUNET_GNSRECORD_value_to_string (rd.record_type, rd.data, 1003 GNUNET_GNSRECORD_value_to_string (rd.record_type, rd.data,
1085 rd.data_size); 1004 rd.data_size);
1086 1005
1087 LOG (_("address: `%s' \n"), address); 1006 GCG_log (_("address: `%s' \n"), address);
1088 1007
1089 label = GTK_LABEL(get_object("GNUNET_CONVERSATION_GTK_my_address")); 1008 label = GTK_LABEL(GCG_get_main_window_object("GNUNET_CONVERSATION_GTK_my_address"));
1090 gtk_label_set_text(label, address); 1009 gtk_label_set_text(label, address);
1091 1010
1092 if (verbose) 1011 if (verbose)
1093 LOG (_("Phone active on line %u\n"), (unsigned int) line); 1012 GCG_log (_("Phone active on line %u\n"),
1013 (unsigned int) line);
1094 phone_state = PS_LISTEN; 1014 phone_state = PS_LISTEN;
1095 } 1015 }
1096 do_status(); 1016 do_status();
@@ -1104,50 +1024,51 @@ start_phone ()
1104 * @param code type of the event on the call 1024 * @param code type of the event on the call
1105 */ 1025 */
1106static void 1026static void
1107call_event_handler (void *cls, enum GNUNET_CONVERSATION_CallEventCode code) 1027call_event_handler (void *cls,
1028 enum GNUNET_CONVERSATION_CallEventCode code)
1108{ 1029{
1109 //struct OutgoingCallClosure *cl = cls; 1030 //struct OutgoingCallClosure *cl = cls;
1110 1031
1111 //LOG("call event handler code: %u num: %u", code, cl->call_num); 1032 //GCG_log("call event handler code: %u num: %u", code, cl->call_num);
1112 1033
1113 //if (cls == NULL){ 1034 //if (cls == NULL){
1114 set_outgoing_call_state(NULL, code); 1035 set_outgoing_call_state(NULL, code);
1115 //GNUNET_break(0); 1036 //GNUNET_break(0);
1116 //} else 1037 //} else
1117 //{ 1038 //{
1118 switch (code) 1039 switch (code)
1119 { 1040 {
1120 case GNUNET_CONVERSATION_EC_CALL_RINGING: 1041 case GNUNET_CONVERSATION_EC_CALL_RINGING:
1121 GNUNET_break (CS_RESOLVING == call_state); 1042 GNUNET_break (CS_RESOLVING == call_state);
1122 LOG (_("Resolved address of `%s'. Now ringing other party."), peer_name); 1043 GCG_log (_("Resolved address of `%s'. Now ringing other party."), peer_name);
1123 // set_outgoing_call_state(cls, CT_ringing); 1044 // set_outgoing_call_state(cls, CT_ringing);
1124 1045
1125 call_state = CS_RINGING; 1046 call_state = CS_RINGING;
1126 break; 1047 break;
1127 case GNUNET_CONVERSATION_EC_CALL_PICKED_UP: 1048 case GNUNET_CONVERSATION_EC_CALL_PICKED_UP:
1128 GNUNET_break (CS_RINGING == call_state); 1049 GNUNET_break (CS_RINGING == call_state);
1129 LOG (_("Connection established to `%s'"), peer_name); 1050 GCG_log (_("Connection established to `%s'"), peer_name);
1130 call_state = CS_CONNECTED; 1051 call_state = CS_CONNECTED;
1131 break; 1052 break;
1132 case GNUNET_CONVERSATION_EC_CALL_GNS_FAIL: 1053 case GNUNET_CONVERSATION_EC_CALL_GNS_FAIL:
1133 GNUNET_break (CS_RESOLVING == call_state); 1054 GNUNET_break (CS_RESOLVING == call_state);
1134 LOG (_("Failed to resolve %s in ego `%s'"), peer_name, ego_name); 1055 GCG_log (_("Failed to resolve %s in ego `%s'"), peer_name, ego_name);
1135 call = NULL; 1056 call = NULL;
1136 break; 1057 break;
1137 case GNUNET_CONVERSATION_EC_CALL_HUNG_UP: 1058 case GNUNET_CONVERSATION_EC_CALL_HUNG_UP:
1138 LOG ("%s", _("Call terminated")); 1059 GCG_log ("%s", _("Call terminated"));
1139 call = NULL; 1060 call = NULL;
1140 break; 1061 break;
1141 case GNUNET_CONVERSATION_EC_CALL_SUSPENDED: 1062 case GNUNET_CONVERSATION_EC_CALL_SUSPENDED:
1142 GNUNET_break (CS_CONNECTED == call_state); 1063 GNUNET_break (CS_CONNECTED == call_state);
1143 LOG (_("Connection to `%s' suspended (by other user)\n"), peer_name); 1064 GCG_log (_("Connection to `%s' suspended (by other user)\n"), peer_name);
1144 break; 1065 break;
1145 case GNUNET_CONVERSATION_EC_CALL_RESUMED: 1066 case GNUNET_CONVERSATION_EC_CALL_RESUMED:
1146 GNUNET_break (CS_CONNECTED == call_state); 1067 GNUNET_break (CS_CONNECTED == call_state);
1147 LOG (_("Connection to `%s' resumed (by other user)\n"), peer_name); 1068 GCG_log (_("Connection to `%s' resumed (by other user)\n"), peer_name);
1148 break; 1069 break;
1149 case GNUNET_CONVERSATION_EC_CALL_ERROR: 1070 case GNUNET_CONVERSATION_EC_CALL_ERROR:
1150 LOG ("GNUNET_CONVERSATION_EC_CALL_ERROR %s", peer_name); 1071 GCG_log ("GNUNET_CONVERSATION_EC_CALL_ERROR %s", peer_name);
1151 } 1072 }
1152 //} 1073 //}
1153} 1074}
@@ -1164,24 +1085,24 @@ do_call (const char *arg)
1164{ 1085{
1165 if (NULL == caller_id) 1086 if (NULL == caller_id)
1166 { 1087 {
1167 LOG (_("Ego `%s' not available\n"), ego_name); 1088 GCG_log (_("Ego `%s' not available\n"), ego_name);
1168 return; 1089 return;
1169 } 1090 }
1170 if (NULL != call) 1091 if (NULL != call)
1171 { 1092 {
1172 LOG (_("You are calling someone else already, hang up first!\n")); 1093 GCG_log (_("You are calling someone else already, hang up first!\n"));
1173 return; 1094 return;
1174 } 1095 }
1175 switch (phone_state) 1096 switch (phone_state)
1176 { 1097 {
1177 case PS_LOOKUP_EGO: 1098 case PS_LOOKUP_EGO:
1178 LOG (_("Ego `%s' not available\n"), ego_name); 1099 GCG_log (_("Ego `%s' not available\n"), ego_name);
1179 return; 1100 return;
1180 case PS_LISTEN: 1101 case PS_LISTEN:
1181 /* ok to call! */ 1102 /* ok to call! */
1182 break; 1103 break;
1183 case PS_ACCEPTED: 1104 case PS_ACCEPTED:
1184 LOG (_ 1105 GCG_log (_
1185 ("You are answering call from `%s', hang up or suspend that call first!\n"), 1106 ("You are answering call from `%s', hang up or suspend that call first!\n"),
1186 peer_name); 1107 peer_name);
1187 GNUNET_break(0); 1108 GNUNET_break(0);
@@ -1192,7 +1113,7 @@ do_call (const char *arg)
1192 } 1113 }
1193 //GNUNET_free_non_null (peer_name); 1114 //GNUNET_free_non_null (peer_name);
1194 peer_name = GNUNET_strdup (arg); 1115 peer_name = GNUNET_strdup (arg);
1195 LOG (_("now calling: %s"), peer_name); 1116 GCG_log (_("now calling: %s"), peer_name);
1196 call_state = CS_RESOLVING; 1117 call_state = CS_RESOLVING;
1197 GNUNET_assert (NULL == call); 1118 GNUNET_assert (NULL == call);
1198 1119
@@ -1204,7 +1125,7 @@ do_call (const char *arg)
1204 1125
1205 // add call to active call list 1126 // add call to active call list
1206 GtkTreeIter gtkiter; 1127 GtkTreeIter gtkiter;
1207 1128
1208 gtk_list_store_append (active_liststore, &gtkiter); 1129 gtk_list_store_append (active_liststore, &gtkiter);
1209 1130
1210 gtk_list_store_set (active_liststore, &gtkiter, 1131 gtk_list_store_set (active_liststore, &gtkiter,
@@ -1218,10 +1139,10 @@ do_call (const char *arg)
1218 AL_call_state, CS_RESOLVING, 1139 AL_call_state, CS_RESOLVING,
1219 -1 1140 -1
1220 ); 1141 );
1221
1222 1142
1223 UPDATE_STATUS (_("We are calling `%s', his phone should be ringing."), 1143
1224 peer_name); 1144 GCG_update_status (_("We are calling `%s', his phone should be ringing."),
1145 peer_name);
1225 GNUNET_CONVERSATION_GTK_history_add (CH_OUTGOING, peer_name); 1146 GNUNET_CONVERSATION_GTK_history_add (CH_OUTGOING, peer_name);
1226} 1147}
1227 1148
@@ -1240,7 +1161,7 @@ do_accept (struct GNUNET_CONVERSATION_Caller *sel_caller)
1240 1161
1241 if ((NULL != call) && (CS_SUSPENDED != call_state)) 1162 if ((NULL != call) && (CS_SUSPENDED != call_state))
1242 { 1163 {
1243 LOG (_("You are calling someone else already, hang up first!\n")); 1164 GCG_log (_("You are calling someone else already, hang up first!\n"));
1244 GNUNET_break(0); 1165 GNUNET_break(0);
1245 return; 1166 return;
1246 } 1167 }
@@ -1253,7 +1174,7 @@ do_accept (struct GNUNET_CONVERSATION_Caller *sel_caller)
1253 /* this is the expected state */ 1174 /* this is the expected state */
1254 break; 1175 break;
1255 case PS_ACCEPTED: 1176 case PS_ACCEPTED:
1256 LOG (_ 1177 GCG_log (_
1257 ("You are answering call from `%s', hang up or suspend that call first!\n"), 1178 ("You are answering call from `%s', hang up or suspend that call first!\n"),
1258 peer_name); 1179 peer_name);
1259 GNUNET_break(0); 1180 GNUNET_break(0);
@@ -1265,7 +1186,7 @@ do_accept (struct GNUNET_CONVERSATION_Caller *sel_caller)
1265 1186
1266 phone_state = PS_ACCEPTED; 1187 phone_state = PS_ACCEPTED;
1267 set_incoming_call_state(sel_caller,CT_active); 1188 set_incoming_call_state(sel_caller,CT_active);
1268 1189
1269 for (cl = cl_head; cl; cl = cl->next) 1190 for (cl = cl_head; cl; cl = cl->next)
1270 { 1191 {
1271 /* FIXME: this may not be unique enough to identify the right item! 1192 /* FIXME: this may not be unique enough to identify the right item!
@@ -1282,49 +1203,40 @@ do_accept (struct GNUNET_CONVERSATION_Caller *sel_caller)
1282} 1203}
1283 1204
1284 1205
1285
1286
1287
1288
1289
1290
1291/** 1206/**
1292 * Suspending a call 1207 * Suspending a call
1293 * 1208 *
1294 * @param args arguments given to the command 1209 * @param args arguments given to the command
1295 */ 1210 */
1296
1297static void 1211static void
1298do_suspend () 1212do_suspend ()
1299{ 1213{
1300
1301 /* 1214 /*
1302 switch (phone_state) 1215 switch (phone_state)
1303 { 1216 {
1304 case PS_LOOKUP_EGO: 1217 case PS_LOOKUP_EGO:
1305 case PS_LISTEN: 1218 case PS_LISTEN:
1306 case PS_ERROR: 1219 case PS_ERROR:
1307 LOG ("%s", _(" There is no call that could be suspended right now. (PS_ERROR)")); 1220 GCG_log ("%s", _(" There is no call that could be suspended right now. (PS_ERROR)"));
1308 return; 1221 return;
1309 case PS_ACCEPTED: 1222 case PS_ACCEPTED:
1310 // expected state, do rejection logic 1223 // expected state, do rejection logic
1311 break; 1224 break;
1312 } 1225 }
1313 */ 1226 */
1314 if (call_selected != NULL && caller_selected != NULL) 1227 if (call_selected != NULL && caller_selected != NULL)
1315 { 1228 {
1316 LOG("this shoud not be possible"); 1229 GCG_log("this shoud not be possible");
1317 GNUNET_break(0); 1230 GNUNET_break(0);
1318 } 1231 }
1319 else 1232 else
1320 { 1233 {
1321
1322 // outgoing 1234 // outgoing
1323 if (NULL != call_selected) 1235 if (NULL != call_selected)
1324 { 1236 {
1325 GNUNET_CONVERSATION_call_suspend (call_selected); 1237 GNUNET_CONVERSATION_call_suspend (call_selected);
1326 set_outgoing_call_state(call_selected,CT_suspended); 1238 set_outgoing_call_state(call_selected,CT_suspended);
1327 1239
1328 return; 1240 return;
1329 } 1241 }
1330 1242
@@ -1354,23 +1266,23 @@ do_resume ()
1354 { 1266 {
1355 case PS_LOOKUP_EGO: 1267 case PS_LOOKUP_EGO:
1356 case PS_ERROR: 1268 case PS_ERROR:
1357 LOG ("%s", _("There is no call that could be resumed right now.(PS_ERROR)")); 1269 GCG_log ("%s", _("There is no call that could be resumed right now.(PS_ERROR)"));
1358 return; 1270 return;
1359 case PS_LISTEN: 1271 case PS_LISTEN:
1360 break; 1272 break;
1361 case PS_ACCEPTED: 1273 case PS_ACCEPTED:
1362 LOG (_("Already talking with `%s', cannot resume a call right now."), 1274 GCG_log (_("Already talking with `%s', cannot resume a call right now."),
1363 peer_name); 1275 peer_name);
1364 return; 1276 return;
1365 } 1277 }
1366//// 1278////
1367 if (call_selected != NULL && caller_selected != NULL) 1279 if (call_selected != NULL && caller_selected != NULL)
1368 { 1280 {
1369 LOG("this shoud not be possible"); 1281 GCG_log("this shoud not be possible");
1370 GNUNET_break(0); 1282 GNUNET_break(0);
1371 return; 1283 return;
1372 } 1284 }
1373 else 1285 else
1374 { 1286 {
1375 1287
1376 // outgoing 1288 // outgoing
@@ -1378,7 +1290,7 @@ do_resume ()
1378 { 1290 {
1379 GNUNET_CONVERSATION_call_resume (call_selected, speaker, mic); 1291 GNUNET_CONVERSATION_call_resume (call_selected, speaker, mic);
1380 set_outgoing_call_state(call_selected,CT_active); 1292 set_outgoing_call_state(call_selected,CT_active);
1381 1293
1382 return; 1294 return;
1383 } 1295 }
1384 1296
@@ -1395,7 +1307,7 @@ do_resume ()
1395 } 1307 }
1396 1308
1397// 1309//
1398//// 1310////
1399} 1311}
1400 1312
1401 1313
@@ -1407,7 +1319,7 @@ do_resume ()
1407static void 1319static void
1408do_reject () 1320do_reject ()
1409{ 1321{
1410 1322
1411 if (call_selected == NULL && caller_selected == NULL){ 1323 if (call_selected == NULL && caller_selected == NULL){
1412 GNUNET_break(0); 1324 GNUNET_break(0);
1413 }else { 1325 }else {
@@ -1416,10 +1328,10 @@ do_reject ()
1416 if (NULL != call_selected) 1328 if (NULL != call_selected)
1417 { 1329 {
1418 set_outgoing_call_state(call_selected,CT_hangup); 1330 set_outgoing_call_state(call_selected,CT_hangup);
1419 1331
1420 GNUNET_CONVERSATION_call_stop(call); 1332 GNUNET_CONVERSATION_call_stop(call);
1421 //GNUNET_CONVERSATION_call_stop (call_selected); 1333 //GNUNET_CONVERSATION_call_stop (call_selected);
1422 1334
1423 call = NULL; 1335 call = NULL;
1424 call_selected = NULL; 1336 call_selected = NULL;
1425 return; 1337 return;
@@ -1441,10 +1353,6 @@ do_reject ()
1441} 1353}
1442 1354
1443 1355
1444
1445
1446
1447
1448/** 1356/**
1449 * Function called by identity service with information about egos. 1357 * Function called by identity service with information about egos.
1450 * 1358 *
@@ -1454,37 +1362,31 @@ do_reject ()
1454 * @param name name of the ego 1362 * @param name name of the ego
1455 */ 1363 */
1456static void 1364static void
1457identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, 1365identity_cb (void *cls,
1366 struct GNUNET_IDENTITY_Ego *ego,
1367 void **ctx,
1458 const char *name) 1368 const char *name)
1459{ 1369{
1460
1461 struct GNUNET_CRYPTO_EcdsaPublicKey pk; 1370 struct GNUNET_CRYPTO_EcdsaPublicKey pk;
1462
1463 GtkTreeIter iter; 1371 GtkTreeIter iter;
1464
1465 if (NULL != ego)
1466 {
1467 GNUNET_IDENTITY_ego_get_public_key (ego, &pk);
1468
1469 fprintf (stderr, "main identity_cb: %s \n", name);
1470
1471 1372
1472 gtk_list_store_insert_with_values (zone_liststore, 1373 if (NULL != ego)
1374 {
1375 GNUNET_IDENTITY_ego_get_public_key (ego, &pk);
1376 gtk_list_store_insert_with_values (zone_liststore,
1473 &iter, -1, 1377 &iter, -1,
1474 0, name, 1378 0, name,
1475 1, ego, 1379 1, ego,
1476 -1); 1380 -1);
1477
1478 } 1381 }
1479
1480
1481 if (NULL == name) 1382 if (NULL == name)
1482 return; 1383 return;
1483 if (ego == caller_id) 1384 if (ego == caller_id)
1484 { 1385 {
1485 if (verbose) 1386 if (verbose)
1486 LOG (_("Name of our ego changed to `%s'\n"), name); 1387 GCG_log (_("Name of our ego changed to `%s'\n"),
1487 //GNUNET_free (ego_name); 1388 name);
1389 GNUNET_free_non_null (ego_name);
1488 ego_name = GNUNET_strdup (name); 1390 ego_name = GNUNET_strdup (name);
1489 return; 1391 return;
1490 } 1392 }
@@ -1493,18 +1395,20 @@ identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
1493 if (NULL == ego) 1395 if (NULL == ego)
1494 { 1396 {
1495 if (verbose) 1397 if (verbose)
1496 LOG (_("Our ego `%s' was deleted!\n"), ego_name); 1398 GCG_log (_("Our ego `%s' was deleted!\n"),
1399 ego_name);
1497 caller_id = NULL; 1400 caller_id = NULL;
1498 return; 1401 return;
1499 } 1402 }
1500
1501 caller_id = ego; 1403 caller_id = ego;
1502 1404
1503 // do not remove this, it tells the phone which line to use 1405 // do not remove this, it tells the phone which line to use
1504 GNUNET_CONFIGURATION_set_value_number (cfg, "CONVERSATION", "LINE", line); 1406 GNUNET_CONFIGURATION_set_value_number (cfg,
1505 1407 "CONVERSATION",
1408 "LINE",
1409 line);
1506 if (NULL == phone) 1410 if (NULL == phone)
1507 start_phone(); 1411 start_phone();
1508} 1412}
1509 1413
1510/** 1414/**
@@ -1513,7 +1417,7 @@ identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
1513 * @return configuration handle 1417 * @return configuration handle
1514 */ 1418 */
1515const struct GNUNET_CONFIGURATION_Handle * 1419const struct GNUNET_CONFIGURATION_Handle *
1516GIG_get_configuration () 1420GCG_get_configuration ()
1517{ 1421{
1518 /* FIXME: Configuration handle returned is const, but we DO alter the config */ 1422 /* FIXME: Configuration handle returned is const, but we DO alter the config */
1519 return GNUNET_GTK_main_loop_get_configuration (ml); 1423 return GNUNET_GTK_main_loop_get_configuration (ml);
@@ -1536,7 +1440,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1536 //struct OperationContext *oc; 1440 //struct OperationContext *oc;
1537 1441
1538/* 1442/*
1539 GIG_advertise_shutdown_ (); 1443 GCG_advertise_shutdown_ ();
1540 while (NULL != (oc = oc_head)) 1444 while (NULL != (oc = oc_head))
1541 { 1445 {
1542 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1446 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -1559,8 +1463,6 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1559} 1463}
1560 1464
1561 1465
1562
1563
1564/** 1466/**
1565 * Callback invoked if the application is supposed to exit. 1467 * Callback invoked if the application is supposed to exit.
1566 * 1468 *
@@ -1568,7 +1470,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1568 * @param user_data unused 1470 * @param user_data unused
1569 */ 1471 */
1570void 1472void
1571GNUNET_GTK_conversation_quit_cb (GObject * object, gpointer user_data) 1473GNUNET_GTK_conversation_quit_cb (GObject *object,
1474 gpointer user_data)
1572{ 1475{
1573 if (NULL != call) 1476 if (NULL != call)
1574 { 1477 {
@@ -1591,7 +1494,7 @@ GNUNET_GTK_conversation_quit_cb (GObject * object, gpointer user_data)
1591 // ns = NULL; 1494 // ns = NULL;
1592 //} 1495 //}
1593 GNUNET_CONVERSATION_GTK_CONTACTS_shutdown(); 1496 GNUNET_CONVERSATION_GTK_CONTACTS_shutdown();
1594 1497
1595 GNUNET_SPEAKER_destroy (speaker); 1498 GNUNET_SPEAKER_destroy (speaker);
1596 speaker = NULL; 1499 speaker = NULL;
1597 GNUNET_MICROPHONE_destroy (mic); 1500 GNUNET_MICROPHONE_destroy (mic);
@@ -1601,10 +1504,6 @@ GNUNET_GTK_conversation_quit_cb (GObject * object, gpointer user_data)
1601 phone_state = PS_ERROR; 1504 phone_state = PS_ERROR;
1602 1505
1603 GNUNET_SCHEDULER_shutdown (); 1506 GNUNET_SCHEDULER_shutdown ();
1604
1605
1606 //return 0;
1607
1608} 1507}
1609 1508
1610 1509
@@ -1616,35 +1515,34 @@ GNUNET_GTK_conversation_quit_cb (GObject * object, gpointer user_data)
1616 * @param tc schedule context 1515 * @param tc schedule context
1617 */ 1516 */
1618static void 1517static void
1619run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1518run (void *cls,
1519 const struct GNUNET_SCHEDULER_TaskContext *tc)
1620{ 1520{
1621 GtkWindow *main_window; 1521 GtkWindow *main_window;
1622 1522
1623 //line = 0;
1624
1625 ml = cls; 1523 ml = cls;
1626 if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (ml, NULL)) 1524 if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (ml, NULL))
1627 return; 1525 return;
1628 GNUNET_GTK_set_icon_search_path (); 1526 GNUNET_GTK_set_icon_search_path ();
1629 GNUNET_GTK_setup_nls (); 1527 GNUNET_GTK_setup_nls ();
1630 /* setup main window */ 1528 /* setup main window */
1631 main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window")); 1529 main_window = GTK_WINDOW (GCG_get_main_window_object ("GNUNET_GTK_conversation_window"));
1632 main_window = 1530 main_window =
1633 GTK_WINDOW (GNUNET_GTK_plug_me 1531 GTK_WINDOW (GNUNET_GTK_plug_me
1634 ("GNUNET_CONVERSATION_GTK_PLUG", GTK_WIDGET (main_window))); 1532 ("GNUNET_CONVERSATION_GTK_PLUG", GTK_WIDGET (main_window)));
1635 gtk_window_set_default_size (main_window, 700, 700); 1533 gtk_window_set_default_size (main_window, 700, 700);
1636 1534
1637 // active calls 1535 // active calls
1638 active_liststore = 1536 active_liststore =
1639 GTK_LIST_STORE (get_object ("gnunet_conversation_gtk_active_calls_liststore")); 1537 GTK_LIST_STORE (GCG_get_main_window_object ("gnunet_conversation_gtk_active_calls_liststore"));
1640 active_treeview = 1538 active_treeview =
1641 GTK_TREE_VIEW (get_object ("gnunet_conversation_gtk_active_calls_treeview")); 1539 GTK_TREE_VIEW (GCG_get_main_window_object ("gnunet_conversation_gtk_active_calls_treeview"));
1540
1642 1541
1643 1542
1543 // gtk_tree_view_set_activate_on_single_click(contacts_treeview, TRUE);
1644 1544
1645//gtk_tree_view_set_activate_on_single_click(contacts_treeview, TRUE);
1646 1545
1647
1648 // gtk_window_maximize (GTK_WINDOW (main_window)); 1546 // gtk_window_maximize (GTK_WINDOW (main_window));
1649 1547
1650 if (NULL == getenv ("GNUNET_CONVERSATION_GTK_PLUG")) 1548 if (NULL == getenv ("GNUNET_CONVERSATION_GTK_PLUG"))
@@ -1664,33 +1562,30 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1664 1562
1665 if(debug_box_enabled) 1563 if(debug_box_enabled)
1666 { 1564 {
1667 gtk_widget_show(GTK_WIDGET(get_object("GNUNET_CONVERSATION_log_box"))); 1565 gtk_widget_show(GTK_WIDGET(GCG_get_main_window_object("GNUNET_CONVERSATION_log_box")));
1668 } 1566 }
1669 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, 1567 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
1670 NULL); 1568 NULL);
1671 1569
1672 cfg = GIG_get_configuration (); 1570 cfg = GNUNET_CONFIGURATION_dup (GCG_get_configuration ());
1673 1571
1674 speaker = GNUNET_SPEAKER_create_from_hardware (cfg); 1572 speaker = GNUNET_SPEAKER_create_from_hardware (cfg);
1675 mic = GNUNET_MICROPHONE_create_from_hardware (cfg); 1573 mic = GNUNET_MICROPHONE_create_from_hardware (cfg);
1676 1574
1677 b_contact = GTK_WIDGET (get_object ("GNUNET_GTK_conversation_use_current_button")); 1575 b_contact = GTK_WIDGET (GCG_get_main_window_object ("GNUNET_GTK_conversation_use_current_button"));
1678 b_accept = GTK_WIDGET (get_object ("GNUNET_GTK_conversation_accept_button")); 1576 b_accept = GTK_WIDGET (GCG_get_main_window_object ("GNUNET_GTK_conversation_accept_button"));
1679 b_hangup = GTK_WIDGET (get_object ("GNUNET_GTK_conversation_hangup_button")); 1577 b_hangup = GTK_WIDGET (GCG_get_main_window_object ("GNUNET_GTK_conversation_hangup_button"));
1680 b_suspend = GTK_WIDGET (get_object ("GNUNET_GTK_conversation_suspend_button")); 1578 b_suspend = GTK_WIDGET (GCG_get_main_window_object ("GNUNET_GTK_conversation_suspend_button"));
1681 b_resume = GTK_WIDGET (get_object ("GNUNET_GTK_conversation_resume_button")); 1579 b_resume = GTK_WIDGET (GCG_get_main_window_object ("GNUNET_GTK_conversation_resume_button"));
1682
1683
1684
1685 1580
1686 if (NULL == ego_name) 1581 if (NULL == ego_name)
1687 { 1582 {
1688 ego_name = "phone-ego"; 1583 ego_name = "phone-ego";
1689 LOG (_("No ego given, using default: %s "), ego_name); 1584 GCG_log (_("No ego given, using default: %s "), ego_name);
1690 1585
1691 } 1586 }
1692 id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL); 1587 id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL);
1693 1588
1694 GNUNET_CONVERSATION_GTK_CONTACTS_init (); 1589 GNUNET_CONVERSATION_GTK_CONTACTS_init ();
1695} 1590}
1696 1591
@@ -1731,9 +1626,15 @@ main (int argc, char *const *argv)
1731 "gnunet_conversation_gtk_main_window.glade", 1626 "gnunet_conversation_gtk_main_window.glade",
1732 &run)) 1627 &run))
1733 return 1; 1628 return 1;
1629 if (NULL != cfg)
1630 {
1631 GNUNET_CONFIGURATION_destroy (cfg);
1632 cfg = NULL;
1633 }
1734 return 0; 1634 return 0;
1735} 1635}
1736 1636
1637
1737/** 1638/**
1738 * call clicked 1639 * call clicked
1739 */ 1640 */
@@ -1742,7 +1643,7 @@ GNUNET_CONVERSATION_GTK_on_call_clicked ()
1742{ 1643{
1743 GtkEntry *address_entry; 1644 GtkEntry *address_entry;
1744 1645
1745 address_entry = GTK_ENTRY (get_object ("GNUNET_GTK_conversation_address")); 1646 address_entry = GTK_ENTRY (GCG_get_main_window_object ("GNUNET_GTK_conversation_address"));
1746 1647
1747 do_call (gtk_entry_get_text(address_entry)); 1648 do_call (gtk_entry_get_text(address_entry));
1748 //disable_button ("GNUNET_GTK_conversation_accept_button"); 1649 //disable_button ("GNUNET_GTK_conversation_accept_button");
@@ -1775,7 +1676,7 @@ GNUNET_CONVERSATION_GTK_on_accept_clicked ()
1775 } else { 1676 } else {
1776 GNUNET_break(0); 1677 GNUNET_break(0);
1777 } 1678 }
1778 do_status(); 1679 do_status();
1779} 1680}
1780 1681
1781 1682
@@ -1826,7 +1727,7 @@ GNUNET_contact_test ()
1826{ 1727{
1827 GtkTreeIter iter; 1728 GtkTreeIter iter;
1828 char *caller_id = "testje"; 1729 char *caller_id = "testje";
1829 int caller_num = 10; 1730 int caller_num = 10;
1830 1731
1831enum { 1732enum {
1832 AL_caller_id, // *gchar 1733 AL_caller_id, // *gchar
@@ -1841,7 +1742,7 @@ enum {
1841 &iter, -1, 1742 &iter, -1,
1842 0, "test", 1743 0, "test",
1843 -1); 1744 -1);
1844} 1745}
1845 1746
1846/* 1747/*
1847 * @brief outgoing ego selector changed 1748 * @brief outgoing ego selector changed
@@ -1864,7 +1765,7 @@ gnunet_conversation_gtk_outgoing_zone_combobox_changed_cb (GtkComboBox *widget,
1864 0, &tempName, 1765 0, &tempName,
1865 1, &tempEgo, 1766 1, &tempEgo,
1866 -1); 1767 -1);
1867 //LOG(stderr,"outgoing ego: %s", tempName); 1768 //GCG_log(stderr,"outgoing ego: %s", tempName);
1868 // caller_id = tempEgo; 1769 // caller_id = tempEgo;
1869 /* 1770 /*
1870 if ( NULL != phone) 1771 if ( NULL != phone)
@@ -1880,12 +1781,12 @@ gnunet_conversation_gtk_outgoing_zone_combobox_changed_cb (GtkComboBox *widget,
1880 * @brief active call list type data function 1781 * @brief active call list type data function
1881 */ 1782 */
1882void 1783void
1883 active_calls_type_data_function (GtkTreeViewColumn *col, 1784active_calls_type_data_function (GtkTreeViewColumn *col,
1884 GtkCellRenderer *renderer, 1785 GtkCellRenderer *renderer,
1885 GtkTreeModel *model, 1786 GtkTreeModel *model,
1886 GtkTreeIter *iter, 1787 GtkTreeIter *iter,
1887 gpointer user_data) 1788 gpointer user_data)
1888 { 1789 {
1889 gint state; 1790 gint state;
1890 gchar buf[20]; 1791 gchar buf[20];
1891 1792
@@ -1893,8 +1794,8 @@ void
1893 g_snprintf(buf, sizeof(buf), "status %u", state); 1794 g_snprintf(buf, sizeof(buf), "status %u", state);
1894 g_object_set(renderer, "text", buf, NULL); 1795 g_object_set(renderer, "text", buf, NULL);
1895 /* set 'cell-background' property of the cell renderer */ 1796 /* set 'cell-background' property of the cell renderer */
1896 1797
1897 switch (state) 1798 switch (state)
1898 { 1799 {
1899 case CT_active: 1800 case CT_active:
1900 g_object_set(renderer, 1801 g_object_set(renderer,
@@ -1926,12 +1827,12 @@ void
1926 default: 1827 default:
1927 GNUNET_break(0); 1828 GNUNET_break(0);
1928 break; 1829 break;
1929 } 1830 }
1930 1831
1931 //gtk_tree_model_get(model, iter, AL_caller_state, &state, -1); 1832 //gtk_tree_model_get(model, iter, AL_caller_state, &state, -1);
1932 1833
1933 //g_snprintf(buf, sizeof(buf), "state: %u", state); 1834 //g_snprintf(buf, sizeof(buf), "state: %u", state);
1934 1835
1935 //g_object_set(renderer, "text", buf, NULL); 1836 //g_object_set(renderer, "text", buf, NULL);
1936 // 1837 //
1937// if (foo->is_important) 1838// if (foo->is_important)
@@ -1942,7 +1843,7 @@ void
1942 } 1843 }
1943 1844
1944 1845
1945/* 1846/**
1946 * @brief second test button 1847 * @brief second test button
1947 */ 1848 */
1948void 1849void
@@ -1951,15 +1852,15 @@ GNUNET_CONVERSATION_GTK_test_button_two()
1951 GtkTreeViewColumn *column; 1852 GtkTreeViewColumn *column;
1952// GtkCellRenderer *cell; 1853// GtkCellRenderer *cell;
1953 GtkCellRenderer *renderer; 1854 GtkCellRenderer *renderer;
1954 //LOG("test"); 1855 //GCG_log("test");
1955// treeview = get_object(ml,"gnunet_conversation_gtk_active_calls_treeview"); 1856// treeview = GCG_get_main_window_object(ml,"gnunet_conversation_gtk_active_calls_treeview");
1956 1857
1957// column = get_object(ml,"GNUNET_CONVERSATION_GTK_caller_typeColumn"); 1858// column = GCG_get_main_window_object(ml,"GNUNET_CONVERSATION_GTK_caller_typeColumn");
1958 //cell = gtk_cell_renderer_text_new(); 1859 //cell = gtk_cell_renderer_text_new();
1959// cell = get_object(ml,"GNUNET_CONVERSATION_GTK_active_calls_type"); 1860// cell = GCG_get_main_window_object(ml,"GNUNET_CONVERSATION_GTK_active_calls_type");
1960// gtk_tree_view_column_set_cell_data_func(column, cell, active_calls_type_data_function, NULL, NULL ); 1861// gtk_tree_view_column_set_cell_data_func(column, cell, active_calls_type_data_function, NULL, NULL );
1961 1862
1962 column = GTK_TREE_VIEW_COLUMN(get_object("caller_testcolumn")); 1863 column = GTK_TREE_VIEW_COLUMN(GCG_get_main_window_object("caller_testcolumn"));
1963 gtk_tree_view_column_set_title(column, "test stateC"); 1864 gtk_tree_view_column_set_title(column, "test stateC");
1964 renderer = gtk_cell_renderer_text_new(); 1865 renderer = gtk_cell_renderer_text_new();
1965 1866
@@ -1974,8 +1875,7 @@ GNUNET_CONVERSATION_GTK_test_button_two()
1974 "cell-background-set", TRUE, 1875 "cell-background-set", TRUE,
1975 NULL); 1876 NULL);
1976 gtk_tree_view_column_add_attribute(column, renderer, "text", AL_caller_state); 1877 gtk_tree_view_column_add_attribute(column, renderer, "text", AL_caller_state);
1977 gtk_tree_view_column_set_cell_data_func(column, renderer, active_calls_type_data_function, NULL, NULL ); 1878 gtk_tree_view_column_set_cell_data_func(column, renderer, active_calls_type_data_function, NULL, NULL );
1978
1979} 1879}
1980 1880
1981 1881/* end of gnunet-conversation-gtk.c */