aboutsummaryrefslogtreecommitdiff
path: root/src/conversation
diff options
context:
space:
mode:
Diffstat (limited to 'src/conversation')
-rw-r--r--src/conversation/conversation_api.c6
-rw-r--r--src/conversation/conversation_api_call.c46
-rw-r--r--src/conversation/gnunet-conversation.c50
3 files changed, 65 insertions, 37 deletions
diff --git a/src/conversation/conversation_api.c b/src/conversation/conversation_api.c
index 0b3920633..00ee3d3ea 100644
--- a/src/conversation/conversation_api.c
+++ b/src/conversation/conversation_api.c
@@ -27,8 +27,6 @@
27 */ 27 */
28#include "platform.h" 28#include "platform.h"
29#include "gnunet_conversation_service.h" 29#include "gnunet_conversation_service.h"
30#include "gnunet_gnsrecord_lib.h"
31#include "gnunet_gns_service.h"
32#include "conversation.h" 30#include "conversation.h"
33 31
34 32
@@ -457,6 +455,9 @@ static int
457check_phone_audio (void *cls, 455check_phone_audio (void *cls,
458 const struct ClientAudioMessage *am) 456 const struct ClientAudioMessage *am)
459{ 457{
458 (void) cls;
459 (void) am;
460
460 /* any variable-size payload is OK */ 461 /* any variable-size payload is OK */
461 return GNUNET_OK; 462 return GNUNET_OK;
462} 463}
@@ -509,6 +510,7 @@ phone_error_handler (void *cls,
509{ 510{
510 struct GNUNET_CONVERSATION_Phone *phone = cls; 511 struct GNUNET_CONVERSATION_Phone *phone = cls;
511 512
513 (void) error;
512 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 514 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
513 _("Connection to conversation service lost, trying to reconnect\n")); 515 _("Connection to conversation service lost, trying to reconnect\n"));
514 reconnect_phone (phone); 516 reconnect_phone (phone);
diff --git a/src/conversation/conversation_api_call.c b/src/conversation/conversation_api_call.c
index 7e4a147a0..816920f0f 100644
--- a/src/conversation/conversation_api_call.c
+++ b/src/conversation/conversation_api_call.c
@@ -91,11 +91,6 @@ struct GNUNET_CONVERSATION_Call
91 struct GNUNET_IDENTITY_Ego *caller_id; 91 struct GNUNET_IDENTITY_Ego *caller_id;
92 92
93 /** 93 /**
94 * GNS zone to use to resolve @e callee.
95 */
96 struct GNUNET_IDENTITY_Ego *zone_id;
97
98 /**
99 * Target callee as a GNS address/name. 94 * Target callee as a GNS address/name.
100 */ 95 */
101 char *callee; 96 char *callee;
@@ -133,7 +128,7 @@ struct GNUNET_CONVERSATION_Call
133 /** 128 /**
134 * Active GNS lookup (or NULL). 129 * Active GNS lookup (or NULL).
135 */ 130 */
136 struct GNUNET_GNS_LookupRequest *gns_lookup; 131 struct GNUNET_GNS_LookupWithTldRequest *gns_lookup;
137 132
138 /** 133 /**
139 * Target phone record, only valid after the lookup is done. 134 * Target phone record, only valid after the lookup is done.
@@ -197,6 +192,7 @@ handle_call_suspend (void *cls,
197{ 192{
198 struct GNUNET_CONVERSATION_Call *call = cls; 193 struct GNUNET_CONVERSATION_Call *call = cls;
199 194
195 (void) msg;
200 switch (call->state) 196 switch (call->state)
201 { 197 {
202 case CS_LOOKUP: 198 case CS_LOOKUP:
@@ -242,6 +238,7 @@ handle_call_resume (void *cls,
242{ 238{
243 struct GNUNET_CONVERSATION_Call *call = cls; 239 struct GNUNET_CONVERSATION_Call *call = cls;
244 240
241 (void) msg;
245 switch (call->state) 242 switch (call->state)
246 { 243 {
247 case CS_LOOKUP: 244 case CS_LOOKUP:
@@ -291,6 +288,7 @@ handle_call_picked_up (void *cls,
291{ 288{
292 struct GNUNET_CONVERSATION_Call *call = cls; 289 struct GNUNET_CONVERSATION_Call *call = cls;
293 290
291 (void) msg;
294 switch (call->state) 292 switch (call->state)
295 { 293 {
296 case CS_LOOKUP: 294 case CS_LOOKUP:
@@ -334,6 +332,7 @@ handle_call_hangup (void *cls,
334 GNUNET_CONVERSATION_CallEventHandler eh; 332 GNUNET_CONVERSATION_CallEventHandler eh;
335 void *eh_cls; 333 void *eh_cls;
336 334
335 (void) msg;
337 switch (call->state) 336 switch (call->state)
338 { 337 {
339 case CS_LOOKUP: 338 case CS_LOOKUP:
@@ -369,6 +368,8 @@ static int
369check_call_audio (void *cls, 368check_call_audio (void *cls,
370 const struct ClientAudioMessage *am) 369 const struct ClientAudioMessage *am)
371{ 370{
371 (void) cls;
372 (void) am;
372 /* any payload is OK */ 373 /* any payload is OK */
373 return GNUNET_OK; 374 return GNUNET_OK;
374} 375}
@@ -421,23 +422,25 @@ handle_call_audio (void *cls,
421 * Iterator called on obtained result for a GNS lookup. 422 * Iterator called on obtained result for a GNS lookup.
422 * 423 *
423 * @param cls closure with the `struct GNUNET_CONVERSATION_Call` 424 * @param cls closure with the `struct GNUNET_CONVERSATION_Call`
425 * @param was_gns #GNUNET_NO if name was not a GNS name
424 * @param rd_count number of records in @a rd 426 * @param rd_count number of records in @a rd
425 * @param rd the records in reply 427 * @param rd the records in reply
426 */ 428 */
427static void 429static void
428handle_gns_response (void *cls, 430handle_gns_response (void *cls,
431 int was_gns,
429 uint32_t rd_count, 432 uint32_t rd_count,
430 const struct GNUNET_GNSRECORD_Data *rd) 433 const struct GNUNET_GNSRECORD_Data *rd)
431{ 434{
432 struct GNUNET_CONVERSATION_Call *call = cls; 435 struct GNUNET_CONVERSATION_Call *call = cls;
433 uint32_t i;
434 struct GNUNET_MQ_Envelope *e; 436 struct GNUNET_MQ_Envelope *e;
435 struct ClientCallMessage *ccm; 437 struct ClientCallMessage *ccm;
436 438
439 (void) was_gns;
437 GNUNET_break (NULL != call->gns_lookup); 440 GNUNET_break (NULL != call->gns_lookup);
438 GNUNET_break (CS_LOOKUP == call->state); 441 GNUNET_break (CS_LOOKUP == call->state);
439 call->gns_lookup = NULL; 442 call->gns_lookup = NULL;
440 for (i=0;i<rd_count;i++) 443 for (uint32_t i=0;i<rd_count;i++)
441 { 444 {
442 if (GNUNET_GNSRECORD_TYPE_PHONE == rd[i].record_type) 445 if (GNUNET_GNSRECORD_TYPE_PHONE == rd[i].record_type)
443 { 446 {
@@ -481,6 +484,7 @@ call_error_handler (void *cls,
481{ 484{
482 struct GNUNET_CONVERSATION_Call *call = cls; 485 struct GNUNET_CONVERSATION_Call *call = cls;
483 486
487 (void) error;
484 if (CS_SHUTDOWN == call->state) 488 if (CS_SHUTDOWN == call->state)
485 { 489 {
486 GNUNET_CONVERSATION_call_stop (call); 490 GNUNET_CONVERSATION_call_stop (call);
@@ -522,7 +526,6 @@ fail_call (struct GNUNET_CONVERSATION_Call *call)
522 * 526 *
523 * @param cfg configuration to use, specifies our phone service 527 * @param cfg configuration to use, specifies our phone service
524 * @param caller_id identity of the caller 528 * @param caller_id identity of the caller
525 * @param zone_id GNS zone to use to resolve @a callee
526 * @param callee GNS name of the callee (used to locate the callee's record) 529 * @param callee GNS name of the callee (used to locate the callee's record)
527 * @param speaker speaker to use (will be used automatically immediately once the 530 * @param speaker speaker to use (will be used automatically immediately once the
528 * #GNUNET_CONVERSATION_EC_CALL_PICKED_UP event is generated); we will NOT generate 531 * #GNUNET_CONVERSATION_EC_CALL_PICKED_UP event is generated); we will NOT generate
@@ -536,7 +539,6 @@ fail_call (struct GNUNET_CONVERSATION_Call *call)
536struct GNUNET_CONVERSATION_Call * 539struct GNUNET_CONVERSATION_Call *
537GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg, 540GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
538 struct GNUNET_IDENTITY_Ego *caller_id, 541 struct GNUNET_IDENTITY_Ego *caller_id,
539 struct GNUNET_IDENTITY_Ego *zone_id,
540 const char *callee, 542 const char *callee,
541 struct GNUNET_SPEAKER_Handle *speaker, 543 struct GNUNET_SPEAKER_Handle *speaker,
542 struct GNUNET_MICROPHONE_Handle *mic, 544 struct GNUNET_MICROPHONE_Handle *mic,
@@ -568,7 +570,6 @@ GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
568 call), 570 call),
569 GNUNET_MQ_handler_end () 571 GNUNET_MQ_handler_end ()
570 }; 572 };
571 struct GNUNET_CRYPTO_EcdsaPublicKey my_zone;
572 573
573 call->mq = GNUNET_CLIENT_connect (cfg, 574 call->mq = GNUNET_CLIENT_connect (cfg,
574 "conversation", 575 "conversation",
@@ -583,7 +584,6 @@ GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
583 } 584 }
584 call->cfg = cfg; 585 call->cfg = cfg;
585 call->caller_id = caller_id; 586 call->caller_id = caller_id;
586 call->zone_id = zone_id;
587 call->callee = GNUNET_strdup (callee); 587 call->callee = GNUNET_strdup (callee);
588 call->speaker = speaker; 588 call->speaker = speaker;
589 call->mic = mic; 589 call->mic = mic;
@@ -596,15 +596,17 @@ GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
596 return NULL; 596 return NULL;
597 } 597 }
598 call->state = CS_LOOKUP; 598 call->state = CS_LOOKUP;
599 GNUNET_IDENTITY_ego_get_public_key (call->zone_id, 599 call->gns_lookup = GNUNET_GNS_lookup_with_tld (call->gns,
600 &my_zone); 600 call->callee,
601 call->gns_lookup = GNUNET_GNS_lookup (call->gns, 601 GNUNET_GNSRECORD_TYPE_PHONE,
602 call->callee, 602 GNUNET_NO,
603 &my_zone, 603 &handle_gns_response,
604 GNUNET_GNSRECORD_TYPE_PHONE, 604 call);
605 GNUNET_NO, 605 if (NULL == call->gns_lookup)
606 &handle_gns_response, call); 606 {
607 GNUNET_assert (NULL != call->gns_lookup); 607 GNUNET_CONVERSATION_call_stop (call);
608 return NULL;
609 }
608 return call; 610 return call;
609} 611}
610 612
@@ -634,7 +636,7 @@ GNUNET_CONVERSATION_call_stop (struct GNUNET_CONVERSATION_Call *call)
634 } 636 }
635 if (NULL != call->gns_lookup) 637 if (NULL != call->gns_lookup)
636 { 638 {
637 GNUNET_GNS_lookup_cancel (call->gns_lookup); 639 GNUNET_GNS_lookup_with_tld_cancel (call->gns_lookup);
638 call->gns_lookup = NULL; 640 call->gns_lookup = NULL;
639 } 641 }
640 if (NULL != call->gns) 642 if (NULL != call->gns)
diff --git a/src/conversation/gnunet-conversation.c b/src/conversation/gnunet-conversation.c
index 00ab65680..70ccedbee 100644
--- a/src/conversation/gnunet-conversation.c
+++ b/src/conversation/gnunet-conversation.c
@@ -262,6 +262,7 @@ phone_event_handler (void *cls,
262{ 262{
263 struct CallList *cl; 263 struct CallList *cl;
264 264
265 (void) cls;
265 switch (code) 266 switch (code)
266 { 267 {
267 case GNUNET_CONVERSATION_EC_PHONE_RING: 268 case GNUNET_CONVERSATION_EC_PHONE_RING:
@@ -393,6 +394,8 @@ static void
393call_event_handler (void *cls, 394call_event_handler (void *cls,
394 enum GNUNET_CONVERSATION_CallEventCode code) 395 enum GNUNET_CONVERSATION_CallEventCode code)
395{ 396{
397 (void) cls;
398
396 switch (code) 399 switch (code)
397 { 400 {
398 case GNUNET_CONVERSATION_EC_CALL_RINGING: 401 case GNUNET_CONVERSATION_EC_CALL_RINGING:
@@ -454,7 +457,8 @@ call_event_handler (void *cls,
454 * 457 *
455 * @param arguments arguments given to the function 458 * @param arguments arguments given to the function
456 */ 459 */
457typedef void (*ActionFunction) (const char *arguments); 460typedef void
461(*ActionFunction) (const char *arguments);
458 462
459 463
460/** 464/**
@@ -496,6 +500,7 @@ do_help (const char *args);
496static void 500static void
497do_quit (const char *args) 501do_quit (const char *args)
498{ 502{
503 (void) args;
499 GNUNET_SCHEDULER_shutdown (); 504 GNUNET_SCHEDULER_shutdown ();
500} 505}
501 506
@@ -566,7 +571,6 @@ do_call (const char *arg)
566 GNUNET_assert (NULL == call); 571 GNUNET_assert (NULL == call);
567 call = GNUNET_CONVERSATION_call_start (cfg, 572 call = GNUNET_CONVERSATION_call_start (cfg,
568 my_caller_id, 573 my_caller_id,
569 my_caller_id,
570 arg, 574 arg,
571 speaker, 575 speaker,
572 mic, 576 mic,
@@ -656,6 +660,7 @@ do_accept (const char *args)
656static void 660static void
657do_address (const char *args) 661do_address (const char *args)
658{ 662{
663 (void) args;
659 if (NULL == address) 664 if (NULL == address)
660 { 665 {
661 FPRINTF (stdout, 666 FPRINTF (stdout,
@@ -679,6 +684,7 @@ do_status (const char *args)
679{ 684{
680 struct CallList *cl; 685 struct CallList *cl;
681 686
687 (void) args;
682 switch (phone_state) 688 switch (phone_state)
683 { 689 {
684 case PS_LOOKUP_EGO: 690 case PS_LOOKUP_EGO:
@@ -757,6 +763,7 @@ do_status (const char *args)
757static void 763static void
758do_suspend (const char *args) 764do_suspend (const char *args)
759{ 765{
766 (void) args;
760 if (NULL != call) 767 if (NULL != call)
761 { 768 {
762 switch (call_state) 769 switch (call_state)
@@ -1025,6 +1032,7 @@ do_help (const char *args)
1025static void 1032static void
1026do_stop_task (void *cls) 1033do_stop_task (void *cls)
1027{ 1034{
1035 (void) cls;
1028#ifdef WINDOWS 1036#ifdef WINDOWS
1029 if (NULL != stdin_hlp) 1037 if (NULL != stdin_hlp)
1030 { 1038 {
@@ -1107,6 +1115,8 @@ console_reader_chars (void *cls,
1107{ 1115{
1108 char *chars; 1116 char *chars;
1109 size_t str_size; 1117 size_t str_size;
1118
1119 (void) cls;
1110 switch (ntohs (message->type)) 1120 switch (ntohs (message->type))
1111 { 1121 {
1112 case GNUNET_MESSAGE_TYPE_W32_CONSOLE_HELPER_CHARS: 1122 case GNUNET_MESSAGE_TYPE_W32_CONSOLE_HELPER_CHARS:
@@ -1127,6 +1137,7 @@ console_reader_chars (void *cls,
1127} 1137}
1128#endif 1138#endif
1129 1139
1140
1130/** 1141/**
1131 * Task to handle commands from the terminal. 1142 * Task to handle commands from the terminal.
1132 * 1143 *
@@ -1137,15 +1148,21 @@ handle_command (void *cls)
1137{ 1148{
1138 char message[MAX_MESSAGE_LENGTH + 1]; 1149 char message[MAX_MESSAGE_LENGTH + 1];
1139 1150
1151 (void) cls;
1140 handle_cmd_task = 1152 handle_cmd_task =
1141 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, 1153 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
1142 stdin_fh, 1154 stdin_fh,
1143 &handle_command, NULL); 1155 &handle_command, NULL);
1144 /* read message from command line and handle it */ 1156 /* read message from command line and handle it */
1145 memset (message, 0, MAX_MESSAGE_LENGTH + 1); 1157 memset (message,
1146 if (NULL == fgets (message, MAX_MESSAGE_LENGTH, stdin)) 1158 0,
1159 MAX_MESSAGE_LENGTH + 1);
1160 if (NULL == fgets (message,
1161 MAX_MESSAGE_LENGTH,
1162 stdin))
1147 return; 1163 return;
1148 handle_command_string (message, strlen (message)); 1164 handle_command_string (message,
1165 strlen (message));
1149} 1166}
1150 1167
1151 1168
@@ -1163,6 +1180,8 @@ identity_cb (void *cls,
1163 void **ctx, 1180 void **ctx,
1164 const char *name) 1181 const char *name)
1165{ 1182{
1183 (void) cls;
1184 (void) ctx;
1166 if (NULL == name) 1185 if (NULL == name)
1167 return; 1186 return;
1168 if (ego == my_caller_id) 1187 if (ego == my_caller_id)
@@ -1210,6 +1229,9 @@ run (void *cls,
1210 const char *cfgfile, 1229 const char *cfgfile,
1211 const struct GNUNET_CONFIGURATION_Handle *c) 1230 const struct GNUNET_CONFIGURATION_Handle *c)
1212{ 1231{
1232 (void) cls;
1233 (void) args;
1234 (void) cfgfile;
1213 cfg = GNUNET_CONFIGURATION_dup (c); 1235 cfg = GNUNET_CONFIGURATION_dup (c);
1214 speaker = GNUNET_SPEAKER_create_from_hardware (cfg); 1236 speaker = GNUNET_SPEAKER_create_from_hardware (cfg);
1215 mic = GNUNET_MICROPHONE_create_from_hardware (cfg); 1237 mic = GNUNET_MICROPHONE_create_from_hardware (cfg);
@@ -1263,22 +1285,20 @@ run (void *cls,
1263 * @return 0 ok, 1 on error 1285 * @return 0 ok, 1 on error
1264 */ 1286 */
1265int 1287int
1266main (int argc, char *const *argv) 1288main (int argc,
1289 char *const *argv)
1267{ 1290{
1268 struct GNUNET_GETOPT_CommandLineOption options[] = { 1291 struct GNUNET_GETOPT_CommandLineOption options[] = {
1269
1270 GNUNET_GETOPT_option_string ('e', 1292 GNUNET_GETOPT_option_string ('e',
1271 "ego", 1293 "ego",
1272 "NAME", 1294 "NAME",
1273 gettext_noop ("sets the NAME of the ego to use for the phone (and name resolution)"), 1295 gettext_noop ("sets the NAME of the ego to use for the caller ID"),
1274 &ego_name), 1296 &ego_name),
1275
1276 GNUNET_GETOPT_option_string ('p', 1297 GNUNET_GETOPT_option_string ('p',
1277 "phone", 1298 "phone",
1278 "LINE", 1299 "LINE",
1279 gettext_noop ("sets the LINE to use for the phone"), 1300 gettext_noop ("sets the LINE to use for the phone"),
1280 &line), 1301 &line),
1281
1282 GNUNET_GETOPT_OPTION_END 1302 GNUNET_GETOPT_OPTION_END
1283 }; 1303 };
1284 int ret; 1304 int ret;
@@ -1299,12 +1319,16 @@ main (int argc, char *const *argv)
1299 stdin_fh = GNUNET_DISK_get_handle_from_int_fd (0); 1319 stdin_fh = GNUNET_DISK_get_handle_from_int_fd (0);
1300#endif 1320#endif
1301 1321
1302 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 1322 if (GNUNET_OK !=
1323 GNUNET_STRINGS_get_utf8_args (argc, argv,
1324 &argc, &argv))
1303 return 2; 1325 return 2;
1304 ret = GNUNET_PROGRAM_run (argc, argv, 1326 ret = GNUNET_PROGRAM_run (argc,
1327 argv,
1305 "gnunet-conversation", 1328 "gnunet-conversation",
1306 gettext_noop ("Enables having a conversation with other GNUnet users."), 1329 gettext_noop ("Enables having a conversation with other GNUnet users."),
1307 options, &run, NULL); 1330 options,
1331 &run, NULL);
1308 GNUNET_free ((void *) argv); 1332 GNUNET_free ((void *) argv);
1309 if (NULL != cfg) 1333 if (NULL != cfg)
1310 { 1334 {