changeset 303:859578ec3275

Fix encoding of usernames in /query and /close.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 11 Jun 2011 04:50:00 +0300
parents a3170f477ae2
children 61884ce9db41
files nnchat.c
diffstat 1 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/nnchat.c	Sat Jun 11 04:32:37 2011 +0300
+++ b/nnchat.c	Sat Jun 11 04:50:00 2011 +0300
@@ -873,25 +873,29 @@
     else if (!strncasecmp(buf, "/query", 6)) {
         char *name = trimLeft(buf + 6);
         if (strlen(name) > 0) {
-            nn_user_t *user = nn_user_find(nnUsers, name);
+            nn_user_t *user = nn_user_find(nnUsers, nn_username_encode(name));
             if (user != NULL) {
-                printMsg(currWin, "Opening PRV query for '%s'.\n", user->name);
-                if (openWindow(user->name, TRUE))
-                    printMsg(currWin, "In PRV query with '%s'.\n", user->name);
+                name = nn_username_decode(th_strdup(user->name));
+                printMsg(currWin, "Opening PRV query for '%s'.\n", name);
+                if (openWindow(name, TRUE))
+                    printMsg(currWin, "In PRV query with '%s'.\n", name);
+                th_free(name);
             }
         } else {
             printMsg(currWin, "Usage: /query username\n");
             printMsg(currWin, "To close a PRV query, use /close [username]\n");
-            printMsg(currWin, "/close without username will close the current PRV window (if any).\n");
+            printMsg(currWin, "/close without username will close the current PRV window.\n");
         }
         return 0;
     }
     else if (!strncasecmp(buf, "/close", 6)) {
         char *name = trimLeft(buf + 6);
         if (strlen(name) > 0) {
-            nn_window_t *win = nn_find_window(name);
+            nn_window_t *win;
+            win = nn_find_window(name);
             if (win != NULL) {
                 closeWindow(win);
+                printMsg(currWin, "Closed PRV query to '%s'.\n", name);
             } else {
                 printMsg(currWin, "No PRV query by name '%s'.\n", name);
             }