[mw-devel] MW3 r1210 - in trunk: src/webclient webclient

tswsl1989 at sucs.org tswsl1989 at sucs.org
Sun Oct 10 10:50:43 BST 2010


Author: tswsl1989
Date: 2010-10-10 10:50:42 +0100 (Sun, 10 Oct 2010)
New Revision: 1210

Modified:
   trunk/src/webclient/Makefile
   trunk/src/webclient/comms.c
   trunk/src/webclient/import.c
   trunk/src/webclient/import.h
   trunk/webclient/say.js
Log:
Add support for .sayto/.sa/.whisper from web client

Modified: trunk/src/webclient/Makefile
===================================================================
--- trunk/src/webclient/Makefile	2010-10-09 23:33:16 UTC (rev 1209)
+++ trunk/src/webclient/Makefile	2010-10-10 09:50:42 UTC (rev 1210)
@@ -48,7 +48,7 @@
 
 .PHONY: build install clean test
 
-mwpoll: mwpoll.o import.o comms.o mwstring.o ../perms.o ../strings.o ../files.o ../ipc.o ../iconv.o ../special.o 
+mwpoll: mwpoll.o import.o comms.o mwstring.o ../perms.o ../strings.o ../files.o ../ipc.o ../iconv.o ../special.o
 	$(CC) $(LDFLAGS) $(LDLIBS) -o $@ $^
 
 clean:

Modified: trunk/src/webclient/comms.c
===================================================================
--- trunk/src/webclient/comms.c	2010-10-09 23:33:16 UTC (rev 1209)
+++ trunk/src/webclient/comms.c	2010-10-10 09:50:42 UTC (rev 1210)
@@ -384,6 +384,31 @@
 		send(co->fd, buff, strlen(buff), 0);
 		return 0; // dont close
 	}else
+	if (strncasecmp(buff, "sayto ", 6)==0) {
+		char *tmp;
+		char *tmpm;
+		char duser[17];
+		char msg[8192];
+		char *tmpu;
+		//struct filter_info f_info;
+                char line[8192];
+		//memset(&f_info, 0, sizeof(f_info));
+		//f_info.channel = user->room;
+		tmp = remove_first_word(buff);
+		tmpm = remove_first_word(tmp);
+		tmpu = strtok(tmp," ");
+		snprintf(msg,sizeof msg,tmpm);
+		snprintf(duser,17,"%s",tmpu);
+		if (buff[strlen(buff)-1]=='?') {
+	                snprintf(line, sizeof line, "%s asks: %s", user->name, msg);
+		}else {
+			snprintf(line, sizeof line, "%s says: %s", user->name, msg);
+		}
+                ipc_send_to_username(duser, IPC_TEXT, line);
+                snprintf(buff, sizeof buff, "{\"status\":\"sayto sent to %s (%s)\"}", duser, msg);
+                send(co->fd, buff, strlen(buff), 0);
+                return 1;			
+	}else
         if (co->authd && strncasecmp(buff, "emote ", 6)==0) {
                 struct filter_info f_info;
                 char line[8192];

Modified: trunk/src/webclient/import.c
===================================================================
--- trunk/src/webclient/import.c	2010-10-09 23:33:16 UTC (rev 1209)
+++ trunk/src/webclient/import.c	2010-10-10 09:50:42 UTC (rev 1210)
@@ -223,3 +223,17 @@
         tmp[i]=0;
 }
 
+char *remove_first_word(char *args)
+{
+        char *ptr, *ptr2;
+
+        ptr = args;
+        while (ptr && *ptr && isspace(*ptr)) ptr++;
+        if (ptr && *ptr)
+        {
+                ptr2 = strchr(ptr, ' ');
+                if (ptr2 != NULL) ptr2++;
+                if (ptr2 == NULL) return(NULL); else return(strdup(ptr2));
+        } else return(NULL);
+}
+

Modified: trunk/src/webclient/import.h
===================================================================
--- trunk/src/webclient/import.h	2010-10-09 23:33:16 UTC (rev 1209)
+++ trunk/src/webclient/import.h	2010-10-10 09:50:42 UTC (rev 1210)
@@ -10,3 +10,4 @@
 void broadcast_onoffcode(int code, int method, const char *sourceuser, const char *reason);
 void show_chatmodes(unsigned long cm, char *tmp, int flag);
 void show_chatprivs(unsigned long cp, char *tmp, int flag);
+char *remove_first_word(char *args) ;

Modified: trunk/webclient/say.js
===================================================================
--- trunk/webclient/say.js	2010-10-09 23:33:16 UTC (rev 1209)
+++ trunk/webclient/say.js	2010-10-10 09:50:42 UTC (rev 1210)
@@ -145,6 +145,12 @@
 		var what = "emote "+args;
                 $.getJSON("send.php", {send: what});
 		break;
+	case "sayto":
+	case "sa":
+	case "whisper":
+		var what = "sayto "+args;
+		$.getJSON("send.php", {send: what});
+		break;
 	case "q":
 	case "qq":
 	case "quit":




More information about the mw-devel mailing list