-fix build system issues
[oweals/gnunet.git] / src / conversation / gnunet-conversation.c
index 45ecdac916beafc31cb7ea9150d74946303129e7..a042629cc86be1a29f176871376aa403eecbcd92 100644 (file)
@@ -249,7 +249,7 @@ phone_event_handler (void *cls,
   {
   case GNUNET_CONVERSATION_EC_PHONE_RING:
     FPRINTF (stdout,
-             _("Incoming call from `%s'.\nPlease /accept #%u or /cancel %u the call.\n"),
+             _("Incoming call from `%s'. Please /accept #%u or /cancel %u the call.\n"),
              caller_id,
              caller_num_gen,
              caller_num_gen);
@@ -332,6 +332,7 @@ start_phone ()
     phone_state = PS_LOOKUP_EGO;
     return;
   }
+  GNUNET_assert (NULL == phone);
   phone = GNUNET_CONVERSATION_phone_create (cfg,
                                             caller_id,
                                             &phone_event_handler, NULL);
@@ -351,10 +352,9 @@ start_phone ()
     address = GNUNET_GNSRECORD_value_to_string (rd.record_type,
                                                 rd.data,
                                                 rd.data_size);
-    if (verbose)
-      FPRINTF (stdout,
-               _("Phone active on line %u\n"),
-               (unsigned int) line);
+    FPRINTF (stdout,
+             _("Phone active on line %u.  Type `/help' for a list of available commands\n"),
+             (unsigned int) line);
     phone_state = PS_LISTEN;
   }
 }
@@ -374,10 +374,9 @@ call_event_handler (void *cls,
   {
   case GNUNET_CONVERSATION_EC_CALL_RINGING:
     GNUNET_break (CS_RESOLVING == call_state);
-    if (verbose)
-      FPRINTF (stdout,
-               "%s",
-               _("Resolved address. Now ringing other party.\n"));
+    FPRINTF (stdout,
+             _("Resolved address of `%s'. Now ringing other party.\n"),
+             peer_name);
     call_state = CS_RINGING;
     break;
   case GNUNET_CONVERSATION_EC_CALL_PICKED_UP:
@@ -412,6 +411,11 @@ call_event_handler (void *cls,
              _("Connection to `%s' resumed (by other user)\n"),
              peer_name);
     break;
+  case GNUNET_CONVERSATION_EC_CALL_ERROR:
+    FPRINTF (stdout,
+             _("Error with the call, restarting it\n"));
+    call_state = CS_RESOLVING;
+    break;
   }
 }
 
@@ -522,8 +526,16 @@ do_call (const char *arg)
     break;
   }
   GNUNET_free_non_null (peer_name);
+  if (NULL == arg)
+  {
+    FPRINTF (stderr,
+             _("Call recipient missing.\n"));
+    do_help ("/call");
+    return;
+  }
   peer_name = GNUNET_strdup (arg);
   call_state = CS_RESOLVING;
+  GNUNET_assert (NULL == call);
   call = GNUNET_CONVERSATION_call_start (cfg,
                                          caller_id,
                                          arg,
@@ -787,7 +799,7 @@ do_resume (const char *args)
   case PS_ERROR:
     FPRINTF (stderr,
              "%s",
-             _("There is no call that could be suspended right now.\n"));
+             _("There is no call that could be resumed right now.\n"));
     return;
   case PS_LISTEN:
     /* expected state, do resume logic */
@@ -1011,8 +1023,6 @@ do_stop_task (void *cls,
   mic = NULL;
   GNUNET_free (ego_name);
   ego_name = NULL;
-  GNUNET_CONFIGURATION_destroy (cfg);
-  cfg = NULL;
   GNUNET_free_non_null (peer_name);
   phone_state = PS_ERROR;
 }
@@ -1054,6 +1064,8 @@ handle_command (void *cls,
   ptr = &message[strlen (commands[i].command)];
   while (isspace ((int) *ptr))
     ptr++;
+  if ('\0' == *ptr)
+    ptr = NULL;
   commands[i].Action (ptr);
 }
 
@@ -1173,6 +1185,11 @@ main (int argc, char *const *argv)
                            gettext_noop ("Enables having a conversation with other GNUnet users."),
                            options, &run, NULL);
   GNUNET_free ((void *) argv);
+  if (NULL != cfg)
+  {
+    GNUNET_CONFIGURATION_destroy (cfg);
+    cfg = NULL;
+  }
   return (GNUNET_OK == ret) ? 0 : 1;
 }