diff options
Diffstat (limited to 'src/chat')
-rw-r--r-- | src/chat/Makefile.in | 2 | ||||
-rw-r--r-- | src/chat/chat.c | 2 | ||||
-rw-r--r-- | src/chat/gnunet-chat.c | 102 | ||||
-rw-r--r-- | src/chat/test_chat.c | 2 | ||||
-rw-r--r-- | src/chat/test_chat_private.c | 2 |
5 files changed, 92 insertions, 18 deletions
diff --git a/src/chat/Makefile.in b/src/chat/Makefile.in index 96c673c..fe310ce 100644 --- a/src/chat/Makefile.in +++ b/src/chat/Makefile.in @@ -272,6 +272,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTLLIBS = @INTLLIBS@ INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +JAVAPORT = @JAVAPORT@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ @@ -305,6 +306,7 @@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ +MONKEYPREFIX = @MONKEYPREFIX@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ diff --git a/src/chat/chat.c b/src/chat/chat.c index ae73b96..72c49a0 100644 --- a/src/chat/chat.c +++ b/src/chat/chat.c @@ -599,7 +599,7 @@ GNUNET_CHAT_leave_room (struct GNUNET_CHAT_Room *chat_room) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Leaving the room '%s'\n", chat_room->room_name); #endif - GNUNET_CLIENT_disconnect (chat_room->client, GNUNET_NO); + GNUNET_CLIENT_disconnect (chat_room->client); GNUNET_free (chat_room->room_name); GNUNET_CONTAINER_meta_data_destroy (chat_room->member_info); GNUNET_CRYPTO_rsa_key_free (chat_room->my_private_key); diff --git a/src/chat/gnunet-chat.c b/src/chat/gnunet-chat.c index 4abc58c..7b11c0d 100644 --- a/src/chat/gnunet-chat.c +++ b/src/chat/gnunet-chat.c @@ -44,13 +44,14 @@ static struct GNUNET_CONTAINER_MetaData *meta; static struct GNUNET_CHAT_Room *room; -static GNUNET_SCHEDULER_TaskIdentifier handle_cmd_task = - GNUNET_SCHEDULER_NO_TASK; +static GNUNET_SCHEDULER_TaskIdentifier handle_cmd_task; + +typedef int (*ActionFunction)(const char *argumetns, const void *xtra); struct ChatCommand { const char *command; - int (*Action) (const char *arguments, const void *xtra); + ActionFunction Action; const char *helptext; }; @@ -114,14 +115,27 @@ receive_cb (void *cls, struct GNUNET_CHAT_Room *room, const char *message, struct GNUNET_TIME_Absolute timestamp, enum GNUNET_CHAT_MsgOptions options) { + char *non_unique_nick; char *nick; + int nick_is_a_dup; char *time; const char *fmt; - if (NULL != sender) - nick = GNUNET_PSEUDONYM_id_to_name (cfg, sender); - else + if (NULL == sender) nick = GNUNET_strdup (_("anonymous")); + else + { + if (GNUNET_OK != GNUNET_PSEUDONYM_get_info (cfg, + sender, NULL, NULL, &non_unique_nick, &nick_is_a_dup) + || (nick_is_a_dup == GNUNET_YES)) + { + GNUNET_free (non_unique_nick); + non_unique_nick = GNUNET_strdup (_("anonymous")); + } + nick = GNUNET_PSEUDONYM_name_uniquify (cfg, sender, non_unique_nick, NULL); + GNUNET_free (non_unique_nick); + } + fmt = NULL; switch ((int) options) { @@ -188,9 +202,20 @@ confirmation_cb (void *cls, struct GNUNET_CHAT_Room *room, const GNUNET_HashCode * receiver) { char *nick; + char *unique_nick; + int nick_is_a_dup; - nick = GNUNET_PSEUDONYM_id_to_name (cfg, receiver); - FPRINTF (stdout, _("'%s' acknowledged message #%d\n"), nick, orig_seq_number); + if (GNUNET_OK != GNUNET_PSEUDONYM_get_info (cfg, + receiver, NULL, NULL, &nick, &nick_is_a_dup) + || (nick_is_a_dup == GNUNET_YES)) + { + GNUNET_free (nick); + nick = GNUNET_strdup (_("anonymous")); + } + unique_nick = GNUNET_PSEUDONYM_name_uniquify (cfg, receiver, nick, NULL); + GNUNET_free (nick); + FPRINTF (stdout, _("'%s' acknowledged message #%d\n"), unique_nick, orig_seq_number); + GNUNET_free (unique_nick); return GNUNET_OK; } @@ -211,6 +236,8 @@ member_list_cb (void *cls, const struct GNUNET_CONTAINER_MetaData *member_info, enum GNUNET_CHAT_MsgOptions options) { char *nick; + char *non_unique_nick; + int nick_is_a_dup; GNUNET_HashCode id; struct UserList *pos; struct UserList *prev; @@ -218,7 +245,16 @@ member_list_cb (void *cls, const struct GNUNET_CONTAINER_MetaData *member_info, GNUNET_CRYPTO_hash (member_id, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &id); - nick = GNUNET_PSEUDONYM_id_to_name (cfg, &id); + if (GNUNET_OK != GNUNET_PSEUDONYM_get_info (cfg, + &id, NULL, NULL, &non_unique_nick, &nick_is_a_dup) + || (nick_is_a_dup == GNUNET_YES)) + { + GNUNET_free (non_unique_nick); + non_unique_nick = GNUNET_strdup (_("anonymous")); + } + nick = GNUNET_PSEUDONYM_name_uniquify (cfg, &id, non_unique_nick, NULL); + GNUNET_free (non_unique_nick); + FPRINTF (stdout, member_info != NULL ? _("`%s' entered the room\n") : _("`%s' left the room\n"), @@ -267,6 +303,7 @@ static int do_join (const char *arg, const void *xtra) { char *my_name; + int my_name_is_a_dup; GNUNET_HashCode me; if (arg[0] == '#') @@ -284,7 +321,16 @@ do_join (const char *arg, const void *xtra) FPRINTF (stdout, "%s", _("Could not change username\n")); return GNUNET_SYSERR; } - my_name = GNUNET_PSEUDONYM_id_to_name (cfg, &me); + if ((GNUNET_OK != GNUNET_PSEUDONYM_get_info (cfg, + &me, NULL, NULL, &my_name, &my_name_is_a_dup)) || + (my_name_is_a_dup == GNUNET_YES)) + { + GNUNET_free (my_name); + my_name = GNUNET_strdup (_("anonymous")); + } + /* Don't uniquify our own name - other people will have a different + * suffix for our own name anyway. + */ FPRINTF (stdout, _("Joining room `%s' as user `%s'...\n"), room_name, my_name); GNUNET_free (my_name); @@ -296,6 +342,7 @@ static int do_nick (const char *msg, const void *xtra) { char *my_name; + int my_name_is_a_dup; GNUNET_HashCode me; GNUNET_CHAT_leave_room (room); @@ -316,7 +363,13 @@ do_nick (const char *msg, const void *xtra) FPRINTF (stdout, "%s", _("Could not change username\n")); return GNUNET_SYSERR; } - my_name = GNUNET_PSEUDONYM_id_to_name (cfg, &me); + if ((GNUNET_OK != GNUNET_PSEUDONYM_get_info (cfg, + &me, NULL, NULL, &my_name, &my_name_is_a_dup)) || + (my_name_is_a_dup == GNUNET_YES)) + { + GNUNET_free (my_name); + my_name = GNUNET_strdup (_("anonymous")); + } FPRINTF (stdout, _("Changed username to `%s'\n"), my_name); GNUNET_free (my_name); return GNUNET_OK; @@ -327,6 +380,8 @@ static int do_names (const char *msg, const void *xtra) { char *name; + char *unique_name; + int name_is_a_dup; struct UserList *pos; GNUNET_HashCode pid; @@ -337,9 +392,17 @@ do_names (const char *msg, const void *xtra) GNUNET_CRYPTO_hash (&pos->pkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &pid); - name = GNUNET_PSEUDONYM_id_to_name (cfg, &pid); - FPRINTF (stdout, "`%s' ", name); + if (GNUNET_OK != GNUNET_PSEUDONYM_get_info (cfg, + &pid, NULL, NULL, &name, &name_is_a_dup) + || (name_is_a_dup == GNUNET_YES)) + { + GNUNET_free (name); + name = GNUNET_strdup (_("anonymous")); + } + unique_name = GNUNET_PSEUDONYM_name_uniquify (cfg, &pid, name, NULL); GNUNET_free (name); + FPRINTF (stdout, "`%s' ", unique_name); + GNUNET_free (unique_name); pos = pos->next; } FPRINTF (stdout, "%s", "\n"); @@ -376,7 +439,9 @@ do_send_pm (const char *msg, const void *xtra) msg += strlen (user) + 1; if (GNUNET_OK != GNUNET_PSEUDONYM_name_to_id (cfg, user, &uid)) { - FPRINTF (stderr, _("Unknown user `%s'\n"), user); + FPRINTF (stderr, + _("Unknown user `%s'. Make sure you specify its numeric suffix, if any.\n"), + user); GNUNET_free (user); return GNUNET_OK; } @@ -598,6 +663,7 @@ run (void *cls, char *const *args, const char *cfgfile, { GNUNET_HashCode me; char *my_name; + int my_name_is_a_dup; cfg = c; /* check arguments */ @@ -626,7 +692,13 @@ run (void *cls, char *const *args, const char *cfgfile, ret = -1; return; } - my_name = GNUNET_PSEUDONYM_id_to_name (cfg, &me); + if ((GNUNET_OK != GNUNET_PSEUDONYM_get_info (cfg, + &me, NULL, NULL, &my_name, &my_name_is_a_dup)) || + (my_name_is_a_dup == GNUNET_YES)) + { + GNUNET_free (my_name); + my_name = GNUNET_strdup (_("anonymous")); + } FPRINTF (stdout, _("Joining room `%s' as user `%s'...\n"), room_name, my_name); GNUNET_free (my_name); diff --git a/src/chat/test_chat.c b/src/chat/test_chat.c index fec5db0..2e8272d 100644 --- a/src/chat/test_chat.c +++ b/src/chat/test_chat.c @@ -140,7 +140,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); - GNUNET_OS_process_close (p->arm_proc); + GNUNET_OS_process_destroy (p->arm_proc); p->arm_proc = NULL; #endif GNUNET_CONFIGURATION_destroy (p->cfg); diff --git a/src/chat/test_chat_private.c b/src/chat/test_chat_private.c index cbc9065..8b61392 100644 --- a/src/chat/test_chat_private.c +++ b/src/chat/test_chat_private.c @@ -154,7 +154,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); - GNUNET_OS_process_close (p->arm_proc); + GNUNET_OS_process_destroy (p->arm_proc); p->arm_proc = NULL; #endif GNUNET_CONFIGURATION_destroy (p->cfg); |