-fix mesh tunnel destruction
[oweals/gnunet.git] / src / conversation / gnunet-conversation.c
index fdf6155fd6f2b53f226b663917ec03babd7fdb10..90b98b36fb3fbfaf95d40f9870be9ef8ba23abfa 100644 (file)
@@ -27,6 +27,7 @@
 #include "gnunet_util_lib.h"
 #include "gnunet_constants.h"
 #include "gnunet_conversation_service.h"
+#include "gnunet_namestore_service.h"
 
 
 /**
@@ -148,6 +149,11 @@ static struct GNUNET_DISK_FileHandle *stdin_fh;
  */
 static enum ConversationState state;
 
+/**
+ * GNS address for this phone.
+ */
+static char *address;
+
 /**
  * Be verbose.
  */
@@ -211,6 +217,8 @@ phone_event_handler (void *cls,
 static void
 start_phone ()
 {
+  struct GNUNET_NAMESTORE_RecordData rd;
+
   if (NULL == caller_id)
   {
     FPRINTF (stderr,
@@ -232,6 +240,12 @@ start_phone ()
   }
   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"),
@@ -272,15 +286,16 @@ call_event_handler (void *cls,
   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"));
+             _("Failed to resolve `%s'\n"),
+             ego_name);
     GNUNET_CONVERSATION_call_stop (call, NULL);
     call = NULL;
     start_phone ();
@@ -493,6 +508,27 @@ do_accept (const char *args)
 }
 
 
+/**
+ * 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
  *
@@ -588,14 +624,16 @@ do_reject (const char *args)
  * List of supported commands.
  */
 static struct VoipCommand commands[] = {
+  {"/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'")},
+   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")},
+   gettext_noop ("Use `/status' to print status information")},
   {"/quit", &do_quit, 
    gettext_noop ("Use `/quit' to terminate gnunet-conversation")},
   {"/help", &do_help,