From 6e53dfca72b932c4bdcd7aa02ca62bf8b2630eac Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 26 Jul 2016 09:20:25 +0000 Subject: less TCHARs: - TCHAR is replaced with wchar_t everywhere; - LPGENT replaced with either LPGENW or LPGEN; - fixes for ANSI plugins that improperly used _t functions; - TCHAR *t removed from MAllStrings; - ptszGroup, ptszTitle & ptszTab in OPTIONSDIALOGPAGE replaced with pwsz* git-svn-id: http://svn.miranda-ng.org/main/trunk@17133 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- .../WhatsApp/src/WhatsAPI++/MediaUploader.cpp | 2 +- protocols/WhatsApp/src/avatars.cpp | 30 ++++++++-------- protocols/WhatsApp/src/chat.cpp | 42 +++++++++++----------- protocols/WhatsApp/src/contacts.cpp | 14 ++++---- protocols/WhatsApp/src/dialogs.cpp | 26 +++++++------- protocols/WhatsApp/src/entities.h | 6 ++-- protocols/WhatsApp/src/main.cpp | 2 +- protocols/WhatsApp/src/media.cpp | 6 ++-- protocols/WhatsApp/src/messages.cpp | 6 ++-- protocols/WhatsApp/src/proto.cpp | 36 +++++++++---------- protocols/WhatsApp/src/proto.h | 28 +++++++-------- protocols/WhatsApp/src/utils.cpp | 14 ++++---- protocols/WhatsApp/src/utils.h | 8 ++--- 13 files changed, 110 insertions(+), 110 deletions(-) (limited to 'protocols/WhatsApp/src') diff --git a/protocols/WhatsApp/src/WhatsAPI++/MediaUploader.cpp b/protocols/WhatsApp/src/WhatsAPI++/MediaUploader.cpp index 9b85cf80bb..ef8fec4bb3 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/MediaUploader.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/MediaUploader.cpp @@ -19,7 +19,7 @@ static NETLIBHTTPHEADER s_imageHeaders[] = { "Content-Type", "multipart/form-data; boundary=zzXXzzYYzzXXzzQQ" } }; -static std::vector* sttFileToMem(const TCHAR *ptszFileName) +static std::vector* sttFileToMem(const wchar_t *ptszFileName) { HANDLE hFile = CreateFile(ptszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) diff --git a/protocols/WhatsApp/src/avatars.cpp b/protocols/WhatsApp/src/avatars.cpp index 2121430f62..e1839586e6 100644 --- a/protocols/WhatsApp/src/avatars.cpp +++ b/protocols/WhatsApp/src/avatars.cpp @@ -8,8 +8,8 @@ INT_PTR WhatsAppProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) if (id == NULL) return GAIR_NOAVATAR; - std::tstring tszFileName = GetAvatarFileName(pai->hContact); - _tcsncpy_s(pai->filename, tszFileName.c_str(), _TRUNCATE); + std::wstring tszFileName = GetAvatarFileName(pai->hContact); + wcsncpy_s(pai->filename, tszFileName.c_str(), _TRUNCATE); pai->format = PA_FORMAT_JPEG; ptrA szAvatarId(getStringA(pai->hContact, WHATSAPP_KEY_AVATAR_ID)); @@ -44,9 +44,9 @@ INT_PTR WhatsAppProto::GetAvatarCaps(WPARAM wParam, LPARAM lParam) return -1; } -std::tstring WhatsAppProto::GetAvatarFileName(MCONTACT hContact) +std::wstring WhatsAppProto::GetAvatarFileName(MCONTACT hContact) { - std::tstring result = m_tszAvatarFolder + L"\\"; + std::wstring result = m_tszAvatarFolder + L"\\"; std::string jid; if (hContact != NULL) { @@ -58,17 +58,17 @@ std::tstring WhatsAppProto::GetAvatarFileName(MCONTACT hContact) } else jid = m_szJid; - return result + std::tstring(_A2T(jid.c_str())) + L".jpg"; + return result + std::wstring(_A2T(jid.c_str())) + L".jpg"; } INT_PTR WhatsAppProto::GetMyAvatar(WPARAM wParam, LPARAM lParam) { - std::tstring tszOwnAvatar(m_tszAvatarFolder + L"\\myavatar.jpg"); - _tcsncpy_s((TCHAR*)wParam, lParam, tszOwnAvatar.c_str(), _TRUNCATE); + std::wstring tszOwnAvatar(m_tszAvatarFolder + L"\\myavatar.jpg"); + wcsncpy_s((wchar_t*)wParam, lParam, tszOwnAvatar.c_str(), _TRUNCATE); return 0; } -static std::vector* sttFileToMem(const TCHAR *ptszFileName) +static std::vector* sttFileToMem(const wchar_t *ptszFileName) { HANDLE hFile = CreateFile(ptszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) @@ -81,12 +81,12 @@ static std::vector* sttFileToMem(const TCHAR *ptszFileName) return result; } -int WhatsAppProto::InternalSetAvatar(MCONTACT hContact, const char *szJid, const TCHAR *ptszFileName) +int WhatsAppProto::InternalSetAvatar(MCONTACT hContact, const char *szJid, const wchar_t *ptszFileName) { if (!isOnline() || ptszFileName == NULL) return 1; - if (_taccess(ptszFileName, 4) != 0) + if (_waccess(ptszFileName, 4) != 0) return errno; ResizeBitmap resize = { 0 }; @@ -100,15 +100,15 @@ int WhatsAppProto::InternalSetAvatar(MCONTACT hContact, const char *szJid, const if (hbmpPreview == NULL) return 3; - TCHAR tszTempFile[MAX_PATH], tszMyFile[MAX_PATH]; + wchar_t tszTempFile[MAX_PATH], tszMyFile[MAX_PATH]; if (hContact == NULL) { mir_sntprintf(tszMyFile, L"%s\\myavatar.jpg", m_tszAvatarFolder.c_str()); mir_sntprintf(tszTempFile, L"%s\\myavatar.preview.jpg", m_tszAvatarFolder.c_str()); } else { - std::tstring tszContactAva = GetAvatarFileName(hContact); - _tcsncpy_s(tszMyFile, tszContactAva.c_str(), _TRUNCATE); - _tcsncpy_s(tszTempFile, (tszContactAva + L".preview").c_str(), _TRUNCATE); + std::wstring tszContactAva = GetAvatarFileName(hContact); + wcsncpy_s(tszMyFile, tszContactAva.c_str(), _TRUNCATE); + wcsncpy_s(tszTempFile, (tszContactAva + L".preview").c_str(), _TRUNCATE); } IMGSRVC_INFO saveInfo = { sizeof(saveInfo), 0 }; @@ -130,5 +130,5 @@ int WhatsAppProto::InternalSetAvatar(MCONTACT hContact, const char *szJid, const INT_PTR WhatsAppProto::SetMyAvatar(WPARAM, LPARAM lParam) { - return InternalSetAvatar(NULL, m_szJid.c_str(), (const TCHAR*)lParam); + return InternalSetAvatar(NULL, m_szJid.c_str(), (const wchar_t*)lParam); } diff --git a/protocols/WhatsApp/src/chat.cpp b/protocols/WhatsApp/src/chat.cpp index e55e8274cf..f33a628461 100644 --- a/protocols/WhatsApp/src/chat.cpp +++ b/protocols/WhatsApp/src/chat.cpp @@ -1,6 +1,6 @@ #include "stdafx.h" -static const TCHAR *sttStatuses[] = { LPGENT("Members"), LPGENT("Owners") }; +static const wchar_t *sttStatuses[] = { LPGENW("Members"), LPGENW("Owners") }; enum { @@ -100,17 +100,17 @@ int WhatsAppProto::onGroupChatEvent(WPARAM, LPARAM lParam) static gc_item sttLogListItems[] = { - { LPGENT("&Invite a user"), IDM_INVITE, MENU_ITEM }, + { LPGENW("&Invite a user"), IDM_INVITE, MENU_ITEM }, { NULL, 0, MENU_SEPARATOR }, - { LPGENT("&Room options"), 0, MENU_NEWPOPUP }, - { LPGENT("View/change &topic"), IDM_TOPIC, MENU_POPUPITEM }, - { LPGENT("&Quit chat session"), IDM_LEAVE, MENU_POPUPITEM }, + { LPGENW("&Room options"), 0, MENU_NEWPOPUP }, + { LPGENW("View/change &topic"), IDM_TOPIC, MENU_POPUPITEM }, + { LPGENW("&Quit chat session"), IDM_LEAVE, MENU_POPUPITEM }, #ifdef _DEBUG - { LPGENT("Set &avatar"), IDM_AVATAR, MENU_POPUPITEM }, // doesn't work, therefore commented out + { LPGENW("Set &avatar"), IDM_AVATAR, MENU_POPUPITEM }, // doesn't work, therefore commented out #endif { NULL, 0, MENU_SEPARATOR }, - { LPGENT("Copy room &JID"), IDM_CPY_RJID, MENU_ITEM }, - { LPGENT("Copy room topic"), IDM_CPY_TOPIC, MENU_ITEM }, + { LPGENW("Copy room &JID"), IDM_CPY_RJID, MENU_ITEM }, + { LPGENW("Copy room topic"), IDM_CPY_TOPIC, MENU_ITEM }, }; void WhatsAppProto::ChatLogMenuHook(WAChatInfo *pInfo, struct GCHOOK *gch) @@ -165,7 +165,7 @@ void WhatsAppProto::EditChatSubject(WAChatInfo *pInfo) void WhatsAppProto::SetChatAvatar(WAChatInfo *pInfo) { - TCHAR tszFileName[MAX_PATH], filter[256]; + wchar_t tszFileName[MAX_PATH], filter[256]; Bitmap_GetFilter(filter, _countof(filter)); OPENFILENAME ofn = { 0 }; @@ -178,7 +178,7 @@ void WhatsAppProto::SetChatAvatar(WAChatInfo *pInfo) ofn.lpstrInitialDir = L"."; ofn.lpstrDefExt = L""; if (GetOpenFileName(&ofn)) - if (_taccess(tszFileName, 4) != -1) + if (_waccess(tszFileName, 4) != -1) InternalSetAvatar(pInfo->hContact, _T2A(pInfo->tszJid), tszFileName); } @@ -187,12 +187,12 @@ void WhatsAppProto::SetChatAvatar(WAChatInfo *pInfo) static gc_item sttNickListItems[] = { - { LPGENT("&Add to roster"), IDM_ADD_RJID, MENU_POPUPITEM }, + { LPGENW("&Add to roster"), IDM_ADD_RJID, MENU_POPUPITEM }, { NULL, 0, MENU_SEPARATOR }, - { LPGENT("&Kick"), IDM_KICK, MENU_ITEM }, + { LPGENW("&Kick"), IDM_KICK, MENU_ITEM }, { NULL, 0, MENU_SEPARATOR }, - { LPGENT("Copy &nickname"), IDM_CPY_NICK, MENU_ITEM }, - { LPGENT("Copy real &JID"), IDM_CPY_RJID, MENU_ITEM }, + { LPGENW("Copy &nickname"), IDM_CPY_NICK, MENU_ITEM }, + { LPGENW("Copy real &JID"), IDM_CPY_RJID, MENU_ITEM }, }; void WhatsAppProto::NickListMenuHook(WAChatInfo *pInfo, struct GCHOOK *gch) @@ -216,7 +216,7 @@ void WhatsAppProto::NickListMenuHook(WAChatInfo *pInfo, struct GCHOOK *gch) } } -void WhatsAppProto::AddChatUser(WAChatInfo*, const TCHAR *ptszJid) +void WhatsAppProto::AddChatUser(WAChatInfo*, const wchar_t *ptszJid) { std::string jid((char*)_T2A(ptszJid)); MCONTACT hContact = ContactIDToHContact(jid); @@ -226,8 +226,8 @@ void WhatsAppProto::AddChatUser(WAChatInfo*, const TCHAR *ptszJid) PROTOSEARCHRESULT psr = { 0 }; psr.cbSize = sizeof(psr); psr.flags = PSR_TCHAR; - psr.id.t = (TCHAR*)ptszJid; - psr.nick.t = GetChatUserNick(jid); + psr.id.w = (wchar_t*)ptszJid; + psr.nick.w = GetChatUserNick(jid); ADDCONTACTSTRUCT acs = { 0 }; acs.handleType = HANDLE_SEARCHRESULT; @@ -236,7 +236,7 @@ void WhatsAppProto::AddChatUser(WAChatInfo*, const TCHAR *ptszJid) CallService(MS_ADDCONTACT_SHOW, (WPARAM)pcli->hwndContactList, (LPARAM)&acs); } -void WhatsAppProto::KickChatUser(WAChatInfo *pInfo, const TCHAR *ptszJid) +void WhatsAppProto::KickChatUser(WAChatInfo *pInfo, const wchar_t *ptszJid) { if (!isOnline()) return; @@ -290,7 +290,7 @@ int WhatsAppProto::OnChatMenu(WPARAM, LPARAM lParam) WAChatInfo* WhatsAppProto::InitChat(const std::string &jid, const std::string &nick) { - TCHAR *ptszJid = str2t(jid), *ptszNick = str2t(nick); + wchar_t *ptszJid = str2t(jid), *ptszNick = str2t(nick); WAChatInfo *pInfo = new WAChatInfo(ptszJid, ptszNick); m_chats[jid] = pInfo; @@ -328,9 +328,9 @@ WAChatInfo* WhatsAppProto::InitChat(const std::string &jid, const std::string &n return pInfo; } -TCHAR* WhatsAppProto::GetChatUserNick(const std::string &jid) +wchar_t* WhatsAppProto::GetChatUserNick(const std::string &jid) { - TCHAR* tszNick; + wchar_t* tszNick; if (m_szJid != jid) { MCONTACT hContact = ContactIDToHContact(jid); tszNick = (hContact == 0) ? utils::removeA(str2t(jid)) : mir_tstrdup(pcli->pfnGetContactDisplayName(hContact, 0)); diff --git a/protocols/WhatsApp/src/contacts.cpp b/protocols/WhatsApp/src/contacts.cpp index 3dfeec59a1..2c9f0c17e9 100644 --- a/protocols/WhatsApp/src/contacts.cpp +++ b/protocols/WhatsApp/src/contacts.cpp @@ -133,11 +133,11 @@ void WhatsAppProto::UpdateStatusMsg(MCONTACT hContact) bool denied = getBool(hContact, WHATSAPP_KEY_LAST_SEEN_DENIED, false); if (lastSeen > 0) { time_t ts = lastSeen; - TCHAR stzLastSeen[MAX_PATH]; + wchar_t stzLastSeen[MAX_PATH]; if (status == ID_STATUS_ONLINE) - _tcsftime(stzLastSeen, _countof(stzLastSeen), TranslateT("Last online on %x at %X"), localtime(&ts)); + wcsftime(stzLastSeen, _countof(stzLastSeen), TranslateT("Last online on %x at %X"), localtime(&ts)); else - _tcsftime(stzLastSeen, _countof(stzLastSeen), denied ? TranslateT("Denied: Last online on %x at %X") : TranslateT("Last seen on %x at %X"), localtime(&ts)); + wcsftime(stzLastSeen, _countof(stzLastSeen), denied ? TranslateT("Denied: Last online on %x at %X") : TranslateT("Last seen on %x at %X"), localtime(&ts)); ss << stzLastSeen; } @@ -162,15 +162,15 @@ void WhatsAppProto::onSendGetPicture(const std::string &jid, const std::vector 0) { @@ -184,7 +184,7 @@ void WhatsAppProto::onSendGetPicture(const std::string &jid, const std::vectorpfnGetContactDisplayName(hContact, 0) : L"none"; diff --git a/protocols/WhatsApp/src/dialogs.cpp b/protocols/WhatsApp/src/dialogs.cpp index b770210dd6..501a09151a 100644 --- a/protocols/WhatsApp/src/dialogs.cpp +++ b/protocols/WhatsApp/src/dialogs.cpp @@ -1,9 +1,9 @@ #include "stdafx.h" -#define szAskSendSms LPGEN("An SMS with registration code will be sent to your mobile phone.\nNotice that you are not able to use the real WhatsApp and this plugin simultaneously!\nContinue?") -#define szAskCall LPGEN("A call with registration code will be made to your mobile phone.\nNotice that you are not able to use the real WhatsApp and this plugin simultaneously!\nContinue?") -#define szPasswordSet LPGEN("Your password has been set automatically. You can proceed with login now.") -#define szSpecifyCode LPGEN("Please correctly specify your registration code received by SMS/Voice.") +#define szAskSendSms LPGENW("An SMS with registration code will be sent to your mobile phone.\nNotice that you are not able to use the real WhatsApp and this plugin simultaneously!\nContinue?") +#define szAskCall LPGENW("A call with registration code will be made to your mobile phone.\nNotice that you are not able to use the real WhatsApp and this plugin simultaneously!\nContinue?") +#define szPasswordSet LPGENW("Your password has been set automatically. You can proceed with login now.") +#define szSpecifyCode LPGENW("Please correctly specify your registration code received by SMS/Voice.") class COptionsDlg : public CProtoDlgBase { @@ -52,14 +52,14 @@ public: void OnRequestVoiceClick(CCtrlButton*) { - if (IDYES != MessageBox(GetHwnd(), TranslateT(szAskCall), PRODUCT_NAME, MB_YESNO)) + if (IDYES != MessageBox(GetHwnd(), TranslateW(szAskCall), PRODUCT_NAME, MB_YESNO)) return; ptrA cc(m_cc.GetTextA()), number(m_login.GetTextA()); string password; if (m_proto->Register(REG_STATE_REQ_CODE, string(cc), string(number), "voice", password)) { if (!password.empty()) { - MessageBox(GetHwnd(), TranslateT(szPasswordSet), PRODUCT_NAME, MB_ICONWARNING); + MessageBox(GetHwnd(), TranslateW(szPasswordSet), PRODUCT_NAME, MB_ICONWARNING); m_proto->setString(WHATSAPP_KEY_PASS, password.c_str()); } else { @@ -73,14 +73,14 @@ public: void OnRequestSMSClick(CCtrlButton*) { - if (IDYES != MessageBox(GetHwnd(), TranslateT(szAskSendSms), PRODUCT_NAME, MB_YESNO)) + if (IDYES != MessageBox(GetHwnd(), TranslateW(szAskSendSms), PRODUCT_NAME, MB_YESNO)) return; ptrA cc(m_cc.GetTextA()), number(m_login.GetTextA()); string password; if (m_proto->Register(REG_STATE_REQ_CODE, string(cc), string(number), "sms", password)) { if (!password.empty()) { - MessageBox(GetHwnd(), TranslateT(szPasswordSet), PRODUCT_NAME, MB_ICONWARNING); + MessageBox(GetHwnd(), TranslateW(szPasswordSet), PRODUCT_NAME, MB_ICONWARNING); m_proto->setString(WHATSAPP_KEY_PASS, password.c_str()); } else { @@ -95,7 +95,7 @@ public: void OnRegisterClick(CCtrlButton*) { if (GetWindowTextLength(m_pw1.GetHwnd()) != 3 || GetWindowTextLength(m_pw2.GetHwnd()) != 3) - MessageBox(GetHwnd(), TranslateT(szSpecifyCode), PRODUCT_NAME, MB_ICONEXCLAMATION); + MessageBox(GetHwnd(), TranslateW(szSpecifyCode), PRODUCT_NAME, MB_ICONEXCLAMATION); else { char code[10]; GetWindowTextA(m_pw1.GetHwnd(), code, 4); @@ -105,7 +105,7 @@ public: ptrA cc(m_cc.GetTextA()), number(m_login.GetTextA()); if (m_proto->Register(REG_STATE_REG_CODE, string(cc), string(number), string(code), password)) { m_proto->setString(WHATSAPP_KEY_PASS, password.c_str()); - MessageBox(GetHwnd(), TranslateT(szPasswordSet), PRODUCT_NAME, MB_ICONWARNING); + MessageBox(GetHwnd(), TranslateW(szPasswordSet), PRODUCT_NAME, MB_ICONWARNING); } } m_proto->setByte("CodeRequestDone", 0); @@ -133,11 +133,11 @@ INT_PTR WhatsAppProto::SvcCreateAccMgrUI(WPARAM, LPARAM lParam) int WhatsAppProto::OnOptionsInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; - odp.ptszTitle = m_tszUserName; + odp.pwszTitle = m_tszUserName; odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR | ODPF_DONTTRANSLATE; - odp.ptszGroup = LPGENT("Network"); + odp.pwszGroup = LPGENW("Network"); - odp.ptszTab = LPGENT("Account"); + odp.pwszTab = LPGENW("Account"); odp.pDialog = new COptionsDlg(this, IDD_OPTIONS); Options_AddPage(wParam, &odp); return 0; diff --git a/protocols/WhatsApp/src/entities.h b/protocols/WhatsApp/src/entities.h index 657cc82f90..7ed362990e 100644 --- a/protocols/WhatsApp/src/entities.h +++ b/protocols/WhatsApp/src/entities.h @@ -14,9 +14,9 @@ struct send_direct struct input_box { - tstring text; - tstring title; - tstring defaultValue; + wstring text; + wstring title; + wstring defaultValue; int limit; void(__cdecl WhatsAppProto::*thread)(void*); diff --git a/protocols/WhatsApp/src/main.cpp b/protocols/WhatsApp/src/main.cpp index 26eea6b01e..f3e7513339 100644 --- a/protocols/WhatsApp/src/main.cpp +++ b/protocols/WhatsApp/src/main.cpp @@ -50,7 +50,7 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC ///////////////////////////////////////////////////////////////////////////////////////// // Load -static PROTO_INTERFACE* protoInit(const char *proto_name, const TCHAR *username) +static PROTO_INTERFACE* protoInit(const char *proto_name, const wchar_t *username) { WhatsAppProto *proto = new WhatsAppProto(proto_name, username); g_Instances.insert(proto); diff --git a/protocols/WhatsApp/src/media.cpp b/protocols/WhatsApp/src/media.cpp index c94d5ab6c8..9b3bb6f5ff 100644 --- a/protocols/WhatsApp/src/media.cpp +++ b/protocols/WhatsApp/src/media.cpp @@ -1,6 +1,6 @@ #include "stdafx.h" -HANDLE WhatsAppProto::SendFile(MCONTACT hContact, const TCHAR* desc, TCHAR **ppszFiles) { +HANDLE WhatsAppProto::SendFile(MCONTACT hContact, const wchar_t* desc, wchar_t **ppszFiles) { if (!isOnline()) return 0; @@ -17,7 +17,7 @@ HANDLE WhatsAppProto::SendFile(MCONTACT hContact, const TCHAR* desc, TCHAR **pps } // get file size - FILE *hFile = _tfopen(ppszFiles[0], L"rb"); + FILE *hFile = _wfopen(ppszFiles[0], L"rb"); if (hFile == NULL) { debugLogA(__FUNCTION__": cannot open file %s", ppszFiles[0]); mir_free(name); @@ -69,7 +69,7 @@ HANDLE WhatsAppProto::SendFile(MCONTACT hContact, const TCHAR* desc, TCHAR **pps SHA256_CONTEXT sha256; mir_sha256_init(&sha256); - FILE *fd = _tfopen(ppszFiles[0], L"rb"); + FILE *fd = _wfopen(ppszFiles[0], L"rb"); int read = 0; do { char buf[1024]; diff --git a/protocols/WhatsApp/src/messages.cpp b/protocols/WhatsApp/src/messages.cpp index aa48df5444..388b12f309 100644 --- a/protocols/WhatsApp/src/messages.cpp +++ b/protocols/WhatsApp/src/messages.cpp @@ -112,7 +112,7 @@ void WhatsAppProto::onMessageStatusUpdate(const FMessage &fmsg) return; } - const TCHAR *ptszBy; + const wchar_t *ptszBy; switch (fmsg.status) { case FMessage::STATUS_RECEIVED_BY_SERVER: ptszBy = TranslateT("server"); break; case FMessage::STATUS_RECEIVED_BY_TARGET: ptszBy = pcli->pfnGetContactDisplayName(hContact, 0); break; @@ -131,7 +131,7 @@ void WhatsAppProto::onMessageStatusUpdate(const FMessage &fmsg) time_t ts = atol(fmsg.key.id.substr(0, delim).c_str()); - TCHAR ttime[64]; - _tcsftime(ttime, _countof(ttime), L"%X", localtime(&ts)); + wchar_t ttime[64]; + wcsftime(ttime, _countof(ttime), L"%X", localtime(&ts)); utils::setStatusMessage(hContact, CMString(FORMAT, TranslateT("Message received: %s by %s"), ttime, ptszBy)); } diff --git a/protocols/WhatsApp/src/proto.cpp b/protocols/WhatsApp/src/proto.cpp index a361ad3e16..56c0d3571e 100644 --- a/protocols/WhatsApp/src/proto.cpp +++ b/protocols/WhatsApp/src/proto.cpp @@ -4,15 +4,15 @@ struct SearchParam { - SearchParam(const TCHAR *_jid, LONG _id) : + SearchParam(const wchar_t *_jid, LONG _id) : jid(_jid), id(_id) {} - std::tstring jid; + std::wstring jid; LONG id; }; -WhatsAppProto::WhatsAppProto(const char *proto_name, const TCHAR *username) +WhatsAppProto::WhatsAppProto(const char *proto_name, const wchar_t *username) : PROTO(proto_name, username), m_tszDefaultGroup(getTStringA(WHATSAPP_KEY_DEF_GROUP)) { @@ -32,7 +32,7 @@ WhatsAppProto::WhatsAppProto(const char *proto_name, const TCHAR *username) HookProtoEvent(ME_CLIST_PREBUILDSTATUSMENU, &WhatsAppProto::OnBuildStatusMenu); // Create standard network connection - TCHAR descr[512]; + wchar_t descr[512]; mir_sntprintf(descr, TranslateT("%s server connection"), m_tszUserName); NETLIBUSER nlu = { sizeof(nlu) }; @@ -41,14 +41,14 @@ WhatsAppProto::WhatsAppProto(const char *proto_name, const TCHAR *username) nlu.ptszDescriptiveName = descr; m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); if (m_hNetlibUser == NULL) { - TCHAR error[200]; + wchar_t error[200]; mir_sntprintf(error, TranslateT("Unable to initialize Netlib for %s."), m_tszUserName); MessageBox(NULL, error, L"Miranda NG", MB_OK | MB_ICONERROR); } WASocketConnection::initNetwork(m_hNetlibUser); - m_tszAvatarFolder = std::tstring(VARST(L"%miranda_avatarcache%")) + L"\\" + m_tszUserName; + m_tszAvatarFolder = std::wstring(VARST(L"%miranda_avatarcache%")) + L"\\" + m_tszUserName; DWORD dwAttributes = GetFileAttributes(m_tszAvatarFolder.c_str()); if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) CreateDirectoryTreeT(m_tszAvatarFolder.c_str()); @@ -173,10 +173,10 @@ int WhatsAppProto::SetStatus(int new_status) MCONTACT WhatsAppProto::AddToList(int flags, PROTOSEARCHRESULT *psr) { - if (psr->id.t == NULL) + if (psr->id.w == NULL) return NULL; - std::string phone(T2Utf(psr->id.t)); + std::string phone(T2Utf(psr->id.w)); std::string jid(phone + "@s.whatsapp.net"); MCONTACT hContact = AddToContactList(jid, phone.c_str()); @@ -197,8 +197,8 @@ void WhatsAppProto::SearchAckThread(void *targ) PROTOSEARCHRESULT psr = { 0 }; psr.cbSize = sizeof(psr); psr.flags = PSR_TCHAR; - psr.nick.t = psr.firstName.t = psr.lastName.t = L""; - psr.id.t = (TCHAR*)param->jid.c_str(); + psr.nick.w = psr.firstName.w = psr.lastName.w = L""; + psr.id.w = (wchar_t*)param->jid.c_str(); ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)param->id, (LPARAM)&psr); ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)param->id, 0); @@ -206,7 +206,7 @@ void WhatsAppProto::SearchAckThread(void *targ) delete param; } -HANDLE WhatsAppProto::SearchBasic(const TCHAR* id) +HANDLE WhatsAppProto::SearchBasic(const wchar_t* id) { if (isOffline()) return 0; @@ -264,7 +264,7 @@ bool WhatsAppProto::Register(int state, const string &cc, const string &number, NETLIBHTTPREQUEST* pnlhr = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)WASocketConnection::hNetlibUser, (LPARAM)&nlhr); - const TCHAR *ptszTitle = TranslateT("Registration"); + const wchar_t *ptszTitle = TranslateT("Registration"); if (pnlhr == NULL) { NotifyEvent(ptszTitle, TranslateT("Registration failed. Invalid server response."), NULL, WHATSAPP_EVENT_CLIENT); return false; @@ -366,16 +366,16 @@ LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return DefWindowProc(hwnd, message, wParam, lParam); }; -void WhatsAppProto::NotifyEvent(const string& title, const string& info, MCONTACT contact, DWORD flags, TCHAR* url) +void WhatsAppProto::NotifyEvent(const string& title, const string& info, MCONTACT contact, DWORD flags, wchar_t* url) { - TCHAR *rawTitle = mir_a2t_cp(title.c_str(), CP_UTF8); - TCHAR *rawInfo = mir_a2t_cp(info.c_str(), CP_UTF8); + wchar_t *rawTitle = mir_a2t_cp(title.c_str(), CP_UTF8); + wchar_t *rawInfo = mir_a2t_cp(info.c_str(), CP_UTF8); NotifyEvent(rawTitle, rawInfo, contact, flags, url); mir_free(rawTitle); mir_free(rawInfo); } -void WhatsAppProto::NotifyEvent(const TCHAR *title, const TCHAR *info, MCONTACT contact, DWORD flags, TCHAR* szUrl) +void WhatsAppProto::NotifyEvent(const wchar_t *title, const wchar_t *info, MCONTACT contact, DWORD flags, wchar_t* szUrl) { int ret, timeout = 0; COLORREF colorBack = 0, colorText = 0; @@ -431,8 +431,8 @@ void WhatsAppProto::NotifyEvent(const TCHAR *title, const TCHAR *info, MCONTACT err.szProto = m_szModuleName; err.cbSize = sizeof(err); err.dwInfoFlags = NIIF_INTERN_TCHAR | niif_flags; - err.tszInfoTitle = (TCHAR*)title; - err.tszInfo = (TCHAR*)info; + err.tszInfoTitle = (wchar_t*)title; + err.tszInfo = (wchar_t*)info; err.uTimeout = 1000 * timeout; ret = CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)& err); diff --git a/protocols/WhatsApp/src/proto.h b/protocols/WhatsApp/src/proto.h index 2822dd85d0..04a557f893 100644 --- a/protocols/WhatsApp/src/proto.h +++ b/protocols/WhatsApp/src/proto.h @@ -7,13 +7,13 @@ class WASocketConnection; struct WAChatInfo { - WAChatInfo(TCHAR *_jid, TCHAR *_nick) : + WAChatInfo(wchar_t *_jid, wchar_t *_nick) : tszJid(_jid), tszNick(_nick) { bActive = false; } - map m_unsentMsgs; + map m_unsentMsgs; ptrT tszJid, tszNick, tszOwner; bool bActive; @@ -23,7 +23,7 @@ struct WAChatInfo class WhatsAppProto : public PROTO, public WAListener, public WAGroupListener { public: - WhatsAppProto(const char *proto_name, const TCHAR *username); + WhatsAppProto(const char *proto_name, const wchar_t *username); ~WhatsAppProto(); inline bool isOnline() const @@ -44,13 +44,13 @@ public: virtual DWORD_PTR __cdecl GetCaps(int type, MCONTACT hContact = NULL); - virtual HANDLE __cdecl SearchBasic(const TCHAR* id); + virtual HANDLE __cdecl SearchBasic(const wchar_t* id); virtual int __cdecl RecvMsg(MCONTACT hContact, PROTORECVEVENT*); virtual int __cdecl SendMsg(MCONTACT hContact, int flags, const char* msg); - virtual HANDLE __cdecl SendFile(MCONTACT hContact, const TCHAR*, TCHAR **ppszFiles); + virtual HANDLE __cdecl SendFile(MCONTACT hContact, const wchar_t*, wchar_t **ppszFiles); virtual int __cdecl SetStatus(int iNewStatus); @@ -85,7 +85,7 @@ public: MCONTACT ContactIDToHContact(const std::string&); void SetAllContactStatuses(int status, bool reset_client = false); void UpdateStatusMsg(MCONTACT hContact); - TCHAR* GetContactDisplayName(const string &jid); + wchar_t* GetContactDisplayName(const string &jid); void RequestFriendship(MCONTACT hContact); // Group chats /////////////////////////////////////////////////////////////////////// @@ -98,11 +98,11 @@ public: void ChatLogMenuHook(WAChatInfo *pInfo, GCHOOK *gch); void NickListMenuHook(WAChatInfo *pInfo, GCHOOK *gch); - void AddChatUser(WAChatInfo *pInfo, const TCHAR *ptszJid); + void AddChatUser(WAChatInfo *pInfo, const wchar_t *ptszJid); void EditChatSubject(WAChatInfo *pInfo); void InviteChatUser(WAChatInfo *pInfo); - void KickChatUser(WAChatInfo *pInfo, const TCHAR *ptszJid); - TCHAR* GetChatUserNick(const std::string &jid); + void KickChatUser(WAChatInfo *pInfo, const wchar_t *ptszJid); + wchar_t* GetChatUserNick(const std::string &jid); void SetChatAvatar(WAChatInfo *pInfo); void onGroupMessageReceived(const FMessage &fmsg); @@ -131,15 +131,15 @@ private: /// Avatars ////////////////////////////////////////////////////////////////////////// - std::tstring GetAvatarFileName(MCONTACT); - std::tstring m_tszAvatarFolder; + std::wstring GetAvatarFileName(MCONTACT); + std::wstring m_tszAvatarFolder; INT_PTR __cdecl GetAvatarInfo(WPARAM, LPARAM); INT_PTR __cdecl GetAvatarCaps(WPARAM, LPARAM); INT_PTR __cdecl GetMyAvatar(WPARAM, LPARAM); INT_PTR __cdecl SetMyAvatar(WPARAM, LPARAM); - int InternalSetAvatar(MCONTACT hContact, const char *szJid, const TCHAR *ptszFileName); + int InternalSetAvatar(MCONTACT hContact, const char *szJid, const wchar_t *ptszFileName); // Private data ////////////////////////////////////////////////////////////////////// @@ -196,8 +196,8 @@ protected: // Information providing ///////////////////////////////////////////////////////////// - void NotifyEvent(const TCHAR *title, const TCHAR *info, MCONTACT contact, DWORD flags, TCHAR *url = NULL); - void NotifyEvent(const std::string &title, const std::string &info, MCONTACT contact, DWORD flags, TCHAR *url = NULL); + void NotifyEvent(const wchar_t *title, const wchar_t *info, MCONTACT contact, DWORD flags, wchar_t *url = NULL); + void NotifyEvent(const std::string &title, const std::string &info, MCONTACT contact, DWORD flags, wchar_t *url = NULL); }; #endif diff --git a/protocols/WhatsApp/src/utils.cpp b/protocols/WhatsApp/src/utils.cpp index 35f84bcc1e..71a33dc2fd 100644 --- a/protocols/WhatsApp/src/utils.cpp +++ b/protocols/WhatsApp/src/utils.cpp @@ -1,16 +1,16 @@ #include "stdafx.h" -TCHAR* utils::removeA(TCHAR *str) +wchar_t* utils::removeA(wchar_t *str) { if (str == NULL) return NULL; - TCHAR *p = _tcschr(str, '@'); + wchar_t *p = wcschr(str, '@'); if (p) *p = 0; return str; } -void utils::copyText(HWND hwnd, const TCHAR *text) +void utils::copyText(HWND hwnd, const wchar_t *text) { if (!hwnd || !text) return; @@ -18,8 +18,8 @@ void utils::copyText(HWND hwnd, const TCHAR *text) return; EmptyClipboard(); - HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, sizeof(TCHAR)*(mir_tstrlen(text) + 1)); - mir_tstrcpy((TCHAR*)GlobalLock(hMem), text); + HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, sizeof(wchar_t)*(mir_tstrlen(text) + 1)); + mir_tstrcpy((wchar_t*)GlobalLock(hMem), text); GlobalUnlock(hMem); SetClipboardData(CF_UNICODETEXT, hMem); CloseClipboard(); @@ -45,13 +45,13 @@ std::string getLastErrorMsg() return ret; } -void utils::setStatusMessage(MCONTACT hContact, const TCHAR *ptszMessage) +void utils::setStatusMessage(MCONTACT hContact, const wchar_t *ptszMessage) { if (ptszMessage != NULL) { StatusTextData st = { 0 }; st.cbSize = sizeof(st); st.hIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE); - _tcsncpy_s(st.tszText, ptszMessage, _TRUNCATE); + wcsncpy_s(st.tszText, ptszMessage, _TRUNCATE); CallService(MS_MSG_SETSTATUSTEXT, hContact, (LPARAM)&st); } else CallService(MS_MSG_SETSTATUSTEXT, hContact, NULL); diff --git a/protocols/WhatsApp/src/utils.h b/protocols/WhatsApp/src/utils.h index 0e760f5013..333860c1dd 100644 --- a/protocols/WhatsApp/src/utils.h +++ b/protocols/WhatsApp/src/utils.h @@ -27,7 +27,7 @@ public: std::string getLastErrorMsg(); -__forceinline TCHAR* str2t(const std::string &str) +__forceinline wchar_t* str2t(const std::string &str) { return mir_utf8decodeT(str.c_str()); } @@ -36,10 +36,10 @@ std::vector &split(const std::string &s, char delim, std::vector