diff options
author | George Hazan <george.hazan@gmail.com> | 2015-05-22 16:04:17 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-05-22 16:04:17 +0000 |
commit | e2c2a1f5a84c6c9b705dc85c6a2dd1f97edd57e4 (patch) | |
tree | ba79bdcede96f80039f8b88d2791f198b9ec2981 /plugins | |
parent | f8e34b5f83f3ce5f39d541e9068b6b8cb6d92acd (diff) |
T2Utf - handy replacement for ptrA<mir_utf8decodeT()>
git-svn-id: http://svn.miranda-ng.org/main/trunk@13758 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
39 files changed, 207 insertions, 291 deletions
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 '%':
|