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.c107
1 files changed, 40 insertions, 67 deletions
diff --git a/src/conversation/gnunet-conversation-gtk.c b/src/conversation/gnunet-conversation-gtk.c
index b07230db..66452e77 100644
--- a/src/conversation/gnunet-conversation-gtk.c
+++ b/src/conversation/gnunet-conversation-gtk.c
@@ -143,23 +143,27 @@ history_add (int type, char *contactName)
143 GtkTreeIter iter; 143 GtkTreeIter iter;
144 time_t t; 144 time_t t;
145 char *event; 145 char *event;
146
146 switch (type) 147 switch (type)
147 { 148 {
148 case 0: 149 case CH_ACCEPTED:
149 event = "Accepted"; 150 event = "Accepted";
150 break; 151 break;
151 case 1: 152 case CH_REJECTED:
152 event = "Rejected"; 153 event = "Rejected";
153 break; 154 break;
154 case 2: 155 case CH_OUTGOING:
155 event = "Outgoing"; 156 event = "Outgoing";
156 break; 157 break;
157 case 3: 158 case CH_HANGUP:
158 event = "Hangup"; 159 event = "Hangup";
159 break; 160 break;
160 case 4: 161 case CH_MISSED:
161 event = "Missed"; 162 event = "Missed";
162 break; 163 break;
164 default:
165 event = "UNKNOWN";
166 break;
163 } 167 }
164 time (&t); 168 time (&t);
165 gtk_list_store_append (history_liststore, &iter); 169 gtk_list_store_append (history_liststore, &iter);
@@ -358,8 +362,6 @@ start_phone ()
358{ 362{
359 struct GNUNET_GNSRECORD_Data rd; 363 struct GNUNET_GNSRECORD_Data rd;
360 364
361 LOG ("start_phone\n");
362
363 if (NULL == caller_id) 365 if (NULL == caller_id)
364 { 366 {
365 LOG (_("Ego `%s' no longer available, phone is now down.\n"), ego_name); 367 LOG (_("Ego `%s' no longer available, phone is now down.\n"), ego_name);
@@ -495,7 +497,6 @@ do_call (const char *arg)
495static void 497static void
496do_accept (const char *args) 498do_accept (const char *args)
497{ 499{
498 FPRINTF (stderr, "do_accept run");
499 struct CallList *cl; 500 struct CallList *cl;
500 char buf[32]; 501 char buf[32];
501 502
@@ -743,7 +744,6 @@ do_resume (const char *args)
743static void 744static void
744do_reject (const char *args) 745do_reject (const char *args)
745{ 746{
746 FPRINTF (stderr, "doing reject");
747 struct CallList *cl; 747 struct CallList *cl;
748 char buf[32]; 748 char buf[32];
749 749
@@ -796,7 +796,6 @@ do_reject (const char *args)
796 phone_state = PS_LISTEN; 796 phone_state = PS_LISTEN;
797 break; 797 break;
798 } 798 }
799 //FPRINTF(stderr,"blaalalal %s",peer_name);
800 history_add (1, peer_name); 799 history_add (1, peer_name);
801 800
802} 801}
@@ -869,7 +868,7 @@ display_record (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
869 { 868 {
870 type = "PHONE"; 869 type = "PHONE";
871 } 870 }
872 FPRINTF (stdout, "%s", rname); 871// FPRINTF (stdout, "%s", rname);
873 gtk_list_store_append (contacts_liststore, &iter); 872 gtk_list_store_append (contacts_liststore, &iter);
874 gtk_list_store_set (contacts_liststore, &iter, 1, type, 0, rname, -1); 873 gtk_list_store_set (contacts_liststore, &iter, 1, type, 0, rname, -1);
875 874
@@ -885,7 +884,7 @@ display_record (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
885 //gtk_widget_show(contacts_liststore); 884 //gtk_widget_show(contacts_liststore);
886 GNUNET_free (s); 885 GNUNET_free (s);
887 } 886 }
888 FPRINTF (stdout, "%s", "\n"); 887// FPRINTF (stdout, "%s", "\n");
889 GNUNET_NAMESTORE_zone_iterator_next (list_it); 888 GNUNET_NAMESTORE_zone_iterator_next (list_it);
890} 889}
891 890
@@ -1122,9 +1121,9 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1122 GNUNET_GTK_set_icon_search_path (); 1121 GNUNET_GTK_set_icon_search_path ();
1123 GNUNET_GTK_setup_nls (); 1122 GNUNET_GTK_setup_nls ();
1124 /* setup main window */ 1123 /* setup main window */
1125 main_window = GTK_WIDGET (get_object ("GNUNET_GTK_conversation_window")); 1124 main_window = GTK_WINDOW (get_object ("GNUNET_GTK_conversation_window"));
1126 main_window = 1125 main_window =
1127 GNUNET_GTK_plug_me ("GNUNET_CONVERSATION_GTK_PLUG", GTK_WIDGET(main_window)); 1126 GTK_WIDGET(GNUNET_GTK_plug_me ("GNUNET_CONVERSATION_GTK_PLUG", GTK_WIDGET(main_window)));
1128 gtk_window_set_default_size (main_window, 300, 700); 1127 gtk_window_set_default_size (main_window, 300, 700);
1129 contacts_liststore = 1128 contacts_liststore =
1130 GTK_LIST_STORE (get_object 1129 GTK_LIST_STORE (get_object
@@ -1169,20 +1168,19 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1169 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, 1168 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
1170 NULL); 1169 NULL);
1171 1170
1171
1172 cfg = GIG_get_configuration (); 1172 cfg = GIG_get_configuration ();
1173//cfg = GNUNET_CONFIGURATION_dup (c); 1173//cfg = GNUNET_CONFIGURATION_dup (c);
1174 1174
1175 speaker = GNUNET_SPEAKER_create_from_hardware (cfg); 1175 speaker = GNUNET_SPEAKER_create_from_hardware (GIG_get_configuration());
1176 mic = GNUNET_MICROPHONE_create_from_hardware (cfg); 1176 mic = GNUNET_MICROPHONE_create_from_hardware (GIG_get_configuration());
1177 1177
1178// ego_name = "phone_ego";
1179 if (NULL == ego_name) 1178 if (NULL == ego_name)
1180 { 1179 {
1181 ego_name = "phone-ego"; 1180 ego_name = "phone-ego";
1182 LOG ("%s", _("No ego given, using default \"phone-ego\" \n")); 1181 LOG (_("No ego given, using default: %s "), ego_name);
1183 //return; 1182
1184 } 1183 }
1185 FPRINTF(stderr, "ego: %s \n", ego_name);
1186 1184
1187 id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL); 1185 id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL);
1188 1186
@@ -1223,7 +1221,7 @@ main (int argc, char *const *argv)
1223 &run)) 1221 &run))
1224 return 1; 1222 return 1;
1225 return 0; 1223 return 0;
1226 FPRINTF (stderr, "line %i", line); 1224// FPRINTF (stderr, "line %i", line);
1227} 1225}
1228 1226
1229/* gui stuff start */ 1227/* gui stuff start */
@@ -1239,7 +1237,7 @@ void
1239quick_message (gchar * message, const char *caller_id) 1237quick_message (gchar * message, const char *caller_id)
1240{ 1238{
1241 GtkWidget *caller_name, *notification, *content_area; 1239 GtkWidget *caller_name, *notification, *content_area;
1242 GtkDialog *dialog; 1240 GtkWidget *dialog;
1243 GtkWindow *main_window; 1241 GtkWindow *main_window;
1244 main_window = GTK_WINDOW(get_object("GNUNET_GTK_conversation_window")); 1242 main_window = GTK_WINDOW(get_object("GNUNET_GTK_conversation_window"));
1245 // Create the widgets 1243 // Create the widgets
@@ -1267,7 +1265,7 @@ quick_message (gchar * message, const char *caller_id)
1267 gtk_container_add (GTK_CONTAINER (content_area), caller_name); 1265 gtk_container_add (GTK_CONTAINER (content_area), caller_name);
1268 gtk_widget_show_all (GTK_WIDGET(dialog)); 1266 gtk_widget_show_all (GTK_WIDGET(dialog));
1269 1267
1270 switch(gtk_dialog_run(dialog)){ 1268 switch(gtk_dialog_run(GTK_DIALOG(dialog))){
1271 case GTK_RESPONSE_ACCEPT : 1269 case GTK_RESPONSE_ACCEPT :
1272 do_status(""); 1270 do_status("");
1273 gtk_widget_destroy(GTK_WIDGET(dialog)); 1271 gtk_widget_destroy(GTK_WIDGET(dialog));
@@ -1296,12 +1294,13 @@ quick_message (gchar * message, const char *caller_id)
1296void 1294void
1297GNUNET_CONVERSATION_GTK_on_call_clicked () 1295GNUNET_CONVERSATION_GTK_on_call_clicked ()
1298{ 1296{
1299 char *to_addr; 1297 char *to_addr = malloc(MAX_TO_ADDR*sizeof(char));
1300 GtkEntry *address_entry; 1298 GtkEntry *address_entry;
1301 1299
1302 address_entry = GTK_ENTRY (get_object ("GNUNET_GTK_conversation_address")); 1300 address_entry = GTK_ENTRY (get_object ("GNUNET_GTK_conversation_address"));
1303 to_addr = gtk_entry_get_text (address_entry); 1301// to_addr = gtk_entry_get_text (address_entry);
1304 1302
1303 strcpy(to_addr, gtk_entry_get_text (address_entry));
1305// FPRINTF (stderr, _("calling: %s \n"), to_addr ); 1304// FPRINTF (stderr, _("calling: %s \n"), to_addr );
1306 1305
1307 do_call (to_addr); 1306 do_call (to_addr);
@@ -1381,43 +1380,19 @@ void
1381GNUNET_CONVERSATION_GTK_on_status_clicked () 1380GNUNET_CONVERSATION_GTK_on_status_clicked ()
1382{ 1381{
1383 1382
1384 FPRINTF (stderr, "status clicked \n");
1385 1383
1386// do_accept("0"); 1384// do_accept("0");
1387 do_status (" "); 1385 do_status (" ");
1388 //quick_message('hee blaaat you have a call from blaat'); 1386 //quick_message('hee blaaat you have a call from blaat');
1389} 1387}
1390 1388
1391/*
1392void
1393GNUNET_contact_test ()
1394{
1395FPRINTF (stderr, "gnunet contact test"
1396}
1397*/
1398
1399void
1400use_current_incoming_address ()
1401{
1402 FPRINTF (stderr, "use cur addr");
1403}
1404
1405
1406/*
1407void
1408test_function (gint response_id)
1409{
1410 FPRINTF (stderr, "teest %u", response_id);
1411}
1412*/
1413
1414 1389
1415/* 1390/*
1416 * add a new contact 1391 * add a new contact
1417 * @param name 1392 * @param name
1418 * @param address 1393 * @param address
1419 */ 1394 */
1420void add_contact(char *name, char *address) 1395void add_contact(const gchar *name, const gchar *address)
1421{ 1396{
1422// memmove(&address+1,&address+51,1); 1397// memmove(&address+1,&address+51,1);
1423 GtkTreeIter iter; 1398 GtkTreeIter iter;
@@ -1474,31 +1449,31 @@ GNUNET_CONVERSATION_GTK_on_add_clicked (GtkButton * button,
1474{ 1449{
1475// gint response_id; 1450// gint response_id;
1476 1451
1477 FPRINTF (stderr, "add clicked \n");
1478 //unused: *anotherArea, *labelName, *labelAddres *caller_name 1452 //unused: *anotherArea, *labelName, *labelAddres *caller_name
1479 1453
1480 GtkLabel *notification; 1454 GtkLabel *notification;
1481 GtkHBox *content_area; 1455// GtkHBox *content_area;
1456 GtkContainer *content_area;
1482 GtkButton *currentCheckButton; 1457 GtkButton *currentCheckButton;
1483 GtkEntry *nameEntry, *addressEntry; 1458 GtkEntry *nameEntry, *addressEntry;
1484 GtkDialog *dialog; 1459 GtkDialog *dialog;
1485 GtkWindow *main_window; 1460 GtkWindow *main_window;
1486 1461
1487 currentCheckButton = 1462 currentCheckButton =
1488 gtk_button_new_with_label ("use currently incoming addres"); 1463 GTK_BUTTON(gtk_button_new_with_label ("use currently incoming addres"));
1489 1464
1490 nameEntry = gtk_entry_new (); 1465 nameEntry = GTK_ENTRY(gtk_entry_new ());
1491 gtk_entry_set_text (nameEntry, "Name of contact"); 1466 gtk_entry_set_text (nameEntry, "Name of contact");
1492 addressEntry = gtk_entry_new (); 1467 addressEntry = GTK_ENTRY(gtk_entry_new ());
1493 gtk_entry_set_text (addressEntry, "Address of contact"); 1468 gtk_entry_set_text (addressEntry, "Address of contact");
1494 1469
1495 main_window = get_object ("GNUNET_GTK_conversation_window"); 1470 main_window = GTK_WINDOW(get_object ("GNUNET_GTK_conversation_window"));
1496 1471
1497 dialog = 1472 dialog =
1498 gtk_dialog_new_with_buttons ("Adding contact", main_window, 1473 GTK_DIALOG(gtk_dialog_new_with_buttons ("Adding contact", main_window,
1499 GTK_DIALOG_DESTROY_WITH_PARENT, 1474 GTK_DIALOG_DESTROY_WITH_PARENT,
1500 _("Add contact"), GTK_RESPONSE_ACCEPT, 1475 _("Add contact"), GTK_RESPONSE_ACCEPT,
1501 _("Cancel"), GTK_RESPONSE_CANCEL, NULL); 1476 _("Cancel"), GTK_RESPONSE_CANCEL, NULL));
1502 gtk_dialog_add_action_widget (dialog, GTK_WIDGET(currentCheckButton), GTK_RESPONSE_OK); 1477 gtk_dialog_add_action_widget (dialog, GTK_WIDGET(currentCheckButton), GTK_RESPONSE_OK);
1503// FPRINTF (stderr, "response id : %u", response_id); 1478// FPRINTF (stderr, "response id : %u", response_id);
1504// g_signal_connect (GTK_BUTTON (currentCheckButton), "clicked", 1479// g_signal_connect (GTK_BUTTON (currentCheckButton), "clicked",
@@ -1508,10 +1483,10 @@ GNUNET_CONVERSATION_GTK_on_add_clicked (GtkButton * button,
1508 gtk_dialog_add_action_widget (dialog, GTK_WIDGET(nameEntry), 2); 1483 gtk_dialog_add_action_widget (dialog, GTK_WIDGET(nameEntry), 2);
1509 gtk_dialog_add_action_widget (dialog, GTK_WIDGET(addressEntry), 3); 1484 gtk_dialog_add_action_widget (dialog, GTK_WIDGET(addressEntry), 3);
1510 1485
1511 content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); 1486 content_area = GTK_CONTAINER(gtk_dialog_get_content_area (GTK_DIALOG (dialog)));
1512 1487
1513 1488
1514 notification = gtk_label_new ("Adding contact"); 1489 notification = GTK_LABEL(gtk_label_new ("Adding contact"));
1515// caller_name = gtk_label_new (caller_id); 1490// caller_name = gtk_label_new (caller_id);
1516 1491
1517 // Add the labels, and show everything we've added to the dialog 1492 // Add the labels, and show everything we've added to the dialog
@@ -1522,7 +1497,6 @@ GNUNET_CONVERSATION_GTK_on_add_clicked (GtkButton * button,
1522 switch (gtk_dialog_run (dialog)) 1497 switch (gtk_dialog_run (dialog))
1523 { 1498 {
1524 case GTK_RESPONSE_ACCEPT: 1499 case GTK_RESPONSE_ACCEPT:
1525 FPRINTF (stderr, "accept clicked");
1526 do_status (""); 1500 do_status ("");
1527 add_contact (gtk_entry_get_text (nameEntry), 1501 add_contact (gtk_entry_get_text (nameEntry),
1528 gtk_entry_get_text (addressEntry)); 1502 gtk_entry_get_text (addressEntry));
@@ -1552,7 +1526,6 @@ void
1552GNUNET_CONVERSATION_GTK_on_remove_clicked (GtkButton * button, 1526GNUNET_CONVERSATION_GTK_on_remove_clicked (GtkButton * button,
1553 gpointer * user_data) 1527 gpointer * user_data)
1554{ 1528{
1555 FPRINTF (stderr, "remove clicked \n");
1556 GtkTreeSelection *selection; 1529 GtkTreeSelection *selection;
1557 GtkTreeModel *model; 1530 GtkTreeModel *model;
1558 GtkTreeIter iter; 1531 GtkTreeIter iter;
@@ -1566,14 +1539,14 @@ GNUNET_CONVERSATION_GTK_on_remove_clicked (GtkButton * button,
1566 { 1539 {
1567 gtk_tree_model_get (model, &iter, 0, &name, -1); 1540 gtk_tree_model_get (model, &iter, 0, &name, -1);
1568 FPRINTF(stderr, "selected %s \n", name); 1541 FPRINTF(stderr, "selected %s \n", name);
1569 main_window = get_object ("GNUNET_GTK_conversation_window"); 1542 main_window = GTK_WINDOW(get_object ("GNUNET_GTK_conversation_window"));
1570 confirm = 1543 confirm =
1571 gtk_dialog_new_with_buttons ("Removing contact", main_window, 1544 GTK_DIALOG(gtk_dialog_new_with_buttons ("Removing contact", main_window,
1572 GTK_DIALOG_DESTROY_WITH_PARENT, 1545 GTK_DIALOG_DESTROY_WITH_PARENT,
1573 _("Yes"), GTK_RESPONSE_ACCEPT, 1546 _("Yes"), GTK_RESPONSE_ACCEPT,
1574 _("No"), GTK_RESPONSE_CANCEL, NULL); 1547 _("No"), GTK_RESPONSE_CANCEL, NULL));
1575 content_area = gtk_dialog_get_content_area (GTK_DIALOG (confirm)); 1548 content_area = GTK_CONTAINER(gtk_dialog_get_content_area (GTK_DIALOG (confirm)));
1576 notification = gtk_label_new ("Do you really want to remove this contact?"); 1549 notification = GTK_LABEL(gtk_label_new ("Do you really want to remove this contact?"));
1577 gtk_container_add (GTK_CONTAINER (content_area), GTK_WIDGET(notification)); 1550 gtk_container_add (GTK_CONTAINER (content_area), GTK_WIDGET(notification));
1578 gtk_widget_show_all (GTK_WIDGET(confirm)); 1551 gtk_widget_show_all (GTK_WIDGET(confirm));
1579 switch (gtk_dialog_run(confirm)) 1552 switch (gtk_dialog_run(confirm))