summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src/jabber_util.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-02-19 15:21:04 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-02-19 19:24:17 +0300
commitfc8f2a3b692878aa581bf3fcd5c1c3c2295bbcb5 (patch)
tree17ed9d45de9d7f293578150081b5e7e4617290eb /protocols/JabberG/src/jabber_util.cpp
parentc9e483e0fb1566d210530339d13a0e6e91260200 (diff)
Jabber:
- XmlGetChildText / XmlGetChildInt - new handy helpers for tinyxml2; - Unicode logging replaced with ANSI when appropriate; - JabberErrorMsg rewritten to be more useful
Diffstat (limited to 'protocols/JabberG/src/jabber_util.cpp')
-rwxr-xr-xprotocols/JabberG/src/jabber_util.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index b19fe77437..dceac9a0db 100755
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp
@@ -244,22 +244,24 @@ wchar_t* JabberErrorStr(int errorCode)
return JabberErrorCodeToStrMapping[i].str;
}
-wchar_t* JabberErrorMsg(const TiXmlElement *errorNode, int* pErrorCode)
+CMStringW JabberErrorMsg(const TiXmlElement *errorNode, int *pErrorCode)
{
- wchar_t *errorStr = (wchar_t*)mir_alloc(256 * sizeof(wchar_t));
+ CMStringW ret;
if (errorNode == nullptr) {
if (pErrorCode)
*pErrorCode = -1;
- mir_snwprintf(errorStr, 256, L"%s -1: %s", TranslateT("Error"), TranslateT("Unknown error message"));
- return errorStr;
+ ret.Format(L"%s -1: %s", TranslateT("Error"), TranslateT("Unknown error message"));
+ return ret;
}
+ if (auto *pChild = errorNode->FirstChildElement("error"))
+ errorNode = pChild;
+
int errorCode = errorNode->IntAttribute("code");
- auto *str = errorNode->GetText();
+ const char *str = errorNode->GetText();
if (str == nullptr)
- if (auto *n = errorNode->FirstChildElement("text"))
- str = n->GetText();
+ str = XmlGetChildText(errorNode, "text");
if (str == nullptr) {
for (auto *c : TiXmlEnum(errorNode)) {
@@ -272,13 +274,13 @@ wchar_t* JabberErrorMsg(const TiXmlElement *errorNode, int* pErrorCode)
}
if (str != nullptr)
- mir_snwprintf(errorStr, 256, L"%s %d: %s\r\n%s", TranslateT("Error"), errorCode, TranslateW(JabberErrorStr(errorCode)), Utf2T(str).get());
+ ret.Format(L"%s %d: %s\r\n%s", TranslateT("Error"), errorCode, TranslateW(JabberErrorStr(errorCode)), Utf2T(str).get());
else
- mir_snwprintf(errorStr, 256, L"%s %d: %s", TranslateT("Error"), errorCode, TranslateW(JabberErrorStr(errorCode)));
+ ret.Format(L"%s %d: %s", TranslateT("Error"), errorCode, TranslateW(JabberErrorStr(errorCode)));
if (pErrorCode)
*pErrorCode = errorCode;
- return errorStr;
+ return ret;
}
void CJabberProto::SendVisibleInvisiblePresence(bool invisible)
@@ -930,6 +932,12 @@ void SetDlgItemTextUtf(HWND hwndDlg, int ctrlId, const char *szValue)
SetDlgItemTextW(hwndDlg, ctrlId, Utf2T(szValue));
}
+void SetWindowTextUtf(HWND hwndDlg, const char *szValue)
+{
+ if (szValue)
+ SetWindowTextW(hwndDlg, Utf2T(szValue));
+}
+
int UIEmulateBtnClick(HWND hwndDlg, UINT idcButton)
{
if (IsWindowEnabled(GetDlgItem(hwndDlg, idcButton)))