diff options
author | George Hazan <george.hazan@gmail.com> | 2015-05-21 16:11:58 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-05-21 16:11:58 +0000 |
commit | 48266e479d1fcf5153b29c612866845990fccad8 (patch) | |
tree | c8cbc908cd3c5f08731e5e8d7eaac6b568007d09 /protocols | |
parent | ebdb556f152734035846f120eb8112f88ef91281 (diff) |
war against atavisms continues
- everything that goes to PSS_MESSAGE should be sent as utf8 string;
- thus PREF_UNICODE & PREF_UTF support discontinued, these constants are removed;
- support for PREF_UNICODE & PREF_UTF in protocols also removed;
- PREF_UNICODE used in file transfers (PROTOFILERECVT) replaced with PRFF_UNICODE / PRFF_TCHAR
git-svn-id: http://svn.miranda-ng.org/main/trunk@13734 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
70 files changed, 213 insertions, 505 deletions
diff --git a/protocols/AimOscar/src/proto.cpp b/protocols/AimOscar/src/proto.cpp index fcf9c2e86b..b3b404cced 100644 --- a/protocols/AimOscar/src/proto.cpp +++ b/protocols/AimOscar/src/proto.cpp @@ -280,7 +280,7 @@ DWORD_PTR __cdecl CAimProto::GetCaps(int type, MCONTACT) case PFLAGNUM_4:
return PF4_SUPPORTTYPING | PF4_FORCEAUTH | PF4_NOCUSTOMAUTH | PF4_FORCEADDED |
- PF4_SUPPORTIDLE | PF4_AVATARS | PF4_IMSENDUTF | PF4_IMSENDOFFLINE;
+ PF4_SUPPORTIDLE | PF4_AVATARS | PF4_IMSENDOFFLINE;
case PFLAGNUM_5:
return PF2_ONTHEPHONE;
@@ -454,7 +454,7 @@ void __cdecl CAimProto::msg_ack_success(void* param) }
-int __cdecl CAimProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc)
+int __cdecl CAimProto::SendMsg(MCONTACT hContact, int, const char* pszSrc)
{
if (pszSrc == NULL) return 0;
@@ -475,31 +475,13 @@ int __cdecl CAimProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc) ForkThread(&CAimProto::msg_ack_success, msg_ack);
}
- char* msg;
- if (flags & PREF_UNICODE)
- {
- const char* p = strchr(pszSrc, '\0');
- if (p != pszSrc)
- {
- while (*(++p) == '\0');
- }
- msg = mir_utf8encodeW((wchar_t*)p);
- }
- else if (flags & PREF_UTF)
- msg = mir_strdup(pszSrc);
- else
- msg = mir_utf8encode(pszSrc);
-
- char* smsg = html_encode(msg);
- mir_free(msg);
-
+ char *smsg = html_encode(pszSrc), *msg;
if (getByte(AIM_KEY_FO, 1))
{
msg = bbcodes_to_html(smsg);
mir_free(smsg);
}
- else
- msg = smsg;
+ else msg = smsg;
bool blast = getBool(hContact, AIM_KEY_BLS, false);
int res = aim_send_message(hServerConn, seqno, sn, msg, false, blast);
diff --git a/protocols/AimOscar/src/server.cpp b/protocols/AimOscar/src/server.cpp index c7f3e75407..672beff746 100644 --- a/protocols/AimOscar/src/server.cpp +++ b/protocols/AimOscar/src/server.cpp @@ -1277,7 +1277,6 @@ void CAimProto::snac_received_message(SNAC &snac,HANDLE hServerConn,unsigned sho CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hMsgContact, 0);
{
PROTORECVEVENT pre = { 0 };
- pre.flags = PREF_UTF;
pre.timestamp = (is_offline) ? offline_timestamp : (DWORD)time(0);
pre.szMessage = msg_buf;
ProtoChainRecvMsg(hMsgContact, &pre);
@@ -1342,8 +1341,8 @@ void CAimProto::snac_received_message(SNAC &snac,HANDLE hServerConn,unsigned sho TCHAR* filenameT = mir_utf8decodeT(filename);
- PROTORECVFILET pre = {0};
- pre.flags = PREF_TCHAR;
+ PROTORECVFILET pre = { 0 };
+ pre.dwFlags = PRFF_TCHAR;
pre.fileCount = 1;
pre.timestamp = time(NULL);
pre.tszDescription = mir_utf8decodeT(msg_buf);
diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp index 401c8d1c92..1ef728d654 100644 --- a/protocols/FacebookRM/src/messages.cpp +++ b/protocols/FacebookRM/src/messages.cpp @@ -112,10 +112,10 @@ void FacebookProto::SendChatMsgWorker(void *p) delete data; } -int FacebookProto::SendMsg(MCONTACT hContact, int flags, const char *msg) +int FacebookProto::SendMsg(MCONTACT hContact, int, const char *msg) { // TODO: msg comes as Unicode (retyped wchar_t*), why should we convert it as ANSI to UTF-8? o_O - std::string message = (flags & PREF_UNICODE) ? ptrA(mir_utf8encode(msg)) : msg; + std::string message = msg; facy.msgid_ = (facy.msgid_ % 1024) + 1; ForkThread(&FacebookProto::SendMsgWorker, new send_direct(hContact, message, facy.msgid_)); diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index 9a95fc584c..c36953563a 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -780,7 +780,6 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message*> messages, boo if (messages[i]->isIncoming && messages[i]->isUnread && messages[i]->type == MESSAGE) { PROTORECVEVENT recv = { 0 }; - recv.flags = PREF_UTF; recv.szMessage = const_cast<char*>(messages[i]->message_text.c_str()); recv.timestamp = messages[i]->time; ProtoChainRecvMsg(hContact, &recv); diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index 81c5e131ae..2b8fba99de 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -167,7 +167,7 @@ DWORD_PTR FacebookProto::GetCaps(int type, MCONTACT) else return 0; case PFLAGNUM_4: - return PF4_NOCUSTOMAUTH | PF4_FORCEADDED | PF4_IMSENDUTF | PF4_AVATARS | PF4_SUPPORTTYPING | PF4_NOAUTHDENYREASON | PF4_IMSENDOFFLINE; + return PF4_NOCUSTOMAUTH | PF4_FORCEADDED | PF4_AVATARS | PF4_SUPPORTTYPING | PF4_NOAUTHDENYREASON | PF4_IMSENDOFFLINE; case PFLAGNUM_5: return PF2_ONTHEPHONE; case PFLAG_MAXLENOFMESSAGE: diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index 08dfae9cb7..01452e7a5f 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -848,7 +848,6 @@ retry: PROTORECVEVENT pre = {0};
time_t t = time(NULL);
pre.timestamp = (!(e->event.msg.msgclass & GG_CLASS_OFFLINE) || e->event.msg.time > (t - timeDeviation)) ? t : e->event.msg.time;
- pre.flags = PREF_UTF;
pre.szMessage = e->event.msg.message;
ProtoChainRecvMsg( getcontact(e->event.msg.sender, 1, 0, NULL), &pre);
}
@@ -1058,7 +1057,7 @@ retry: TCHAR* filenameT = mir_a2t((char*)dcc7->filename);
PROTORECVFILET pre = {0};
- pre.flags = PREF_TCHAR;
+ pre.dwFlags = PRFF_TCHAR;
pre.fileCount = 1;
pre.timestamp = time(NULL);
pre.tszDescription = filenameT;
diff --git a/protocols/Gadu-Gadu/src/filetransfer.cpp b/protocols/Gadu-Gadu/src/filetransfer.cpp index 4426f3c9eb..162c57f27c 100644 --- a/protocols/Gadu-Gadu/src/filetransfer.cpp +++ b/protocols/Gadu-Gadu/src/filetransfer.cpp @@ -385,7 +385,7 @@ void __cdecl GGPROTO::dccmainthread(void*) TCHAR* filenameT = mir_utf8decodeT((char*)dcc->file_info.filename);
PROTORECVFILET pre = {0};
- pre.flags = PREF_TCHAR;
+ pre.dwFlags = PRFF_TCHAR;
pre.fileCount = 1;
pre.timestamp = time(NULL);
pre.tszDescription = filenameT;
diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp index 4a55df086f..7d497c7033 100644 --- a/protocols/Gadu-Gadu/src/gg_proto.cpp +++ b/protocols/Gadu-Gadu/src/gg_proto.cpp @@ -155,7 +155,7 @@ DWORD_PTR GGPROTO::GetCaps(int type, MCONTACT hContact) case PFLAGNUM_3:
return PF2_ONLINE | PF2_SHORTAWAY | PF2_HEAVYDND | PF2_FREECHAT | PF2_INVISIBLE;
case PFLAGNUM_4:
- return PF4_NOCUSTOMAUTH | PF4_SUPPORTTYPING | PF4_AVATARS | PF4_IMSENDOFFLINE | PF4_IMSENDUTF;
+ return PF4_NOCUSTOMAUTH | PF4_SUPPORTTYPING | PF4_AVATARS | PF4_IMSENDOFFLINE;
case PFLAGNUM_5:
return PF2_LONGAWAY;
case PFLAG_UNIQUEIDTEXT:
@@ -567,25 +567,17 @@ void __cdecl GGPROTO::sendackthread(void *ack) mir_free(ack);
}
-int GGPROTO::SendMsg(MCONTACT hContact, int flags, const char *msg)
+int GGPROTO::SendMsg(MCONTACT hContact, int, const char *msg)
{
uin_t uin = (uin_t)getDword(hContact, GG_KEY_UIN, 0);
if (!isonline() || !uin)
return 0;
- char* msg_utf8;
- if (flags & PREF_UNICODE)
- msg_utf8 = mir_utf8encodeW((wchar_t*)&msg[ strlen( msg )+1 ] );
- else if (flags & PREF_UTF)
- msg_utf8 = mir_strdup(msg);
- else
- msg_utf8 = mir_utf8encode(msg);
-
- if (!msg_utf8)
+ if (!msg)
return 0;
gg_EnterCriticalSection(&sess_mutex, "SendMsg", 53, "sess_mutex", 1);
- int seq = gg_send_message(sess, GG_CLASS_CHAT, uin, (BYTE*)msg_utf8);
+ int seq = gg_send_message(sess, GG_CLASS_CHAT, uin, (BYTE*)msg);
gg_LeaveCriticalSection(&sess_mutex, "SendMsg", 53, 1, "sess_mutex", 1);
if (!getByte(GG_KEY_MSGACK, GG_KEYDEF_MSGACK))
{
@@ -601,7 +593,6 @@ int GGPROTO::SendMsg(MCONTACT hContact, int flags, const char *msg) ForkThread(&GGPROTO::sendackthread, ack);
}
}
- mir_free(msg_utf8);
return seq;
}
diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp index e0dccada81..61452bb6fc 100644 --- a/protocols/Gadu-Gadu/src/image.cpp +++ b/protocols/Gadu-Gadu/src/image.cpp @@ -863,11 +863,12 @@ int GGPROTO::img_displayasmsg(MCONTACT hContact, void *img) mir_sntprintf(image_msg, SIZEOF(image_msg), _T("[img]%s[/img]"), szPath);
PROTORECVEVENT pre = {0};
- pre.flags = PREF_TCHAR;
pre.timestamp = time(NULL);
- pre.tszMessage = image_msg;
+ pre.szMessage = mir_utf8encodeT(image_msg);
ProtoChainRecvMsg(hContact, &pre);
debugLog(_T("img_displayasmsg(): Image saved to %s."), szPath);
+
+ mir_free(pre.szMessage);
}
else
{
diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp index c6dbac79e0..824588b369 100644 --- a/protocols/IRCG/src/commandmonitor.cpp +++ b/protocols/IRCG/src/commandmonitor.cpp @@ -705,7 +705,6 @@ bool CIrcProto::OnIrc_PRIVMSG(const CIrcMessage* pmsg) PROTORECVEVENT pre = { 0 };
pre.timestamp = (DWORD)time(NULL);
- pre.flags = PREF_UTF;
pre.szMessage = mir_utf8encodeW(mess.c_str());
setTString(hContact, "User", pmsg->prefix.sUser.c_str());
setTString(hContact, "Host", pmsg->prefix.sHost.c_str());
@@ -1162,7 +1161,7 @@ bool CIrcProto::IsCTCP(const CIrcMessage* pmsg) TCHAR* tszTemp = (TCHAR*)sFile.c_str();
PROTORECVFILET pre = { 0 };
- pre.flags = PREF_TCHAR;
+ pre.dwFlags = PRFF_TCHAR;
pre.timestamp = (DWORD)time(NULL);
pre.fileCount = 1;
pre.ptszFiles = &tszTemp;
@@ -2284,7 +2283,7 @@ void CIrcProto::OnIrcDisconnected() m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)Temp, ID_STATUS_OFFLINE);
- CMString sDisconn = _T("\0035\002");
+ CMString sDisconn = _T("\035\002");
sDisconn += TranslateT("*Disconnected*");
DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, sDisconn.c_str(), NULL, NULL, NULL, true, false);
diff --git a/protocols/IRCG/src/ircproto.cpp b/protocols/IRCG/src/ircproto.cpp index c70e78ab11..162876aeca 100644 --- a/protocols/IRCG/src/ircproto.cpp +++ b/protocols/IRCG/src/ircproto.cpp @@ -460,7 +460,7 @@ DWORD_PTR __cdecl CIrcProto::GetCaps(int type, MCONTACT) return PF2_SHORTAWAY;
case PFLAGNUM_4:
- return PF4_NOAUTHDENYREASON | PF4_NOCUSTOMAUTH | PF4_IMSENDUTF;
+ return PF4_NOAUTHDENYREASON | PF4_NOCUSTOMAUTH;
case PFLAG_UNIQUEIDTEXT:
return (DWORD_PTR)Translate("Nickname");
@@ -678,7 +678,7 @@ void __cdecl CIrcProto::AckMessageSuccess(void *info) delete param;
}
-int __cdecl CIrcProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc)
+int __cdecl CIrcProto::SendMsg(MCONTACT hContact, int, const char* pszSrc)
{
BYTE bDcc = getByte(hContact, "DCC", 0);
WORD wStatus = getWord(hContact, "Status", ID_STATUS_OFFLINE);
@@ -686,6 +686,7 @@ int __cdecl CIrcProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc) ForkThread(&CIrcProto::AckMessageFailDcc, (void*)hContact);
return 0;
}
+
if (!bDcc && (m_iStatus == ID_STATUS_OFFLINE || m_iStatus == ID_STATUS_CONNECTING)) {
ForkThread(&CIrcProto::AckMessageFail, (void*)hContact);
return 0;
@@ -694,20 +695,7 @@ int __cdecl CIrcProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc) int codepage = getCodepage();
TCHAR *result;
- if (flags & PREF_UNICODE) {
- const char* p = strchr(pszSrc, '\0');
- if (p != pszSrc) {
- while (*(++p) == '\0')
- ;
- result = mir_u2t_cp((wchar_t*)p, codepage);
- }
- else result = mir_a2t_cp(pszSrc, codepage);
- }
- else if (flags & PREF_UTF)
- mir_utf8decode(NEWSTR_ALLOCA(pszSrc), &result);
- else
- result = mir_a2t_cp(pszSrc, codepage);
-
+ mir_utf8decode(NEWSTR_ALLOCA(pszSrc), &result);
PostIrcMessageWnd(NULL, hContact, result);
mir_free(result);
diff --git a/protocols/IcqOscarJ/src/fam_04message.cpp b/protocols/IcqOscarJ/src/fam_04message.cpp index 84339c2846..f3f4808b6b 100644 --- a/protocols/IcqOscarJ/src/fam_04message.cpp +++ b/protocols/IcqOscarJ/src/fam_04message.cpp @@ -302,9 +302,8 @@ void CIcqProto::handleRecvServMsgType1(BYTE *buf, size_t wLen, DWORD dwUin, char SAFE_FREE(&szMsg);
szMsg = szUtfMsg;
}
- pre.flags = PREF_UTF;
}
- if (!bMsgPartUnicode && pre.flags == PREF_UTF) { // convert message part to utf-8 and append
+ if (!bMsgPartUnicode) { // convert message part to utf-8 and append
char *szUtfPart = ansi_to_utf8_codepage((char*)szMsgPart, getWord(hContact, "CodePage", m_wAnsiCodepage));
SAFE_FREE(&szMsgPart);
@@ -327,7 +326,6 @@ void CIcqProto::handleRecvServMsgType1(BYTE *buf, size_t wLen, DWORD dwUin, char if (usMsg) {
SAFE_FREE(&szMsg);
szMsg = usMsg;
- pre.flags = PREF_UTF;
}
}
@@ -1053,7 +1051,6 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, size_t wLen, DWORD dwUin, c pre.timestamp = (DWORD)time(NULL);
pre.szMessage = (char *)contacts;
pre.lParam = nContacts;
- pre.flags = PREF_TCHAR;
ProtoChainRecv(hContact, PSR_CONTACTS, 0, (LPARAM)&pre);
}
@@ -1414,7 +1411,7 @@ void packPluginTypeId(icq_packet *packet, int nTypeID) }
-void CIcqProto::handleStatusMsgReply(const char *szPrefix, MCONTACT hContact, DWORD dwUin, WORD wVersion, int bMsgType, WORD wCookie, const char *szMsg)
+void CIcqProto::handleStatusMsgReply(const char *szPrefix, MCONTACT hContact, DWORD dwUin, int bMsgType, WORD wCookie, const char *szMsg)
{
if (hContact == INVALID_CONTACT_ID) {
debugLogA("%sIgnoring status message from unknown contact %u", szPrefix, dwUin);
@@ -1429,10 +1426,6 @@ void CIcqProto::handleStatusMsgReply(const char *szPrefix, MCONTACT hContact, DW // it is probably UTF-8 status reply
PROTORECVEVENT pre = { 0 };
- if (wVersion >= 9)
- if (UTF8_IsValid(szMsg))
- pre.flags |= PREF_UTF;
-
pre.szMessage = (char*)szMsg;
pre.timestamp = time(NULL);
pre.lParam = wCookie;
@@ -1440,7 +1433,7 @@ void CIcqProto::handleStatusMsgReply(const char *szPrefix, MCONTACT hContact, DW }
-HANDLE CIcqProto::handleMessageAck(DWORD dwUin, char *szUID, WORD wCookie, WORD wVersion, int type, PBYTE buf, BYTE bFlags)
+HANDLE CIcqProto::handleMessageAck(DWORD dwUin, char *szUID, WORD wCookie, int type, PBYTE buf, BYTE bFlags)
{
if (bFlags == 3) {
MCONTACT hCookieContact;
@@ -1463,7 +1456,7 @@ HANDLE CIcqProto::handleMessageAck(DWORD dwUin, char *szUID, WORD wCookie, WORD }
ReleaseCookie(wCookie);
- handleStatusMsgReply("handleMessageAck: ", hContact, dwUin, wVersion, type, wCookie, (char*)buf);
+ handleStatusMsgReply("handleMessageAck: ", hContact, dwUin, type, wCookie, (char*)buf);
}
else // Should not happen
debugLogA("%sIgnored type %u ack message (this should not happen)", "handleMessageAck: ", type);
@@ -1504,7 +1497,7 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, }
if (wAckType == 2) {
- handleMessageAck(dwUin, szUID, wCookie, wVersion, type, (LPBYTE)pMsg, (BYTE)flags);
+ handleMessageAck(dwUin, szUID, wCookie, type, (LPBYTE)pMsg, (BYTE)flags);
return;
}
@@ -1552,10 +1545,6 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, usMsg[dwExtraLen] = '\0';
SAFE_FREE(&szMsg);
szMsg = (char*)make_utf8_string(usMsg);
-
- if (!IsUnicodeAscii(usMsg, dwExtraLen))
- pre.flags = PREF_UTF; // only mark real non-ascii messages as unicode
-
bDoubleMsg = 1;
}
}
@@ -1568,7 +1557,6 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, while ((dwGuidLen >= 38) && (dwDataLen >= dwGuidLen)) {
if (!strncmp(pMsg, CAP_UTF8MSGS, 38)) { // Found UTF8 cap, convert message to ansi
- pre.flags = PREF_UTF;
break;
}
else if (!strncmp(pMsg, CAP_RTFMSGS, 38)) { // Found RichText cap
@@ -1583,14 +1571,13 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, }
hContact = HContactFromUIN(dwUin, &bAdded);
- sendMessageTypesAck(hContact, pre.flags & PREF_UTF, pAckParams);
+ sendMessageTypesAck(hContact, true, pAckParams);
if (!pre.flags && !IsUSASCII(szMsg, mir_strlen(szMsg))) { // message is Ansi and contains national characters, create Unicode part by codepage
char *usMsg = convertMsgToUserSpecificUtf(hContact, szMsg);
if (usMsg) {
SAFE_FREE(&szMsg);
szMsg = (char*)usMsg;
- pre.flags = PREF_UTF;
}
}
@@ -1625,9 +1612,7 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, PROTORECVEVENT pre = { 0 };
pre.timestamp = dwTimestamp;
pre.szMessage = (char *)szBlob;
- pre.flags = PREF_UTF;
ProtoChainRecvMsg(hContact, &pre);
-
SAFE_FREE(&szBlob);
}
break;
@@ -1719,7 +1704,6 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, pre.timestamp = dwTimestamp;
pre.szMessage = (char *)isrList;
pre.lParam = nContacts;
- pre.flags = PREF_TCHAR;
ProtoChainRecv(hContact, PSR_CONTACTS, 0, (LPARAM)&pre);
}
@@ -2025,7 +2009,7 @@ void CIcqProto::handleRecvMsgResponse(BYTE *buf, size_t wLen) }
if (bFlags == 3) // A status message reply
- handleStatusMsgReply("SNAC(4.B) ", hContact, dwUin, wVersion, bMsgType, dwCookie, (char*)(buf + 2));
+ handleStatusMsgReply("SNAC(4.B) ", hContact, dwUin, bMsgType, dwCookie, (char*)(buf + 2));
else {
// An ack of some kind
int ackType;
@@ -2111,7 +2095,7 @@ void CIcqProto::handleRecvMsgResponse(BYTE *buf, size_t wLen) if (dwDataLen > 0)
memcpy(szMsg, buf, dwDataLen);
szMsg[dwDataLen] = '\0';
- handleStatusMsgReply("SNAC(4.B) ", hContact, dwUin, wVersion, pCookieData->nAckType, dwCookie, szMsg);
+ handleStatusMsgReply("SNAC(4.B) ", hContact, dwUin, pCookieData->nAckType, dwCookie, szMsg);
ReleaseCookie(dwCookie);
return;
@@ -2167,7 +2151,7 @@ void CIcqProto::handleRecvMsgResponse(BYTE *buf, size_t wLen) szMsg[dwDataLen] = '\0';
szMsg = EliminateHtml(szMsg, dwDataLen);
- handleStatusMsgReply("SNAC(4.B) ", hContact, dwUin, wVersion, pCookieData->nAckType, (WORD)dwCookie, szMsg);
+ handleStatusMsgReply("SNAC(4.B) ", hContact, dwUin, pCookieData->nAckType, (WORD)dwCookie, szMsg);
SAFE_FREE(&szMsg);
diff --git a/protocols/IcqOscarJ/src/fam_13servclist.cpp b/protocols/IcqOscarJ/src/fam_13servclist.cpp index 77faf554f2..aa1a487ad1 100644 --- a/protocols/IcqOscarJ/src/fam_13servclist.cpp +++ b/protocols/IcqOscarJ/src/fam_13servclist.cpp @@ -1390,22 +1390,16 @@ void CIcqProto::handleRecvAuthRequest(unsigned char *buf, size_t wLen) nReasonLen = (int)mir_strlen(szReason); char *temp = (char*)_alloca(nReasonLen + 2); - if (!IsUSASCII(szReason, nReasonLen) && UTF8_IsValid(szReason) && utf8_decode_static(szReason, temp, nReasonLen + 1)) - pre.flags |= PREF_UTF; + if (!IsUSASCII(szReason, nReasonLen) && UTF8_IsValid(szReason)) + utf8_decode_static(szReason, temp, nReasonLen + 1); } // Read nick name from DB char *szNick = NULL; - if (dwUin) { - DBVARIANT dbv = { 0 }; - if (pre.flags & PREF_UTF) - szNick = getSettingStringUtf(hContact, "Nick", NULL); - else if (!getString(hContact, "Nick", &dbv)) { - szNick = null_strdup(dbv.pszVal); - db_free(&dbv); - } - } - else szNick = null_strdup(szUid); + if (dwUin) + szNick = getSettingStringUtf(hContact, "Nick", NULL); + else + szNick = null_strdup(szUid); size_t nNickLen = mir_strlen(szNick); diff --git a/protocols/IcqOscarJ/src/icq_filerequests.cpp b/protocols/IcqOscarJ/src/icq_filerequests.cpp index 0b93cf87a5..9d6891dfb6 100644 --- a/protocols/IcqOscarJ/src/icq_filerequests.cpp +++ b/protocols/IcqOscarJ/src/icq_filerequests.cpp @@ -155,7 +155,7 @@ void CIcqProto::handleFileRequest(PBYTE buf, DWORD dwUin, DWORD dwCookie, DWORD TCHAR* ptszFileName = mir_utf8decodeT(pszFileName);
PROTORECVFILET pre = { 0 };
- pre.flags = PREF_TCHAR;
+ pre.dwFlags = PRFF_TCHAR;
pre.fileCount = 1;
pre.timestamp = time(NULL);
pre.tszDescription = mir_utf8decodeT(pszDescription);
diff --git a/protocols/IcqOscarJ/src/icq_proto.cpp b/protocols/IcqOscarJ/src/icq_proto.cpp index 8fb7f68e67..3095247501 100644 --- a/protocols/IcqOscarJ/src/icq_proto.cpp +++ b/protocols/IcqOscarJ/src/icq_proto.cpp @@ -633,7 +633,7 @@ DWORD_PTR __cdecl CIcqProto::GetCaps(int type, MCONTACT hContact) break;
case PFLAGNUM_4:
- nReturn = PF4_SUPPORTIDLE | PF4_IMSENDUTF | PF4_IMSENDOFFLINE | PF4_INFOSETTINGSVC;
+ nReturn = PF4_SUPPORTIDLE | PF4_IMSENDOFFLINE | PF4_INFOSETTINGSVC;
if (m_bAvatarsEnabled)
nReturn |= PF4_AVATARS;
#ifdef DBG_CAPMTN
@@ -869,41 +869,27 @@ int __cdecl CIcqProto::RecvContacts(MCONTACT hContact, PROTORECVEVENT* pre) ICQSEARCHRESULT **isrList = (ICQSEARCHRESULT**)pre->szMessage;
int i;
size_t cbBlob = 0;
- DWORD flags = 0;
-
- if (pre->flags & PREF_UTF || pre->flags & PREF_UNICODE)
- flags |= DBEF_UTF;
+ DWORD flags = DBEF_UTF;
for (i = 0; i < pre->lParam; i++) {
- if (pre->flags & PREF_UNICODE)
- cbBlob += get_utf8_size((WCHAR*)isrList[i]->hdr.nick) + 2;
- else
- cbBlob += mir_strlen((char*)isrList[i]->hdr.nick) + 2; // both trailing zeros
+ cbBlob += mir_strlen((char*)isrList[i]->hdr.nick) + 2; // both trailing zeros
if (isrList[i]->uin)
cbBlob += getUINLen(isrList[i]->uin);
- else if (pre->flags & PREF_UNICODE)
- cbBlob += mir_wstrlen((WCHAR*)isrList[i]->hdr.id);
else
cbBlob += mir_strlen((char*)isrList[i]->hdr.id);
}
PBYTE pBlob = (PBYTE)_alloca(cbBlob), pCurBlob;
for (i = 0, pCurBlob = pBlob; i < pre->lParam; i++) {
- if (pre->flags & PREF_UNICODE)
- make_utf8_string_static((WCHAR*)isrList[i]->hdr.nick, (char*)pCurBlob, cbBlob - (pCurBlob - pBlob));
- else
- strcpy((char*)pCurBlob, (char*)isrList[i]->hdr.nick);
+ strcpy((char*)pCurBlob, (char*)isrList[i]->hdr.nick);
pCurBlob += mir_strlen((char*)pCurBlob) + 1;
if (isrList[i]->uin) {
char szUin[UINMAXLEN];
_itoa(isrList[i]->uin, szUin, 10);
strcpy((char*)pCurBlob, szUin);
}
- else { // aim contact
- if (pre->flags & PREF_UNICODE)
- unicode_to_ansi_static((WCHAR*)isrList[i]->hdr.id, (char*)pCurBlob, cbBlob - (pCurBlob - pBlob));
- else
- strcpy((char*)pCurBlob, (char*)isrList[i]->hdr.id);
- }
+ else // aim contact
+ strcpy((char*)pCurBlob, (char*)isrList[i]->hdr.id);
+
pCurBlob += mir_strlen((char*)pCurBlob) + 1;
}
@@ -917,17 +903,8 @@ int __cdecl CIcqProto::RecvContacts(MCONTACT hContact, PROTORECVEVENT* pre) int __cdecl CIcqProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT* pre)
{
- DWORD flags = 0;
-
size_t cbBlob = mir_strlen(pre->szMessage) + 1;
- // process utf-8 encoded messages
- if ((pre->flags & PREF_UTF) && !IsUSASCII(pre->szMessage, mir_strlen(pre->szMessage)))
- flags |= DBEF_UTF;
- // process unicode ucs-2 messages
- if ((pre->flags & PREF_UNICODE) && !IsUnicodeAscii((WCHAR*)(pre->szMessage + cbBlob), mir_wstrlen((WCHAR*)(pre->szMessage + cbBlob))))
- cbBlob *= (sizeof(WCHAR)+1);
-
- ICQAddRecvEvent(hContact, EVENTTYPE_MESSAGE, pre, cbBlob, (PBYTE)pre->szMessage, flags);
+ ICQAddRecvEvent(hContact, EVENTTYPE_MESSAGE, pre, cbBlob, (PBYTE)pre->szMessage, DBEF_UTF);
// stop contact from typing - some clients do not sent stop notify
if (CheckContactCapabilities(hContact, CAPF_TYPING))
@@ -1275,13 +1252,13 @@ HANDLE __cdecl CIcqProto::SendFile(MCONTACT hContact, const TCHAR* szDescription ////////////////////////////////////////////////////////////////////////////////////////
// PS_SendMessage - sends a message
-int __cdecl CIcqProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc)
+int __cdecl CIcqProto::SendMsg(MCONTACT hContact, int, const char* pszSrc)
{
if (hContact == NULL || pszSrc == NULL)
return NULL;
DWORD dwCookie;
- char* puszText = NULL;
+ char* puszText = (char*)pszSrc;
int bNeedFreeU = 0;
// Invalid contact
@@ -1290,23 +1267,11 @@ int __cdecl CIcqProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc) if (getContactUid(hContact, &dwUin, &szUID))
return ReportGenericSendError(hContact, ACKTYPE_MESSAGE, "The receiver has an invalid user ID.");
- if (flags & PREF_UNICODE) {
- puszText = make_utf8_string((WCHAR*)(pszSrc + mir_strlen(pszSrc) + 1)); // get the UTF-16 part
- bNeedFreeU = 1;
- }
- else if (flags & PREF_UTF)
- puszText = (char*)pszSrc;
- else {
- puszText = (char*)ansi_to_utf8(pszSrc);
- bNeedFreeU = 1;
- }
-
WORD wRecipientStatus = getContactStatus(hContact);
BOOL plain_ascii = IsUSASCII(puszText, mir_strlen(puszText));
BOOL oldAnsi = plain_ascii || !m_bUtfEnabled ||
- (!(flags & (PREF_UTF | PREF_UNICODE)) && m_bUtfEnabled == 1) ||
!CheckContactCapabilities(hContact, CAPF_UTF) ||
!getByte(hContact, "UnicodeSend", 1);
@@ -1342,11 +1307,9 @@ int __cdecl CIcqProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc) dwCookie = icq_SendDirectMessage(hContact, dc_msg, mir_strlen(dc_msg), pCookieData, dc_cap);
SAFE_FREE(&szUserAnsi);
- if (dwCookie) { // free the buffers if alloced
- if (bNeedFreeU) SAFE_FREE(&puszText);
-
+ if (dwCookie) // free the buffers if alloced
return dwCookie; // we succeded, return
- }
+
// on failure, fallback to send thru server
}
@@ -1358,7 +1321,6 @@ int __cdecl CIcqProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc) memmove(mng + 12, mng, len + 1);
memcpy(mng, "<HTML><BODY>", 12);
strcat(mng, "</BODY></HTML>");
- if (bNeedFreeU) SAFE_FREE(&puszText);
puszText = mng;
bNeedFreeU = 1;
}
@@ -1779,17 +1741,11 @@ HANDLE __cdecl CIcqProto::GetAwayMsg(MCONTACT hContact) int __cdecl CIcqProto::RecvAwayMsg(MCONTACT hContact, int, PROTORECVEVENT* evt)
{
- if (evt->flags & PREF_UTF) {
- setStatusMsgVar(hContact, evt->szMessage, false);
+ setStatusMsgVar(hContact, evt->szMessage, false);
- TCHAR* pszMsg = mir_utf8decodeT(evt->szMessage);
- ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)evt->lParam, (LPARAM)pszMsg);
- mir_free(pszMsg);
- }
- else {
- setStatusMsgVar(hContact, evt->szMessage, true);
- ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)evt->lParam, (LPARAM)(TCHAR*)_A2T(evt->szMessage));
- }
+ TCHAR* pszMsg = mir_utf8decodeT(evt->szMessage);
+ ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)evt->lParam, (LPARAM)pszMsg);
+ mir_free(pszMsg);
return 0;
}
diff --git a/protocols/IcqOscarJ/src/icq_proto.h b/protocols/IcqOscarJ/src/icq_proto.h index 97666e109d..f0e7be49f6 100644 --- a/protocols/IcqOscarJ/src/icq_proto.h +++ b/protocols/IcqOscarJ/src/icq_proto.h @@ -290,7 +290,7 @@ struct CIcqProto : public PROTO<CIcqProto> void handleRecvServMsgError(BYTE *buf, size_t wLen, DWORD dwRef);
void handleRecvMsgResponse(BYTE *buf, size_t wLen);
void handleServerAck(BYTE *buf, size_t wLen, DWORD dwRef);
- void handleStatusMsgReply(const char *szPrefix, MCONTACT hContact, DWORD dwUin, WORD wVersion, int bMsgType, WORD wCookie, const char *szMsg);
+ void handleStatusMsgReply(const char *szPrefix, MCONTACT hContact, DWORD dwUin, int bMsgType, WORD wCookie, const char *szMsg);
void handleTypingNotification(BYTE *buf, size_t wLen);
void handleMissedMsg(BYTE *buf, size_t wLen);
void handleOffineMessagesReply(DWORD dwRef);
@@ -300,7 +300,7 @@ struct CIcqProto : public PROTO<CIcqProto> void parseServRelayData(BYTE *pDataBuf, size_t wLen, MCONTACT hContact, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, WORD wAckType);
void parseServRelayPluginData(BYTE *pDataBuf, size_t wLen, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, WORD wAckType, BYTE bFlags, WORD wStatus, WORD wCookie, WORD wVersion);
- HANDLE handleMessageAck(DWORD dwUin, char *szUID, WORD wCookie, WORD wVersion, int type, PBYTE buf, BYTE bFlags);
+ HANDLE handleMessageAck(DWORD dwUin, char *szUID, WORD wCookie, int type, PBYTE buf, BYTE bFlags);
void handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, DWORD dwMsgID, DWORD dwMsgID2, WORD wCookie, WORD wVersion, int type, int flags, WORD wAckType, size_t dwDataLen, size_t wMsgLen, char *pMsg, int nMsgFlags, message_ack_params *pAckParams);
void sendMessageTypesAck(MCONTACT hContact, int bUnicode, message_ack_params *pArgs);
void sendTypingNotification(MCONTACT hContact, WORD wMTNCode);
diff --git a/protocols/IcqOscarJ/src/icq_xtraz.cpp b/protocols/IcqOscarJ/src/icq_xtraz.cpp index 334ed7455b..bbd5eb7146 100644 --- a/protocols/IcqOscarJ/src/icq_xtraz.cpp +++ b/protocols/IcqOscarJ/src/icq_xtraz.cpp @@ -332,7 +332,7 @@ void CIcqProto::handleXtrazData(DWORD dwUin, char* szMsg, BOOL bThruDC) PROTORECVEVENT pre = { 0 };
pre.timestamp = time(NULL);
pre.szMessage = szWork;
- pre.flags = PREF_UTF;
+ pre.flags = 0;
int bAdded;
ProtoChainRecvMsg(HContactFromUIN(dwUin, &bAdded), &pre);
diff --git a/protocols/IcqOscarJ/src/icqosc_svcs.cpp b/protocols/IcqOscarJ/src/icqosc_svcs.cpp index 5193eac141..4c325a7b6e 100644 --- a/protocols/IcqOscarJ/src/icqosc_svcs.cpp +++ b/protocols/IcqOscarJ/src/icqosc_svcs.cpp @@ -586,12 +586,10 @@ MCONTACT CIcqProto::AddToListByUID(const char *szUID, DWORD dwFlags) void CIcqProto::ICQAddRecvEvent(MCONTACT hContact, WORD wType, PROTORECVEVENT* pre, size_t cbBlob, PBYTE pBlob, DWORD flags)
{
+ flags |= DBEF_UTF;
if (pre->flags & PREF_CREATEREAD)
flags |= DBEF_READ;
- if (pre->flags & PREF_UTF)
- flags |= DBEF_UTF;
-
if (hContact && db_get_b(hContact, "CList", "Hidden", 0)) {
// if the contact was hidden, add to client-list if not in server-list authed
if (!getWord(hContact, DBSETTING_SERVLIST_ID, 0) || getByte(hContact, "Auth", 0)) {
diff --git a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp index 917977dad5..8ac157c740 100644 --- a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp +++ b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp @@ -499,19 +499,13 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, size_t wLen, DWORD dwUin, char * strcpy(szBlob + sizeof(DWORD), pszFileName);
strcpy(szBlob + sizeof(DWORD) + mir_strlen(pszFileName) + 1, pszDescription);
- TCHAR* ptszFileName = mir_utf8decodeT(pszFileName);
-
PROTORECVFILET pre = { 0 };
- pre.flags = PREF_TCHAR;
pre.fileCount = 1;
pre.timestamp = time(NULL);
- pre.tszDescription = mir_utf8decodeT(pszDescription);
- pre.ptszFiles = &ptszFileName;
+ pre.szDescription = pszDescription;
+ pre.pszFiles = &pszFileName;
pre.lParam = (LPARAM)ft;
ProtoChainRecvFile(hContact, &pre);
-
- mir_free(pre.tszDescription);
- mir_free(ptszFileName);
}
else if (wAckType == 2) { // First attempt failed, reverse requested
oscar_filetransfer *ft = FindOscarTransfer(hContact, dwID1, dwID2);
diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp index d138c4d4fc..33c2407aa7 100644 --- a/protocols/JabberG/src/jabber_ft.cpp +++ b/protocols/JabberG/src/jabber_ft.cpp @@ -361,7 +361,7 @@ void CJabberProto::FtHandleSiRequest(HXML iqNode) ft->std.totalBytes = ft->std.currentFileSize = filesize;
PROTORECVFILET pre = { 0 };
- pre.flags = PREF_TCHAR;
+ pre.dwFlags = PRFF_TCHAR;
pre.fileCount = 1;
pre.timestamp = time(NULL);
pre.ptszFiles = (TCHAR**)&filename;
diff --git a/protocols/JabberG/src/jabber_iq_handlers.cpp b/protocols/JabberG/src/jabber_iq_handlers.cpp index 675b0cefbb..c382e37d38 100644 --- a/protocols/JabberG/src/jabber_iq_handlers.cpp +++ b/protocols/JabberG/src/jabber_iq_handlers.cpp @@ -673,7 +673,7 @@ BOOL CJabberProto::OnIqRequestOOB(HXML, CJabberIqInfo *pInfo) JabberHttpUrlDecode(str2);
PROTORECVFILET pre;
- pre.flags = PREF_TCHAR;
+ pre.dwFlags = PRFF_TCHAR;
pre.timestamp = time(NULL);
pre.tszDescription = desc;
pre.ptszFiles = &str2;
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 58e48abc36..a7663e7624 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -574,7 +574,7 @@ DWORD_PTR __cdecl CJabberProto::GetCaps(int type, MCONTACT hContact) case PFLAGNUM_3:
return PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_HEAVYDND | PF2_FREECHAT;
case PFLAGNUM_4:
- return PF4_FORCEAUTH | PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON | PF4_SUPPORTTYPING | PF4_AVATARS | PF4_IMSENDUTF | PF4_FORCEADDED;
+ return PF4_FORCEAUTH | PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON | PF4_SUPPORTTYPING | PF4_AVATARS | PF4_FORCEADDED;
case PFLAG_UNIQUEIDTEXT:
return (DWORD_PTR)Translate("JID");
case PFLAG_UNIQUEIDSETTING:
@@ -956,7 +956,7 @@ void __cdecl CJabberProto::SendMessageAckThread(void* param) static char PGP_PROLOG[] = "-----BEGIN PGP MESSAGE-----\r\n\r\n";
static char PGP_EPILOG[] = "\r\n-----END PGP MESSAGE-----\r\n";
-int __cdecl CJabberProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc)
+int __cdecl CJabberProto::SendMsg(MCONTACT hContact, int, const char* pszSrc)
{
TCHAR szClientJid[JABBER_MAX_JID_LEN];
if (!m_bJabberOnline || !GetClientJID(hContact, szClientJid, SIZEOF(szClientJid))) {
@@ -965,9 +965,7 @@ int __cdecl CJabberProto::SendMsg(MCONTACT hContact, int flags, const char* pszS return 1;
}
- TCHAR *msg;
int isEncrypted, id = SerialNext();
-
if (!strncmp(pszSrc, PGP_PROLOG, strlen(PGP_PROLOG))) {
const char *szEnd = strstr(pszSrc, PGP_EPILOG);
char *tempstring = (char*)alloca(strlen(pszSrc) + 1);
@@ -976,17 +974,11 @@ int __cdecl CJabberProto::SendMsg(MCONTACT hContact, int flags, const char* pszS tempstring[nStrippedLength] = 0;
pszSrc = tempstring;
isEncrypted = 1;
- flags &= ~PREF_UNICODE;
}
else isEncrypted = 0;
- if (flags & PREF_UTF)
- mir_utf8decode(NEWSTR_ALLOCA(pszSrc), &msg);
- else if (flags & PREF_UNICODE)
- msg = mir_u2t((wchar_t*)&pszSrc[strlen(pszSrc) + 1]);
- else
- msg = mir_a2t(pszSrc);
-
+ TCHAR *msg;
+ mir_utf8decode(NEWSTR_ALLOCA(pszSrc), &msg);
if (msg == NULL)
return 0;
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 0c5f428ff2..f185af3e33 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -1376,7 +1376,6 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) msgTime = now;
PROTORECVEVENT recv = { 0 };
- recv.flags = PREF_UTF;
recv.timestamp = (DWORD)msgTime;
recv.szMessage = buf;
recv.lParam = (LPARAM)((pFromResource != NULL && m_options.EnableRemoteControl) ? pFromResource->m_tszResourceName : 0);
diff --git a/protocols/MRA/src/MraFilesQueue.cpp b/protocols/MRA/src/MraFilesQueue.cpp index f6b1e3ebd8..8ab0e44bb4 100644 --- a/protocols/MRA/src/MraFilesQueue.cpp +++ b/protocols/MRA/src/MraFilesQueue.cpp @@ -692,7 +692,7 @@ DWORD CMraProto::MraFilesQueueAddReceive(HANDLE hFilesQueueHandle, DWORD dwFlags // Send chain event
PROTORECVFILET prf;
- prf.flags = PREF_UNICODE;
+ prf.dwFlags = PRFF_UNICODE;
prf.timestamp = _time32(NULL);
prf.tszDescription = dat->pwszDescription;
prf.fileCount = 1;//dat->dwFilesCount;
diff --git a/protocols/MRA/src/MraProto.cpp b/protocols/MRA/src/MraProto.cpp index 7274ba6954..f22cb1cfdf 100644 --- a/protocols/MRA/src/MraProto.cpp +++ b/protocols/MRA/src/MraProto.cpp @@ -272,7 +272,7 @@ DWORD_PTR CMraProto::GetCaps(int type, MCONTACT) return PF2_ONLINE | PF2_INVISIBLE | PF2_SHORTAWAY | PF2_HEAVYDND | PF2_FREECHAT | PF2_ONTHEPHONE;
case PFLAGNUM_4:
- return PF4_FORCEAUTH | PF4_FORCEADDED | PF4_SUPPORTTYPING | PF4_AVATARS | PF4_IMSENDUTF;
+ return PF4_FORCEAUTH | PF4_FORCEADDED | PF4_SUPPORTTYPING | PF4_AVATARS;
case PFLAGNUM_5:
return PF2_ONTHEPHONE;
@@ -385,7 +385,7 @@ HANDLE CMraProto::SendFile(MCONTACT hContact, const TCHAR*, TCHAR **ppszFiles) return (HANDLE)iRet;
}
-int CMraProto::SendMsg(MCONTACT hContact, int flags, const char *lpszMessage)
+int CMraProto::SendMsg(MCONTACT hContact, int, const char *lpszMessage)
{
if (!m_bLoggedIn) {
ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, NULL, (LPARAM)"You cannot send when you are offline.");
@@ -393,15 +393,7 @@ int CMraProto::SendMsg(MCONTACT hContact, int flags, const char *lpszMessage) }
DWORD dwFlags = 0;
- CMStringW wszMessage;
-
- if (flags & PREF_UNICODE)
- wszMessage = (LPWSTR)(lpszMessage + mir_strlen(lpszMessage) + 1);
- else if (flags & PREF_UTF)
- wszMessage = ptrW(mir_utf8decodeT(lpszMessage));
- else
- wszMessage = ptrW(mir_a2t(lpszMessage));
-
+ CMStringW wszMessage(ptrW(mir_utf8decodeT(lpszMessage)));
if (wszMessage.IsEmpty()) {
ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, NULL, (LPARAM)"Cant allocate buffer for convert to unicode.");
return 0;
diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp index 53fa0e572b..f17cc8ce60 100644 --- a/protocols/MRA/src/Mra_proto.cpp +++ b/protocols/MRA/src/Mra_proto.cpp @@ -1781,8 +1781,8 @@ DWORD CMraProto::MraRecvCommand_Message(DWORD dwTime, DWORD dwFlags, CMStringA & if (m_heNudgeReceived)
NotifyEventHooks(m_heNudgeReceived, hContact, NULL);
else {
- pre.flags = PREF_UNICODE;
- pre.szMessage = (LPSTR)TranslateTS(MRA_ALARM_MESSAGE);
+ ptrA szMsg(mir_utf8encodeT(TranslateTS(MRA_ALARM_MESSAGE)));
+ pre.szMessage = szMsg;
ProtoChainRecvMsg(hContact, &pre);
}
}
@@ -1797,7 +1797,6 @@ DWORD CMraProto::MraRecvCommand_Message(DWORD dwTime, DWORD dwFlags, CMStringA & // some plugins can change pre.szMessage pointer and we failed to free it
ptrA lpszMessageUTF(mir_utf8encodeW(wszMessage));
pre.szMessage = lpszMessageUTF;
- pre.flags = PREF_UTF;
ProtoChainRecvMsg(hContact, &pre);
}
diff --git a/protocols/MSN/src/msn_commands.cpp b/protocols/MSN/src/msn_commands.cpp index cddb412fe5..0f3cd8db04 100644 --- a/protocols/MSN/src/msn_commands.cpp +++ b/protocols/MSN/src/msn_commands.cpp @@ -244,7 +244,6 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para pre.timestamp = (DWORD)time(NULL);
pre.szMessage = (char *)isr;
pre.lParam = cnt;
- pre.flags = PREF_TCHAR;
ProtoChainRecv(hContact, PSR_CONTACTS, 0, (LPARAM)&pre);
for (cnt=0; cnt<pre.lParam; cnt++) {
mir_free(isr[cnt]->email);
@@ -299,7 +298,7 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para PROTORECVEVENT pre = { 0 };
pre.szMessage = (char*)msgBody;
- pre.flags = PREF_UTF + (isRtl ? PREF_RTL : 0);
+ pre.flags = (isRtl ? PREF_RTL : 0);
pre.timestamp = (DWORD)time(NULL);
pre.lParam = 0;
ProtoChainRecvMsg(hContact, &pre);
@@ -1067,7 +1066,6 @@ LBL_InvalidCommand: if (!sentMsg) {
PROTORECVEVENT pre = { 0 };
pre.szMessage = (char*)message;
- pre.flags = PREF_UTF;
pre.timestamp = (DWORD)ts;
ProtoChainRecvMsg(hContact, &pre);
}
@@ -1349,7 +1347,7 @@ void CMsnProto::MSN_InviteMessage(ThreadData* info, char* msgBody, char* email, mir_sntprintf(tComment, SIZEOF(tComment), TranslateT("%I64u bytes"), ft->std.currentFileSize);
PROTORECVFILET pre = { 0 };
- pre.flags = PREF_TCHAR;
+ pre.dwFlags = PRFF_TCHAR;
pre.fileCount = 1;
pre.timestamp = time(NULL);
pre.tszDescription = tComment;
diff --git a/protocols/MSN/src/msn_mail.cpp b/protocols/MSN/src/msn_mail.cpp index 03ab085bc5..77d5d9600c 100644 --- a/protocols/MSN/src/msn_mail.cpp +++ b/protocols/MSN/src/msn_mail.cpp @@ -117,7 +117,6 @@ void CMsnProto::getOIMs(ezxml_t xmli) PROTORECVEVENT pre = { 0 };
pre.szMessage = mailInfo.decodeMailBody((char*)mailbody);
- pre.flags = PREF_UTF /*+ ((isRtl) ? PREF_RTL : 0)*/;
pre.timestamp = evtm;
ProtoChainRecvMsg(MSN_HContactFromEmail(szEmail), &pre);
mir_free(pre.szMessage);
diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp index 5683bdb389..ff7e203847 100644 --- a/protocols/MSN/src/msn_misc.cpp +++ b/protocols/MSN/src/msn_misc.cpp @@ -98,7 +98,6 @@ void CMsnProto::MSN_AddAuthRequest(const char *email, const char *nick, const ch int reasonlen = (int)strlen(reason);
PROTORECVEVENT pre = { 0 };
- pre.flags = PREF_UTF;
pre.timestamp = (DWORD)time(NULL);
pre.lParam = sizeof(DWORD) + sizeof(HANDLE) + nicklen + emaillen + 5 + reasonlen;
diff --git a/protocols/MSN/src/msn_p2p.cpp b/protocols/MSN/src/msn_p2p.cpp index 8d97c5fa79..06f90bb63b 100644 --- a/protocols/MSN/src/msn_p2p.cpp +++ b/protocols/MSN/src/msn_p2p.cpp @@ -1231,7 +1231,7 @@ void CMsnProto::p2p_InitFileTransfer( mir_sntprintf(tComment, SIZEOF(tComment), TranslateT("%I64u bytes"), ft->std.currentFileSize);
PROTORECVFILET pre = { 0 };
- pre.flags = PREF_TCHAR;
+ pre.dwFlags = PRFF_TCHAR;
pre.fileCount = 1;
pre.timestamp = time(NULL);
pre.tszDescription = tComment;
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp index 3b9a588261..a49e3bca54 100644 --- a/protocols/MSN/src/msn_proto.cpp +++ b/protocols/MSN/src/msn_proto.cpp @@ -659,8 +659,7 @@ DWORD_PTR __cdecl CMsnProto::GetCaps(int type, MCONTACT) return PF2_ONLINE | PF2_SHORTAWAY | PF2_LIGHTDND;
case PFLAGNUM_4:
- return PF4_FORCEAUTH | PF4_FORCEADDED | PF4_SUPPORTTYPING | PF4_AVATARS | PF4_SUPPORTIDLE | PF4_IMSENDUTF |
- PF4_IMSENDOFFLINE | PF4_NOAUTHDENYREASON;
+ return PF4_FORCEAUTH | PF4_FORCEADDED | PF4_SUPPORTTYPING | PF4_AVATARS | PF4_SUPPORTIDLE | PF4_IMSENDOFFLINE | PF4_NOAUTHDENYREASON;
case PFLAGNUM_5:
return PF2_ONTHEPHONE;
@@ -824,19 +823,8 @@ int __cdecl CMsnProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc) }
char *msg = (char*)pszSrc;
- if (msg == NULL) return 0;
-
- if (flags & PREF_UNICODE) {
- char* p = strchr(msg, '\0');
- if (p != msg) {
- while (*(++p) == '\0') {}
- msg = mir_utf8encodeW((wchar_t*)p);
- }
- else
- msg = mir_strdup(msg);
- }
- else
- msg = (flags & PREF_UTF) ? mir_strdup(msg) : mir_utf8encode(msg);
+ if (msg == NULL)
+ return 0;
int rtlFlag = (flags & PREF_RTL) ? MSG_RTL : 0;
@@ -911,7 +899,6 @@ int __cdecl CMsnProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc) break;
}
- mir_free(msg);
return seq;
}
diff --git a/protocols/Omegle/src/proto.cpp b/protocols/Omegle/src/proto.cpp index d0ac1b3370..dd4b332c1a 100644 --- a/protocols/Omegle/src/proto.cpp +++ b/protocols/Omegle/src/proto.cpp @@ -86,7 +86,7 @@ DWORD_PTR OmegleProto::GetCaps(int type, MCONTACT) case PFLAGNUM_2:
return PF2_ONLINE;
case PFLAGNUM_4:
- return PF4_IMSENDUTF | PF4_SUPPORTTYPING;
+ return PF4_SUPPORTTYPING;
case PFLAG_MAXLENOFMESSAGE:
return OMEGLE_MESSAGE_LIMIT;
case PFLAG_UNIQUEIDTEXT:
diff --git a/protocols/Sametime/src/StdAfx.h b/protocols/Sametime/src/StdAfx.h index 7e2bb9e1e1..7fbf8e695a 100644 --- a/protocols/Sametime/src/StdAfx.h +++ b/protocols/Sametime/src/StdAfx.h @@ -77,4 +77,4 @@ extern "C" { #include <m_chat.h>
#include <m_genmenu.h>
#include <m_icolib.h>
-
+#include <m_string.h>
diff --git a/protocols/Sametime/src/files.cpp b/protocols/Sametime/src/files.cpp index f890a3f19e..e3836b75ae 100644 --- a/protocols/Sametime/src/files.cpp +++ b/protocols/Sametime/src/files.cpp @@ -10,8 +10,8 @@ CSametimeProto* getProtoFromMwFileTransfer(mwFileTransfer* ft) }
/** an incoming file transfer has been offered */
-void mwFileTransfer_offered(mwFileTransfer* ft) {
-
+void mwFileTransfer_offered(mwFileTransfer* ft)
+{
CSametimeProto* proto = getProtoFromMwFileTransfer(ft);
proto->debugLog(_T("mwFileTransfer_offered() start"));
@@ -39,7 +39,7 @@ void mwFileTransfer_offered(mwFileTransfer* ft) { _tcsncpy_s(descriptionT, filenameT, _TRUNCATE);
PROTORECVFILET pre = {0};
- pre.flags = PREF_TCHAR;
+ pre.dwFlags = PRFF_TCHAR;
pre.fileCount = 1;
pre.timestamp = time(NULL);
pre.tszDescription = descriptionT;
diff --git a/protocols/Sametime/src/messaging.cpp b/protocols/Sametime/src/messaging.cpp index e6e953b38f..ce457d3611 100644 --- a/protocols/Sametime/src/messaging.cpp +++ b/protocols/Sametime/src/messaging.cpp @@ -84,7 +84,6 @@ void mwIm_conversation_recv(mwConversation* conv, mwImSendType type, gconstpoint PROTORECVEVENT pre = { 0 };
time_t t = time(NULL);
pre.timestamp = t;
- pre.flags = PREF_UTF;
pre.szMessage = (char*)msg;
ProtoChainRecvMsg(hContact, &pre);
}
@@ -113,7 +112,7 @@ mwImHandler mwIm_handler = { NULL
};
-HANDLE CSametimeProto::SendMessageToUser(MCONTACT hContact, char* msg_utf8)
+HANDLE CSametimeProto::SendMessageToUser(MCONTACT hContact, const char *szMsg)
{
debugLog(_T("CSametimeProto::SendMessageToUser() hContact=[%x]"), hContact);
@@ -128,12 +127,12 @@ HANDLE CSametimeProto::SendMessageToUser(MCONTACT hContact, char* msg_utf8) if (!mwConversation_isOpen(conv)) {
debugLog(_T("CSametimeProto::SendMessageToUser() mwConversation_isOpen"));
mir_cslock lck(q_cs);
- contact_message_queue[hContact].push(msg_utf8);
+ contact_message_queue[hContact].push(szMsg);
mwConversation_open(conv);
}
else {
debugLog(_T("CSametimeProto::SendMessageToUser() !mwConversation_isOpen"));
- mwConversation_send(conv, mwImSend_PLAIN, (gconstpointer)msg_utf8);
+ mwConversation_send(conv, mwImSend_PLAIN, szMsg);
}
free(id_block.user);
diff --git a/protocols/Sametime/src/sametime_proto.cpp b/protocols/Sametime/src/sametime_proto.cpp index cacb87a850..c807697ad1 100644 --- a/protocols/Sametime/src/sametime_proto.cpp +++ b/protocols/Sametime/src/sametime_proto.cpp @@ -131,7 +131,7 @@ DWORD_PTR CSametimeProto::GetCaps(int type, MCONTACT hContact) ret = PF2_ONLINE | PF2_SHORTAWAY | PF2_HEAVYDND | PF2_LIGHTDND;
break;
case PFLAGNUM_4:
- ret = PF4_SUPPORTTYPING | PF4_IMSENDUTF;
+ ret = PF4_SUPPORTTYPING;
break;
case PFLAG_UNIQUEIDTEXT:
ret = (DWORD_PTR)Translate("ID");
@@ -231,9 +231,9 @@ HANDLE CSametimeProto::SendFile(MCONTACT hContact, const PROTOCHAR* szDescriptio return 0; // failure
}
-int CSametimeProto::SendMsg(MCONTACT hContact, int flags, const char* msg)
+int CSametimeProto::SendMsg(MCONTACT hContact, int, const char* msg)
{
- debugLog(_T("CSametimeProto::SendMsg() hContact=[%x], flags=[%d]"), hContact, flags);
+ debugLog(_T("CSametimeProto::SendMsg() hContact=[%x]"), hContact);
char *proto = GetContactProto(hContact);
int ret;
@@ -247,19 +247,10 @@ int CSametimeProto::SendMsg(MCONTACT hContact, int flags, const char* msg) return 0;
}
- char *msg_utf8;
- if (flags & PREF_UNICODE)
- msg_utf8 = mir_utf8encodeW((wchar_t*)&msg[strlen(msg) + 1]);
- else if (flags & PREF_UTF)
- msg_utf8 = mir_strdup(msg);
- else
- msg_utf8 = mir_utf8encode(msg);
-
- if (!msg_utf8)
+ if (!msg)
return 0;
- ret = (int)SendMessageToUser(hContact, msg_utf8);
- mir_free(msg_utf8);
+ ret = (int)SendMessageToUser(hContact, msg);
TFakeAckParams *tfap = (TFakeAckParams*)mir_alloc(sizeof(TFakeAckParams));
tfap->proto = this;
@@ -305,13 +296,8 @@ int CSametimeProto::RecvAwayMsg(MCONTACT hContact, int mode, PROTORECVEVENT* evt {
debugLog(_T("CSametimeProto::RecvAwayMsg() hContact=[%x], mode=[%d]"), hContact, mode);
- if (evt->flags & PREF_UTF) {
- TCHAR* pszMsg = mir_utf8decodeT(evt->szMessage);
- ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)evt->lParam, (LPARAM)pszMsg);
- mir_free(pszMsg);
- }
- else ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)evt->lParam, (LPARAM)(TCHAR*)_A2T(evt->szMessage));
-
+ ptrT pszMsg(mir_utf8decodeT(evt->szMessage));
+ ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)evt->lParam, pszMsg);
return 0;
}
diff --git a/protocols/Sametime/src/sametime_proto.h b/protocols/Sametime/src/sametime_proto.h index 4243f16f61..c2a023317d 100644 --- a/protocols/Sametime/src/sametime_proto.h +++ b/protocols/Sametime/src/sametime_proto.h @@ -63,7 +63,7 @@ struct CSametimeProto : public PROTO<CSametimeProto> void InitMessaging();
void DeinitMessaging();
void SendTyping(MCONTACT hContact, bool typing);
- HANDLE SendMessageToUser(MCONTACT hContact, char* msg_utf8);
+ HANDLE SendMessageToUser(MCONTACT hContact, const char *szMsg);
void CloseIm(MCONTACT hContact);
// userlist.cpp
diff --git a/protocols/SkypeClassic/src/filexfer.cpp b/protocols/SkypeClassic/src/filexfer.cpp index 0c53202a83..d0caedea03 100644 --- a/protocols/SkypeClassic/src/filexfer.cpp +++ b/protocols/SkypeClassic/src/filexfer.cpp @@ -21,19 +21,11 @@ INT_PTR SkypeRecvFile(WPARAM, LPARAM lParam) dbei.szModule = SKYPE_PROTONAME;
dbei.timestamp = pre->timestamp;
if (pre->flags & PREF_CREATEREAD) dbei.flags |= DBEF_READ;
- if (pre->flags & PREF_UTF) dbei.flags |= DBEF_UTF;
dbei.eventType = EVENTTYPE_FILE;
dbei.cbBlob = sizeof(DWORD);
- if (pre->flags & PREF_UNICODE) {
- for (nFiles = 0; cbFilename = wcslen((wchar_t*)&pre->szMessage[dbei.cbBlob])*sizeof(wchar_t); nFiles++)
- dbei.cbBlob += DWORD(cbFilename) + sizeof(wchar_t);
- dbei.cbBlob += sizeof(wchar_t);
- }
- else {
- for (nFiles = 0; cbFilename = strlen(&pre->szMessage[dbei.cbBlob]); nFiles++)
- dbei.cbBlob += DWORD(cbFilename) + 1;
- dbei.cbBlob++;
- }
+ for (nFiles = 0; cbFilename = strlen(&pre->szMessage[dbei.cbBlob]); nFiles++)
+ dbei.cbBlob += DWORD(cbFilename) + 1;
+ dbei.cbBlob++;
dbei.pBlob = (PBYTE)pre->szMessage;
TYP_MSGLENTRY *pEntry = MsgList_Add(pre->lParam, db_event_add(ccs->hContact, &dbei));
@@ -48,21 +40,12 @@ INT_PTR SkypeRecvFile(WPARAM, LPARAM lParam) pfts->hContact = ccs->hContact;
pfts->totalFiles = nFiles;
if (pfts->pszFiles = (char**)calloc(nFiles + 1, sizeof(char*))) {
- if (pre->flags & PREF_UNICODE) {
- wchar_t *pFN;
- for (size_t i = 0; cbFilename = wcslen(pFN = (wchar_t*)&pre->szMessage[iOffs])*sizeof(wchar_t); i++) {
- pfts->pszFiles[i] = (char*)wcsdup(pFN);
- iOffs += cbFilename + sizeof(wchar_t);
- }
- }
- else {
- char *pFN;
- for (size_t i = 0; cbFilename = strlen(pFN = &pre->szMessage[iOffs]); i++) {
- pfts->pszFiles[i] = strdup(pFN);
- iOffs += cbFilename + 1;
- }
- if (pre->flags & PREF_UTF) pfts->flags |= PFTS_UTF;
+ char *pFN;
+ for (size_t i = 0; cbFilename = strlen(pFN = &pre->szMessage[iOffs]); i++) {
+ pfts->pszFiles[i] = strdup(pFN);
+ iOffs += cbFilename + 1;
}
+ pfts->flags |= PFTS_UTF;
ret = pre->lParam;
}
}
@@ -244,7 +227,6 @@ BOOL FXHandleRecv(PROTORECVEVENT *pre, MCONTACT hContact) cbMsg = cbNewSize - 1;
}
else pszMsgNum = NULL;
- pre->flags |= PREF_UTF;
free(pszFN);
}
}
diff --git a/protocols/SkypeClassic/src/gchat.cpp b/protocols/SkypeClassic/src/gchat.cpp index cbd154ac4a..93ad849677 100644 --- a/protocols/SkypeClassic/src/gchat.cpp +++ b/protocols/SkypeClassic/src/gchat.cpp @@ -621,11 +621,11 @@ int GCEventHook(WPARAM,LPARAM lParam) { // remove the ending linebreak for (pEnd = &gch->ptszText[_tcslen(gch->ptszText) - 1]; *pEnd==_T('\r') || *pEnd==_T('\n'); pEnd--) *pEnd=0; - // Send message to the chat-contact + // Send message to the chat-contact if (ccs.hContact = find_chat(gch->pDest->ptszID)) { // If PREF_UTF is supported, just convert it to UTF8 and pass the buffer to PSS_MESSAGE ccs.lParam = (LPARAM)make_utf8_string(gch->ptszText); - ccs.wParam = PREF_UTF; + ccs.wParam = 0; CallProtoService (SKYPE_PROTONAME, PSS_MESSAGE, 0, (LPARAM)&ccs); free ((void*)ccs.lParam); } diff --git a/protocols/SkypeClassic/src/skype.cpp b/protocols/SkypeClassic/src/skype.cpp index 60c5f89556..e152a1496e 100644 --- a/protocols/SkypeClassic/src/skype.cpp +++ b/protocols/SkypeClassic/src/skype.cpp @@ -513,8 +513,6 @@ static void QueryUserWaitingAuthorization(char *pszNick, char *pszAuthRq) pCurBlob += sizeof(DWORD); // Not used
memcpy(pCurBlob, &hContact, sizeof(HANDLE)); pCurBlob += sizeof(HANDLE);
- pre.flags |= PREF_UTF;
-
sprintf(pCurBlob, "%s%c%s%c%s%c%c%s", pszNick, 0, firstname ? firstname : "", 0, lastname ? lastname : "", 0, 0, authmsg ? authmsg : "");
CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs);
@@ -1215,28 +1213,15 @@ void FetchMessageThread(fetchmsg_arg *pargs) { if (!isGroupChat) { // I guess Groupchat doesn't support UTF8?
msg = ptr;
- pre.flags |= PREF_UTF;
}
- else { // Older version has to decode either UTF8->ANSI or UTF8->UNICODE
+ else {
+ // Older version has to decode either UTF8->ANSI or UTF8->UNICODE
// This could be replaced by mir_getUTFI - functions for Miranda 0.5+ builds, but we stay
// 0.4 compatible for backwards compatibility. Unfortunately this requires us to link with utf8.c
-#ifdef _UNICODE
- int wcLen;
-#endif
-
if (utf8_decode(msgptr, &msg) == -1) {
free(ptr);
__leave;
}
-#ifdef _UNICODE
- msglen = (int)strlen(msg) + 1;
- msgptr = (char*)make_unicode_string((const unsigned char*)msgptr);
- wcLen = int(_tcslen((TCHAR*)msgptr) + 1)*sizeof(TCHAR);
- msg = (char*)realloc(msg, msglen + wcLen);
- memcpy(msg + msglen, msgptr, wcLen);
- free(msgptr);
- pre.flags |= PREF_UNICODE;
-#endif
msgptr = msg;
free(ptr);
}
@@ -1309,13 +1294,11 @@ void FetchMessageThread(fetchmsg_arg *pargs) { if (!(dbei.szModule = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact, 0)))
dbei.szModule = SKYPE_PROTONAME;
dbei.cbBlob = msglen;
- if (pre.flags & PREF_UNICODE)
- dbei.cbBlob += sizeof(WCHAR)*((DWORD)wcslen((WCHAR*)&msgptr[dbei.cbBlob]) + 1);
dbei.pBlob = (PBYTE)msgptr;
dbei.timestamp = timestamp > 0 ? timestamp : (DWORD)SkypeTime(NULL);
dbei.flags = direction;
- if (pre.flags & PREF_CREATEREAD) dbei.flags |= DBEF_READ;
- if (pre.flags & PREF_UTF) dbei.flags |= DBEF_UTF;
+ if (pre.flags & PREF_CREATEREAD)
+ dbei.flags |= DBEF_READ;
dbei.eventType = EVENTTYPE_MESSAGE;
pme = MsgList_Add((DWORD)pre.lParam, db_event_add(hContact, &dbei));
@@ -2711,7 +2694,7 @@ void MessageSendWatchThread(void *a) { INT_PTR SkypeSendMessage(WPARAM, LPARAM lParam) {
CCSDATA *ccs = (CCSDATA *)lParam;
DBVARIANT dbv;
- char *msg = (char *)ccs->lParam, *utfmsg = NULL, *mymsgcmd = cmdMessage, szId[16] = { 0 };
+ char *msg = (char *)ccs->lParam, *mymsgcmd = cmdMessage, szId[16] = { 0 };
static DWORD dwMsgNum = 0;
BYTE bIsChatroom = 0 != db_get_b(ccs->hContact, SKYPE_PROTONAME, "ChatRoom", 0);
@@ -2728,24 +2711,14 @@ INT_PTR SkypeSendMessage(WPARAM, LPARAM lParam) { mymsgcmd = "MESSAGE";
}
- if (ccs->wParam & PREF_UTF) {
- utfmsg = msg;
- }
- else if (ccs->wParam & PREF_UNICODE) {
- utfmsg = (char*)make_utf8_string((WCHAR*)(msg + strlen(msg) + 1));
- }
- else {
- if (utf8_encode(msg, &utfmsg) == -1) utfmsg = NULL;
- }
if (protocol >= 4) {
InterlockedIncrement((LONG*)&dwMsgNum);
sprintf(szId, "#M%d ", dwMsgNum++);
}
InterlockedIncrement(&sendwatchers);
bool sendok = true;
- if (!utfmsg || SkypeSend("%s%s %s %s", szId, mymsgcmd, dbv.pszVal, utfmsg))
+ if (!msg || SkypeSend("%s%s %s %s", szId, mymsgcmd, dbv.pszVal, msg))
sendok = false;
- if (utfmsg && utfmsg != msg) free(utfmsg);
db_free(&dbv);
if (sendok) {
@@ -2777,12 +2750,11 @@ INT_PTR SkypeRecvMessage(WPARAM, LPARAM lParam) dbei.cbSize = sizeof(dbei);
dbei.szModule = SKYPE_PROTONAME;
dbei.timestamp = pre->timestamp;
- if (pre->flags & PREF_CREATEREAD) dbei.flags |= DBEF_READ;
- if (pre->flags & PREF_UTF) dbei.flags |= DBEF_UTF;
+ if (pre->flags & PREF_CREATEREAD)
+ dbei.flags |= DBEF_READ;
+ dbei.flags |= DBEF_UTF;
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.cbBlob = (int)strlen(pre->szMessage) + 1;
- if (pre->flags & PREF_UNICODE)
- dbei.cbBlob += sizeof(wchar_t)*((DWORD)wcslen((wchar_t*)&pre->szMessage[dbei.cbBlob]) + 1);
dbei.pBlob = (PBYTE)pre->szMessage;
MsgList_Add((DWORD)pre->lParam, db_event_add(ccs->hContact, &dbei));
return 0;
@@ -2838,8 +2810,7 @@ INT_PTR SkypeRecvAuth(WPARAM, LPARAM lParam) { dbei.cbSize = sizeof(dbei);
dbei.szModule = SKYPE_PROTONAME;
dbei.timestamp = pre->timestamp;
- dbei.flags = ((pre->flags & PREF_CREATEREAD) ? DBEF_READ : 0);
- dbei.flags |= (pre->flags & PREF_UTF) ? DBEF_UTF : 0;
+ dbei.flags = DBEF_UTF | ((pre->flags & PREF_CREATEREAD) ? DBEF_READ : 0);
dbei.eventType = EVENTTYPE_AUTHREQUEST;
dbei.cbBlob = (int)pre->lParam;
dbei.pBlob = (PBYTE)pre->szMessage;
diff --git a/protocols/SkypeClassic/src/skypesvc.cpp b/protocols/SkypeClassic/src/skypesvc.cpp index 1ca79ec62b..fae8b8cd3b 100644 --- a/protocols/SkypeClassic/src/skypesvc.cpp +++ b/protocols/SkypeClassic/src/skypesvc.cpp @@ -131,7 +131,7 @@ INT_PTR SkypeGetCaps(WPARAM wParam, LPARAM) case PFLAGNUM_3:
return PF2_ONLINE | PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE | PF2_IDLE;
case PFLAGNUM_4:
- return PF4_FORCEAUTH | PF4_FORCEADDED | PF4_AVATARS | PF4_SUPPORTTYPING /* Not really, but libgaim compat. */ | PF4_IMSENDUTF;
+ return PF4_FORCEAUTH | PF4_FORCEADDED | PF4_AVATARS | PF4_SUPPORTTYPING;
case PFLAGNUM_5:
return Proto_Status2Flag(db_get_dw(NULL, SKYPE_PROTONAME, "SkypeOutStatusMode", ID_STATUS_ONTHEPHONE));
case PFLAG_UNIQUEIDTEXT:
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp index 873186e0d9..0a33ee44e8 100644 --- a/protocols/SkypeWeb/src/skype_contacts.cpp +++ b/protocols/SkypeWeb/src/skype_contacts.cpp @@ -151,7 +151,6 @@ void CSkypeProto::LoadContactsAuth(const NETLIBHTTPREQUEST *response) delSetting(hContact, "Auth");
PROTORECVEVENT pre = { 0 };
- pre.flags = PREF_UTF;
pre.timestamp = time(NULL);
pre.lParam = (DWORD)(sizeof(DWORD) * 2 + mir_strlen(skypename) + reason.GetLength() + 5);
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp index 72b359247c..65c26869d4 100644 --- a/protocols/SkypeWeb/src/skype_messages.cpp +++ b/protocols/SkypeWeb/src/skype_messages.cpp @@ -30,7 +30,6 @@ int CSkypeProto::OnReceiveMessage(const char *messageId, const char *url, time_t return 0;
PROTORECVEVENT recv = { 0 };
- recv.flags = PREF_UTF;
recv.timestamp = timestamp;
recv.szMessage = content;
recv.lParam = emoteOffset;
@@ -68,7 +67,7 @@ struct SendMessageParam };
// outcoming message flow
-int CSkypeProto::OnSendMessage(MCONTACT hContact, int flags, const char *szMessage)
+int CSkypeProto::OnSendMessage(MCONTACT hContact, int, const char *szMessage)
{
if (!IsOnline())
{
@@ -80,22 +79,14 @@ int CSkypeProto::OnSendMessage(MCONTACT hContact, int flags, const char *szMessa param->hContact = hContact;
param->hMessage = time(NULL);
- ptrA message;
- if (flags & PREF_UNICODE)
- message = mir_utf8encodeW((wchar_t*)&szMessage[mir_strlen(szMessage) + 1]);
- else if (flags & PREF_UTF)
- message = mir_strdup(szMessage);
- else
- message = mir_utf8encode(szMessage);
-
ptrA username(getStringA(hContact, "Skypename"));
debugLogA(__FUNCTION__ " clientmsgid = %d", param->hMessage);
- if (strncmp(message, "/me ", 4) == 0)
- SendRequest(new SendActionRequest(RegToken, SelfSkypeName, param->hMessage, &message[4], Server), &CSkypeProto::OnMessageSent, param);
+ if (strncmp(szMessage, "/me ", 4) == 0)
+ SendRequest(new SendActionRequest(RegToken, SelfSkypeName, param->hMessage, &szMessage[4], Server), &CSkypeProto::OnMessageSent, param);
else
- SendRequest(new SendMessageRequest(RegToken, username, param->hMessage, message, Server), &CSkypeProto::OnMessageSent, param);
+ SendRequest(new SendMessageRequest(RegToken, username, param->hMessage, szMessage, Server), &CSkypeProto::OnMessageSent, param);
return param->hMessage;
}
diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp index dc51bca888..dc95b115ea 100644 --- a/protocols/SkypeWeb/src/skype_proto.cpp +++ b/protocols/SkypeWeb/src/skype_proto.cpp @@ -85,7 +85,7 @@ DWORD_PTR CSkypeProto::GetCaps(int type, MCONTACT) case PFLAGNUM_3:
return PF2_ONLINE | PF2_INVISIBLE | PF2_SHORTAWAY | PF2_HEAVYDND;
case PFLAGNUM_4:
- return PF4_FORCEADDED | PF4_NOAUTHDENYREASON | PF4_SUPPORTTYPING | PF4_AVATARS | PF4_IMSENDOFFLINE | PF4_IMSENDUTF;
+ return PF4_FORCEADDED | PF4_NOAUTHDENYREASON | PF4_SUPPORTTYPING | PF4_AVATARS | PF4_IMSENDOFFLINE;
case PFLAG_UNIQUEIDTEXT:
return (INT_PTR)"Skypename";
case PFLAG_UNIQUEIDSETTING:
diff --git a/protocols/Steam/src/steam_pooling.cpp b/protocols/Steam/src/steam_pooling.cpp index e1dcb1ff28..912af1e7a5 100644 --- a/protocols/Steam/src/steam_pooling.cpp +++ b/protocols/Steam/src/steam_pooling.cpp @@ -35,10 +35,8 @@ void CSteamProto::ParsePollData(JSONNODE *data) if (_tcsstr(type, _T("my_")) == NULL) { PROTORECVEVENT recv = { 0 }; - recv.flags = PREF_UTF; recv.timestamp = timestamp; recv.szMessage = szMessage; - ProtoChainRecvMsg(hContact, &recv); } else diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp index 405f598d5e..9196e03aa5 100644 --- a/protocols/Steam/src/steam_proto.cpp +++ b/protocols/Steam/src/steam_proto.cpp @@ -202,7 +202,7 @@ DWORD_PTR __cdecl CSteamProto:: GetCaps(int type, MCONTACT) case PFLAGNUM_2: return PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_HEAVYDND | PF2_OUTTOLUNCH | PF2_FREECHAT; case PFLAGNUM_4: - return PF4_AVATARS | PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON | PF4_FORCEAUTH | PF4_FORCEADDED | PF4_IMSENDUTF | PF4_SUPPORTIDLE | PF4_SUPPORTTYPING;// | PF4_IMSENDOFFLINE; + return PF4_AVATARS | PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON | PF4_FORCEAUTH | PF4_FORCEADDED | PF4_SUPPORTIDLE | PF4_SUPPORTTYPING;// | PF4_IMSENDOFFLINE; case PFLAGNUM_5: return PF2_HEAVYDND | PF2_OUTTOLUNCH | PF2_FREECHAT; case PFLAG_UNIQUEIDTEXT: @@ -240,7 +240,7 @@ int __cdecl CSteamProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT* pre) return (INT_PTR)AddDBEvent(hContact, EVENTTYPE_MESSAGE, pre->timestamp, DBEF_UTF, lstrlenA(pre->szMessage), (BYTE*)pre->szMessage); } -int __cdecl CSteamProto::SendMsg(MCONTACT hContact, int flags, const char *msg) +int __cdecl CSteamProto::SendMsg(MCONTACT hContact, int, const char *msg) { UINT hMessage = InterlockedIncrement(&hMessageProcess); @@ -248,10 +248,7 @@ int __cdecl CSteamProto::SendMsg(MCONTACT hContact, int flags, const char *msg) param->hContact = hContact; param->hMessage = (HANDLE)hMessage; param->msg = msg; - param->flags = flags; - ForkThread(&CSteamProto::SendMsgThread, (void*)param); - return hMessage; } @@ -266,14 +263,12 @@ void __cdecl CSteamProto::SendMsgThread(void *arg) return; } - CMStringA message = (param->flags & PREF_UNICODE) ? ptrA(mir_utf8encode(param->msg)) : param->msg; // TODO: mir_utf8encode check taken from FacebookRM, is it needed? Usually we get PREF_UTF8 flag instead. - ptrA token(getStringA("TokenSecret")); ptrA umqid(getStringA("UMQID")); ptrA steamId(getStringA(param->hContact, "SteamID")); PushRequest( - new SteamWebApi::SendMessageRequest(token, umqid, steamId, message), + new SteamWebApi::SendMessageRequest(token, umqid, steamId, param->msg), &CSteamProto::OnMessageSent, param, ARG_MIR_FREE); diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h index 1a2e7f38f2..157fb71a8b 100644 --- a/protocols/Steam/src/steam_proto.h +++ b/protocols/Steam/src/steam_proto.h @@ -22,7 +22,6 @@ struct SendMessageParam MCONTACT hContact;
HANDLE hMessage;
const char *msg;
- int flags;
};
struct STEAM_SEARCH_RESULT
diff --git a/protocols/Tlen/src/tlen_file.cpp b/protocols/Tlen/src/tlen_file.cpp index 869097190d..830c828cf4 100644 --- a/protocols/Tlen/src/tlen_file.cpp +++ b/protocols/Tlen/src/tlen_file.cpp @@ -592,7 +592,7 @@ void TlenProcessF(XmlNode *node, ThreadData *info) if (szFilename[0] != '\0' && ft->iqId != NULL) {
TCHAR* filenameT = mir_utf8decodeT((char*)szFilename);
PROTORECVFILET pre = {0};
- pre.flags = PREF_TCHAR;
+ pre.dwFlags = PRFF_TCHAR;
pre.fileCount = 1;
pre.timestamp = time(NULL);
pre.tszDescription = filenameT;
diff --git a/protocols/Tlen/src/tlen_p2p_new.cpp b/protocols/Tlen/src/tlen_p2p_new.cpp index ec7ebdd473..868b877313 100644 --- a/protocols/Tlen/src/tlen_p2p_new.cpp +++ b/protocols/Tlen/src/tlen_p2p_new.cpp @@ -259,8 +259,8 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) { item->ft = ft;
mir_snprintf(fileInfo, SIZEOF(fileInfo), "%s file(s), %s bytes", c, s);
TCHAR* filenameT = mir_utf8decodeT((char*)fileInfo);
- PROTORECVFILET pre = {0};
- pre.flags = PREF_TCHAR;
+ PROTORECVFILET pre = { 0 };
+ pre.dwFlags = PRFF_TCHAR;
pre.fileCount = 1;
pre.timestamp = time(NULL);
pre.tszDescription = filenameT;
diff --git a/protocols/Tlen/src/tlen_svc.cpp b/protocols/Tlen/src/tlen_svc.cpp index 96e20cdc21..9481729dd8 100644 --- a/protocols/Tlen/src/tlen_svc.cpp +++ b/protocols/Tlen/src/tlen_svc.cpp @@ -601,7 +601,7 @@ INT_PTR TlenProtocol::SendAlert(WPARAM hContact, LPARAM lParam) return 0;
}
-int TlenProtocol::SendMsg(MCONTACT hContact, int flags, const char* msgRAW)
+int TlenProtocol::SendMsg(MCONTACT hContact, int, const char* msgRAW)
{
DBVARIANT dbv;
if (!isOnline || db_get(hContact, m_szModuleName, "jid", &dbv)) {
@@ -609,30 +609,21 @@ int TlenProtocol::SendMsg(MCONTACT hContact, int flags, const char* msgRAW) return 2;
}
- char* msg;
- if (flags & PREF_UNICODE)
- msg = mir_u2a((wchar_t*)&msgRAW[strlen(msgRAW) + 1]);
- else if (flags & PREF_UTF)
- msg = mir_utf8decodeA(msgRAW);
- else
- msg = mir_strdup(msgRAW);
-
TLEN_LIST_ITEM *item;
char msgType[16];
-
int id = TlenSerialNext(this);
- if (!strcmp(msg, "<alert>")) {
+ if (!strcmp(msgRAW, "<alert>")) {
TlenSend(this, "<m tp='a' to='%s'/>", dbv.pszVal);
forkthread(TlenSendMessageAckThread, 0, new SENDACKTHREADDATA(this, hContact, id));
}
- else if (!strcmp(msg, "<image>")) {
+ else if (!strcmp(msgRAW, "<image>")) {
TlenSend(this, "<message to='%s' type='%s' crc='%x' idt='%d'/>", dbv.pszVal, "pic", 0x757f044, id);
forkthread(TlenSendMessageAckThread, 0, new SENDACKTHREADDATA(this, hContact, id));
}
else {
- char *msgEnc=TlenTextEncode(msg);
+ char *msgEnc = TlenTextEncode(msgRAW);
if (msgEnc != NULL) {
if (TlenListExist(this, LIST_CHATROOM, dbv.pszVal) && strchr(dbv.pszVal, '/') == NULL)
strcpy(msgType, "groupchat");
@@ -660,7 +651,6 @@ int TlenProtocol::SendMsg(MCONTACT hContact, int flags, const char* msgRAW) mir_free(msgEnc);
}
- mir_free(msg);
db_free(&dbv);
return id;
}
diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp index 95491995a1..2611f185a1 100644 --- a/protocols/Tox/src/tox_contacts.cpp +++ b/protocols/Tox/src/tox_contacts.cpp @@ -255,7 +255,6 @@ void CToxProto::OnFriendRequest(Tox*, const uint8_t *pubKey, const uint8_t *mess proto->delSetting(hContact, "Auth");
PROTORECVEVENT pre = { 0 };
- pre.flags = PREF_UTF;
pre.timestamp = time(NULL);
pre.lParam = (DWORD)(sizeof(DWORD) * 2 + address.GetLength() + length + 5);
diff --git a/protocols/Tox/src/tox_messages.cpp b/protocols/Tox/src/tox_messages.cpp index d6e77e1ab7..895e4e9aa1 100644 --- a/protocols/Tox/src/tox_messages.cpp +++ b/protocols/Tox/src/tox_messages.cpp @@ -18,17 +18,14 @@ void CToxProto::OnFriendMessage(Tox*, uint32_t friendNumber, TOX_MESSAGE_TYPE ty length -= 3;
mir_strncpy(rawMessage, (const char*)&message[4], length);
}
- else
- mir_strncpy(rawMessage, (const char*)message, length + 1);
+ else mir_strncpy(rawMessage, (const char*)message, length + 1);
rawMessage[length] = 0;
PROTORECVEVENT recv = { 0 };
- recv.flags = PREF_UTF;
+ recv.flags = 0;
recv.timestamp = time(NULL);
recv.szMessage = rawMessage;
- recv.lParam = type == TOX_MESSAGE_TYPE_NORMAL
- ? EVENTTYPE_MESSAGE : DB_EVENT_ACTION;
-
+ recv.lParam = type == TOX_MESSAGE_TYPE_NORMAL ? EVENTTYPE_MESSAGE : DB_EVENT_ACTION;
ProtoChainRecvMsg(hContact, &recv);
CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)PROTOTYPE_CONTACTTYPING_OFF);
@@ -55,24 +52,16 @@ int CToxProto::OnReceiveMessage(MCONTACT hContact, PROTORECVEVENT *pre) /* MESSAGE SENDING */
// outcoming message flow
-int CToxProto::OnSendMessage(MCONTACT hContact, int flags, const char *szMessage)
+int CToxProto::OnSendMessage(MCONTACT hContact, const char *szMessage)
{
int32_t friendNumber = GetToxFriendNumber(hContact);
if (friendNumber == UINT32_MAX)
return 0;
- ptrA message;
- if (flags & PREF_UNICODE)
- message = mir_utf8encodeW((wchar_t*)&szMessage[mir_strlen(szMessage) + 1]);
- else //if (flags & PREF_UTF)
- message = mir_strdup(szMessage);
- //else
- //message = mir_utf8encode(szMessage);
-
- size_t msgLen = mir_strlen(message);
- uint8_t *msg = (uint8_t*)(char*)message;
+ size_t msgLen = mir_strlen(szMessage);
+ uint8_t *msg = (uint8_t*)szMessage;
TOX_MESSAGE_TYPE type = TOX_MESSAGE_TYPE_NORMAL;
- if (strncmp(message, "/me ", 4) == 0)
+ if (strncmp(szMessage, "/me ", 4) == 0)
{
msg += 4; msgLen -= 4;
type = TOX_MESSAGE_TYPE_ACTION;
diff --git a/protocols/Tox/src/tox_multimedia.cpp b/protocols/Tox/src/tox_multimedia.cpp index 0fe92349d5..0325794eb2 100644 --- a/protocols/Tox/src/tox_multimedia.cpp +++ b/protocols/Tox/src/tox_multimedia.cpp @@ -295,9 +295,10 @@ void CToxProto::OnAvInvite(void*, int32_t callId, void *arg) PROTORECVEVENT recv = { 0 };
recv.timestamp = time(NULL);
recv.lParam = callId;
- recv.flags = PREF_UTF;
recv.szMessage = mir_utf8encodeT(message);
ProtoChainRecv(hContact, PSR_AUDIO, hContact, (LPARAM)&recv);
+
+ mir_free(recv.szMessage);
}
// save event to db
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index caa507c315..ab48ce60a2 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -49,8 +49,7 @@ DWORD_PTR CToxProto::GetCaps(int type, MCONTACT) case PFLAGNUM_3:
return PF2_ONLINE | PF2_SHORTAWAY | PF2_LIGHTDND;
case PFLAGNUM_4:
- return PF4_IMSENDUTF | PF4_SINGLEFILEONLY | PF4_SUPPORTTYPING | PF4_AVATARS
- | PF4_FORCEADDED | PF4_NOAUTHDENYREASON | PF4_FORCEAUTH;
+ return PF4_SINGLEFILEONLY | PF4_SUPPORTTYPING | PF4_AVATARS | PF4_FORCEADDED | PF4_NOAUTHDENYREASON | PF4_FORCEAUTH;
case PFLAG_UNIQUEIDTEXT:
return (INT_PTR)"Tox ID";
case PFLAG_UNIQUEIDSETTING:
@@ -136,9 +135,9 @@ int CToxProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT *pre) return OnReceiveMessage(hContact, pre);
}
-int CToxProto::SendMsg(MCONTACT hContact, int flags, const char *msg)
+int CToxProto::SendMsg(MCONTACT hContact, int, const char *msg)
{
- return OnSendMessage(hContact, flags, msg);
+ return OnSendMessage(hContact, msg);
}
HANDLE CToxProto::SendFile(MCONTACT hContact, const PROTOCHAR *msg, PROTOCHAR **ppszFiles)
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index 97b87f27eb..bdb9b82c7d 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -210,7 +210,7 @@ private: // messages
int OnReceiveMessage(MCONTACT hContact, PROTORECVEVENT *pre);
- int OnSendMessage(MCONTACT hContact, int flags, const char *message);
+ int OnSendMessage(MCONTACT hContact, const char *message);
static void OnFriendMessage(Tox *tox, uint32_t friendNumber, TOX_MESSAGE_TYPE type, const uint8_t *message, size_t length, void *arg);
static void OnReadReceipt(Tox *tox, uint32_t friendNumber, uint32_t messageId, void *arg);
diff --git a/protocols/Tox/src/tox_transfer.cpp b/protocols/Tox/src/tox_transfer.cpp index dce86334ae..e1460b3d53 100644 --- a/protocols/Tox/src/tox_transfer.cpp +++ b/protocols/Tox/src/tox_transfer.cpp @@ -10,54 +10,52 @@ void CToxProto::OnFriendFile(Tox*, uint32_t friendNumber, uint32_t fileNumber, u MCONTACT hContact = proto->GetContact(friendNumber);
if (hContact)
{
- switch (kind)
- {
+ switch (kind) {
case TOX_FILE_KIND_AVATAR:
- {
- ptrT address(proto->getTStringA(hContact, TOX_SETTINGS_ID));
- TCHAR avatarName[MAX_PATH];
- mir_sntprintf(avatarName, MAX_PATH, _T("%s.png"), address);
-
- AvatarTransferParam *transfer = new AvatarTransferParam(friendNumber, fileNumber, avatarName, fileSize);
- transfer->pfts.flags |= PFTS_RECEIVING;
- transfer->pfts.hContact = hContact;
- proto->transfers.Add(transfer);
-
- TOX_ERR_FILE_GET error;
- tox_file_get_file_id(proto->tox, friendNumber, fileNumber, transfer->hash, &error);
- if (error != TOX_ERR_FILE_GET_OK)
{
- proto->debugLogA(__FUNCTION__": unable to get avatar hash (%d)", error);
- memset(transfer->hash, 0, TOX_HASH_LENGTH);
+ ptrT address(proto->getTStringA(hContact, TOX_SETTINGS_ID));
+ TCHAR avatarName[MAX_PATH];
+ mir_sntprintf(avatarName, MAX_PATH, _T("%s.png"), address);
+
+ AvatarTransferParam *transfer = new AvatarTransferParam(friendNumber, fileNumber, avatarName, fileSize);
+ transfer->pfts.flags |= PFTS_RECEIVING;
+ transfer->pfts.hContact = hContact;
+ proto->transfers.Add(transfer);
+
+ TOX_ERR_FILE_GET error;
+ tox_file_get_file_id(proto->tox, friendNumber, fileNumber, transfer->hash, &error);
+ if (error != TOX_ERR_FILE_GET_OK) {
+ proto->debugLogA(__FUNCTION__": unable to get avatar hash (%d)", error);
+ memset(transfer->hash, 0, TOX_HASH_LENGTH);
+ }
+ proto->OnGotFriendAvatarInfo(transfer);
}
- proto->OnGotFriendAvatarInfo(transfer);
- }
- break;
+ break;
case TOX_FILE_KIND_DATA:
- {
- ptrA rawName((char*)mir_alloc(filenameLength + 1));
- memcpy(rawName, fileName, filenameLength);
- rawName[filenameLength] = 0;
- TCHAR *name = mir_utf8decodeT(rawName);
-
- FileTransferParam *transfer = new FileTransferParam(friendNumber, fileNumber, name, fileSize);
- transfer->pfts.flags |= PFTS_RECEIVING;
- transfer->pfts.hContact = hContact;
- proto->transfers.Add(transfer);
-
- PROTORECVFILET pre = { 0 };
- pre.flags = PREF_TCHAR;
- pre.fileCount = 1;
- pre.timestamp = time(NULL);
- pre.tszDescription = _T("");
- pre.ptszFiles = (TCHAR**)mir_alloc(sizeof(TCHAR*) * 2);
- pre.ptszFiles[0] = name;
- pre.ptszFiles[1] = NULL;
- pre.lParam = (LPARAM)transfer;
- ProtoChainRecvFile(hContact, &pre);
- }
- break;
+ {
+ ptrA rawName((char*)mir_alloc(filenameLength + 1));
+ memcpy(rawName, fileName, filenameLength);
+ rawName[filenameLength] = 0;
+ TCHAR *name = mir_utf8decodeT(rawName);
+
+ FileTransferParam *transfer = new FileTransferParam(friendNumber, fileNumber, name, fileSize);
+ transfer->pfts.flags |= PFTS_RECEIVING;
+ transfer->pfts.hContact = hContact;
+ proto->transfers.Add(transfer);
+
+ PROTORECVFILET pre = { 0 };
+ pre.dwFlags = PRFF_TCHAR;
+ pre.fileCount = 1;
+ pre.timestamp = time(NULL);
+ pre.tszDescription = _T("");
+ pre.ptszFiles = (TCHAR**)mir_alloc(sizeof(TCHAR*) * 2);
+ pre.ptszFiles[0] = name;
+ pre.ptszFiles[1] = NULL;
+ pre.lParam = (LPARAM)transfer;
+ ProtoChainRecvFile(hContact, &pre);
+ }
+ break;
default:
proto->debugLogA(__FUNCTION__": unsupported transfer type (%d)", kind);
diff --git a/protocols/Twitter/src/connection.cpp b/protocols/Twitter/src/connection.cpp index f40a6294f3..f793b09e0a 100644 --- a/protocols/Twitter/src/connection.cpp +++ b/protocols/Twitter/src/connection.cpp @@ -628,7 +628,6 @@ void TwitterProto::UpdateMessages(bool pre_read) MCONTACT hContact = AddToClientList(i->username.c_str(), "");
PROTORECVEVENT recv = { 0 };
- recv.flags = PREF_UTF;
if (pre_read)
recv.flags |= PREF_CREATEREAD;
recv.szMessage = const_cast<char*>(i->status.text.c_str());
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp index 820c67d1e2..dd28a80e25 100644 --- a/protocols/Twitter/src/proto.cpp +++ b/protocols/Twitter/src/proto.cpp @@ -86,7 +86,7 @@ DWORD_PTR TwitterProto::GetCaps(int type, MCONTACT) case PFLAGNUM_3:
return PF2_ONLINE;
case PFLAGNUM_4:
- return PF4_NOCUSTOMAUTH | PF4_IMSENDUTF | PF4_AVATARS;
+ return PF4_NOCUSTOMAUTH | PF4_AVATARS;
case PFLAG_MAXLENOFMESSAGE:
return 159; // 140 + <max length of a users name (15 apparently)> + 4 ("RT @"). this allows for the new style retweets
case PFLAG_UNIQUEIDTEXT:
@@ -136,19 +136,11 @@ void TwitterProto::SendSuccess(void *p) delete data;
}
-int TwitterProto::SendMsg(MCONTACT hContact, int flags, const char *msg)
+int TwitterProto::SendMsg(MCONTACT hContact, int, const char *msg)
{
if (m_iStatus != ID_STATUS_ONLINE)
return 0;
- TCHAR *tszMsg;
- if (flags & PREF_UTF)
- tszMsg = mir_utf8decodeT(msg);
- else if (flags & PREF_UNICODE)
- tszMsg = mir_u2t((wchar_t*)&msg[strlen(msg) + 1]);
- else
- tszMsg = mir_a2t(msg);
-
int seq = InterlockedIncrement(&g_msgid);
ForkThread(&TwitterProto::SendSuccess, new send_direct(hContact, msg, seq));
return seq;
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp index 78d1d71d04..cd84677cc8 100644 --- a/protocols/VKontakte/src/vk_feed.cpp +++ b/protocols/VKontakte/src/vk_feed.cpp @@ -54,16 +54,14 @@ void CVkProto::AddFeedEvent(CMString& tszBody, time_t tTime) }
MCONTACT hContact = FindUser(VK_FEED_USER, true);
- ptrT ptszBody(mir_tstrdup(tszBody.GetBuffer()));
- PROTORECVEVENT recv = { 0 };
+ ptrA pszBody(mir_utf8encodeT(tszBody));
- recv.flags = PREF_TCHAR;
+ PROTORECVEVENT recv = { 0 };
recv.timestamp = tTime;
- recv.tszMessage = ptszBody;
+ recv.szMessage = pszBody;
recv.lParam = 0;
recv.pCustomData = NULL;
recv.cbCustomDataSize = 0;
-
ProtoChainRecvMsg(hContact, &recv);
}
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp index fdca4b00db..fb10ae9c05 100644 --- a/protocols/VKontakte/src/vk_history.cpp +++ b/protocols/VKontakte/src/vk_history.cpp @@ -218,18 +218,19 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque MCONTACT hContact = FindUser(uid, true);
PROTORECVEVENT recv = { 0 };
- recv.flags = PREF_TCHAR;
if (isRead)
recv.flags |= PREF_CREATEREAD;
if (isOut)
recv.flags |= PREF_SENT;
recv.timestamp = datetime;
- recv.tszMessage = ptszBody;
+ recv.szMessage = mir_utf8encodeT(ptszBody);
recv.lParam = isOut;
recv.pCustomData = szMid;
recv.cbCustomDataSize = (int)mir_strlen(szMid);
ProtoChainRecvMsg(hContact, &recv);
+
count++;
+ mir_free((char*)recv.szMessage);
}
setDword(param->hContact, "lastmsgid", iLastMsgId);
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index 57f25817af..6a9d6825ed 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -37,7 +37,7 @@ void CVkProto::SendMsgAck(void *param) delete ack;
}
-int CVkProto::SendMsg(MCONTACT hContact, int flags, const char *msg)
+int CVkProto::SendMsg(MCONTACT hContact, int, const char *szMsg)
{
debugLogA("CVkProto::SendMsg");
if (!IsOnline())
@@ -48,14 +48,6 @@ int CVkProto::SendMsg(MCONTACT hContact, int flags, const char *msg) return 0;
}
- ptrA szMsg;
- if (flags & PREF_UTF)
- szMsg = mir_strdup(msg);
- else if (flags & PREF_UNICODE)
- szMsg = mir_utf8encodeW((wchar_t*)&msg[mir_strlen(msg) + 1]);
- else
- szMsg = mir_utf8encode(msg);
-
int StickerId = 0;
ptrA retMsg(GetStickerId(szMsg, StickerId));
@@ -77,9 +69,8 @@ int CVkProto::SendMsg(MCONTACT hContact, int flags, const char *msg) ForkThread(&CVkProto::SendMsgAck, new TFakeAckParams(hContact, msgId));
if (retMsg) {
- int _flags = flags | PREF_UTF;
Sleep(330);
- SendMsg(hContact, _flags, retMsg);
+ SendMsg(hContact, 0, retMsg);
}
return msgId;
}
@@ -255,7 +246,6 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe }
PROTORECVEVENT recv = { 0 };
- recv.flags = PREF_TCHAR;
if (isRead && !m_bMesAsUnread)
recv.flags |= PREF_CREATEREAD;
if (isOut)
@@ -264,7 +254,7 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe SetInvisible(hContact);
recv.timestamp = m_bUseLocalTime ? time(NULL) : datetime;
- recv.tszMessage = ptszBody;
+ recv.szMessage = mir_utf8encodeT(ptszBody);
recv.lParam = isOut;
recv.pCustomData = szMid;
recv.cbCustomDataSize = (int)mir_strlen(szMid);
@@ -280,6 +270,8 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe if (!isOut)
m_incIds.insert((HANDLE)mid);
}
+
+ mir_free((char*)recv.szMessage);
}
if (!mids.IsEmpty())
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index d5649f806d..bc6198c5b5 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -461,7 +461,7 @@ DWORD_PTR CVkProto::GetCaps(int type, MCONTACT) return PF2_ONLINE;
case PFLAGNUM_4:
- return PF4_IMSENDUTF | PF4_AVATARS | PF4_SUPPORTTYPING | PF4_NOAUTHDENYREASON | PF4_IMSENDOFFLINE | PF4_OFFLINEFILES;
+ return PF4_AVATARS | PF4_SUPPORTTYPING | PF4_NOAUTHDENYREASON | PF4_IMSENDOFFLINE | PF4_OFFLINEFILES;
case PFLAGNUM_5:
return PF2_ONTHEPHONE;
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index a00a08466e..0468fd7802 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -268,7 +268,7 @@ struct CVkProto : public PROTO<CVkProto> virtual HANDLE __cdecl SearchByName(const TCHAR *nick, const TCHAR *firstName, const TCHAR *lastName);
virtual int __cdecl RecvMsg(MCONTACT hContact, PROTORECVEVENT*);
- virtual int __cdecl SendMsg(MCONTACT hContact, int flags, const char* msg);
+ virtual int __cdecl SendMsg(MCONTACT hContact, int flags, const char *msg);
virtual HANDLE __cdecl SendFile(MCONTACT hContact, const TCHAR *szDescription, TCHAR **ppszFiles);
diff --git a/protocols/WhatsApp/src/messages.cpp b/protocols/WhatsApp/src/messages.cpp index 4525e09b96..74bdc36b00 100644 --- a/protocols/WhatsApp/src/messages.cpp +++ b/protocols/WhatsApp/src/messages.cpp @@ -30,7 +30,6 @@ void WhatsAppProto::onMessageForMe(const FMessage &pMsg) MCONTACT hContact = this->AddToContactList(pMsg.key.remote_jid, pMsg.notifyname.c_str());
PROTORECVEVENT recv = { 0 };
- recv.flags = PREF_UTF;
recv.szMessage = const_cast<char*>(msg.c_str());
recv.timestamp = time(NULL);
ProtoChainRecvMsg(hContact, &recv);
@@ -40,7 +39,7 @@ void WhatsAppProto::onMessageForMe(const FMessage &pMsg) m_pConnection->sendMessageReceived(pMsg);
}
-int WhatsAppProto::SendMsg(MCONTACT hContact, int flags, const char *msg)
+int WhatsAppProto::SendMsg(MCONTACT hContact, int, const char *msg)
{
ptrA jid(getStringA(hContact, "ID"));
if (jid == NULL)
diff --git a/protocols/WhatsApp/src/proto.cpp b/protocols/WhatsApp/src/proto.cpp index 2b5c275981..2bf2bd88db 100644 --- a/protocols/WhatsApp/src/proto.cpp +++ b/protocols/WhatsApp/src/proto.cpp @@ -90,7 +90,7 @@ DWORD_PTR WhatsAppProto::GetCaps(int type, MCONTACT hContact) case PFLAGNUM_3:
return 0;
case PFLAGNUM_4:
- return PF4_NOCUSTOMAUTH | PF4_IMSENDUTF | PF4_FORCEADDED | PF4_NOAUTHDENYREASON | PF4_IMSENDOFFLINE | PF4_SUPPORTTYPING | PF4_AVATARS;
+ return PF4_NOCUSTOMAUTH | PF4_FORCEADDED | PF4_NOAUTHDENYREASON | PF4_IMSENDOFFLINE | PF4_SUPPORTTYPING | PF4_AVATARS;
case PFLAGNUM_5:
return 0;
case PFLAG_UNIQUEIDTEXT:
diff --git a/protocols/Xfire/src/main.cpp b/protocols/Xfire/src/main.cpp index 14f8e7200a..ff8e1b947d 100644 --- a/protocols/Xfire/src/main.cpp +++ b/protocols/Xfire/src/main.cpp @@ -715,12 +715,11 @@ void XFireClient::receivedPacket(XFirePacket *packet) { {
str = ((MessagePacket*)content)->getMessage();
+ CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)entry->hcontact, PROTOTYPE_CONTACTTYPING_OFF);
+
PROTORECVEVENT pre = { 0 };
pre.timestamp = time(NULL);
pre.szMessage = (char*)str.c_str();
- pre.flags = PREF_UTF;
-
- CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)entry->hcontact, PROTOTYPE_CONTACTTYPING_OFF);
ProtoChainRecvMsg(entry->hcontact, &pre);
}
}
diff --git a/protocols/Yahoo/src/file_transfer.cpp b/protocols/Yahoo/src/file_transfer.cpp index b5d4f56839..21faa232d1 100644 --- a/protocols/Yahoo/src/file_transfer.cpp +++ b/protocols/Yahoo/src/file_transfer.cpp @@ -503,7 +503,7 @@ void CYahooProto::ext_got_file(const char *me, const char *who, const char *url, TCHAR* ptszFileName = mir_a2t(fn);
PROTORECVFILET pre = {0};
- pre.flags = PREF_TCHAR;
+ pre.dwFlags = PRFF_TCHAR;
pre.fileCount = 1;
pre.timestamp = time(NULL);
pre.tszDescription = mir_a2t(msg);
@@ -547,18 +547,13 @@ void CYahooProto::ext_got_files(const char *me, const char *who, const char *ft_ }
- TCHAR* ptszFileName = mir_a2t(fn);
-
PROTORECVFILET pre = {0};
- pre.flags = PREF_TCHAR;
pre.fileCount = 1;
pre.timestamp = time(NULL);
- pre.tszDescription = _T("");
- pre.ptszFiles = &ptszFileName;
+ pre.szDescription = "";
+ pre.pszFiles = (char**)&fn;
pre.lParam = (LPARAM)ft;
ProtoChainRecvFile(ft->hContact, &pre);
-
- mir_free(ptszFileName);
}
void CYahooProto::ext_got_file7info(const char *me, const char *who, const char *url, const char *fname, const char *ft_token)
diff --git a/protocols/Yahoo/src/im.cpp b/protocols/Yahoo/src/im.cpp index 0da62a376a..1301007189 100644 --- a/protocols/Yahoo/src/im.cpp +++ b/protocols/Yahoo/src/im.cpp @@ -105,8 +105,6 @@ void CYahooProto::ext_got_im(const char *me, const char *who, int protocol, cons Set_Protocol(hContact, protocol);
PROTORECVEVENT pre = { 0 };
- pre.flags = (utf8) ? PREF_UTF : 0;
-
if (tm) {
MEVENT hEvent = db_event_last(hContact);
@@ -171,29 +169,21 @@ void __cdecl CYahooProto::im_sendackfail_longmsg(void *hContact) (LPARAM)Translate("Message is too long: Yahoo messages are limited by 800 UTF8 chars"));
}
-int __cdecl CYahooProto::SendMsg(MCONTACT hContact, int flags, const char* pszSrc)
+int __cdecl CYahooProto::SendMsg(MCONTACT hContact, int, const char* pszSrc)
{
if (!m_bLoggedIn) {/* don't send message if we not connected! */
ForkThread(&CYahooProto::im_sendackfail, (void*)hContact);
return 1;
}
- ptrA msg;
- if (flags & PREF_UNICODE) /* convert to utf8 */
- msg = mir_utf8encodeW((wchar_t*)&pszSrc[mir_strlen(pszSrc) + 1]);
- else if (flags & PREF_UTF)
- msg = mir_strdup(pszSrc);
- else
- msg = mir_utf8encode(pszSrc);
-
- if (mir_strlen(msg) > 800) {
+ if (mir_strlen(pszSrc) > 800) {
ForkThread(&CYahooProto::im_sendackfail_longmsg, (void*)hContact);
return 1;
}
DBVARIANT dbv;
if (!getString(hContact, YAHOO_LOGINID, &dbv)) {
- send_msg(dbv.pszVal, getWord(hContact, "yprotoid", 0), msg, 1);
+ send_msg(dbv.pszVal, getWord(hContact, "yprotoid", 0), pszSrc, 1);
ForkThread(&CYahooProto::im_sendacksuccess, (void*)hContact);
diff --git a/protocols/Yahoo/src/proto.cpp b/protocols/Yahoo/src/proto.cpp index af005ccd85..6183eda35d 100644 --- a/protocols/Yahoo/src/proto.cpp +++ b/protocols/Yahoo/src/proto.cpp @@ -308,7 +308,7 @@ DWORD_PTR __cdecl CYahooProto::GetCaps(int type, MCONTACT hContact) case PFLAGNUM_4:
return PF4_FORCEAUTH | PF4_FORCEADDED | PF4_SUPPORTTYPING | PF4_SUPPORTIDLE
- |PF4_AVATARS | PF4_OFFLINEFILES | PF4_IMSENDUTF | PF4_IMSENDOFFLINE /* for Meta plugin*/;
+ |PF4_AVATARS | PF4_OFFLINEFILES | PF4_IMSENDOFFLINE /* for Meta plugin*/;
case PFLAG_UNIQUEIDTEXT:
return (DWORD_PTR) Translate("ID");
case PFLAG_UNIQUEIDSETTING:
diff --git a/protocols/Yahoo/src/yahoo.cpp b/protocols/Yahoo/src/yahoo.cpp index a6690a2010..b0fb7b6aa5 100644 --- a/protocols/Yahoo/src/yahoo.cpp +++ b/protocols/Yahoo/src/yahoo.cpp @@ -782,9 +782,7 @@ void CYahooProto::ext_contact_added(const char *myid, const char *who, const cha //setWord(hContact, "yprotoid", protocol);
Set_Protocol(hContact, protocol);
- pre.flags = PREF_UTF;
- pre.timestamp = time(NULL);
-
+ pre.timestamp = time(NULL);
pre.lParam = sizeof(DWORD)+sizeof(HANDLE)+mir_strlen(who)+mir_strlen(nick)+5;
if (fname != NULL)
|