changeset 109:1323a7f88c21

Fix /w -command and add some comments.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 23 Oct 2010 02:55:45 +0300
parents f323b137ca08
children 8af4072dc31a
files nnchat.c
diffstat 1 files changed, 9 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/nnchat.c	Sat Oct 23 02:01:00 2010 +0300
+++ b/nnchat.c	Sat Oct 23 02:55:45 2010 +0300
@@ -552,10 +552,11 @@
     while (bufLen > 0 && (buf[bufLen] == '\n' || buf[bufLen] == '\r' || th_isspace(buf[bufLen])))
         buf[bufLen--] = 0;
     
-    /* Check command */
+    /* Check for special user commands */
     if (*buf == 0) {
         return 1;
     } else if (!strncmp(buf, "/color ", 7)) {
+        /* Change color */
         int tmpInt;
         if ((tmpInt = getColor(buf+7)) < 0) {
             printMsg("Invalid color value '%s'\n", buf+7);
@@ -566,31 +567,29 @@
         nn_send_msg(sock, optUserName2, "%%2FSetFontColor%%20%%2Dcolor%%20%06X", optUserColor);
         return 0;
     } else if (!strncmp(buf, "/w ", 3)) {
+        /* Open given username's profile via firefox in a new tab */
         char *name = buf + 3;
         pid_t pud;
         tmpStr = nn_encode_str1(name);
-        snprintf(tmpBuf, sizeof(tmpBuf), "openurl(http://www.newbienudes.com/profile/%s/,new-tab)", tmpStr);
+        snprintf(tmpBuf, sizeof(tmpBuf), "firefox -remote \"openurl(http://www.newbienudes.com/profile/%s/,new-tab)\"", tmpStr);
         th_free(tmpStr);
 
         printMsg("Opening profile for: %s\n", name);
         printMsg("%s\n", tmpBuf);
-/*
-        if ((pud = fork()) < 0) return 0;
-        if (getpid() == pud) {
-            execlp("firefox", "-remote", tmpBuf, (char *) NULL);
-            exit(0);
-        } else
-*/
-            return 0;
+        system(tmpBuf);
+        return 0;
     } else if (!strncmp(buf, "/to ", 4)) {
+        /* Set private messaging target */
         th_free(setTarget);
         setTarget = th_strdup(buf + 4);
         printMsg("Set prv target to '%s'\n", setTarget);
         return 0;
     } else if (!strncmp(buf, "/who", 4)) {
+        /* Alias /who to /listallusers */
         snprintf(tmpBuf, sizeof(tmpBuf), "/listallusers");
         buf = tmpBuf;
     } else if (setPrvMode) {
+        /* Private chat mode, send as PRV */
         if (setTarget != NULL) {
             snprintf(tmpBuf, sizeof(tmpBuf), "/prv -to %s -msg %s", setTarget, buf);
             buf = tmpBuf;
@@ -601,7 +600,6 @@
         }
     }
     
-    
     /* Send double-encoded */
     tmpStr = nn_dblencode_str(buf);
     if (tmpStr == 0) return -2;