summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2007-07-01 16:50:43 +0000
committersje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2007-07-01 16:50:43 +0000
commit7d2d0d17e720b43162433410b88ff1de7f019f38 (patch)
treed9693399fbf3ab569941b5ac1da14f70013c2f30
parentf98ef8ff5f7c6d2485d9e627a9af67d67e846d72 (diff)
fix 'unentitizing' formatting
unentitize nicks try to fix missed packets again (not fixed yet) git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@235 4f64403b-2f21-0410-a795-97e2b3489a10
-rw-r--r--MySpace/formatting.cpp10
-rw-r--r--MySpace/nick_dialog.cpp3
-rw-r--r--MySpace/proto.cpp24
-rw-r--r--MySpace/server_con.cpp34
-rw-r--r--MySpace/version.h2
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, "&quot;") == 0) {
+ if(strncmp(buff + in, "&quot;", 6) == 0) {
buff[out++] = '\"'; in += 6;
- } else if(strcmp(buff + in, "&amp;") == 0) {
+ } else if(strncmp(buff + in, "&amp;", 5) == 0) {
buff[out++] = '&'; in += 5;
- } else if(strcmp(buff + in, "&apos;") == 0) {
+ } else if(strncmp(buff + in, "&apos;", 6) == 0) {
buff[out++] = '\''; in += 6;
- } else if(strcmp(buff + in, "&lt;") == 0) {
+ } else if(strncmp(buff + in, "&lt;", 4) == 0) {
buff[out++] = '<'; in += 4;
- } else if(strcmp(buff + in, "&gt;") == 0) {
+ } else if(strncmp(buff + in, "&gt;", 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