aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryids <yids@140774ce-b5e7-0310-ab8b-a85725594a96>2014-01-27 19:34:31 +0000
committeryids <yids@140774ce-b5e7-0310-ab8b-a85725594a96>2014-01-27 19:34:31 +0000
commit77ef751bada764793036f3a12dd672f627fdd748 (patch)
treecf3df08d3e378a3feb66bc27d8c953c2be36292d
parentcc7d4f4d7f4e789dbc7e5dafb06aa34d1849f150 (diff)
downloadgnunet-gtk-77ef751bada764793036f3a12dd672f627fdd748.tar.gz
gnunet-gtk-77ef751bada764793036f3a12dd672f627fdd748.zip
Add contact is working now
-rw-r--r--src/conversation/gnunet-conversation-gtk.c103
1 files changed, 83 insertions, 20 deletions
diff --git a/src/conversation/gnunet-conversation-gtk.c b/src/conversation/gnunet-conversation-gtk.c
index ecfa8256..93051504 100644
--- a/src/conversation/gnunet-conversation-gtk.c
+++ b/src/conversation/gnunet-conversation-gtk.c
@@ -338,6 +338,8 @@ start_phone ()
338{ 338{
339 struct GNUNET_GNSRECORD_Data rd; 339 struct GNUNET_GNSRECORD_Data rd;
340 340
341 LOG ("start_phone\n");
342
341 if (NULL == caller_id) 343 if (NULL == caller_id)
342 { 344 {
343 LOG (_("Ego `%s' no longer available, phone is now down.\n"), ego_name); 345 LOG (_("Ego `%s' no longer available, phone is now down.\n"), ego_name);
@@ -470,6 +472,7 @@ do_call (const char *arg)
470static void 472static void
471do_accept (const char *args) 473do_accept (const char *args)
472{ 474{
475 FPRINTF (stderr, "do_accept run");
473 struct CallList *cl; 476 struct CallList *cl;
474 char buf[32]; 477 char buf[32];
475 478
@@ -715,6 +718,7 @@ do_resume (const char *args)
715static void 718static void
716do_reject (const char *args) 719do_reject (const char *args)
717{ 720{
721 FPRINTF (stderr, "doing reject");
718 struct CallList *cl; 722 struct CallList *cl;
719 char buf[32]; 723 char buf[32];
720 724
@@ -803,6 +807,9 @@ display_record (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
803 GNUNET_NAMESTORE_zone_iterator_next (list_it); 807 GNUNET_NAMESTORE_zone_iterator_next (list_it);
804 return; 808 return;
805 } 809 }
810 //FPRINTF (stdout,
811// "%s:\n",
812// rname);
806 for (i = 0; i < rd_len; i++) 813 for (i = 0; i < rd_len; i++)
807 { 814 {
808 815
@@ -1012,7 +1019,7 @@ GNUNET_GTK_conversation_quit_cb (GObject * object, gpointer user_data)
1012 } 1019 }
1013 if (NULL != ns) 1020 if (NULL != ns)
1014 { 1021 {
1015 GNUNET_NAMESTORE_disconnect (ns); 1022 GNUNET_IDENTITY_disconnect (ns);
1016 ns = NULL; 1023 ns = NULL;
1017 } 1024 }
1018 1025
@@ -1108,13 +1115,15 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1108 speaker = GNUNET_SPEAKER_create_from_hardware (cfg); 1115 speaker = GNUNET_SPEAKER_create_from_hardware (cfg);
1109 mic = GNUNET_MICROPHONE_create_from_hardware (cfg); 1116 mic = GNUNET_MICROPHONE_create_from_hardware (cfg);
1110 1117
1111 if (ego_name == NULL) 1118// ego_name = "phone_ego";
1119 if (NULL == ego_name)
1112 { 1120 {
1113 ego_name = "phone-ego"; 1121 ego_name = "phone-ego";
1114 1122 LOG ("%s", _("No ego given, using default \"phone-ego\" \n"));
1115 LOG (_("No ego given, using default: %s "), ego_name); 1123 return;
1116 } 1124 }
1117 1125
1126
1118 id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL); 1127 id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL);
1119 1128
1120// zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (caller_id); 1129// zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (caller_id);
@@ -1140,15 +1149,12 @@ main (int argc, char *const *argv)
1140 {'e', "ego", "ego", 1149 {'e', "ego", "ego",
1141 gettext_noop ("select ego to use"), 1, 1150 gettext_noop ("select ego to use"), 1,
1142 &GNUNET_GETOPT_set_string, &ego_name}, 1151 &GNUNET_GETOPT_set_string, &ego_name},
1152
1143 {'t', "tray", NULL, 1153 {'t', "tray", NULL,
1144 gettext_noop ("start in tray mode"), 0, 1154 gettext_noop ("start in tray mode"), 0,
1145 &GNUNET_GETOPT_set_one, &tray_only}, 1155 &GNUNET_GETOPT_set_one, &tray_only},
1146 GNUNET_GETOPT_OPTION_END 1156 GNUNET_GETOPT_OPTION_END
1147 }; 1157 };
1148
1149
1150
1151
1152 if (GNUNET_OK != 1158 if (GNUNET_OK !=
1153 GNUNET_GTK_main_loop_start ("gnunet-conversation-gtk", 1159 GNUNET_GTK_main_loop_start ("gnunet-conversation-gtk",
1154 "GTK GUI for conversation", argc, argv, 1160 "GTK GUI for conversation", argc, argv,
@@ -1157,6 +1163,7 @@ main (int argc, char *const *argv)
1157 &run)) 1163 &run))
1158 return 1; 1164 return 1;
1159 return 0; 1165 return 0;
1166 FPRINTF (stderr, "line %i", line);
1160} 1167}
1161 1168
1162/* gui stuff start */ 1169/* gui stuff start */
@@ -1235,6 +1242,8 @@ GNUNET_CONVERSATION_GTK_on_call_clicked ()
1235 address_entry = GTK_ENTRY (get_object ("GNUNET_GTK_conversation_address")); 1242 address_entry = GTK_ENTRY (get_object ("GNUNET_GTK_conversation_address"));
1236 to_addr = gtk_entry_get_text (address_entry); 1243 to_addr = gtk_entry_get_text (address_entry);
1237 1244
1245// FPRINTF (stderr, _("calling: %s \n"), to_addr );
1246
1238 do_call (to_addr); 1247 do_call (to_addr);
1239 disable_button ("GNUNET_GTK_conversation_accept_button"); 1248 disable_button ("GNUNET_GTK_conversation_accept_button");
1240 do_status (""); 1249 do_status ("");
@@ -1251,6 +1260,7 @@ GNUNET_CONVERSATION_GTK_on_hangup_clicked ()
1251 enable_button ("GNUNET_GTK_conversation_call_button"); 1260 enable_button ("GNUNET_GTK_conversation_call_button");
1252 1261
1253 1262
1263 //FPRINTF (stderr, "hangup clicked \n");
1254 do_reject (""); 1264 do_reject ("");
1255 do_status (""); 1265 do_status ("");
1256} 1266}
@@ -1261,6 +1271,7 @@ GNUNET_CONVERSATION_GTK_on_hangup_clicked ()
1261void 1271void
1262GNUNET_CONVERSATION_GTK_on_accept_clicked () 1272GNUNET_CONVERSATION_GTK_on_accept_clicked ()
1263{ 1273{
1274 FPRINTF (stderr, "accept clicked \n");
1264 do_accept (0); 1275 do_accept (0);
1265 // hide_infobar (); 1276 // hide_infobar ();
1266} 1277}
@@ -1282,7 +1293,14 @@ GNUNET_CONVERSATION_GTK_on_reject_clicked ()
1282void 1293void
1283GNUNET_CONVERSATION_GTK_on_pause_clicked () 1294GNUNET_CONVERSATION_GTK_on_pause_clicked ()
1284{ 1295{
1296// GtkEntry *entry;
1285do_suspend("0"); 1297do_suspend("0");
1298 //FPRINTF (stderr, "pause clicked \n");
1299 //do_pause("");
1300 // entry = GTK_ENTRY((get_object ("GNUNET_GTK_conversation_address")));
1301 //FPRINTF (stderr, gtk_entry_get_text (entry));
1302// gtk_entry_set_text (entry, "testtextje");
1303// show_infobar ();
1286} 1304}
1287 1305
1288/** 1306/**
@@ -1291,6 +1309,7 @@ do_suspend("0");
1291void 1309void
1292GNUNET_CONVERSATION_GTK_on_resume_clicked () 1310GNUNET_CONVERSATION_GTK_on_resume_clicked ()
1293{ 1311{
1312 //FPRINTF (stderr, "reject clicked \n");
1294 do_resume (""); 1313 do_resume ("");
1295} 1314}
1296 1315
@@ -1300,11 +1319,39 @@ GNUNET_CONVERSATION_GTK_on_resume_clicked ()
1300void 1319void
1301GNUNET_CONVERSATION_GTK_on_status_clicked () 1320GNUNET_CONVERSATION_GTK_on_status_clicked ()
1302{ 1321{
1322
1323 FPRINTF (stderr, "status clicked \n");
1324
1325// do_accept("0");
1303 do_status (" "); 1326 do_status (" ");
1327 //quick_message('hee blaaat you have a call from blaat');
1328}
1329
1330/*
1331void
1332GNUNET_contact_test ()
1333{
1334FPRINTF (stderr, "gnunet contact test"
1335}
1336*/
1337
1338void
1339use_current_incoming_address ()
1340{
1341 FPRINTF (stderr, "use cur addr");
1304} 1342}
1305 1343
1306 1344
1307/* 1345/*
1346void
1347test_function (gint response_id)
1348{
1349 FPRINTF (stderr, "teest %u", response_id);
1350}
1351*/
1352
1353
1354/*
1308 * add a new contact 1355 * add a new contact
1309 * @param name 1356 * @param name
1310 * @param address 1357 * @param address
@@ -1314,18 +1361,31 @@ void add_contact(char *name, char *address)
1314// memmove(&address+1,&address+51,1); 1361// memmove(&address+1,&address+51,1);
1315 GtkTreeIter iter; 1362 GtkTreeIter iter;
1316 struct GNUNET_GNSRECORD_Data rd; 1363 struct GNUNET_GNSRECORD_Data rd;
1364 struct GNUNET_GNSRECORD_Data *rde;
1365 static void *data;
1366 static size_t data_size;
1367 struct GNUNET_CRYPTO_EcdsaPublicKey pkey;
1317 1368
1369 GNUNET_CRYPTO_ecdsa_public_key_from_string (address, strlen (address), &pkey);
1370 rde=&rd;
1318 zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (caller_id); 1371 zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (caller_id);
1319 rd.data = address; 1372 rd.data = &pkey;
1320 rd.data_size = sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey); 1373 rd.data_size = sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey);
1321 rd.record_type = GNUNET_GNSRECORD_TYPE_PKEY; 1374 rd.record_type = GNUNET_GNSRECORD_TYPE_PKEY;
1322 rd.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; // always set to relative for testing purposes 1375 rd.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; // always set to relative for testing purposes
1376 rde->flags |= GNUNET_GNSRECORD_RF_PRIVATE;
1377 rde->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
1323 FPRINTF (stderr, "adding\n"); 1378 FPRINTF (stderr, "adding\n");
1324 FPRINTF (stderr, "name: %s\n", name); 1379 FPRINTF (stderr, "name: %s\n", name);
1325 FPRINTF (stderr, "address: %s\n", address); 1380 FPRINTF (stderr, "address: %s\n", address);
1326 add_qe = 1381 add_qe =
1327 GNUNET_NAMESTORE_records_store (ns, &zone_pkey, name, 1, &rd, NULL, 1382 GNUNET_NAMESTORE_records_store (ns,
1328 add_qe); 1383 &zone_pkey,
1384 name,
1385 1,
1386 rde,
1387 &add_continuation,
1388 &add_qe);
1329 gtk_list_store_append (contacts_liststore, &iter); 1389 gtk_list_store_append (contacts_liststore, &iter);
1330 gtk_list_store_set (contacts_liststore, &iter, 1, "PKEY", 0, name, -1); 1390 gtk_list_store_set (contacts_liststore, &iter, 1, "PKEY", 0, name, -1);
1331 1391
@@ -1343,6 +1403,7 @@ GNUNET_CONVERSATION_GTK_on_add_clicked (GtkButton * button,
1343{ 1403{
1344// gint response_id; 1404// gint response_id;
1345 1405
1406 FPRINTF (stderr, "add clicked \n");
1346 //unused: *anotherArea, *labelName, *labelAddres *caller_name 1407 //unused: *anotherArea, *labelName, *labelAddres *caller_name
1347 1408
1348 GtkLabel *notification; 1409 GtkLabel *notification;
@@ -1369,7 +1430,10 @@ GNUNET_CONVERSATION_GTK_on_add_clicked (GtkButton * button,
1369 _("Cancel"), GTK_RESPONSE_CANCEL, NULL); 1430 _("Cancel"), GTK_RESPONSE_CANCEL, NULL);
1370 gtk_dialog_add_action_widget (dialog, GTK_WIDGET(currentCheckButton), GTK_RESPONSE_OK); 1431 gtk_dialog_add_action_widget (dialog, GTK_WIDGET(currentCheckButton), GTK_RESPONSE_OK);
1371// FPRINTF (stderr, "response id : %u", response_id); 1432// FPRINTF (stderr, "response id : %u", response_id);
1372 1433// g_signal_connect (GTK_BUTTON (currentCheckButton), "clicked",
1434// G_CALLBACK (use_current_incoming_address), NULL);
1435
1436
1373 gtk_dialog_add_action_widget (dialog, GTK_WIDGET(nameEntry), 2); 1437 gtk_dialog_add_action_widget (dialog, GTK_WIDGET(nameEntry), 2);
1374 gtk_dialog_add_action_widget (dialog, GTK_WIDGET(addressEntry), 3); 1438 gtk_dialog_add_action_widget (dialog, GTK_WIDGET(addressEntry), 3);
1375 1439
@@ -1387,19 +1451,22 @@ GNUNET_CONVERSATION_GTK_on_add_clicked (GtkButton * button,
1387 switch (gtk_dialog_run (dialog)) 1451 switch (gtk_dialog_run (dialog))
1388 { 1452 {
1389 case GTK_RESPONSE_ACCEPT: 1453 case GTK_RESPONSE_ACCEPT:
1454 FPRINTF (stderr, "accept clicked");
1390 do_status (""); 1455 do_status ("");
1391 add_contact (gtk_entry_get_text (nameEntry), 1456 add_contact (gtk_entry_get_text (nameEntry),
1392 gtk_entry_get_text (addressEntry)); 1457 gtk_entry_get_text (addressEntry));
1393 gtk_widget_destroy (GTK_WIDGET(dialog)); 1458 gtk_widget_destroy (GTK_WIDGET(dialog));
1394 break; 1459 break;
1395 case GTK_RESPONSE_CANCEL: 1460 case GTK_RESPONSE_CANCEL:
1461 FPRINTF (stderr, "cancel clicked");
1396 do_status (""); 1462 do_status ("");
1397 gtk_widget_destroy (GTK_WIDGET(dialog)); 1463 gtk_widget_destroy (GTK_WIDGET(dialog));
1398 break; 1464 break;
1399 case GTK_RESPONSE_OK: 1465 case GTK_RESPONSE_OK:
1400 //use_current_incoming_address(); 1466 //use_current_incoming_address();
1401 gtk_entry_set_text (GTK_ENTRY(addressEntry), callerName); 1467 gtk_entry_set_text (GTK_ENTRY(addressEntry), callerName);
1402 add_contact (gtk_entry_get_text (nameEntry), callerName); 1468 add_contact (gtk_entry_get_text (nameEntry),
1469 callerName);
1403// add_contact(gtk_entry_get_text(nameEntry),memmove(&callerName,&callerName+52,1)); 1470// add_contact(gtk_entry_get_text(nameEntry),memmove(&callerName,&callerName+52,1));
1404 gtk_widget_destroy (GTK_WIDGET(dialog)); 1471 gtk_widget_destroy (GTK_WIDGET(dialog));
1405 1472
@@ -1410,16 +1477,11 @@ GNUNET_CONVERSATION_GTK_on_add_clicked (GtkButton * button,
1410 1477
1411} 1478}
1412 1479
1413/**
1414 * clicked contact remove button
1415 */
1416void 1480void
1417GNUNET_CONVERSATION_GTK_on_remove_clicked (GtkButton * button, 1481GNUNET_CONVERSATION_GTK_on_remove_clicked (GtkButton * button,
1418 gpointer * user_data) 1482 gpointer * user_data)
1419{ 1483{
1420 // FIXME: make this work 1484 FPRINTF (stderr, "remove clicked \n");
1421 FPRINTF (stderr, "TODO:remove clicked \n");
1422
1423} 1485}
1424 1486
1425 1487
@@ -1434,6 +1496,7 @@ GNUNET_CONVERSATION_GTK_row_activated ()
1434 gchar *callAddress; 1496 gchar *callAddress;
1435 gchar *type; 1497 gchar *type;
1436 1498
1499 FPRINTF (stderr, "row activated \n");
1437 1500
1438 GtkTreeSelection *selection; 1501 GtkTreeSelection *selection;
1439 1502