summaryrefslogtreecommitdiff
path: root/plugins/CmdLine/src/utils.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-02-16 22:07:43 +0200
committerGeorge Hazan <ghazan@miranda.im>2018-02-16 22:08:26 +0200
commit8d127430d057891fbd3ac5989d32090715d7923a (patch)
tree2c02b3401ca7a583302730161c3e11ec9607c1f4 /plugins/CmdLine/src/utils.cpp
parent9cde0c92420f4811a646964c1304f7c55f8a50a5 (diff)
fixes #1143 (CmdLine Plugin error when using Diacritics in message)
Diffstat (limited to 'plugins/CmdLine/src/utils.cpp')
-rw-r--r--plugins/CmdLine/src/utils.cpp44
1 files changed, 9 insertions, 35 deletions
diff --git a/plugins/CmdLine/src/utils.cpp b/plugins/CmdLine/src/utils.cpp
index eb8081ccd0..97c2ef57f7 100644
--- a/plugins/CmdLine/src/utils.cpp
+++ b/plugins/CmdLine/src/utils.cpp
@@ -150,70 +150,44 @@ int GetStringFromDatabase(char *szSettingName, WCHAR *szError, WCHAR *szResult,
}
#pragma warning (disable: 4312)
-char* GetContactName(MCONTACT hContact, char *szProto)
+wchar_t* GetContactName(MCONTACT hContact, char *szProto)
{
- ptrW name(Contact_GetInfo(CNF_DISPLAY, hContact, szProto));
- return (name == NULL) ? nullptr : strdup(_T2A(name));
+ return Contact_GetInfo(CNF_DISPLAY, hContact, szProto);
}
-#pragma warning (default: 4312)
-#pragma warning (disable: 4312)
void GetContactProto(MCONTACT hContact, char *szProto, size_t size)
{
GetStringFromDatabase(hContact, "Protocol", "p", nullptr, szProto, size);
}
-#pragma warning (default: 4312)
-#pragma warning (disable: 4312)
-char* GetContactID(MCONTACT hContact)
+wchar_t* GetContactID(MCONTACT hContact, char *szProto)
{
- char protocol[256];
- GetContactProto(hContact, protocol, sizeof(protocol));
-
- return GetContactID(hContact, protocol);
+ return Contact_GetInfo(CNF_UNIQUEID, hContact, szProto);
}
-char* GetContactID(MCONTACT hContact, char *szProto)
+MCONTACT GetContactFromID(wchar_t *szID, char *szProto)
{
- ptrW name(Contact_GetInfo(CNF_UNIQUEID, hContact, szProto));
- return (name == NULL) ? nullptr : strdup(_T2A(name));
-}
-#pragma warning (default: 4312)
-
-#pragma warning (disable: 4312)
-MCONTACT GetContactFromID(char *szID, char *szProto)
-{
- char dispName[1024];
+ wchar_t dispName[1024];
char cProtocol[256];
int found = 0;
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
GetContactProto(hContact, cProtocol, sizeof(cProtocol));
- char *szHandle = GetContactID(hContact, cProtocol);
+ ptrW szHandle(GetContactID(hContact, cProtocol));
wchar_t *tmp = pcli->pfnGetContactDisplayName(hContact, 0);
- strncpy_s(dispName, _T2A(tmp), _TRUNCATE);
+ wcsncpy_s(dispName, tmp, _TRUNCATE);
- if ((szHandle) && ((mir_strcmpi(szHandle, szID) == 0) || (mir_strcmpi(dispName, szID) == 0)) && ((szProto == nullptr) || (_stricmp(szProto, cProtocol) == 0)))
+ if ((szHandle) && ((mir_wstrcmpi(szHandle, szID) == 0) || (mir_wstrcmpi(dispName, szID) == 0)) && ((szProto == nullptr) || (_stricmp(szProto, cProtocol) == 0)))
found = 1;
- free(szHandle);
-
if (found)
return hContact;
}
return 0;
}
-#pragma warning (default: 4312)
-#pragma warning (disable: 4312)
-MCONTACT GetContactFromID(char *szID, wchar_t *szProto)
-{
- char protocol[1024];
- WideCharToMultiByte(CP_ACP, 0, szProto, -1, protocol, sizeof(protocol), nullptr, nullptr);
- return GetContactFromID(szID, protocol);
-}
#pragma warning (default: 4312)
void ScreenToClient(HWND hWnd, LPRECT rect)