From 1ac9fb8bc3555213fda82ef3dd974a6b30e45b25 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 5 Mar 2018 20:44:15 +0100 Subject: update gnunet-conversation to match .gnu-less GNS --- doc/man/gnunet-conversation.1 | 2 +- src/conversation/conversation_api.c | 6 ++-- src/conversation/conversation_api_call.c | 46 ++++++++++++++-------------- src/conversation/gnunet-conversation.c | 50 +++++++++++++++++++++++-------- src/include/gnunet_conversation_service.h | 2 -- 5 files changed, 66 insertions(+), 40 deletions(-) diff --git a/doc/man/gnunet-conversation.1 b/doc/man/gnunet-conversation.1 index 5048bdbcd..912d2a17e 100644 --- a/doc/man/gnunet-conversation.1 +++ b/doc/man/gnunet-conversation.1 @@ -17,7 +17,7 @@ gnunet\-conversation \- have a conversation with your peers Use the configuration file FILENAME. .B .IP "\-e NAME, \-\-ego=NAME" -Specifies the NAME of the ego to use (for caller ID) and the GNS master zone for our own lookups. +Specifies the NAME of the ego to use (for caller ID). .B .IP "\-h, \-\-help" Print short help on options. 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 @@ */ #include "platform.h" #include "gnunet_conversation_service.h" -#include "gnunet_gnsrecord_lib.h" -#include "gnunet_gns_service.h" #include "conversation.h" @@ -457,6 +455,9 @@ static int check_phone_audio (void *cls, const struct ClientAudioMessage *am) { + (void) cls; + (void) am; + /* any variable-size payload is OK */ return GNUNET_OK; } @@ -509,6 +510,7 @@ phone_error_handler (void *cls, { struct GNUNET_CONVERSATION_Phone *phone = cls; + (void) error; GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Connection to conversation service lost, trying to reconnect\n")); 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 @@ -90,11 +90,6 @@ struct GNUNET_CONVERSATION_Call */ struct GNUNET_IDENTITY_Ego *caller_id; - /** - * GNS zone to use to resolve @e callee. - */ - struct GNUNET_IDENTITY_Ego *zone_id; - /** * Target callee as a GNS address/name. */ @@ -133,7 +128,7 @@ struct GNUNET_CONVERSATION_Call /** * Active GNS lookup (or NULL). */ - struct GNUNET_GNS_LookupRequest *gns_lookup; + struct GNUNET_GNS_LookupWithTldRequest *gns_lookup; /** * Target phone record, only valid after the lookup is done. @@ -197,6 +192,7 @@ handle_call_suspend (void *cls, { struct GNUNET_CONVERSATION_Call *call = cls; + (void) msg; switch (call->state) { case CS_LOOKUP: @@ -242,6 +238,7 @@ handle_call_resume (void *cls, { struct GNUNET_CONVERSATION_Call *call = cls; + (void) msg; switch (call->state) { case CS_LOOKUP: @@ -291,6 +288,7 @@ handle_call_picked_up (void *cls, { struct GNUNET_CONVERSATION_Call *call = cls; + (void) msg; switch (call->state) { case CS_LOOKUP: @@ -334,6 +332,7 @@ handle_call_hangup (void *cls, GNUNET_CONVERSATION_CallEventHandler eh; void *eh_cls; + (void) msg; switch (call->state) { case CS_LOOKUP: @@ -369,6 +368,8 @@ static int check_call_audio (void *cls, const struct ClientAudioMessage *am) { + (void) cls; + (void) am; /* any payload is OK */ return GNUNET_OK; } @@ -421,23 +422,25 @@ handle_call_audio (void *cls, * Iterator called on obtained result for a GNS lookup. * * @param cls closure with the `struct GNUNET_CONVERSATION_Call` + * @param was_gns #GNUNET_NO if name was not a GNS name * @param rd_count number of records in @a rd * @param rd the records in reply */ static void handle_gns_response (void *cls, + int was_gns, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd) { struct GNUNET_CONVERSATION_Call *call = cls; - uint32_t i; struct GNUNET_MQ_Envelope *e; struct ClientCallMessage *ccm; + (void) was_gns; GNUNET_break (NULL != call->gns_lookup); GNUNET_break (CS_LOOKUP == call->state); call->gns_lookup = NULL; - for (i=0;istate) { GNUNET_CONVERSATION_call_stop (call); @@ -522,7 +526,6 @@ fail_call (struct GNUNET_CONVERSATION_Call *call) * * @param cfg configuration to use, specifies our phone service * @param caller_id identity of the caller - * @param zone_id GNS zone to use to resolve @a callee * @param callee GNS name of the callee (used to locate the callee's record) * @param speaker speaker to use (will be used automatically immediately once the * #GNUNET_CONVERSATION_EC_CALL_PICKED_UP event is generated); we will NOT generate @@ -536,7 +539,6 @@ fail_call (struct GNUNET_CONVERSATION_Call *call) struct GNUNET_CONVERSATION_Call * GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_IDENTITY_Ego *caller_id, - struct GNUNET_IDENTITY_Ego *zone_id, const char *callee, struct GNUNET_SPEAKER_Handle *speaker, struct GNUNET_MICROPHONE_Handle *mic, @@ -568,7 +570,6 @@ GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg, call), GNUNET_MQ_handler_end () }; - struct GNUNET_CRYPTO_EcdsaPublicKey my_zone; call->mq = GNUNET_CLIENT_connect (cfg, "conversation", @@ -583,7 +584,6 @@ GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg, } call->cfg = cfg; call->caller_id = caller_id; - call->zone_id = zone_id; call->callee = GNUNET_strdup (callee); call->speaker = speaker; call->mic = mic; @@ -596,15 +596,17 @@ GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg, return NULL; } call->state = CS_LOOKUP; - GNUNET_IDENTITY_ego_get_public_key (call->zone_id, - &my_zone); - call->gns_lookup = GNUNET_GNS_lookup (call->gns, - call->callee, - &my_zone, - GNUNET_GNSRECORD_TYPE_PHONE, - GNUNET_NO, - &handle_gns_response, call); - GNUNET_assert (NULL != call->gns_lookup); + call->gns_lookup = GNUNET_GNS_lookup_with_tld (call->gns, + call->callee, + GNUNET_GNSRECORD_TYPE_PHONE, + GNUNET_NO, + &handle_gns_response, + call); + if (NULL == call->gns_lookup) + { + GNUNET_CONVERSATION_call_stop (call); + return NULL; + } return call; } @@ -634,7 +636,7 @@ GNUNET_CONVERSATION_call_stop (struct GNUNET_CONVERSATION_Call *call) } if (NULL != call->gns_lookup) { - GNUNET_GNS_lookup_cancel (call->gns_lookup); + GNUNET_GNS_lookup_with_tld_cancel (call->gns_lookup); call->gns_lookup = NULL; } 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, { struct CallList *cl; + (void) cls; switch (code) { case GNUNET_CONVERSATION_EC_PHONE_RING: @@ -393,6 +394,8 @@ static void call_event_handler (void *cls, enum GNUNET_CONVERSATION_CallEventCode code) { + (void) cls; + switch (code) { case GNUNET_CONVERSATION_EC_CALL_RINGING: @@ -454,7 +457,8 @@ call_event_handler (void *cls, * * @param arguments arguments given to the function */ -typedef void (*ActionFunction) (const char *arguments); +typedef void +(*ActionFunction) (const char *arguments); /** @@ -496,6 +500,7 @@ do_help (const char *args); static void do_quit (const char *args) { + (void) args; GNUNET_SCHEDULER_shutdown (); } @@ -565,7 +570,6 @@ do_call (const char *arg) call_state = CS_RESOLVING; GNUNET_assert (NULL == call); call = GNUNET_CONVERSATION_call_start (cfg, - my_caller_id, my_caller_id, arg, speaker, @@ -656,6 +660,7 @@ do_accept (const char *args) static void do_address (const char *args) { + (void) args; if (NULL == address) { FPRINTF (stdout, @@ -679,6 +684,7 @@ do_status (const char *args) { struct CallList *cl; + (void) args; switch (phone_state) { case PS_LOOKUP_EGO: @@ -757,6 +763,7 @@ do_status (const char *args) static void do_suspend (const char *args) { + (void) args; if (NULL != call) { switch (call_state) @@ -1025,6 +1032,7 @@ do_help (const char *args) static void do_stop_task (void *cls) { + (void) cls; #ifdef WINDOWS if (NULL != stdin_hlp) { @@ -1107,6 +1115,8 @@ console_reader_chars (void *cls, { char *chars; size_t str_size; + + (void) cls; switch (ntohs (message->type)) { case GNUNET_MESSAGE_TYPE_W32_CONSOLE_HELPER_CHARS: @@ -1127,6 +1137,7 @@ console_reader_chars (void *cls, } #endif + /** * Task to handle commands from the terminal. * @@ -1137,15 +1148,21 @@ handle_command (void *cls) { char message[MAX_MESSAGE_LENGTH + 1]; + (void) cls; handle_cmd_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, stdin_fh, &handle_command, NULL); /* read message from command line and handle it */ - memset (message, 0, MAX_MESSAGE_LENGTH + 1); - if (NULL == fgets (message, MAX_MESSAGE_LENGTH, stdin)) + memset (message, + 0, + MAX_MESSAGE_LENGTH + 1); + if (NULL == fgets (message, + MAX_MESSAGE_LENGTH, + stdin)) return; - handle_command_string (message, strlen (message)); + handle_command_string (message, + strlen (message)); } @@ -1163,6 +1180,8 @@ identity_cb (void *cls, void **ctx, const char *name) { + (void) cls; + (void) ctx; if (NULL == name) return; if (ego == my_caller_id) @@ -1210,6 +1229,9 @@ run (void *cls, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { + (void) cls; + (void) args; + (void) cfgfile; cfg = GNUNET_CONFIGURATION_dup (c); speaker = GNUNET_SPEAKER_create_from_hardware (cfg); mic = GNUNET_MICROPHONE_create_from_hardware (cfg); @@ -1263,22 +1285,20 @@ run (void *cls, * @return 0 ok, 1 on error */ int -main (int argc, char *const *argv) +main (int argc, + char *const *argv) { struct GNUNET_GETOPT_CommandLineOption options[] = { - GNUNET_GETOPT_option_string ('e', "ego", "NAME", - gettext_noop ("sets the NAME of the ego to use for the phone (and name resolution)"), + gettext_noop ("sets the NAME of the ego to use for the caller ID"), &ego_name), - GNUNET_GETOPT_option_string ('p', "phone", "LINE", gettext_noop ("sets the LINE to use for the phone"), &line), - GNUNET_GETOPT_OPTION_END }; int ret; @@ -1299,12 +1319,16 @@ main (int argc, char *const *argv) stdin_fh = GNUNET_DISK_get_handle_from_int_fd (0); #endif - if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) + if (GNUNET_OK != + GNUNET_STRINGS_get_utf8_args (argc, argv, + &argc, &argv)) return 2; - ret = GNUNET_PROGRAM_run (argc, argv, + ret = GNUNET_PROGRAM_run (argc, + argv, "gnunet-conversation", gettext_noop ("Enables having a conversation with other GNUnet users."), - options, &run, NULL); + options, + &run, NULL); GNUNET_free ((void *) argv); if (NULL != cfg) { diff --git a/src/include/gnunet_conversation_service.h b/src/include/gnunet_conversation_service.h index 88eb7a585..eedf4937b 100644 --- a/src/include/gnunet_conversation_service.h +++ b/src/include/gnunet_conversation_service.h @@ -374,7 +374,6 @@ typedef void * * @param cfg configuration to use, specifies our phone service * @param caller_id identity of the caller - * @param zone_id GNS zone to use to resolve @a callee * @param callee GNS name of the callee (used to locate the callee's record) * @param speaker speaker to use (will be used automatically immediately once the * #GNUNET_CONVERSATION_EC_CALL_PICKED_UP event is generated); we will NOT generate @@ -388,7 +387,6 @@ typedef void struct GNUNET_CONVERSATION_Call * GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_IDENTITY_Ego *caller_id, - struct GNUNET_IDENTITY_Ego *zone_id, const char *callee, struct GNUNET_SPEAKER_Handle *speaker, struct GNUNET_MICROPHONE_Handle *mic, -- cgit v1.2.3