# HG changeset patch # User Matti Hamalainen # Date 1287791745 -10800 # Node ID 1323a7f88c211997f581c885dc9a9110c82c76ab # Parent f323b137ca08540a94435ee386a27ae2628e7565 Fix /w -command and add some comments. diff -r f323b137ca08 -r 1323a7f88c21 nnchat.c --- 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;