diff options
104 files changed, 421 insertions, 645 deletions
diff --git a/include/m_core.h b/include/m_core.h index 4b8eb0a824..e29dc0f100 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -670,6 +670,33 @@ __forceinline char* mir_utf8decodeA(const char* src) #define mir_utf8encodeT mir_utf8encode
#endif
+class T2Utf
+{
+ char* m_str;
+
+public:
+ __forceinline T2Utf(const TCHAR *str) :
+ m_str(mir_utf8encodeT(str))
+ {}
+
+ __forceinline ~T2Utf()
+ { mir_free(m_str);
+ }
+
+ __forceinline char* detach()
+ { char *res = m_str; m_str = NULL;
+ return res;
+ }
+
+ __forceinline char& operator[](int idx) const { return m_str[idx]; }
+ __forceinline operator char*() const { return m_str; }
+ __forceinline operator unsigned char*() const { return (unsigned char*)m_str; }
+ __forceinline operator LPARAM() const { return (LPARAM)m_str; }
+ #ifdef _XSTRING_
+ std::string str() const { return std::string(m_str); }
+ #endif
+};
+
///////////////////////////////////////////////////////////////////////////////
// Window subclassing
diff --git a/plugins/AvatarHistory/src/AvatarHistory.cpp b/plugins/AvatarHistory/src/AvatarHistory.cpp index 022754652f..dc1489ee7e 100644 --- a/plugins/AvatarHistory/src/AvatarHistory.cpp +++ b/plugins/AvatarHistory/src/AvatarHistory.cpp @@ -211,15 +211,15 @@ static int AvatarChanged(WPARAM hContact, LPARAM lParam) if (ContactEnabled(hContact, "LogToHistory", AVH_DEF_LOGTOHISTORY)) {
TCHAR rel_path[MAX_PATH];
PathToRelativeT(history_filename, rel_path);
- ptrA blob( mir_utf8encodeT(rel_path));
+ T2Utf blob(rel_path);
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = GetContactProto(hContact);
dbei.flags = DBEF_READ | DBEF_UTF;
dbei.timestamp = (DWORD) time(NULL);
dbei.eventType = EVENTTYPE_AVATAR_CHANGE;
- dbei.cbBlob = (DWORD) mir_strlen(blob) + 1;
- dbei.pBlob = (PBYTE)(char*)blob;
+ dbei.cbBlob = (DWORD)mir_strlen(blob) + 1;
+ dbei.pBlob = blob;
db_event_add(hContact, &dbei);
}
}
diff --git a/plugins/Boltun/src/actionQueue.cpp b/plugins/Boltun/src/actionQueue.cpp index 18554974be..3eaa6200f0 100644 --- a/plugins/Boltun/src/actionQueue.cpp +++ b/plugins/Boltun/src/actionQueue.cpp @@ -83,7 +83,7 @@ static bool NotifyTyping(MCONTACT hContact) static void TimerAnswer(MCONTACT hContact, const TalkBot::MessageInfo* info)
{
- ptrA msg(mir_utf8encodeT(info->Answer.c_str()));
+ T2Utf msg(info->Answer.c_str());
size_t bufsize = mir_strlen(msg);
CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)msg);
@@ -101,8 +101,6 @@ static void TimerAnswer(MCONTACT hContact, const TalkBot::MessageInfo* info) bot->AnswerGiven(hContact, *info);
delete info;
- delete[] msg;
-
mir_cslock lck(typingContactsLock);
typingContacts.erase(hContact);
}
diff --git a/plugins/BuddyPounce/src/main.cpp b/plugins/BuddyPounce/src/main.cpp index b7fe00b559..f5890628fa 100644 --- a/plugins/BuddyPounce/src/main.cpp +++ b/plugins/BuddyPounce/src/main.cpp @@ -59,38 +59,38 @@ int MsgAck(WPARAM, LPARAM lParam) {
ACKDATA *ack=(ACKDATA*)lParam;
- if (ack && ack->cbSize==sizeof(ACKDATA)
- && ack->type==ACKTYPE_MESSAGE
- && ack->hProcess==(HANDLE)WindowList_Find(hWindowList,ack->hContact)) {
- if (db_get_b(NULL, modname, "ShowDeliveryMessages", 1))
- CreateMessageAcknowlegedWindow(ack->hContact,ack->result == ACKRESULT_SUCCESS);
- if (ack->result == ACKRESULT_SUCCESS) {
- // wrtie it to the DB
- DBEVENTINFO dbei = { 0 };
- DBVARIANT dbv;
- int reuse = db_get_b(ack->hContact,modname, "Reuse", 0);
- if ( !db_get_ts(ack->hContact, modname, "PounceMsg", &dbv) && (dbv.ptszVal[0] != '\0')) {
- ptrA pszUtf( mir_utf8encodeT(dbv.ptszVal));
- dbei.cbSize = sizeof(dbei);
- dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.flags = DBEF_UTF | DBEF_SENT;
- dbei.szModule = (char*)ack->szModule;
- dbei.timestamp = time(NULL);
- dbei.cbBlob = (int)mir_strlen(pszUtf) + 1;
- dbei.pBlob = (PBYTE)(char*)pszUtf;
- db_event_add(ack->hContact, &dbei);
- }
- // check to reuse
- if (reuse > 1)
- db_set_b(ack->hContact, modname, "Reuse", (BYTE)(reuse-1));
- else {
- db_set_b(ack->hContact,modname, "Reuse", 0);
- db_set_ws(ack->hContact, modname, "PounceMsg", _T(""));
+ if (ack && ack->cbSize == sizeof(ACKDATA) && ack->type == ACKTYPE_MESSAGE) {
+ if (ack->hProcess == (HANDLE)WindowList_Find(hWindowList,ack->hContact)) {
+ if (db_get_b(NULL, modname, "ShowDeliveryMessages", 1))
+ CreateMessageAcknowlegedWindow(ack->hContact,ack->result == ACKRESULT_SUCCESS);
+ if (ack->result == ACKRESULT_SUCCESS) {
+ // wrtie it to the DB
+ DBEVENTINFO dbei = { 0 };
+ DBVARIANT dbv;
+ int reuse = db_get_b(ack->hContact,modname, "Reuse", 0);
+ if (!db_get_ts(ack->hContact, modname, "PounceMsg", &dbv) && (dbv.ptszVal[0] != '\0')) {
+ T2Utf pszUtf(dbv.ptszVal);
+ dbei.cbSize = sizeof(dbei);
+ dbei.eventType = EVENTTYPE_MESSAGE;
+ dbei.flags = DBEF_UTF | DBEF_SENT;
+ dbei.szModule = (char*)ack->szModule;
+ dbei.timestamp = time(NULL);
+ dbei.cbBlob = (int)mir_strlen(pszUtf) + 1;
+ dbei.pBlob = (PBYTE)(char*)pszUtf;
+ db_event_add(ack->hContact, &dbei);
+ }
+ // check to reuse
+ if (reuse > 1)
+ db_set_b(ack->hContact, modname, "Reuse", (BYTE)(reuse-1));
+ else {
+ db_set_b(ack->hContact,modname, "Reuse", 0);
+ db_set_ws(ack->hContact, modname, "PounceMsg", _T(""));
+ }
}
+ WindowList_Remove(hWindowList,(HWND)ack->hProcess);
}
- WindowList_Remove(hWindowList,(HWND)ack->hProcess);
- }
- return 0;
+ }
+ return 0;
}
int BuddyPounceOptInit(WPARAM wParam, LPARAM)
@@ -145,8 +145,7 @@ int CheckDate(MCONTACT hContact) void SendPounce(TCHAR *text, MCONTACT hContact)
{
- ptrA pszUtf(mir_utf8encodeT(text));
- if (HANDLE hSendId = (HANDLE)CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)pszUtf))
+ if (HANDLE hSendId = (HANDLE)CallContactService(hContact, PSS_MESSAGE, 0, T2Utf(text)))
WindowList_Add(hWindowList, (HWND)hSendId, hContact);
}
diff --git a/plugins/Clist_modern/src/modern_clcpaint.cpp b/plugins/Clist_modern/src/modern_clcpaint.cpp index cca4d6844b..840ffd7ca3 100644 --- a/plugins/Clist_modern/src/modern_clcpaint.cpp +++ b/plugins/Clist_modern/src/modern_clcpaint.cpp @@ -642,28 +642,21 @@ MODERNMASK *CLCPaint::_GetCLCContactRowBackModernMask(ClcGroup *group, ClcContac _itoa(index, buf, BUF2SIZE);
AddParam(mpModernMask, HASH[hi_Index], buf, 0);
{
- TCHAR *b2 = mir_tstrdup(Drawing->szText);
- int i, m = (int)mir_tstrlen(b2);
- for (i = 0; i < m; i++)
+ TCHAR *b2 = NEWTSTR_ALLOCA(Drawing->szText);
+ for (int i = 0; b2[i] != 0; i++)
if (b2[i] == _T(','))
b2[i] = _T('.');
- char* b3 = mir_utf8encodeT(b2);
- AddParam(mpModernMask, HASH[hi_Name], b3, 0);
- mir_free(b3);
- mir_free(b2);
+ AddParam(mpModernMask, HASH[hi_Name], T2Utf(b2), 0);
}
if (group->parent) {
- TCHAR *b2 = mir_tstrdup(group->parent->cl.items[0]->szText);
- int i, m = (int)mir_tstrlen(b2);
- for (i = 0; i < m; i++)
- if (b2[i] == _T(',')) b2[i] = _T('.');
-
- char * b3 = mir_utf8encodeT(b2);
- AddParam(mpModernMask, HASH[hi_Group], b3, 0);
- mir_free(b3);
- mir_free(b2);
+ TCHAR *b2 = NEWTSTR_ALLOCA(group->parent->cl.items[0]->szText);
+ for (int i = 0; b2[i] != 0; i++)
+ if (b2[i] == _T(','))
+ b2[i] = _T('.');
+
+ AddParam(mpModernMask, HASH[hi_Group], T2Utf(b2), 0);
}
return mpModernMask;
}
diff --git a/plugins/Clist_modern/src/modern_statusbar.cpp b/plugins/Clist_modern/src/modern_statusbar.cpp index 82d031905c..4e6ea38bc4 100644 --- a/plugins/Clist_modern/src/modern_statusbar.cpp +++ b/plugins/Clist_modern/src/modern_statusbar.cpp @@ -814,12 +814,10 @@ LRESULT CALLBACK ModernStatusProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa char protoF[sizeof(g_CluiData.protoFilter)];
mir_snprintf(protoF, SIZEOF(protoF), "%s|", accs[i]->szModuleName);
if (strstri(g_CluiData.protoFilter, protoF)) {
- char * temp = mir_utf8encodeT(accs[i]->tszAccountName);
if (!first)
mir_strncat(filterName, "; ", SIZEOF(filterName) - mir_strlen(filterName));
- mir_strncat(filterName, temp, SIZEOF(filterName) - mir_strlen(filterName));
+ mir_strncat(filterName, T2Utf(accs[i]->tszAccountName), SIZEOF(filterName) - mir_strlen(filterName));
first = false;
- mir_free(temp);
}
}
diff --git a/plugins/Clist_modern/src/modern_viewmodebar.cpp b/plugins/Clist_modern/src/modern_viewmodebar.cpp index 08a2a800c6..4d1b3cc2c6 100644 --- a/plugins/Clist_modern/src/modern_viewmodebar.cpp +++ b/plugins/Clist_modern/src/modern_viewmodebar.cpp @@ -433,7 +433,7 @@ void SaveState() if (szTempModeName) {
SendDlgItemMessage(clvmHwnd, IDC_VIEWMODES, LB_GETTEXT, clvm_curItem, (LPARAM)szTempModeName);
- ptrA szModeName(mir_utf8encodeT(szTempModeName));
+ T2Utf szModeName(szTempModeName);
DWORD dwGlobalMask = GetMaskForItem(hInfoItem);
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
@@ -483,13 +483,7 @@ void SaveState() static void UpdateFilters()
{
- DBVARIANT dbv_pf = { 0 };
- DBVARIANT dbv_gf = { 0 };
char szSetting[128];
- TCHAR *szTempBuf = NULL;
- char *szBuf = NULL;
- int iLen;
- DWORD statusMask = 0;
DWORD dwFlags;
DWORD opt;
TCHAR szTemp[100];
@@ -497,31 +491,35 @@ static void UpdateFilters() if (clvm_curItem == LB_ERR)
return;
- iLen = SendDlgItemMessageA(clvmHwnd, IDC_VIEWMODES, LB_GETTEXTLEN, clvm_curItem, 0);
-
+ int iLen = SendDlgItemMessageA(clvmHwnd, IDC_VIEWMODES, LB_GETTEXTLEN, clvm_curItem, 0);
if (iLen == 0)
return;
- szTempBuf = (TCHAR *)mir_alloc((iLen + 1)*sizeof(TCHAR));
+ TCHAR *szTempBuf = (TCHAR*)_alloca((iLen + 1)*sizeof(TCHAR));
SendDlgItemMessage(clvmHwnd, IDC_VIEWMODES, LB_GETTEXT, clvm_curItem, (LPARAM)szTempBuf);
- szBuf = mir_utf8encodeT(szTempBuf);
+ T2Utf szBuf(szTempBuf);
mir_strncpy(g_szModename, szBuf, SIZEOF(g_szModename));
- g_szModename[SIZEOF(g_szModename) - 1] = 0;
+
mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("Configuring view mode: %s"), szTempBuf);
SetDlgItemText(clvmHwnd, IDC_CURVIEWMODE2, szTemp);
+
mir_snprintf(szSetting, SIZEOF(szSetting), "%c%s_PF", 246, szBuf);
- if (db_get_s(NULL, CLVM_MODULE, szSetting, &dbv_pf))
- goto cleanup;
+ ptrA szPF(db_get_sa(NULL, CLVM_MODULE, szSetting));
+ if (szPF == NULL)
+ return;
+
mir_snprintf(szSetting, SIZEOF(szSetting), "%c%s_GF", 246, szBuf);
- if (db_get_ts(NULL, CLVM_MODULE, szSetting, &dbv_gf))
- goto cleanup;
+ ptrT szGF(db_get_tsa(NULL, CLVM_MODULE, szSetting));
+ if (szGF == NULL)
+ return;
+
mir_snprintf(szSetting, SIZEOF(szSetting), "%c%s_OPT", 246, szBuf);
- if ((opt = db_get_dw(NULL, CLVM_MODULE, szSetting, -1)) != -1) {
+ if ((opt = db_get_dw(NULL, CLVM_MODULE, szSetting, -1)) != -1)
SendDlgItemMessage(clvmHwnd, IDC_AUTOCLEARSPIN, UDM_SETPOS, 0, MAKELONG(LOWORD(opt), 0));
- }
+
mir_snprintf(szSetting, SIZEOF(szSetting), "%c%s_SM", 246, szBuf);
- statusMask = db_get_dw(NULL, CLVM_MODULE, szSetting, 0);
+ DWORD statusMask = db_get_dw(NULL, CLVM_MODULE, szSetting, 0);
mir_snprintf(szSetting, SIZEOF(szSetting), "%c%s_SSM", 246, szBuf);
stickyStatusMask = db_get_dw(NULL, CLVM_MODULE, szSetting, -1);
dwFlags = db_get_dw(NULL, CLVM_MODULE, szBuf, 0);
@@ -540,7 +538,7 @@ static void UpdateFilters() item.iItem = i;
SendMessageA(hwndList, LVM_GETITEMA, 0, (LPARAM)&item);
mir_snprintf(szMask, SIZEOF(szMask), "%s|", szTemp);
- if (dbv_pf.pszVal && strstr(dbv_pf.pszVal, szMask))
+ if (szPF && strstr(szPF, szMask))
ListView_SetCheckState(hwndList, i, TRUE)
else
ListView_SetCheckState(hwndList, i, FALSE);
@@ -563,7 +561,7 @@ static void UpdateFilters() item.iItem = i;
SendMessage(hwndList, LVM_GETITEM, 0, (LPARAM)&item);
mir_sntprintf(szMask, SIZEOF(szMask), _T("%s|"), szTemp);
- if (dbv_gf.ptszVal && _tcsstr(dbv_gf.ptszVal, szMask))
+ if (szGF && _tcsstr(szGF, szMask))
ListView_SetCheckState(hwndList, i, TRUE)
else
ListView_SetCheckState(hwndList, i, FALSE);
@@ -586,12 +584,8 @@ static void UpdateFilters() {
int useLastMsg = dwFlags & CLVM_USELASTMSG;
-
int useGroupsState = (dwFlags & CLVM_USEGROUPS) ? BST_CHECKED : (dwFlags & CLVM_DONOTUSEGROUPS) ? BST_UNCHECKED : BST_INDETERMINATE;
- DWORD lmdat;
- BYTE bTmp;
-
CheckDlgButton(clvmHwnd, IDC_LASTMSG, useLastMsg ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(clvmHwnd, IDC_USEGROUPS, useGroupsState ? BST_CHECKED : BST_UNCHECKED);
@@ -600,21 +594,16 @@ static void UpdateFilters() EnableWindow(GetDlgItem(clvmHwnd, IDC_LASTMESSAGEUNIT), useLastMsg);
mir_snprintf(szSetting, SIZEOF(szSetting), "%c%s_LM", 246, szBuf);
- lmdat = db_get_dw(NULL, CLVM_MODULE, szSetting, 0);
+ DWORD lmdat = db_get_dw(NULL, CLVM_MODULE, szSetting, 0);
SetDlgItemInt(clvmHwnd, IDC_LASTMSGVALUE, LOWORD(lmdat), FALSE);
- bTmp = LOBYTE(HIWORD(lmdat));
+ BYTE bTmp = LOBYTE(HIWORD(lmdat));
SendDlgItemMessage(clvmHwnd, IDC_LASTMESSAGEOP, CB_SETCURSEL, bTmp, 0);
bTmp = HIBYTE(HIWORD(lmdat));
SendDlgItemMessage(clvmHwnd, IDC_LASTMESSAGEUNIT, CB_SETCURSEL, bTmp, 0);
}
ShowPage(clvmHwnd, 0);
-cleanup:
- db_free(&dbv_pf);
- db_free(&dbv_gf);
- mir_free(szBuf);
- mir_free(szTempBuf);
}
void DeleteViewMode(char * szName)
@@ -763,26 +752,16 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (MessageBox(0, TranslateT("Really delete this view mode? This cannot be undone"), TranslateT("Delete a view mode"), MB_YESNO | MB_ICONQUESTION) == IDYES) {
int iLen = SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETTEXTLEN, SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0), 0);
if (iLen) {
- //TODO: UNICODE
- TCHAR *szTempBuf = (TCHAR*)malloc((iLen + 1)*sizeof(TCHAR));
- char *szBuf = NULL;
- if (szTempBuf) {
- SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETTEXT, SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0), (LPARAM)szTempBuf);
- szBuf = mir_utf8encodeT(szTempBuf);
- DeleteViewMode(szBuf);
-
- SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_DELETESTRING, SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0), 0);
- if (SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_SETCURSEL, 0, 0) != LB_ERR) {
- clvm_curItem = 0;
- UpdateFilters();
- }
- else clvm_curItem = -1;
-
- if (szBuf && szBuf != (char*)szTempBuf) mir_free(szBuf);
- if (szTempBuf) free(szTempBuf);
- szTempBuf = NULL;
- szBuf = NULL;
+ TCHAR *szTempBuf = (TCHAR*)_alloca((iLen + 1)*sizeof(TCHAR));
+ SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETTEXT, SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0), (LPARAM)szTempBuf);
+ DeleteViewMode(T2Utf(szTempBuf));
+
+ SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_DELETESTRING, SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0), 0);
+ if (SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_SETCURSEL, 0, 0) != LB_ERR) {
+ clvm_curItem = 0;
+ UpdateFilters();
}
+ else clvm_curItem = -1;
}
}
break;
@@ -795,7 +774,7 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP szBuf[255] = 0;
if (szBuf[0] != 0) {
- char *szUTF8Buf = mir_utf8encodeT(szBuf);
+ T2Utf szUTF8Buf(szBuf);
if (db_get_dw(NULL, CLVM_MODULE, szUTF8Buf, -1) != -1)
MessageBox(0, TranslateT("A view mode with this name does already exist"), TranslateT("Duplicate name"), MB_OK);
@@ -811,7 +790,6 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP }
}
SetDlgItemText(hwndDlg, IDC_NEWVIEMODE, _T(""));
- mir_free(szUTF8Buf);
}
EnableWindow(GetDlgItem(hwndDlg, IDC_ADDVIEWMODE), FALSE);
UpdateFilters();
@@ -1114,7 +1092,7 @@ LRESULT CALLBACK ViewModeFrameWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM mii.cch = 256;
GetMenuItemInfo(hViewModeMenu, selection, FALSE, &mii);
- ApplyViewMode(ptrA(mir_utf8encodeT(szTemp)));
+ ApplyViewMode(T2Utf(szTemp));
}
}
break;
diff --git a/plugins/CrashDumper/src/crshdmp.cpp b/plugins/CrashDumper/src/crshdmp.cpp index a20f5c82d0..6176b145e9 100644 --- a/plugins/CrashDumper/src/crshdmp.cpp +++ b/plugins/CrashDumper/src/crshdmp.cpp @@ -75,10 +75,7 @@ INT_PTR StoreVersionInfoToFile(WPARAM, LPARAM lParam) CMString buffer;
PrintVersionInfo(buffer, (unsigned int)lParam | VI_FLAG_PRNVAR);
- char* bufu = mir_utf8encodeT(buffer.c_str());
- WriteUtfFile(hDumpFile, bufu);
- mir_free(bufu);
-
+ WriteUtfFile(hDumpFile, T2Utf(buffer.c_str()));
CloseHandle(hDumpFile);
ShowMessage(3, TranslateT("Version Info stored into file %s"), path);
diff --git a/plugins/Db3x_mmap/src/dbcrypt.cpp b/plugins/Db3x_mmap/src/dbcrypt.cpp index fdff3ce5ec..f80dd8f6e2 100644 --- a/plugins/Db3x_mmap/src/dbcrypt.cpp +++ b/plugins/Db3x_mmap/src/dbcrypt.cpp @@ -232,7 +232,7 @@ void CDb3Mmap::SetPassword(LPCTSTR ptszPassword) }
else {
m_bUsesPassword = true;
- m_crypto->setPassword(ptrA(mir_utf8encodeT(ptszPassword)));
+ m_crypto->setPassword(T2Utf(ptszPassword));
}
UpdateMenuItem();
}
diff --git a/plugins/Db3x_mmap/src/ui.cpp b/plugins/Db3x_mmap/src/ui.cpp index 4a6cb3d543..ec5fcb4184 100644 --- a/plugins/Db3x_mmap/src/ui.cpp +++ b/plugins/Db3x_mmap/src/ui.cpp @@ -125,7 +125,7 @@ bool CDb3Mmap::EnterPassword(const BYTE *pKey, const size_t keyLen) if (IDOK != DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_LOGIN), 0, sttEnterPassword, (LPARAM)¶m))
return false;
- m_crypto->setPassword(ptrA(mir_utf8encodeT(param.newPass)));
+ m_crypto->setPassword(T2Utf(param.newPass));
if (m_crypto->setKey(pKey, keyLen)) {
m_bUsesPassword = true;
SecureZeroMemory(¶m, sizeof(param));
@@ -143,8 +143,7 @@ static bool CheckOldPassword(HWND hwndDlg, CDb3Mmap *db) if (db->usesPassword()) {
TCHAR buf[100];
GetDlgItemText(hwndDlg, IDC_OLDPASS, buf, SIZEOF(buf));
- ptrA oldPass(mir_utf8encodeT(buf));
- if (!db->m_crypto->checkPassword(oldPass)) {
+ if (!db->m_crypto->checkPassword(T2Utf(buf))) {
SetDlgItemText(hwndDlg, IDC_HEADERBAR, TranslateT("Wrong old password entered!"));
return false;
}
diff --git a/plugins/IEView/src/TemplateHTMLBuilder.cpp b/plugins/IEView/src/TemplateHTMLBuilder.cpp index 34b013d07b..e81e1fd85a 100644 --- a/plugins/IEView/src/TemplateHTMLBuilder.cpp +++ b/plugins/IEView/src/TemplateHTMLBuilder.cpp @@ -146,7 +146,7 @@ char *TemplateHTMLBuilder::timestampToString(DWORD dwFlags, time_t check, int mo }
}
- mir_strncpy(szResult, ptrA(mir_utf8encodeT(str)), 500);
+ mir_strncpy(szResult, T2Utf(str), 500);
return szResult;
}
diff --git a/plugins/MirOTR/src/dialogs.cpp b/plugins/MirOTR/src/dialogs.cpp index f724c5a371..350d761d8d 100644 --- a/plugins/MirOTR/src/dialogs.cpp +++ b/plugins/MirOTR/src/dialogs.cpp @@ -266,34 +266,32 @@ INT_PTR CALLBACK DlgSMPResponseProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA case WM_COMMAND: switch ( HIWORD( wParam )) { - case BN_CLICKED: - { - ConnContext *context = (ConnContext *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - switch ( LOWORD( wParam )) { - case IDOK: - { - SMPInitUpdateDialog(context, true); - - int len = SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD2, WM_GETTEXTLENGTH, 0, 0); - TCHAR *answer = new TCHAR[len+1]; - GetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD2, answer, len+1); - char *ans = mir_utf8encodeT(answer); - delete[] answer; - - otr_continue_smp(context, (const unsigned char *)ans, mir_strlen(ans)); - mir_free(ans); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, NULL); - DestroyWindow(hwndDlg); - }break; - case IDCANCEL: - smp_for_contact.erase(context->app_data); - DestroyWindow(hwndDlg); - break; - } + case BN_CLICKED: + ConnContext *context = (ConnContext *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + switch ( LOWORD( wParam )) { + case IDOK: + SMPInitUpdateDialog(context, true); + { + int len = SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD2, WM_GETTEXTLENGTH, 0, 0); + TCHAR *answer = new TCHAR[len+1]; + GetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD2, answer, len+1); + + T2Utf ans(answer); + otr_continue_smp(context, (const unsigned char *)ans, mir_strlen(ans)); + delete[] answer; + + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, NULL); + DestroyWindow(hwndDlg); } + break; + + case IDCANCEL: + smp_for_contact.erase(context->app_data); + DestroyWindow(hwndDlg); + break; + } } break; - } return FALSE; @@ -429,19 +427,17 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA int len = SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD1, WM_GETTEXTLENGTH, 0, 0); TCHAR *question = new TCHAR[len+1]; GetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD1, question, len+1); - char *quest = mir_utf8encodeT(question); + T2Utf quest(question); delete question; len = SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD2, WM_GETTEXTLENGTH, 0, 0); TCHAR *answer = new TCHAR[len+1]; GetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD2, answer, len+1); - char *ans = mir_utf8encodeT(answer); + T2Utf ans(answer); delete answer; SMPInitUpdateDialog(context, false); otr_start_smp(context, quest, (const unsigned char*)ans, mir_strlen(ans)); - mir_free(quest); - mir_free(ans); } }else if (_tcsncmp(msg, TranslateT(LANG_SMPTYPE_PASSWORD), 255)==0) { @@ -453,12 +449,11 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA int len = SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD2, WM_GETTEXTLENGTH, 0, 0); TCHAR *answer = new TCHAR[len+1]; GetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD2, answer, len+1); - char *ans = mir_utf8encodeT(answer); + T2Utf ans(answer); delete[] answer; SMPInitUpdateDialog(context, false); otr_start_smp(context, NULL, (const unsigned char*)ans, mir_strlen(ans)); - mir_free(ans); } }else break; diff --git a/plugins/MirOTR/src/options.cpp b/plugins/MirOTR/src/options.cpp index 72b5d0d023..21ac240c25 100644 --- a/plugins/MirOTR/src/options.cpp +++ b/plugins/MirOTR/src/options.cpp @@ -137,7 +137,7 @@ void ReadPrivkeyFiles() static INT_PTR CALLBACK DlgProcMirOTROpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - TCHAR *prefix; char* prefix_utf; + TCHAR *prefix; switch ( msg ) { case WM_INITDIALOG: TranslateDialogDefault( hwndDlg ); @@ -218,16 +218,15 @@ static INT_PTR CALLBACK DlgProcMirOTROpts(HWND hwndDlg, UINT msg, WPARAM wParam, options.end_offline = (TRUE==IsDlgButtonChecked(hwndDlg, IDC_CHK_ENDOFFLINE)); options.end_window_close = (TRUE==IsDlgButtonChecked(hwndDlg, IDC_CHK_ENDCLOSE)); - prefix = (TCHAR*)mir_alloc(sizeof(TCHAR)*OPTIONS_PREFIXLEN); + prefix = (TCHAR*)_alloca(sizeof(TCHAR)*OPTIONS_PREFIXLEN); GetDlgItemText(hwndDlg, IDC_ED_PREFIX, prefix, OPTIONS_PREFIXLEN); - prefix_utf = mir_utf8encodeT(prefix); - mir_free(prefix); - if(!prefix_utf[0]){ + + T2Utf prefix_utf(prefix); + if (!mir_strlen(prefix_utf)) { SetDlgItemTextA(hwndDlg, IDC_ED_PREFIX, OPTIONS_DEFAULT_PREFIX); mir_strncpy(options.prefix, OPTIONS_DEFAULT_PREFIX, OPTIONS_PREFIXLEN); - } else - mir_strncpy(options.prefix, prefix_utf, OPTIONS_PREFIXLEN); - mir_free(prefix_utf); + } + else mir_strncpy(options.prefix, prefix_utf, OPTIONS_PREFIXLEN); SaveOptions(); return TRUE; diff --git a/plugins/MirOTR/src/svcs_menu.cpp b/plugins/MirOTR/src/svcs_menu.cpp index 93771cfa23..86a8e44a37 100644 --- a/plugins/MirOTR/src/svcs_menu.cpp +++ b/plugins/MirOTR/src/svcs_menu.cpp @@ -39,9 +39,9 @@ int StartOTR(MCONTACT hContact) { } *msgoff='\0'; mir_free(nick); - char* msg_utf8 = mir_utf8encodeT(msg); + + T2Utf msg_utf8(msg); otr_gui_inject_message((void*)hContact, proto, proto, uname, msg_utf8 ? msg_utf8 : MIROTR_PROTO_HELLO); - mir_free(msg_utf8); } #endif mir_free(uname); diff --git a/plugins/MirOTR/src/utils.cpp b/plugins/MirOTR/src/utils.cpp index 93375922e8..5e9715e256 100644 --- a/plugins/MirOTR/src/utils.cpp +++ b/plugins/MirOTR/src/utils.cpp @@ -316,15 +316,13 @@ void ShowErrorUtf(char* msg) { void ShowMessageInline(const MCONTACT hContact, const TCHAR *msg) { TCHAR buff[1024]; mir_sntprintf(buff, SIZEOF(buff), _T("%s%s"), TranslateT(LANG_INLINE_PREFIX), msg); + T2Utf utf(buff); PROTORECVEVENT pre = {0}; pre.timestamp = time(0); - char *utf = mir_utf8encodeT(buff); pre.szMessage = utf; pre.flags = PREF_BYPASS_OTR; ProtoChainRecvMsg(hContact, &pre); - - mir_free(utf); } void ShowMessageInlineUtf(const MCONTACT hContact, const char *msg) { diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp index 7f38c49e5a..528ff489d5 100755 --- a/plugins/Msg_Export/src/utils.cpp +++ b/plugins/Msg_Export/src/utils.cpp @@ -456,7 +456,7 @@ static bool bWriteTextToFile(HANDLE hFile, const TCHAR *pszSrc, bool bUtf8File, return bWriteToFile(hFile, pszAstr, -1);
}
- ptrA pszUtf8(mir_utf8encodeT(pszSrc));
+ T2Utf pszUtf8(pszSrc);
return bWriteToFile(hFile, pszUtf8, -1);
}
diff --git a/plugins/NewAwaySysMod/src/MsgEventAdded.cpp b/plugins/NewAwaySysMod/src/MsgEventAdded.cpp index 94b5eb018f..0d6e151793 100644 --- a/plugins/NewAwaySysMod/src/MsgEventAdded.cpp +++ b/plugins/NewAwaySysMod/src/MsgEventAdded.cpp @@ -58,7 +58,7 @@ void __cdecl AutoreplyDelayThread(void *_ad) return;
}
- ptrA pszReply(mir_utf8encodeT(ad->Reply));
+ T2Utf pszReply(ad->Reply);
int ReplyLen = (int)mir_strlen(pszReply);
CallContactService(ad->hContact, PSS_MESSAGE, 0, (LPARAM)pszReply);
diff --git a/plugins/NewXstatusNotify/src/main.cpp b/plugins/NewXstatusNotify/src/main.cpp index d7e7e25505..a98bf4b3cf 100644 --- a/plugins/NewXstatusNotify/src/main.cpp +++ b/plugins/NewXstatusNotify/src/main.cpp @@ -262,9 +262,8 @@ bool SkipHiddenContact(MCONTACT hContact) void LogSMsgToDB(STATUSMSGINFO *smi, const TCHAR *tmplt)
{
- TCHAR *str = GetStr(smi, tmplt);
-
- char *blob = mir_utf8encodeT(str);
+ ptrT str(GetStr(smi, tmplt));
+ T2Utf blob(str);
DBEVENTINFO dbei = { 0 };
dbei.cbSize = sizeof(dbei);
@@ -276,8 +275,6 @@ void LogSMsgToDB(STATUSMSGINFO *smi, const TCHAR *tmplt) dbei.timestamp = (DWORD)time(NULL);
dbei.szModule = MODULE;
MEVENT hDBEvent = db_event_add(smi->hContact, &dbei);
- mir_free(blob);
- mir_free(str);
if (opt.SMsgLogToDB_WinOpen && opt.SMsgLogToDB_Remove) {
DBEVENT *dbevent = (DBEVENT *)mir_alloc(sizeof(DBEVENT));
@@ -353,7 +350,7 @@ int ContactStatusChanged(MCONTACT hContact, WORD oldStatus, WORD newStatus) if (opt.LogToDB && (!opt.LogToDB_WinOpen || CheckMsgWnd(hContact))) {
TCHAR stzStatusText[MAX_SECONDLINE] = { 0 };
GetStatusText(hContact, newStatus, oldStatus, stzStatusText);
- char *blob = mir_utf8encodeT(stzStatusText);
+ T2Utf blob(stzStatusText);
DBEVENTINFO dbei = { 0 };
dbei.cbSize = sizeof(dbei);
@@ -365,7 +362,6 @@ int ContactStatusChanged(MCONTACT hContact, WORD oldStatus, WORD newStatus) dbei.timestamp = (DWORD)time(NULL);
dbei.szModule = MODULE;
MEVENT hDBEvent = db_event_add(hContact, &dbei);
- mir_free(blob);
if (opt.LogToDB_WinOpen && opt.LogToDB_Remove) {
DBEVENT *dbevent = (DBEVENT *)mir_alloc(sizeof(DBEVENT));
@@ -636,11 +632,11 @@ int ProcessStatusMessage(DBCONTACTWRITESETTING *cws, MCONTACT hContact) if (_stricmp(szProto, "mRadio") == 0 && !cws->value.type == DBVT_DELETED) {
TCHAR buf[MAX_PATH];
mir_sntprintf(buf, SIZEOF(buf), _T(" (%s)"), TranslateT("connecting"));
- ptrA pszUtf(mir_utf8encodeT(buf));
+ T2Utf pszUtf(buf);
mir_sntprintf(buf, SIZEOF(buf), _T(" (%s)"), TranslateT("aborting"));
- ptrA pszUtf2(mir_utf8encodeT(buf));
+ T2Utf pszUtf2(buf);
mir_sntprintf(buf, SIZEOF(buf), _T(" (%s)"), TranslateT("playing"));
- ptrA pszUtf3(mir_utf8encodeT(buf));
+ T2Utf pszUtf3(buf);
if (_stricmp(cws->value.pszVal, pszUtf) == 0 || _stricmp(cws->value.pszVal, pszUtf2) == 0 || _stricmp(cws->value.pszVal, pszUtf3) == 0)
goto skip_notify;
}
diff --git a/plugins/NewXstatusNotify/src/utils.cpp b/plugins/NewXstatusNotify/src/utils.cpp index 951a2dd551..7dd1e9dc58 100644 --- a/plugins/NewXstatusNotify/src/utils.cpp +++ b/plugins/NewXstatusNotify/src/utils.cpp @@ -87,11 +87,7 @@ void LogToFile(TCHAR *stzText) {
FILE *fp = _tfopen(opt.LogFilePath, _T("a+b, ccs=UTF-8"));
if (fp) {
- char *encodedText = mir_utf8encodeT(stzText);
- if (encodedText) {
- fprintf(fp, encodedText);
- mir_free(encodedText);
- }
+ fprintf(fp, T2Utf(stzText));
fclose(fp);
}
}
diff --git a/plugins/NewXstatusNotify/src/xstatus.cpp b/plugins/NewXstatusNotify/src/xstatus.cpp index 07bfbf22be..911c595945 100644 --- a/plugins/NewXstatusNotify/src/xstatus.cpp +++ b/plugins/NewXstatusNotify/src/xstatus.cpp @@ -294,7 +294,7 @@ void LogChangeToDB(XSTATUSCHANGE *xsc) if (opt.XLogToDB) {
db_set_ws(xsc->hContact, MODULE, DB_LASTLOG, stzLogText);
- ptrA blob(mir_utf8encodeT(stzLogText));
+ T2Utf blob(stzLogText);
DBEVENTINFO dbei = { 0 };
dbei.cbSize = sizeof(dbei);
diff --git a/plugins/NewsAggregator/Src/CheckFeed.cpp b/plugins/NewsAggregator/Src/CheckFeed.cpp index 35cdab14fa..613a3e2981 100644 --- a/plugins/NewsAggregator/Src/CheckFeed.cpp +++ b/plugins/NewsAggregator/Src/CheckFeed.cpp @@ -123,7 +123,7 @@ static void XmlToMsg(MCONTACT hContact, CMString &title, CMString &link, CMStrin olddbei.cbSize = sizeof(olddbei);
bool MesExist = false;
- ptrA pszTemp(mir_utf8encodeT(message));
+ T2Utf pszTemp(message);
DWORD cbMemoLen = 10000, cbOrigLen = (DWORD)mir_strlen(pszTemp);
BYTE *pbBuffer = (BYTE*)mir_alloc(cbMemoLen);
for (MEVENT hDbEvent = db_event_last(hContact); hDbEvent; hDbEvent = db_event_prev(hContact, hDbEvent)) {
@@ -148,7 +148,7 @@ static void XmlToMsg(MCONTACT hContact, CMString &title, CMString &link, CMStrin if (stamp == 0)
stamp = time(NULL);
- ptrA pszMessage(mir_utf8encodeT(message));
+ T2Utf pszMessage(message);
PROTORECVEVENT recv = { 0 };
recv.timestamp = (DWORD)stamp;
diff --git a/plugins/Nudge/src/main.cpp b/plugins/Nudge/src/main.cpp index 7859e28be8..b515b3dbff 100644 --- a/plugins/Nudge/src/main.cpp +++ b/plugins/Nudge/src/main.cpp @@ -476,7 +476,7 @@ void Nudge_ShowPopup(CNudgeElement *n, MCONTACT hContact, TCHAR * Message) void Nudge_SentStatus(CNudgeElement *n, MCONTACT hContact)
{
- char *buff = mir_utf8encodeT(n->senText);
+ T2Utf buff(n->senText);
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = MODULENAME;
@@ -486,12 +486,11 @@ void Nudge_SentStatus(CNudgeElement *n, MCONTACT hContact) dbei.cbBlob = (DWORD)mir_strlen(buff) + 1;
dbei.pBlob = (PBYTE)buff;
db_event_add(hContact, &dbei);
- mir_free(buff);
}
void Nudge_ShowStatus(CNudgeElement *n, MCONTACT hContact, DWORD timestamp)
{
- char *buff = mir_utf8encodeT(n->recText);
+ T2Utf buff(n->recText);
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = MODULENAME;
@@ -501,7 +500,6 @@ void Nudge_ShowStatus(CNudgeElement *n, MCONTACT hContact, DWORD timestamp) dbei.cbBlob = (DWORD)mir_strlen(buff) + 1;
dbei.pBlob = (PBYTE)buff;
db_event_add(hContact, &dbei);
- mir_free(buff);
}
void Nudge_AddAccount(PROTOACCOUNT *proto)
diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp index 574115edcf..ee37144fe8 100644 --- a/plugins/Popup/src/popup_wnd2.cpp +++ b/plugins/Popup/src/popup_wnd2.cpp @@ -860,8 +860,8 @@ LRESULT CALLBACK ReplyEditWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM }
{
- ptrA buf(mir_utf8encodeT(msg));
- CallContactService(dat->hContact, PSS_MESSAGE, 0, (LPARAM)buf);
+ T2Utf buf(msg);
+ CallContactService(dat->hContact, PSS_MESSAGE, 0, buf);
AddMessageToDB(dat->hContact, buf);
}
// fall through
diff --git a/plugins/Quotes/src/ImportExport.cpp b/plugins/Quotes/src/ImportExport.cpp index af8faee952..b3dc6e2a9d 100644 --- a/plugins/Quotes/src/ImportExport.cpp +++ b/plugins/Quotes/src/ImportExport.cpp @@ -401,12 +401,11 @@ namespace }
else if (0 == quotes_stricmp(g_pszXmlTypeUtf8, sType.c_str()))
{
- dbs.value.pszVal = mir_utf8encodeT(sValue.c_str());
+ T2Utf szValue(sValue.c_str());
+ dbs.value.pszVal = szValue;
dbs.value.type = DBVT_UTF8;
if (set_contact_settings(hContact, dbs))
++cCreatedRecords;
-
- mir_free(dbs.value.pszVal);
}
else if (0 == quotes_stricmp(g_pszXmlTypeWchar, sType.c_str()))
{
diff --git a/plugins/Quotes/src/QuotesProviderBase.cpp b/plugins/Quotes/src/QuotesProviderBase.cpp index e080025278..74dbfc01f0 100644 --- a/plugins/Quotes/src/QuotesProviderBase.cpp +++ b/plugins/Quotes/src/QuotesProviderBase.cpp @@ -566,7 +566,7 @@ namespace const tstring& rsFormat)
{
tstring s = format_rate(pProvider, hContact, rsFormat);
- ptrA psz(mir_utf8encodeT(s.c_str()));
+ T2Utf psz(s.c_str());
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = QUOTES_PROTOCOL_NAME;
diff --git a/plugins/Quotes/src/XMLEngineMI.cpp b/plugins/Quotes/src/XMLEngineMI.cpp index 7e9e3f6016..871cc2ed4f 100644 --- a/plugins/Quotes/src/XMLEngineMI.cpp +++ b/plugins/Quotes/src/XMLEngineMI.cpp @@ -114,13 +114,7 @@ namespace safe_string<TCHAR> ss(xi.toString(m_hXML, NULL));
if (ss.m_p)
- {
- mir_safe_string<char> mss(mir_utf8encodeT(ss.m_p));
- if (mss.m_p)
- {
- o << mss.m_p;
- }
- }
+ o << (char*)T2Utf(ss.m_p);
}
private:
diff --git a/plugins/Scriver/src/utils.cpp b/plugins/Scriver/src/utils.cpp index afb697e2fc..1d4e9b829f 100644 --- a/plugins/Scriver/src/utils.cpp +++ b/plugins/Scriver/src/utils.cpp @@ -384,7 +384,7 @@ void SearchWord(TCHAR * word, int engine) {
char szURL[4096];
if (word && word[0]) {
- ptrA wordUTF(mir_utf8encodeT(word));
+ T2Utf wordUTF(word);
ptrA wordURL(mir_urlEncode(wordUTF));
switch (engine) {
case SEARCHENGINE_WIKIPEDIA:
diff --git a/plugins/SimpleAR/src/Main.cpp b/plugins/SimpleAR/src/Main.cpp index 5b468ea34b..904cf42461 100644 --- a/plugins/SimpleAR/src/Main.cpp +++ b/plugins/SimpleAR/src/Main.cpp @@ -220,17 +220,16 @@ INT addEvent(WPARAM hContact, LPARAM hDBEvent) mir_sntprintf(ptszTemp2, msgLen+5, _T("%s\r\n\r\n%s"), ptszTemp.c_str(), dbv.ptszVal);
if (ServiceExists(MS_VARS_FORMATSTRING))
{
- FORMATINFO fi;
-
- memset(&fi, 0, sizeof(fi));
+ FORMATINFO fi = { 0 };
fi.cbSize = sizeof(fi);
fi.flags = FIF_TCHAR;
fi.tszFormat = ptszTemp2;
ptszTemp = (TCHAR*)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
- }else
- ptszTemp = Utils_ReplaceVarsT(ptszTemp2);
- char* pszUtf = mir_utf8encodeT(ptszTemp);
- CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)pszUtf);
+ }
+ else ptszTemp = Utils_ReplaceVarsT(ptszTemp2);
+
+ T2Utf pszUtf(ptszTemp);
+ CallContactService(hContact, PSS_MESSAGE, 0, pszUtf);
dbei.cbSize = sizeof(dbei);
dbei.eventType = EVENTTYPE_MESSAGE;
@@ -242,7 +241,6 @@ INT addEvent(WPARAM hContact, LPARAM hDBEvent) db_event_add(hContact, &dbei);
mir_free(ptszTemp2);
- mir_free(pszUtf);
if (dbvNick.ptszVal)
db_free(&dbvNick);
if (dbvHead.ptszVal)
diff --git a/plugins/SkypeStatusChange/src/main.cpp b/plugins/SkypeStatusChange/src/main.cpp index 369d7b5e03..068342e2fc 100644 --- a/plugins/SkypeStatusChange/src/main.cpp +++ b/plugins/SkypeStatusChange/src/main.cpp @@ -195,14 +195,13 @@ LRESULT APIENTRY SkypeAPI_WindowProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) if ((NULL == pszStatusMsg) || (CALLSERVICE_NOTFOUND == reinterpret_cast<int>(pszStatusMsg)))
pszStatusMsg = reinterpret_cast<TCHAR*>(CallService(MS_AWAYMSG_GETSTATUSMSGT,(WPARAM)ms.m_nMirandaStatus,0));
- if (pszStatusMsg && reinterpret_cast<int>(pszStatusMsg) != CALLSERVICE_NOTFOUND) {
- char* pMsg = mir_utf8encodeT(pszStatusMsg);
+ if (pszStatusMsg && reinterpret_cast<LPARAM>(pszStatusMsg) != CALLSERVICE_NOTFOUND) {
+ T2Utf pMsg(pszStatusMsg);
mir_free(pszStatusMsg);
const char szSkypeCmdSetStatusMsg[] = "SET PROFILE MOOD_TEXT ";
::strncpy_s(szSkypeCmd,szSkypeCmdSetStatusMsg,sizeof(szSkypeCmdSetStatusMsg)/sizeof(szSkypeCmdSetStatusMsg[0]));
::strncat_s(szSkypeCmd, pMsg, SIZEOF(szSkypeCmd) - mir_strlen(szSkypeCmd));
- mir_free(pMsg);
DWORD cLength = static_cast<DWORD>(mir_strlen(szSkypeCmd));
diff --git a/plugins/Spamotron/src/spamotron.cpp b/plugins/Spamotron/src/spamotron.cpp index 2e5c9ed93b..3f7e3fe04e 100644 --- a/plugins/Spamotron/src/spamotron.cpp +++ b/plugins/Spamotron/src/spamotron.cpp @@ -173,7 +173,7 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam) db_unset(hContact, "CList", "NotOnList");
db_unset(hContact, "CList", "Delete");
if (_getOptB("ReplyOnSuccess", defaultReplyOnSuccess) && (_getCOptB(hContact, "MsgSent", 0))) {
- ptrA response(mir_utf8encodeT(_getOptS(buf, buflen, "SuccessResponse", defaultSuccessResponse)));
+ T2Utf response(_getOptS(buf, buflen, "SuccessResponse", defaultSuccessResponse));
CallContactService(hContact, PSS_MESSAGE, 0, response);
}
return 0;
@@ -239,7 +239,7 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam) db_unset(hContact, "CList", "Delete");
db_unset(hContact, "CList", "ResponseNum");
if (_getOptB("ReplyOnSuccess", defaultReplyOnSuccess)) {
- ptrA response(mir_utf8encodeT(_getOptS(buf, buflen, "SuccessResponse", defaultSuccessResponse)));
+ T2Utf response(_getOptS(buf, buflen, "SuccessResponse", defaultSuccessResponse));
CallContactService(hContact, PSS_MESSAGE, 0, response);
}
_notify(hContact, POPUP_APPROVED, TranslateT("Contact %s approved."), NULL);
@@ -368,7 +368,7 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam) else
_getOptS(challengeW, maxmsglen, "Challenge", defaultChallenge);
ReplaceVars(challengeW, maxmsglen);
- CallContactService(hContact, PSS_MESSAGE, 0, ptrA(mir_utf8encodeT(challengeW)));
+ CallContactService(hContact, PSS_MESSAGE, 0, T2Utf(challengeW));
_notify(hContact, POPUP_CHALLENGE, TranslateT("Sending plain challenge to %s."), message);
break;
@@ -383,7 +383,7 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam) _setCOptD(hContact, "ResponseNum", _getCOptD(hContact, "ResponseNum", -1) + 1);
ReplaceVarsNum(challengeW, maxmsglen, _getCOptD(hContact, "ResponseNum", 0));
- CallContactService(hContact, PSS_MESSAGE, 0, ptrA(mir_utf8encodeT(challengeW)));
+ CallContactService(hContact, PSS_MESSAGE, 0, T2Utf(challengeW));
_notify(hContact, POPUP_CHALLENGE, TranslateT("Sending round-robin challenge to %s."), message);
break;
@@ -396,7 +396,7 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam) 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)));
+ CallContactService(hContact, PSS_MESSAGE, 0, T2Utf(challengeW));
_notify(hContact, POPUP_CHALLENGE, TranslateT("Sending random challenge to %s."), message);
break;
@@ -410,7 +410,7 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam) _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)));
+ CallContactService(hContact, PSS_MESSAGE, 0, T2Utf(challengeW));
_notify(hContact, POPUP_CHALLENGE, TranslateT("Sending math expression challenge to %s."), message);
break;
}
diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp index 074835e644..d64543ff14 100644 --- a/plugins/TabSRMM/src/globals.cpp +++ b/plugins/TabSRMM/src/globals.cpp @@ -605,7 +605,7 @@ void CGlobals::logStatusChange(WPARAM wParam, const CContactCache *c) else
text.Format(TranslateT("changed status from %s to %s."), szOldStatus, szNewStatus);
- ptrA szMsg(mir_utf8encodeT(text));
+ T2Utf szMsg(text);
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.pBlob = (PBYTE)(char*)szMsg;
dbei.cbBlob = (int)mir_strlen(szMsg) + 1;
diff --git a/plugins/TabSRMM/src/infopanel.cpp b/plugins/TabSRMM/src/infopanel.cpp index 9e660bcf3d..caa644f02b 100644 --- a/plugins/TabSRMM/src/infopanel.cpp +++ b/plugins/TabSRMM/src/infopanel.cpp @@ -1326,10 +1326,7 @@ CTip::CTip(const HWND hwndParent, const MCONTACT hContact, const TCHAR *pszText, ::SendMessage(m_hRich, WM_SETFONT, (WPARAM)CInfoPanel::m_ipConfig.hFonts[IPFONTID_STATUS], 0);
m_hContact = hContact;
- if (pszText)
- m_pszText = mir_utf8encodeT(pszText);
- else
- m_pszText = 0;
+ m_pszText = mir_utf8encodeT(pszText);
m_panel = panel;
m_hwndParent = hwndParent;
mir_subclassWindow(m_hRich, RichEditProc);
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 37ec46d0ab..6ff33acddf 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -609,7 +609,7 @@ static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wPar if (OpenClipboard(hwnd)) {
HANDLE hClip = GetClipboardData(CF_TEXT);
if (hClip) {
- if (mir_strlen((char*)hClip) > mwdat->nMax) {
+ if ((int)mir_strlen((char*)hClip) > mwdat->nMax) {
TCHAR szBuffer[512];
if (M.GetByte("autosplit", 0))
mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("WARNING: The message you are trying to paste exceeds the message size limit for the active protocol. It will be sent in chunks of max %d characters"), mwdat->nMax - 10);
@@ -2667,34 +2667,36 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP int bufSize = WideCharToMultiByte(dat->codePage, 0, decoded, -1, dat->sendBuffer, 0, 0, 0);
int flags = 0;
- char *utfResult = mir_utf8encodeT(decoded);
- size_t memRequired = mir_strlen(utfResult) + 1;
-
- // try to detect RTL
- HWND hwndEdit = GetDlgItem(hwndDlg, IDC_MESSAGE);
- SendMessage(hwndEdit, WM_SETREDRAW, FALSE, 0);
-
- PARAFORMAT2 pf2;
- memset(&pf2, 0, sizeof(PARAFORMAT2));
- pf2.cbSize = sizeof(pf2);
- pf2.dwMask = PFM_RTLPARA;
- SendMessage(hwndEdit, EM_SETSEL, 0, -1);
- SendMessage(hwndEdit, EM_GETPARAFORMAT, 0, (LPARAM)&pf2);
- if (pf2.wEffects & PFE_RTLPARA)
- if (SendQueue::RTL_Detect(decoded))
- flags |= PREF_RTL;
-
- SendMessage(hwndEdit, WM_SETREDRAW, TRUE, 0);
- SendMessage(hwndEdit, EM_SETSEL, -1, -1);
- InvalidateRect(hwndEdit, NULL, FALSE);
-
- if (memRequired > dat->iSendBufferSize) {
- dat->sendBuffer = (char *)mir_realloc(dat->sendBuffer, memRequired);
- dat->iSendBufferSize = memRequired;
- }
+ size_t memRequired;
+ {
+ T2Utf utfResult(decoded);
+ memRequired = mir_strlen(utfResult) + 1;
+
+ // try to detect RTL
+ HWND hwndEdit = GetDlgItem(hwndDlg, IDC_MESSAGE);
+ SendMessage(hwndEdit, WM_SETREDRAW, FALSE, 0);
+
+ PARAFORMAT2 pf2;
+ memset(&pf2, 0, sizeof(PARAFORMAT2));
+ pf2.cbSize = sizeof(pf2);
+ pf2.dwMask = PFM_RTLPARA;
+ SendMessage(hwndEdit, EM_SETSEL, 0, -1);
+ SendMessage(hwndEdit, EM_GETPARAFORMAT, 0, (LPARAM)&pf2);
+ if (pf2.wEffects & PFE_RTLPARA)
+ if (SendQueue::RTL_Detect(decoded))
+ flags |= PREF_RTL;
+
+ SendMessage(hwndEdit, WM_SETREDRAW, TRUE, 0);
+ SendMessage(hwndEdit, EM_SETSEL, -1, -1);
+ InvalidateRect(hwndEdit, NULL, FALSE);
+
+ if (memRequired > dat->iSendBufferSize) {
+ dat->sendBuffer = (char *)mir_realloc(dat->sendBuffer, memRequired);
+ dat->iSendBufferSize = memRequired;
+ }
- memcpy(dat->sendBuffer, utfResult, memRequired);
- mir_free(utfResult);
+ memcpy(dat->sendBuffer, (char*)utfResult, memRequired);
+ }
if (memRequired == 0 || dat->sendBuffer[0] == 0)
break;
diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp index 4e9471f662..2795233135 100644 --- a/plugins/TabSRMM/src/sendqueue.cpp +++ b/plugins/TabSRMM/src/sendqueue.cpp @@ -681,7 +681,7 @@ int SendQueue::doSendLater(int iJobIndex, TWindowData *dat, MCONTACT hContact, b else szNote = TranslateT("The send later feature is not available on this protocol."); - char *utfText = mir_utf8encodeT(szNote); + T2Utf utfText(szNote); DBEVENTINFO dbei; dbei.cbSize = sizeof(dbei); dbei.eventType = EVENTTYPE_MESSAGE; @@ -689,7 +689,7 @@ int SendQueue::doSendLater(int iJobIndex, TWindowData *dat, MCONTACT hContact, b dbei.szModule = GetContactProto(dat->hContact); dbei.timestamp = time(NULL); dbei.cbBlob = (int)mir_strlen(utfText) + 1; - dbei.pBlob = (PBYTE)utfText; + dbei.pBlob = (PBYTE)(char*)utfText; StreamInEvents(dat->hwnd, 0, 1, 1, &dbei); if (dat->hDbEventFirst == NULL) SendMessage(dat->hwnd, DM_REMAKELOG, 0, 0); @@ -700,7 +700,6 @@ int SendQueue::doSendLater(int iJobIndex, TWindowData *dat, MCONTACT hContact, b SendDlgItemMessage(dat->hwnd, IDC_SAVE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)PluginConfig.g_buttonBarIcons[ICON_BUTTON_CANCEL]); SendDlgItemMessage(dat->hwnd, IDC_SAVE, BUTTONADDTOOLTIP, (WPARAM)pszIDCSAVE_close, BATF_TCHAR); dat->dwFlags &= ~MWF_SAVEBTN_SAV; - mir_free(utfText); if (!fAvail) return 0; @@ -720,7 +719,7 @@ int SendQueue::doSendLater(int iJobIndex, TWindowData *dat, MCONTACT hContact, b } else mir_sntprintf(tszHeader, SIZEOF(tszHeader), _T("M%d|"), time(0)); - char *utf_header = mir_utf8encodeT(tszHeader); + T2Utf utf_header(tszHeader); size_t required = mir_strlen(utf_header) + mir_strlen(job->szSendBuffer) + 10; char *tszMsg = reinterpret_cast<char *>(mir_alloc(required)); @@ -732,7 +731,6 @@ int SendQueue::doSendLater(int iJobIndex, TWindowData *dat, MCONTACT hContact, b mir_snprintf(tszMsg, required, "%s%s", utf_header, job->szSendBuffer); sendLater->addJob(tszMsg, hContact); } - mir_free(utf_header); mir_free(tszMsg); if (fIsSendLater) { diff --git a/plugins/TabSRMM/src/srmm.cpp b/plugins/TabSRMM/src/srmm.cpp index afe680f635..c98b28c076 100644 --- a/plugins/TabSRMM/src/srmm.cpp +++ b/plugins/TabSRMM/src/srmm.cpp @@ -125,15 +125,8 @@ int _DebugTraceW(const wchar_t *fmt, ...) mir_snprintf(szLogFileName, SIZEOF(szLogFileName), "%s\\%s", szDataPath, "tabsrmm_debug.log"); f = fopen(szLogFileName, "a+"); if (f) { - char *szDebug = mir_utf8encodeT(debug); fputs(tszTime, f); - if (szDebug != NULL) { - fputs(szDebug, f); - mir_free(szDebug); - } - else { - fputs("mir_utf8encodeT() fail in _DebugTraceW()", f); - } + fputs(T2Utf(debug), f); fputs("\n", f); fclose(f); } diff --git a/plugins/TabSRMM/src/themeio.cpp b/plugins/TabSRMM/src/themeio.cpp index fe1f0d3f1a..6a1b1531f1 100644 --- a/plugins/TabSRMM/src/themeio.cpp +++ b/plugins/TabSRMM/src/themeio.cpp @@ -225,19 +225,11 @@ void TSAPI WriteThemeToINI(const TCHAR *szIniFilenameT, TWindowData *dat) WritePrivateProfileStringA("Message Log", "ExtraMicroLF", _itoa(M.GetByte("extramicrolf", 0), szBuf, 10), szIniFilename);
for (i = 0; i <= TMPL_ERRMSG; i++) {
- char *encoded;
- if (dat == 0)
- encoded = mir_utf8encodeT(LTR_Active.szTemplates[i]);
- else
- encoded = mir_utf8encodeT(dat->pContainer->ltr_templates->szTemplates[i]);
- WritePrivateProfileStringA("Templates", TemplateNames[i], encoded, szIniFilename);
- mir_free(encoded);
- if (dat == 0)
- encoded = mir_utf8encodeT(RTL_Active.szTemplates[i]);
- else
- encoded = mir_utf8encodeT(dat->pContainer->rtl_templates->szTemplates[i]);
- WritePrivateProfileStringA("RTLTemplates", TemplateNames[i], encoded, szIniFilename);
- mir_free(encoded);
+ T2Utf szLTR((dat == 0) ? LTR_Active.szTemplates[i] : dat->pContainer->ltr_templates->szTemplates[i]);
+ WritePrivateProfileStringA("Templates", TemplateNames[i], szLTR, szIniFilename);
+
+ T2Utf szRTL((dat == 0) ? RTL_Active.szTemplates[i] : dat->pContainer->rtl_templates->szTemplates[i]);
+ WritePrivateProfileStringA("RTLTemplates", TemplateNames[i], szRTL, szIniFilename);
}
for (i = 0; i < CUSTOM_COLORS; i++) {
mir_snprintf(szTemp, SIZEOF(szTemp), "cc%d", i + 1);
diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp index 55aeea166a..a13c263edd 100644 --- a/plugins/TabSRMM/src/utils.cpp +++ b/plugins/TabSRMM/src/utils.cpp @@ -1293,9 +1293,7 @@ INT_PTR CALLBACK CWarning::dlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP str->insert(pos, L"\\line ");
}
- char *utf8 = mir_utf8encodeT(str->c_str());
- ::SendDlgItemMessage(hwnd, IDC_WARNTEXT, EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)utf8);
- mir_free(utf8);
+ ::SendDlgItemMessage(hwnd, IDC_WARNTEXT, EM_SETTEXTEX, (WPARAM)&stx, T2Utf(str->c_str()));
delete str;
::SetDlgItemTextW(hwnd, IDC_CAPTION, m_szTitle);
diff --git a/plugins/Weather/src/weather_addstn.cpp b/plugins/Weather/src/weather_addstn.cpp index 7c70cd4f8a..cede7efbf4 100644 --- a/plugins/Weather/src/weather_addstn.cpp +++ b/plugins/Weather/src/weather_addstn.cpp @@ -310,7 +310,7 @@ int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR * // replace spaces with %20
char loc[256];
- ptrA szSearchName( mir_utf8encodeT(name));
+ T2Utf szSearchName(name);
mir_snprintf(loc, SIZEOF(loc), sData->SearchURL, ptrA( mir_urlEncode(szSearchName)));
if (InternetDownloadFile(loc, NULL, NULL, &szData) == 0) {
TCHAR* szInfo = szData;
diff --git a/plugins/Weather/src/weather_update.cpp b/plugins/Weather/src/weather_update.cpp index 7b757961cc..fc94299a79 100644 --- a/plugins/Weather/src/weather_update.cpp +++ b/plugins/Weather/src/weather_update.cpp @@ -189,13 +189,15 @@ int UpdateWeather(MCONTACT hContact) // internal log using history
GetDisplay(&winfo, opt.hText, str2);
+ T2Utf szMessage(str2);
+
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = WEATHERPROTONAME;
dbei.timestamp = (DWORD)time(NULL);
- dbei.flags = DBEF_READ|DBEF_UTF;
+ dbei.flags = DBEF_READ | DBEF_UTF;
dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.pBlob = (PBYTE)mir_utf8encodeT(str2);
- dbei.cbBlob = (DWORD)mir_strlen((char*)dbei.pBlob)+1;
+ dbei.pBlob = szMessage;
+ dbei.cbBlob = (DWORD)mir_strlen(szMessage)+1;
db_event_add(hContact, &dbei);
}
diff --git a/plugins/YARelay/src/main.cpp b/plugins/YARelay/src/main.cpp index d6f3d80d44..a87eafb9a6 100644 --- a/plugins/YARelay/src/main.cpp +++ b/plugins/YARelay/src/main.cpp @@ -134,7 +134,7 @@ static int MessageEventAdded(WPARAM hContact, LPARAM hDBEvent) // build a message
Buffer<char> szUtfMsg;
- ptrA szTemplate( mir_utf8encodeT(tszForwardTemplate));
+ T2Utf szTemplate(tszForwardTemplate);
for (char *p = szTemplate; *p; p++) {
if (*p != '%') {
szUtfMsg.append(*p);
@@ -145,7 +145,7 @@ static int MessageEventAdded(WPARAM hContact, LPARAM hDBEvent) switch(*++p) {
case 'u':
case 'U':
- szUtfMsg.append( ptrA(mir_utf8encodeT(pcli->pfnGetContactDisplayName(hContact, 0))));
+ szUtfMsg.append(T2Utf(pcli->pfnGetContactDisplayName(hContact, 0)));
break;
case 'i':
@@ -166,19 +166,19 @@ static int MessageEventAdded(WPARAM hContact, LPARAM hDBEvent) }
else mir_sntprintf(buf, SIZEOF(buf), _T("%p"), hContact);
}
- szUtfMsg.append( ptrA(mir_utf8encodeT(buf)));
+ szUtfMsg.append(T2Utf(buf));
break;
case 't':
case 'T':
_tcsftime(buf, 10, _T("%H:%M"), tm_time);
- szUtfMsg.append( ptrA(mir_utf8encodeT(buf)));
+ szUtfMsg.append(T2Utf(buf));
break;
case 'd':
case 'D':
_tcsftime(buf, 12, _T("%d/%m/%Y"), tm_time);
- szUtfMsg.append( ptrA(mir_utf8encodeT(buf)));
+ szUtfMsg.append(T2Utf(buf));
break;
case 'm':
@@ -186,7 +186,7 @@ static int MessageEventAdded(WPARAM hContact, LPARAM hDBEvent) if (dbei.flags & DBEF_UTF)
szUtfMsg.append((char*)dbei.pBlob, dbei.cbBlob);
else
- szUtfMsg.append( ptrA(mir_utf8encode((char*)dbei.pBlob)));
+ szUtfMsg.append(ptrA(mir_utf8encode((char*)dbei.pBlob)));
break;
case '%':
diff --git a/protocols/AimOscar/src/chat.cpp b/protocols/AimOscar/src/chat.cpp index a861dccb84..0188d4609f 100644 --- a/protocols/AimOscar/src/chat.cpp +++ b/protocols/AimOscar/src/chat.cpp @@ -123,12 +123,9 @@ int CAimProto::OnGCEvent(WPARAM, LPARAM lParam) case GC_USER_MESSAGE:
if (gch->ptszText && mir_tstrlen(gch->ptszText))
- {
- char* msg = mir_utf8encodeT(gch->ptszText);
- aim_chat_send_message(item->hconn, item->seqno, msg);
- mir_free(msg);
- }
+ aim_chat_send_message(item->hconn, item->seqno, T2Utf(gch->ptszText));
break;
+
case GC_USER_CHANMGR:
DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, invite_to_chat_dialog,
LPARAM(new invite_chat_param(item->id, this)));
diff --git a/protocols/AimOscar/src/conv.cpp b/protocols/AimOscar/src/conv.cpp index f0458f7fde..75c95e2cc7 100644 --- a/protocols/AimOscar/src/conv.cpp +++ b/protocols/AimOscar/src/conv.cpp @@ -771,10 +771,9 @@ char* rtf_to_html(HWND hwndDlg,int DlgItem) }
else
{
- char* txt = mir_utf8encodeT(text);
+ T2Utf txt(text);
strcpy(&buf[pos], txt);
pos += mir_strlen(txt);
- mir_free(txt);
}
start++;
end++;
diff --git a/protocols/AimOscar/src/file.cpp b/protocols/AimOscar/src/file.cpp index b8eb1840f0..d47aa56b02 100644 --- a/protocols/AimOscar/src/file.cpp +++ b/protocols/AimOscar/src/file.cpp @@ -120,24 +120,22 @@ bool setup_next_file_send(file_transfer *ft) ft->pfts.currentFileProgress = 0;
char* fnamea;
- char* fname = mir_utf8encodeT(file);
+ T2Utf fname(file);
if (ft->pfts.totalFiles > 1 && ft->file[0])
{
size_t dlen = mir_strlen(ft->file);
if (strncmp(fname, ft->file, dlen) == 0 && fname[dlen] == '\\')
{
fnamea = &fname[dlen+1];
- for (char *p = fnamea; *p; ++p) { if (*p == '\\') *p = 1; }
+ for (char *p = fnamea; *p; ++p)
+ if (*p == '\\')
+ *p = 1;
}
- else
- fnamea = get_fname(fname);
+ else fnamea = get_fname(fname);
}
- else
- fnamea = get_fname(fname);
+ else fnamea = get_fname(fname);
send_init_oft2(ft, fnamea);
-
- mir_free(fname);
return true;
}
diff --git a/protocols/AimOscar/src/server.cpp b/protocols/AimOscar/src/server.cpp index 1f3a2403d9..a48b25df92 100644 --- a/protocols/AimOscar/src/server.cpp +++ b/protocols/AimOscar/src/server.cpp @@ -1264,11 +1264,10 @@ void CAimProto::snac_received_message(SNAC &snac,HANDLE hServerConn,unsigned sho if (channel == 1) { //Message not file
if (auto_response) { //this message must be an autoresponse
- char* away = mir_utf8encodeT(TranslateT("[Auto-Response]:"));
+ T2Utf away(TranslateT("[Auto-Response]:"));
size_t len = mir_strlen(msg_buf) + mir_strlen(away) + 2;
char* buf = (char*)mir_alloc(len);
mir_snprintf(buf, len, "%s %s", away, msg_buf);
- mir_free(away);
mir_free(msg_buf);
msg_buf = buf;
}
@@ -1291,11 +1290,10 @@ void CAimProto::snac_received_message(SNAC &snac,HANDLE hServerConn,unsigned sho {
char* s_msg = process_status_msg(*msgptr, sn);
- char* away = mir_utf8encodeT(TranslateT("[Auto-Response]:"));
+ T2Utf away(TranslateT("[Auto-Response]:"));
size_t len = mir_strlen(s_msg) + mir_strlen(away) + 2;
char* buf = (char*)alloca(len);
mir_snprintf(buf, len, "%s %s", away, s_msg);
- mir_free(away);
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = m_szModuleName;
diff --git a/protocols/AimOscar/src/services.cpp b/protocols/AimOscar/src/services.cpp index 5097b0d080..01944ef024 100644 --- a/protocols/AimOscar/src/services.cpp +++ b/protocols/AimOscar/src/services.cpp @@ -204,34 +204,26 @@ int CAimProto::OnGroupChange(WPARAM hContact,LPARAM lParam) if (hContact == NULL) {
if (grpchg->pszNewName == NULL && grpchg->pszOldName != NULL) {
- char* szOldName = mir_utf8encodeT(grpchg->pszOldName);
+ T2Utf szOldName(grpchg->pszOldName);
unsigned short group_id = group_list.find_id(szOldName);
if (group_id) {
aim_delete_contact(hServerConn, seqno, szOldName, 0, group_id, 1, false);
group_list.remove_by_id(group_id);
update_server_group("", 0);
}
- mir_free(szOldName);
}
else if (grpchg->pszNewName != NULL && grpchg->pszOldName != NULL) {
- char* szOldName = mir_utf8encodeT(grpchg->pszOldName);
- unsigned short group_id = group_list.find_id(szOldName);
- if (group_id) {
- char* szNewName = mir_utf8encodeT(grpchg->pszNewName);
- update_server_group(szNewName, group_id);
- mir_free(szNewName);
- }
- mir_free(szOldName);
+ unsigned short group_id = group_list.find_id(T2Utf(grpchg->pszOldName));
+ if (group_id)
+ update_server_group(T2Utf(grpchg->pszNewName), group_id);
}
}
else {
if (is_my_contact(hContact) && getBuddyId(hContact, 1) && !db_get_b(hContact, MOD_KEY_CL, AIM_KEY_NL, 0)) {
- if (grpchg->pszNewName) {
- char* szNewName = mir_utf8encodeT(grpchg->pszNewName);
- add_contact_to_group(hContact, szNewName);
- mir_free(szNewName);
- }
- else add_contact_to_group(hContact, AIM_DEFAULT_GROUP);
+ if (grpchg->pszNewName)
+ add_contact_to_group(hContact, T2Utf(grpchg->pszNewName));
+ else
+ add_contact_to_group(hContact, AIM_DEFAULT_GROUP);
}
}
return 0;
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp index b736b2c239..771adf60bd 100644 --- a/protocols/FacebookRM/src/dialogs.cpp +++ b/protocols/FacebookRM/src/dialogs.cpp @@ -299,16 +299,16 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara status->user_id = data->walls[wall_id]->user_id; status->isPage = data->walls[wall_id]->isPage; status->privacy = privacy_types[privacy_id].id; - status->place = ptrA(mir_utf8encodeT(placeT)); + status->place = T2Utf(placeT); status->url = _T2A(urlT); HWND hwndList = GetDlgItem(hwnd, IDC_CCLIST); GetSelectedContacts(data->proto, NULL, hwndList, &status->users); - ptrA narrow(mir_utf8encodeT(mindMessageT)); + T2Utf narrow(mindMessageT); status->text = narrow; - if (status->user_id == data->proto->facy.self_.user_id && data->proto->last_status_msg_ != (char *)narrow) + if (status->user_id == data->proto->facy.self_.user_id && data->proto->last_status_msg_ != (char*)narrow) data->proto->last_status_msg_ = narrow; data->proto->ForkThread(&FacebookProto::SetAwayMsgWorker, status); diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index defcec4595..36dcc6aae9 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -378,12 +378,12 @@ void parseAttachments(FacebookProto *proto, std::string *message_text, JSONNODE TCHAR title[200]; mir_sntprintf(title, SIZEOF(title), TranslateT("User sent %s:"), newText.c_str()); - *message_text += ptrA(mir_utf8encodeT(title)); + *message_text += T2Utf(title); *message_text += attachments_text; } else { // TODO: better support for these attachments (parse it from "m_messaging" instead of "messaging" - *message_text += ptrA(mir_utf8encodeT(TranslateT("User sent an unsupported attachment. Open your browser to see it."))); + *message_text += T2Utf(TranslateT("User sent an unsupported attachment. Open your browser to see it.")); } } } diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index af61679db4..e89049cd70 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -27,7 +27,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. /** * Helper function for loading name from database (or use default one specified as parameter), used for title of few notifications. */ -std::string getContactName(FacebookProto *proto, MCONTACT hContact, const char *defaultName) { +std::string getContactName(FacebookProto *proto, MCONTACT hContact, const char *defaultName) +{ std::string name = defaultName; DBVARIANT dbv; @@ -1225,8 +1226,7 @@ void FacebookProto::SearchAckThread(void *targ) int count = 0; - char *arg = mir_utf8encodeT((TCHAR*)targ); - std::string search = utils::url::encode(arg); + std::string search = utils::url::encode(T2Utf((TCHAR *)targ).str()); std::string ssid; while (count < 50 && !isOffline()) @@ -1300,15 +1300,13 @@ void FacebookProto::SearchAckThread(void *targ) facy.handle_success("searchAckThread"); mir_free(targ); - mir_free(arg); } void FacebookProto::SearchIdAckThread(void *targ) { facy.handle_entry("searchIdAckThread"); - char *arg = mir_utf8encodeT((TCHAR*)targ); - std::string search = utils::url::encode(arg) + "?"; + std::string search = utils::url::encode(T2Utf((TCHAR*)targ).str()) + "?"; if (!isOffline()) { @@ -1358,5 +1356,4 @@ void FacebookProto::SearchIdAckThread(void *targ) facy.handle_success("searchIdAckThread"); mir_free(targ); - mir_free(arg); } diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index afa5303574..7018e530ea 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -227,10 +227,9 @@ int FacebookProto::SetAwayMsg(int, const PROTOCHAR *msg) return 0; } - char *narrow = mir_utf8encodeT(msg); - if (last_status_msg_ != narrow) + T2Utf narrow(msg); + if (last_status_msg_ != (char*)narrow) last_status_msg_ = narrow; - mir_free(narrow); if (isOnline() && getByte(FACEBOOK_KEY_SET_MIRANDA_STATUS, DEFAULT_SET_MIRANDA_STATUS)) ForkThread(&FacebookProto::SetAwayMsgWorker, NULL); diff --git a/protocols/GTalkExt/src/notifications.cpp b/protocols/GTalkExt/src/notifications.cpp index 1a6eb2825d..fa83bcb284 100644 --- a/protocols/GTalkExt/src/notifications.cpp +++ b/protocols/GTalkExt/src/notifications.cpp @@ -190,7 +190,7 @@ MCONTACT SetupPseudocontact(LPCTSTR jid, LPCTSTR unreadCount, LPCSTR acc, LPCTST static MEVENT AddCListNotification(MCONTACT hContact, LPCSTR acc, POPUPDATAT *data, LPCTSTR url)
{
- mir_ptr<char> szUrl(mir_utf8encodeT(url)), szText(mir_utf8encodeT(data->lptzText));
+ T2Utf szUrl(url), szText(data->lptzText);
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = (LPSTR)acc;
diff --git a/protocols/Gadu-Gadu/src/dialogs.cpp b/protocols/Gadu-Gadu/src/dialogs.cpp index a75e6ef516..5ace2600c9 100644 --- a/protocols/Gadu-Gadu/src/dialogs.cpp +++ b/protocols/Gadu-Gadu/src/dialogs.cpp @@ -832,32 +832,20 @@ static INT_PTR CALLBACK gg_detailsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, req = gg_pubdir50_new(GG_PUBDIR50_WRITE); GetDlgItemText(hwndDlg, IDC_FIRSTNAME, text, SIZEOF(text)); - if (mir_tstrlen(text)){ - char* text_utf8 = mir_utf8encodeT(text); - gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, text_utf8); - mir_free(text_utf8); - } + if (mir_tstrlen(text)) + gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, T2Utf(text)); GetDlgItemText(hwndDlg, IDC_LASTNAME, text, SIZEOF(text)); - if (mir_tstrlen(text)){ - char* text_utf8 = mir_utf8encodeT(text); - gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, text_utf8); - mir_free(text_utf8); - } + if (mir_tstrlen(text)) + gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, T2Utf(text)); GetDlgItemText(hwndDlg, IDC_NICKNAME, text, SIZEOF(text)); - if (mir_tstrlen(text)){ - char* text_utf8 = mir_utf8encodeT(text); - gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, text_utf8); - mir_free(text_utf8); - } + if (mir_tstrlen(text)) + gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, T2Utf(text)); GetDlgItemText(hwndDlg, IDC_CITY, text, SIZEOF(text)); - if (mir_tstrlen(text)){ - char* text_utf8 = mir_utf8encodeT(text); - gg_pubdir50_add(req, GG_PUBDIR50_CITY, text_utf8); - mir_free(text_utf8); - } + if (mir_tstrlen(text)) + gg_pubdir50_add(req, GG_PUBDIR50_CITY, T2Utf(text)); // Gadu-Gadu Female <-> Male switch(SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_GETCURSEL, 0, 0)) { @@ -872,25 +860,16 @@ static INT_PTR CALLBACK gg_detailsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, } GetDlgItemText(hwndDlg, IDC_BIRTHYEAR, text, SIZEOF(text)); - if (mir_tstrlen(text)){ - char* text_utf8 = mir_utf8encodeT(text); - gg_pubdir50_add(req, GG_PUBDIR50_BIRTHYEAR, text_utf8); - mir_free(text_utf8); - } + if (mir_tstrlen(text)) + gg_pubdir50_add(req, GG_PUBDIR50_BIRTHYEAR, T2Utf(text)); GetDlgItemText(hwndDlg, IDC_FAMILYNAME, text, SIZEOF(text)); - if (mir_tstrlen(text)){ - char* text_utf8 = mir_utf8encodeT(text); - gg_pubdir50_add(req, GG_PUBDIR50_FAMILYNAME, text_utf8); - mir_free(text_utf8); - } + if (mir_tstrlen(text)) + gg_pubdir50_add(req, GG_PUBDIR50_FAMILYNAME, T2Utf(text)); GetDlgItemText(hwndDlg, IDC_CITYORIGIN, text, SIZEOF(text)); - if (mir_tstrlen(text)){ - char* text_utf8 = mir_utf8encodeT(text); - gg_pubdir50_add(req, GG_PUBDIR50_FAMILYCITY, text_utf8); - mir_free(text_utf8); - } + if (mir_tstrlen(text)) + gg_pubdir50_add(req, GG_PUBDIR50_FAMILYCITY, T2Utf(text)); // Run update gg_pubdir50_seq_set(req, GG_SEQ_CHINFO); diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp index 6c532d195b..2b6d0db04a 100644 --- a/protocols/Gadu-Gadu/src/gg_proto.cpp +++ b/protocols/Gadu-Gadu/src/gg_proto.cpp @@ -277,14 +277,10 @@ HANDLE GGPROTO::SearchBasic(const PROTOCHAR *id) return (HANDLE)1;
}
- char *id_utf8 = mir_utf8encodeT(id);
-
// Add uin and search it
- gg_pubdir50_add(req, GG_PUBDIR50_UIN, id_utf8);
+ gg_pubdir50_add(req, GG_PUBDIR50_UIN, T2Utf(id));
gg_pubdir50_seq_set(req, GG_SEQ_SEARCH);
- mir_free(id_utf8);
-
gg_EnterCriticalSection(&sess_mutex, "SearchBasic", 50, "sess_mutex", 1);
if (!gg_pubdir50(sess, req))
{
@@ -330,28 +326,25 @@ HANDLE GGPROTO::SearchByName(const PROTOCHAR *nick, const PROTOCHAR *firstName, // Add nick,firstName,lastName and search it
if (nick)
{
- char *nick_utf8 = mir_utf8encodeT(nick);
+ T2Utf nick_utf8(nick);
gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, nick_utf8);
strncat(data, nick_utf8, sizeof(data) - mir_strlen(data));
- mir_free(nick_utf8);
}
strncat(data, ".", sizeof(data) - mir_strlen(data));
if (firstName)
{
- char *firstName_utf8 = mir_utf8encodeT(firstName);
+ T2Utf firstName_utf8(firstName);
gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, firstName_utf8);
strncat(data, firstName_utf8, sizeof(data) - mir_strlen(data));
- mir_free(firstName_utf8);
}
strncat(data, ".", sizeof(data) - mir_strlen(data));
if (lastName)
{
- char *lastName_utf8 = mir_utf8encodeT(lastName);
+ T2Utf lastName_utf8(lastName);
gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, lastName_utf8);
strncat(data, lastName_utf8, sizeof(data) - mir_strlen(data));
- mir_free(lastName_utf8);
}
strncat(data, ".", sizeof(data) - mir_strlen(data));
@@ -407,40 +400,36 @@ HWND GGPROTO::SearchAdvanced(HWND hwndDlg) GetDlgItemText(hwndDlg, IDC_FIRSTNAME, text, SIZEOF(text));
if (mir_tstrlen(text))
{
- char *firstName_utf8 = mir_utf8encodeT(text);
+ T2Utf firstName_utf8(text);
gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, firstName_utf8);
strncat(data, firstName_utf8, sizeof(data) - mir_strlen(data));
- mir_free(firstName_utf8);
}
/* 1 */ strncat(data, ".", sizeof(data) - mir_strlen(data));
GetDlgItemText(hwndDlg, IDC_LASTNAME, text, SIZEOF(text));
if (mir_tstrlen(text))
{
- char *lastName_utf8 = mir_utf8encodeT(text);
+ T2Utf lastName_utf8(text);
gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, lastName_utf8);
strncat(data, lastName_utf8, sizeof(data) - mir_strlen(data));
- mir_free(lastName_utf8);
}
/* 2 */ strncat(data, ".", sizeof(data) - mir_strlen(data));
GetDlgItemText(hwndDlg, IDC_NICKNAME, text, SIZEOF(text));
if (mir_tstrlen(text))
{
- char *nickName_utf8 = mir_utf8encodeT(text);
+ T2Utf nickName_utf8(text);
gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, nickName_utf8);
strncat(data, nickName_utf8, sizeof(data) - mir_strlen(data));
- mir_free(nickName_utf8);
}
/* 3 */ strncat(data, ".", sizeof(data) - mir_strlen(data));
GetDlgItemText(hwndDlg, IDC_CITY, text, SIZEOF(text));
if (mir_tstrlen(text))
{
- char *city_utf8 = mir_utf8encodeT(text);
+ T2Utf city_utf8(text);
gg_pubdir50_add(req, GG_PUBDIR50_CITY, city_utf8);
strncat(data, city_utf8, sizeof(data) - mir_strlen(data));
- mir_free(city_utf8);
}
/* 4 */ strncat(data, ".", sizeof(data) - mir_strlen(data));
@@ -468,10 +457,9 @@ HWND GGPROTO::SearchAdvanced(HWND hwndDlg) yearFrom = ay - yearFrom;
mir_sntprintf(text, SIZEOF(text), _T("%d %d"), yearFrom, yearTo);
- char *age_utf8 = mir_utf8encodeT(text);
+ T2Utf age_utf8(text);
gg_pubdir50_add(req, GG_PUBDIR50_BIRTHYEAR, age_utf8);
strncat(data, age_utf8, sizeof(data) - mir_strlen(data));
- mir_free(age_utf8);
}
/* 5 */ strncat(data, ".", sizeof(data) - mir_strlen(data));
diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp index 4735a055e9..1e194c6ece 100644 --- a/protocols/Gadu-Gadu/src/groupchat.cpp +++ b/protocols/Gadu-Gadu/src/groupchat.cpp @@ -181,12 +181,10 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam) CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
mir_free(nickT);
- char* pszText_utf8 = mir_utf8encodeT(gch->ptszText);
+ T2Utf pszText_utf8(gch->ptszText);
gg_EnterCriticalSection(&sess_mutex, "gc_event", 57, "sess_mutex", 1);
- gg_send_message_confer(sess, GG_CLASS_CHAT, chat->recipients_count, chat->recipients, (BYTE*)pszText_utf8);
+ gg_send_message_confer(sess, GG_CLASS_CHAT, chat->recipients_count, chat->recipients, pszText_utf8);
gg_LeaveCriticalSection(&sess_mutex, "gc_event", 57, 1, "sess_mutex", 1);
- mir_free(pszText_utf8);
-
return 1;
}
diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp index a93de45b5a..5f1dd86fd3 100644 --- a/protocols/Gadu-Gadu/src/image.cpp +++ b/protocols/Gadu-Gadu/src/image.cpp @@ -862,18 +862,14 @@ int GGPROTO::img_displayasmsg(MCONTACT hContact, void *img) TCHAR image_msg[MAX_PATH + 11];
mir_sntprintf(image_msg, SIZEOF(image_msg), _T("[img]%s[/img]"), szPath);
+ T2Utf szMessage(image_msg);
PROTORECVEVENT pre = {0};
pre.timestamp = time(NULL);
- pre.szMessage = mir_utf8encodeT(image_msg);
+ pre.szMessage = szMessage;
ProtoChainRecvMsg(hContact, &pre);
debugLog(_T("img_displayasmsg(): Image saved to %s."), szPath);
-
- mir_free(pre.szMessage);
- }
- else
- {
- debugLog(_T("img_displayasmsg(): Cannot save image to %s."), szPath);
}
+ else debugLog(_T("img_displayasmsg(): Cannot save image to %s."), szPath);
return 0;
}
diff --git a/protocols/Gadu-Gadu/src/services.cpp b/protocols/Gadu-Gadu/src/services.cpp index 26c0d62734..af998847a4 100644 --- a/protocols/Gadu-Gadu/src/services.cpp +++ b/protocols/Gadu-Gadu/src/services.cpp @@ -105,16 +105,14 @@ int GGPROTO::refreshstatus(int status) gg_EnterCriticalSection(&modemsg_mutex, "refreshstatus", 69, "modemsg_mutex", 1);
szMsg = getstatusmsg(status);
gg_LeaveCriticalSection(&modemsg_mutex, "refreshstatus", 69, 1, "modemsg_mutex", 1);
- char *szMsg_utf8 = mir_utf8encodeT(szMsg);
- if (szMsg_utf8)
- {
+ T2Utf szMsg_utf8(szMsg);
+ if (szMsg_utf8) {
debugLogA("refreshstatus(): Setting status and away message.");
gg_EnterCriticalSection(&sess_mutex, "refreshstatus", 70, "sess_mutex", 1);
gg_change_status_descr(sess, status_m2gg(status, szMsg_utf8 != NULL), szMsg_utf8);
gg_LeaveCriticalSection(&sess_mutex, "refreshstatus", 70, 1, "sess_mutex", 1);
}
- else
- {
+ else {
debugLogA("refreshstatus(): Setting just status.");
gg_EnterCriticalSection(&sess_mutex, "refreshstatus", 71, "sess_mutex", 1);
gg_change_status(sess, status_m2gg(status, 0));
@@ -123,7 +121,6 @@ int GGPROTO::refreshstatus(int status) // Change status of the contact with our own UIN (if got yourself added to the contact list)
changecontactstatus( getDword(GG_KEY_UIN, 0), status_m2gg(status, szMsg != NULL), szMsg, 0, 0, 0, 0);
broadcastnewstatus(status);
- mir_free(szMsg_utf8);
}
return TRUE;
diff --git a/protocols/JabberG/src/jabber_archive.cpp b/protocols/JabberG/src/jabber_archive.cpp index 18fbec6911..21e686c742 100644 --- a/protocols/JabberG/src/jabber_archive.cpp +++ b/protocols/JabberG/src/jabber_archive.cpp @@ -288,14 +288,14 @@ void CJabberProto::OnIqResultGetCollection(HXML iqNode, CJabberIqInfo*) if (!tszBody || !tszSecs)
continue;
- ptrA szEventText( mir_utf8encodeT(tszBody));
+ T2Utf szEventText(tszBody);
DBEVENTINFO dbei = { sizeof(DBEVENTINFO) };
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.szModule = m_szModuleName;
dbei.cbBlob = (DWORD)mir_strlen(szEventText);
dbei.flags = DBEF_READ + DBEF_UTF + from;
- dbei.pBlob = (PBYTE)(char*)szEventText;
+ dbei.pBlob = szEventText;
dbei.timestamp = tmStart + _ttol(tszSecs) - timezone;
if (!IsDuplicateEvent(hContact, dbei))
db_event_add(hContact, &dbei);
diff --git a/protocols/JabberG/src/jabber_byte.cpp b/protocols/JabberG/src/jabber_byte.cpp index b9910d9b5d..ffbc79d77f 100644 --- a/protocols/JabberG/src/jabber_byte.cpp +++ b/protocols/JabberG/src/jabber_byte.cpp @@ -367,7 +367,7 @@ int CJabberProto::ByteSendParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* b mir_free(szInitiatorJid);
mir_free(szTargetJid);
- ptrA szAuthString(mir_utf8encodeT(text));
+ T2Utf szAuthString(text);
debugLogA("Auth: '%s'", szAuthString);
JabberShaStrBuf buf;
@@ -516,7 +516,7 @@ int CJabberProto::ByteSendProxyParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, ch mir_free(szInitiatorJid);
mir_free(szTargetJid);
- char* szAuthString = mir_utf8encodeT(text);
+ T2Utf szAuthString(text);
debugLogA("Auth: '%s'", szAuthString);
JabberShaStrBuf buf;
@@ -524,7 +524,6 @@ int CJabberProto::ByteSendProxyParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, ch Netlib_Send(hConn, (char*)data, 47, 0);
jbt->state = JBT_CONNECT;
- mir_free(szAuthString);
}
else jbt->state = JBT_SOCKSERR;
break;
@@ -705,12 +704,13 @@ int CJabberProto::ByteReceiveParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char data[4] = 40;
TCHAR text[JABBER_MAX_JID_LEN * 2];
- TCHAR *szInitiatorJid = JabberPrepareJid(jbt->srcJID);
- TCHAR *szTargetJid = JabberPrepareJid(jbt->dstJID);
- mir_sntprintf(text, SIZEOF(text), _T("%s%s%s"), jbt->sid, szInitiatorJid, szTargetJid);
- mir_free(szInitiatorJid);
- mir_free(szTargetJid);
- char* szAuthString = mir_utf8encodeT(text);
+ {
+ ptrT szInitiatorJid(JabberPrepareJid(jbt->srcJID));
+ ptrT szTargetJid(JabberPrepareJid(jbt->dstJID));
+ mir_sntprintf(text, SIZEOF(text), _T("%s%s%s"), jbt->sid, szInitiatorJid, szTargetJid);
+ }
+
+ T2Utf szAuthString(text);
debugLogA("Auth: '%s'", szAuthString);
JabberShaStrBuf buf;
@@ -718,7 +718,6 @@ int CJabberProto::ByteReceiveParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char Netlib_Send(hConn, (char*)data, 47, 0);
jbt->state = JBT_CONNECT;
- mir_free(szAuthString);
}
else jbt->state = JBT_SOCKSERR;
break;
diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp index 1c51a3b87e..d962cac51e 100644 --- a/protocols/JabberG/src/jabber_file.cpp +++ b/protocols/JabberG/src/jabber_file.cpp @@ -277,7 +277,7 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft) else
p = ft->std.ptszFiles[i];
- char *pFileName = mir_urlEncode(ptrA(mir_utf8encodeT(p)));
+ ptrA pFileName(mir_urlEncode(T2Utf(p)));
if (pFileName != NULL) {
ft->szId = JabberId2string(SerialNext());
@@ -290,8 +290,6 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft) char szAddr[256];
mir_snprintf(szAddr, SIZEOF(szAddr), "http://%s:%d/%s", myAddr, nlb.wPort, pFileName);
- mir_free(pFileName);
-
size_t len = mir_tstrlen(ptszResource) + mir_tstrlen(ft->jid) + 2;
TCHAR *fulljid = (TCHAR *)alloca(sizeof(TCHAR) * len);
mir_sntprintf(fulljid, len, _T("%s/%s"), ft->jid, ptszResource);
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index a109b3bea3..59594259fa 100644 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -217,7 +217,7 @@ void CJabberProto::OnIqResultGetAuth(HXML iqNode, CJabberIqInfo*) query << XCHILD(_T("username"), m_ThreadInfo->conn.username);
if (xmlGetChild(queryNode, "digest") != NULL && m_ThreadInfo->szStreamId) {
JabberShaStrBuf buf;
- ptrA str(mir_utf8encodeT(m_ThreadInfo->conn.password));
+ T2Utf str(m_ThreadInfo->conn.password);
char text[200];
mir_snprintf(text, SIZEOF(text), "%s%s", m_ThreadInfo->szStreamId, str);
query << XCHILD(_T("digest"), _A2T(JabberSha1(text, buf)));
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index 7072c507db..672857fe74 100644 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -73,11 +73,11 @@ void CJabberProto::DBAddAuthRequest(const TCHAR *jid, const TCHAR *nick) MCONTACT hContact = DBCreateContact(jid, nick, TRUE, TRUE);
delSetting(hContact, "Hidden");
- char* szJid = mir_utf8encodeT(jid);
- char* szNick = mir_utf8encodeT(nick);
+ T2Utf szJid(jid);
+ T2Utf szNick(nick);
- //blob is: uin(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
- //blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), ""(ASCIIZ), ""(ASCIIZ), email(ASCIIZ), ""(ASCIIZ)
+ // blob is: uin(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
+ // blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), ""(ASCIIZ), ""(ASCIIZ), email(ASCIIZ), ""(ASCIIZ)
DBEVENTINFO dbei = { sizeof(DBEVENTINFO) };
dbei.szModule = m_szModuleName;
dbei.timestamp = (DWORD)time(NULL);
@@ -95,9 +95,6 @@ void CJabberProto::DBAddAuthRequest(const TCHAR *jid, const TCHAR *nick) db_event_add(NULL, &dbei);
debugLogA("Setup DBAUTHREQUEST with nick='%s' jid='%s'", szNick, szJid);
-
- mir_free(szJid);
- mir_free(szNick);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp index 5afc459a87..bdf8e06dc0 100644 --- a/protocols/JabberG/src/jabber_opt.cpp +++ b/protocols/JabberG/src/jabber_opt.cpp @@ -1232,11 +1232,8 @@ void CJabberProto::_RosterExportToFile(HWND hwndDlg) fwrite(header, 1, sizeof(header) - 1 /* for zero terminator */, fp);
TCHAR *xtmp = xi.toString(root, NULL);
- char *tmp = mir_utf8encodeT(xtmp);
+ fputs(T2Utf(xtmp), fp);
xi.freeMem(xtmp);
-
- fwrite(tmp, 1, mir_strlen(tmp), fp);
- mir_free(tmp);
fclose(fp);
}
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index ac27168eb1..c7b61995a2 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -804,8 +804,8 @@ HANDLE __cdecl CJabberProto::SearchByName(const TCHAR *nick, const TCHAR *firstN int __cdecl CJabberProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT *evt)
{
- ptrA szResUtf(mir_utf8encodeT((LPCTSTR)evt->lParam));
- evt->pCustomData = szResUtf;
+ T2Utf szResUtf((LPCTSTR)evt->lParam);
+ evt->pCustomData = (char*)szResUtf;
evt->cbCustomDataSize = (DWORD)mir_strlen(szResUtf);
Proto_RecvMessage(hContact, evt);
return 0;
diff --git a/protocols/JabberG/src/jabber_secur.cpp b/protocols/JabberG/src/jabber_secur.cpp index ce2cafb2fc..a364050197 100644 --- a/protocols/JabberG/src/jabber_secur.cpp +++ b/protocols/JabberG/src/jabber_secur.cpp @@ -157,9 +157,8 @@ char* TMD5Auth::getChallenge(const TCHAR *challenge) CallService(MS_UTILS_GETRANDOM, sizeof(digest), (LPARAM)digest);
mir_snprintf(cnonce, SIZEOF(cnonce), "%08x%08x%08x%08x", htonl(digest[0]), htonl(digest[1]), htonl(digest[2]), htonl(digest[3]));
- ptrA uname(mir_utf8encodeT(info->conn.username)),
- passw(mir_utf8encodeT(info->conn.password)),
- serv(mir_utf8encode(info->conn.server));
+ T2Utf uname(info->conn.username), passw(info->conn.password);
+ ptrA serv(mir_utf8encode(info->conn.server));
mir_md5_init(&ctx);
mir_md5_append(&ctx, (BYTE*)(char*)uname, (int)mir_strlen(uname));
@@ -304,7 +303,7 @@ char* TScramAuth::getChallenge(const TCHAR *challenge) char* TScramAuth::getInitialRequest()
{
- ptrA uname(mir_utf8encodeT(info->conn.username));
+ T2Utf uname(info->conn.username);
unsigned char nonce[24];
CallService(MS_UTILS_GETRANDOM, sizeof(nonce), (LPARAM)nonce);
@@ -339,7 +338,7 @@ TPlainAuth::~TPlainAuth() char* TPlainAuth::getInitialRequest()
{
- ptrA uname(mir_utf8encodeT(info->conn.username)), passw(mir_utf8encodeT(info->conn.password));
+ T2Utf uname(info->conn.username), passw(info->conn.password);
size_t size = 2 * mir_strlen(uname) + mir_strlen(passw) + mir_strlen(info->conn.server) + 4;
char *toEncode = (char*)alloca(size);
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 917a0af363..c5c18a6453 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -205,15 +205,14 @@ void CJabberProto::xmlStreamInitializeNow(ThreadData *info) xmlAddAttr(stream, _T("version"), _T("1.0"));
LPTSTR xmlQuery = xi.toString(n, NULL);
- char* buf = mir_utf8encodeT(xmlQuery);
+ T2Utf buf(xmlQuery);
int bufLen = (int)mir_strlen(buf);
if (bufLen > 2) {
- strdel(buf + bufLen - 2, 1);
+ strdel((char*)buf + bufLen - 2, 1);
bufLen--;
}
info->send(buf, bufLen);
- mir_free(buf);
xi.freeMem(xmlQuery);
xi.destroyNode(n);
}
@@ -1987,9 +1986,8 @@ int ThreadData::send(HXML node) *q = 0;
- char* utfStr = mir_utf8encodeT(str);
+ T2Utf utfStr(str);
int result = send(utfStr, (int)mir_strlen(utfStr));
- mir_free(utfStr);
xi.freeMem(str);
return result;
diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp index 856ab61442..80eed2e2a7 100644 --- a/protocols/MRA/src/Mra_proto.cpp +++ b/protocols/MRA/src/Mra_proto.cpp @@ -1781,7 +1781,7 @@ DWORD CMraProto::MraRecvCommand_Message(DWORD dwTime, DWORD dwFlags, CMStringA & if (m_heNudgeReceived)
NotifyEventHooks(m_heNudgeReceived, hContact, NULL);
else {
- ptrA szMsg(mir_utf8encodeT(TranslateTS(MRA_ALARM_MESSAGE)));
+ T2Utf szMsg(TranslateTS(MRA_ALARM_MESSAGE));
pre.szMessage = szMsg;
ProtoChainRecvMsg(hContact, &pre);
}
diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp index 8776bfd310..7408bd7df4 100644 --- a/protocols/MSN/src/msn_misc.cpp +++ b/protocols/MSN/src/msn_misc.cpp @@ -236,7 +236,7 @@ int CMsnProto::MSN_SetMyAvatar(const TCHAR* sztFname, void* pData, size_t cbLen) mir_sha1_ctx sha1ctx;
BYTE sha1c[MIR_SHA1_HASH_SIZE], sha1d[MIR_SHA1_HASH_SIZE];
- char *szFname = mir_utf8encodeT(sztFname);
+ T2Utf szFname(sztFname);
mir_sha1_init(&sha1ctx);
mir_sha1_append(&sha1ctx, (BYTE*)pData, (int)cbLen);
@@ -281,7 +281,6 @@ int CMsnProto::MSN_SetMyAvatar(const TCHAR* sztFname, void* pData, size_t cbLen) char* szBuffer = ezxml_toxml(xmlp, false);
ezxml_free(xmlp);
- mir_free(szFname);
ptrA szEncodedBuffer(mir_urlEncode(szBuffer));
free(szBuffer);
diff --git a/protocols/MSN/src/msn_p2p.cpp b/protocols/MSN/src/msn_p2p.cpp index 2a515a0e8c..46b85d9f43 100644 --- a/protocols/MSN/src/msn_p2p.cpp +++ b/protocols/MSN/src/msn_p2p.cpp @@ -249,9 +249,7 @@ void CMsnProto::p2p_savePicture2disk(filetransfer* ft) setString(ft->std.hContact, "PictSavedContext", ft->p2p_object);
ProtoBroadcastAck(AI.hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, &AI, 0);
- char *filename = mir_utf8encodeT(AI.filename);
- debugLogA("Avatar for contact %08x saved to file '%s'", AI.hContact, filename);
- mir_free(filename);
+ debugLogA("Avatar for contact %08x saved to file '%s'", AI.hContact, T2Utf(AI.filename));
}
break;
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp index 5a2036a115..acf07cc3a4 100644 --- a/protocols/MSN/src/msn_proto.cpp +++ b/protocols/MSN/src/msn_proto.cpp @@ -295,16 +295,13 @@ int __cdecl CMsnProto::AuthRequest(MCONTACT hContact, const TCHAR* szMessage) db_get_static(hContact, m_szModuleName, "e-mail", email, sizeof(email)))
return 1;
- char* szMsg = mir_utf8encodeT(szMessage);
-
int netId = strncmp(email, "tel:", 4) == 0 ? NETID_MOB : (strncmp(email, "live:", 5) == 0 ? NETID_SKYPE : NETID_MSN);
- if (MSN_AddUser(hContact, email, netId, LIST_FL, szMsg)) {
+ if (MSN_AddUser(hContact, email, netId, LIST_FL, T2Utf(szMessage))) {
MSN_AddUser(hContact, email, netId, LIST_PL + LIST_REMOVE);
MSN_AddUser(hContact, email, netId, LIST_BL + LIST_REMOVE);
MSN_AddUser(hContact, email, netId, LIST_AL);
}
MSN_SetContactDb(hContact, email);
- mir_free(szMsg);
if (MSN_IsMeByContact(hContact)) displayEmailCount(hContact);
return 0;
@@ -400,7 +397,7 @@ int CMsnProto::AuthDeny(MEVENT hDbEvent, const TCHAR*) void __cdecl CMsnProto::MsnSearchAckThread(void* arg)
{
const TCHAR* emailT = (TCHAR*)arg;
- char *email = mir_utf8encodeT(emailT);
+ T2Utf email(emailT);
if (Lists_IsInList(LIST_FL, email)) {
MSN_ShowPopup(emailT, TranslateT("Contact already in your contact list"), MSN_ALLOW_MSGBOX, NULL);
@@ -442,7 +439,6 @@ void __cdecl CMsnProto::MsnSearchAckThread(void* arg) ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0);
break;
}
- mir_free(email);
mir_free(arg);
}
diff --git a/protocols/MSN/src/msn_soapstore.cpp b/protocols/MSN/src/msn_soapstore.cpp index 42a6d9ae8f..a10dbd11f0 100644 --- a/protocols/MSN/src/msn_soapstore.cpp +++ b/protocols/MSN/src/msn_soapstore.cpp @@ -507,7 +507,7 @@ bool CMsnProto::MSN_StoreCreateDocument(const TCHAR *sztName, const char *szMime {
char* reqHdr;
ezxml_t tbdy;
- char* szName = mir_utf8encodeT(sztName);
+ T2Utf szName(sztName);
ezxml_t xmlp = storeSoapHdr("CreateDocument", "RoamingIdentityChanged", tbdy, reqHdr);
ezxml_t hndl = ezxml_add_child(tbdy, "parentHandle", 0);
@@ -544,7 +544,6 @@ bool CMsnProto::MSN_StoreCreateDocument(const TCHAR *sztName, const char *szMime char* szData = ezxml_toxml(xmlp, true);
ezxml_free(xmlp);
- mir_free(szName);
unsigned status = 0;
char *storeUrl = NULL, *tResult = NULL;
@@ -589,7 +588,7 @@ bool CMsnProto::MSN_StoreCreateDocument(const TCHAR *sztName, const char *szMime bool CMsnProto::MSN_StoreUpdateDocument(const TCHAR *sztName, const char *szMimeType, const char *szPicData, bool allowRecurse)
{
char* reqHdr;
- char* szName = mir_utf8encodeT(sztName);
+ T2Utf szName(sztName);
ezxml_t tbdy;
ezxml_t xmlp = storeSoapHdr("UpdateDocument", "RoamingIdentityChanged", tbdy, reqHdr);
@@ -616,7 +615,6 @@ bool CMsnProto::MSN_StoreUpdateDocument(const TCHAR *sztName, const char *szMime char* szData = ezxml_toxml(xmlp, true);
ezxml_free(xmlp);
- mir_free(szName);
unsigned status = 0;
char *storeUrl = NULL, *tResult = NULL;
diff --git a/protocols/MSN/src/msn_svcs.cpp b/protocols/MSN/src/msn_svcs.cpp index 32de674020..8a70038f54 100644 --- a/protocols/MSN/src/msn_svcs.cpp +++ b/protocols/MSN/src/msn_svcs.cpp @@ -436,7 +436,7 @@ int CMsnProto::OnGroupChange(WPARAM hContact, LPARAM lParam) }
else {
if (MSN_IsMyContact(hContact))
- MSN_MoveContactToGroup(hContact, ptrA(mir_utf8encodeT(grpchg->pszNewName)));
+ MSN_MoveContactToGroup(hContact, T2Utf(grpchg->pszNewName));
}
return 0;
}
diff --git a/protocols/Sametime/src/conference.cpp b/protocols/Sametime/src/conference.cpp index a34be253cf..4f3402413a 100644 --- a/protocols/Sametime/src/conference.cpp +++ b/protocols/Sametime/src/conference.cpp @@ -34,9 +34,7 @@ void mwServiceConf_on_invited(mwConference* conf, mwLoginInfo* inviter, const ch for (;mem;mem=mem->next) {
if (proto->my_login_info && strcmp(proto->my_login_info->login_id, ((mwLoginInfo*)mem->data)->login_id) == 0) {
proto->debugLog(_T("mwServiceConf_on_invited() already present"));
- char* utfs = mir_utf8encodeT(TranslateT("Invitation rejected - already present."));
- mwConference_reject(conf, 0, utfs);
- mir_free(utfs);
+ mwConference_reject(conf, 0, T2Utf(TranslateT("Invitation rejected - already present.")));
return;
}
}
@@ -75,14 +73,11 @@ void CSametimeProto::ClearInviteQueue() MCONTACT hContact = FindContactByUserId(idb.user);
if (!hContact) {
mwSametimeList* user_list = mwSametimeList_new();
- char* utfs = mir_utf8encodeT(TranslateT("None"));
- mwSametimeGroup* stgroup = mwSametimeGroup_new(user_list, mwSametimeGroup_NORMAL, utfs);
+ mwSametimeGroup* stgroup = mwSametimeGroup_new(user_list, mwSametimeGroup_NORMAL, T2Utf(TranslateT("None")));
mwSametimeUser* stuser = mwSametimeUser_new(stgroup, mwSametimeUser_NORMAL, &idb);
hContact = AddContact(stuser, (options.add_contacts ? false : true));
mwSametimeList_free(user_list);
- mir_free(utfs);
-
}
bool found = false;
@@ -96,11 +91,8 @@ void CSametimeProto::ClearInviteQueue() }
g_list_free(members);
- if (!found) {
- char* temp = mir_utf8encodeT(TranslateT("Please join this meeting."));
- mwConference_invite(my_conference, &idb, temp);
- mir_free(temp);
- }
+ if (!found)
+ mwConference_invite(my_conference, &idb, T2Utf(TranslateT("Please join this meeting.")));
invite_queue.pop();
}
@@ -209,14 +201,12 @@ void mwServiceConf_on_peer_joined(mwConference* conf, mwLoginInfo *user) idb.community = 0;
mwSametimeList* user_list = mwSametimeList_new();
- char* utfs = mir_utf8encodeT(TranslateT("None"));
- mwSametimeGroup* stgroup = mwSametimeGroup_new(user_list, mwSametimeGroup_NORMAL, utfs);
+ mwSametimeGroup* stgroup = mwSametimeGroup_new(user_list, mwSametimeGroup_NORMAL, T2Utf(TranslateT("None")));
mwSametimeUser* stuser = mwSametimeUser_new(stgroup, mwSametimeUser_NORMAL, &idb);
hContact = proto->AddContact(stuser, (proto->options.add_contacts ? false : true));
mwSametimeList_free(user_list);
- mir_free(utfs);
}
ptrT tszConfId(mir_utf8decodeT(mwConference_getName(conf)));
@@ -360,10 +350,7 @@ int CSametimeProto::GcEventHook(WPARAM wParam, LPARAM lParam) { case GC_USER_MESSAGE:
{
debugLog(_T("CSametimeProto::GcEventHook() GC_USER_MESSAGE"));
- char* utf_msg;
- utf_msg = mir_utf8encodeT(gch->ptszText);
- mwConference_sendText((mwConference*)conf->data, utf_msg);
- mir_free(utf_msg);
+ mwConference_sendText((mwConference*)conf->data, T2Utf(gch->ptszText));
}
break;
case GC_SESSION_TERMINATE:
@@ -373,9 +360,7 @@ int CSametimeProto::GcEventHook(WPARAM wParam, LPARAM lParam) { CloseMyConference(this);
} else {
debugLog(_T("CSametimeProto::GcEventHook() GC_SESSION_TERMINATE mwConference_destroy"));
- char* utfs = mir_utf8encodeT(TranslateT("I'm outa here."));
- mwConference_destroy((mwConference*)conf->data, 0, utfs);
- mir_free(utfs);
+ mwConference_destroy((mwConference*)conf->data, 0, T2Utf(TranslateT("I'm outa here.")));
}
}
break;
@@ -435,11 +420,10 @@ INT_PTR CSametimeProto::onMenuCreateChat(WPARAM wParam, LPARAM lParam) if (!my_conference) {
debugLog(_T("CSametimeProto::onMenuCreateChat() mwConference_open"));
- char* utfs;
- my_conference = mwConference_new(service_conference, utfs = mir_utf8encodeT(title));
+ my_conference = mwConference_new(service_conference, T2Utf(title));
mwConference_open(my_conference);
- mir_free(utfs);
- } else {
+ }
+ else {
debugLog(_T("CSametimeProto::onMenuCreateChat() ClearInviteQueue"));
ClearInviteQueue();
}
@@ -503,12 +487,10 @@ void CSametimeProto::DeinitConference() if (service_conference){
conferences = conf = mwServiceConference_getConferences(service_conference);
for (;conf;conf = conf->next) {
- if (my_conference == conf->data) CloseMyConference(this);
- else {
- char* utfs = mir_utf8encodeT(TranslateT("I'm outa here."));
- mwConference_destroy((mwConference*)conf->data, 0, utfs);
- mir_free(utfs);
- }
+ if (my_conference == conf->data)
+ CloseMyConference(this);
+ else
+ mwConference_destroy((mwConference*)conf->data, 0, T2Utf(TranslateT("I'm outa here.")));
}
g_list_free(conferences);
}
diff --git a/protocols/Sametime/src/files.cpp b/protocols/Sametime/src/files.cpp index e3836b75ae..f65b6c3b87 100644 --- a/protocols/Sametime/src/files.cpp +++ b/protocols/Sametime/src/files.cpp @@ -297,17 +297,10 @@ HANDLE CSametimeProto::SendFilesToUser(MCONTACT hContact, PROTOCHAR** files, con TCHAR *fn = _tcsrchr(files[i], '\\');
if (fn)
fn++;
-
- char* pszDesc_utf8 = mir_utf8encodeT(ptszDesc);
- char* pszFile_utf8;
- if (fn)
- pszFile_utf8 = mir_utf8encodeT(fn);
else
- pszFile_utf8 = mir_utf8encodeT(files[i]);
+ fn = files[i];
- ft = mwFileTransfer_new(service_files, &idb, pszDesc_utf8, pszFile_utf8, filesize);
- mir_free(pszFile_utf8);
- mir_free(pszDesc_utf8);
+ ft = mwFileTransfer_new(service_files, &idb, T2Utf(ptszDesc), T2Utf(fn), filesize);
ftcd = new FileTransferClientData;
memset((void*)ftcd, 0, sizeof(FileTransferClientData));
diff --git a/protocols/Sametime/src/options.cpp b/protocols/Sametime/src/options.cpp index cd44b6c915..5d1f077911 100644 --- a/protocols/Sametime/src/options.cpp +++ b/protocols/Sametime/src/options.cpp @@ -292,14 +292,13 @@ static INT_PTR CALLBACK DlgProcOptNet(HWND hwndDlg, UINT msg, WPARAM wParam, LPA case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
TCHAR ws[2048];
- char* utf;
GetDlgItemText(hwndDlg, IDC_ED_SNAME, ws, LSTRINGLEN);
- strcpy(proto->options.server_name, utf = mir_utf8encodeT(ws)); mir_free(utf);
+ strcpy(proto->options.server_name, T2Utf(ws));
GetDlgItemText(hwndDlg, IDC_ED_NAME, ws, LSTRINGLEN);
- strcpy(proto->options.id, utf = mir_utf8encodeT(ws)); mir_free(utf);
+ strcpy(proto->options.id, T2Utf(ws));
GetDlgItemText(hwndDlg, IDC_ED_PWORD, ws, LSTRINGLEN);
- strcpy(proto->options.pword, utf = mir_utf8encodeT(ws)); mir_free(utf);
+ strcpy(proto->options.pword, T2Utf(ws));
BOOL translated;
int port = GetDlgItemInt(hwndDlg, IDC_ED_PORT, &translated, FALSE);
diff --git a/protocols/Sametime/src/sametime_proto.cpp b/protocols/Sametime/src/sametime_proto.cpp index e0a01850ac..6aa6eb2325 100644 --- a/protocols/Sametime/src/sametime_proto.cpp +++ b/protocols/Sametime/src/sametime_proto.cpp @@ -171,24 +171,18 @@ int CSametimeProto::GetInfo(MCONTACT hContact, int infoType) HANDLE CSametimeProto::SearchBasic(const PROTOCHAR* id)
{
debugLog(_T("CSametimeProto::SearchBasic() id:len=[%d]"), id == NULL ? -1 : mir_tstrlen(id));
- char* id_utf8 = mir_utf8encodeT(id);
- int ret = SearchForUser(id_utf8, FALSE);
- mir_free(id_utf8);
- return (HANDLE)ret;
+ return (HANDLE)SearchForUser(T2Utf(id), FALSE);
///TODO - add timeout (like at GGPROTO::searchthread)
}
HWND CSametimeProto::SearchAdvanced(HWND owner)
{
TCHAR buf[512];
- int ret = 0;
if (GetDlgItemText(owner, IDC_EDIT1, buf, SIZEOF(buf))) {
debugLog(_T("CSametimeProto::SearchAdvanced() buf:len=[%d]"), buf == NULL ? -1 : mir_tstrlen(buf));
- char* buf_utf8 = mir_utf8encodeT(buf);
- ret = SearchForUser(buf_utf8, TRUE);
- mir_free(buf_utf8);
+ return (HWND)SearchForUser(T2Utf(buf), TRUE);
}
- return (HWND)ret;
+ return NULL;
}
HWND CSametimeProto::CreateExtendedSearchUI(HWND owner)
diff --git a/protocols/Sametime/src/sametime_session.cpp b/protocols/Sametime/src/sametime_session.cpp index 3adfbdf8ec..c0ee790d85 100644 --- a/protocols/Sametime/src/sametime_session.cpp +++ b/protocols/Sametime/src/sametime_session.cpp @@ -319,7 +319,7 @@ void CSametimeProto::SetSessionAwayMessage(int status, const PROTOCHAR* msgT) {
debugLog(_T("SetSessionAwayMessage() status=[%d], msgT:len=[%d]"), status, msgT == NULL ? -1 : mir_tstrlen(msgT));
- ptrA msg(mir_utf8encodeT(msgT));
+ T2Utf msg(msgT);
if (status == ID_STATUS_ONLINE)
replaceStr(AwayMessages.szOnline, msg);
else if (status == ID_STATUS_AWAY)
@@ -540,9 +540,8 @@ void CSametimeProto::DeinitAwayMsg() void SendAnnouncement(SendAnnouncementFunc_arg* arg)
{
CSametimeProto* proto = arg->proto;
- char* utfs = mir_utf8encodeT(arg->msg);
- if (proto->session && arg->recipients) mwSession_sendAnnounce(proto->session, false, utfs, arg->recipients);
- mir_free(utfs);
+ if (proto->session && arg->recipients)
+ mwSession_sendAnnounce(proto->session, false, T2Utf(arg->msg), arg->recipients);
}
INT_PTR CSametimeProto::SessionAnnounce(WPARAM wParam, LPARAM lParam)
diff --git a/protocols/SkypeWeb/src/requests/chatrooms.h b/protocols/SkypeWeb/src/requests/chatrooms.h index f5a1dfd6db..57e76b2cf2 100644 --- a/protocols/SkypeWeb/src/requests/chatrooms.h +++ b/protocols/SkypeWeb/src/requests/chatrooms.h @@ -54,7 +54,7 @@ public: json_push_back(node, json_new_a("contenttype", "text"));
json_push_back(node, json_new_a("content", ptrA(mir_utf8encode(message))));
- ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
+ T2Utf data(ptrT(json_write(node)));
Body << VALUE(data);
json_delete(node);
@@ -79,7 +79,7 @@ public: json_push_back(node, json_new_a("content", ptrA(mir_utf8encode(message))));
json_push_back(node, json_new_i("skypeemoteoffset", 4));
- ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
+ T2Utf data(ptrT(json_write(node)));
Body << VALUE(data);
json_delete(node);
diff --git a/protocols/SkypeWeb/src/requests/messages.h b/protocols/SkypeWeb/src/requests/messages.h index 922253b0df..3523a95f47 100644 --- a/protocols/SkypeWeb/src/requests/messages.h +++ b/protocols/SkypeWeb/src/requests/messages.h @@ -34,7 +34,7 @@ public: json_push_back(node, json_new_a("contenttype", "text"));
json_push_back(node, json_new_a("content", message));
- ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
+ T2Utf data(ptrT(json_write(node)));
Body << VALUE(data);
json_delete(node);
@@ -62,7 +62,7 @@ public: json_push_back(node, json_new_a("content", content));
json_push_back(node, json_new_i("skypeemoteoffset", (int)(mir_strlen(username) + 1)));
- ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
+ T2Utf data(ptrT(json_write(node)));
Body << VALUE(data);
json_delete(node);
@@ -88,7 +88,7 @@ public: json_push_back(node, json_new_a("contenttype", "text"));
json_push_back(node, json_new_a("content", ""));
- ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
+ T2Utf data(ptrT(json_write(node)));
Body << VALUE(data);
json_delete(node);
diff --git a/protocols/SkypeWeb/src/requests/subscriptions.h b/protocols/SkypeWeb/src/requests/subscriptions.h index 718d342d72..c0777819b0 100644 --- a/protocols/SkypeWeb/src/requests/subscriptions.h +++ b/protocols/SkypeWeb/src/requests/subscriptions.h @@ -42,7 +42,7 @@ public: json_push_back(interestedResources, json_new_a(NULL, "/v1/threads/ALL"));
json_push_back(node, interestedResources);
- ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
+ T2Utf data(ptrT(json_write(node)));
Body << VALUE(data);
diff --git a/protocols/SkypeWeb/src/requests/trouter.h b/protocols/SkypeWeb/src/requests/trouter.h index 89bad5a14b..1d68e78470 100644 --- a/protocols/SkypeWeb/src/requests/trouter.h +++ b/protocols/SkypeWeb/src/requests/trouter.h @@ -40,10 +40,8 @@ public: JSONNODE *node = json_new(5);
json_push_back(node, json_new_a("sr", sr));
- ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
-
- Body << VALUE(data);
+ Body << VALUE(T2Utf(ptrT(json_write(node))));
json_delete(node);
}
//{"sr":"AUKRNgA8_eKV0Ibsx037Gbd8GVrsDg8zLQRt1pH8sCyIAile3gtoWmlq2x1yZ_VNZ3tf","issuer":"edf","sp":"connect","st":"1430236511619","se":"1430318082619","sig":"nYczCdlBENCxoAFLy7lPkGELVV1w5TcUnpSUE2G7GLA"}
@@ -85,7 +83,7 @@ public: json_push_back(transports, TROUTER);
json_push_back(node, transports);
- ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
+ T2Utf data(ptrT(json_write(node)));
Body << VALUE(data);
diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp index fde3788e65..26628255b3 100644 --- a/protocols/SkypeWeb/src/skype_proto.cpp +++ b/protocols/SkypeWeb/src/skype_proto.cpp @@ -168,7 +168,7 @@ int CSkypeProto::AuthRequest(MCONTACT hContact, const PROTOCHAR *szMessage) ptrA token(getStringA("TokenSecret"));
ptrA skypename(getStringA(hContact, SKYPE_SETTINGS_ID));
- PushRequest(new AddContactRequest(token, skypename, ptrA(mir_utf8encodeT(szMessage))));
+ PushRequest(new AddContactRequest(token, skypename, T2Utf(szMessage)));
return 0;
}
diff --git a/protocols/SkypeWeb/src/skype_search.cpp b/protocols/SkypeWeb/src/skype_search.cpp index 67f3892f02..b74daf47c1 100644 --- a/protocols/SkypeWeb/src/skype_search.cpp +++ b/protocols/SkypeWeb/src/skype_search.cpp @@ -30,7 +30,7 @@ void CSkypeProto::SearchBasicThread(void* id) return;
ptrT idT((TCHAR *)id);
- ptrA string(mir_urlEncode(ptrA(mir_utf8encodeT(idT))));
+ ptrA string(mir_urlEncode(T2Utf(idT)));
SendRequest(new GetSearchRequest(TokenSecret, string), &CSkypeProto::OnSearch);
}
diff --git a/protocols/Steam/src/steam_pooling.cpp b/protocols/Steam/src/steam_pooling.cpp index 912af1e7a5..4ea31428e8 100644 --- a/protocols/Steam/src/steam_pooling.cpp +++ b/protocols/Steam/src/steam_pooling.cpp @@ -30,7 +30,7 @@ void CSteamProto::ParsePollData(JSONNODE *data) node = json_get(item, "text"); ptrT text(json_as_string(node)); - ptrA szMessage(mir_utf8encodeT(text)); + T2Utf szMessage(text); if (_tcsstr(type, _T("my_")) == NULL) { diff --git a/protocols/Steam/src/steam_queue.cpp b/protocols/Steam/src/steam_queue.cpp index fee24bee64..c838b91294 100644 --- a/protocols/Steam/src/steam_queue.cpp +++ b/protocols/Steam/src/steam_queue.cpp @@ -36,7 +36,7 @@ void CSteamProto::StartQueue() } else { - ptrA username(mir_urlEncode(ptrA(mir_utf8encodeT(getTStringA("Username"))))); + ptrA username(mir_urlEncode(T2Utf(getTStringA("Username")))); if (username == NULL || username[0] == '\0') return; diff --git a/protocols/Tox/src/tox_multimedia.cpp b/protocols/Tox/src/tox_multimedia.cpp index 0325794eb2..2068b64a44 100644 --- a/protocols/Tox/src/tox_multimedia.cpp +++ b/protocols/Tox/src/tox_multimedia.cpp @@ -291,14 +291,13 @@ void CToxProto::OnAvInvite(void*, int32_t callId, void *arg) TCHAR message[MAX_PATH];
mir_sntprintf(message, SIZEOF(message), TranslateT("Incoming call from %s"), pcli->pfnGetContactDisplayName(hContact, 0));
+ T2Utf szMessage(message);
PROTORECVEVENT recv = { 0 };
recv.timestamp = time(NULL);
recv.lParam = callId;
- recv.szMessage = mir_utf8encodeT(message);
+ recv.szMessage = szMessage;
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 ab48ce60a2..3891400c79 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -219,7 +219,7 @@ int CToxProto::SetAwayMsg(int, const PROTOCHAR *msg) {
if (IsOnline())
{
- ptrA statusMessage(mir_utf8encodeT(msg));
+ T2Utf statusMessage(msg);
TOX_ERR_SET_INFO error;
if (tox_self_set_status_message(tox, (uint8_t*)(char*)statusMessage, min(TOX_MAX_STATUS_MESSAGE_LENGTH, mir_strlen(statusMessage)), &error))
debugLogA("CToxProto::SetAwayMsg: failed to set status status message %s (%d)", msg, error);
diff --git a/protocols/Tox/src/tox_search.cpp b/protocols/Tox/src/tox_search.cpp index 0eb8eca77e..c9962d90a0 100644 --- a/protocols/Tox/src/tox_search.cpp +++ b/protocols/Tox/src/tox_search.cpp @@ -190,7 +190,7 @@ HWND CToxProto::OnSearchAdvanced(HWND owner) TCHAR text[MAX_PATH];
GetDlgItemText(owner, IDC_SEARCH, text, SIZEOF(text));
- const std::string query = ptrA(mir_utf8encodeT(text));
+ const std::string query = T2Utf(text);
if (std::regex_search(query, match, regex))
{
std::string address = match[1];
diff --git a/protocols/Tox/src/tox_services.cpp b/protocols/Tox/src/tox_services.cpp index 3b5ba18395..f42a3d35c0 100644 --- a/protocols/Tox/src/tox_services.cpp +++ b/protocols/Tox/src/tox_services.cpp @@ -3,10 +3,11 @@ INT_PTR CToxProto::SetMyNickname(WPARAM wParam, LPARAM lParam)
{
ptrT nickname((wParam & SMNN_UNICODE) ? mir_u2t((TCHAR*)lParam) : mir_a2t((char*)lParam));
-
setTString("Nick", nickname);
+
+ T2Utf szNick8(nickname);
TOX_ERR_SET_INFO error;
- if (!tox_self_set_name(tox, (uint8_t*)(char*)ptrA(mir_utf8encodeT(nickname)), mir_tstrlen(nickname), &error))
+ if (!tox_self_set_name(tox, szNick8, mir_strlen(szNick8), &error))
{
debugLogA(__FUNCTION__": failed to set nick name");
return 1;
diff --git a/protocols/Twitter/src/chat.cpp b/protocols/Twitter/src/chat.cpp index 5990cb63a1..6771ce6cd2 100644 --- a/protocols/Twitter/src/chat.cpp +++ b/protocols/Twitter/src/chat.cpp @@ -66,7 +66,7 @@ int TwitterProto::OnChatOutgoing(WPARAM, LPARAM lParam) case GC_USER_MESSAGE:
debugLog(_T("**Chat - Outgoing message: %s"), hook->ptszText);
{
- ptrA text(mir_utf8encodeT(hook->ptszText));
+ T2Utf text(hook->ptszText);
std::string tweet(text);
replaceAll(tweet, "%%", "%"); // the chat plugin will turn "%" into "%%", so we have to change it back :/
diff --git a/protocols/Twitter/src/contacts.cpp b/protocols/Twitter/src/contacts.cpp index cea1ce17ef..e58c6ee01f 100644 --- a/protocols/Twitter/src/contacts.cpp +++ b/protocols/Twitter/src/contacts.cpp @@ -107,14 +107,13 @@ void TwitterProto::DoSearch(void *p) bool found = false;
try {
- char *p = mir_utf8encodeT(query->query.c_str());
+ T2Utf p(query->query.c_str());
mir_cslock s(twitter_lock_);
if (query->by_email)
- found = twit_.get_info_by_email(p, &info);
+ found = twit_.get_info_by_email(p.str(), &info);
else
- found = twit_.get_info(p, &info);
- mir_free(p);
+ found = twit_.get_info(p.str(), &info);
}
catch (const std::exception &e) {
ShowPopup((std::string("While searching for contacts, an error occurred: ") + e.what()).c_str());
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index e90b7b84fd..357a094f69 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -463,9 +463,9 @@ bool CVkProto::AutoFillForm(char *pBody, CMStringA &szAction, CMStringA& szResul CMStringA name = getAttr(pFieldBeg, "name");
CMStringA value = getAttr(pFieldBeg, "value");
if (name == "email")
- value = ptrA(mir_utf8encodeT(ptrT(getTStringA("Login"))));
+ value = (char*)T2Utf(ptrT(getTStringA("Login")));
else if (name == "pass")
- value = ptrA(mir_utf8encodeT(ptrT(GetUserStoredPassword())));
+ value = (char*)T2Utf(ptrT(GetUserStoredPassword()));
else if (name == "captcha_key") {
char *pCaptchaBeg = strstr(pFormBeg, "<img id=\"captcha\"");
if (pCaptchaBeg != NULL)
@@ -580,9 +580,9 @@ void CVkProto::DBAddAuthRequest(const MCONTACT hContact) {
debugLogA("CVkProto::DBAddAuthRequest");
- ptrA szNick(mir_utf8encodeT(ptrT(db_get_tsa(hContact, m_szModuleName, "Nick"))));
- ptrA szFirstName(mir_utf8encodeT(ptrT(db_get_tsa(hContact, m_szModuleName, "FirstName"))));
- ptrA szLastName(mir_utf8encodeT(ptrT(db_get_tsa(hContact, m_szModuleName, "LastName"))));
+ T2Utf szNick(ptrT(db_get_tsa(hContact, m_szModuleName, "Nick")));
+ T2Utf szFirstName(ptrT(db_get_tsa(hContact, m_szModuleName, "FirstName")));
+ T2Utf szLastName(ptrT(db_get_tsa(hContact, m_szModuleName, "LastName")));
//blob is: uin(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
//blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), ""(ASCIIZ), ""(ASCIIZ)
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index ea75491a07..b2c7fd4060 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -376,7 +376,7 @@ int CVkProto::OnChatEvent(WPARAM, LPARAM lParam) UnEscapeChatTags(buf);
AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, &CVkProto::OnSendChatMsg, AsyncHttpRequest::rpHigh)
<< INT_PARAM("chat_id", cc->m_chatid)
- << CHAR_PARAM("message", mir_utf8encodeT(buf))
+ << CHAR_PARAM("message", T2Utf(buf))
<< VER_API;
pReq->AddHeader("Content-Type", "application/x-www-form-urlencoded");
Push(pReq);
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp index cd84677cc8..966d1ccaee 100644 --- a/protocols/VKontakte/src/vk_feed.cpp +++ b/protocols/VKontakte/src/vk_feed.cpp @@ -54,7 +54,7 @@ void CVkProto::AddFeedEvent(CMString& tszBody, time_t tTime) }
MCONTACT hContact = FindUser(VK_FEED_USER, true);
- ptrA pszBody(mir_utf8encodeT(tszBody));
+ T2Utf pszBody(tszBody);
PROTORECVEVENT recv = { 0 };
recv.timestamp = tTime;
diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp index 0bdf7aefeb..bcc509c3e4 100644 --- a/protocols/VKontakte/src/vk_files.cpp +++ b/protocols/VKontakte/src/vk_files.cpp @@ -48,7 +48,7 @@ CVkFileUploadParam::VKFileType CVkFileUploadParam::GetType() _tsplitpath(FileName, DRIVE, DIR, FNAME, EXT);
CMStringA fn;
- ptrA pszFNAME(mir_utf8encodeT(FNAME)), pszEXT(mir_utf8encodeT(EXT));
+ T2Utf pszFNAME(FNAME), pszEXT(EXT);
fn.AppendFormat("%s%s", pszFNAME, pszEXT);
fname = mir_strdup(fn.GetBuffer());
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp index fb10ae9c05..a07b003730 100644 --- a/protocols/VKontakte/src/vk_history.cpp +++ b/protocols/VKontakte/src/vk_history.cpp @@ -216,6 +216,7 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque ptszBody = mir_tstrdup(CMString(ptszBody) + tszAttachmentDescr);
}
+ T2Utf pszBody(ptszBody);
MCONTACT hContact = FindUser(uid, true);
PROTORECVEVENT recv = { 0 };
if (isRead)
@@ -223,14 +224,13 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque if (isOut)
recv.flags |= PREF_SENT;
recv.timestamp = datetime;
- recv.szMessage = mir_utf8encodeT(ptszBody);
+ recv.szMessage = pszBody;
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 6a9d6825ed..1c24dc30e5 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -253,8 +253,9 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe else if (m_bUserForceOnlineOnActivity)
SetInvisible(hContact);
+ T2Utf pszBody(ptszBody);
recv.timestamp = m_bUseLocalTime ? time(NULL) : datetime;
- recv.szMessage = mir_utf8encodeT(ptszBody);
+ recv.szMessage = pszBody;
recv.lParam = isOut;
recv.pCustomData = szMid;
recv.cbCustomDataSize = (int)mir_strlen(szMid);
@@ -270,8 +271,6 @@ 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_options.cpp b/protocols/VKontakte/src/vk_options.cpp index 78f417c487..0e169aceb9 100644 --- a/protocols/VKontakte/src/vk_options.cpp +++ b/protocols/VKontakte/src/vk_options.cpp @@ -67,7 +67,7 @@ INT_PTR CALLBACK VKAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP ppro->setTString("Login", str);
GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
- ptrA szRawPasswd(mir_utf8encodeT(str));
+ T2Utf szRawPasswd(str);
if (szRawPasswd != NULL)
ppro->setString("Password", szRawPasswd);
}
@@ -180,7 +180,7 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L }
GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
- ptrA szRawPasswd(mir_utf8encodeT(str));
+ T2Utf szRawPasswd(str);
if (szRawPasswd != NULL)
ppro->setString("Password", szRawPasswd);
diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp index c01442fa26..4934c3a29f 100644 --- a/protocols/VKontakte/src/vk_queue.cpp +++ b/protocols/VKontakte/src/vk_queue.cpp @@ -177,7 +177,7 @@ AsyncHttpRequest* operator<<(AsyncHttpRequest *pReq, const CHAR_PARAM ¶m) AsyncHttpRequest* operator<<(AsyncHttpRequest *pReq, const TCHAR_PARAM ¶m)
{
- ptrA szValue(mir_utf8encodeT(param.tszValue));
+ T2Utf szValue(param.tszValue);
CMStringA &s = pReq->m_szParam;
if (!s.IsEmpty())
s.AppendChar('&');
diff --git a/protocols/WhatsApp/src/chat.cpp b/protocols/WhatsApp/src/chat.cpp index 8f4469af3e..68ccac9a58 100644 --- a/protocols/WhatsApp/src/chat.cpp +++ b/protocols/WhatsApp/src/chat.cpp @@ -25,7 +25,7 @@ INT_PTR __cdecl WhatsAppProto::OnCreateGroup(WPARAM wParam, LPARAM lParam) es.szModuleName = m_szModuleName;
if (EnterString(&es)) {
if (isOnline()) {
- std::string groupName(ptrA(mir_utf8encodeT(es.ptszResult)));
+ std::string groupName(T2Utf(es.ptszResult));
m_pConnection->sendCreateGroupChat(groupName);
}
mir_free(es.ptszResult);
@@ -43,7 +43,7 @@ int WhatsAppProto::onGroupChatEvent(WPARAM wParam, LPARAM lParam) if (mir_strcmp(gch->pDest->pszModule, m_szModuleName))
return 0;
- std::string chat_id(ptrA(mir_utf8encodeT(gch->pDest->ptszID)));
+ std::string chat_id(T2Utf(gch->pDest->ptszID));
WAChatInfo *pInfo = SafeGetChat(chat_id);
if (pInfo == NULL)
return 0;
@@ -59,7 +59,7 @@ int WhatsAppProto::onGroupChatEvent(WPARAM wParam, LPARAM lParam) case GC_USER_MESSAGE:
if (isOnline()) {
- std::string msg(ptrA(mir_utf8encodeT(gch->ptszText)));
+ std::string msg(T2Utf(gch->ptszText));
try {
int msgId = GetSerial();
@@ -156,8 +156,8 @@ void WhatsAppProto::EditChatSubject(WAChatInfo *pInfo) es.caption = title;
es.szDataPrefix = "setSubject_";
if (EnterString(&es)) {
- ptrA gjid(mir_utf8encodeT(pInfo->tszJid));
- ptrA gsubject(mir_utf8encodeT(es.ptszResult));
+ T2Utf gjid(pInfo->tszJid);
+ T2Utf gsubject(es.ptszResult);
m_pConnection->sendSetNewSubject(std::string(gjid), std::string(gsubject));
mir_free(es.ptszResult);
}
diff --git a/protocols/WhatsApp/src/proto.cpp b/protocols/WhatsApp/src/proto.cpp index 2bf2bd88db..b594ad63fd 100644 --- a/protocols/WhatsApp/src/proto.cpp +++ b/protocols/WhatsApp/src/proto.cpp @@ -168,7 +168,7 @@ MCONTACT WhatsAppProto::AddToList(int flags, PROTOSEARCHRESULT* psr) if (psr->id == NULL)
return NULL;
- std::string phone(ptrA(mir_utf8encodeT(psr->id)));
+ std::string phone(T2Utf(psr->id));
std::string jid(phone + "@s.whatsapp.net");
MCONTACT hContact = AddToContactList(jid, phone.c_str());
diff --git a/protocols/Yahoo/src/chat.cpp b/protocols/Yahoo/src/chat.cpp index 39e584b655..6cb48c658e 100644 --- a/protocols/Yahoo/src/chat.cpp +++ b/protocols/Yahoo/src/chat.cpp @@ -289,11 +289,9 @@ int __cdecl CYahooProto::OnGCEventHook(WPARAM, LPARAM lParam) case GC_USER_MESSAGE:
if (gch->ptszText && gch->ptszText[0])
{
- char* msg = mir_utf8encodeT(gch->ptszText);
ChatRoom *cm = m_chatrooms.find((ChatRoom*)&room);
if (cm)
- yahoo_conference_message(m_id, NULL, cm->members, room, msg, 1);
- mir_free(msg);
+ yahoo_conference_message(m_id, NULL, cm->members, room, T2Utf(gch->ptszText), 1);
}
break;
@@ -435,17 +433,13 @@ static void clist_chat_invite_send(MCONTACT hItem, HWND hwndList, YList* &who, c if (root && who)
{
- char *msg8 = mir_utf8encodeT(msg);
+ T2Utf msg8(msg);
CYahooProto::ChatRoom *cm = ppro->m_chatrooms.find((CYahooProto::ChatRoom*)&room);
- if (cm)
- {
+ if (cm) {
for (YList *l = who; l; l = l->next)
yahoo_conference_addinvite(ppro->m_id, NULL, (char*)l->data, room, cm->members, msg8);
}
- else
- yahoo_conference_invite(ppro->m_id, NULL, who, room, msg8);
-
- mir_free(msg8);
+ else yahoo_conference_invite(ppro->m_id, NULL, who, room, msg8);
for (YList *l = who; l; l = l->next) mir_free(l->data);
y_list_free(who);
@@ -630,9 +624,7 @@ INT_PTR CALLBACK ChatRequestDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM {
TCHAR msg[1024];
GetDlgItemText(hwndDlg, IDC_MSG2, msg, SIZEOF(msg));
- char *msg8 = mir_utf8encodeT(msg);
- yahoo_conference_decline(param->ppro->m_id, NULL, cm->members, param->room, msg8);
- mir_free(msg8);
+ yahoo_conference_decline(param->ppro->m_id, NULL, cm->members, param->room, T2Utf(msg));
param->ppro->m_chatrooms.remove((CYahooProto::ChatRoom*)¶m->room);
}
diff --git a/protocols/Yahoo/src/file_transfer.cpp b/protocols/Yahoo/src/file_transfer.cpp index 08a884023d..f757f81a96 100644 --- a/protocols/Yahoo/src/file_transfer.cpp +++ b/protocols/Yahoo/src/file_transfer.cpp @@ -685,13 +685,7 @@ HANDLE __cdecl CYahooProto::SendFile(MCONTACT hContact, const PROTOCHAR* szDescr struct yahoo_file_info *fi = y_new(struct yahoo_file_info,1);
- /**
- * Need to use regular memory allocator/deallocator, since this is how things are build w/ libyahoo2
- */
- char *s = mir_utf8encodeT(ppszFiles[i]);
- fi->filename = strdup(s);
- mir_free(s);
-
+ fi->filename = strdup(T2Utf(ppszFiles[i]));
fi->filesize = tFileSize;
fs = y_list_append(fs, fi);
diff --git a/protocols/Yahoo/src/proto.cpp b/protocols/Yahoo/src/proto.cpp index 50fa071785..c757fa6fe7 100644 --- a/protocols/Yahoo/src/proto.cpp +++ b/protocols/Yahoo/src/proto.cpp @@ -248,10 +248,10 @@ int CYahooProto::AuthDeny(MEVENT hdbe, const TCHAR *reason) /* Need to remove the buddy from our Miranda Lists */
MCONTACT hContact = DbGetAuthEventContact(&dbei);
if (hContact != NULL) {
- ptrA who( getStringA(hContact, YAHOO_LOGINID));
+ ptrA who(getStringA(hContact, YAHOO_LOGINID));
if (who) {
- ptrA myid( getStringA(hContact, "MyIdentity"));
- ptrA u_reason( mir_utf8encodeT(reason));
+ ptrA myid(getStringA(hContact, "MyIdentity"));
+ T2Utf u_reason(reason);
debugLogA("Rejecting buddy:%s msg: %s", who, u_reason);
reject(myid, who, getWord(hContact, "yprotoid", 0), u_reason);
diff --git a/protocols/Yahoo/src/yahoo.cpp b/protocols/Yahoo/src/yahoo.cpp index 3f70ae957a..58c9089d4d 100644 --- a/protocols/Yahoo/src/yahoo.cpp +++ b/protocols/Yahoo/src/yahoo.cpp @@ -200,56 +200,28 @@ void CYahooProto::logout() void CYahooProto::AddBuddy(MCONTACT hContact, const char *group, const TCHAR *msg)
{
- DBVARIANT dbv;
- char *fname=NULL, *lname=NULL, *ident=NULL, *who, *u_msg;
- int protocol;
-
/* We adding a buddy to our list.
2 Stages.
1. We send add buddy packet.
2. We get a packet back from the server confirming add.
No refresh needed. */
-
- if (!getString(hContact, YAHOO_LOGINID, &dbv))
- {
- who = strdup(dbv.pszVal);
- db_free(&dbv);
- }
- else
- return;
-
- protocol = getWord(hContact, "yprotoid", 0);
- u_msg = mir_utf8encodeT(msg);
- if (!getString(hContact, "MyIdentity", &dbv))
- {
- ident = strdup(dbv.pszVal);
- db_free(&dbv);
- }
+ ptrA who(getStringA(hContact, YAHOO_LOGINID));
+ if (who == NULL)
+ return;
- if (!GetStringUtf(NULL, "FirstName", &dbv))
- {
- fname = strdup(dbv.pszVal);
- db_free(&dbv);
- }
+ int protocol = getWord(hContact, "yprotoid", 0);
+ T2Utf u_msg(msg);
- if (!GetStringUtf(NULL, "LastName", &dbv))
- {
- lname = strdup(dbv.pszVal);
- db_free(&dbv);
- }
+ ptrA ident(getStringA(hContact, "MyIdentity"));
+ ptrT fname(getTStringA(NULL, "FirstName"));
+ ptrT lname(getTStringA(NULL, "LastName"));
SetStringUtf(hContact, "YGroup", group);
debugLogA("Adding Permanently %s to list. Auth: %s", who, u_msg ? u_msg : "<None>");
- yahoo_add_buddy(m_id, ident, fname, lname, who, protocol, group, u_msg);
-
- free(fname);
- free(lname);
- free(ident);
- free(who);
- mir_free(u_msg);
+ yahoo_add_buddy(m_id, ident, T2Utf(fname), T2Utf(lname), who, protocol, group, u_msg);
}
MCONTACT CYahooProto::getbuddyH(const char *yahoo_id)
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index 1d9ec43d28..ffe181ffd9 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -75,20 +75,15 @@ int SendMessageDirect(const TCHAR *szMsg, MCONTACT hContact, char *szProto) if (RTL_Detect(szMsg))
flags |= PREF_RTL;
- char *sendBuffer = mir_utf8encodeT(szMsg);
- if (!sendBuffer || !sendBuffer[0]) {
- mir_free(sendBuffer);
- return NULL;
- }
-
- if (sendBuffer == NULL)
+ T2Utf sendBuffer(szMsg);
+ if (!mir_strlen(sendBuffer))
return NULL;
if (db_mc_isMeta(hContact))
hContact = db_mc_getSrmmSub(hContact);
int sendId = CallContactService(hContact, PSS_MESSAGE, flags, (LPARAM)sendBuffer);
- msgQueue_add(hContact, sendId, sendBuffer, flags);
+ msgQueue_add(hContact, sendId, sendBuffer.detach(), flags);
return sendId;
}
|