diff options
-rw-r--r-- | MySpace/formatting.cpp | 10 | ||||
-rw-r--r-- | MySpace/nick_dialog.cpp | 3 | ||||
-rw-r--r-- | MySpace/proto.cpp | 24 | ||||
-rw-r--r-- | MySpace/server_con.cpp | 34 | ||||
-rw-r--r-- | MySpace/version.h | 2 |
5 files changed, 60 insertions, 13 deletions
diff --git a/MySpace/formatting.cpp b/MySpace/formatting.cpp index d2604fe..4b8669a 100644 --- a/MySpace/formatting.cpp +++ b/MySpace/formatting.cpp @@ -27,15 +27,15 @@ void unentitize(char *buff) { int in = 0, out = 0;
while(buff[in]) {
if(buff[in] == '&') {
- if(strcmp(buff + in, """) == 0) {
+ if(strncmp(buff + in, """, 6) == 0) {
buff[out++] = '\"'; in += 6;
- } else if(strcmp(buff + in, "&") == 0) {
+ } else if(strncmp(buff + in, "&", 5) == 0) {
buff[out++] = '&'; in += 5;
- } else if(strcmp(buff + in, "'") == 0) {
+ } else if(strncmp(buff + in, "'", 6) == 0) {
buff[out++] = '\''; in += 6;
- } else if(strcmp(buff + in, "<") == 0) {
+ } else if(strncmp(buff + in, "<", 4) == 0) {
buff[out++] = '<'; in += 4;
- } else if(strcmp(buff + in, ">") == 0) {
+ } else if(strncmp(buff + in, ">", 4) == 0) {
buff[out++] = '>'; in += 4;
} else
buff[out++] = buff[in++];
diff --git a/MySpace/nick_dialog.cpp b/MySpace/nick_dialog.cpp index 3dad545..eb711b3 100644 --- a/MySpace/nick_dialog.cpp +++ b/MySpace/nick_dialog.cpp @@ -2,6 +2,7 @@ #include "nick_dialog.h"
#include "resource.h"
#include "server_con.h"
+#include "formatting.h"
int check_rid = 0;
int set_rid = 0;
@@ -26,6 +27,7 @@ void CheckAvailable(HWND hwndDlg, TCHAR *nick) { strncpy(an, nick, 256);
#endif
char body[512];
+ entitize(an, 256);
mir_snprintf(body, 512, "UserName=%s", an);
msg.add_string("body", body);
@@ -49,6 +51,7 @@ void SetNick(HWND hwndDlg, TCHAR *nick) { strncpy(an, nick, 256);
#endif
char body[512];
+ entitize(an, 256);
mir_snprintf(body, 512, "UserName=%s", an);
msg.add_string("body", body);
diff --git a/MySpace/proto.cpp b/MySpace/proto.cpp index 821b33e..35ace9b 100644 --- a/MySpace/proto.cpp +++ b/MySpace/proto.cpp @@ -24,7 +24,7 @@ int GetCaps(WPARAM wParam,LPARAM lParam) { ret = PF2_ONLINE | PF2_SHORTAWAY | PF2_INVISIBLE;
break;
case PFLAGNUM_4:
- //ret = PF4_SUPPORTTYPING;
+ ret = PF4_SUPPORTTYPING;
break;
case PFLAGNUM_5:
//ret = PF2_INVISIBLE;
@@ -389,6 +389,24 @@ int SetAwayMsg(WPARAM wParam, LPARAM lParam) { return 0;
}
+int SendTyping(WPARAM wParam, LPARAM lParam) {
+ HANDLE hContact = (HANDLE)wParam;
+ int flags = (int)lParam, uid;
+ if(status != ID_STATUS_OFFLINE) {
+ if((uid = DBGetContactSettingDword(hContact, MODULE, "UID", 0)) != 0) {
+ ClientNetMessage msg;
+ msg.add_int("bm", 121);
+ msg.add_int("sesskey", sesskey);
+ msg.add_int("t", uid);
+ msg.add_int("f", my_uid);
+ msg.add_int("cv", CLIENT_VER);
+ msg.add_string("msg", (flags == PROTOTYPE_SELFTYPING_ON ? "%typing%" : "%stoptyping%"));
+ SendMessage(msg);
+ }
+ }
+ return 0;
+}
+
int ContactDeleted(WPARAM wParam, LPARAM lParam) {
HANDLE hContact = (HANDLE)wParam;
int uid = DBGetContactSettingDword(hContact, MODULE, "UID", 0);
@@ -433,7 +451,7 @@ void RegisterProto() { CallService(MS_PROTO_REGISTERMODULE,0,(LPARAM)&pd);
}
-#define NUM_FILTER_SERVICES 16
+#define NUM_FILTER_SERVICES 17
HANDLE hServices[NUM_FILTER_SERVICES];
HANDLE hEventContactDeleted;
@@ -459,6 +477,8 @@ void CreateProtoServices() { hServices[i++] = CreateProtoServiceFunction(MODULE, PSS_GETAWAYMSG, GetAwayMsg);
hServices[i++] = CreateProtoServiceFunction(MODULE, PSR_AWAYMSG, RecvAwayMsg);
hServices[i++] = CreateProtoServiceFunction(MODULE, PS_SETAWAYMSG, SetAwayMsg);
+
+ hServices[i++] = CreateProtoServiceFunction(MODULE, PSS_USERISTYPING, SendTyping);
// remember to modify the NUM_FILTER_SERVICES #define above if you add more services!
hEventContactDeleted = HookEvent(ME_DB_CONTACT_DELETED, ContactDeleted);
diff --git a/MySpace/server_con.cpp b/MySpace/server_con.cpp index 9f5a75d..e7eea8d 100644 --- a/MySpace/server_con.cpp +++ b/MySpace/server_con.cpp @@ -400,6 +400,23 @@ void __cdecl ServerThreadFunc(void*) { ParseStatusMessage(hContact, smsg);
}
}
+ } else if(msg.get_int("bm") == 121) { // action message
+ int uid = msg.get_int("f");
+ if(uid) {
+ HANDLE hContact = FindContact(uid);
+ if(!hContact) {
+ hContact = CreateContact(uid, 0, 0, false);
+ LookupUID(uid);
+ }
+ char smsg[1024];
+ if(msg.get_string("msg", smsg, 1024)) {
+ if(strcmp(smsg, "%typing%") == 0)
+ CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact, (LPARAM)5);
+ else if(strcmp(smsg, "%stoptyping%") == 0) {
+ CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact, (LPARAM)0);
+ }
+ }
+ }
} else if(msg.get_int("bm") == 1) { // instant message
int uid = msg.get_int("f");
if(uid) {
@@ -443,10 +460,13 @@ void __cdecl ServerThreadFunc(void*) { if(uid != 0) {
MYPROTOSEARCHRESULT mpsr = {sizeof(mpsr)};
- if(body.get_string("UserName", nick, 256))
+ if(body.get_string("UserName", nick, 256)) {
+ unentitize(nick);
mpsr.psr.nick = nick;
- else if(body.get_string("DisplayName", nick, 256))
+ } else if(body.get_string("DisplayName", nick, 256)) {
+ unentitize(nick);
mpsr.psr.nick = nick;
+ }
if(body.get_string("Email", email, 256))
mpsr.psr.email = email;
mpsr.uid = uid;
@@ -468,10 +488,13 @@ void __cdecl ServerThreadFunc(void*) { if(uid != 0) {
MYPROTOSEARCHRESULT mpsr = {sizeof(mpsr)};
- if(body.get_string("DisplayName", nick, 256))
+ if(body.get_string("DisplayName", nick, 256)) {
+ unentitize(nick);
mpsr.psr.nick = nick;
- else if(body.get_string("UserName", nick, 256))
+ } else if(body.get_string("UserName", nick, 256)) {
+ unentitize(nick);
mpsr.psr.nick = nick;
+ }
if(body.get_string("Email", email, 256))
mpsr.psr.email = email;
@@ -500,6 +523,7 @@ void __cdecl ServerThreadFunc(void*) { int uid = body.get_int("ContactID");
if(uid != 0) {
if(body.get_string("NickName", nick, 256)) {
+ unentitize(nick);
DBWriteContactSettingStringUtf(0, MODULE, "Nick", nick);
}
}
@@ -516,7 +540,7 @@ void __cdecl ServerThreadFunc(void*) { }
}
}
- pbuff = end + 1;
+ pbuff = end;
}
}
}
diff --git a/MySpace/version.h b/MySpace/version.h index c34959c..adeec54 100644 --- a/MySpace/version.h +++ b/MySpace/version.h @@ -5,7 +5,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 0
#define __RELEASE_NUM 1
-#define __BUILD_NUM 3
+#define __BUILD_NUM 6
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM
|