-bringing copyright tags up to FSF standard
[oweals/gnunet.git] / src / conversation / gnunet-conversation.c
index 7d5cb990a7d8c876652354af6786d2697866444c..5861be184daecef40c07938f999be9e2007844ec 100644 (file)
@@ -1,6 +1,6 @@
 /*
   This file is part of GNUnet.
-  (C) 2013 Christian Grothoff (and other contributing authors)
+  Copyright (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
@@ -104,7 +104,6 @@ enum CallState
 };
 
 
-
 /**
  * List of incoming calls
  */
@@ -152,6 +151,7 @@ static struct GNUNET_CONVERSATION_Call *call;
 
 /**
  * Caller handle (for active incoming call).
+ * This call handler is NOT in the #cl_head / #cl_tail list.
  */
 static struct CallList *cl_active;
 
@@ -266,7 +266,7 @@ phone_event_handler (void *cls,
   {
   case GNUNET_CONVERSATION_EC_PHONE_RING:
     FPRINTF (stdout,
-             _("Incoming call from `%s'. Please /accept #%u or /cancel %u the call.\n"),
+             _("Incoming call from `%s'. Please /accept %u or /cancel %u the call.\n"),
              GNUNET_GNSRECORD_pkey_to_zkey (caller_id),
              caller_num_gen,
              caller_num_gen);
@@ -282,6 +282,9 @@ phone_event_handler (void *cls,
     for (cl = cl_head; NULL != cl; cl = cl->next)
       if (caller == cl->caller)
         break;
+    if ( (NULL == cl) &&
+         (caller == cl_active->caller) )
+      cl = cl_active;
     if (NULL == cl)
     {
       GNUNET_break (0);
@@ -290,14 +293,17 @@ phone_event_handler (void *cls,
     FPRINTF (stdout,
              _("Call from `%s' terminated\n"),
              GNUNET_GNSRECORD_pkey_to_zkey (&cl->caller_id));
-    GNUNET_CONTAINER_DLL_remove (cl_head,
-                                 cl_tail,
-                                 cl);
     if (cl == cl_active)
     {
       cl_active = NULL;
       phone_state = PS_LISTEN;
     }
+    else
+    {
+      GNUNET_CONTAINER_DLL_remove (cl_head,
+                                   cl_tail,
+                                   cl);
+    }
     GNUNET_free (cl);
     break;
   }
@@ -434,8 +440,9 @@ call_event_handler (void *cls,
   case GNUNET_CONVERSATION_EC_CALL_ERROR:
     FPRINTF (stdout,
              _("Error with the call, restarting it\n"));
-    call_state = CS_RESOLVING;
-    // FIXME: is this correct?
+    GNUNET_free (peer_name);
+    peer_name = NULL;
+    call = NULL;
     break;
   }
 }