gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r33551 - in gnunet/src: conversation include


From: gnunet
Subject: [GNUnet-SVN] r33551 - in gnunet/src: conversation include
Date: Fri, 6 Jun 2014 10:43:16 +0200

Author: grothoff
Date: 2014-06-06 10:43:16 +0200 (Fri, 06 Jun 2014)
New Revision: 33551

Modified:
   gnunet/src/conversation/conversation_api.c
   gnunet/src/conversation/gnunet-conversation.c
   gnunet/src/conversation/test_conversation_api.c
   gnunet/src/conversation/test_conversation_api_reject.c
   gnunet/src/conversation/test_conversation_api_twocalls.c
   gnunet/src/include/gnunet_conversation_service.h
   gnunet/src/include/gnunet_namestore_service.h
Log:
addressing #3431

Modified: gnunet/src/conversation/conversation_api.c
===================================================================
--- gnunet/src/conversation/conversation_api.c  2014-06-06 08:12:49 UTC (rev 
33550)
+++ gnunet/src/conversation/conversation_api.c  2014-06-06 08:43:16 UTC (rev 
33551)
@@ -1,6 +1,6 @@
 /*
   This file is part of GNUnet
-  (C) 2013 Christian Grothoff (and other contributing authors)
+  (C) 2013, 2014 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
@@ -38,11 +38,6 @@
 enum CallerState
 {
   /**
-   * We still need to reverse lookup the caller ID.
-   */
-  CS_RESOLVE,
-
-  /**
    * The phone is ringing (user knows about incoming call).
    */
   CS_RINGING,
@@ -112,21 +107,11 @@
   struct GNUNET_MICROPHONE_Handle *mic;
 
   /**
-   * Active NAMESTORE lookup (or NULL).
-   */
-  struct GNUNET_NAMESTORE_QueueEntry *qe;
-
-  /**
    * Identity of the person calling us.
    */
   struct GNUNET_CRYPTO_EcdsaPublicKey caller_id;
 
   /**
-   * Caller ID of the person calling us as a string.
-   */
-  char *caller_id_str;
-
-  /**
    * Internal handle to identify the caller with the service.
    */
   uint32_t cid;
@@ -238,40 +223,6 @@
 
 
 /**
- * We have resolved the caller ID using our name service.
- *
- * @param cls the `struct GNUNET_CONVERSATION_Caller`
- * @param zone our zone used for resolution
- * @param label name of the caller
- * @param rd_count number of records we have in @a rd
- * @param rd records we have for the caller's label
- */
-static void
-handle_caller_name (void *cls,
-                    const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
-                    const char *label,
-                    unsigned int rd_count,
-                    const struct GNUNET_GNSRECORD_Data *rd)
-{
-  struct GNUNET_CONVERSATION_Caller *caller = cls;
-  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
-  char *name;
-
-  caller->qe = NULL;
-  if (NULL == label)
-    name = GNUNET_strdup (GNUNET_GNSRECORD_pkey_to_zkey (&caller->caller_id));
-  else
-    GNUNET_asprintf (&name, "%s.gnu", label);
-  caller->caller_id_str = name;
-  caller->state = CS_RINGING;
-  phone->event_handler (phone->event_handler_cls,
-                        GNUNET_CONVERSATION_EC_PHONE_RING,
-                        caller,
-                        name);
-}
-
-
-/**
  * Process recorded audio data.
  *
  * @param cls closure with the `struct GNUNET_CONVERSATION_Caller`
@@ -323,14 +274,13 @@
     GNUNET_CONTAINER_DLL_insert (phone->caller_head,
                                  phone->caller_tail,
                                  caller);
-    caller->state = CS_RESOLVE;
     caller->caller_id = ring->caller_id;
     caller->cid = ring->cid;
-    caller->qe = GNUNET_NAMESTORE_zone_to_name (phone->ns,
-                                                &phone->my_zone,
-                                                &ring->caller_id,
-                                                &handle_caller_name,
-                                                caller);
+    caller->state = CS_RINGING;
+    phone->event_handler (phone->event_handler_cls,
+                          GNUNET_CONVERSATION_EC_PHONE_RING,
+                          caller,
+                          &caller->caller_id);
     break;
   }
 }
@@ -364,19 +314,14 @@
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received HANG_UP message, terminating call with `%s'\n",
-              caller->caller_id_str);
+              GNUNET_GNSRECORD_pkey_to_zkey (&caller->caller_id));
   switch (caller->state)
   {
-  case CS_RESOLVE:
-    /* application doesn't even know about call yet */
-    GNUNET_NAMESTORE_cancel (caller->qe);
-    caller->qe = NULL;
-    break;
   case CS_RINGING:
     phone->event_handler (phone->event_handler_cls,
                           GNUNET_CONVERSATION_EC_PHONE_HUNG_UP,
                           caller,
-                          caller->caller_id_str);
+                          &caller->caller_id);
     break;
   case CS_ACTIVE:
     caller->speaker->disable_speaker (caller->speaker->cls);
@@ -384,7 +329,7 @@
     phone->event_handler (phone->event_handler_cls,
                           GNUNET_CONVERSATION_EC_PHONE_HUNG_UP,
                           caller,
-                          caller->caller_id_str);
+                          &caller->caller_id);
     break;
   case CS_CALLEE_SUSPENDED:
   case CS_CALLER_SUSPENDED:
@@ -392,7 +337,7 @@
     phone->event_handler (phone->event_handler_cls,
                           GNUNET_CONVERSATION_EC_PHONE_HUNG_UP,
                           caller,
-                          caller->caller_id_str);
+                          &caller->caller_id);
     break;
   }
   GNUNET_CONTAINER_DLL_remove (phone->caller_head,
@@ -424,9 +369,6 @@
     return;
   switch (caller->state)
   {
-  case CS_RESOLVE:
-    GNUNET_break_op (0);
-    break;
   case CS_RINGING:
     GNUNET_break_op (0);
     break;
@@ -472,9 +414,6 @@
     return;
   switch (caller->state)
   {
-  case CS_RESOLVE:
-    GNUNET_break_op (0);
-    break;
   case CS_RINGING:
     GNUNET_break_op (0);
     break;
@@ -522,9 +461,6 @@
     return;
   switch (caller->state)
   {
-  case CS_RESOLVE:
-    GNUNET_break_op (0);
-    break;
   case CS_RINGING:
     GNUNET_break_op (0);
     break;
@@ -581,7 +517,7 @@
     phone->event_handler (phone->event_handler_cls,
                           GNUNET_CONVERSATION_EC_PHONE_HUNG_UP,
                           caller,
-                          caller->caller_id_str);
+                          &caller->caller_id);
     GNUNET_CONVERSATION_caller_hang_up (caller);
   }
 }
@@ -781,10 +717,6 @@
 
   switch (caller->state)
   {
-  case CS_RESOLVE:
-    GNUNET_NAMESTORE_cancel (caller->qe);
-    caller->qe = NULL;
-    break;
   case CS_ACTIVE:
     caller->speaker->disable_speaker (caller->speaker->cls);
     caller->mic->disable_microphone (caller->mic->cls);
@@ -799,7 +731,6 @@
                      GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP);
   hang->cid = caller->cid;
   GNUNET_MQ_send (phone->mq, e);
-  GNUNET_free_non_null (caller->caller_id_str);
   GNUNET_free (caller);
 }
 

Modified: gnunet/src/conversation/gnunet-conversation.c
===================================================================
--- gnunet/src/conversation/gnunet-conversation.c       2014-06-06 08:12:49 UTC 
(rev 33550)
+++ gnunet/src/conversation/gnunet-conversation.c       2014-06-06 08:43:16 UTC 
(rev 33551)
@@ -127,9 +127,9 @@
   struct GNUNET_CONVERSATION_Caller *caller;
 
   /**
-   * String identifying the caller.
+   * Public key identifying the caller.
    */
-  char *caller_id;
+  struct GNUNET_CRYPTO_EcdsaPublicKey caller_id;
 
   /**
    * Unique number of the call.
@@ -193,7 +193,7 @@
 /**
  * Our ego.
  */
-static struct GNUNET_IDENTITY_Ego *caller_id;
+static struct GNUNET_IDENTITY_Ego *my_caller_id;
 
 /**
  * Handle to identity service.
@@ -206,8 +206,13 @@
 static char *ego_name;
 
 /**
- * Name of conversation partner (if any).
+ * Public key of active conversation partner (if any).
  */
+static struct GNUNET_CRYPTO_EcdsaPublicKey peer_key;
+
+/**
+ * Name of active conversation partner (if any).
+ */
 static char *peer_name;
 
 /**
@@ -247,13 +252,13 @@
  * @param cls closure
  * @param code type of the event
  * @param caller handle for the caller
- * @param caller_id name of the caller in GNS
+ * @param caller_id public key of the caller (in GNS)
  */
 static void
 phone_event_handler (void *cls,
                      enum GNUNET_CONVERSATION_PhoneEventCode code,
                      struct GNUNET_CONVERSATION_Caller *caller,
-                     const char *caller_id)
+                     const struct GNUNET_CRYPTO_EcdsaPublicKey *caller_id)
 {
   struct CallList *cl;
 
@@ -262,12 +267,12 @@
   case GNUNET_CONVERSATION_EC_PHONE_RING:
     FPRINTF (stdout,
              _("Incoming call from `%s'. Please /accept #%u or /cancel %u the 
call.\n"),
-             caller_id,
+             GNUNET_GNSRECORD_pkey_to_zkey (caller_id),
              caller_num_gen,
              caller_num_gen);
     cl = GNUNET_new (struct CallList);
     cl->caller = caller;
-    cl->caller_id = GNUNET_strdup (caller_id);
+    cl->caller_id = *caller_id;
     cl->caller_num = caller_num_gen++;
     GNUNET_CONTAINER_DLL_insert (cl_head,
                                  cl_tail,
@@ -284,11 +289,10 @@
     }
     FPRINTF (stdout,
              _("Call from `%s' terminated\n"),
-             cl->caller_id);
+             GNUNET_GNSRECORD_pkey_to_zkey (&cl->caller_id));
     GNUNET_CONTAINER_DLL_remove (cl_head,
                                  cl_tail,
                                  cl);
-    GNUNET_free (cl->caller_id);
     if (cl == cl_active)
     {
       cl_active = NULL;
@@ -317,12 +321,12 @@
   case GNUNET_CONVERSATION_EC_CALLER_SUSPEND:
     FPRINTF (stdout,
              _("Call from `%s' suspended by other user\n"),
-             cl->caller_id);
+             GNUNET_GNSRECORD_pkey_to_zkey (&cl->caller_id));
     break;
   case GNUNET_CONVERSATION_EC_CALLER_RESUME:
     FPRINTF (stdout,
              _("Call from `%s' resumed by other user\n"),
-             cl->caller_id);
+             GNUNET_GNSRECORD_pkey_to_zkey (&cl->caller_id));
     break;
   }
 }
@@ -336,7 +340,7 @@
 {
   struct GNUNET_GNSRECORD_Data rd;
 
-  if (NULL == caller_id)
+  if (NULL == my_caller_id)
   {
     FPRINTF (stderr,
              _("Ego `%s' no longer available, phone is now down.\n"),
@@ -346,7 +350,7 @@
   }
   GNUNET_assert (NULL == phone);
   phone = GNUNET_CONVERSATION_phone_create (cfg,
-                                            caller_id,
+                                            my_caller_id,
                                             &phone_event_handler, NULL);
   /* FIXME: get record and print full GNS record info later here... */
   if (NULL == phone)
@@ -402,13 +406,17 @@
     GNUNET_break (CS_RESOLVING == call_state);
     FPRINTF (stdout,
              _("Failed to resolve `%s'\n"),
-             ego_name);
+             peer_name);
+    GNUNET_free (peer_name);
+    peer_name = NULL;
     call = NULL;
     break;
   case GNUNET_CONVERSATION_EC_CALL_HUNG_UP:
     FPRINTF (stdout,
-             "%s",
-             _("Call terminated\n"));
+             _("Call to `%s' terminated\n"),
+             peer_name);
+    GNUNET_free (peer_name);
+    peer_name = NULL;
     call = NULL;
     break;
   case GNUNET_CONVERSATION_EC_CALL_SUSPENDED:
@@ -427,6 +435,7 @@
     FPRINTF (stdout,
              _("Error with the call, restarting it\n"));
     call_state = CS_RESOLVING;
+    // FIXME: is this correct?
     break;
   }
 }
@@ -505,7 +514,7 @@
 static void
 do_call (const char *arg)
 {
-  if (NULL == caller_id)
+  if (NULL == my_caller_id)
   {
     FPRINTF (stderr,
              _("Ego `%s' not available\n"),
@@ -531,13 +540,12 @@
   case PS_ACCEPTED:
     FPRINTF (stderr,
              _("You are answering call from `%s', hang up or suspend that call 
first!\n"),
-             peer_name);
+             GNUNET_GNSRECORD_pkey_to_zkey (&peer_key));
     return;
   case PS_ERROR:
     /* ok to call */
     break;
   }
-  GNUNET_free_non_null (peer_name);
   if (NULL == arg)
   {
     FPRINTF (stderr,
@@ -549,7 +557,7 @@
   call_state = CS_RESOLVING;
   GNUNET_assert (NULL == call);
   call = GNUNET_CONVERSATION_call_start (cfg,
-                                         caller_id,
+                                         my_caller_id,
                                          arg,
                                          speaker,
                                          mic,
@@ -586,7 +594,7 @@
   case PS_ACCEPTED:
     FPRINTF (stderr,
              _("You are answering call from `%s', hang up or suspend that call 
first!\n"),
-             peer_name);
+             GNUNET_GNSRECORD_pkey_to_zkey (&peer_key));
     return;
   case PS_ERROR:
     GNUNET_break (0);
@@ -621,8 +629,7 @@
                                cl_tail,
                                cl);
   cl_active = cl;
-  GNUNET_free_non_null (peer_name);
-  peer_name = GNUNET_strdup (cl->caller_id);
+  peer_key = cl->caller_id;
   phone_state = PS_ACCEPTED;
   GNUNET_CONVERSATION_caller_pick_up (cl->caller,
                                       &caller_event_handler,
@@ -679,7 +686,7 @@
   case PS_ACCEPTED:
     FPRINTF (stdout,
              _("You are having a conversation with `%s'.\n"),
-             peer_name);
+             GNUNET_GNSRECORD_pkey_to_zkey (&peer_key));;
     break;
   case PS_ERROR:
     FPRINTF (stdout,
@@ -724,7 +731,7 @@
       FPRINTF (stdout,
                _("#%u: `%s'\n"),
                cl->caller_num,
-               cl->caller_id);
+               GNUNET_GNSRECORD_pkey_to_zkey (&cl->caller_id));
     }
     FPRINTF (stdout,
              "%s",
@@ -822,7 +829,7 @@
   case PS_ACCEPTED:
     FPRINTF (stderr,
              _("Already talking with `%s', cannot resume a call right now.\n"),
-             peer_name);
+             GNUNET_GNSRECORD_pkey_to_zkey (&peer_key));
     return;
   }
   GNUNET_assert (NULL == cl_active);
@@ -915,7 +922,6 @@
     GNUNET_CONTAINER_DLL_remove (cl_head,
                                  cl_tail,
                                  cl);
-    GNUNET_free (cl->caller_id);
     GNUNET_free (cl);
     break;
   case PS_ACCEPTED:
@@ -1046,11 +1052,20 @@
   GNUNET_free (ego_name);
   ego_name = NULL;
   GNUNET_free_non_null (peer_name);
+  peer_name = NULL;
   phone_state = PS_ERROR;
 }
 
+
+/**
+ * Handle user command.
+ *
+ * @param message command the user typed in
+ * @param str_len number of bytes to process in @a message
+ */
 static void
-handle_command_string (char *message, size_t str_len)
+handle_command_string (char *message,
+                       size_t str_len)
 {
   size_t i;
   const char *ptr;
@@ -1078,9 +1093,10 @@
 
 
 #ifdef WINDOWS
-int
-console_reader_chars (void *cls, void *client,
-    const struct GNUNET_MessageHeader *message)
+static int
+console_reader_chars (void *cls,
+                      void *client,
+                      const struct GNUNET_MessageHeader *message)
 {
   char *chars;
   size_t str_size;
@@ -1144,7 +1160,7 @@
 {
   if (NULL == name)
     return;
-  if (ego == caller_id)
+  if (ego == my_caller_id)
   {
     if (verbose)
       FPRINTF (stdout,
@@ -1163,10 +1179,10 @@
       FPRINTF (stdout,
                _("Our ego `%s' was deleted!\n"),
                ego_name);
-    caller_id = NULL;
+    my_caller_id = NULL;
     return;
   }
-  caller_id = ego;
+  my_caller_id = ego;
   GNUNET_CONFIGURATION_set_value_number (cfg,
                                          "CONVERSATION",
                                          "LINE",

Modified: gnunet/src/conversation/test_conversation_api.c
===================================================================
--- gnunet/src/conversation/test_conversation_api.c     2014-06-06 08:12:49 UTC 
(rev 33550)
+++ gnunet/src/conversation/test_conversation_api.c     2014-06-06 08:43:16 UTC 
(rev 33551)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2013 Christian Grothoff (and other contributing authors)
+     (C) 2013, 2014 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
@@ -330,13 +330,11 @@
 phone_event_handler (void *cls,
                      enum GNUNET_CONVERSATION_PhoneEventCode code,
                      struct GNUNET_CONVERSATION_Caller *caller,
-                     const char *caller_id)
+                     const struct GNUNET_CRYPTO_EcdsaPublicKey *caller_id)
 {
   static enum GNUNET_CONVERSATION_PhoneEventCode expect
     = GNUNET_CONVERSATION_EC_PHONE_RING;
 
-  GNUNET_break (0 == strcmp (caller_id,
-                             gns_caller_id));
   GNUNET_break (code == expect);
   switch (code)
   {

Modified: gnunet/src/conversation/test_conversation_api_reject.c
===================================================================
--- gnunet/src/conversation/test_conversation_api_reject.c      2014-06-06 
08:12:49 UTC (rev 33550)
+++ gnunet/src/conversation/test_conversation_api_reject.c      2014-06-06 
08:43:16 UTC (rev 33551)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2013 Christian Grothoff (and other contributing authors)
+     (C) 2013, 2014 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
@@ -174,13 +174,11 @@
 phone_event_handler (void *cls,
                      enum GNUNET_CONVERSATION_PhoneEventCode code,
                      struct GNUNET_CONVERSATION_Caller *caller,
-                     const char *caller_id)
+                     const struct GNUNET_CRYPTO_EcdsaPublicKey *caller_id)
 {
   static enum GNUNET_CONVERSATION_PhoneEventCode expect
     = GNUNET_CONVERSATION_EC_PHONE_RING;
 
-  GNUNET_break (0 == strcmp (caller_id,
-                             gns_caller_id));
   GNUNET_break (code == expect);
   switch (code)
   {
@@ -242,7 +240,8 @@
   GNUNET_assert (GNUNET_YES == success);
   GNUNET_assert (NULL == emsg);
   GNUNET_assert (NULL == op);
-  op = GNUNET_IDENTITY_create (id, "caller-ego", &caller_ego_create_cont, 
NULL);
+  op = GNUNET_IDENTITY_create (id, "caller-ego",
+                               &caller_ego_create_cont, NULL);
 }
 
 

Modified: gnunet/src/conversation/test_conversation_api_twocalls.c
===================================================================
--- gnunet/src/conversation/test_conversation_api_twocalls.c    2014-06-06 
08:12:49 UTC (rev 33550)
+++ gnunet/src/conversation/test_conversation_api_twocalls.c    2014-06-06 
08:43:16 UTC (rev 33551)
@@ -406,12 +406,10 @@
 phone_event_handler (void *cls,
                      enum GNUNET_CONVERSATION_PhoneEventCode code,
                      struct GNUNET_CONVERSATION_Caller *caller,
-                     const char *caller_id)
+                     const struct GNUNET_CRYPTO_EcdsaPublicKey *caller_id)
 {
   const char *cid;
 
-  GNUNET_break (0 == strcmp (caller_id,
-                             gns_caller_id));
   switch (code)
   {
   case GNUNET_CONVERSATION_EC_PHONE_RING:

Modified: gnunet/src/include/gnunet_conversation_service.h
===================================================================
--- gnunet/src/include/gnunet_conversation_service.h    2014-06-06 08:12:49 UTC 
(rev 33550)
+++ gnunet/src/include/gnunet_conversation_service.h    2014-06-06 08:43:16 UTC 
(rev 33551)
@@ -1,6 +1,6 @@
 /*
   This file is part of GNUnet
-  (C) 2013 Christian Grothoff (and other contributing authors)
+  (C) 2013, 2014 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
@@ -131,13 +131,13 @@
  * @param cls closure
  * @param code type of the event
  * @param caller handle for the caller
- * @param caller_id name of the caller in GNS
+ * @param caller_id public key of the caller (in GNS)
  */
 typedef void
 (*GNUNET_CONVERSATION_PhoneEventHandler)(void *cls,
                                          enum 
GNUNET_CONVERSATION_PhoneEventCode code,
                                          struct GNUNET_CONVERSATION_Caller 
*caller,
-                                         const char *caller_id);
+                                         const struct 
GNUNET_CRYPTO_EcdsaPublicKey *caller_id);
 
 
 /**

Modified: gnunet/src/include/gnunet_namestore_service.h
===================================================================
--- gnunet/src/include/gnunet_namestore_service.h       2014-06-06 08:12:49 UTC 
(rev 33550)
+++ gnunet/src/include/gnunet_namestore_service.h       2014-06-06 08:43:16 UTC 
(rev 33551)
@@ -154,6 +154,7 @@
                            GNUNET_NAMESTORE_ContinuationWithStatus cont,
                            void *cont_cls);
 
+
 /**
  * Lookup an item in the namestore.
  *




reply via email to

[Prev in Thread] Current Thread [Next in Thread]