summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-05-21 16:11:58 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-05-21 16:11:58 +0000
commit48266e479d1fcf5153b29c612866845990fccad8 (patch)
treec8cbc908cd3c5f08731e5e8d7eaac6b568007d09
parentebdb556f152734035846f120eb8112f88ef91281 (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
-rw-r--r--include/m_protosvc.h86
-rw-r--r--plugins/Boltun/src/actionQueue.cpp40
-rw-r--r--plugins/BuddyPounce/src/main.cpp2
-rw-r--r--plugins/CyrTranslit/src/TransliterationProtocol.cpp41
-rw-r--r--plugins/CyrTranslit/src/TransliterationProtocol.h2
-rw-r--r--plugins/Dropbox/src/dropbox_services.cpp20
-rw-r--r--plugins/Dropbox/src/dropbox_transfers.cpp2
-rw-r--r--plugins/MirFox/src/MirandaUtils.cpp71
-rw-r--r--plugins/MirFox/src/MirandaUtils.h6
-rw-r--r--plugins/MirOTR/src/otr.cpp2
-rw-r--r--plugins/MirOTR/src/svcs_proto.cpp152
-rw-r--r--plugins/MirOTR/src/utils.cpp4
-rw-r--r--plugins/MirandaG15/src/CAppletManager.cpp70
-rw-r--r--plugins/MirandaG15/src/CAppletManager.h3
-rw-r--r--plugins/NewAwaySysMod/src/MsgEventAdded.cpp10
-rwxr-xr-xplugins/New_GPG/src/messages.cpp67
-rwxr-xr-xplugins/New_GPG/src/utilities.cpp4
-rw-r--r--plugins/NewsAggregator/Src/CheckFeed.cpp5
-rw-r--r--plugins/Popup/src/popup_wnd2.cpp49
-rw-r--r--plugins/Scriver/src/globals.cpp6
-rw-r--r--plugins/Scriver/src/msgdialog.cpp65
-rw-r--r--plugins/Scriver/src/sendqueue.cpp12
-rw-r--r--plugins/SecureIM/secureim_10.vcxproj2
-rw-r--r--plugins/SecureIM/secureim_10.vcxproj.filters6
-rw-r--r--plugins/SecureIM/secureim_12.vcxproj2
-rw-r--r--plugins/SecureIM/secureim_12.vcxproj.filters6
-rw-r--r--plugins/SecureIM/src/commonheaders.h1
-rw-r--r--plugins/SecureIM/src/crypt_dll.cpp32
-rw-r--r--plugins/SecureIM/src/crypt_lists.cpp10
-rw-r--r--plugins/SecureIM/src/main.cpp3
-rw-r--r--plugins/SecureIM/src/mmi.cpp13
-rw-r--r--plugins/SecureIM/src/rtfconv.cpp40
-rw-r--r--plugins/SecureIM/src/rtfconv.h20
-rw-r--r--plugins/SecureIM/src/svcs_proto.cpp31
-rw-r--r--plugins/SimpleAR/src/Main.cpp2
-rw-r--r--plugins/Spamotron/src/spamotron.cpp135
-rwxr-xr-xplugins/StopSpamMod/src/stopspam.cpp13
-rw-r--r--plugins/StopSpamPlus/src/events.cpp6
-rw-r--r--plugins/TabSRMM/src/functions.h1
-rw-r--r--plugins/TabSRMM/src/msgdialog.cpp37
-rw-r--r--plugins/TabSRMM/src/sendlater.cpp7
-rw-r--r--plugins/TabSRMM/src/sendqueue.cpp156
-rw-r--r--plugins/YARelay/src/main.cpp2
-rw-r--r--protocols/AimOscar/src/proto.cpp26
-rw-r--r--protocols/AimOscar/src/server.cpp5
-rw-r--r--protocols/FacebookRM/src/messages.cpp4
-rw-r--r--protocols/FacebookRM/src/process.cpp1
-rw-r--r--protocols/FacebookRM/src/proto.cpp2
-rw-r--r--protocols/Gadu-Gadu/src/core.cpp3
-rw-r--r--protocols/Gadu-Gadu/src/filetransfer.cpp2
-rw-r--r--protocols/Gadu-Gadu/src/gg_proto.cpp17
-rw-r--r--protocols/Gadu-Gadu/src/image.cpp5
-rw-r--r--protocols/IRCG/src/commandmonitor.cpp5
-rw-r--r--protocols/IRCG/src/ircproto.cpp20
-rw-r--r--protocols/IcqOscarJ/src/fam_04message.cpp34
-rw-r--r--protocols/IcqOscarJ/src/fam_13servclist.cpp18
-rw-r--r--protocols/IcqOscarJ/src/icq_filerequests.cpp2
-rw-r--r--protocols/IcqOscarJ/src/icq_proto.cpp76
-rw-r--r--protocols/IcqOscarJ/src/icq_proto.h4
-rw-r--r--protocols/IcqOscarJ/src/icq_xtraz.cpp2
-rw-r--r--protocols/IcqOscarJ/src/icqosc_svcs.cpp4
-rw-r--r--protocols/IcqOscarJ/src/oscar_filetransfer.cpp10
-rw-r--r--protocols/JabberG/src/jabber_ft.cpp2
-rw-r--r--protocols/JabberG/src/jabber_iq_handlers.cpp2
-rw-r--r--protocols/JabberG/src/jabber_proto.cpp16
-rw-r--r--protocols/JabberG/src/jabber_thread.cpp1
-rw-r--r--protocols/MRA/src/MraFilesQueue.cpp2
-rw-r--r--protocols/MRA/src/MraProto.cpp14
-rw-r--r--protocols/MRA/src/Mra_proto.cpp5
-rw-r--r--protocols/MSN/src/msn_commands.cpp6
-rw-r--r--protocols/MSN/src/msn_mail.cpp1
-rw-r--r--protocols/MSN/src/msn_misc.cpp1
-rw-r--r--protocols/MSN/src/msn_p2p.cpp2
-rw-r--r--protocols/MSN/src/msn_proto.cpp19
-rw-r--r--protocols/Omegle/src/proto.cpp2
-rw-r--r--protocols/Sametime/src/StdAfx.h2
-rw-r--r--protocols/Sametime/src/files.cpp6
-rw-r--r--protocols/Sametime/src/messaging.cpp7
-rw-r--r--protocols/Sametime/src/sametime_proto.cpp28
-rw-r--r--protocols/Sametime/src/sametime_proto.h2
-rw-r--r--protocols/SkypeClassic/src/filexfer.cpp34
-rw-r--r--protocols/SkypeClassic/src/gchat.cpp4
-rw-r--r--protocols/SkypeClassic/src/skype.cpp49
-rw-r--r--protocols/SkypeClassic/src/skypesvc.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_contacts.cpp1
-rw-r--r--protocols/SkypeWeb/src/skype_messages.cpp17
-rw-r--r--protocols/SkypeWeb/src/skype_proto.cpp2
-rw-r--r--protocols/Steam/src/steam_pooling.cpp2
-rw-r--r--protocols/Steam/src/steam_proto.cpp11
-rw-r--r--protocols/Steam/src/steam_proto.h1
-rw-r--r--protocols/Tlen/src/tlen_file.cpp2
-rw-r--r--protocols/Tlen/src/tlen_p2p_new.cpp4
-rw-r--r--protocols/Tlen/src/tlen_svc.cpp18
-rw-r--r--protocols/Tox/src/tox_contacts.cpp1
-rw-r--r--protocols/Tox/src/tox_messages.cpp25
-rw-r--r--protocols/Tox/src/tox_multimedia.cpp3
-rw-r--r--protocols/Tox/src/tox_proto.cpp7
-rw-r--r--protocols/Tox/src/tox_proto.h2
-rw-r--r--protocols/Tox/src/tox_transfer.cpp84
-rw-r--r--protocols/Twitter/src/connection.cpp1
-rw-r--r--protocols/Twitter/src/proto.cpp12
-rw-r--r--protocols/VKontakte/src/vk_feed.cpp8
-rw-r--r--protocols/VKontakte/src/vk_history.cpp5
-rw-r--r--protocols/VKontakte/src/vk_messages.cpp18
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp2
-rw-r--r--protocols/VKontakte/src/vk_proto.h2
-rw-r--r--protocols/WhatsApp/src/messages.cpp3
-rw-r--r--protocols/WhatsApp/src/proto.cpp2
-rw-r--r--protocols/Xfire/src/main.cpp5
-rw-r--r--protocols/Yahoo/src/file_transfer.cpp11
-rw-r--r--protocols/Yahoo/src/im.cpp16
-rw-r--r--protocols/Yahoo/src/proto.cpp2
-rw-r--r--protocols/Yahoo/src/yahoo.cpp4
-rw-r--r--src/core/stdfile/src/file.cpp65
-rw-r--r--src/core/stdmsg/src/cmdlist.cpp2
-rw-r--r--src/core/stdmsg/src/msgdialog.cpp38
-rw-r--r--src/modules/metacontacts/meta_services.cpp2
-rw-r--r--src/modules/protocols/protocols.cpp21
-rw-r--r--src/modules/protocols/protoint.cpp4
119 files changed, 572 insertions, 1522 deletions
diff --git a/include/m_protosvc.h b/include/m_protosvc.h
index e9c8eebef5..82a5291be2 100644
--- a/include/m_protosvc.h
+++ b/include/m_protosvc.h
@@ -140,7 +140,6 @@ static __inline unsigned long Proto_Status2Flag(int status)
#define PF4_SUPPORTIDLE 0x00000010 // protocol understands idle
#define PF4_AVATARS 0x00000020 // protocol has avatar support
#define PF4_OFFLINEFILES 0x00000040 // protocols supports sending files to offline users
-#define PF4_IMSENDUTF 0x00000080 // protocol is able to process messages in utf-8
#define PF4_IMSENDOFFLINE 0x00000100 // protocol supports sending offline messages
#define PF4_INFOSETTINGSVC 0x00000200 // protocol supports user info translation services
#define PF4_NOAUTHDENYREASON 0x00000400 // protocol doesn't support authorization deny reason
@@ -698,29 +697,18 @@ typedef struct {
//DB event: EVENTTYPE_MESSAGE, blob contains szMessage without 0 terminator
//Return 0 - success, other failure
typedef struct {
- DWORD flags;
- DWORD timestamp; //unix time
- union {
- char *szMessage;
- TCHAR *tszMessage;
- };
- LPARAM lParam; //extra space for the network level protocol module
- void *pCustomData;
- DWORD cbCustomDataSize;
+ DWORD flags;
+ DWORD timestamp; // unix time
+ char *szMessage; // message body in utf8
+ LPARAM lParam; // extra space for the network level protocol module
+ void *pCustomData;
+ DWORD cbCustomDataSize;
} PROTORECVEVENT;
#define PREF_CREATEREAD 1 //create the database event with the 'read' flag set
-#define PREF_UNICODE 2
#define PREF_RTL 4 // 0.5+ addition: support for right-to-left messages
-#define PREF_UTF 8 // message is in utf-8 (0.7.0+)
#define PREF_SENT 16 // message will be created with the DBEF_SENT flag
-#if defined(_UNICODE)
- #define PREF_TCHAR PREF_UNICODE
-#else
- #define PREF_TCHAR 0
-#endif
-
/* Proto/RecvMessage
Copies a message from a PROTORECVEVENT event into the database
wParam = 0 (unused)
@@ -751,17 +739,30 @@ __forceinline INT_PTR Proto_AuthRecv(const char *szProtoName, PROTORECVEVENT *pc
{ return CallService(MS_PROTO_AUTHRECV, (WPARAM)szProtoName, (LPARAM)pcre);
}
-//File(s) have been received
-//wParam = 0
-//lParam = (LPARAM)(PROTORECVFILET*)&prf
+// File(s) have been received
+// wParam = 0
+// lParam = (LPARAM)(PROTORECVFILET*)&prf
+
+#define PRFF_UNICODE 1
+#if defined(_UNICODE)
+ #define PRFF_TCHAR PRFF_UNICODE
+#else
+ #define PRFF_TCHAR 0
+#endif
typedef struct {
- DWORD flags;
- DWORD timestamp; //unix time
- TCHAR *tszDescription;
- int fileCount;
- TCHAR **ptszFiles;
- LPARAM lParam; //extra space for the network level protocol module
+ DWORD dwFlags; // PRFF_*
+ DWORD timestamp; // unix time
+ union {
+ char *szDescription; // utf8
+ TCHAR *tszDescription; // TCHAR*, if PRFF_TCHAR is specified
+ };
+ int fileCount;
+ union {
+ char **pszFiles; // utf8
+ TCHAR **ptszFiles; // TCHAR*, if PRFF_TCHAR is specified
+ };
+ LPARAM lParam; // extra space for the network level protocol module
} PROTORECVFILET;
#define PSR_FILE "/RecvFile"
@@ -774,21 +775,20 @@ __forceinline INT_PTR Proto_RecvFile(MCONTACT hContact, PROTORECVFILET *pcre)
return CallService(MS_PROTO_RECVFILET, 0, ( LPARAM )&ccs);
}
-
-//An URL has been received
-//wParam = 0
-//lParam = (LPARAM)(PROTORECVEVENT*)&pre
-//szMessage is encoded the same as for PSS_URL
-//DB event: EVENTTYPE_URL, blob contains szMessage without 0 terminator
+// An URL has been received
+// wParam = 0
+// lParam = (LPARAM)(PROTORECVEVENT*)&pre
+// szMessage is encoded the same as for PSS_URL
+// DB event: EVENTTYPE_URL, blob contains szMessage without 0 terminator
#define PSR_URL "/RecvUrl"
-//Contacts have been received
-//wParam = 0
-//lParam = (LPARAM)(PROTORECVEVENT*)&pre
-//pre.szMessage is actually a (PROTOSEARCHRESULT**) list.
-//pre.lParam is the number of contacts in that list.
-//pre.flags can contain PREF_UTF defining the strings as utf-8 encoded (0.7.0+)
-//PS_ADDTOLIST can be used to add the contacts to the contact list.
+// Contacts have been received
+// wParam = 0
+// lParam = (LPARAM)(PROTORECVEVENT*)&pre
+// pre.szMessage is actually a (PROTOSEARCHRESULT**) list.
+// pre.lParam is the number of contacts in that list.
+// pre.flags can contain PREF_UTF defining the strings as utf-8 encoded (0.7.0+)
+// PS_ADDTOLIST can be used to add the contacts to the contact list.
#define PSR_CONTACTS "/RecvContacts"
/* contacts database event format (EVENTTYPE_CONTACTS)
@@ -806,9 +806,9 @@ zero-terminated, binary data should be converted to text.
Use PS_ADDTOLISTBYEVENT to add the contacts from one of these to the list.
*/
-//An away message reply has been received
-//wParam = statusMode
-//lParam = (LPARAM)(PROTORECVEVENT*)&pre
+// An away message reply has been received
+// wParam = statusMode
+// lParam = (LPARAM)(PROTORECVEVENT*)&pre
#define PSR_AWAYMSG "/RecvAwayMsg"
#ifdef _UNICODE
diff --git a/plugins/Boltun/src/actionQueue.cpp b/plugins/Boltun/src/actionQueue.cpp
index f9d2166001..18554974be 100644
--- a/plugins/Boltun/src/actionQueue.cpp
+++ b/plugins/Boltun/src/actionQueue.cpp
@@ -83,31 +83,21 @@ static bool NotifyTyping(MCONTACT hContact)
static void TimerAnswer(MCONTACT hContact, const TalkBot::MessageInfo* info)
{
- DBEVENTINFO ldbei;
- size_t size = info->Answer.length() + 1;
- size_t bufsize = size;
- char* msg;
-
- bufsize *= sizeof(TCHAR) + 1;
- msg = new char[bufsize];
-
- if (!WideCharToMultiByte(CP_ACP, 0, info->Answer.c_str(), -1, msg, (int)size, NULL, NULL))
- memset(msg, '-', (size - 1)); //In case of fault return "----" in ANSI part
- memcpy(msg + size, info->Answer.c_str(), size * 2);
-
- CallContactService(hContact, PSS_MESSAGE, PREF_TCHAR, (LPARAM)msg);
-
- memset(&ldbei, 0, sizeof(ldbei));
- ldbei.cbSize = sizeof(ldbei);
- //FIXME: Error may happen
- ldbei.cbBlob = (int)bufsize;
- ldbei.pBlob = (PBYTE)(void*)msg;
- ldbei.eventType = EVENTTYPE_MESSAGE;
- ldbei.flags = DBEF_SENT;
- ldbei.szModule = BOLTUN_NAME;
- ldbei.timestamp = (DWORD)time(NULL);
-
- db_event_add(hContact, &ldbei);
+ ptrA msg(mir_utf8encodeT(info->Answer.c_str()));
+ size_t bufsize = mir_strlen(msg);
+
+ CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)msg);
+
+ DBEVENTINFO dbei = { 0 };
+ dbei.cbSize = sizeof(dbei);
+ dbei.cbBlob = (int)bufsize;
+ dbei.pBlob = (PBYTE)(char*)msg;
+ dbei.eventType = EVENTTYPE_MESSAGE;
+ dbei.flags = DBEF_SENT;
+ dbei.szModule = BOLTUN_NAME;
+ dbei.timestamp = (DWORD)time(NULL);
+
+ db_event_add(hContact, &dbei);
bot->AnswerGiven(hContact, *info);
delete info;
diff --git a/plugins/BuddyPounce/src/main.cpp b/plugins/BuddyPounce/src/main.cpp
index 843ee1d2ca..21ede36856 100644
--- a/plugins/BuddyPounce/src/main.cpp
+++ b/plugins/BuddyPounce/src/main.cpp
@@ -146,7 +146,7 @@ int CheckDate(MCONTACT hContact)
void SendPounce(TCHAR *text, MCONTACT hContact)
{
ptrA pszUtf(mir_utf8encodeT(text));
- if (HANDLE hSendId = (HANDLE)CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)pszUtf))
+ if (HANDLE hSendId = (HANDLE)CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)pszUtf))
WindowList_Add(hWindowList, (HWND)hSendId, hContact);
}
diff --git a/plugins/CyrTranslit/src/TransliterationProtocol.cpp b/plugins/CyrTranslit/src/TransliterationProtocol.cpp
index c4d6649f2c..ebb544ffd1 100644
--- a/plugins/CyrTranslit/src/TransliterationProtocol.cpp
+++ b/plugins/CyrTranslit/src/TransliterationProtocol.cpp
@@ -55,40 +55,6 @@ void TransliterationProtocol::TranslateMessageUTF(WPARAM, LPARAM lParam)
strcpy(reinterpret_cast<char*>(ccs->lParam), txtUTF.c_str());
}
-void TransliterationProtocol::TranslateMessageW(WPARAM, LPARAM lParam)
-{
- CCSDATA *ccs = reinterpret_cast<CCSDATA*>(lParam);
-
- std::string txtA = reinterpret_cast<const char*>(ccs->lParam);
- int txtAlen = (int)(sizeof(txtA[0]) * (txtA.length() + 1));
- txtA = TransliterationMap::getInstance().cyrillicToLatin(txtA);
-
- std::wstring txtW = reinterpret_cast<const wchar_t*>(ccs->lParam + txtAlen);
- txtW = TransliterationMap::getInstance().cyrillicToLatin(txtW);
-
- txtAlen = (int)(sizeof(txtA[0]) * (txtA.length() + 1));
- const DWORD newSize = static_cast<DWORD>(txtAlen + (sizeof(txtW[0]) * (txtW.length() + 1)));
-
- ccs->lParam = reinterpret_cast<LPARAM>(mir_alloc(newSize));
-
- strcpy(reinterpret_cast<char*>(ccs->lParam), txtA.c_str());
- wcscpy(reinterpret_cast<wchar_t*>(ccs->lParam + txtAlen), txtW.c_str());
-}
-
-void TransliterationProtocol::TranslateMessageA(WPARAM, LPARAM lParam)
-{
- CCSDATA *ccs = reinterpret_cast<CCSDATA*>(lParam);
-
- std::string txt = reinterpret_cast<const char*>(ccs->lParam);
- txt = TransliterationMap::getInstance().cyrillicToLatin(txt);
-
- const DWORD newSize = static_cast<DWORD>(txt.length() + 1);
-
- ccs->lParam = reinterpret_cast<LPARAM>(mir_alloc(newSize));
-
- strcpy(reinterpret_cast<char*>(ccs->lParam), txt.c_str());
-}
-
//------------------------------------------------------------------------------
INT_PTR TransliterationProtocol::sendMessage(WPARAM wParam, LPARAM lParam)
@@ -100,12 +66,7 @@ INT_PTR TransliterationProtocol::sendMessage(WPARAM wParam, LPARAM lParam)
LPARAM oldlParam = ccs->lParam;
bool msgProcessed = true;
- if (ccs->wParam & PREF_UTF)
- TranslateMessageUTF(wParam, lParam);
- else if (ccs->wParam & PREF_UNICODE)
- TranslateMessageW(wParam, lParam);
- else
- TranslateMessageA(wParam, lParam);
+ TranslateMessageUTF(wParam, lParam);
int ret = CallService(MS_PROTO_CHAINSEND, wParam, lParam);
diff --git a/plugins/CyrTranslit/src/TransliterationProtocol.h b/plugins/CyrTranslit/src/TransliterationProtocol.h
index 08cb715447..cf86d183bc 100644
--- a/plugins/CyrTranslit/src/TransliterationProtocol.h
+++ b/plugins/CyrTranslit/src/TransliterationProtocol.h
@@ -46,8 +46,6 @@ public:
*/
static INT_PTR sendMessage(WPARAM wParam, LPARAM lParam);
- static void TranslateMessageA(WPARAM wParam, LPARAM lParam);
- static void TranslateMessageW(WPARAM wParam, LPARAM lParam);
static void TranslateMessageUTF(WPARAM wParam, LPARAM lParam);
private:
diff --git a/plugins/Dropbox/src/dropbox_services.cpp b/plugins/Dropbox/src/dropbox_services.cpp
index c32ebf1802..66e5c14b98 100644
--- a/plugins/Dropbox/src/dropbox_services.cpp
+++ b/plugins/Dropbox/src/dropbox_services.cpp
@@ -149,28 +149,21 @@ INT_PTR CDropbox::ProtoSendMessage(WPARAM, LPARAM lParam)
return 0;
}
- char *message = NULL;
char *szMessage = (char*)pccsd->lParam;
- if (pccsd->wParam & PREF_UNICODE)
- message = mir_utf8encodeW((wchar_t*)&szMessage[mir_strlen(szMessage) + 1]);
- else if (pccsd->wParam & PREF_UTF)
- message = mir_strdup(szMessage);
- else
- message = mir_utf8encode(szMessage);
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = MODULE;
dbei.timestamp = time(NULL);
dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.cbBlob = (int)mir_strlen(message);
- dbei.pBlob = (PBYTE)message;
+ dbei.cbBlob = (int)mir_strlen(szMessage);
+ dbei.pBlob = (PBYTE)szMessage;
dbei.flags = DBEF_SENT | DBEF_READ | DBEF_UTF;
db_event_add(pccsd->hContact, &dbei);
- if (message[0] && message[0] == '/')
+ if (*szMessage == '/')
{
// parse commands
- char *sep = strchr(message, ' ');
+ char *sep = strchr(szMessage, ' ');
if (sep != NULL) *sep = 0;
struct
@@ -188,7 +181,7 @@ INT_PTR CDropbox::ProtoSendMessage(WPARAM, LPARAM lParam)
for (int i = 0; i < SIZEOF(commands); i++)
{
- if (!strcmp(message + 1, commands[i].szCommand))
+ if (!strcmp(szMessage+1, commands[i].szCommand))
{
ULONG messageId = InterlockedIncrement(&hMessageProcess);
@@ -206,9 +199,8 @@ INT_PTR CDropbox::ProtoSendMessage(WPARAM, LPARAM lParam)
}
char help[1024];
- mir_snprintf(help, SIZEOF(help), Translate("\"%s\" is not valid.\nUse \"/help\" for more info."), message);
+ mir_snprintf(help, SIZEOF(help), Translate("\"%s\" is not valid.\nUse \"/help\" for more info."), szMessage);
CallContactService(GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)help);
-
return 0;
}
diff --git a/plugins/Dropbox/src/dropbox_transfers.cpp b/plugins/Dropbox/src/dropbox_transfers.cpp
index cceb9ea985..40aa523691 100644
--- a/plugins/Dropbox/src/dropbox_transfers.cpp
+++ b/plugins/Dropbox/src/dropbox_transfers.cpp
@@ -228,7 +228,7 @@ UINT CDropbox::SendFilesAndReportAsync(void *owner, void *arg)
char *message = mir_utf8encode(data);
if (ftp->hContact != instance->GetDefaultContact())
{
- if (CallContactService(ftp->hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)message) != ACKRESULT_FAILED)
+ if (CallContactService(ftp->hContact, PSS_MESSAGE, 0, (LPARAM)message) != ACKRESULT_FAILED)
{
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.flags = DBEF_UTF | DBEF_SENT/* | DBEF_READ*/;
diff --git a/plugins/MirFox/src/MirandaUtils.cpp b/plugins/MirFox/src/MirandaUtils.cpp
index 79a897b098..737add6ca9 100644
--- a/plugins/MirFox/src/MirandaUtils.cpp
+++ b/plugins/MirFox/src/MirandaUtils.cpp
@@ -149,25 +149,11 @@ void MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_
return;
}
- int mirandaSendModeFlag = getMirandaSendModeFlag(targetHandleSzProto);
-
- char* msgBuffer = NULL;
- std::size_t bufSize = 0;
-
- if (mirandaSendModeFlag == PREF_UTF){
- msgBuffer = mir_utf8encodeW(args->userActionSelection);
- bufSize = strlen(msgBuffer) + 1;
- } else if (mirandaSendModeFlag == PREF_UNICODE){
- msgBuffer = mir_t2a(args->userActionSelection);
- bufSize = strlen(msgBuffer) + 1;
- size_t bufSizeT = (wcslen(args->userActionSelection) + 1) * sizeof(wchar_t);
- msgBuffer = (char*)mir_realloc(msgBuffer, bufSizeT + bufSize);
- memcpy((wchar_t*)&msgBuffer[bufSize], args->userActionSelection, bufSizeT);
- bufSize += bufSizeT;
- }
+ ptrA msgBuffer(mir_utf8encodeW(args->userActionSelection));
+ std::size_t bufSize = strlen(msgBuffer) + 1;
- logger->log_p(L"SMTC: mirandaSendModeFlag = [%d] bufSize = [%d]", mirandaSendModeFlag, bufSize);
- HANDLE hProcess = sendMessageMiranda((MCONTACT)args->targetHandle, mirandaSendModeFlag, msgBuffer);
+ logger->log_p(L"SMTC: bufSize = [%d]", bufSize);
+ HANDLE hProcess = sendMessageMiranda((MCONTACT)args->targetHandle, msgBuffer);
logger->log_p(L"SMTC: hProcess = [" SCNuPTR L"]", hProcess);
MIRFOXACKDATA* myMfAck = NULL;
@@ -204,40 +190,38 @@ void MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_
if (mirandaContact){
contactNameW = mirandaContact->contactNameW.c_str();
MirandaAccount* mirandaAccount = mirandaContact->mirandaAccountPtr;
- if (mirandaAccount){
+ if (mirandaAccount)
tszAccountName = mirandaAccount->tszAccountName;
- }
}
if(myMfAck != NULL && myMfAck->result == ACKRESULT_SUCCESS){
- addMessageToDB((MCONTACT)args->targetHandle, mirandaSendModeFlag, msgBuffer, bufSize, targetHandleSzProto);
+ addMessageToDB((MCONTACT)args->targetHandle, msgBuffer, bufSize, targetHandleSzProto);
if (mode == MFENUM_SMM_ONLY_SEND){
//show notyfication popup (only in SMM_ONLY_SEND mode)
wchar_t* buffer = new wchar_t[1024 * sizeof(wchar_t)];
- if (contactNameW != NULL && tszAccountName != NULL){
+ if (contactNameW != NULL && tszAccountName != NULL)
mir_sntprintf(buffer, 1024, TranslateT("Message sent to %s (%s)"), contactNameW, tszAccountName);
- } else {
+ else
mir_sntprintf(buffer, 1024, TranslateT("Message sent"));
- }
- if(ServiceExists(MS_POPUP_ADDPOPUPCLASS)) {
+ if(ServiceExists(MS_POPUP_ADDPOPUPCLASS))
ShowClassPopupT("MirFox_Notify", _T("MirFox"), buffer);
- } else {
+ else
PUShowMessageT(buffer, SM_NOTIFY);
- }
delete[] buffer;
- } else if (mode == MFENUM_SMM_SEND_AND_SHOW_MW){
+ }
+ else if (mode == MFENUM_SMM_SEND_AND_SHOW_MW){
//notify hook to open window
if (args->mirfoxDataPtr != NULL && args->mirfoxDataPtr->hhook_EventOpenMW != NULL){
OnHookOpenMvStruct* onHookOpenMv = new(OnHookOpenMvStruct);
onHookOpenMv->targetHandle = args->targetHandle;
onHookOpenMv->msgBuffer = NULL;
NotifyEventHooks(args->mirfoxDataPtr->hhook_EventOpenMW, (WPARAM)onHookOpenMv, 0);
- } else {
- logger->log(L"SMTC: ERROR1 args->mirfoxDataPtr == NULL || args->mirfoxDataPtr->hhook_EventOpenMW == NULL");
}
+ else logger->log(L"SMTC: ERROR1 args->mirfoxDataPtr == NULL || args->mirfoxDataPtr->hhook_EventOpenMW == NULL");
}
- } else {
+ }
+ else {
//error - show error popup
wchar_t* buffer = new wchar_t[1024 * sizeof(wchar_t)];
if (myMfAck != NULL){
@@ -281,9 +265,8 @@ void MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_
EnterCriticalSection(&ackMapCs);
ackMap.erase(hProcess);
LeaveCriticalSection(&ackMapCs);
-
- mir_free(msgBuffer);
- } else if (mode == MFENUM_SMM_ONLY_SHOW_MW){
+ }
+ else if (mode == MFENUM_SMM_ONLY_SHOW_MW) {
//notify hook to open window
if (args->mirfoxDataPtr != NULL && args->mirfoxDataPtr->hhook_EventOpenMW != NULL){
@@ -295,32 +278,22 @@ void MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_
msgBuffer->append(L"\r\n");
onHookOpenMv->msgBuffer = msgBuffer;
NotifyEventHooks(args->mirfoxDataPtr->hhook_EventOpenMW, (WPARAM)onHookOpenMv, 0);
- } else {
- logger->log(L"SMTC: ERROR1 args->mirfoxDataPtr == NULL || args->mirfoxDataPtr->hhook_EventOpenMW == NULL");
}
+ else logger->log(L"SMTC: ERROR1 args->mirfoxDataPtr == NULL || args->mirfoxDataPtr->hhook_EventOpenMW == NULL");
}
}
-int MirandaUtils::getMirandaSendModeFlag(char* targetHandleSzProto)
-{
- if (CallProtoService(targetHandleSzProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDUTF){
- return PREF_UTF;
- } else {
- return PREF_UNICODE;
- }
-}
-
-HANDLE MirandaUtils::sendMessageMiranda(MCONTACT hContact, int mirandaSendModeFlag, char* msgBuffer)
+HANDLE MirandaUtils::sendMessageMiranda(MCONTACT hContact, char *msgBuffer)
{
- return (HANDLE)CallContactService(hContact, PSS_MESSAGE, (WPARAM)mirandaSendModeFlag, (LPARAM)msgBuffer);
+ return (HANDLE)CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)msgBuffer);
}
-void MirandaUtils::addMessageToDB(MCONTACT hContact, int mirandaSendModeFlag, char* msgBuffer, std::size_t bufSize, char* targetHandleSzProto)
+void MirandaUtils::addMessageToDB(MCONTACT hContact, char* msgBuffer, std::size_t bufSize, char* targetHandleSzProto)
{
DBEVENTINFO dbei = {0};
dbei.cbSize = sizeof(dbei);
dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.flags = DBEF_SENT | ((mirandaSendModeFlag&PREF_UTF)==PREF_UTF ? DBEF_UTF : 0);
+ dbei.flags = DBEF_SENT | DBEF_UTF;
dbei.szModule = targetHandleSzProto;
dbei.timestamp = (DWORD)time(NULL);
dbei.cbBlob = (DWORD)bufSize;
diff --git a/plugins/MirFox/src/MirandaUtils.h b/plugins/MirFox/src/MirandaUtils.h
index 08d434a418..f43c7c0f67 100644
--- a/plugins/MirFox/src/MirandaUtils.h
+++ b/plugins/MirFox/src/MirandaUtils.h
@@ -78,11 +78,9 @@ private:
void sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_MODE mode);
- int getMirandaSendModeFlag(char* targetHandleSzProto);
+ HANDLE sendMessageMiranda(MCONTACT hContact, char* msgBuffer);
- HANDLE sendMessageMiranda(MCONTACT hContact, int mirandaSendModeFlag, char* msgBuffer);
-
- void addMessageToDB(MCONTACT hContact, int mirandaSendModeFlag, char* msgBuffer, std::size_t bufSize, char* targetHandleSzProto);
+ void addMessageToDB(MCONTACT hContact, char* msgBuffer, std::size_t bufSize, char* targetHandleSzProto);
void setStatusOnAccount(ActionThreadArgStruct* args);
diff --git a/plugins/MirOTR/src/otr.cpp b/plugins/MirOTR/src/otr.cpp
index 09d912adf8..e8f0bcbe22 100644
--- a/plugins/MirOTR/src/otr.cpp
+++ b/plugins/MirOTR/src/otr.cpp
@@ -133,7 +133,7 @@ extern "C" {
DEBUGOUT_T("OTR_GUI_INJECT_MESSAGE\n");
MCONTACT hContact = (MCONTACT)opdata;
if (db_get_w(hContact, protocol, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF | PREF_BYPASS_OTR, (LPARAM)message);
+ CallContactService(hContact, PSS_MESSAGE, PREF_BYPASS_OTR, (LPARAM)message);
}
/* When the list of ConnContexts changes (including a change in
diff --git a/plugins/MirOTR/src/svcs_proto.cpp b/plugins/MirOTR/src/svcs_proto.cpp
index 1d89651585..22b428145e 100644
--- a/plugins/MirOTR/src/svcs_proto.cpp
+++ b/plugins/MirOTR/src/svcs_proto.cpp
@@ -21,44 +21,26 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){
return 1; // error
const char *oldmessage = (const char *)ccs->lParam;
- char *oldmessage_utf = NULL;
-
- //MessageBox(0, "Send message - converting to UTF-8", "msg", MB_OK);
-
- if(ccs->wParam & PREF_UTF) {
- oldmessage_utf = (char*)oldmessage;
- }
- else if(ccs->wParam & PREF_UNICODE) {
- oldmessage_utf = mir_utf8encodeW((wchar_t*)&oldmessage[strlen(oldmessage)+1]);
- }
- else {
- oldmessage_utf = mir_utf8encode(oldmessage);
- }
- if (!oldmessage_utf) return 1;
+ if (!oldmessage)
+ return 1;
// don't filter OTR messages being sent (OTR messages should only happen *after* the otrl_message_sending call below)
- if(strncmp(oldmessage_utf, "?OTR", 4) == 0) {
+ if(strncmp(oldmessage, "?OTR", 4) == 0) {
DEBUGOUT_T("OTR message without PREF_BYPASS_OTR\n");
- if (!(ccs->wParam & PREF_UTF))
- mir_free(oldmessage_utf);
return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
}
char *tmpencode = NULL;
ConnContext *context = otrl_context_find_miranda(otr_user_state, ccs->hContact);
if (db_get_b(ccs->hContact, MODULENAME, "HTMLConv", 0) && otr_context_get_trust(context) >= TRUST_UNVERIFIED) {
- tmpencode = encode_html_entities_utf8(oldmessage_utf);
- if (tmpencode != NULL) {
- if (!(ccs->wParam & PREF_UTF)) mir_free(oldmessage_utf);
- oldmessage_utf = tmpencode;
- }
+ tmpencode = encode_html_entities_utf8(oldmessage);
+ if (tmpencode != NULL)
+ oldmessage = tmpencode;
}
char *newmessage = NULL;
char *username = contact_get_id(ccs->hContact);
- gcry_error_t err = otrl_message_sending(otr_user_state, &ops, (void*)ccs->hContact, proto, proto, username, OTRL_INSTAG_BEST, oldmessage_utf, NULL, &newmessage, OTRL_FRAGMENT_SEND_ALL_BUT_LAST, NULL, add_appdata, (void*)ccs->hContact);
- if (tmpencode!= NULL || !(ccs->wParam & PREF_UTF))
- mir_free(oldmessage_utf);
+ gcry_error_t err = otrl_message_sending(otr_user_state, &ops, (void*)ccs->hContact, proto, proto, username, OTRL_INSTAG_BEST, oldmessage, NULL, &newmessage, OTRL_FRAGMENT_SEND_ALL_BUT_LAST, NULL, add_appdata, (void*)ccs->hContact);
mir_free(username);
if (err) { /* Be *sure* not to send out plaintext */
@@ -66,35 +48,30 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){
ShowError(TranslateT(LANG_ENCRYPTION_ERROR));
otrl_message_free(newmessage);
return 1;
- } else if (newmessage) {
- if(!newmessage[0]){
- otrl_message_free(newmessage);
- return 1; // skip empty messages (OTR might prevent us sending unencrypted messages by replacing them with empty ones)
- }
- WPARAM oldflags = ccs->wParam;
- if(ccs->wParam & (PREF_UTF|PREF_UNICODE)) {
- ccs->lParam = (LPARAM)newmessage;
- ccs->wParam &= ~PREF_UNICODE;
- ccs->wParam |= PREF_UTF;
- } else {
- mir_utf8decode(newmessage, NULL);
- ccs->lParam = (LPARAM)newmessage;
- }
- INT_PTR ret = CallService(MS_PROTO_CHAINSEND, wParam, lParam);
-
- DEBUGOUTA("OTR - sending raw message: '");
- DEBUGOUTA((const char*)ccs->lParam);
- DEBUGOUTA("'\n");
+ }
+
+ if (newmessage == NULL)
+ return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
+
+ if(!newmessage[0]){
otrl_message_free(newmessage);
-
- // reset to original values
- ccs->lParam = (LPARAM)oldmessage;
- ccs->wParam = oldflags;
- return ret;
+ return 1; // skip empty messages (OTR might prevent us sending unencrypted messages by replacing them with empty ones)
}
- return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
-}
+ WPARAM oldflags = ccs->wParam;
+ ccs->lParam = (LPARAM)newmessage;
+ INT_PTR ret = CallService(MS_PROTO_CHAINSEND, wParam, lParam);
+
+ DEBUGOUTA("OTR - sending raw message: '");
+ DEBUGOUTA((const char*)ccs->lParam);
+ DEBUGOUTA("'\n");
+ otrl_message_free(newmessage);
+
+ // reset to original values
+ ccs->lParam = (LPARAM)oldmessage;
+ ccs->wParam = oldflags;
+ return ret;
+}
INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam)
{
@@ -116,17 +93,9 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam)
return CallService(MS_PROTO_CHAINRECV, wParam, lParam);
char *oldmessage = pre->szMessage;
- char *oldmessage_utf = NULL;
// convert oldmessage to utf-8
- if(pre->flags & PREF_UTF) {
- oldmessage_utf = oldmessage;
- } else if(pre->flags & PREF_UNICODE) {
- oldmessage_utf = mir_utf8encodeW((wchar_t*)(&oldmessage[strlen(oldmessage)+1]));
- } else {
- oldmessage_utf = mir_utf8encode(oldmessage);
- }
- if (!oldmessage_utf) return 1;
-
+ if (!oldmessage)
+ return 1;
ConnContext* context=NULL;
char *uname = contact_get_id(ccs->hContact);
@@ -135,12 +104,9 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam)
lib_cs_lock();
int ignore_msg = otrl_message_receiving(otr_user_state, &ops, (void*)ccs->hContact,
- proto, proto, uname, oldmessage_utf,
+ proto, proto, uname, oldmessage,
&newmessage, &tlvs, &context, add_appdata, (void*)ccs->hContact);
mir_free(uname);
-
- if ( !(pre->flags & PREF_UTF))
- mir_free(oldmessage_utf);
OtrlTLV *tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED);
if (tlv && !Miranda_Terminated()) {
@@ -156,38 +122,36 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam)
if (newmessage)
otrl_message_free(newmessage);
return 1; // discard internal protocol messages
- } else if (newmessage) {
- DWORD oldflags = pre->flags;
- pre->flags &= ~PREF_UNICODE;
- pre->flags |= PREF_UTF; // just use UTF, so we do not have to recode the message
+ }
+ if (newmessage == NULL)
+ return CallService(MS_PROTO_CHAINRECV, wParam, lParam);
+
+ DWORD oldflags = pre->flags;
- typedef void (*msg_free_t)(void*);
- msg_free_t msg_free = (msg_free_t)otrl_message_free;
- if (db_get_b(ccs->hContact, MODULENAME, "HTMLConv", 0)) {
- char* tmp = striphtml(newmessage);
- msg_free(newmessage);
- newmessage = tmp;
- msg_free = mir_free;
- }
- if (options.prefix_messages) {
- size_t len = (strlen(options.prefix)+strlen(newmessage)+1)*sizeof(char);
- char* tmp = (char*)mir_alloc( len );
- strcpy(tmp, options.prefix);
- strcat(tmp, newmessage);
- msg_free(newmessage);
- newmessage = tmp;
- msg_free = mir_free;
- }
- pre->szMessage = newmessage;
- BOOL ret = CallService(MS_PROTO_CHAINRECV, wParam, lParam);
-/// @todo (White-Tiger#1#03/23/15): why are we doing this?
- pre->flags = oldflags;
- pre->szMessage = oldmessage;
+ typedef void (*msg_free_t)(void*);
+ msg_free_t msg_free = (msg_free_t)otrl_message_free;
+ if (db_get_b(ccs->hContact, MODULENAME, "HTMLConv", 0)) {
+ char* tmp = striphtml(newmessage);
msg_free(newmessage);
- return ret;
+ newmessage = tmp;
+ msg_free = mir_free;
}
- return CallService(MS_PROTO_CHAINRECV, wParam, lParam);
-
+ if (options.prefix_messages) {
+ size_t len = (strlen(options.prefix)+strlen(newmessage)+1)*sizeof(char);
+ char* tmp = (char*)mir_alloc( len );
+ strcpy(tmp, options.prefix);
+ strcat(tmp, newmessage);
+ msg_free(newmessage);
+ newmessage = tmp;
+ msg_free = mir_free;
+ }
+ pre->szMessage = newmessage;
+ BOOL ret = CallService(MS_PROTO_CHAINRECV, wParam, lParam);
+/// @todo (White-Tiger#1#03/23/15): why are we doing this?
+ pre->flags = oldflags;
+ pre->szMessage = oldmessage;
+ msg_free(newmessage);
+ return ret;
}
/* Abort the SMP protocol. Used when malformed or unexpected messages
diff --git a/plugins/MirOTR/src/utils.cpp b/plugins/MirOTR/src/utils.cpp
index 2cb11f610f..997abd82e6 100644
--- a/plugins/MirOTR/src/utils.cpp
+++ b/plugins/MirOTR/src/utils.cpp
@@ -321,7 +321,7 @@ void ShowMessageInline(const MCONTACT hContact, const TCHAR *msg) {
pre.timestamp = time(0);
char *utf = mir_utf8encodeT(buff);
pre.szMessage = utf;
- pre.flags = PREF_UTF|PREF_BYPASS_OTR;
+ pre.flags = PREF_BYPASS_OTR;
ProtoChainRecvMsg(hContact, &pre);
mir_free(utf);
@@ -334,7 +334,7 @@ void ShowMessageInlineUtf(const MCONTACT hContact, const char *msg) {
PROTORECVEVENT pre = {0};
pre.timestamp = time(0);
pre.szMessage = buff;
- pre.flags = PREF_UTF|PREF_BYPASS_OTR;
+ pre.flags = PREF_BYPASS_OTR;
ProtoChainRecvMsg(hContact, &pre);
}
diff --git a/plugins/MirandaG15/src/CAppletManager.cpp b/plugins/MirandaG15/src/CAppletManager.cpp
index 4596306b56..7774c21448 100644
--- a/plugins/MirandaG15/src/CAppletManager.cpp
+++ b/plugins/MirandaG15/src/CAppletManager.cpp
@@ -629,27 +629,6 @@ void CAppletManager::HandleEvent(CEvent *pEvent)
}
}
-bool CAppletManager::IsUtfSendAvailable(MCONTACT hContact) {
- char* szProto = GetContactProto(hContact);
- if ( szProto == NULL )
- return FALSE;
-
- return ( CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDUTF ) ? TRUE : FALSE;
-}
-
-//************************************************************************
-// returns the contacts message service name
-//************************************************************************
-char *CAppletManager::GetMessageServiceName(MCONTACT hContact,bool bIsUnicode)
-{
- char *szProto = GetContactProto(hContact);
-
- if(szProto == NULL)
- return NULL;
-
- return PSS_MESSAGE;
-}
-
//************************************************************************
// updates all pending message jobs
//************************************************************************
@@ -710,17 +689,13 @@ void CAppletManager::FinishMessageJob(SMessageJob *pJob)
DBEVENTINFO dbei = { 0 };
dbei.cbSize = sizeof(dbei);
dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.flags = DBEF_SENT;
+ dbei.flags = DBEF_SENT | DBEF_UTF;
dbei.szModule = szProto;
dbei.timestamp = time(NULL);
// Check if protocoll is valid
if(dbei.szModule == NULL)
return;
- if(pJob->dwFlags & PREF_UTF) {
- dbei.flags |= DBEF_UTF;
- }
-
dbei.cbBlob = pJob->iBufferSize;
dbei.pBlob = (PBYTE) pJob->pcBuffer;
@@ -834,43 +809,16 @@ MEVENT CAppletManager::SendMessageToContact(MCONTACT hContact,tstring strMessage
}
else
{
- DWORD pref = 0;
- bool bIsUnicode = false;
- if(CAppletManager::IsUtfSendAvailable(pJob->hContact)) {
- pref = PREF_UTF;
- char* szMsgUtf = NULL;
- szMsgUtf = mir_utf8encodeW( strMessage.c_str());
-
- pJob->iBufferSize = (int)strlen(szMsgUtf)+1;
- pJob->pcBuffer = (char *)malloc(pJob->iBufferSize);
- pJob->dwFlags = PREF_UTF;
-
- memcpy(pJob->pcBuffer,szMsgUtf,pJob->iBufferSize);
- mir_free(szMsgUtf);
- } else {
- bIsUnicode = !IsUnicodeAscii(strMessage.c_str(),mir_tstrlen(strMessage.c_str()));
- if(bIsUnicode) {
- pref = PREF_UNICODE;
- pJob->iBufferSize = bufSize * (sizeof(TCHAR) + 1);
- } else {
- pJob->iBufferSize = bufSize;
- }
- pJob->pcBuffer = (char *)malloc(pJob->iBufferSize);
- memcpy(pJob->pcBuffer,strAscii.c_str(),bufSize);
+ char* szMsgUtf = mir_utf8encodeW(strMessage.c_str());
- if(bIsUnicode) {
- memcpy(&pJob->pcBuffer[bufSize],strMessage.c_str(),bufSize*sizeof(TCHAR));
- }
- }
- char *szService = CAppletManager::GetMessageServiceName(pJob->hContact,bIsUnicode);
+ pJob->iBufferSize = (int)strlen(szMsgUtf)+1;
+ pJob->pcBuffer = (char *)malloc(pJob->iBufferSize);
+ pJob->dwFlags = 0;
- if(szService == NULL)
- {
- free(pJob->pcBuffer);
- pJob->pcBuffer = NULL;
- return NULL;
- }
- pJob->hEvent = (MEVENT)CallContactService(pJob->hContact, szService , pref, (LPARAM)pJob->pcBuffer );
+ memcpy(pJob->pcBuffer,szMsgUtf,pJob->iBufferSize);
+ mir_free(szMsgUtf);
+
+ pJob->hEvent = (MEVENT)CallContactService(pJob->hContact, PSS_MESSAGE, 0, (LPARAM)pJob->pcBuffer );
CAppletManager::GetInstance()->AddMessageJob(pJob);
}
diff --git a/plugins/MirandaG15/src/CAppletManager.h b/plugins/MirandaG15/src/CAppletManager.h
index 5af6058273..2e70f906ba 100644
--- a/plugins/MirandaG15/src/CAppletManager.h
+++ b/plugins/MirandaG15/src/CAppletManager.h
@@ -83,9 +83,6 @@ public:
// sends typing notifications to the specified contact
static void SendTypingNotification(MCONTACT hContact,bool bEnable);
- // returns the contacts message service name
- static char *GetMessageServiceName(MCONTACT hContact,bool bIsUnicode);
- static bool IsUtfSendAvailable(MCONTACT hContact);
// returns a formatted timestamp string
static tstring GetFormattedTimestamp(tm *time);
diff --git a/plugins/NewAwaySysMod/src/MsgEventAdded.cpp b/plugins/NewAwaySysMod/src/MsgEventAdded.cpp
index 61a45f0af6..94b5eb018f 100644
--- a/plugins/NewAwaySysMod/src/MsgEventAdded.cpp
+++ b/plugins/NewAwaySysMod/src/MsgEventAdded.cpp
@@ -58,11 +58,9 @@ void __cdecl AutoreplyDelayThread(void *_ad)
return;
}
- int ReplyLen = (ad->Reply.GetLen() + 1) * (sizeof(char)+sizeof(WCHAR));
- PBYTE pBuf = (PBYTE)_alloca(ReplyLen);
- memcpy(pBuf, _T2A(ad->Reply), ad->Reply.GetLen() + 1);
- memcpy(pBuf + ad->Reply.GetLen() + 1, ad->Reply, (ad->Reply.GetLen() + 1) * sizeof(WCHAR));
- CallContactService(ad->hContact, ServiceExists(CString(szProto) + PSS_MESSAGE "W") ? (PSS_MESSAGE "W") : PSS_MESSAGE, PREF_UNICODE, (LPARAM)pBuf);
+ ptrA pszReply(mir_utf8encodeT(ad->Reply));
+ int ReplyLen = (int)mir_strlen(pszReply);
+ CallContactService(ad->hContact, PSS_MESSAGE, 0, (LPARAM)pszReply);
if (g_AutoreplyOptPage.GetDBValueCopy(IDC_REPLYDLG_LOGREPLY)) { // store in the history
DBEVENTINFO dbeo = { 0 };
@@ -73,7 +71,7 @@ void __cdecl AutoreplyDelayThread(void *_ad)
dbeo.timestamp = time(NULL);
dbeo.cbBlob = ReplyLen;
- dbeo.pBlob = pBuf;
+ dbeo.pBlob = (PBYTE)(char*)pszReply;
SleepEx(1000, true); // delay before sending the reply, as we need it to be later than the message we're replying to (without this delay, srmm puts the messages in a wrong order)
db_event_add(ad->hContact, &dbeo);
diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp
index 27d6258d50..70a4b0c450 100755
--- a/plugins/New_GPG/src/messages.cpp
+++ b/plugins/New_GPG/src/messages.cpp
@@ -150,7 +150,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD flags
HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags));
BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0);
db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0);
- CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message");
+ CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)"Unable to decrypt PGP encrypted message");
HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT));
db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc);
return;
@@ -179,7 +179,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD flags
{
BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0);
db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message");
+ CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)"Unable to decrypt PGP encrypted message");
HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT));
db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc);
break;
@@ -217,7 +217,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD flags
HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags));
BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0);
db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message");
+ CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)"Unable to decrypt PGP encrypted message");
HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT));
db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc);
return;
@@ -236,7 +236,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD flags
HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags));
BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0);
db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message");
+ CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)"Unable to decrypt PGP encrypted message");
HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT));
db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc);
return;
@@ -267,7 +267,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD flags
HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags));
BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0);
db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message");
+ CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)"Unable to decrypt PGP encrypted message");
HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT));
db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc);
mir_free(tmp);
@@ -304,7 +304,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD flags
HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags));
BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0);
db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message");
+ CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)"Unable to decrypt PGP encrypted message");
HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT));
db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc);
mir_free(tmp);
@@ -524,7 +524,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l)
db_set_b(ccs->hContact, szGPGModuleName, "GPGEncryption", 0);
string str = "-----PGP KEY RESPONSE-----";
str.append(tmp);
- CallContactService(ccs->hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)str.c_str());
+ CallContactService(ccs->hContact, PSS_MESSAGE, 0, (LPARAM)str.c_str());
if(enc_state)
db_set_b(ccs->hContact, szGPGModuleName, "GPGEncryption", 1);
}
@@ -540,7 +540,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l)
ICQ_CUSTOMCAP cap = {0};
strncpy(cap.caps, "GPGAutoExchange", sizeof(cap.caps));
if(ProtoCallService(proto, PS_ICQ_CHECKCAPABILITY, (WPARAM)ccs->hContact, (LPARAM)&cap)) {
- CallContactService(ccs->hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)"-----PGP KEY REQUEST-----");
+ CallContactService(ccs->hContact, PSS_MESSAGE, 0, (LPARAM)"-----PGP KEY REQUEST-----");
return 0;
}
}
@@ -586,9 +586,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l)
void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags)
{
bool isansi = false;
- DWORD dbflags = 0;
- if((flags & PREF_UTF) == PREF_UTF)
- dbflags |= DBEF_UTF;
+ DWORD dbflags = DBEF_UTF;
wstring str = toUTF16(msg);
if(bStripTags && bAppendTags)
{
@@ -752,8 +750,6 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags)
if(bDebugLog)
debuglog<<std::string(time_str()+": adding event to contact: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR))+" on send message.");
- if(!(flags & PREF_UTF))
- flags |= PREF_UTF;
fix_line_term(str);
sent_msgs.push_back((HANDLE)CallContactService(hContact, PSS_MESSAGE, flags, (LPARAM)toUTF8(str).c_str()));
}
@@ -765,16 +761,11 @@ INT_PTR SendMsgSvc(WPARAM w, LPARAM l)
return CallService(MS_PROTO_CHAINSEND, w, l);
if(!ccs->lParam)
return CallService(MS_PROTO_CHAINSEND, w, l);
- char *msg = nullptr;
- if((ccs->wParam & PREF_UTF) == PREF_UTF)
- msg = mir_strdup((char*)(ccs->lParam));
- else
- msg = mir_utf8encode((char*)(ccs->lParam));
+ char *msg = (char*)ccs->lParam;
if (!msg)
{
if(bDebugLog)
debuglog<<std::string(time_str()+": info: failed to get message data, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR)));
- mir_free(msg);
return CallService(MS_PROTO_CHAINSEND, w, l);
}
if(strstr(msg,"-----BEGIN PGP MESSAGE-----"))
@@ -791,10 +782,8 @@ INT_PTR SendMsgSvc(WPARAM w, LPARAM l)
{
if(bDebugLog)
debuglog<<std::string(time_str()+": info: contact not secured, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR)));
- mir_free(msg);
return CallService(MS_PROTO_CHAINSEND, w, l);
}
- mir_free(msg);
return returnNoError(ccs->hContact);
}
@@ -850,7 +839,7 @@ int HookSendMsg(WPARAM w, LPARAM l)
if( ProtoCallService(proto, PS_ICQ_CHECKCAPABILITY, hContact, (LPARAM)&cap)) {
if(bDebugLog)
debuglog<<std::string(time_str()+": info(autoexchange, icq): sending key requiest, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR)));
- CallContactService(hContact, PSS_MESSAGE, (dbei->flags & DBEF_UTF) ? PREF_UTF : 0, (LPARAM)"-----PGP KEY REQUEST-----");
+ CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)"-----PGP KEY REQUEST-----");
hcontact_data[hContact].msgs_to_send.push_back((char*)dbei->pBlob);
boost::thread *thr = new boost::thread(boost::bind(send_encrypted_msgs_thread, (void*)hContact));
//TODO: wait for message
@@ -885,7 +874,7 @@ int HookSendMsg(WPARAM w, LPARAM l)
{
if(bDebugLog)
debuglog<<std::string(time_str()+": info(autoexchange, jabber): autoexchange capability found, sending key request, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR)));
- CallContactService(hContact, PSS_MESSAGE, (dbei->flags & DBEF_UTF) ? PREF_UTF : 0, (LPARAM)"-----PGP KEY REQUEST-----");
+ CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)"-----PGP KEY REQUEST-----");
hcontact_data[hContact].msgs_to_send.push_back((char*)dbei->pBlob);
boost::thread *thr = new boost::thread(boost::bind(send_encrypted_msgs_thread, (void*)hContact));
//mir_free((char*)dbei->pBlob);
@@ -905,10 +894,7 @@ int HookSendMsg(WPARAM w, LPARAM l)
}
if(isContactSecured(hContact) && (dbei->flags & DBEF_SENT)) //aggressive outgoing events filtering
{
- DWORD flags = 0;
- if((dbei->flags & DBEF_UTF) == DBEF_UTF)
- flags |= PREF_UTF;
- SendMsgSvc_func(hContact, (char*)dbei->pBlob, flags);
+ SendMsgSvc_func(hContact, (char*)dbei->pBlob, 0);
//TODO: handle errors somehow ...
if(bAppendTags)
{
@@ -921,33 +907,6 @@ int HookSendMsg(WPARAM w, LPARAM l)
}
return 0;
-/* bool stop = false;
- int count = 0; */
-/* while(!stop)
- {
- if(count >= 300)
- stop = true;
- if(!hcontact_data[hContact].msgs_to_pass.empty())
- {
- event_processing_mutex.lock();
- std::list<string>::iterator end = hcontact_data[hContact].msgs_to_pass.end();
- for(std::list<string>::iterator i = hcontact_data[hContact].msgs_to_pass.begin(); i != end; ++i)
- {
- if(!strcmp((*i).c_str(), (char*)dbei->pBlob))
- {
- hcontact_data[hContact].msgs_to_pass.erase(i);
- if(bDebugLog)
- debuglog<<std::string(time_str()+": event message: \""+(char*)dbei->pBlob+"\" passed event filter, contact "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR))+", message is in allowed list");
- event_processing_mutex.unlock();
- return 0;
- }
- }
- event_processing_mutex.unlock();
- }
- boost::this_thread::sleep(boost::posix_time::milliseconds(100));
- count++;
- } */
- //return 1;
}
if(!isContactSecured(hContact))
{
diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp
index 135a4df41f..b4078f24ac 100755
--- a/plugins/New_GPG/src/utilities.cpp
+++ b/plugins/New_GPG/src/utilities.cpp
@@ -178,7 +178,7 @@ INT_PTR SendKey(WPARAM w, LPARAM l)
{
BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0);
db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)szMessage);
+ CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)szMessage);
std::string msg = "Public key ";
char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, key_id_str.c_str(), "");
if(!keyid[0])
@@ -1325,7 +1325,7 @@ void send_encrypted_msgs_thread(void *param)
extern std::list<HANDLE> sent_msgs;
for(list<string>::iterator p = hcontact_data[hContact].msgs_to_send.begin(); p != end; ++p)
{
- sent_msgs.push_back((HANDLE)CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)p->c_str()));
+ sent_msgs.push_back((HANDLE)CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)p->c_str()));
HistoryLog(hContact, db_event((char*)p->c_str(),0,0, DBEF_SENT));
boost::this_thread::sleep(boost::posix_time::seconds(1));
}
diff --git a/plugins/NewsAggregator/Src/CheckFeed.cpp b/plugins/NewsAggregator/Src/CheckFeed.cpp
index 7daad6dc2f..3f2c96b7b5 100644
--- a/plugins/NewsAggregator/Src/CheckFeed.cpp
+++ b/plugins/NewsAggregator/Src/CheckFeed.cpp
@@ -148,10 +148,11 @@ static void XmlToMsg(MCONTACT hContact, CMString &title, CMString &link, CMStrin
if (stamp == 0)
stamp = time(NULL);
+ ptrA pszMessage(mir_utf8encodeT(message));
+
PROTORECVEVENT recv = { 0 };
- recv.flags = PREF_TCHAR;
recv.timestamp = (DWORD)stamp;
- recv.tszMessage = (TCHAR*)message.c_str();
+ recv.szMessage = pszMessage;
ProtoChainRecvMsg(hContact, &recv);
}
}
diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp
index acd1430802..574115edcf 100644
--- a/plugins/Popup/src/popup_wnd2.cpp
+++ b/plugins/Popup/src/popup_wnd2.cpp
@@ -830,32 +830,15 @@ struct ReplyEditData
WNDPROC oldWndProc;
};
-BOOL IsUtfSendAvailable(MCONTACT hContact)
-{
- char* szProto = GetContactProto(hContact);
- if (szProto == NULL) return FALSE;
- // check for MetaContact and get szProto from subcontact
- if (!mir_strcmp(szProto, META_PROTO)) {
- MCONTACT hSubContact = db_mc_getDefault(hContact);
- if (!hSubContact)
- return FALSE;
- szProto = GetContactProto(hSubContact);
- }
- return(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDUTF) ? TRUE : FALSE;
-}
-
-void AddMessageToDB(MCONTACT hContact, char *msg, int flag/*bool utf*/)
+void AddMessageToDB(MCONTACT hContact, char *msg)
{
DBEVENTINFO dbei = { 0 };
dbei.cbSize = sizeof(dbei);
dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.flags = DBEF_SENT | ((flag&PREF_UTF) == PREF_UTF ? DBEF_UTF : 0);
+ dbei.flags = DBEF_SENT | DBEF_UTF;
dbei.szModule = GetContactProto(hContact);
dbei.timestamp = time(NULL);
- if (!((flag & PREF_UTF) == PREF_UTF) && (flag & PREF_UNICODE) == PREF_UNICODE)
- dbei.cbBlob = ((int)mir_tstrlen((LPTSTR)msg) + 1)*sizeof(TCHAR);
- else
- dbei.cbBlob = (int)mir_strlen(msg) + 1;
+ dbei.cbBlob = (int)mir_strlen(msg) + 1;
dbei.pBlob = (PBYTE)msg;
db_event_add(hContact, &dbei);
}
@@ -869,33 +852,19 @@ LRESULT CALLBACK ReplyEditWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
case WM_KEYDOWN:
switch (wParam) {
case VK_RETURN:
- {
- char *buf = NULL;
- int flag = 0;
TCHAR msg[2048];
-
GetWindowText(hwnd, msg, SIZEOF(msg));
-
if (wcslen(msg) == 0) {
DestroyWindow(hwnd);
return 0;
}
- // we have unicode message, check if it is possible and reasonable to send it as unicode
- if (IsUtfSendAvailable(dat->hContact)) {
- buf = mir_utf8encodeT(msg);
- flag = PREF_UTF;
- }
- else {
- buf = mir_t2a(msg);
- flag = 0;
- }
- CallContactService(dat->hContact, PSS_MESSAGE, flag, (LPARAM)buf);
- AddMessageToDB(dat->hContact, buf, flag);
- mir_free(buf);
- }
- DestroyWindow(hwnd);
- return 0;
+ {
+ ptrA buf(mir_utf8encodeT(msg));
+ CallContactService(dat->hContact, PSS_MESSAGE, 0, (LPARAM)buf);
+ AddMessageToDB(dat->hContact, buf);
+ }
+ // fall through
case VK_ESCAPE:
DestroyWindow(hwnd);
diff --git a/plugins/Scriver/src/globals.cpp b/plugins/Scriver/src/globals.cpp
index 8bf0853259..db0ba35a56 100644
--- a/plugins/Scriver/src/globals.cpp
+++ b/plugins/Scriver/src/globals.cpp
@@ -145,14 +145,10 @@ static int ackevent(WPARAM, LPARAM lParam)
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.flags = DBEF_SENT | ((item->flags & PREF_RTL) ? DBEF_RTL : 0);
- if (item->flags & PREF_UTF)
- dbei.flags |= DBEF_UTF;
+ dbei.flags = DBEF_UTF | DBEF_SENT | ((item->flags & PREF_RTL) ? DBEF_RTL : 0);
dbei.szModule = GetContactProto(hContact);
dbei.timestamp = time(NULL);
dbei.cbBlob = (int)mir_strlen(item->sendBuffer) + 1;
- if (!(item->flags & PREF_UTF))
- dbei.cbBlob *= sizeof(TCHAR) + 1;
dbei.pBlob = (PBYTE)item->sendBuffer;
MessageWindowEvent evt = { sizeof(evt), (int)item->hSendId, hContact, &dbei };
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp
index acb56dad6c..586f449cea 100644
--- a/plugins/Scriver/src/msgdialog.cpp
+++ b/plugins/Scriver/src/msgdialog.cpp
@@ -149,15 +149,6 @@ void NotifyLocalWinEvent(MCONTACT hContact, HWND hwnd, unsigned int type)
NotifyEventHooks(hHookWinEvt, 0, (LPARAM)&mwe);
}
-static BOOL IsUtfSendAvailable(MCONTACT hContact)
-{
- char *szProto = GetContactProto(hContact);
- if (szProto == NULL)
- return FALSE;
-
- return (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDUTF) ? TRUE : FALSE;
-}
-
int RTL_Detect(WCHAR *pszwText)
{
size_t iLen = mir_wstrlen(pszwText);
@@ -1188,7 +1179,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
pf2.cbSize = sizeof(pf2);
pf2.dwMask = PFM_RTLPARA;
dat->flags ^= SMF_RTL;
- if (dat->flags&SMF_RTL) {
+ if (dat->flags & SMF_RTL) {
pf2.wEffects = PFE_RTLPARA;
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWL_EXSTYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWL_EXSTYLE) | WS_EX_RIGHT | WS_EX_RTLREADING | WS_EX_LEFTSCROLLBAR);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG), GWL_EXSTYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG), GWL_EXSTYLE) | WS_EX_LEFTSCROLLBAR);
@@ -1480,31 +1471,15 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
case DM_SENDMESSAGE:
if (lParam) {
MessageSendQueueItem *msi = (MessageSendQueueItem *)lParam;
+ SendMessage(hwndDlg, DM_STARTMESSAGESENDING, 0, 0);
+
MessageSendQueueItem *item = CreateSendQueueItem(hwndDlg);
item->hContact = dat->hContact;
item->proto = mir_strdup(dat->szProto);
item->flags = msi->flags;
item->codepage = dat->codePage;
- if (IsUtfSendAvailable(dat->hContact)) {
- char *szMsgUtf = mir_utf8encodeW((TCHAR*)&msi->sendBuffer[strlen(msi->sendBuffer) + 1]);
- item->flags &= ~PREF_UNICODE;
- if (!szMsgUtf)
- break;
-
- if (*szMsgUtf == 0) {
- mir_free(szMsgUtf);
- break;
- }
- item->sendBufferSize = (int)strlen(szMsgUtf) + 1;
- item->sendBuffer = szMsgUtf;
- item->flags |= PREF_UTF;
- }
- else {
- item->sendBufferSize = msi->sendBufferSize;
- item->sendBuffer = (char*)mir_alloc(msi->sendBufferSize);
- memcpy(item->sendBuffer, msi->sendBuffer, msi->sendBufferSize);
- }
- SendMessage(hwndDlg, DM_STARTMESSAGESENDING, 0, 0);
+ item->sendBufferSize = msi->sendBufferSize;
+ item->sendBuffer = mir_strndup(msi->sendBuffer, msi->sendBufferSize);
SendSendQueueItem(item);
}
break;
@@ -1627,48 +1602,40 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
break;
if (dat->hContact != NULL) {
- int ansiBufSize = GetRichTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE), dat->codePage, TRUE) + 1;
- int bufSize = ansiBufSize + GetRichTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE), 1200, TRUE) + 2;
-
memset(&pf2, 0, sizeof(pf2));
pf2.cbSize = sizeof(pf2);
pf2.dwMask = PFM_RTLPARA;
SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETPARAFORMAT, 0, (LPARAM)&pf2);
- ptrA szSendBuffer((char*)mir_alloc(bufSize));
+ int bufSize = GetRichTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE), 1200, TRUE) + 2;
+ ptrT ptszUnicode((TCHAR*)mir_alloc(bufSize * sizeof(TCHAR)));
MessageSendQueueItem msi = { 0 };
- msi.flags = PREF_TCHAR;
if (pf2.wEffects & PFE_RTLPARA)
msi.flags |= PREF_RTL;
- msi.sendBufferSize = bufSize;
- msi.sendBuffer = szSendBuffer;
GETTEXTEX gt = { 0 };
gt.flags = GT_USECRLF;
- gt.cb = ansiBufSize;
- gt.codepage = dat->codePage;
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETTEXTEX, (WPARAM)&gt, (LPARAM)msi.sendBuffer);
- gt.cb = bufSize - ansiBufSize;
+ gt.cb = bufSize;
gt.codepage = 1200;
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETTEXTEX, (WPARAM)&gt, (LPARAM)&msi.sendBuffer[ansiBufSize]);
- if (RTL_Detect((wchar_t*)&msi.sendBuffer[ansiBufSize]))
+ SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETTEXTEX, (WPARAM)&gt, ptszUnicode);
+ if (RTL_Detect(ptszUnicode))
msi.flags |= PREF_RTL;
- if (msi.sendBuffer[0] == 0)
+ msi.sendBuffer = mir_utf8encodeT(ptszUnicode);
+ msi.sendBufferSize = (int)mir_strlen(msi.sendBuffer);
+ if (msi.sendBufferSize == 0)
break;
/* Store messaging history */
- char *msgText = GetRichTextEncoded(GetDlgItem(hwndDlg, IDC_MESSAGE), dat->codePage);
TCmdList *cmdListNew = tcmdlist_last(dat->cmdList);
while (cmdListNew != NULL && cmdListNew->temporary) {
dat->cmdList = tcmdlist_remove(dat->cmdList, cmdListNew);
cmdListNew = tcmdlist_last(dat->cmdList);
}
- if (msgText != NULL) {
- dat->cmdList = tcmdlist_append(dat->cmdList, rtrim(msgText), 20, FALSE);
- mir_free(msgText);
- }
+ if (msi.sendBuffer != NULL)
+ dat->cmdList = tcmdlist_append(dat->cmdList, rtrim(msi.sendBuffer), 20, FALSE);
+
dat->cmdListCurrent = NULL;
if (dat->nTypeMode == PROTOTYPE_SELFTYPING_ON)
diff --git a/plugins/Scriver/src/sendqueue.cpp b/plugins/Scriver/src/sendqueue.cpp
index 51c6dbb972..49bc01553e 100644
--- a/plugins/Scriver/src/sendqueue.cpp
+++ b/plugins/Scriver/src/sendqueue.cpp
@@ -28,17 +28,7 @@ static mir_cs queueMutex;
TCHAR* GetSendBufferMsg(MessageSendQueueItem *item)
{
- TCHAR *szMsg = NULL;
- size_t len = strlen(item->sendBuffer);
-
- if (item->flags & PREF_UTF)
- szMsg = mir_utf8decodeW(item->sendBuffer);
- else {
- szMsg = (TCHAR*)mir_alloc(item->sendBufferSize - len - 1);
- memcpy(szMsg, item->sendBuffer + len + 1, item->sendBufferSize - len - 1);
- }
-
- return szMsg;
+ return mir_utf8decodeW(item->sendBuffer);
}
MessageSendQueueItem* CreateSendQueueItem(HWND hwndSender)
diff --git a/plugins/SecureIM/secureim_10.vcxproj b/plugins/SecureIM/secureim_10.vcxproj
index 156bf385bd..12bf242797 100644
--- a/plugins/SecureIM/secureim_10.vcxproj
+++ b/plugins/SecureIM/secureim_10.vcxproj
@@ -200,7 +200,6 @@
<ClInclude Include="src\options.h" />
<ClInclude Include="src\popupOptions.h" />
<ClInclude Include="src\resource.h" />
- <ClInclude Include="src\rtfconv.h" />
<ClInclude Include="src\secureim.h" />
<ClInclude Include="src\splitmsg.h" />
<ClInclude Include="src\svcs_clist.h" />
@@ -230,7 +229,6 @@
<ClCompile Include="src\mmi.cpp" />
<ClCompile Include="src\options.cpp" />
<ClCompile Include="src\popupOptions.cpp" />
- <ClCompile Include="src\rtfconv.cpp" />
<ClCompile Include="src\splitmsg.cpp" />
<ClCompile Include="src\commonheaders.cpp" />
<ClCompile Include="src\svcs_clist.cpp" />
diff --git a/plugins/SecureIM/secureim_10.vcxproj.filters b/plugins/SecureIM/secureim_10.vcxproj.filters
index ececb6efdf..51fcf274df 100644
--- a/plugins/SecureIM/secureim_10.vcxproj.filters
+++ b/plugins/SecureIM/secureim_10.vcxproj.filters
@@ -72,9 +72,6 @@
<ClCompile Include="src\popupOptions.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\rtfconv.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\splitmsg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -137,9 +134,6 @@
<ClInclude Include="src\resource.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\rtfconv.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="src\secureim.h">
<Filter>Header Files</Filter>
</ClInclude>
diff --git a/plugins/SecureIM/secureim_12.vcxproj b/plugins/SecureIM/secureim_12.vcxproj
index e158f71170..f1a8922d1f 100644
--- a/plugins/SecureIM/secureim_12.vcxproj
+++ b/plugins/SecureIM/secureim_12.vcxproj
@@ -203,7 +203,6 @@
<ClInclude Include="src\options.h" />
<ClInclude Include="src\popupOptions.h" />
<ClInclude Include="src\resource.h" />
- <ClInclude Include="src\rtfconv.h" />
<ClInclude Include="src\secureim.h" />
<ClInclude Include="src\splitmsg.h" />
<ClInclude Include="src\svcs_clist.h" />
@@ -233,7 +232,6 @@
<ClCompile Include="src\mmi.cpp" />
<ClCompile Include="src\options.cpp" />
<ClCompile Include="src\popupOptions.cpp" />
- <ClCompile Include="src\rtfconv.cpp" />
<ClCompile Include="src\splitmsg.cpp" />
<ClCompile Include="src\commonheaders.cpp" />
<ClCompile Include="src\svcs_clist.cpp" />
diff --git a/plugins/SecureIM/secureim_12.vcxproj.filters b/plugins/SecureIM/secureim_12.vcxproj.filters
index ececb6efdf..51fcf274df 100644
--- a/plugins/SecureIM/secureim_12.vcxproj.filters
+++ b/plugins/SecureIM/secureim_12.vcxproj.filters
@@ -72,9 +72,6 @@
<ClCompile Include="src\popupOptions.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\rtfconv.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\splitmsg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -137,9 +134,6 @@
<ClInclude Include="src\resource.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\rtfconv.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="src\secureim.h">
<Filter>Header Files</Filter>
</ClInclude>
diff --git a/plugins/SecureIM/src/commonheaders.h b/plugins/SecureIM/src/commonheaders.h
index 9d3262643f..f416e46339 100644
--- a/plugins/SecureIM/src/commonheaders.h
+++ b/plugins/SecureIM/src/commonheaders.h
@@ -48,7 +48,6 @@
#include "options.h"
#include "popupoptions.h"
#include "loadicons.h"
-#include "rtfconv.h"
#include "cryptopp.h"
#include "loadlib.h"
#include "images.h"
diff --git a/plugins/SecureIM/src/crypt_dll.cpp b/plugins/SecureIM/src/crypt_dll.cpp
index d7c57ea17a..a40b6c4974 100644
--- a/plugins/SecureIM/src/crypt_dll.cpp
+++ b/plugins/SecureIM/src/crypt_dll.cpp
@@ -121,18 +121,7 @@ LPSTR encrypt(pUinKey ptr, LPCSTR szEncMsg)
LPSTR encodeMsg(pUinKey ptr, LPARAM lParam)
{
CCSDATA *pccsd = (CCSDATA *)lParam;
- LPSTR szNewMsg = NULL;
- LPSTR szOldMsg = (LPSTR)pccsd->lParam;
-
- if (pccsd->wParam & PREF_UTF)
- szNewMsg = encrypt(ptr, cpp_encodeU(ptr->cntx, szOldMsg));
- else if (pccsd->wParam & PREF_UNICODE)
- szNewMsg = encrypt(ptr, cpp_encodeW(ptr->cntx, (LPWSTR)(szOldMsg + strlen(szOldMsg) + 1)));
- else
- szNewMsg = encrypt(ptr, cpp_encodeA(ptr->cntx, szOldMsg));
-
- pccsd->wParam &= ~PREF_UNICODE;
- return szNewMsg;
+ return encrypt(ptr, cpp_encodeU(ptr->cntx, (LPSTR)pccsd->lParam));
}
@@ -143,7 +132,7 @@ LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg)
PROTORECVEVENT *ppre = (PROTORECVEVENT *)pccsd->lParam;
LPSTR szNewMsg = NULL;
- LPSTR szOldMsg = (ppre->flags&PREF_UTF) ? cpp_decodeU(ptr->cntx, szEncMsg) : cpp_decode(ptr->cntx, szEncMsg);
+ LPSTR szOldMsg = cpp_decodeU(ptr->cntx, szEncMsg);
if (szOldMsg == NULL) {
ptr->decoded = false;
@@ -159,23 +148,12 @@ LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg)
szNewMsg = mir_strdup(Translate(sim101));
break;
}
- ppre->flags &= ~(PREF_UNICODE | PREF_UTF);
- pccsd->wParam &= ~(PREF_UNICODE | PREF_UTF);
}
else {
ptr->decoded = true;
- if (ppre->flags & PREF_UTF) {
- int olen = (int)strlen(szOldMsg) + 1;
- szNewMsg = (LPSTR)mir_alloc(olen);
- memcpy(szNewMsg, szOldMsg, olen);
- }
- else {
- int olen = ((int)strlen(szOldMsg) + 1)*(sizeof(WCHAR) + 1);
- szNewMsg = (LPSTR)mir_alloc(olen);
- memcpy(szNewMsg, szOldMsg, olen);
- ppre->flags |= PREF_UNICODE;
- pccsd->wParam |= PREF_UNICODE;
- }
+ int olen = (int)strlen(szOldMsg) + 1;
+ szNewMsg = (LPSTR)mir_alloc(olen);
+ memcpy(szNewMsg, szOldMsg, olen);
}
ppre->szMessage = szNewMsg;
return szNewMsg;
diff --git a/plugins/SecureIM/src/crypt_lists.cpp b/plugins/SecureIM/src/crypt_lists.cpp
index 73812cad0a..9137f9b592 100644
--- a/plugins/SecureIM/src/crypt_lists.cpp
+++ b/plugins/SecureIM/src/crypt_lists.cpp
@@ -186,15 +186,7 @@ void addMsg2Queue(pUinKey ptr, WPARAM wParam, LPSTR szMsg)
ptrMessage->wParam = wParam;
ptrMessage->nextMessage = NULL;
-
- if (wParam & PREF_UNICODE) {
- int slen = (int)strlen(szMsg) + 1;
- int wlen = (int)wcslen((wchar_t *)(szMsg + slen)) + 1;
- ptrMessage->Message = (LPSTR)mir_alloc(slen + wlen*sizeof(WCHAR));
- memcpy(ptrMessage->Message, szMsg, slen + wlen*sizeof(WCHAR));
- }
- else ptrMessage->Message = mir_strdup(szMsg);
-
+ ptrMessage->Message = mir_strdup(szMsg);
}
void getContactNameA(MCONTACT hContact, LPSTR szName)
diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp
index 773dcccd0e..470ffa12de 100644
--- a/plugins/SecureIM/src/main.cpp
+++ b/plugins/SecureIM/src/main.cpp
@@ -294,7 +294,6 @@ static int onShutdown(WPARAM, LPARAM)
DestroyHookableEvent(g_hEvent[1]);
freeContactList();
- free_rtfconv();
DeinitNetlib();
return 0;
@@ -344,8 +343,6 @@ extern "C" __declspec(dllexport) int __cdecl Load(void)
return 1;
}
- load_rtfconv();
-
// register plugin module
PROTOCOLDESCRIPTOR pd = { sizeof(pd) };
pd.szName = (char*)MODULENAME;
diff --git a/plugins/SecureIM/src/mmi.cpp b/plugins/SecureIM/src/mmi.cpp
index 45361fd5ad..e75a076472 100644
--- a/plugins/SecureIM/src/mmi.cpp
+++ b/plugins/SecureIM/src/mmi.cpp
@@ -105,22 +105,11 @@ void __fastcall safe_delete(void** p)
// ïðåîáðàçóåì òåêñò èç ÷èñòîãî UTF8 â ôîðìàò ìèðàíäû
LPSTR utf8_to_miranda(LPCSTR szUtfMsg, DWORD& flags)
{
- flags &= ~PREF_UNICODE; flags |= PREF_UTF;
return mir_strdup(szUtfMsg);
}
// ïðåîáðàçóåì òåêñò èç ôîðìàòà ìèðàíäû â ÷èñòûé UTF8
LPSTR miranda_to_utf8(LPCSTR szMirMsg, DWORD flags)
{
- LPSTR szNewMsg;
- if (flags & PREF_UTF)
- szNewMsg = (LPSTR)szMirMsg;
- else if (flags & PREF_UNICODE)
- szNewMsg = exp->utf8encode((LPCWSTR)(szMirMsg + strlen(szMirMsg) + 1));
- else {
- LPWSTR wszMirMsg = mir_a2u(szMirMsg);
- szNewMsg = exp->utf8encode(wszMirMsg);
- mir_free(wszMirMsg);
- }
- return mir_strdup(szNewMsg);
+ return mir_strdup(szMirMsg);
}
diff --git a/plugins/SecureIM/src/rtfconv.cpp b/plugins/SecureIM/src/rtfconv.cpp
deleted file mode 100644
index d76b316b22..0000000000
--- a/plugins/SecureIM/src/rtfconv.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-#include "commonheaders.h"
-
-HINSTANCE hRtfconv = NULL;
-RTFCONVSTRING pRtfconvString = NULL;
-
-BOOL load_rtfconv()
-{
- hRtfconv = LoadLibrary(_T("rtfconv.dll"));
- if (hRtfconv == NULL) {
- hRtfconv = LoadLibrary(_T("plugins\\rtfconv.dll"));
- if (hRtfconv == NULL)
- return FALSE;
- }
-
- pRtfconvString = (RTFCONVSTRING)GetProcAddress(hRtfconv, "RtfconvString");
- if (pRtfconvString == NULL) {
- FreeLibrary(hRtfconv);
- return FALSE;
- }
-
- return TRUE;
-}
-
-void free_rtfconv()
-{
- if (hRtfconv)
- FreeLibrary(hRtfconv);
- pRtfconvString = NULL;
- hRtfconv = NULL;
-}
-
-void rtfconvA(LPCSTR rtf, LPWSTR plain)
-{
- pRtfconvString(rtf, plain, 0, 1200, CONVMODE_USE_SYSTEM_TABLE, (strlen(rtf) + 1)*sizeof(WCHAR));
-}
-
-void rtfconvW(LPCWSTR rtf, LPWSTR plain)
-{
- pRtfconvString(rtf, plain, 0, 1200, CONVMODE_USE_SYSTEM_TABLE, (wcslen(rtf) + 1)*sizeof(WCHAR));
-}
diff --git a/plugins/SecureIM/src/rtfconv.h b/plugins/SecureIM/src/rtfconv.h
deleted file mode 100644
index eed541a85e..0000000000
--- a/plugins/SecureIM/src/rtfconv.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __RTFCONV_H__
-#define __RTFCONV_H__
-
-#ifndef _INTPTR_T_DEFINED
-#define intptr_t int
-#endif
-
-#define CONVMODE_USE_SYSTEM_TABLE 0x800000 /* Use OS's table only */
-
-typedef intptr_t (WINAPI *RTFCONVSTRING)(const void *pSrcBuffer, void *pDstBuffer,
- int nSrcCodePage, int nDstCodePage, unsigned long dwFlags, size_t nMaxLen);
-
-extern RTFCONVSTRING pRtfconvString;
-
-BOOL load_rtfconv ();
-void free_rtfconv ();
-void rtfconvA(LPCSTR rtf, LPWSTR plain);
-void rtfconvW(LPCWSTR rtf, LPWSTR plain);
-
-#endif
diff --git a/plugins/SecureIM/src/svcs_proto.cpp b/plugins/SecureIM/src/svcs_proto.cpp
index 0ebc1de9ed..fb39f770d2 100644
--- a/plugins/SecureIM/src/svcs_proto.cpp
+++ b/plugins/SecureIM/src/svcs_proto.cpp
@@ -55,32 +55,6 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam)
Sent_NetLog("onRecvMsg: %s", szEncMsg);
- // cut rtf tags
- if (pRtfconvString && memcmp(szEncMsg, "{\\rtf1", 6) == 0) {
- SAFE_FREE(szUnrtfMsg);
- int len = (int)strlen(szEncMsg) + 1;
- LPWSTR szTemp = (LPWSTR)mir_alloc(len*sizeof(WCHAR));
- if (ppre->flags & PREF_UNICODE)
- rtfconvW((LPWSTR)(szEncMsg + len), szTemp);
- else
- rtfconvA(szEncMsg, szTemp);
- len = (int)wcslen(szTemp) - 1;
- while (len) {
- if (szTemp[len] == 0x0D || szTemp[len] == 0x0A)
- szTemp[len] = 0;
- else
- break;
- len--;
- }
- len = (int)wcslen(&szTemp[1]) + 1;
- szUnrtfMsg = (LPSTR)mir_alloc(len*(sizeof(WCHAR) + 1));
- WideCharToMultiByte(CP_ACP, 0, &szTemp[1], -1, szUnrtfMsg, len*(sizeof(WCHAR) + 1), NULL, NULL);
- memcpy(szUnrtfMsg + len, &szTemp[1], len*sizeof(WCHAR));
- ppre->szMessage = szEncMsg = szUnrtfMsg;
- ppre->flags |= PREF_UNICODE;
- mir_free(szTemp);
- }
-
int ssig = getSecureSig(ppre->szMessage, &szEncMsg);
bool bSecured = (isContactSecured(pccsd->hContact)&SECURED) != 0;
bool bPGP = isContactPGP(pccsd->hContact);
@@ -104,7 +78,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam)
if (ssig == SiG_NONE && !ptr->msgSplitted) {
Sent_NetLog("onRecvMsg: non-secure message");
- ptrA szPlainMsg((ppre->flags & PREF_UNICODE) ? m_awstrcat(Translate(sim402), szEncMsg) : m_aastrcat(Translate(sim402), szEncMsg));
+ ptrA szPlainMsg(m_aastrcat(Translate(sim402), szEncMsg));
ppre->szMessage = szPlainMsg;
pccsd->wParam |= PREF_SIMNOMETA;
return CallService(MS_PROTO_CHAINRECV, wParam, lParam);
@@ -178,8 +152,6 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam)
if (!szOldMsg) { // error while decrypting message, send error
SAFE_FREE(ptr->msgSplitted);
- ppre->flags &= ~(PREF_UNICODE | PREF_UTF);
- pccsd->wParam &= ~(PREF_UNICODE | PREF_UTF);
ppre->szMessage = Translate(sim401);
return CallService(MS_PROTO_CHAINRECV, wParam, lParam);
}
@@ -761,7 +733,6 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam)
ptrA keyToSend(InitKeyA(ptr, 0)); // calculate public and private key & fill KeyA
Sent_NetLog("Sending KEY3: %s", keyToSend);
- pccsd->wParam &= ~PREF_UNICODE;
pccsd->wParam |= PREF_METANODB;
pccsd->lParam = (LPARAM)keyToSend;
pccsd->szProtoService = PSS_MESSAGE;
diff --git a/plugins/SimpleAR/src/Main.cpp b/plugins/SimpleAR/src/Main.cpp
index b7e8cd0b6d..aa1e5bdfb9 100644
--- a/plugins/SimpleAR/src/Main.cpp
+++ b/plugins/SimpleAR/src/Main.cpp
@@ -230,7 +230,7 @@ INT addEvent(WPARAM hContact, LPARAM hDBEvent)
}else
ptszTemp = Utils_ReplaceVarsT(ptszTemp2);
char* pszUtf = mir_utf8encodeT(ptszTemp);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)pszUtf);
+ CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)pszUtf);
dbei.cbSize = sizeof(dbei);
dbei.eventType = EVENTTYPE_MESSAGE;
diff --git a/plugins/Spamotron/src/spamotron.cpp b/plugins/Spamotron/src/spamotron.cpp
index dc7fe34e84..4ce453a710 100644
--- a/plugins/Spamotron/src/spamotron.cpp
+++ b/plugins/Spamotron/src/spamotron.cpp
@@ -56,7 +56,6 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam)
POPUPDATAT ppdp = {0};
DBTIMETOSTRING tts = {0};
char protoOption[256] = {0};
- char *response, *tmp, *challenge;
int buflen = MAX_BUFFER_LENGTH;
TCHAR buf[MAX_BUFFER_LENGTH];
TCHAR *message = NULL, *challengeW = NULL, *tmpW = NULL;
@@ -174,11 +173,8 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam)
db_unset(hContact, "CList", "NotOnList");
db_unset(hContact, "CList", "Delete");
if (_getOptB("ReplyOnSuccess", defaultReplyOnSuccess) && (_getCOptB(hContact, "MsgSent", 0))) {
- tmp = mir_u2a(_getOptS(buf, buflen, "SuccessResponse", defaultSuccessResponse));
- response = mir_utf8encode(tmp);
- mir_free(tmp);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)response);
- mir_free(response);
+ ptrA response(mir_utf8encodeT(_getOptS(buf, buflen, "SuccessResponse", defaultSuccessResponse)));
+ CallContactService(hContact, PSS_MESSAGE, 0, response);
}
return 0;
}
@@ -243,11 +239,8 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam)
db_unset(hContact, "CList", "Delete");
db_unset(hContact, "CList", "ResponseNum");
if (_getOptB("ReplyOnSuccess", defaultReplyOnSuccess)) {
- tmp = mir_u2a(_getOptS(buf, buflen, "SuccessResponse", defaultSuccessResponse));
- response = mir_utf8encode(tmp);
- mir_free(tmp);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)response);
- mir_free(response);
+ ptrA response(mir_utf8encodeT(_getOptS(buf, buflen, "SuccessResponse", defaultSuccessResponse)));
+ CallContactService(hContact, PSS_MESSAGE, 0, response);
}
_notify(hContact, POPUP_APPROVED, TranslateT("Contact %s approved."), NULL);
@@ -368,76 +361,58 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam)
challengeW = (TCHAR *)malloc(maxmsglen*sizeof(TCHAR));
tmpW = (TCHAR *)malloc(maxmsglen*sizeof(TCHAR));
- switch (_getOptB("Mode", defaultMode))
- {
- case SPAMOTRON_MODE_PLAIN:
- if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
- _getOptS(challengeW, maxmsglen, "AuthChallenge", defaultAuthChallenge);
- else
- _getOptS(challengeW, maxmsglen, "Challenge", defaultChallenge);
- ReplaceVars(challengeW, maxmsglen);
- tmp = mir_u2a(challengeW);
- challenge = mir_utf8encode(tmp);
- mir_free(tmp);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)challenge);
- mir_free(challenge);
- _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending plain challenge to %s."), message);
- break;
+ switch (_getOptB("Mode", defaultMode)) {
+ case SPAMOTRON_MODE_PLAIN:
+ if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
+ _getOptS(challengeW, maxmsglen, "AuthChallenge", defaultAuthChallenge);
+ else
+ _getOptS(challengeW, maxmsglen, "Challenge", defaultChallenge);
+ ReplaceVars(challengeW, maxmsglen);
+ CallContactService(hContact, PSS_MESSAGE, 0, ptrA(mir_utf8encodeT(challengeW)));
+ _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending plain challenge to %s."), message);
+ break;
- case SPAMOTRON_MODE_ROTATE:
- if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
- _getOptS(challengeW, maxmsglen, "AuthChallenge", defaultAuthChallenge);
- else
- _getOptS(challengeW, maxmsglen, "Challenge", defaultChallenge);
- _getOptS(buf, buflen, "Response", defaultResponse);
- if (_getCOptD(hContact, "ResponseNum", 0) >= (unsigned int)(get_response_num(buf)-1)) {
- _setCOptD(hContact, "ResponseNum", -1);
- }
- _setCOptD(hContact, "ResponseNum", _getCOptD(hContact, "ResponseNum", -1) + 1);
- ReplaceVarsNum(challengeW, maxmsglen, _getCOptD(hContact, "ResponseNum", 0));
-
- tmp = mir_u2a(challengeW);
- challenge = mir_utf8encode(tmp);
- mir_free(tmp);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)challenge);
- mir_free(challenge);
- _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending round-robin challenge to %s."), message);
- break;
-
- case SPAMOTRON_MODE_RANDOM:
- if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
- _getOptS(challengeW, maxmsglen, "AuthChallenge", defaultAuthChallenge);
- else
- _getOptS(challengeW, maxmsglen, "Challenge", defaultChallenge);
- _getOptS(buf, buflen, "Response", defaultResponse);
- srand(time(NULL));
- _setCOptD(hContact, "ResponseNum", rand() % get_response_num(buf));
- ReplaceVarsNum(challengeW, maxmsglen, _getCOptD(hContact, "ResponseNum", 0));
- tmp = mir_u2a(challengeW);
- challenge = mir_utf8encode(tmp);
- mir_free(tmp);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)challenge);
- mir_free(challenge);
- _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending random challenge to %s."), message);
- break;
-
- case SPAMOTRON_MODE_MATH:
- a = (rand() % 10) + 1;
- b = (rand() % 10) + 1;
- mir_sntprintf(mexpr, SIZEOF(mexpr), _T("%d + %d"), a, b);
- if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
- _getOptS(challengeW, maxmsglen, "AuthChallengeMath", defaultAuthChallengeMath);
- else
- _getOptS(challengeW, maxmsglen, "ChallengeMath", defaultChallengeMath);
- ReplaceVar(challengeW, maxmsglen, _T("%mathexpr%"), mexpr);
- _setCOptD(hContact, "ResponseMath", a + b);
- tmp = mir_u2a(challengeW);
- challenge = mir_utf8encode(tmp);
- mir_free(tmp);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)challenge);
- mir_free(challenge);
- _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending math expression challenge to %s."), message);
- break;
+ case SPAMOTRON_MODE_ROTATE:
+ if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
+ _getOptS(challengeW, maxmsglen, "AuthChallenge", defaultAuthChallenge);
+ else
+ _getOptS(challengeW, maxmsglen, "Challenge", defaultChallenge);
+ _getOptS(buf, buflen, "Response", defaultResponse);
+ if (_getCOptD(hContact, "ResponseNum", 0) >= (unsigned int)(get_response_num(buf)-1))
+ _setCOptD(hContact, "ResponseNum", -1);
+
+ _setCOptD(hContact, "ResponseNum", _getCOptD(hContact, "ResponseNum", -1) + 1);
+ ReplaceVarsNum(challengeW, maxmsglen, _getCOptD(hContact, "ResponseNum", 0));
+ CallContactService(hContact, PSS_MESSAGE, 0, ptrA(mir_utf8encodeT(challengeW)));
+ _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending round-robin challenge to %s."), message);
+ break;
+
+ case SPAMOTRON_MODE_RANDOM:
+ if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
+ _getOptS(challengeW, maxmsglen, "AuthChallenge", defaultAuthChallenge);
+ else
+ _getOptS(challengeW, maxmsglen, "Challenge", defaultChallenge);
+ _getOptS(buf, buflen, "Response", defaultResponse);
+ srand(time(NULL));
+ _setCOptD(hContact, "ResponseNum", rand() % get_response_num(buf));
+ ReplaceVarsNum(challengeW, maxmsglen, _getCOptD(hContact, "ResponseNum", 0));
+ CallContactService(hContact, PSS_MESSAGE, 0, ptrA(mir_utf8encodeT(challengeW)));
+ _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending random challenge to %s."), message);
+ break;
+
+ case SPAMOTRON_MODE_MATH:
+ a = (rand() % 10) + 1;
+ b = (rand() % 10) + 1;
+ mir_sntprintf(mexpr, SIZEOF(mexpr), _T("%d + %d"), a, b);
+ if (dbei->eventType == EVENTTYPE_AUTHREQUEST)
+ _getOptS(challengeW, maxmsglen, "AuthChallengeMath", defaultAuthChallengeMath);
+ else
+ _getOptS(challengeW, maxmsglen, "ChallengeMath", defaultChallengeMath);
+ ReplaceVar(challengeW, maxmsglen, _T("%mathexpr%"), mexpr);
+ _setCOptD(hContact, "ResponseMath", a + b);
+ CallContactService(hContact, PSS_MESSAGE, 0, ptrA(mir_utf8encodeT(challengeW)));
+ _notify(hContact, POPUP_CHALLENGE, TranslateT("Sending math expression challenge to %s."), message);
+ break;
}
free(challengeW);
free(tmpW);
diff --git a/plugins/StopSpamMod/src/stopspam.cpp b/plugins/StopSpamMod/src/stopspam.cpp
index bcb22c885d..1e6da982db 100755
--- a/plugins/StopSpamMod/src/stopspam.cpp
+++ b/plugins/StopSpamMod/src/stopspam.cpp
@@ -66,9 +66,8 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, hContact, hDbEvent)
msg = 0; //is it useful ?
}
if(msg) {
- char * buff=mir_utf8encodeW(variables_parse(gbAuthRepl, hcntct).c_str());
- CallContactService(hcntct, PSS_MESSAGE, PREF_UTF, (LPARAM) buff);
- mir_free(buff);
+ ptrA buff(mir_utf8encodeW(variables_parse(gbAuthRepl, hcntct).c_str()));
+ CallContactService(hcntct, PSS_MESSAGE, 0, (LPARAM)buff);
}
return 1;
}
@@ -197,9 +196,9 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
if((Stricmp(_T("ICQ"),prot.c_str()))||(!gbAutoReqAuth))
{
char * buf=mir_utf8encodeW(variables_parse(gbCongratulation, hContact).c_str());
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)buf);
+ CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)buf);
mir_free(buf);
- };
+ }
// Note: For ANSI can be not work
if(!Stricmp(_T("ICQ"),prot.c_str())){
// grand auth.
@@ -298,9 +297,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
else
q += variables_parse(gbQuestion, hContact);
- char * buf=mir_utf8encodeW(q.c_str());
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)buf);
- mir_free(buf);
+ CallContactService(hContact, PSS_MESSAGE, 0, ptrA(mir_utf8encodeW(q.c_str())));
// increment question count
DWORD questCount = db_get_dw(hContact, pluginName, "QuestionCount", 0);
diff --git a/plugins/StopSpamPlus/src/events.cpp b/plugins/StopSpamPlus/src/events.cpp
index 58845a2ce1..5e51915364 100644
--- a/plugins/StopSpamPlus/src/events.cpp
+++ b/plugins/StopSpamPlus/src/events.cpp
@@ -27,7 +27,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, wParam, lParam)
if (db_get_b(hcntct, "CList", "NotOnList", 0) && !db_get_b(hcntct, pluginName, answeredSetting, 0) && !IsExistMyMessage(hcntct)) {
if (!plSets->HandleAuthReq.Get()) {
char *buf = mir_utf8encodeW(variables_parse(plSets->AuthRepl.Get(), hcntct).c_str());
- CallContactService(hcntct, PSS_MESSAGE, PREF_UTF, (LPARAM)buf);
+ CallContactService(hcntct, PSS_MESSAGE, 0, (LPARAM)buf);
mir_free(buf);
}
@@ -120,7 +120,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
// send congratulation
char * buf = mir_utf8encodeW(variables_parse(plSets->Congratulation.Get(), hContact).c_str());
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)buf);
+ CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)buf);
mir_free(buf);
// process the event
@@ -140,7 +140,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
char * buf = mir_utf8encodeW(q.c_str());
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)buf);
+ CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)buf);
mir_free(buf);
diff --git a/plugins/TabSRMM/src/functions.h b/plugins/TabSRMM/src/functions.h
index f5fa1e308f..83c7f532ee 100644
--- a/plugins/TabSRMM/src/functions.h
+++ b/plugins/TabSRMM/src/functions.h
@@ -70,7 +70,6 @@ void TSAPI HandleMenuEntryFromhContact(MCONTACT iSelection);
* gneric msgwindow functions(creation, container management etc.)
*/
-BOOL TSAPI IsUtfSendAvailable(MCONTACT hContact);
HWND TSAPI CreateNewTabForContact(TContainerData *pContainer, MCONTACT hContact, int isSend,
const char *pszInitialText, BOOL bActivateTAb, BOOL bPopupContainer, BOOL bWantPopup, MEVENT hdbEvent);
int TSAPI ActivateTabFromHWND(HWND hwndTab, HWND hwnd);
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp
index 2367fc9d6c..81ae18d9a8 100644
--- a/plugins/TabSRMM/src/msgdialog.cpp
+++ b/plugins/TabSRMM/src/msgdialog.cpp
@@ -72,15 +72,6 @@ static void _clrMsgFilter(LPARAM lParam)
m->wParam = 0;
}
-BOOL TSAPI IsUtfSendAvailable(MCONTACT hContact)
-{
- char *szProto = GetContactProto(hContact);
- if (szProto == NULL)
- return FALSE;
-
- return (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDUTF) ? TRUE : FALSE;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
// show a modified context menu for the richedit control(s)
// @param dat message window data
@@ -2422,8 +2413,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if (job->hSendId == 0 && job->hContact == 0)
break;
- job->hSendId = (HANDLE)CallContactService(job->hContact, PSS_MESSAGE,
- (dat->sendMode & SMODE_FORCEANSI) ? (job->dwFlags & ~PREF_UNICODE) : job->dwFlags, (LPARAM)job->szSendBuffer);
+ job->hSendId = (HANDLE)CallContactService(job->hContact, PSS_MESSAGE, job->dwFlags, (LPARAM)job->szSendBuffer);
resent++;
}
@@ -2671,23 +2661,14 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if (decoded.IsEmpty())
break;
- char *utfResult = NULL;
if (final_sendformat)
DoRtfToTags(dat, decoded, SIZEOF(rtfDefColors), rtfDefColors);
decoded.TrimRight();
int bufSize = WideCharToMultiByte(dat->codePage, 0, decoded, -1, dat->sendBuffer, 0, 0, 0);
- size_t memRequired = 0;
int flags = 0;
- if (!IsUtfSendAvailable(dat->hContact)) {
- flags |= PREF_UNICODE;
- memRequired = bufSize + (mir_wstrlen(decoded) + 1) * sizeof(WCHAR);
- }
- else {
- flags |= PREF_UTF;
- utfResult = mir_utf8encodeT(decoded);
- memRequired = strlen(utfResult) + 1;
- }
+ char *utfResult = mir_utf8encodeT(decoded);
+ size_t memRequired = strlen(utfResult) + 1;
// try to detect RTL
HWND hwndEdit = GetDlgItem(hwndDlg, IDC_MESSAGE);
@@ -2711,15 +2692,9 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
dat->sendBuffer = (char *)mir_realloc(dat->sendBuffer, memRequired);
dat->iSendBufferSize = memRequired;
}
- if (utfResult) {
- memcpy(dat->sendBuffer, utfResult, memRequired);
- mir_free(utfResult);
- }
- else {
- WideCharToMultiByte(dat->codePage, 0, decoded, -1, dat->sendBuffer, bufSize, 0, 0);
- if (flags & PREF_UNICODE)
- memcpy(&dat->sendBuffer[bufSize], decoded, (mir_wstrlen(decoded) + 1) * sizeof(WCHAR));
- }
+
+ memcpy(dat->sendBuffer, utfResult, memRequired);
+ mir_free(utfResult);
if (memRequired == 0 || dat->sendBuffer[0] == 0)
break;
diff --git a/plugins/TabSRMM/src/sendlater.cpp b/plugins/TabSRMM/src/sendlater.cpp
index fddb95208a..f373ca98fa 100644
--- a/plugins/TabSRMM/src/sendlater.cpp
+++ b/plugins/TabSRMM/src/sendlater.cpp
@@ -417,12 +417,7 @@ int CSendLater::sendIt(CSendLaterJob *job)
job->iSendCount++;
job->hTargetContact = hContact;
job->bCode = CSendLaterJob::JOB_WAITACK;
-
- DWORD dwFlags = IsUtfSendAvailable(hContact) ? PREF_UTF : PREF_UNICODE;
- if (dwFlags & PREF_UTF)
- job->hProcess = (HANDLE)CallContactService(hContact, PSS_MESSAGE, dwFlags, (LPARAM)job->sendBuffer);
- else
- job->hProcess = (HANDLE)CallContactService(hContact, PSS_MESSAGE, dwFlags, (LPARAM)job->pBuf);
+ job->hProcess = (HANDLE)CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)job->sendBuffer);
return 0;
}
diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp
index 98b9932f7f..4e9471f662 100644
--- a/plugins/TabSRMM/src/sendqueue.cpp
+++ b/plugins/TabSRMM/src/sendqueue.cpp
@@ -137,75 +137,6 @@ static int SendChunkA(char *chunk, MCONTACT hContact, char *szSvc, DWORD dwFlags
return(CallContactService(hContact, szSvc, dwFlags, (LPARAM)chunk));
}
-static void DoSplitSendW(LPVOID param)
-{
- SendJob *job = sendQueue->getJobByIndex((int)param);
- BOOL fFirstSend = FALSE;
- WCHAR *wszSaved, savedChar;
- size_t iCur = 0, iSavedCur = 0, i;
- BOOL fSplitting = TRUE;
- MCONTACT hContact = job->hContact;
- DWORD dwFlags = job->dwFlags;
- size_t chunkSize = job->chunkSize / 2;
-
- size_t iLen = mir_strlen(job->szSendBuffer);
- WCHAR *wszBegin = (WCHAR*)& job->szSendBuffer[iLen + 1];
- WCHAR *wszTemp = (WCHAR*)mir_alloc(sizeof(WCHAR) * (mir_wstrlen(wszBegin) + 1));
- memcpy(wszTemp, wszBegin, sizeof(WCHAR) * (mir_wstrlen(wszBegin) + 1));
- wszBegin = wszTemp;
-
- do {
- iCur += chunkSize;
- if (iCur > iLen)
- fSplitting = FALSE;
-
- // try to "word wrap" the chunks - split on word boundaries (space characters), if possible.
- // SPLIT_WORD_CUTOFF = max length of unbreakable words, longer words may be split.
- if (fSplitting) {
- i = 0;
- wszSaved = &wszBegin[iCur];
- iSavedCur = iCur;
- while (iCur) {
- if (wszBegin[iCur] == (TCHAR)' ') {
- wszSaved = &wszBegin[iCur];
- break;
- }
- if (i == SPLIT_WORD_CUTOFF) { // no space found backwards, restore old split position
- iCur = iSavedCur;
- wszSaved = &wszBegin[iCur];
- break;
- }
- i++;
- iCur--;
- }
- savedChar = *wszSaved;
- *wszSaved = 0;
- int id = SendChunkW(wszTemp, hContact, dwFlags);
- if (!fFirstSend) {
- job->hSendId = (HANDLE)id;
- fFirstSend = TRUE;
- PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_SPLITSENDACK, (WPARAM)param, 0);
- }
- *wszSaved = savedChar;
- wszTemp = wszSaved;
- if (savedChar == (TCHAR)' ') {
- wszTemp++;
- iCur++;
- }
- }
- else {
- int id = SendChunkW(wszTemp, hContact, dwFlags);
- if (!fFirstSend) {
- job->hSendId = (HANDLE)id;
- fFirstSend = TRUE;
- PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_SPLITSENDACK, (WPARAM)param, 0);
- }
- }
- Sleep(500L);
- } while (fSplitting);
- mir_free(wszBegin);
-}
-
static void DoSplitSendA(LPVOID param)
{
SendJob *job = sendQueue->getJobByIndex((int)param);
@@ -279,14 +210,7 @@ static void DoSplitSendA(LPVOID param)
size_t SendQueue::getSendLength(const int iEntry, int sendMode)
{
SendJob &p = m_jobs[iEntry];
- if (p.dwFlags & PREF_UNICODE && !(sendMode & SMODE_FORCEANSI)) {
- size_t iLen = mir_strlen(p.szSendBuffer);
- WCHAR *wszBuf = (WCHAR*)&p.szSendBuffer[iLen + 1];
- char *utf8 = mir_utf8encodeT(wszBuf);
- p.iSendLength = mir_strlen(utf8);
- mir_free(utf8);
- }
- else p.iSendLength = mir_strlen(p.szSendBuffer);
+ p.iSendLength = mir_strlen(p.szSendBuffer);
return p.iSendLength;
}
@@ -365,13 +289,7 @@ int SendQueue::sendQueued(TWindowData *dat, const int iEntry)
m_jobs[iEntry].chunkSize = dat->nMax;
DWORD dwOldFlags = m_jobs[iEntry].dwFlags;
- if (dat->sendMode & SMODE_FORCEANSI)
- m_jobs[iEntry].dwFlags &= ~PREF_UNICODE;
-
- if (!(m_jobs[iEntry].dwFlags & PREF_UNICODE) || dat->sendMode & SMODE_FORCEANSI)
- mir_forkthread(DoSplitSendA, (LPVOID)iEntry);
- else
- mir_forkthread(DoSplitSendW, (LPVOID)iEntry);
+ mir_forkthread(DoSplitSendA, (LPVOID)iEntry);
m_jobs[iEntry].dwFlags = dwOldFlags;
}
else {
@@ -394,8 +312,7 @@ int SendQueue::sendQueued(TWindowData *dat, const int iEntry)
clearJob(iEntry);
return 0;
}
- m_jobs[iEntry].hSendId = (HANDLE)CallContactService(dat->hContact, PSS_MESSAGE,
- (dat->sendMode & SMODE_FORCEANSI) ? (m_jobs[iEntry].dwFlags & ~PREF_UNICODE) : m_jobs[iEntry].dwFlags, (LPARAM)m_jobs[iEntry].szSendBuffer);
+ m_jobs[iEntry].hSendId = (HANDLE)CallContactService(dat->hContact, PSS_MESSAGE, m_jobs[iEntry].dwFlags, (LPARAM)m_jobs[iEntry].szSendBuffer);
if (dat->sendMode & SMODE_NOACK) { // fake the ack if we are not interested in receiving real acks
ACKDATA ack = { 0 };
@@ -472,13 +389,8 @@ void SendQueue::logError(const TWindowData *dat, int iSendJobIndex, const TCHAR
iMsgLen = 0;
dbei.pBlob = NULL;
}
- if (m_jobs[iSendJobIndex].dwFlags & PREF_UTF)
- dbei.flags = DBEF_UTF;
- if (iSendJobIndex >= 0) {
- if (m_jobs[iSendJobIndex].dwFlags & PREF_UNICODE) {
- iMsgLen *= 3;
- }
- }
+
+ dbei.flags = DBEF_UTF;
dbei.cbBlob = (int)iMsgLen;
dbei.timestamp = time(NULL);
dbei.szModule = (char *)szErrMsg;
@@ -545,13 +457,8 @@ void SendQueue::recallFailed(const TWindowData *dat, int iEntry) const
return;
// message area is empty, so we can recall the failed message...
- SETTEXTEX stx = { ST_DEFAULT, 1200 };
- if (m_jobs[iEntry].dwFlags & PREF_UNICODE)
- SendDlgItemMessage(dat->hwnd, IDC_MESSAGE, EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)&m_jobs[iEntry].szSendBuffer[mir_strlen(m_jobs[iEntry].szSendBuffer) + 1]);
- else {
- stx.codepage = (m_jobs[iEntry].dwFlags & PREF_UTF) ? CP_UTF8 : CP_ACP;
- SendDlgItemMessage(dat->hwnd, IDC_MESSAGE, EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)m_jobs[iEntry].szSendBuffer);
- }
+ SETTEXTEX stx = { ST_DEFAULT, CP_UTF8 };
+ SendDlgItemMessage(dat->hwnd, IDC_MESSAGE, EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)m_jobs[iEntry].szSendBuffer);
UpdateSaveAndSendButton(const_cast<TWindowData *>(dat));
SendDlgItemMessage(dat->hwnd, IDC_MESSAGE, EM_SETSEL, (WPARAM)-1, (LPARAM)-1);
}
@@ -698,12 +605,9 @@ int SendQueue::ackMessage(TWindowData *dat, WPARAM wParam, LPARAM lParam)
cc->updateStats(TSessionStats::BYTES_SENT, dbei.cbBlob - 1);
}
- if (job.dwFlags & PREF_UNICODE)
- dbei.cbBlob *= sizeof(TCHAR) + 1;
if (job.dwFlags & PREF_RTL)
dbei.flags |= DBEF_RTL;
- if (job.dwFlags & PREF_UTF)
- dbei.flags |= DBEF_UTF;
+ dbei.flags |= DBEF_UTF;
dbei.pBlob = (PBYTE)job.szSendBuffer;
MessageWindowEvent evt = { sizeof(evt), (int)job.hSendId, job.hContact, &dbei };
@@ -816,41 +720,21 @@ int SendQueue::doSendLater(int iJobIndex, TWindowData *dat, MCONTACT hContact, b
}
else mir_sntprintf(tszHeader, SIZEOF(tszHeader), _T("M%d|"), time(0));
- if (job->dwFlags & PREF_UTF || !(job->dwFlags & PREF_UNICODE)) {
- char *utf_header = mir_utf8encodeT(tszHeader);
- size_t required = mir_strlen(utf_header) + mir_strlen(job->szSendBuffer) + 10;
- char *tszMsg = reinterpret_cast<char *>(mir_alloc(required));
+ char *utf_header = mir_utf8encodeT(tszHeader);
+ size_t required = mir_strlen(utf_header) + mir_strlen(job->szSendBuffer) + 10;
+ char *tszMsg = reinterpret_cast<char *>(mir_alloc(required));
- if (fIsSendLater) {
- mir_snprintf(tszMsg, required, "%s%s", job->szSendBuffer, utf_header);
- db_set_s(hContact ? hContact : job->hContact, "SendLater", szKeyName, tszMsg);
- }
- else {
- mir_snprintf(tszMsg, required, "%s%s", utf_header, job->szSendBuffer);
- sendLater->addJob(tszMsg, hContact);
- }
- mir_free(utf_header);
- mir_free(tszMsg);
+ if (fIsSendLater) {
+ mir_snprintf(tszMsg, required, "%s%s", job->szSendBuffer, utf_header);
+ db_set_s(hContact ? hContact : job->hContact, "SendLater", szKeyName, tszMsg);
}
- else if (job->dwFlags & PREF_UNICODE) {
- size_t iLen = mir_strlen(job->szSendBuffer);
- wchar_t *wszMsg = (wchar_t *)&job->szSendBuffer[iLen + 1];
-
- size_t required = sizeof(TCHAR) * (mir_tstrlen(tszHeader) + mir_wstrlen(wszMsg) + 10);
-
- TCHAR *tszMsg = reinterpret_cast<TCHAR *>(mir_alloc(required));
- if (fIsSendLater)
- mir_sntprintf(tszMsg, required, _T("%s%s"), wszMsg, tszHeader);
- else
- mir_sntprintf(tszMsg, required, _T("%s%s"), tszHeader, wszMsg);
- char *utf = mir_utf8encodeT(tszMsg);
- if (fIsSendLater)
- db_set_s(hContact ? hContact : job->hContact, "SendLater", szKeyName, utf);
- else
- sendLater->addJob(utf, hContact);
- mir_free(utf);
- mir_free(tszMsg);
+ else {
+ mir_snprintf(tszMsg, required, "%s%s", utf_header, job->szSendBuffer);
+ sendLater->addJob(tszMsg, hContact);
}
+ mir_free(utf_header);
+ mir_free(tszMsg);
+
if (fIsSendLater) {
int iCount = db_get_dw(hContact ? hContact : job->hContact, "SendLater", "count", 0);
iCount++;
diff --git a/plugins/YARelay/src/main.cpp b/plugins/YARelay/src/main.cpp
index 8a7974b621..310eb5eece 100644
--- a/plugins/YARelay/src/main.cpp
+++ b/plugins/YARelay/src/main.cpp
@@ -208,7 +208,7 @@ static int MessageEventAdded(WPARAM hContact, LPARAM hDBEvent)
strncpy(szMsgPart, szBuf, cbPortion);
szMsgPart[cbPortion] = 0;
- HANDLE hMsgProc = (HANDLE)CallContactService(hForwardTo, PSS_MESSAGE, PREF_UTF, (LPARAM)szMsgPart);
+ HANDLE hMsgProc = (HANDLE)CallContactService(hForwardTo, PSS_MESSAGE, 0, (LPARAM)szMsgPart);
MESSAGE_PROC* msgProc = (MESSAGE_PROC*)mir_alloc(sizeof(MESSAGE_PROC));
msgProc->hProcess = hMsgProc;
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)
diff --git a/src/core/stdfile/src/file.cpp b/src/core/stdfile/src/file.cpp
index 042d1fe44e..fbe092784a 100644
--- a/src/core/stdfile/src/file.cpp
+++ b/src/core/stdfile/src/file.cpp
@@ -371,27 +371,6 @@ INT_PTR openRecDir(WPARAM, LPARAM)
/////////////////////////////////////////////////////////////////////////////////////////
-static void sttRecvCreateBlob(DBEVENTINFO &dbei, int fileCount, char **pszFiles, char *szDescr)
-{
- dbei.cbBlob = sizeof(DWORD);
-
- for (int i = 0; i < fileCount; i++)
- dbei.cbBlob += (int)mir_strlen(pszFiles[i]) + 1;
-
- dbei.cbBlob += (int)mir_strlen(szDescr) + 1;
-
- if ((dbei.pBlob = (BYTE*)mir_alloc(dbei.cbBlob)) == 0)
- return;
-
- *(DWORD*)dbei.pBlob = 0;
- BYTE* p = dbei.pBlob + sizeof(DWORD);
- for (int i = 0; i < fileCount; i++) {
- strcpy((char*)p, pszFiles[i]);
- p += mir_strlen(pszFiles[i]) + 1;
- }
- strcpy((char*)p, (szDescr == NULL) ? "" : szDescr);
-}
-
static INT_PTR Proto_RecvFileT(WPARAM, LPARAM lParam)
{
CCSDATA *ccs = (CCSDATA*)lParam;
@@ -402,20 +381,46 @@ static INT_PTR Proto_RecvFileT(WPARAM, LPARAM lParam)
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = GetContactProto(ccs->hContact);
dbei.timestamp = pre->timestamp;
- dbei.flags = (pre->flags & PREF_CREATEREAD) ? DBEF_READ : 0;
+ dbei.flags = DBEF_UTF | (pre->dwFlags & PREF_CREATEREAD) ? DBEF_READ : 0;
dbei.eventType = EVENTTYPE_FILE;
- char **pszFiles = (char**)alloca(pre->fileCount * sizeof(char*));
- for (int i = 0; i < pre->fileCount; i++)
- pszFiles[i] = Utf8EncodeT(pre->ptszFiles[i]);
+ bool bUnicode = (pre->dwFlags & PRFF_UNICODE) == PRFF_UNICODE;
- char *szDescr = Utf8EncodeT(pre->tszDescription);
- dbei.flags |= DBEF_UTF;
- sttRecvCreateBlob(dbei, pre->fileCount, pszFiles, szDescr);
+ char *szDescr, **pszFiles;
+ if (bUnicode) {
+ pszFiles = (char**)alloca(pre->fileCount * sizeof(char*));
+ for (int i = 0; i < pre->fileCount; i++)
+ pszFiles[i] = Utf8EncodeT(pre->ptszFiles[i]);
+
+ szDescr = Utf8EncodeT(pre->tszDescription);
+ }
+ else {
+ pszFiles = pre->pszFiles;
+ szDescr = pre->szDescription;
+ }
+
+ dbei.cbBlob = sizeof(DWORD);
for (int i = 0; i < pre->fileCount; i++)
- mir_free(pszFiles[i]);
- mir_free(szDescr);
+ dbei.cbBlob += (int)mir_strlen(pszFiles[i]) + 1;
+
+ dbei.cbBlob += (int)mir_strlen(szDescr) + 1;
+
+ if ((dbei.pBlob = (BYTE*)mir_alloc(dbei.cbBlob)) == 0)
+ return 0;
+
+ *(DWORD*)dbei.pBlob = 0;
+ BYTE* p = dbei.pBlob + sizeof(DWORD);
+ for (int i = 0; i < pre->fileCount; i++) {
+ strcpy((char*)p, pszFiles[i]);
+ p += mir_strlen(pszFiles[i]) + 1;
+ if (bUnicode)
+ mir_free(pszFiles[i]);
+ }
+
+ strcpy((char*)p, (szDescr == NULL) ? "" : szDescr);
+ if (bUnicode)
+ mir_free(szDescr);
MEVENT hdbe = db_event_add(ccs->hContact, &dbei);
PushFileEvent(ccs->hContact, hdbe, pre->lParam);
diff --git a/src/core/stdmsg/src/cmdlist.cpp b/src/core/stdmsg/src/cmdlist.cpp
index f462ddbb14..4fa38ae9ac 100644
--- a/src/core/stdmsg/src/cmdlist.cpp
+++ b/src/core/stdmsg/src/cmdlist.cpp
@@ -94,7 +94,7 @@ void msgQueue_processack(MCONTACT hContact, int id, BOOL success, const char *sz
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.flags = DBEF_SENT | (p->flags & PREF_UTF ? DBEF_UTF : 0) | (p->flags & PREF_RTL ? DBEF_RTL : 0);
+ dbei.flags = DBEF_SENT | DBEF_UTF | (p->flags & PREF_RTL ? DBEF_RTL : 0);
dbei.szModule = GetContactProto(hContact);
dbei.timestamp = time(0);
dbei.cbBlob = (DWORD)mir_strlen(p->szMsg);
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp
index 9e72a86f62..af2c574587 100644
--- a/src/core/stdmsg/src/msgdialog.cpp
+++ b/src/core/stdmsg/src/msgdialog.cpp
@@ -53,15 +53,6 @@ static void NotifyLocalWinEvent(MCONTACT hContact, HWND hwnd, unsigned int type)
}
}
-static BOOL IsUtfSendAvailable(MCONTACT hContact)
-{
- char *szProto = GetContactProto(hContact);
- if (szProto == NULL)
- return FALSE;
-
- return (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDUTF) ? TRUE : FALSE;
-}
-
static int RTL_Detect(const TCHAR *ptszText)
{
int iLen = (int)_tcslen(ptszText);
@@ -81,34 +72,13 @@ int SendMessageDirect(const TCHAR *szMsg, MCONTACT hContact, char *szProto)
return NULL;
int flags = 0;
- int bufSize = 0;
- char *sendBuffer = NULL;
-
if (RTL_Detect(szMsg))
flags |= PREF_RTL;
- if (IsUtfSendAvailable(hContact)) {
- flags |= PREF_UTF;
- sendBuffer = mir_utf8encodeT(szMsg);
- if (!sendBuffer || !sendBuffer[0]) {
- mir_free(sendBuffer);
- return NULL;
- }
- bufSize = (int)strlen(sendBuffer) + 1;
- }
- else {
- flags |= PREF_TCHAR;
- sendBuffer = mir_t2a(szMsg);
- if (!sendBuffer || !sendBuffer[0]) {
- mir_free(sendBuffer);
- return NULL;
- }
- bufSize = (int)strlen(sendBuffer) + 1;
-
- size_t bufSizeT = (_tcslen(szMsg) + 1) * sizeof(TCHAR);
- sendBuffer = (char*)mir_realloc(sendBuffer, bufSizeT + bufSize);
- memcpy((TCHAR*)&sendBuffer[bufSize], szMsg, bufSizeT);
- bufSize += (int)bufSizeT;
+ char *sendBuffer = mir_utf8encodeT(szMsg);
+ if (!sendBuffer || !sendBuffer[0]) {
+ mir_free(sendBuffer);
+ return NULL;
}
if (sendBuffer == NULL)
diff --git a/src/modules/metacontacts/meta_services.cpp b/src/modules/metacontacts/meta_services.cpp
index 7c10f7de2f..9d3a0c89a0 100644
--- a/src/modules/metacontacts/meta_services.cpp
+++ b/src/modules/metacontacts/meta_services.cpp
@@ -63,7 +63,7 @@ INT_PTR Meta_GetCaps(WPARAM wParam, LPARAM lParam)
return PF2_ONLINE | PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE;
case PFLAGNUM_4:
- return PF4_SUPPORTTYPING | PF4_AVATARS | PF4_IMSENDUTF;
+ return PF4_SUPPORTTYPING | PF4_AVATARS;
case PFLAGNUM_5:
return PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE;
diff --git a/src/modules/protocols/protocols.cpp b/src/modules/protocols/protocols.cpp
index 2a0c2b9b2a..3787696bd9 100644
--- a/src/modules/protocols/protocols.cpp
+++ b/src/modules/protocols/protocols.cpp
@@ -124,20 +124,14 @@ static INT_PTR Proto_RecvMessage(WPARAM, LPARAM lParam)
ptrA pszTemp;
mir_ptr<BYTE> pszBlob;
- DBEVENTINFO dbei = { sizeof(dbei) };
+ DBEVENTINFO dbei = { 0 };
+ dbei.cbSize = sizeof(dbei);
+ dbei.flags = DBEF_UTF;
dbei.szModule = GetContactProto(ccs->hContact);
dbei.timestamp = pre->timestamp;
dbei.eventType = EVENTTYPE_MESSAGE;
- if (pre->flags & PREF_UNICODE) {
- pszTemp = mir_utf8encodeT(pre->tszMessage);
- dbei.pBlob = (PBYTE)(char*)pszTemp;
- dbei.cbBlob = (DWORD)strlen(pszTemp) + 1;
- dbei.flags |= DBEF_UTF;
- }
- else {
- dbei.cbBlob = (DWORD)strlen(pre->szMessage) + 1;
- dbei.pBlob = (PBYTE)pre->szMessage;
- }
+ dbei.cbBlob = (DWORD)strlen(pre->szMessage) + 1;
+ dbei.pBlob = (PBYTE)pre->szMessage;
if (pre->cbCustomDataSize != 0) {
pszBlob = (PBYTE)mir_alloc(dbei.cbBlob + pre->cbCustomDataSize);
@@ -149,8 +143,6 @@ static INT_PTR Proto_RecvMessage(WPARAM, LPARAM lParam)
if (pre->flags & PREF_CREATEREAD)
dbei.flags |= DBEF_READ;
- if (pre->flags & PREF_UTF)
- dbei.flags |= DBEF_UTF;
if (pre->flags & PREF_SENT)
dbei.flags |= DBEF_SENT;
@@ -164,8 +156,7 @@ static INT_PTR Proto_AuthRecv(WPARAM wParam, LPARAM lParam)
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = (char*)wParam;
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 = pre->lParam;
dbei.pBlob = (PBYTE)pre->szMessage;
diff --git a/src/modules/protocols/protoint.cpp b/src/modules/protocols/protoint.cpp
index 9152877e44..d6b9a9f39f 100644
--- a/src/modules/protocols/protoint.cpp
+++ b/src/modules/protocols/protoint.cpp
@@ -208,9 +208,9 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE
return res;
}
- int __cdecl SendMsg(MCONTACT hContact, int flags, const char* msg)
+ int __cdecl SendMsg(MCONTACT hContact, const char* msg)
{
- CCSDATA ccs = { hContact, PSS_MESSAGE, flags, (LPARAM)msg };
+ CCSDATA ccs = { hContact, PSS_MESSAGE, 0, (LPARAM)msg };
return (int)ProtoCallService(m_szModuleName, PSS_MESSAGE, 0, (LPARAM)&ccs);
}