/*
This file is part of GNUnet.
(C) 2013 Christian Grothoff (and other contributing authors)
-
+
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your
option) any later version.
-
+
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_conversation_service.h"
+#include "gnunet_namestore_service.h"
/**
*/
static enum ConversationState state;
+/**
+ * GNS address for this phone.
+ */
+static char *address;
+
/**
* Be verbose.
*/
...)
{
va_list va;
-
+
va_start (va, code);
switch (code)
{
static void
start_phone ()
{
+ struct GNUNET_NAMESTORE_RecordData rd;
+
if (NULL == caller_id)
{
FPRINTF (stderr,
}
else
{
+ GNUNET_CONVERSATION_phone_get_record (phone,
+ &rd);
+ GNUNET_free_non_null (address);
+ address = GNUNET_NAMESTORE_value_to_string (rd.record_type,
+ rd.data,
+ rd.data_size);
if (verbose)
FPRINTF (stdout,
_("Phone active on line %u\n"),
...)
{
va_list va;
-
+
va_start (va, code);
switch (code)
{
case GNUNET_CONVERSATION_EC_READY:
GNUNET_break (CS_RINGING == state);
FPRINTF (stdout,
- _("Connection established: %s\n"),
+ _("Connection established to `%s': %s\n"),
+ peer_name,
va_arg (va, const char *));
state = CS_CONNECTED;
break;
case GNUNET_CONVERSATION_EC_GNS_FAIL:
GNUNET_break (CS_RESOLVING == state);
FPRINTF (stdout,
- "%s",
- _("Failed to resolve name\n"));
- GNUNET_CONVERSATION_call_stop (call, NULL);
+ _("Failed to resolve `%s'\n"),
+ ego_name);
call = NULL;
start_phone ();
break;
FPRINTF (stdout,
"%s",
_("Line busy\n"));
- GNUNET_CONVERSATION_call_stop (call, NULL);
call = NULL;
start_phone ();
break;
FPRINTF (stdout,
_("Call terminated: %s\n"),
va_arg (va, const char *));
- GNUNET_CONVERSATION_call_stop (call, NULL);
call = NULL;
start_phone ();
break;
* Command the user needs to enter.
*/
const char *command;
-
+
/**
* Function to call on command.
*/
/**
* Action function to print help for the command shell.
*
- * @param arguments arguments given to the command
+ * @param args arguments given to the command
*/
static void
do_help (const char *args);
/**
* Handler for unknown command.
*
- * @param args arguments given to the command
+ * @param msg arguments given to the command
*/
static void
do_unknown (const char *msg)
{
- FPRINTF (stderr,
- _("Unknown command `%s'\n"),
+ FPRINTF (stderr,
+ _("Unknown command `%s'\n"),
msg);
}
/**
* Initiating a new call
*
- * @param args arguments given to the command
+ * @param arg arguments given to the command
*/
static void
do_call (const char *arg)
}
switch (state)
{
- case CS_LOOKUP_EGO:
+ case CS_LOOKUP_EGO:
FPRINTF (stderr,
_("Ego `%s' not available\n"),
ego_name);
{
switch (state)
{
- case CS_LOOKUP_EGO:
+ case CS_LOOKUP_EGO:
case CS_LISTEN:
case CS_ERROR:
FPRINTF (stderr,
return;
}
GNUNET_assert (NULL != phone);
- GNUNET_CONVERSATION_phone_pick_up (phone,
+ GNUNET_CONVERSATION_phone_pick_up (phone,
args,
speaker,
mic);
}
+/**
+ * Print address information for this phone.
+ *
+ * @param args arguments given to the command
+ */
+static void
+do_address (const char *args)
+{
+ if (NULL == address)
+ {
+ FPRINTF (stdout,
+ "%s",
+ _("We currently do not have an address.\n"));
+ return;
+ }
+ FPRINTF (stdout,
+ "%s\n",
+ address);
+}
+
+
/**
* Accepting an incoming call
*
{
switch (state)
{
- case CS_LOOKUP_EGO:
+ case CS_LOOKUP_EGO:
FPRINTF (stdout,
_("We are currently trying to locate the private key for the ego `%s'.\n"),
ego_name);
{
switch (state)
{
- case CS_LOOKUP_EGO:
+ case CS_LOOKUP_EGO:
case CS_LISTEN:
case CS_ERROR:
FPRINTF (stderr,
if (NULL == call)
{
GNUNET_assert (NULL != phone);
- GNUNET_CONVERSATION_phone_hang_up (phone,
+ GNUNET_CONVERSATION_phone_hang_up (phone,
args);
state = CS_LISTEN;
}
* List of supported commands.
*/
static struct VoipCommand commands[] = {
- {"/call", &do_call,
- gettext_noop ("Use `/call USER.gnu'")},
+ {"/address", &do_address,
+ gettext_noop ("Use `/address' to find out which address this phone should have in GNS")},
+ {"/call", &do_call,
+ gettext_noop ("Use `/call USER.gnu' to call USER")},
{"/accept", &do_accept,
gettext_noop ("Use `/accept MESSAGE' to accept an incoming call")},
{"/cancel", &do_reject,
gettext_noop ("Use `/cancel MESSAGE' to reject or terminate a call")},
{"/status", &do_status,
- gettext_noop ("Use `/status to print status information")},
- {"/quit", &do_quit,
+ gettext_noop ("Use `/status' to print status information")},
+ {"/quit", &do_quit,
gettext_noop ("Use `/quit' to terminate gnunet-conversation")},
{"/help", &do_help,
gettext_noop ("Use `/help command' to get help for a specific command")},
- {"", &do_unknown,
+ {"", &do_unknown,
NULL},
{NULL, NULL, NULL},
};
do_help (const char *args)
{
unsigned int i;
-
- i = 0;
+
+ i = 0;
while ( (NULL != args) &&
(0 != strlen (args)) &&
(commands[i].Action != &do_help))
if (0 ==
strncasecmp (&args[1], &commands[i].command[1], strlen (args) - 1))
{
- FPRINTF (stdout,
+ FPRINTF (stdout,
"%s\n",
gettext (commands[i].helptext));
return;
i++;
}
i = 0;
- FPRINTF (stdout,
- "%s",
+ FPRINTF (stdout,
+ "%s",
"Available commands:\n");
while (commands[i].Action != &do_help)
{
- FPRINTF (stdout,
- "%s\n",
+ FPRINTF (stdout,
+ "%s\n",
gettext (commands[i].command));
i++;
}
{
GNUNET_SCHEDULER_cancel (handle_cmd_task);
handle_cmd_task = GNUNET_SCHEDULER_NO_TASK;
- }
+ }
if (NULL != id)
{
GNUNET_IDENTITY_disconnect (id);
ego_name))
return;
if (NULL == ego)
- {
+ {
if (verbose)
FPRINTF (stdout,
_("Our ego `%s' was deleted!\n"),
*/
static void
run (void *cls,
- char *const *args,
+ char *const *args,
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *c)
{
}
-/**
+/**
* The main function to conversation.
*
* @param argc number of arguments from the command line