diff options
Diffstat (limited to 'src/conversation/gnunet-conversation-gtk.c')
-rw-r--r-- | src/conversation/gnunet-conversation-gtk.c | 158 |
1 files changed, 44 insertions, 114 deletions
diff --git a/src/conversation/gnunet-conversation-gtk.c b/src/conversation/gnunet-conversation-gtk.c index 622db57f..010194f2 100644 --- a/src/conversation/gnunet-conversation-gtk.c +++ b/src/conversation/gnunet-conversation-gtk.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "gnunet-conversation-gtk.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 | #include "gnunet-conversation-gtk_egos.h" | ||
30 | 31 | ||
31 | 32 | ||
32 | /** | 33 | /** |
@@ -164,11 +165,6 @@ static struct GNUNET_SPEAKER_Handle *speaker; | |||
164 | static struct GNUNET_MICROPHONE_Handle *mic; | 165 | static struct GNUNET_MICROPHONE_Handle *mic; |
165 | 166 | ||
166 | /** | 167 | /** |
167 | * Handle to identity service. | ||
168 | */ | ||
169 | static struct GNUNET_IDENTITY_Handle *id; | ||
170 | |||
171 | /** | ||
172 | * Name of conversation partner (if any). | 168 | * Name of conversation partner (if any). |
173 | */ | 169 | */ |
174 | static char *peer_name; | 170 | static char *peer_name; |
@@ -1315,98 +1311,45 @@ do_resume () | |||
1315 | static void | 1311 | static void |
1316 | do_reject () | 1312 | do_reject () |
1317 | { | 1313 | { |
1318 | 1314 | if (call_selected == NULL && caller_selected == NULL) | |
1319 | if (call_selected == NULL && caller_selected == NULL){ | ||
1320 | GNUNET_break(0); | ||
1321 | }else { | ||
1322 | |||
1323 | // if selected call is outgoing, stop it | ||
1324 | if (NULL != call_selected) | ||
1325 | { | 1315 | { |
1326 | set_outgoing_call_state(call_selected,CT_hangup); | 1316 | GNUNET_break(0); |
1327 | |||
1328 | GNUNET_CONVERSATION_call_stop(call); | ||
1329 | //GNUNET_CONVERSATION_call_stop (call_selected); | ||
1330 | |||
1331 | call = NULL; | ||
1332 | call_selected = NULL; | ||
1333 | return; | ||
1334 | } else | ||
1335 | |||
1336 | // if selected call is incoming, hang it up | ||
1337 | if (NULL != caller_selected) | ||
1338 | { | ||
1339 | set_incoming_call_state(caller_selected,CT_hangup); | ||
1340 | //FPRINTF(stderr,"hangup: %u", caller_selected); | ||
1341 | GNUNET_CONVERSATION_caller_hang_up(caller_selected); | ||
1342 | //cl_active = NULL; | ||
1343 | phone_state = PS_LISTEN; | ||
1344 | caller_selected = NULL; | ||
1345 | } else { | ||
1346 | GNUNET_break(0); | ||
1347 | } | 1317 | } |
1348 | } | 1318 | else |
1349 | } | 1319 | { |
1320 | // if selected call is outgoing, stop it | ||
1321 | if (NULL != call_selected) | ||
1322 | { | ||
1323 | set_outgoing_call_state(call_selected,CT_hangup); | ||
1350 | 1324 | ||
1325 | GNUNET_CONVERSATION_call_stop(call); | ||
1326 | //GNUNET_CONVERSATION_call_stop (call_selected); | ||
1351 | 1327 | ||
1352 | /** | 1328 | call = NULL; |
1353 | * Function called by identity service with information about egos. | 1329 | call_selected = NULL; |
1354 | * | 1330 | return; |
1355 | * @param cls NULL | 1331 | } |
1356 | * @param ego ego handle | 1332 | else |
1357 | * @param ctx unused | 1333 | { |
1358 | * @param name name of the ego | 1334 | // if selected call is incoming, hang it up |
1359 | */ | 1335 | if (NULL != caller_selected) |
1360 | static void | 1336 | { |
1361 | identity_cb (void *cls, | 1337 | set_incoming_call_state(caller_selected,CT_hangup); |
1362 | struct GNUNET_IDENTITY_Ego *ego, | 1338 | //FPRINTF(stderr,"hangup: %u", caller_selected); |
1363 | void **ctx, | 1339 | GNUNET_CONVERSATION_caller_hang_up(caller_selected); |
1364 | const char *name) | 1340 | //cl_active = NULL; |
1365 | { | 1341 | phone_state = PS_LISTEN; |
1366 | struct GNUNET_CRYPTO_EcdsaPublicKey pk; | 1342 | caller_selected = NULL; |
1367 | GtkTreeIter iter; | 1343 | } |
1368 | 1344 | else | |
1369 | if (NULL != ego) | 1345 | { |
1370 | { | 1346 | GNUNET_break(0); |
1371 | GNUNET_IDENTITY_ego_get_public_key (ego, &pk); | 1347 | } |
1372 | gtk_list_store_insert_with_values (zone_liststore, | 1348 | } |
1373 | &iter, -1, | ||
1374 | 0, name, | ||
1375 | 1, ego, | ||
1376 | -1); | ||
1377 | } | ||
1378 | if (NULL == name) | ||
1379 | return; | ||
1380 | if (ego == caller_id) | ||
1381 | { | ||
1382 | if (verbose) | ||
1383 | GCG_log (_("Name of our ego changed to `%s'\n"), | ||
1384 | name); | ||
1385 | GNUNET_free_non_null (ego_name); | ||
1386 | ego_name = GNUNET_strdup (name); | ||
1387 | return; | ||
1388 | } | ||
1389 | if (0 != strcmp (name, ego_name)) | ||
1390 | return; | ||
1391 | if (NULL == ego) | ||
1392 | { | ||
1393 | if (verbose) | ||
1394 | GCG_log (_("Our ego `%s' was deleted!\n"), | ||
1395 | ego_name); | ||
1396 | caller_id = NULL; | ||
1397 | return; | ||
1398 | } | 1349 | } |
1399 | caller_id = ego; | ||
1400 | |||
1401 | // do not remove this, it tells the phone which line to use | ||
1402 | GNUNET_CONFIGURATION_set_value_number (cfg, | ||
1403 | "CONVERSATION", | ||
1404 | "LINE", | ||
1405 | line); | ||
1406 | if (NULL == phone) | ||
1407 | start_phone(); | ||
1408 | } | 1350 | } |
1409 | 1351 | ||
1352 | |||
1410 | /** | 1353 | /** |
1411 | * Get our configuration. | 1354 | * Get our configuration. |
1412 | * | 1355 | * |
@@ -1420,8 +1363,6 @@ GCG_get_configuration () | |||
1420 | } | 1363 | } |
1421 | 1364 | ||
1422 | 1365 | ||
1423 | |||
1424 | |||
1425 | /** | 1366 | /** |
1426 | * Task run on shutdown. | 1367 | * Task run on shutdown. |
1427 | * | 1368 | * |
@@ -1429,7 +1370,8 @@ GCG_get_configuration () | |||
1429 | * @param tc scheduler context, unused | 1370 | * @param tc scheduler context, unused |
1430 | */ | 1371 | */ |
1431 | static void | 1372 | static void |
1432 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 1373 | shutdown_task (void *cls, |
1374 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
1433 | { | 1375 | { |
1434 | 1376 | ||
1435 | //TODO: make this work | 1377 | //TODO: make this work |
@@ -1447,12 +1389,9 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1447 | oc); | 1389 | oc); |
1448 | GNUNET_free (oc); | 1390 | GNUNET_free (oc); |
1449 | } | 1391 | } |
1450 | if (NULL != identity) | ||
1451 | { | ||
1452 | GNUNET_IDENTITY_disconnect (identity); | ||
1453 | identity = NULL; | ||
1454 | } | ||
1455 | */ | 1392 | */ |
1393 | GCG_CONTACTS_shutdown(); | ||
1394 | GCG_EGOS_shutdown(); | ||
1456 | GNUNET_GTK_tray_icon_destroy (); | 1395 | GNUNET_GTK_tray_icon_destroy (); |
1457 | GNUNET_GTK_main_loop_quit (ml); | 1396 | GNUNET_GTK_main_loop_quit (ml); |
1458 | ml = NULL; | 1397 | ml = NULL; |
@@ -1479,18 +1418,6 @@ GNUNET_GTK_conversation_quit_cb (GObject *object, | |||
1479 | GNUNET_CONVERSATION_phone_destroy (phone); | 1418 | GNUNET_CONVERSATION_phone_destroy (phone); |
1480 | phone = NULL; | 1419 | phone = NULL; |
1481 | } | 1420 | } |
1482 | if (NULL != id) | ||
1483 | { | ||
1484 | GNUNET_IDENTITY_disconnect (id); | ||
1485 | id = NULL; | ||
1486 | } | ||
1487 | //if (NULL != ns) | ||
1488 | //{ | ||
1489 | // GNUNET_NAMESTORE_disconnect (ns); | ||
1490 | // ns = NULL; | ||
1491 | //} | ||
1492 | GNUNET_CONVERSATION_GTK_CONTACTS_shutdown(); | ||
1493 | |||
1494 | GNUNET_SPEAKER_destroy (speaker); | 1421 | GNUNET_SPEAKER_destroy (speaker); |
1495 | speaker = NULL; | 1422 | speaker = NULL; |
1496 | GNUNET_MICROPHONE_destroy (mic); | 1423 | GNUNET_MICROPHONE_destroy (mic); |
@@ -1498,7 +1425,6 @@ GNUNET_GTK_conversation_quit_cb (GObject *object, | |||
1498 | ego_name = NULL; | 1425 | ego_name = NULL; |
1499 | //GNUNET_free_non_null (peer_name); | 1426 | //GNUNET_free_non_null (peer_name); |
1500 | phone_state = PS_ERROR; | 1427 | phone_state = PS_ERROR; |
1501 | |||
1502 | GNUNET_SCHEDULER_shutdown (); | 1428 | GNUNET_SCHEDULER_shutdown (); |
1503 | } | 1429 | } |
1504 | 1430 | ||
@@ -1552,6 +1478,11 @@ run (void *cls, | |||
1552 | &shutdown_task, | 1478 | &shutdown_task, |
1553 | NULL); | 1479 | NULL); |
1554 | cfg = GNUNET_CONFIGURATION_dup (GCG_get_configuration ()); | 1480 | cfg = GNUNET_CONFIGURATION_dup (GCG_get_configuration ()); |
1481 | if (0 != line) | ||
1482 | GNUNET_CONFIGURATION_set_value_number (cfg, | ||
1483 | "CONVERSATION", | ||
1484 | "LINE", | ||
1485 | line); | ||
1555 | speaker = GNUNET_SPEAKER_create_from_hardware (cfg); | 1486 | speaker = GNUNET_SPEAKER_create_from_hardware (cfg); |
1556 | mic = GNUNET_MICROPHONE_create_from_hardware (cfg); | 1487 | mic = GNUNET_MICROPHONE_create_from_hardware (cfg); |
1557 | b_contact = GTK_WIDGET (GCG_get_main_window_object ("GNUNET_GTK_conversation_use_current_button")); | 1488 | b_contact = GTK_WIDGET (GCG_get_main_window_object ("GNUNET_GTK_conversation_use_current_button")); |
@@ -1564,9 +1495,8 @@ run (void *cls, | |||
1564 | ego_name = "phone-ego"; | 1495 | ego_name = "phone-ego"; |
1565 | GCG_log (_("No ego given, using default: %s "), ego_name); | 1496 | GCG_log (_("No ego given, using default: %s "), ego_name); |
1566 | } | 1497 | } |
1567 | id = GNUNET_IDENTITY_connect (cfg, | 1498 | GCG_EGOS_init (); |
1568 | &identity_cb, NULL); | 1499 | GCG_CONTACTS_init (); |
1569 | GNUNET_CONVERSATION_GTK_CONTACTS_init (); | ||
1570 | } | 1500 | } |
1571 | 1501 | ||
1572 | 1502 | ||