summaryrefslogtreecommitdiff
path: root/messages.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'messages.cpp')
-rw-r--r--messages.cpp57
1 files changed, 15 insertions, 42 deletions
diff --git a/messages.cpp b/messages.cpp
index 3479f7e..8df3a2b 100644
--- a/messages.cpp
+++ b/messages.cpp
@@ -40,11 +40,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
{ //check for gpg related data
- wchar_t *tmp = mir_utf8decodeW(msg);
- if(!tmp)
- tmp = mir_a2t(msg);
- wstring str = tmp;
- mir_free(tmp);
+ wstring str = toUTF16(msg);
wstring::size_type s1 = wstring::npos, s2 = wstring::npos;
if((str.find(_T("-----END PGP PUBLIC KEY BLOCK-----")) != wstring::npos) && (str.find(_T("-----BEGIN PGP PUBLIC KEY BLOCK-----")) != wstring::npos))
@@ -311,16 +307,9 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
f.seekg(0, std::ios::beg);
f.read(tmp, size);
tmp[size] = '\0';
- TCHAR *tmp2 = mir_utf8decodeW(tmp);
- if(!tmp2)
- {
- str.append(_T("Miranda failed to decode this utf8 message, showing it as is:\n"));
- tmp2 = mir_a2t(tmp);
- str.append(tmp2);
- }
+ toUTF16(tmp);
+ str.append(toUTF16(tmp));
delete [] tmp;
- str.append(tmp2);
- mir_free(tmp2);
f.close();
DeleteFile(path.c_str());
}
@@ -341,10 +330,10 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
str.insert(0, inopentag);
str.append(inclosetag);
}
- pre->szMessage = mir_utf8encodeW(str.c_str());
+ pre->szMessage = mir_strdup(toUTF8(str).c_str());
if(metaIsSubcontact(hContact))
{
- char *msg = mir_utf8encodeW(str.c_str());
+ char *msg = mir_strdup(toUTF8(str).c_str());
HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, DBEF_UTF);
mir_free(msg);
return 1;
@@ -363,11 +352,9 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
mir_free(msg);
return 1;
}
- wchar_t *tmp = mir_utf8decodeW(msg);
- wstring str = tmp;
- mir_free(tmp);
+ wstring str = toUTF16(msg);
mir_free((void**)pre->szMessage);
- pre->szMessage = mir_utf8encodeW(str.c_str());
+ pre->szMessage = mir_strdup(toUTF8(str).c_str());
return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs);
}
return CallService(MS_PROTO_CHAINRECV, w, l);
@@ -405,11 +392,7 @@ int SendMsgSvc(WPARAM w, LPARAM l)
{ //encrypt data here
- TCHAR *tmp = mir_utf8decodeW(msg);
- if(!tmp)
- tmp = mir_a2t(msg);
- wstring str = tmp;
- mir_free(tmp);
+ wstring str = toUTF16(msg);
{ //not xmpp, just replace whole message
string out;
DWORD code;
@@ -442,7 +425,7 @@ int SendMsgSvc(WPARAM w, LPARAM l)
cmd += _T("\"");
{
char *tmp;
- tmp = mir_utf8encodeW(str.c_str());
+ tmp = mir_strdup(toUTF8(str).c_str());
fstream f(path.c_str(), std::ios::out);
f<<tmp;
mir_free(tmp);
@@ -535,22 +518,16 @@ int SendMsgSvc(WPARAM w, LPARAM l)
msgs_to_ignore.push_back(hps);
if(bAppendTags)
{
- char *opentag = mir_utf8encodeW(outopentag);
- str_event.insert(0, opentag);
- mir_free(opentag);
- char *closetag = mir_utf8encodeW(outclosetag);
- str_event.append(closetag);
- mir_free(closetag);
+ str_event.insert(0, toUTF8(outopentag));
+ str_event.append(toUTF8(outclosetag));
}
HistoryLog(hContact, (char*)str_event.c_str(), EVENTTYPE_MESSAGE, DBEF_SENT | DBEF_UTF);
HistoryLog(metaGetContact(hContact), (char*)str_event.c_str(), EVENTTYPE_MESSAGE, DBEF_SENT | DBEF_UTF);
DBWriteContactSettingByte(metaGetContact(hContact), szGPGModuleName, "MsgsForTagging", DBGetContactSettingByte(metaGetContact(hContact), szGPGModuleName, "MsgsForTagging", 0) + 1);
- char *data = mir_utf8encodeW(str.c_str());
- CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)data);
- mir_free(data);
+ CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)toUTF8(str).c_str());
return returnNoError(hContact);
}
- ccs->lParam = (LPARAM)mir_utf8encodeW(str.c_str());
+ ccs->lParam = (LPARAM)mir_strdup(toUTF8(str).c_str());
if(bAppendTags)
DBWriteContactSettingByte(hContact, szGPGModuleName, "MsgsForTagging", DBGetContactSettingByte(hContact, szGPGModuleName, "MsgsForTagging", 0) + 1);
}
@@ -596,14 +573,10 @@ int HookSendMsg(WPARAM w, LPARAM l)
if((dbei->eventType == EVENTTYPE_MESSAGE) && (dbei->flags & DBEF_SENT))
{
char *msg = (char*)dbei->pBlob;
- TCHAR *tmp = mir_utf8decodeW(msg);
- if(!tmp)
- tmp = mir_a2t(msg);
- wstring str = tmp;
- mir_free(tmp);
+ wstring str = toUTF16(msg);
str.insert(0, outopentag);
str.append(outclosetag);
- char *msg2 = mir_utf8encodeW(str.c_str());
+ char *msg2 = mir_strdup(toUTF8(str).c_str());
mir_free(dbei->pBlob);
dbei->pBlob = (PBYTE)msg2;
dbei->cbBlob = strlen(msg2)+1;