summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_jabber.h27
-rw-r--r--include/m_netlib.h2
-rwxr-xr-xprotocols/JabberG/src/jabber.cpp6
-rw-r--r--protocols/JabberG/src/jabber_adhoc.cpp220
-rw-r--r--protocols/JabberG/src/jabber_agent.cpp83
-rw-r--r--protocols/JabberG/src/jabber_api.cpp77
-rw-r--r--protocols/JabberG/src/jabber_archive.cpp70
-rw-r--r--protocols/JabberG/src/jabber_bookmarks.cpp83
-rw-r--r--protocols/JabberG/src/jabber_byte.cpp236
-rw-r--r--protocols/JabberG/src/jabber_byte.h23
-rwxr-xr-xprotocols/JabberG/src/jabber_caps.cpp285
-rwxr-xr-xprotocols/JabberG/src/jabber_caps.h242
-rw-r--r--protocols/JabberG/src/jabber_captcha.cpp79
-rw-r--r--protocols/JabberG/src/jabber_chat.cpp486
-rw-r--r--protocols/JabberG/src/jabber_console.cpp93
-rw-r--r--protocols/JabberG/src/jabber_disco.cpp409
-rw-r--r--protocols/JabberG/src/jabber_disco.h74
-rw-r--r--protocols/JabberG/src/jabber_events.cpp58
-rw-r--r--protocols/JabberG/src/jabber_file.cpp22
-rw-r--r--protocols/JabberG/src/jabber_form.cpp332
-rw-r--r--protocols/JabberG/src/jabber_ft.cpp252
-rw-r--r--protocols/JabberG/src/jabber_groupchat.cpp395
-rw-r--r--protocols/JabberG/src/jabber_ibb.cpp51
-rw-r--r--protocols/JabberG/src/jabber_ibb.h12
-rw-r--r--protocols/JabberG/src/jabber_icolib.cpp82
-rw-r--r--protocols/JabberG/src/jabber_iq.cpp92
-rw-r--r--protocols/JabberG/src/jabber_iq.h73
-rw-r--r--protocols/JabberG/src/jabber_iq_handlers.cpp224
-rwxr-xr-xprotocols/JabberG/src/jabber_iqid.cpp936
-rw-r--r--protocols/JabberG/src/jabber_iqid_muc.cpp106
-rw-r--r--protocols/JabberG/src/jabber_list.cpp66
-rw-r--r--protocols/JabberG/src/jabber_list.h36
-rw-r--r--protocols/JabberG/src/jabber_menu.cpp78
-rw-r--r--protocols/JabberG/src/jabber_message_handlers.cpp20
-rw-r--r--protocols/JabberG/src/jabber_message_manager.cpp46
-rw-r--r--protocols/JabberG/src/jabber_message_manager.h36
-rwxr-xr-xprotocols/JabberG/src/jabber_misc.cpp162
-rw-r--r--protocols/JabberG/src/jabber_notes.cpp165
-rw-r--r--protocols/JabberG/src/jabber_notes.h33
-rwxr-xr-xprotocols/JabberG/src/jabber_omemo.cpp337
-rwxr-xr-xprotocols/JabberG/src/jabber_omemo.h10
-rwxr-xr-xprotocols/JabberG/src/jabber_opt.cpp695
-rw-r--r--protocols/JabberG/src/jabber_password.cpp14
-rw-r--r--protocols/JabberG/src/jabber_presence_manager.cpp2
-rw-r--r--protocols/JabberG/src/jabber_presence_manager.h6
-rw-r--r--protocols/JabberG/src/jabber_privacy.cpp580
-rw-r--r--protocols/JabberG/src/jabber_privacy.h46
-rwxr-xr-xprotocols/JabberG/src/jabber_proto.cpp227
-rwxr-xr-xprotocols/JabberG/src/jabber_proto.h452
-rw-r--r--protocols/JabberG/src/jabber_rc.cpp543
-rw-r--r--protocols/JabberG/src/jabber_rc.h55
-rw-r--r--protocols/JabberG/src/jabber_search.cpp209
-rw-r--r--protocols/JabberG/src/jabber_search.h35
-rw-r--r--protocols/JabberG/src/jabber_secur.cpp57
-rw-r--r--protocols/JabberG/src/jabber_secur.h16
-rw-r--r--protocols/JabberG/src/jabber_send_manager.cpp2
-rw-r--r--protocols/JabberG/src/jabber_send_manager.h6
-rw-r--r--protocols/JabberG/src/jabber_std.cpp33
-rwxr-xr-xprotocols/JabberG/src/jabber_strm_mgmt.cpp151
-rwxr-xr-xprotocols/JabberG/src/jabber_strm_mgmt.h24
-rw-r--r--protocols/JabberG/src/jabber_svc.cpp139
-rwxr-xr-xprotocols/JabberG/src/jabber_thread.cpp951
-rwxr-xr-xprotocols/JabberG/src/jabber_userinfo.cpp114
-rwxr-xr-xprotocols/JabberG/src/jabber_util.cpp215
-rw-r--r--protocols/JabberG/src/jabber_vcard.cpp74
-rw-r--r--protocols/JabberG/src/jabber_xml.cpp293
-rw-r--r--protocols/JabberG/src/jabber_xml.h227
-rw-r--r--protocols/JabberG/src/jabber_xstatus.cpp129
-rw-r--r--protocols/JabberG/src/jabber_xstatus.h30
-rw-r--r--protocols/JabberG/src/obsoleted/jabber_form2.cpp.obsoleted1200
-rw-r--r--protocols/JabberG/src/obsoleted/jabber_form2.h.obsoleted192
-rwxr-xr-xprotocols/JabberG/src/stdafx.h154
-rw-r--r--src/mir_app/src/netlibsecurity.cpp2
73 files changed, 5408 insertions, 7584 deletions
diff --git a/include/m_jabber.h b/include/m_jabber.h
index 33a451f086..fdb865ec6b 100644
--- a/include/m_jabber.h
+++ b/include/m_jabber.h
@@ -76,12 +76,12 @@ enum
struct JABBER_DISCO_FIELD
{
- LPCTSTR category, type, name;
+ LPCSTR category, type, name;
};
typedef void* HJHANDLER;
-typedef BOOL (*JABBER_HANDLER_FUNC)(struct IJabberInterface *ji, HXML node, void *pUserData);
+typedef BOOL (*JABBER_HANDLER_FUNC)(struct IJabberInterface *ji, const TiXmlElement *node, void *pUserData);
// IJabberInterface::dwFlags values
enum
@@ -102,16 +102,16 @@ struct IJabberInterface
virtual DWORD STDMETHODCALLTYPE GetJabberVersion() const = 0;
// Returns contact handle for given JID, or NULL on error.
- virtual MCONTACT STDMETHODCALLTYPE ContactFromJID(LPCTSTR jid) = 0;
+ virtual MCONTACT STDMETHODCALLTYPE ContactFromJID(LPCSTR jid) = 0;
// Returns JID of hContact, or NULL on error. You must free the result using mir_free().
- virtual LPTSTR STDMETHODCALLTYPE ContactToJID(MCONTACT hContact) = 0;
+ virtual char* STDMETHODCALLTYPE ContactToJID(MCONTACT hContact) = 0;
// Returns best resource name for given JID, or NULL on error. You must free the result using mir_free().
- virtual LPTSTR STDMETHODCALLTYPE GetBestResourceName(LPCTSTR jid) = 0;
+ virtual char* STDMETHODCALLTYPE GetBestResourceName(LPCSTR jid) = 0;
// Returns all resource names for a given JID in format "resource1\0resource2\0resource3\0\0" (all resources are separated by \0 character and the whole string is terminated with two \0 characters), or NULL on error. You must free returned string using mir_free().
- virtual LPTSTR STDMETHODCALLTYPE GetResourceList(LPCTSTR jid) = 0;
+ virtual char* STDMETHODCALLTYPE GetResourceList(LPCSTR jid) = 0;
// Returns Jabber module name. DO NOT free the returned string.
virtual char* STDMETHODCALLTYPE GetModuleName() const = 0;
@@ -119,18 +119,15 @@ struct IJabberInterface
// Returns id that can be used for next message sent through SendXmlNode().
virtual int STDMETHODCALLTYPE SerialNext() = 0;
- // Sends XML node.
- virtual int STDMETHODCALLTYPE SendXmlNode(HXML node) = 0;
-
// Registers incoming <presence/> handler. Returns handler handle on success or NULL on error.
virtual HJHANDLER STDMETHODCALLTYPE AddPresenceHandler(JABBER_HANDLER_FUNC Func, void *pUserData = nullptr, int iPriority = JH_PRIORITY_DEFAULT) = 0;
// Registers incoming <message/> handler for messages of types specified by iMsgTypes. iMsgTypes is a combination of JABBER_MESSAGE_TYPE_* flags. Returns handler handle on success or NULL on error.
- virtual HJHANDLER STDMETHODCALLTYPE AddMessageHandler(JABBER_HANDLER_FUNC Func, int iMsgTypes, LPCTSTR szXmlns, LPCTSTR szTag, void *pUserData = nullptr, int iPriority = JH_PRIORITY_DEFAULT) = 0;
+ virtual HJHANDLER STDMETHODCALLTYPE AddMessageHandler(JABBER_HANDLER_FUNC Func, int iMsgTypes, LPCSTR szXmlns, LPCSTR szTag, void *pUserData = nullptr, int iPriority = JH_PRIORITY_DEFAULT) = 0;
// Registers incoming <iq/> handler. iIqTypes is a combination of JABBER_IQ_TYPE_* flags. Returns handler handle on success or NULL on error.
- virtual HJHANDLER STDMETHODCALLTYPE AddIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, LPCTSTR szXmlns, LPCTSTR szTag, void *pUserData = nullptr, int iPriority = JH_PRIORITY_DEFAULT) = 0;
+ virtual HJHANDLER STDMETHODCALLTYPE AddIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, LPCSTR szXmlns, LPCSTR szTag, void *pUserData = nullptr, int iPriority = JH_PRIORITY_DEFAULT) = 0;
// Registers temporary handler for incoming <iq/> stanza of type iIqType with id iIqId. iIqTypes is a combination of JABBER_IQ_TYPE_* flags. Returns handler handle on success or NULL on error.
// If dwTimeout milliseconds pass and no Iq stanza with the specified iIqId is received, Jabber plugin will call Func() with NULL node.
@@ -145,16 +142,16 @@ struct IJabberInterface
// Entity capabilities support (see xep-0115)
// Registers feature so that it's displayed with proper description in other users' details. Call this function in your ME_SYSTEM_MODULESLOADED handler. Returns TRUE on success or FALSE on error.
- virtual int STDMETHODCALLTYPE RegisterFeature(LPCTSTR szFeature, LPCTSTR szDescription) = 0;
+ virtual int STDMETHODCALLTYPE RegisterFeature(LPCSTR szFeature, LPCSTR szDescription) = 0;
// Adds features to the list of features supported by the client. szFeatures is a list of features separated by \0 character and terminated with two \0 characters. You can call this function at any time. Returns TRUE on success or FALSE on error.
- virtual int STDMETHODCALLTYPE AddFeatures(LPCTSTR szFeatures) = 0;
+ virtual int STDMETHODCALLTYPE AddFeatures(LPCSTR szFeatures) = 0;
// Removes features from the list of features supported by the client. szFeatures is a list of features separated by \0 character and terminated with two \0 characters. You can call this function at any time.
- virtual int STDMETHODCALLTYPE RemoveFeatures(LPCTSTR szFeatures) = 0;
+ virtual int STDMETHODCALLTYPE RemoveFeatures(LPCSTR szFeatures) = 0;
// Returns features supported by JID in format "feature1\0feature2\0...\0featureN\0\0" (a list of features separated by \0 character and terminated with two \0 characters), or NULL on error. JID may contain resource name to get features of a specific resource. If there's no resource name, GetResourceFeatures() returns features for the same resource as IJabberSysInterface::GetBestResourceName() returns. If a feature you're checking for is not supported by Jabber plugin natively, you must register it with RegisterFeature(), otherwise GetContactFeatures() won't be able to return it. You must free returned string using mir_free().
- virtual LPTSTR STDMETHODCALLTYPE GetResourceFeatures(LPCTSTR jid) = 0;
+ virtual char* STDMETHODCALLTYPE GetResourceFeatures(LPCSTR jid) = 0;
// Returns the connection handle
virtual HNETLIBUSER STDMETHODCALLTYPE GetHandle(void) = 0;
diff --git a/include/m_netlib.h b/include/m_netlib.h
index 925d6a1656..6d7106a882 100644
--- a/include/m_netlib.h
+++ b/include/m_netlib.h
@@ -773,7 +773,7 @@ EXTERN_C MIR_APP_DLL(void) Netlib_DestroySecurityProvider(HANDLE hProvider);
/////////////////////////////////////////////////////////////////////////////////////////
// Returns the NTLM response string. The result value should be freed using mir_free
-EXTERN_C MIR_APP_DLL(char*) Netlib_NtlmCreateResponse(HANDLE hProvider, char *szChallenge, wchar_t *szLogin, wchar_t *szPass, unsigned &complete);
+EXTERN_C MIR_APP_DLL(char*) Netlib_NtlmCreateResponse(HANDLE hProvider, const char *szChallenge, wchar_t *szLogin, wchar_t *szPass, unsigned &complete);
/////////////////////////////////////////////////////////////////////////////////////////
// Netlib hooks (0.8+)
diff --git a/protocols/JabberG/src/jabber.cpp b/protocols/JabberG/src/jabber.cpp
index 3cb8afcb14..2317ee00e8 100755
--- a/protocols/JabberG/src/jabber.cpp
+++ b/protocols/JabberG/src/jabber.cpp
@@ -43,7 +43,7 @@ int g_cbCountries;
CountryListEntry *g_countries;
unsigned int g_nTempFileId;
-wchar_t szCoreVersion[100];
+char szCoreVersion[100];
HANDLE hExtraActivity = nullptr;
HANDLE hExtraMood = nullptr;
@@ -156,9 +156,7 @@ int CMPlugin::Load()
bPlatform = 0;
#endif
- char mirVer[100];
- Miranda_GetVersionText(mirVer, _countof(mirVer));
- mir_wstrcpy(szCoreVersion, _A2T(mirVer));
+ Miranda_GetVersionText(szCoreVersion, _countof(szCoreVersion));
CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&g_cbCountries, (LPARAM)&g_countries);
diff --git a/protocols/JabberG/src/jabber_adhoc.cpp b/protocols/JabberG/src/jabber_adhoc.cpp
index 97705591db..b19a76e3d5 100644
--- a/protocols/JabberG/src/jabber_adhoc.cpp
+++ b/protocols/JabberG/src/jabber_adhoc.cpp
@@ -91,110 +91,102 @@ static void JabberAdHoc_RefreshFrameScroll(HWND hwndDlg, JabberAdHocData * dat)
// Iq handlers
// Forwards to dialog window procedure
-void CJabberProto::OnIqResult_ListOfCommands(HXML iqNode, CJabberIqInfo *pInfo)
+void CJabberProto::OnIqResult_ListOfCommands(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
- SendMessage(GetWindowFromIq(pInfo), JAHM_COMMANDLISTRESULT, 0, (LPARAM)xmlCopyNode(iqNode));
+ SendMessage(GetWindowFromIq(pInfo), JAHM_COMMANDLISTRESULT, 0, (LPARAM)iqNode->DeepClone(0));
}
-void CJabberProto::OnIqResult_CommandExecution(HXML iqNode, CJabberIqInfo *pInfo)
+void CJabberProto::OnIqResult_CommandExecution(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
- SendMessage(GetWindowFromIq(pInfo), JAHM_PROCESSRESULT, (WPARAM)xmlCopyNode(iqNode), 0);
+ SendMessage(GetWindowFromIq(pInfo), JAHM_PROCESSRESULT, (WPARAM)iqNode->DeepClone(0), 0);
}
-void CJabberProto::AdHoc_RequestListOfCommands(wchar_t * szResponder, HWND hwndDlg)
+void CJabberProto::AdHoc_RequestListOfCommands(char *szResponder, HWND hwndDlg)
{
m_ThreadInfo->send(XmlNodeIq(AddIQ(&CJabberProto::OnIqResult_ListOfCommands, JABBER_IQ_TYPE_GET, szResponder, 0, -1, hwndDlg))
- << XQUERY(JABBER_FEAT_DISCO_ITEMS) << XATTR(L"node", JABBER_FEAT_COMMANDS));
+ << XQUERY(JABBER_FEAT_DISCO_ITEMS) << XATTR("node", JABBER_FEAT_COMMANDS));
}
-int CJabberProto::AdHoc_ExecuteCommand(HWND hwndDlg, wchar_t*, JabberAdHocData* dat)
+int CJabberProto::AdHoc_ExecuteCommand(HWND hwndDlg, char*, JabberAdHocData *dat)
{
- for (int i = 1;; i++) {
- HXML itemNode = XmlGetNthChild(dat->CommandsNode, L"item", i);
- if (!itemNode)
- break;
-
- if (BST_UNCHECKED == IsDlgButtonChecked(GetDlgItem(hwndDlg, IDC_FRAME), i))
+ int i = 1;
+ for (auto *itemNode : TiXmlFilter(dat->CommandsNode, "item")) {
+ if (BST_UNCHECKED == IsDlgButtonChecked(GetDlgItem(hwndDlg, IDC_FRAME), i++))
continue;
- const wchar_t *node = XmlGetAttrValue(itemNode, L"node");
+ const char *node = itemNode->Attribute("node");
if (node) {
- const wchar_t *jid2 = XmlGetAttrValue(itemNode, L"jid");
+ const char *jid2 = itemNode->Attribute("jid");
m_ThreadInfo->send(
XmlNodeIq(AddIQ(&CJabberProto::OnIqResult_CommandExecution, JABBER_IQ_TYPE_SET, jid2, 0, -1, hwndDlg))
- << XCHILDNS(L"command", JABBER_FEAT_COMMANDS) << XATTR(L"node", node) << XATTR(L"action", L"execute"));
+ << XCHILDNS("command", JABBER_FEAT_COMMANDS) << XATTR("node", node) << XATTR("action", "execute"));
EnableDlgItem(hwndDlg, IDC_SUBMIT, FALSE);
SetDlgItemText(hwndDlg, IDC_SUBMIT, TranslateT("OK"));
}
}
- xmlDestroyNode(dat->CommandsNode); dat->CommandsNode = nullptr;
return TRUE;
}
// Messages handlers
-int CJabberProto::AdHoc_OnJAHMCommandListResult(HWND hwndDlg, HXML iqNode, JabberAdHocData* dat)
+int CJabberProto::AdHoc_OnJAHMCommandListResult(HWND hwndDlg, TiXmlElement *iqNode, JabberAdHocData *dat)
{
int nodeIdx = 0;
- const wchar_t *type = XmlGetAttrValue(iqNode, L"type");
- if (!type || !mir_wstrcmp(type, L"error")) {
+ const char *type = iqNode->Attribute("type");
+ if (!type || !mir_strcmp(type, "error")) {
// error occurred here
- wchar_t buff[255];
- const wchar_t *code = nullptr;
- const wchar_t *description = nullptr;
+ const char *code = "";
+ const char *description = "";
- HXML errorNode = XmlGetChild(iqNode, "error");
+ TiXmlElement *errorNode = iqNode->FirstChildElement("error");
if (errorNode) {
- code = XmlGetAttrValue(errorNode, L"code");
- description = XmlGetText(errorNode);
+ code = errorNode->Attribute("code");
+ description = errorNode->GetText();
}
- mir_snwprintf(buff, TranslateT("Error %s %s"), (code) ? code : L"", (description) ? description : L"");
- JabberFormSetInstruction(hwndDlg, buff);
+
+ JabberFormSetInstruction(hwndDlg, CMStringA(FORMAT, Translate("Error %s %s"), code, description));
}
- else if (!mir_wstrcmp(type, L"result")) {
+ else if (!mir_strcmp(type, "result")) {
BOOL validResponse = FALSE;
EnumChildWindows(GetDlgItem(hwndDlg, IDC_FRAME), sttDeleteChildWindowsProc, 0);
dat->CurrentHeight = 0;
dat->curPos = 0;
SetScrollPos(GetDlgItem(hwndDlg, IDC_VSCROLL), SB_CTL, 0, FALSE);
- HXML queryNode = XmlGetChild(iqNode, "query");
+ TiXmlElement *queryNode = iqNode->FirstChildElement("query");
if (queryNode) {
- const wchar_t *xmlns = XmlGetAttrValue(queryNode, L"xmlns");
- const wchar_t *node = XmlGetAttrValue(queryNode, L"node");
- if (xmlns && node && !mir_wstrcmp(xmlns, JABBER_FEAT_DISCO_ITEMS) && !mir_wstrcmp(node, JABBER_FEAT_COMMANDS))
+ const char *xmlns = queryNode->Attribute("xmlns");
+ const char *node = queryNode->Attribute("node");
+ if (xmlns && node && !mir_strcmp(xmlns, JABBER_FEAT_DISCO_ITEMS) && !mir_strcmp(node, JABBER_FEAT_COMMANDS))
validResponse = TRUE;
}
- if (queryNode && XmlGetChild(queryNode, 0) && validResponse) {
- dat->CommandsNode = xmlCopyNode(queryNode);
+ if (queryNode && queryNode->FirstChildElement(0) && validResponse) {
+ dat->CommandsNode = queryNode->DeepClone(&dat->doc)->ToElement();
int ypos = 20;
- for (nodeIdx = 1;; nodeIdx++) {
- HXML itemNode = XmlGetNthChild(queryNode, L"item", nodeIdx);
- if (!itemNode)
- break;
-
- const wchar_t *name = XmlGetAttrValue(itemNode, L"name");
- if (!name) name = XmlGetAttrValue(itemNode, L"node");
- ypos = AdHoc_AddCommandRadio(GetDlgItem(hwndDlg, IDC_FRAME), TranslateW(name), nodeIdx, ypos, (nodeIdx == 1) ? 1 : 0);
+ for (auto *itemNode : TiXmlFilter(queryNode, "item")) {
+ const char *name = itemNode->Attribute("name");
+ if (!name)
+ name = itemNode->Attribute("node");
+ ypos = AdHoc_AddCommandRadio(GetDlgItem(hwndDlg, IDC_FRAME), name, nodeIdx, ypos, (nodeIdx == 1) ? 1 : 0);
dat->CurrentHeight = ypos;
}
}
if (nodeIdx > 1) {
- JabberFormSetInstruction(hwndDlg, TranslateT("Select Command"));
+ JabberFormSetInstruction(hwndDlg, Translate("Select Command"));
ShowDlgItem(hwndDlg, IDC_FRAME, SW_SHOW);
ShowDlgItem(hwndDlg, IDC_VSCROLL, SW_SHOW);
EnableDlgItem(hwndDlg, IDC_SUBMIT, TRUE);
}
- else JabberFormSetInstruction(hwndDlg, TranslateT("Not supported"));
+ else JabberFormSetInstruction(hwndDlg, Translate("Not supported"));
}
JabberAdHoc_RefreshFrameScroll(hwndDlg, dat);
return (TRUE);
}
-int CJabberProto::AdHoc_OnJAHMProcessResult(HWND hwndDlg, HXML workNode, JabberAdHocData* dat)
+int CJabberProto::AdHoc_OnJAHMProcessResult(HWND hwndDlg, TiXmlElement *workNode, JabberAdHocData *dat)
{
EnumChildWindows(GetDlgItem(hwndDlg, IDC_FRAME), sttDeleteChildWindowsProc, 0);
dat->CurrentHeight = 0;
@@ -204,48 +196,48 @@ int CJabberProto::AdHoc_OnJAHMProcessResult(HWND hwndDlg, HXML workNode, JabberA
if (workNode == nullptr)
return TRUE;
- dat->AdHocNode = xmlCopyNode(workNode);
+ dat->AdHocNode = workNode->DeepClone(&dat->doc)->ToElement();
- const wchar_t *type;
- if ((type = XmlGetAttrValue(workNode, L"type")) == nullptr) return TRUE;
- if (!mir_wstrcmp(type, L"result")) {
+ const char *type;
+ if ((type = workNode->Attribute("type")) == nullptr) return TRUE;
+ if (!mir_strcmp(type, "result")) {
// wParam = <iq/> node from responder as a result of command execution
- HXML commandNode, xNode;
- if ((commandNode = XmlGetChild(dat->AdHocNode, L"command")) == nullptr)
+ TiXmlElement *commandNode, *xNode;
+ if ((commandNode = dat->AdHocNode->FirstChildElement("command")) == nullptr)
return TRUE;
- const wchar_t *status = XmlGetAttrValue(commandNode, L"status");
+ const char *status = commandNode->Attribute("status");
if (!status)
- status = L"completed";
+ status = "completed";
- if ((xNode = XmlGetChild(commandNode, "x"))) {
+ if ((xNode = commandNode->FirstChildElement("x"))) {
// use jabber:x:data form
HWND hFrame = GetDlgItem(hwndDlg, IDC_FRAME);
ShowWindow(GetDlgItem(hwndDlg, IDC_FRAME_TEXT), SW_HIDE);
- if (const wchar_t *ptszInstr = XmlGetText(XmlGetChild(xNode, "instructions")))
+ if (const char *ptszInstr = xNode->FirstChildElement("instructions")->GetText())
JabberFormSetInstruction(hwndDlg, ptszInstr);
- else if (const wchar_t *ptszTitle = XmlGetText(XmlGetChild(xNode, "title")))
+ else if (const char *ptszTitle = xNode->FirstChildElement("title")->GetText())
JabberFormSetInstruction(hwndDlg, ptszTitle);
else
- JabberFormSetInstruction(hwndDlg, TranslateW(status));
+ JabberFormSetInstruction(hwndDlg, Translate(status));
JabberFormCreateUI(hFrame, xNode, &dat->CurrentHeight);
ShowDlgItem(hwndDlg, IDC_FRAME, SW_SHOW);
}
else {
- //NO X FORM
+ // NO X FORM
int toHide[] = { IDC_FRAME_TEXT, IDC_FRAME, IDC_VSCROLL, 0 };
sttShowControls(hwndDlg, FALSE, toHide);
- const wchar_t *noteText = XmlGetText(XmlGetChild(commandNode, "note"));
- JabberFormSetInstruction(hwndDlg, noteText ? noteText : TranslateW(status));
+ const char *noteText = commandNode->FirstChildElement("note")->GetText();
+ JabberFormSetInstruction(hwndDlg, noteText ? noteText : Translate(status));
}
// check actions
- HXML actionsNode = XmlGetChild(commandNode, "actions");
+ TiXmlElement *actionsNode = commandNode->FirstChildElement("actions");
if (actionsNode != nullptr) {
- ShowDlgItem(hwndDlg, IDC_PREV, (XmlGetChild(actionsNode, "prev") != nullptr) ? SW_SHOW : SW_HIDE);
- ShowDlgItem(hwndDlg, IDC_NEXT, (XmlGetChild(actionsNode, "next") != nullptr) ? SW_SHOW : SW_HIDE);
- ShowDlgItem(hwndDlg, IDC_COMPLETE, (XmlGetChild(actionsNode, "complete") != nullptr) ? SW_SHOW : SW_HIDE);
+ ShowDlgItem(hwndDlg, IDC_PREV, (actionsNode->FirstChildElement("prev") != nullptr) ? SW_SHOW : SW_HIDE);
+ ShowDlgItem(hwndDlg, IDC_NEXT, (actionsNode->FirstChildElement("next") != nullptr) ? SW_SHOW : SW_HIDE);
+ ShowDlgItem(hwndDlg, IDC_COMPLETE, (actionsNode->FirstChildElement("complete") != nullptr) ? SW_SHOW : SW_HIDE);
ShowDlgItem(hwndDlg, IDC_SUBMIT, SW_HIDE);
int toEnable[] = { IDC_PREV, IDC_NEXT, IDC_COMPLETE, 0 };
@@ -259,66 +251,65 @@ int CJabberProto::AdHoc_OnJAHMProcessResult(HWND hwndDlg, HXML workNode, JabberA
EnableDlgItem(hwndDlg, IDC_SUBMIT, TRUE);
}
- if (!status || mir_wstrcmp(status, L"executing")) {
+ if (!status || mir_strcmp(status, "executing")) {
ShowDlgItem(hwndDlg, IDC_SUBMIT, SW_HIDE);
SetDlgItemText(hwndDlg, IDCANCEL, TranslateT("Done"));
}
}
- else if (!mir_wstrcmp(type, L"error")) {
+ else if (!mir_strcmp(type, "error")) {
// error occurred here
int toHide[] = { IDC_FRAME, IDC_FRAME_TEXT, IDC_VSCROLL, IDC_PREV, IDC_NEXT, IDC_COMPLETE, IDC_SUBMIT, 0 };
sttShowControls(hwndDlg, FALSE, toHide);
- const wchar_t *code = nullptr;
- const wchar_t *description = nullptr;
- wchar_t buff[255];
- HXML errorNode = XmlGetChild(workNode, "error");
+ const char *code = "";
+ const char *description = "";
+ TiXmlElement *errorNode = workNode->FirstChildElement("error");
if (errorNode) {
- code = XmlGetAttrValue(errorNode, L"code");
- description = XmlGetText(errorNode);
+ code = errorNode->Attribute("code");
+ description = errorNode->GetText();
}
- mir_snwprintf(buff, TranslateT("Error %s %s"), code ? code : L"", description ? description : L"");
- JabberFormSetInstruction(hwndDlg, buff);
+
+ JabberFormSetInstruction(hwndDlg, CMStringA(FORMAT, Translate("Error %s %s"), code, description));
}
JabberAdHoc_RefreshFrameScroll(hwndDlg, dat);
return TRUE;
}
-int CJabberProto::AdHoc_SubmitCommandForm(HWND hwndDlg, JabberAdHocData* dat, wchar_t* action)
+int CJabberProto::AdHoc_SubmitCommandForm(HWND hwndDlg, JabberAdHocData *dat, char* action)
{
- HXML commandNode = XmlGetChild(dat->AdHocNode, "command");
- HXML xNode = XmlGetChild(commandNode, "x");
- HXML dataNode = JabberFormGetData(GetDlgItem(hwndDlg, IDC_FRAME), xNode);
+ TiXmlElement *commandNode = dat->AdHocNode->FirstChildElement("command");
+ TiXmlElement *xNode = commandNode->FirstChildElement("x");
- const wchar_t *jid2 = XmlGetAttrValue(dat->AdHocNode, L"from");
+ const char *jid2 = dat->AdHocNode->Attribute("from");
XmlNodeIq iq(AddIQ(&CJabberProto::OnIqResult_CommandExecution, JABBER_IQ_TYPE_SET, jid2, 0, -1, hwndDlg));
- HXML command = iq << XCHILDNS(L"command", JABBER_FEAT_COMMANDS);
+ TiXmlElement *command = iq << XCHILDNS("command", JABBER_FEAT_COMMANDS);
- const wchar_t *sessionId = XmlGetAttrValue(commandNode, L"sessionid");
+ const char *sessionId = commandNode->Attribute("sessionid");
if (sessionId)
- command << XATTR(L"sessionid", sessionId);
+ command << XATTR("sessionid", sessionId);
- const wchar_t *node = XmlGetAttrValue(commandNode, L"node");
+ const char *node = commandNode->Attribute("node");
if (node)
- command << XATTR(L"node", node);
+ command << XATTR("node", node);
if (action)
- command << XATTR(L"action", action);
+ command << XATTR("action", action);
- XmlAddChild(command, dataNode);
+ TiXmlElement *dataNode = JabberFormGetData(GetDlgItem(hwndDlg, IDC_FRAME), &iq, xNode);
+ command->InsertEndChild(dataNode);
m_ThreadInfo->send(iq);
- xmlDestroyNode(dataNode);
-
- JabberFormSetInstruction(hwndDlg, TranslateT("In progress. Please Wait..."));
+ JabberFormSetInstruction(hwndDlg, Translate("In progress. Please Wait..."));
static const int toDisable[] = { IDC_SUBMIT, IDC_PREV, IDC_NEXT, IDC_COMPLETE, 0 };
sttEnableControls(hwndDlg, FALSE, toDisable);
return TRUE;
}
-int CJabberProto::AdHoc_AddCommandRadio(HWND hFrame, wchar_t * labelStr, int id, int ypos, int value)
+int CJabberProto::AdHoc_AddCommandRadio(HWND hFrame, const char *labelStr, int id, int ypos, int value)
{
+ Utf2T wszLabel(labelStr);
+
RECT strRect = { 0 };
int verticalStep = 4;
int ctrlMinHeight = 18;
@@ -330,11 +321,11 @@ int CJabberProto::AdHoc_AddCommandRadio(HWND hFrame, wchar_t * labelStr, int id,
int ctrlWidth = rcFrame.right - ctrlOffset;
HDC hdc = GetDC(hFrame);
- int labelHeight = max(ctrlMinHeight, DrawText(hdc, labelStr, -1, &strRect, DT_CALCRECT));
+ int labelHeight = max(ctrlMinHeight, DrawTextW(hdc, wszLabel, -1, &strRect, DT_CALCRECT));
ctrlWidth = min(ctrlWidth, strRect.right - strRect.left + 20);
ReleaseDC(hFrame, hdc);
- HWND hCtrl = CreateWindowEx(0, L"button", labelStr, WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTORADIOBUTTON, ctrlOffset, ypos, ctrlWidth, labelHeight, hFrame, (HMENU)id, g_plugin.getInst(), nullptr);
+ HWND hCtrl = CreateWindowExW(0, L"button", wszLabel, WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTORADIOBUTTON, ctrlOffset, ypos, ctrlWidth, labelHeight, hFrame, (HMENU)id, g_plugin.getInst(), nullptr);
SendMessage(hCtrl, WM_SETFONT, (WPARAM)SendMessage(GetParent(hFrame), WM_GETFONT, 0, 0), 0);
SendMessage(hCtrl, BM_SETCHECK, value, 0);
return (ypos + labelHeight + verticalStep);
@@ -342,14 +333,14 @@ int CJabberProto::AdHoc_AddCommandRadio(HWND hFrame, wchar_t * labelStr, int id,
static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- JabberAdHocData* dat = (JabberAdHocData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ JabberAdHocData *dat = (JabberAdHocData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (msg) {
case WM_INITDIALOG:
- dat = (JabberAdHocData*)mir_calloc(sizeof(JabberAdHocData));
+ dat = new JabberAdHocData();
{
- CJabberAdhocStartupParams* pStartupParams = (CJabberAdhocStartupParams *)lParam;
- dat->ResponderJID = mir_wstrdup(pStartupParams->m_szJid);
+ CJabberAdhocStartupParams *pStartupParams = (CJabberAdhocStartupParams *)lParam;
+ dat->ResponderJID = mir_strdup(pStartupParams->m_szJid);
dat->proto = pStartupParams->m_pProto;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
@@ -373,7 +364,7 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA
SetWindowPos(GetDlgItem(hwndDlg, IDC_VSCROLL), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
SetDlgItemText(hwndDlg, IDC_SUBMIT, TranslateT("Execute"));
- JabberFormSetInstruction(hwndDlg, TranslateT("Requesting command list. Please wait..."));
+ JabberFormSetInstruction(hwndDlg, Translate("Requesting command list. Please wait..."));
if (!pStartupParams->m_szNode) {
dat->proto->AdHoc_RequestListOfCommands(pStartupParams->m_szJid, hwndDlg);
@@ -385,8 +376,8 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA
else {
dat->proto->m_ThreadInfo->send(
XmlNodeIq(dat->proto->AddIQ(&CJabberProto::OnIqResult_CommandExecution, JABBER_IQ_TYPE_SET, pStartupParams->m_szJid, 0, -1, hwndDlg))
- << XCHILDNS(L"command", JABBER_FEAT_COMMANDS)
- << XATTR(L"node", pStartupParams->m_szNode) << XATTR(L"action", L"execute"));
+ << XCHILDNS("command", JABBER_FEAT_COMMANDS)
+ << XATTR("node", pStartupParams->m_szNode) << XATTR("action", "execute"));
EnableDlgItem(hwndDlg, IDC_SUBMIT, FALSE);
SetDlgItemText(hwndDlg, IDC_SUBMIT, TranslateT("OK"));
@@ -410,11 +401,11 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_PREV:
- return dat->proto->AdHoc_SubmitCommandForm(hwndDlg, dat, L"prev");
+ return dat->proto->AdHoc_SubmitCommandForm(hwndDlg, dat, "prev");
case IDC_NEXT:
- return dat->proto->AdHoc_SubmitCommandForm(hwndDlg, dat, L"next");
+ return dat->proto->AdHoc_SubmitCommandForm(hwndDlg, dat, "next");
case IDC_COMPLETE:
- return dat->proto->AdHoc_SubmitCommandForm(hwndDlg, dat, L"complete");
+ return dat->proto->AdHoc_SubmitCommandForm(hwndDlg, dat, "complete");
case IDC_SUBMIT:
if (!dat->AdHocNode && dat->CommandsNode && LOWORD(wParam) == IDC_SUBMIT)
return dat->proto->AdHoc_ExecuteCommand(hwndDlg, dat->ResponderJID, dat);
@@ -422,17 +413,16 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA
return dat->proto->AdHoc_SubmitCommandForm(hwndDlg, dat, nullptr);
case IDCLOSE:
case IDCANCEL:
- xmlDestroyNode(dat->AdHocNode); dat->AdHocNode = nullptr;
DestroyWindow(hwndDlg);
return TRUE;
}
break;
case JAHM_COMMANDLISTRESULT:
- return dat->proto->AdHoc_OnJAHMCommandListResult(hwndDlg, (HXML)lParam, dat);
+ return dat->proto->AdHoc_OnJAHMCommandListResult(hwndDlg, (TiXmlElement*)lParam, dat);
case JAHM_PROCESSRESULT:
- return dat->proto->AdHoc_OnJAHMProcessResult(hwndDlg, (HXML)wParam, dat);
+ return dat->proto->AdHoc_OnJAHMProcessResult(hwndDlg, (TiXmlElement*)wParam, dat);
case WM_MOUSEWHEEL:
{
@@ -492,9 +482,7 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA
dat->proto->m_hwndCommandWindow = nullptr;
mir_free(dat->ResponderJID);
- xmlDestroyNode(dat->CommandsNode);
- xmlDestroyNode(dat->AdHocNode);
- mir_free(dat);
+ delete dat;
dat = nullptr;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
break;
@@ -507,12 +495,11 @@ int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM hContact, LPARAM lParam)
int res = -1;
if ((hContact != 0 || lParam != 0) && m_bJabberOnline) {
- ptrW szJid(getWStringA(hContact, "jid"));
+ ptrA szJid(getUStringA(hContact, "jid"));
if (hContact && szJid != nullptr) {
JABBER_LIST_ITEM *item = nullptr;
int selected = 0;
- wchar_t jid[JABBER_MAX_JID_LEN];
- wcsncpy_s(jid, szJid, _TRUNCATE);
+ CMStringA jid(szJid);
{
mir_cslock lck(m_csLists);
item = ListGetItemPtr(LIST_ROSTER, jid);
@@ -520,7 +507,7 @@ int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM hContact, LPARAM lParam)
if (item->arResources.getCount() > 1) {
HMENU hMenu = CreatePopupMenu();
for (int i = 0; i < item->arResources.getCount(); i++)
- AppendMenu(hMenu, MF_STRING, i + 1, item->arResources[i]->m_tszResourceName);
+ AppendMenu(hMenu, MF_STRING, i + 1, Utf2T(item->arResources[i]->m_szResourceName));
HWND hwndTemp = CreateWindowEx(WS_EX_TOOLWINDOW, L"button", L"PopupMenuHost", 0, 0, 0, 10, 10, nullptr, nullptr, g_plugin.getInst(), nullptr);
SetForegroundWindow(hwndTemp);
RECT rc;
@@ -535,17 +522,16 @@ int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM hContact, LPARAM lParam)
if (selected > 0) {
JABBER_RESOURCE_STATUS *r = item->arResources[selected - 1];
if (r) {
- mir_wstrncat(jid, L"/", _countof(jid) - mir_wstrlen(jid));
- mir_wstrncat(jid, r->m_tszResourceName, _countof(jid) - mir_wstrlen(jid));
+ jid.AppendChar('/');
+ jid.Append(r->m_szResourceName);
}
selected = 1;
}
}
}
- if (item == nullptr || selected) {
+ if (item == nullptr || selected)
ContactMenuAdhocCommands(new CJabberAdhocStartupParams(this, jid, nullptr));
- }
}
else if (lParam != 0)
ContactMenuAdhocCommands((CJabberAdhocStartupParams*)lParam);
diff --git a/protocols/JabberG/src/jabber_agent.cpp b/protocols/JabberG/src/jabber_agent.cpp
index e81495a443..4639d07795 100644
--- a/protocols/JabberG/src/jabber_agent.cpp
+++ b/protocols/JabberG/src/jabber_agent.cpp
@@ -82,13 +82,14 @@ class CAgentRegDlg : public CJabberDlgBase
int m_curPos;
int m_formHeight, m_frameHeight;
RECT m_frameRect;
- HXML m_agentRegIqNode;
- wchar_t *m_jid;
+ TiXmlDocument m_doc;
+ TiXmlElement *m_agentRegIqNode;
+ char *m_jid;
CCtrlButton m_submit;
public:
- CAgentRegDlg(CJabberProto *_ppro, wchar_t *_jid) :
+ CAgentRegDlg(CJabberProto *_ppro, char *_jid) :
CJabberDlgBase(_ppro, IDD_FORM),
m_submit(this, IDC_SUBMIT),
m_jid(_jid),
@@ -118,7 +119,6 @@ public:
void OnDestroy() override
{
- xmlDestroyNode(m_agentRegIqNode);
JabberFormDestroyUI(GetDlgItem(m_hwnd, IDC_FRAME));
m_proto->m_hwndAgentRegInput = nullptr;
EnableWindow(GetParent(m_hwnd), TRUE);
@@ -142,9 +142,13 @@ public:
HWND hFrame = GetDlgItem(m_hwnd, IDC_FRAME);
ShowWindow(GetDlgItem(m_hwnd, IDC_FRAME_TEXT), SW_HIDE);
- HXML queryNode, xNode;
- if ((m_agentRegIqNode = (HXML)lParam) == nullptr) return TRUE;
- if ((queryNode = XmlGetChild(m_agentRegIqNode, "query")) == nullptr) return TRUE;
+ if ((m_agentRegIqNode = (TiXmlElement*)lParam) == nullptr)
+ return TRUE;
+
+ m_agentRegIqNode = m_agentRegIqNode->DeepClone(&m_doc)->ToElement();
+ auto *queryNode = m_agentRegIqNode->FirstChildElement("query");
+ if (queryNode == nullptr)
+ return TRUE;
m_curPos = 0;
GetClientRect(GetDlgItem(m_hwnd, IDC_FRAME), &m_frameRect);
@@ -155,9 +159,9 @@ public:
GetClientRect(GetDlgItem(m_hwnd, IDC_FRAME), &rect);
m_frameHeight = rect.bottom - rect.top;
- if ((xNode = XmlGetChild(queryNode, "x")) != nullptr) {
+ if (auto *xNode = queryNode->FirstChildElement("x")) {
// use new jabber:x:data form
- if (const wchar_t *ptszInstr = XmlGetText(XmlGetChild(xNode, "instructions")))
+ if (const char *ptszInstr = xNode->FirstChildElement("instructions")->GetText())
JabberFormSetInstruction(m_hwnd, ptszInstr);
JabberFormCreateUI(hFrame, xNode, &m_formHeight /*dummy*/);
@@ -165,22 +169,19 @@ public:
else {
// use old registration information form
HJFORMLAYOUT layout_info = JabberFormCreateLayout(hFrame);
- for (int i = 0; ; i++) {
- HXML n = XmlGetChild(queryNode, i);
- if (n == nullptr)
- break;
-
- if (XmlGetName(n)) {
- if (!mir_wstrcmp(XmlGetName(n), L"instructions")) {
- JabberFormSetInstruction(m_hwnd, XmlGetText(n));
+ for (auto *n : TiXmlEnum(queryNode)) {
+ const char *pszName = n->Name();
+ if (pszName) {
+ if (!mir_strcmp(pszName, "instructions")) {
+ JabberFormSetInstruction(m_hwnd, n->GetText());
}
- else if (!mir_wstrcmp(XmlGetName(n), L"key") || !mir_wstrcmp(XmlGetName(n), L"registered")) {
+ else if (!mir_strcmp(pszName, "key") || !mir_strcmp(pszName, "registered")) {
// do nothing
}
- else if (!mir_wstrcmp(XmlGetName(n), L"password"))
- JabberFormAppendControl(hFrame, layout_info, JFORM_CTYPE_TEXT_PRIVATE, XmlGetName(n), XmlGetText(n));
+ else if (!mir_strcmp(pszName, "password"))
+ JabberFormAppendControl(hFrame, layout_info, JFORM_CTYPE_TEXT_PRIVATE, pszName, n->GetText());
else // everything else is a normal text field
- JabberFormAppendControl(hFrame, layout_info, JFORM_CTYPE_TEXT_SINGLE, XmlGetName(n), XmlGetText(n));
+ JabberFormAppendControl(hFrame, layout_info, JFORM_CTYPE_TEXT_SINGLE, pszName, n->GetText());
}
}
JabberFormLayoutControls(hFrame, layout_info, &m_formHeight);
@@ -232,45 +233,41 @@ public:
if (m_agentRegIqNode == nullptr)
return;
- HXML queryNode, xNode;
- const wchar_t *from;
- if ((from = XmlGetAttrValue(m_agentRegIqNode, L"from")) == nullptr) return;
- if ((queryNode = XmlGetChild(m_agentRegIqNode, "query")) == nullptr) return;
+ TiXmlElement *queryNode;
+ const char *from;
+ if ((from = m_agentRegIqNode->Attribute("from")) == nullptr) return;
+ if ((queryNode = m_agentRegIqNode->FirstChildElement("query")) == nullptr) return;
HWND hFrame = GetDlgItem(m_hwnd, IDC_FRAME);
wchar_t *str2 = (wchar_t*)alloca(sizeof(wchar_t) * 128);
int id = 0;
XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultSetRegister, JABBER_IQ_TYPE_SET, from));
- HXML query = iq << XQUERY(JABBER_FEAT_REGISTER);
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_REGISTER);
- if ((xNode = XmlGetChild(queryNode, "x")) != nullptr) {
+ if (auto *xNode = queryNode->FirstChildElement("x")) {
// use new jabber:x:data form
- HXML n = JabberFormGetData(hFrame, xNode);
- XmlAddChild(query, n);
- xmlDestroyNode(n);
+ TiXmlElement *n = JabberFormGetData(hFrame, &iq, xNode);
+ query->InsertEndChild(n);
}
else {
// use old registration information form
- for (int i = 0; ; i++) {
- HXML n = XmlGetChild(queryNode, i);
- if (!n)
- break;
-
- if (XmlGetName(n)) {
- if (!mir_wstrcmp(XmlGetName(n), L"key")) {
+ for (auto *n : TiXmlEnum(queryNode)) {
+ const char *pszName = n->Name();
+ if (pszName) {
+ if (!mir_strcmp(pszName, "key")) {
// field that must be passed along with the registration
- if (XmlGetText(n))
- XmlAddChild(query, XmlGetName(n), XmlGetText(n));
+ if (n->GetText())
+ XmlAddChild(query, pszName, n->GetText());
else
- XmlAddChild(query, XmlGetName(n));
+ XmlAddChild(query, pszName);
}
- else if (!mir_wstrcmp(XmlGetName(n), L"registered") || !mir_wstrcmp(XmlGetName(n), L"instructions")) {
+ else if (!mir_strcmp(pszName, "registered") || !mir_strcmp(pszName, "instructions")) {
// do nothing, we will skip these
}
else {
GetDlgItemText(hFrame, id, str2, 128);
- XmlAddChild(query, XmlGetName(n), str2);
+ XmlAddChild(query, pszName, T2Utf(str2));
id++;
}
}
@@ -285,7 +282,7 @@ public:
}
};
-void CJabberProto::RegisterAgent(HWND /*hwndDlg*/, wchar_t* jid)
+void CJabberProto::RegisterAgent(HWND, char *jid)
{
(new CAgentRegDlg(this, jid))->Show();
}
diff --git a/protocols/JabberG/src/jabber_api.cpp b/protocols/JabberG/src/jabber_api.cpp
index 4560cb081a..4d52cfa41b 100644
--- a/protocols/JabberG/src/jabber_api.cpp
+++ b/protocols/JabberG/src/jabber_api.cpp
@@ -50,29 +50,29 @@ DWORD CJabberProto::GetJabberVersion() const
return PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM);
}
-MCONTACT CJabberProto::ContactFromJID(const wchar_t *jid)
+MCONTACT CJabberProto::ContactFromJID(const char *jid)
{
return HContactFromJID(jid);
}
-LPTSTR CJabberProto::ContactToJID(MCONTACT hContact)
+char* CJabberProto::ContactToJID(MCONTACT hContact)
{
- return getWStringA(hContact, isChatRoom(hContact) ? "ChatRoomID" : "jid");
+ return getUStringA(hContact, isChatRoom(hContact) ? "ChatRoomID" : "jid");
}
-LPTSTR CJabberProto::GetBestResourceName(const wchar_t *jid)
+char* CJabberProto::GetBestResourceName(const char *jid)
{
if (jid == nullptr)
return nullptr;
- const wchar_t *p = wcschr(jid, '/');
+ const char *p = strchr(jid, '/');
if (p == nullptr) {
mir_cslock lck(m_csLists);
- return mir_wstrdup(ListGetBestClientResourceNamePtr(jid));
+ return mir_strdup(ListGetBestClientResourceNamePtr(jid));
}
- return mir_wstrdup(jid);
+ return mir_strdup(jid);
}
-LPTSTR CJabberProto::GetResourceList(const wchar_t *jid)
+char* CJabberProto::GetResourceList(const char *jid)
{
if (jid == nullptr)
return nullptr;
@@ -87,58 +87,53 @@ LPTSTR CJabberProto::GetResourceList(const wchar_t *jid)
if (!item->arResources.getCount())
return nullptr;
- CMStringW res;
+ CMStringA res;
for (auto &it : item->arResources) {
- res.Append(it->m_tszResourceName);
+ res.Append(it->m_szResourceName);
res.AppendChar(0);
}
res.AppendChar(0);
- return mir_wstrndup(res, res.GetLength());
+ return mir_strndup(res, res.GetLength());
}
-char *CJabberProto::GetModuleName() const
+char* CJabberProto::GetModuleName() const
{
return m_szModuleName;
}
-int CJabberProto::SendXmlNode(HXML node)
-{
- return m_ThreadInfo->send(node);
-}
-
typedef struct
{
JABBER_HANDLER_FUNC Func;
void *pUserData;
} sHandlerData;
-void CJabberProto::ExternalTempIqHandler(HXML node, CJabberIqInfo *pInfo)
+void CJabberProto::ExternalTempIqHandler(const TiXmlElement *node, CJabberIqInfo *pInfo)
{
sHandlerData *d = (sHandlerData*)pInfo->GetUserData();
d->Func(this, node, d->pUserData);
free(d); // free IqHandlerData allocated in CJabberProto::AddIqHandler below
}
-BOOL CJabberProto::ExternalIqHandler(HXML node, CJabberIqInfo *pInfo)
+BOOL CJabberProto::ExternalIqHandler(const TiXmlElement *node, CJabberIqInfo *pInfo)
{
sHandlerData *d = (sHandlerData*)pInfo->GetUserData();
return d->Func(this, node, d->pUserData);
}
-BOOL CJabberProto::ExternalMessageHandler(HXML node, ThreadData*, CJabberMessageInfo* pInfo)
+BOOL CJabberProto::ExternalMessageHandler(const TiXmlElement *node, ThreadData*, CJabberMessageInfo* pInfo)
{
sHandlerData *d = (sHandlerData*)pInfo->GetUserData();
return d->Func(this, node, d->pUserData);
}
-BOOL CJabberProto::ExternalPresenceHandler(HXML node, ThreadData*, CJabberPresenceInfo* pInfo)
+BOOL CJabberProto::ExternalPresenceHandler(const TiXmlElement *node, ThreadData*, CJabberPresenceInfo* pInfo)
{
sHandlerData *d = (sHandlerData*)pInfo->GetUserData();
return d->Func(this, node, d->pUserData);
}
-BOOL CJabberProto::ExternalSendHandler(HXML node, ThreadData*, CJabberSendInfo* pInfo)
+BOOL CJabberProto::ExternalSendHandler(const TiXmlElement *node, ThreadData*, CJabberSendInfo* pInfo)
{
sHandlerData *d = (sHandlerData*)pInfo->GetUserData();
return d->Func(this, node, d->pUserData);
@@ -152,7 +147,7 @@ HJHANDLER CJabberProto::AddPresenceHandler(JABBER_HANDLER_FUNC Func, void *pUser
return (HJHANDLER)m_presenceManager.AddPermanentHandler(&CJabberProto::ExternalPresenceHandler, d, free, iPriority);
}
-HJHANDLER CJabberProto::AddMessageHandler(JABBER_HANDLER_FUNC Func, int iMsgTypes, const wchar_t *szXmlns, const wchar_t *szTag, void *pUserData, int iPriority)
+HJHANDLER CJabberProto::AddMessageHandler(JABBER_HANDLER_FUNC Func, int iMsgTypes, const char *szXmlns, const char *szTag, void *pUserData, int iPriority)
{
sHandlerData *d = (sHandlerData*)malloc(sizeof(sHandlerData));
d->Func = Func;
@@ -160,7 +155,7 @@ HJHANDLER CJabberProto::AddMessageHandler(JABBER_HANDLER_FUNC Func, int iMsgType
return (HJHANDLER)m_messageManager.AddPermanentHandler(&CJabberProto::ExternalMessageHandler, iMsgTypes, 0, szXmlns, FALSE, szTag, d, free, iPriority);
}
-HJHANDLER CJabberProto::AddIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, const wchar_t *szXmlns, const wchar_t *szTag, void *pUserData, int iPriority)
+HJHANDLER CJabberProto::AddIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, const char *szXmlns, const char *szTag, void *pUserData, int iPriority)
{
sHandlerData *d = (sHandlerData*)malloc(sizeof(sHandlerData));
d->Func = Func;
@@ -196,23 +191,23 @@ int CJabberProto::RemoveHandler(HJHANDLER hHandler)
m_iqManager.DeleteHandler((CJabberIqInfo*)hHandler);
}
-JabberFeatCapPairDynamic *CJabberProto::FindFeature(const wchar_t *szFeature)
+JabberFeatCapPairDynamic *CJabberProto::FindFeature(const char *szFeature)
{
for (auto &it : m_lstJabberFeatCapPairsDynamic)
- if (!mir_wstrcmp(it->szFeature, szFeature))
+ if (!mir_strcmp(it->szFeature, szFeature))
return it;
return nullptr;
}
-int CJabberProto::RegisterFeature(const wchar_t *szFeature, const wchar_t *szDescription)
+int CJabberProto::RegisterFeature(const char *szFeature, const char *szDescription)
{
if (!szFeature)
return false;
// check for this feature in core features, and return false if it's present, to prevent re-registering a core feature
for (int i = 0; i < g_cJabberFeatCapPairs; i++)
- if (!mir_wstrcmp(g_JabberFeatCapPairs[i].szFeature, szFeature))
+ if (!mir_strcmp(g_JabberFeatCapPairs[i].szFeature, szFeature))
return false;
mir_cslock lck(m_csLists);
@@ -236,8 +231,8 @@ int CJabberProto::RegisterFeature(const wchar_t *szFeature, const wchar_t *szDes
return false;
// remove unnecessary symbols from szFeature to make the string shorter, and use it as szExt
- LPTSTR szExt = mir_wstrdup(szFeature);
- LPTSTR pSrc, pDst;
+ LPSTR szExt = mir_strdup(szFeature);
+ LPSTR pSrc, pDst;
for (pSrc = szExt, pDst = szExt; *pSrc; pSrc++)
if (wcschr(L"bcdfghjklmnpqrstvwxz0123456789", *pSrc))
*pDst++ = *pSrc;
@@ -246,27 +241,27 @@ int CJabberProto::RegisterFeature(const wchar_t *szFeature, const wchar_t *szDes
fcp = new JabberFeatCapPairDynamic();
fcp->szExt = szExt; // will be deallocated along with other values of JabberFeatCapPairDynamic in CJabberProto destructor
- fcp->szFeature = mir_wstrdup(szFeature);
- fcp->szDescription = szDescription ? mir_wstrdup(szDescription) : nullptr;
+ fcp->szFeature = mir_strdup(szFeature);
+ fcp->szDescription = szDescription ? mir_strdup(szDescription) : nullptr;
fcp->jcbCap = jcb;
m_lstJabberFeatCapPairsDynamic.insert(fcp);
}
else if (szDescription) { // update description
if (fcp->szDescription)
mir_free(fcp->szDescription);
- fcp->szDescription = mir_wstrdup(szDescription);
+ fcp->szDescription = mir_strdup(szDescription);
}
return true;
}
-int CJabberProto::AddFeatures(const wchar_t *szFeatures)
+int CJabberProto::AddFeatures(const char *szFeatures)
{
if (!szFeatures)
return false;
mir_cslockfull lck(m_csLists);
BOOL ret = true;
- const wchar_t *szFeat = szFeatures;
+ const char *szFeat = szFeatures;
while (szFeat[0]) {
JabberFeatCapPairDynamic *fcp = FindFeature(szFeat);
// if someone is trying to add one of core features, RegisterFeature() will return false, so we don't have to perform this check here
@@ -280,7 +275,7 @@ int CJabberProto::AddFeatures(const wchar_t *szFeatures)
m_uEnabledFeatCapsDynamic |= fcp->jcbCap;
else
ret = false;
- szFeat += mir_wstrlen(szFeat) + 1;
+ szFeat += mir_strlen(szFeat) + 1;
}
lck.unlock();
@@ -290,14 +285,14 @@ int CJabberProto::AddFeatures(const wchar_t *szFeatures)
return ret;
}
-int CJabberProto::RemoveFeatures(const wchar_t *szFeatures)
+int CJabberProto::RemoveFeatures(const char *szFeatures)
{
if (!szFeatures)
return false;
mir_cslockfull lck(m_csLists);
BOOL ret = true;
- const wchar_t *szFeat = szFeatures;
+ const char *szFeat = szFeatures;
while (szFeat[0]) {
JabberFeatCapPairDynamic *fcp = FindFeature(szFeat);
if (fcp)
@@ -305,7 +300,7 @@ int CJabberProto::RemoveFeatures(const wchar_t *szFeatures)
else
ret = false; // indicate that there was an error removing at least one of the specified features
- szFeat += mir_wstrlen(szFeat) + 1;
+ szFeat += mir_strlen(szFeat) + 1;
}
lck.unlock();
@@ -315,13 +310,13 @@ int CJabberProto::RemoveFeatures(const wchar_t *szFeatures)
return ret;
}
-LPTSTR CJabberProto::GetResourceFeatures(const wchar_t *jid)
+char* CJabberProto::GetResourceFeatures(const char *jid)
{
JabberCapsBits jcb = GetResourceCapabilities(jid);
if (jcb & JABBER_RESOURCE_CAPS_ERROR)
return nullptr;
- CMStringW res;
+ CMStringA res;
mir_cslockfull lck(m_csLists);
// allocate memory and fill it
diff --git a/protocols/JabberG/src/jabber_archive.cpp b/protocols/JabberG/src/jabber_archive.cpp
index fdf51062de..e60891f0d4 100644
--- a/protocols/JabberG/src/jabber_archive.cpp
+++ b/protocols/JabberG/src/jabber_archive.cpp
@@ -33,8 +33,8 @@ bool operator==(const DBEVENTINFO &ev1, const DBEVENTINFO &ev2)
void CJabberProto::EnableArchive(bool bEnable)
{
- m_ThreadInfo->send(XmlNodeIq(L"set", SerialNext())
- << XCHILDNS(L"auto", JABBER_FEAT_ARCHIVE) << XATTR(L"save", (bEnable) ? L"true" : L"false"));
+ m_ThreadInfo->send(XmlNodeIq("set", SerialNext())
+ << XCHILDNS("auto", JABBER_FEAT_ARCHIVE) << XATTR("save", (bEnable) ? "true" : "false"));
}
void CJabberProto::RetrieveMessageArchive(MCONTACT hContact, JABBER_LIST_ITEM *pItem)
@@ -45,38 +45,34 @@ void CJabberProto::RetrieveMessageArchive(MCONTACT hContact, JABBER_LIST_ITEM *p
pItem->bHistoryRead = true;
XmlNodeIq iq(AddIQ(&CJabberProto::OnIqResultGetCollectionList, JABBER_IQ_TYPE_GET));
- HXML list = iq << XCHILDNS(L"list", JABBER_FEAT_ARCHIVE) << XATTR(L"with", pItem->jid);
+ TiXmlElement *list = iq << XCHILDNS("list", JABBER_FEAT_ARCHIVE) << XATTR("with", pItem->jid);
time_t tmLast = getDword(hContact, "LastCollection", 0);
if (tmLast) {
- wchar_t buf[40];
- list << XATTR(L"start", time2str(tmLast, buf, _countof(buf)));
+ char buf[40];
+ list << XATTR("start", time2str(tmLast, buf, _countof(buf)));
}
m_ThreadInfo->send(iq);
}
-void CJabberProto::OnIqResultGetCollectionList(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultGetCollectionList(const TiXmlElement *iqNode, CJabberIqInfo*)
{
- const wchar_t *to = XmlGetAttrValue(iqNode, L"to");
- if (to == nullptr || mir_wstrcmp(XmlGetAttrValue(iqNode, L"type"), L"result"))
+ const char *to = iqNode->Attribute("to");
+ if (to == nullptr || mir_strcmp(iqNode->Attribute("type"), "result"))
return;
- HXML list = XmlGetChild(iqNode, "list");
- if (!list || mir_wstrcmp(XmlGetAttrValue(list, L"xmlns"), JABBER_FEAT_ARCHIVE))
+ auto *list = iqNode->FirstChildElement("list");
+ if (!list || mir_strcmp(list->Attribute("xmlns"), JABBER_FEAT_ARCHIVE))
return;
- for (int nodeIdx = 1;; nodeIdx++) {
- HXML itemNode = XmlGetNthChild(list, L"chat", nodeIdx);
- if (!itemNode)
- break;
-
- const wchar_t* start = XmlGetAttrValue(itemNode, L"start");
- const wchar_t* with = XmlGetAttrValue(itemNode, L"with");
+ for (auto *itemNode : TiXmlFilter(list, "chat")) {
+ const char *start = itemNode->Attribute("start");
+ const char *with = itemNode->Attribute("with");
if (!start || !with)
continue;
m_ThreadInfo->send(XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetCollection, JABBER_IQ_TYPE_GET))
- << XCHILDNS(L"retrieve", JABBER_FEAT_ARCHIVE) << XATTR(L"with", with) << XATTR(L"start", start));
+ << XCHILDNS("retrieve", JABBER_FEAT_ARCHIVE) << XATTR("with", with) << XATTR("start", start));
}
}
@@ -214,17 +210,17 @@ BOOL IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO& dbei)
return FALSE;
}
-void CJabberProto::OnIqResultGetCollection(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultGetCollection(const TiXmlElement *iqNode, CJabberIqInfo*)
{
- if (mir_wstrcmp(XmlGetAttrValue(iqNode, L"type"), L"result"))
+ if (mir_strcmp(iqNode->Attribute("type"), "result"))
return;
- HXML chatNode = XmlGetChild(iqNode, "chat");
- if (!chatNode || mir_wstrcmp(XmlGetAttrValue(chatNode, L"xmlns"), JABBER_FEAT_ARCHIVE))
+ auto *chatNode = iqNode->FirstChildElement("chat");
+ if (!chatNode || mir_strcmp(chatNode->Attribute("xmlns"), JABBER_FEAT_ARCHIVE))
return;
- const wchar_t* start = XmlGetAttrValue(chatNode, L"start");
- const wchar_t* with = XmlGetAttrValue(chatNode, L"with");
+ const char* start = chatNode->Attribute("start");
+ const char* with = chatNode->Attribute("with");
if (!start || !with)
return;
@@ -237,38 +233,32 @@ void CJabberProto::OnIqResultGetCollection(HXML iqNode, CJabberIqInfo*)
time_t tmLast = getDword(hContact, "LastCollection", 0);
- for (int nodeIdx = 0;; nodeIdx++) {
- HXML itemNode = XmlGetChild(chatNode, nodeIdx);
- if (!itemNode)
- break;
-
+ for (auto *itemNode : TiXmlEnum(chatNode)) {
int from;
- const wchar_t *itemName = XmlGetName(itemNode);
- if (!mir_wstrcmp(itemName, L"to"))
+ const char *itemName = itemNode->Name();
+ if (!mir_strcmp(itemName, "to"))
from = DBEF_SENT;
- else if (!mir_wstrcmp(itemName, L"from"))
+ else if (!mir_strcmp(itemName, "from"))
from = 0;
else
continue;
- HXML body = XmlGetChild(itemNode, "body");
+ const TiXmlElement *body = itemNode->FirstChildElement("body");
if (!body)
continue;
- const wchar_t *tszBody = XmlGetText(body);
- const wchar_t *tszSecs = XmlGetAttrValue(itemNode, L"secs");
+ const char *tszBody = body->GetText();
+ const char *tszSecs = itemNode->Attribute("secs");
if (!tszBody || !tszSecs)
continue;
- T2Utf szEventText(tszBody);
-
DBEVENTINFO dbei = {};
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.szModule = m_szModuleName;
- dbei.cbBlob = (DWORD)mir_strlen(szEventText) + 1;
+ dbei.cbBlob = (DWORD)mir_strlen(tszBody) + 1;
dbei.flags = DBEF_READ + DBEF_UTF + from;
- dbei.pBlob = szEventText;
- dbei.timestamp = tmStart + _wtol(tszSecs);
+ dbei.pBlob = (BYTE*)tszBody;
+ dbei.timestamp = tmStart + atol(tszSecs);
if (!IsDuplicateEvent(hContact, dbei))
db_event_add(hContact, &dbei);
diff --git a/protocols/JabberG/src/jabber_bookmarks.cpp b/protocols/JabberG/src/jabber_bookmarks.cpp
index 5f2d258a5d..aacea692dc 100644
--- a/protocols/JabberG/src/jabber_bookmarks.cpp
+++ b/protocols/JabberG/src/jabber_bookmarks.cpp
@@ -48,8 +48,8 @@ static INT_PTR CALLBACK JabberAddBookmarkDlgProc(HWND hwndDlg, UINT msg, WPARAM
param->ppro->m_hwndJabberAddBookmark = hwndDlg;
TranslateDialogDefault(hwndDlg);
if (item = param->m_item) {
- if (!mir_wstrcmp(item->type, L"conference")) {
- if (!wcschr(item->jid, '@')) { //no room name - consider it is transport
+ if (!mir_strcmp(item->type, "conference")) {
+ if (!strchr(item->jid, '@')) { //no room name - consider it is transport
CheckDlgButton(hwndDlg, IDC_AGENT_RADIO, BST_CHECKED);
EnableWindow(GetDlgItem(hwndDlg, IDC_NICK), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), FALSE);
@@ -69,10 +69,10 @@ static INT_PTR CALLBACK JabberAddBookmarkDlgProc(HWND hwndDlg, UINT msg, WPARAM
EnableWindow(GetDlgItem(hwndDlg, IDC_AGENT_RADIO), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_BM_AUTOJOIN), FALSE);
- if (item->jid) SetDlgItemText(hwndDlg, IDC_ROOM_JID, item->jid);
- if (item->name) SetDlgItemText(hwndDlg, IDC_NAME, item->name);
- if (item->nick) SetDlgItemText(hwndDlg, IDC_NICK, item->nick);
- if (item->password) SetDlgItemText(hwndDlg, IDC_PASSWORD, item->password);
+ if (item->jid) SetDlgItemTextUtf(hwndDlg, IDC_ROOM_JID, item->jid);
+ if (item->name) SetDlgItemTextW(hwndDlg, IDC_NAME, item->name);
+ if (item->nick) SetDlgItemTextUtf(hwndDlg, IDC_NICK, item->nick);
+ if (item->password) SetDlgItemTextUtf(hwndDlg, IDC_PASSWORD, item->password);
if (item->bAutoJoin) CheckDlgButton(hwndDlg, IDC_CHECK_BM_AUTOJOIN, BST_CHECKED);
if (IsDlgButtonChecked(hwndDlg, IDC_ROOM_RADIO) == BST_CHECKED)
EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_BM_AUTOJOIN), TRUE);
@@ -111,7 +111,7 @@ static INT_PTR CALLBACK JabberAddBookmarkDlgProc(HWND hwndDlg, UINT msg, WPARAM
case IDOK:
{
GetDlgItemText(hwndDlg, IDC_ROOM_JID, text, _countof(text));
- wchar_t *roomJID = NEWWSTR_ALLOCA(text);
+ T2Utf roomJID(text);
if (param->m_item)
param->ppro->ListRemove(LIST_BOOKMARK, param->m_item->jid);
@@ -119,18 +119,18 @@ static INT_PTR CALLBACK JabberAddBookmarkDlgProc(HWND hwndDlg, UINT msg, WPARAM
item = param->ppro->ListAdd(LIST_BOOKMARK, roomJID);
if (IsDlgButtonChecked(hwndDlg, IDC_URL_RADIO) == BST_CHECKED)
- replaceStrW(item->type, L"url");
+ replaceStr(item->type, "url");
else
- replaceStrW(item->type, L"conference");
+ replaceStr(item->type, "conference");
GetDlgItemText(hwndDlg, IDC_NICK, text, _countof(text));
- replaceStrW(item->nick, text);
+ replaceStr(item->nick, T2Utf(text));
GetDlgItemText(hwndDlg, IDC_PASSWORD, text, _countof(text));
- replaceStrW(item->password, text);
+ replaceStr(item->password, T2Utf(text));
GetDlgItemText(hwndDlg, IDC_NAME, text, _countof(text));
- replaceStrW(item->name, (text[0] == 0) ? roomJID : text);
+ replaceStrW(item->name, (text[0] == 0) ? Utf2T(roomJID) : text);
item->bAutoJoin = IsDlgButtonChecked(hwndDlg, IDC_CHECK_BM_AUTOJOIN) == BST_CHECKED;
@@ -204,16 +204,20 @@ private:
void btnEdit_OnClick(CCtrlFilterListView *)
{
- if (!m_proto->m_bJabberOnline) return;
+ if (!m_proto->m_bJabberOnline)
+ return;
int iItem = m_lvBookmarks.GetNextItem(-1, LVNI_SELECTED);
- if (iItem < 0) return;
+ if (iItem < 0)
+ return;
- wchar_t *address = (wchar_t *)m_lvBookmarks.GetItemData(iItem);
- if (address == nullptr) return;
+ char *address = (char*)m_lvBookmarks.GetItemData(iItem);
+ if (address == nullptr)
+ return;
JABBER_LIST_ITEM *item = m_proto->ListGetItemPtr(LIST_BOOKMARK, address);
- if (item == nullptr) return;
+ if (item == nullptr)
+ return;
JabberAddBookmarkDlgParam param;
param.ppro = m_proto;
@@ -223,16 +227,20 @@ private:
void btnRemove_OnClick(CCtrlFilterListView *)
{
- if (!m_proto->m_bJabberOnline) return;
+ if (!m_proto->m_bJabberOnline)
+ return;
int iItem = m_lvBookmarks.GetNextItem(-1, LVNI_SELECTED);
- if (iItem < 0) return;
+ if (iItem < 0)
+ return;
- wchar_t *address = (wchar_t *)m_lvBookmarks.GetItemData(iItem);
- if (address == nullptr) return;
+ char *address = (char*)m_lvBookmarks.GetItemData(iItem);
+ if (address == nullptr)
+ return;
JABBER_LIST_ITEM *item = m_proto->ListGetItemPtr(LIST_BOOKMARK, address);
- if (item == nullptr) return;
+ if (item == nullptr)
+ return;
m_btnAdd.Disable();
m_btnEdit.Disable();
@@ -267,7 +275,7 @@ void CJabberDlgBookmarks::UpdateData()
m_proto->m_ThreadInfo->send(
XmlNodeIq(m_proto->AddIQ(&CJabberProto::OnIqResultDiscoBookmarks, JABBER_IQ_TYPE_GET))
- << XQUERY(JABBER_FEAT_PRIVATE_STORAGE) << XCHILDNS(L"storage", L"storage:bookmarks"));
+ << XQUERY(JABBER_FEAT_PRIVATE_STORAGE) << XCHILDNS("storage", "storage:bookmarks"));
}
bool CJabberDlgBookmarks::OnInitDialog()
@@ -324,33 +332,36 @@ void CJabberDlgBookmarks::OnDestroy()
void CJabberDlgBookmarks::OpenBookmark()
{
int iItem = m_lvBookmarks.GetNextItem(-1, LVNI_SELECTED);
- if (iItem < 0) return;
+ if (iItem < 0)
+ return;
- wchar_t *address = (wchar_t *)m_lvBookmarks.GetItemData(iItem);
- if (address == nullptr) return;
+ char *address = (char*)m_lvBookmarks.GetItemData(iItem);
+ if (address == nullptr)
+ return;
JABBER_LIST_ITEM *item = m_proto->ListGetItemPtr(LIST_BOOKMARK, address);
- if (item == nullptr) return;
+ if (item == nullptr)
+ return;
- if (!mir_wstrcmpi(item->type, L"conference")) {
+ if (!mir_strcmpi(item->type, "conference")) {
m_lvBookmarks.SetItemState(iItem, 0, LVIS_SELECTED); // Unselect the item
/* some hack for using bookmark to transport not under XEP-0048 */
- if (!wcschr(item->jid, '@'))
+ if (!strchr(item->jid, '@'))
//the room name is not provided let consider that it is transport and send request to registration
m_proto->RegisterAgent(nullptr, item->jid);
else {
- wchar_t *room = NEWWSTR_ALLOCA(item->jid);
- wchar_t *server = wcschr(room, '@');
+ char *room = NEWSTR_ALLOCA(item->jid);
+ char *server = strchr(room, '@');
*(server++) = 0;
if (item->nick && *item->nick)
m_proto->GroupchatJoinRoom(server, room, item->nick, item->password);
else
- m_proto->GroupchatJoinRoom(server, room, ptrW(JabberNickFromJID(m_proto->m_szJabberJID)), item->password);
+ m_proto->GroupchatJoinRoom(server, room, ptrA(JabberNickFromJID(m_proto->m_szJabberJID)), item->password);
}
}
- else Utils_OpenUrlW(item->jid);
+ else Utils_OpenUrl(item->jid);
}
INT_PTR CJabberDlgBookmarks::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
@@ -394,11 +405,11 @@ void CJabberDlgBookmarks::OnProtoRefresh(WPARAM, LPARAM)
LISTFOREACH(i, m_proto, LIST_BOOKMARK)
{
if (item = m_proto->ListGetItemPtrFromIndex(i)) {
- int itemType = mir_wstrcmpi(item->type, L"conference") ? 1 : 0;
+ int itemType = mir_strcmpi(item->type, "conference") ? 1 : 0;
int iItem = m_lvBookmarks.AddItem(item->name, itemType, (LPARAM)item->jid, itemType);
- m_lvBookmarks.SetItem(iItem, 1, item->jid);
+ m_lvBookmarks.SetItem(iItem, 1, Utf2T(item->jid));
if (itemType == 0)
- m_lvBookmarks.SetItem(iItem, 2, item->nick);
+ m_lvBookmarks.SetItem(iItem, 2, Utf2T(item->nick));
}
}
diff --git a/protocols/JabberG/src/jabber_byte.cpp b/protocols/JabberG/src/jabber_byte.cpp
index fa97cb5483..bf4c98c6c2 100644
--- a/protocols/JabberG/src/jabber_byte.cpp
+++ b/protocols/JabberG/src/jabber_byte.cpp
@@ -44,8 +44,6 @@ JABBER_BYTE_TRANSFER::~JABBER_BYTE_TRANSFER()
mir_free(iqId);
mir_free(sid);
- xmlDestroyNode(iqNode);
-
// XEP-0065 proxy support
mir_free(szProxyHost);
mir_free(szProxyPort);
@@ -53,26 +51,30 @@ JABBER_BYTE_TRANSFER::~JABBER_BYTE_TRANSFER()
mir_free(szStreamhostUsed);
}
-void CJabberProto::IqResultProxyDiscovery(HXML iqNode, CJabberIqInfo *pInfo)
+void CJabberProto::IqResultProxyDiscovery(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
JABBER_BYTE_TRANSFER *jbt = (JABBER_BYTE_TRANSFER *)pInfo->GetUserData();
if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
- HXML queryNode = XmlGetChild(iqNode , "query");
+ auto *queryNode = iqNode->FirstChildElement("query");
if (queryNode) {
- const wchar_t *queryXmlns = XmlGetAttrValue(queryNode, L"xmlns");
- if (queryXmlns && !mir_wstrcmp(queryXmlns, JABBER_FEAT_BYTESTREAMS)) {
- HXML streamHostNode = XmlGetChild(queryNode , "streamhost");
+ const char *queryXmlns = queryNode->Attribute("xmlns");
+ if (queryXmlns && !mir_strcmp(queryXmlns, JABBER_FEAT_BYTESTREAMS)) {
+ auto *streamHostNode = queryNode->FirstChildElement("streamhost");
if (streamHostNode) {
- const wchar_t *streamJid = XmlGetAttrValue(streamHostNode, L"jid");
- const wchar_t *streamHost = XmlGetAttrValue(streamHostNode, L"host");
- const wchar_t *streamPort = XmlGetAttrValue(streamHostNode, L"port");
+ const char *streamJid = streamHostNode->Attribute("jid");
+ const char *streamHost = streamHostNode->Attribute("host");
+ const char *streamPort = streamHostNode->Attribute("port");
if (streamJid && streamHost && streamPort) {
- jbt->szProxyHost = mir_wstrdup(streamHost);
- jbt->szProxyJid = mir_wstrdup(streamJid);
- jbt->szProxyPort = mir_wstrdup(streamPort);
- jbt->bProxyDiscovered = TRUE;
- } } } } }
+ jbt->szProxyHost = mir_strdup(streamHost);
+ jbt->szProxyJid = mir_strdup(streamJid);
+ jbt->szProxyPort = mir_strdup(streamPort);
+ jbt->bProxyDiscovered = true;
+ }
+ }
+ }
+ }
+ }
else if (pInfo->GetIqType() == JABBER_IQ_TYPE_ERROR)
jbt->state = JBT_ERROR;
@@ -83,7 +85,6 @@ void CJabberProto::IqResultProxyDiscovery(HXML iqNode, CJabberIqInfo *pInfo)
void JabberByteSendConnection(HNETLIBCONN hConn, DWORD /*dwRemoteIP*/, void* extra)
{
CJabberProto *ppro = (CJabberProto*)extra;
- wchar_t szPort[8];
JABBER_BYTE_TRANSFER *jbt;
int recvResult, bytesParsed;
HANDLE hListen;
@@ -94,7 +95,8 @@ void JabberByteSendConnection(HNETLIBCONN hConn, DWORD /*dwRemoteIP*/, void* ext
NETLIBCONNINFO connInfo = {};
Netlib_GetConnectionInfo(hConn, &connInfo);
- mir_snwprintf(szPort, L"%u", connInfo.wPort);
+ char szPort[8];
+ itoa(connInfo.wPort, szPort, 10);
ppro->debugLogA("bytestream_send_connection incoming connection accepted: %s", connInfo.szIpPort);
if ((item = ppro->ListGetItemPtr(LIST_BYTE, szPort)) == nullptr) {
@@ -117,15 +119,15 @@ void JabberByteSendConnection(HNETLIBCONN hConn, DWORD /*dwRemoteIP*/, void* ext
jbt->hConn = hConn;
jbt->state = JBT_INIT;
datalen = 0;
- while (jbt->state!=JBT_DONE && jbt->state!=JBT_ERROR) {
- recvResult = Netlib_Recv(hConn, buffer+datalen, JABBER_NETWORK_BUFFER_SIZE-datalen, 0);
+ while (jbt->state != JBT_DONE && jbt->state != JBT_ERROR) {
+ recvResult = Netlib_Recv(hConn, buffer + datalen, JABBER_NETWORK_BUFFER_SIZE - datalen, 0);
if (recvResult <= 0)
break;
datalen += recvResult;
bytesParsed = ppro->ByteSendParse(hConn, jbt, buffer, datalen);
if (bytesParsed < datalen)
- memmove(buffer, buffer+bytesParsed, datalen-bytesParsed);
+ memmove(buffer, buffer + bytesParsed, datalen - bytesParsed);
datalen -= bytesParsed;
}
@@ -142,7 +144,6 @@ void JabberByteSendConnection(HNETLIBCONN hConn, DWORD /*dwRemoteIP*/, void* ext
void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt)
{
- wchar_t szPort[8];
HANDLE hEvent = nullptr;
int nIqId = 0;
@@ -152,7 +153,7 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt)
BOOL bDirect = m_bBsDirect;
if (m_bBsProxyManual) {
- ptrW proxyJid( getWStringA("BsProxyServer"));
+ ptrA proxyJid(getUStringA("BsProxyServer"));
if (proxyJid) {
jbt->bProxyDiscovered = FALSE;
jbt->szProxyHost = nullptr;
@@ -173,19 +174,22 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt)
if (jbt->state == JBT_ERROR && !bDirect) {
debugLogA("Bytestream proxy failure");
- MsgPopup(pInfo->GetHContact(), TranslateT("Bytestream Proxy not available"), proxyJid);
+ MsgPopup(pInfo->GetHContact(), TranslateT("Bytestream Proxy not available"), _A2T(proxyJid));
jbt->ft->state = FT_DENIED;
(this->*jbt->pfnFinal)(FALSE, jbt->ft);
jbt->ft = nullptr;
delete jbt;
return;
- } } }
+ }
+ }
+ }
CJabberIqInfo *pInfo = AddIQ(&CJabberProto::ByteInitiateResult, JABBER_IQ_TYPE_SET, jbt->dstJID, 0, -1, jbt);
nIqId = pInfo->GetIqId();
+ char szPort[8];
{
XmlNodeIq iq(pInfo);
- HXML query = iq << XQUERY(JABBER_FEAT_BYTESTREAMS) << XATTR(L"sid", jbt->sid);
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_BYTESTREAMS) << XATTR("sid", jbt->sid);
if (bDirect) {
ptrA localAddr;
@@ -196,7 +200,7 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt)
nlb.pfnNewConnectionV2 = JabberByteSendConnection;
nlb.pExtra = this;
nlb.wPort = 0; // Use user-specified incoming port ranges, if available
-
+
jbt->hConn = Netlib_BindPort(m_hNetlibUser, &nlb);
if (jbt->hConn == nullptr) {
debugLogA("Cannot allocate port for bytestream_send thread, thread ended.");
@@ -211,24 +215,24 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt)
localAddr = Netlib_AddressToString(&sin);
}
- mir_snwprintf(szPort, L"%d", nlb.wPort);
+ itoa(nlb.wPort, szPort, 8);
JABBER_LIST_ITEM *item = ListAdd(LIST_BYTE, szPort);
item->jbt = jbt;
hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
jbt->hEvent = hEvent;
jbt->hSendEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
- query << XCHILD(L"streamhost") << XATTR(L"jid", m_ThreadInfo->fullJID) << XATTR(L"host", _A2T(localAddr)) << XATTRI(L"port", nlb.wPort);
+ query << XCHILD("streamhost") << XATTR("jid", m_ThreadInfo->fullJID) << XATTR("host", localAddr) << XATTRI("port", nlb.wPort);
NETLIBIPLIST *ihaddr = Netlib_GetMyIp(true);
- for (unsigned i=0; i < ihaddr->cbNum; i++)
+ for (unsigned i = 0; i < ihaddr->cbNum; i++)
if (mir_strcmp(localAddr, ihaddr->szIp[i]))
- query << XCHILD(L"streamhost") << XATTR(L"jid", m_ThreadInfo->fullJID) << XATTR(L"host", _A2T(ihaddr->szIp[i])) << XATTRI(L"port", nlb.wPort);
+ query << XCHILD("streamhost") << XATTR("jid", m_ThreadInfo->fullJID) << XATTR("host", ihaddr->szIp[i]) << XATTRI("port", nlb.wPort);
mir_free(ihaddr);
}
if (jbt->bProxyDiscovered)
- query << XCHILD(L"streamhost") << XATTR(L"jid", jbt->szProxyJid) << XATTR(L"host", jbt->szProxyHost) << XATTR(L"port", jbt->szProxyPort);
+ query << XCHILD("streamhost") << XATTR("jid", jbt->szProxyJid) << XATTR("host", jbt->szProxyHost) << XATTR("port", jbt->szProxyPort);
jbt->hProxyEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
jbt->szStreamhostUsed = nullptr;
@@ -252,7 +256,7 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt)
jbt->hConn = nullptr;
ListRemove(LIST_BYTE, szPort);
}
- (this->*jbt->pfnFinal)((jbt->state==JBT_DONE)?TRUE:FALSE, jbt->ft);
+ (this->*jbt->pfnFinal)((jbt->state == JBT_DONE) ? TRUE : FALSE, jbt->ft);
jbt->ft = nullptr;
// stupid fix: wait for listening thread exit
Sleep(100);
@@ -260,7 +264,7 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt)
return;
}
- if (jbt->bProxyDiscovered && !mir_wstrcmp(jbt->szProxyJid, jbt->szStreamhostUsed)) {
+ if (jbt->bProxyDiscovered && !mir_strcmp(jbt->szProxyJid, jbt->szStreamhostUsed)) {
// jabber proxy used
if (bDirect) {
SetEvent(jbt->hSendEvent);
@@ -294,21 +298,21 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt)
debugLogA("Thread ended: type=bytestream_send");
}
-void CJabberProto::ByteInitiateResult(HXML iqNode, CJabberIqInfo *pInfo)
+void CJabberProto::ByteInitiateResult(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
JABBER_BYTE_TRANSFER *jbt = (JABBER_BYTE_TRANSFER *)pInfo->GetUserData();
if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
- HXML queryNode = XmlGetChild(iqNode , "query");
+ auto *queryNode = XmlGetChildByTag(iqNode, "query", "xmlns", JABBER_FEAT_BYTESTREAMS);
if (queryNode) {
- const wchar_t *queryXmlns = XmlGetAttrValue(queryNode, L"xmlns");
- if (queryXmlns && !mir_wstrcmp(queryXmlns, JABBER_FEAT_BYTESTREAMS)) {
- HXML streamHostNode = XmlGetChild(queryNode , "streamhost-used");
- if (streamHostNode) {
- const wchar_t *streamJid = XmlGetAttrValue(streamHostNode, L"jid");
- if (streamJid)
- jbt->szStreamhostUsed = mir_wstrdup(streamJid);
- } } } }
+ auto *streamHostNode = queryNode->FirstChildElement("streamhost-used");
+ if (streamHostNode) {
+ const char *streamJid = streamHostNode->Attribute("jid");
+ if (streamJid)
+ jbt->szStreamhostUsed = mir_strdup(streamJid);
+ }
+ }
+ }
if (jbt->hProxyEvent)
SetEvent(jbt->hProxyEvent);
@@ -329,9 +333,9 @@ int CJabberProto::ByteSendParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt, ch
// send:
// 00-00 ver (0x05)
// 01-01 select method (0=no auth required)
- if (datalen>=2 && buffer[0]==5 && buffer[1]+2==datalen) {
+ if (datalen >= 2 && buffer[0] == 5 && buffer[1] + 2 == datalen) {
nMethods = buffer[1];
- for (i=0; i<nMethods && buffer[2+i]!=0; i++);
+ for (i = 0; i < nMethods && buffer[2 + i] != 0; i++);
if (i < nMethods) {
data[1] = 0;
jbt->state = JBT_CONNECT;
@@ -361,11 +365,11 @@ int CJabberProto::ByteSendParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt, ch
// 03-03 address type (1=IPv4 address)
// 04-07 bnd.addr server bound address
// 08-09 bnd.port server bound port
- if (datalen == 47 && *((DWORD*)buffer)==0x03000105 && buffer[4]==40 && *((WORD*)(buffer+45))==0) {
+ if (datalen == 47 && *((DWORD*)buffer) == 0x03000105 && buffer[4] == 40 && *((WORD*)(buffer + 45)) == 0) {
wchar_t text[256];
- wchar_t *szInitiatorJid = JabberPrepareJid(jbt->srcJID);
- wchar_t *szTargetJid = JabberPrepareJid(jbt->dstJID);
+ char *szInitiatorJid = JabberPrepareJid(jbt->srcJID);
+ char *szTargetJid = JabberPrepareJid(jbt->dstJID);
mir_snwprintf(text, L"%s%s%s", jbt->sid, szInitiatorJid, szTargetJid);
mir_free(szInitiatorJid);
mir_free(szTargetJid);
@@ -404,18 +408,18 @@ int CJabberProto::ByteSendParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt, ch
///////////////// Bytestream receiving /////////////////////////
-void CJabberProto::IqResultStreamActivate(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::IqResultStreamActivate(const TiXmlElement *iqNode, CJabberIqInfo*)
{
int id = JabberGetPacketID(iqNode);
- wchar_t listJid[JABBER_MAX_JID_LEN];
- mir_snwprintf(listJid, L"ftproxy_%d", id);
+ char listJid[JABBER_MAX_JID_LEN];
+ mir_snprintf(listJid, "ftproxy_%d", id);
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_FTIQID, listJid);
if (item == nullptr)
return;
- if (!mir_wstrcmp(XmlGetAttrValue(iqNode, L"type"), L"result"))
+ if (!mir_strcmp(iqNode->Attribute("type"), "result"))
item->jbt->bStreamActivated = TRUE;
if (item->jbt->hProxyEvent)
@@ -425,32 +429,27 @@ void CJabberProto::IqResultStreamActivate(HXML iqNode, CJabberIqInfo*)
void CJabberProto::ByteSendViaProxy(JABBER_BYTE_TRANSFER *jbt)
{
- wchar_t *szHost, *szPort;
- WORD port;
- char data[3];
- char* buffer;
- int datalen, bytesParsed, recvResult;
- BOOL validStreamhost;
-
if (jbt == nullptr) return;
- if ((buffer=(char*)mir_alloc(JABBER_NETWORK_BUFFER_SIZE)) == nullptr) {
- m_ThreadInfo->send( XmlNodeIq(L"error", jbt->iqId, jbt->srcJID)
- << XCHILD(L"error") << XATTRI(L"code", 406) << XATTR(L"type", L"auth")
- << XCHILDNS(L"not-acceptable", L"urn:ietf:params:xml:ns:xmpp-stanzas"));
+
+ char* buffer;
+ if ((buffer = (char*)mir_alloc(JABBER_NETWORK_BUFFER_SIZE)) == nullptr) {
+ m_ThreadInfo->send(XmlNodeIq("error", jbt->iqId, jbt->srcJID)
+ << XCHILD("error") << XATTRI("code", 406) << XATTR("type", "auth")
+ << XCHILDNS("not-acceptable", "urn:ietf:params:xml:ns:xmpp-stanzas"));
return;
}
jbt->state = JBT_INIT;
- validStreamhost = FALSE;
- szPort = jbt->szProxyPort;
- szHost = jbt->szProxyHost;
+ BOOL validStreamhost = FALSE;
+ char *szPort = jbt->szProxyPort;
+ char *szHost = jbt->szProxyHost;
- port = (WORD)_wtoi(szPort);
- replaceStrW(jbt->streamhostJID, jbt->szProxyJid);
+ WORD port = (WORD)atoi(szPort);
+ replaceStr(jbt->streamhostJID, jbt->szProxyJid);
NETLIBOPENCONNECTION nloc = { 0 };
nloc.cbSize = sizeof(nloc);
- nloc.szHost = mir_u2a(szHost);
+ nloc.szHost = szHost;
nloc.wPort = port;
HNETLIBCONN hConn = Netlib_OpenConnection(m_hNetlibUser, &nloc);
mir_free((void*)nloc.szHost);
@@ -458,22 +457,20 @@ void CJabberProto::ByteSendViaProxy(JABBER_BYTE_TRANSFER *jbt)
if (hConn != nullptr) {
jbt->hConn = hConn;
- data[0] = 5;
- data[1] = 1;
- data[2] = 0;
+ char data[3] = { 5, 1, 0 };
Netlib_Send(hConn, data, 3, 0);
jbt->state = JBT_INIT;
- datalen = 0;
- while (jbt->state!=JBT_DONE && jbt->state!=JBT_ERROR && jbt->state!=JBT_SOCKSERR) {
- recvResult = Netlib_Recv(hConn, buffer+datalen, JABBER_NETWORK_BUFFER_SIZE-datalen, 0);
+ int datalen = 0;
+ while (jbt->state != JBT_DONE && jbt->state != JBT_ERROR && jbt->state != JBT_SOCKSERR) {
+ int recvResult = Netlib_Recv(hConn, buffer + datalen, JABBER_NETWORK_BUFFER_SIZE - datalen, 0);
if (recvResult <= 0)
break;
datalen += recvResult;
- bytesParsed = ByteSendProxyParse(hConn, jbt, buffer, datalen);
+ int bytesParsed = ByteSendProxyParse(hConn, jbt, buffer, datalen);
if (bytesParsed < datalen)
- memmove(buffer, buffer+bytesParsed, datalen-bytesParsed);
+ memmove(buffer, buffer + bytesParsed, datalen - bytesParsed);
datalen -= bytesParsed;
if (jbt->state == JBT_DONE) validStreamhost = TRUE;
}
@@ -483,9 +480,9 @@ void CJabberProto::ByteSendViaProxy(JABBER_BYTE_TRANSFER *jbt)
(this->*jbt->pfnFinal)((jbt->state == JBT_DONE) ? TRUE : FALSE, jbt->ft);
jbt->ft = nullptr;
if (!validStreamhost)
- m_ThreadInfo->send( XmlNodeIq(L"error", jbt->iqId, jbt->srcJID)
- << XCHILD(L"error") << XATTRI(L"code", 404) << XATTR(L"type", L"cancel")
- << XCHILDNS(L"item-not-found", L"urn:ietf:params:xml:ns:xmpp-stanzas"));
+ m_ThreadInfo->send(XmlNodeIq("error", jbt->iqId, jbt->srcJID)
+ << XCHILD("error") << XATTRI("code", 404) << XATTR("type", "cancel")
+ << XCHILDNS("item-not-found", "urn:ietf:params:xml:ns:xmpp-stanzas"));
}
int CJabberProto::ByteSendProxyParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen)
@@ -510,15 +507,8 @@ int CJabberProto::ByteSendProxyParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jb
*((DWORD*)data) = 0x03000105;
data[4] = 40;
- wchar_t text[256];
-
- wchar_t *szInitiatorJid = JabberPrepareJid(jbt->srcJID);
- wchar_t *szTargetJid = JabberPrepareJid(jbt->dstJID);
- mir_snwprintf(text, L"%s%s%s", jbt->sid, szInitiatorJid, szTargetJid);
- mir_free(szInitiatorJid);
- mir_free(szTargetJid);
-
- T2Utf szAuthString(text);
+ char szAuthString[256];
+ mir_snprintf(szAuthString, "%s%s%s", jbt->sid, ptrA(JabberPrepareJid(jbt->srcJID)), ptrA(JabberPrepareJid(jbt->dstJID)));
debugLogA("Auth: '%s'", szAuthString);
JabberShaStrBuf buf;
@@ -556,15 +546,15 @@ int CJabberProto::ByteSendProxyParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jb
int iqId = SerialNext();
- wchar_t listJid[256];
- mir_snwprintf(listJid, L"ftproxy_%d", iqId);
+ char listJid[256];
+ mir_snprintf(listJid, "ftproxy_%d", iqId);
JABBER_LIST_ITEM *item = ListAdd(LIST_FTIQID, listJid);
item->jbt = jbt;
m_ThreadInfo->send(
XmlNodeIq(AddIQ(&CJabberProto::IqResultStreamActivate, JABBER_IQ_TYPE_SET, jbt->streamhostJID, 0, iqId))
- << XQUERY(JABBER_FEAT_BYTESTREAMS) << XATTR(L"sid", jbt->sid) << XCHILD(L"activate", jbt->dstJID));
+ << XQUERY(JABBER_FEAT_BYTESTREAMS) << XATTR("sid", jbt->sid) << XCHILD("activate", jbt->dstJID));
WaitForSingleObject(jbt->hProxyEvent, INFINITE);
@@ -587,9 +577,7 @@ int CJabberProto::ByteSendProxyParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jb
void __cdecl CJabberProto::ByteReceiveThread(JABBER_BYTE_TRANSFER *jbt)
{
- HXML iqNode, queryNode = nullptr, n;
- const wchar_t *sid = nullptr, *from = nullptr, *to = nullptr, *szId = nullptr, *szHost, *szPort, *str;
- int i;
+ TiXmlElement *iqNode, *queryNode = nullptr;
WORD port;
char data[3];
char* buffer;
@@ -601,35 +589,36 @@ void __cdecl CJabberProto::ByteReceiveThread(JABBER_BYTE_TRANSFER *jbt)
jbt->state = JBT_INIT;
+ const char *sid = nullptr, *from = nullptr, *to = nullptr, *szId = nullptr;
if (iqNode = jbt->iqNode) {
- from = XmlGetAttrValue(iqNode, L"from");
- to = XmlGetAttrValue(iqNode, L"to");
- szId = XmlGetAttrValue(iqNode, L"id");
+ from = iqNode->Attribute("from");
+ to = iqNode->Attribute("to");
+ szId = iqNode->Attribute("id");
- queryNode = XmlGetChild(iqNode, "query");
+ queryNode = iqNode->FirstChildElement("query");
if (queryNode)
- sid = XmlGetAttrValue(queryNode, L"sid");
+ sid = queryNode->Attribute("sid");
}
- if (szId && from && to && sid && (n = XmlGetChild(queryNode, "streamhost")) != nullptr) {
- jbt->iqId = mir_wstrdup(szId);
- jbt->srcJID = mir_wstrdup(from);
- jbt->dstJID = mir_wstrdup(to);
- jbt->sid = mir_wstrdup(sid);
+ if (szId && from && to && sid) {
+ jbt->iqId = mir_strdup(szId);
+ jbt->srcJID = mir_strdup(from);
+ jbt->dstJID = mir_strdup(to);
+ jbt->sid = mir_strdup(sid);
if ((buffer = (char*)mir_alloc(JABBER_NETWORK_BUFFER_SIZE))) {
- for (i = 1; (n = XmlGetNthChild(queryNode, L"streamhost", i)) != nullptr; i++) {
- if ((szHost = XmlGetAttrValue(n, L"host")) != nullptr &&
- (szPort = XmlGetAttrValue(n, L"port")) != nullptr &&
- (str = XmlGetAttrValue(n, L"jid")) != nullptr) {
-
- port = (WORD)_wtoi(szPort);
- replaceStrW(jbt->streamhostJID, str);
+ for (auto *n : TiXmlFilter(queryNode, "streamhost")) {
+ const char *str = n->Attribute("jid");
+ const char *szHost = n->Attribute("host");
+ const char *szPort = n->Attribute("port");
+ if (str != nullptr && szHost != nullptr && szPort != nullptr) {
+ port = (WORD)atoi(szPort);
+ replaceStr(jbt->streamhostJID, str);
debugLogW(L"bytestream_recv connecting to %s:%d", szHost, port);
NETLIBOPENCONNECTION nloc = { 0 };
nloc.cbSize = sizeof(nloc);
- nloc.szHost = mir_u2a(szHost);
+ nloc.szHost = mir_strdup(szHost);
nloc.wPort = port;
HNETLIBCONN hConn = Netlib_OpenConnection(m_hNetlibUser, &nloc);
mir_free((void*)nloc.szHost);
@@ -674,9 +663,9 @@ void __cdecl CJabberProto::ByteReceiveThread(JABBER_BYTE_TRANSFER *jbt)
if (!validStreamhost && szId && from) {
debugLogA("bytestream_recv_connection session not completed");
- m_ThreadInfo->send(XmlNodeIq(L"error", szId, from)
- << XCHILD(L"error") << XATTRI(L"code", 404) << XATTR(L"type", L"cancel")
- << XCHILDNS(L"item-not-found", L"urn:ietf:params:xml:ns:xmpp-stanzas"));
+ m_ThreadInfo->send(XmlNodeIq("error", szId, from)
+ << XCHILD("error") << XATTRI("code", 404) << XATTR("type", "cancel")
+ << XCHILDNS("item-not-found", "urn:ietf:params:xml:ns:xmpp-stanzas"));
}
delete jbt;
@@ -705,15 +694,8 @@ int CJabberProto::ByteReceiveParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt,
*((DWORD*)data) = 0x03000105;
data[4] = 40;
- wchar_t text[JABBER_MAX_JID_LEN * 2];
- {
- ptrW szInitiatorJid(JabberPrepareJid(jbt->srcJID));
- ptrW szTargetJid(JabberPrepareJid(jbt->dstJID));
- mir_snwprintf(text, L"%s%s%s", jbt->sid, szInitiatorJid, szTargetJid);
- }
-
- T2Utf szAuthString(text);
- debugLogA("Auth: '%s'", szAuthString);
+ CMStringA szAuthString(FORMAT, "%s%s%s", jbt->sid, ptrA(JabberPrepareJid(jbt->srcJID)).get(), ptrA(JabberPrepareJid(jbt->dstJID)).get());
+ debugLogA("Auth: '%s'", szAuthString.c_str());
JabberShaStrBuf buf;
strncpy_s((char*)(data + 5), 40 + 1, JabberSha1(szAuthString, buf), _TRUNCATE);
@@ -746,8 +728,8 @@ int CJabberProto::ByteReceiveParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt,
jbt->state = JBT_RECVING;
m_ThreadInfo->send(
- XmlNodeIq(L"result", jbt->iqId, jbt->srcJID) << XQUERY(JABBER_FEAT_BYTESTREAMS)
- << XCHILD(L"streamhost-used") << XATTR(L"jid", jbt->streamhostJID));
+ XmlNodeIq("result", jbt->iqId, jbt->srcJID) << XQUERY(JABBER_FEAT_BYTESTREAMS)
+ << XCHILD("streamhost-used") << XATTR("jid", jbt->streamhostJID));
}
else jbt->state = JBT_SOCKSERR;
break;
diff --git a/protocols/JabberG/src/jabber_byte.h b/protocols/JabberG/src/jabber_byte.h
index 63784db5c6..8eef2a40d7 100644
--- a/protocols/JabberG/src/jabber_byte.h
+++ b/protocols/JabberG/src/jabber_byte.h
@@ -31,19 +31,20 @@ typedef enum { JBT_INIT, JBT_AUTH, JBT_CONNECT, JBT_SOCKSERR, JBT_SENDING, JBT_R
struct CJabberProto;
struct filetransfer;
-struct JABBER_BYTE_TRANSFER
+struct JABBER_BYTE_TRANSFER : public MZeroedObject
{
~JABBER_BYTE_TRANSFER();
- wchar_t *sid;
- wchar_t *srcJID;
- wchar_t *dstJID;
- wchar_t *streamhostJID;
- wchar_t *iqId;
+ char *sid;
+ char *srcJID;
+ char *dstJID;
+ char *streamhostJID;
+ char *iqId;
JABBER_BYTE_STATE state;
HANDLE hConn;
HANDLE hEvent;
- HXML iqNode;
+ TiXmlDocument doc;
+ TiXmlElement *iqNode;
BOOL (CJabberProto::*pfnSend)(HNETLIBCONN hConn, filetransfer *ft);
int (CJabberProto::*pfnRecv)(HNETLIBCONN hConn, filetransfer *ft, char* buffer, int datalen);
void (CJabberProto::*pfnFinal)(BOOL success, filetransfer *ft);
@@ -52,10 +53,10 @@ struct JABBER_BYTE_TRANSFER
// XEP-0065 proxy support
BOOL bProxyDiscovered;
HANDLE hProxyEvent;
- wchar_t *szProxyHost;
- wchar_t *szProxyPort;
- wchar_t *szProxyJid;
- wchar_t *szStreamhostUsed;
+ char *szProxyHost;
+ char *szProxyPort;
+ char *szProxyJid;
+ char *szStreamhostUsed;
BOOL bStreamActivated;
HANDLE hSendEvent;
};
diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp
index c6b783166c..2d5ca5b347 100755
--- a/protocols/JabberG/src/jabber_caps.cpp
+++ b/protocols/JabberG/src/jabber_caps.cpp
@@ -30,54 +30,54 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
const JabberFeatCapPair g_JabberFeatCapPairs[] =
{
- { JABBER_FEAT_DISCO_INFO, JABBER_CAPS_DISCO_INFO, LPGENW("Supports Service Discovery info") },
- { JABBER_FEAT_DISCO_ITEMS, JABBER_CAPS_DISCO_ITEMS, LPGENW("Supports Service Discovery items list") },
- { JABBER_FEAT_ENTITY_CAPS, JABBER_CAPS_ENTITY_CAPS, LPGENW("Can inform about its Jabber capabilities") },
- { JABBER_FEAT_SI, JABBER_CAPS_SI, LPGENW("Supports stream initiation (e.g., for filetransfers)") },
- { JABBER_FEAT_SI_FT, JABBER_CAPS_SI_FT, LPGENW("Supports stream initiation for file transfers") },
- { JABBER_FEAT_BYTESTREAMS, JABBER_CAPS_BYTESTREAMS, LPGENW("Supports file transfers via SOCKS5 Bytestreams") },
- { JABBER_FEAT_IBB, JABBER_CAPS_IBB, LPGENW("Supports file transfers via In-Band Bytestreams") },
- { JABBER_FEAT_OOB, JABBER_CAPS_OOB, LPGENW("Supports file transfers via Out-of-Band Bytestreams") },
- { JABBER_FEAT_OOB2, JABBER_CAPS_OOB, LPGENW("Supports file transfers via Out-of-Band Bytestreams") },
- { JABBER_FEAT_COMMANDS, JABBER_CAPS_COMMANDS, LPGENW("Supports execution of Ad-Hoc commands") },
- { JABBER_FEAT_REGISTER, JABBER_CAPS_REGISTER, LPGENW("Supports in-band registration") },
- { JABBER_FEAT_MUC, JABBER_CAPS_MUC, LPGENW("Supports multi-user chat") },
- { JABBER_FEAT_CHATSTATES, JABBER_CAPS_CHATSTATES, LPGENW("Can report chat state in a chat session") },
- { JABBER_FEAT_LAST_ACTIVITY, JABBER_CAPS_LAST_ACTIVITY, LPGENW("Can report information about the last activity of the user") },
- { JABBER_FEAT_VERSION, JABBER_CAPS_VERSION, LPGENW("Can report own version information") },
- { JABBER_FEAT_ENTITY_TIME, JABBER_CAPS_ENTITY_TIME, LPGENW("Can report local time of the user") },
- { JABBER_FEAT_PING, JABBER_CAPS_PING, LPGENW("Can send and receive ping requests") },
- { JABBER_FEAT_DATA_FORMS, JABBER_CAPS_DATA_FORMS, LPGENW("Supports data forms") },
- { JABBER_FEAT_MESSAGE_EVENTS, JABBER_CAPS_MESSAGE_EVENTS, LPGENW("Can request and respond to events relating to the delivery, display, and composition of messages") },
- { JABBER_FEAT_VCARD_TEMP, JABBER_CAPS_VCARD_TEMP, LPGENW("Supports vCard") },
- { JABBER_FEAT_AVATAR, JABBER_CAPS_AVATAR, LPGENW("Supports iq-based avatars") },
- { JABBER_FEAT_XHTML, JABBER_CAPS_XHTML, LPGENW("Supports XHTML formatting of chat messages") },
- { JABBER_FEAT_AGENTS, JABBER_CAPS_AGENTS, LPGENW("Supports Jabber Browsing") },
- { JABBER_FEAT_BROWSE, JABBER_CAPS_BROWSE, LPGENW("Supports Jabber Browsing") },
- { JABBER_FEAT_FEATURE_NEG, JABBER_CAPS_FEATURE_NEG, LPGENW("Can negotiate options for specific features") },
- { JABBER_FEAT_AMP, JABBER_CAPS_AMP, LPGENW("Can request advanced processing of message stanzas") },
- { JABBER_FEAT_USER_MOOD, JABBER_CAPS_USER_MOOD, LPGENW("Can report information about user moods") },
- { JABBER_FEAT_USER_MOOD_NOTIFY, JABBER_CAPS_USER_MOOD_NOTIFY, LPGENW("Receives information about user moods") },
- { JABBER_FEAT_PUBSUB, JABBER_CAPS_PUBSUB, LPGENW("Supports generic publish-subscribe functionality") },
- { JABBER_FEAT_SECUREIM, JABBER_CAPS_SECUREIM, LPGENW("Supports SecureIM plugin for Miranda NG") },
- { JABBER_FEAT_MIROTR, JABBER_CAPS_MIROTR, LPGENW("Supports OTR (Off-the-Record Messaging)") },
- { JABBER_FEAT_NEWGPG, JABBER_CAPS_NEWGPG, LPGENW("Supports New_GPG plugin for Miranda NG") },
- { JABBER_FEAT_PRIVACY_LISTS, JABBER_CAPS_PRIVACY_LISTS, LPGENW("Blocks packets from other users/group chats using Privacy lists") },
- { JABBER_FEAT_MESSAGE_RECEIPTS, JABBER_CAPS_MESSAGE_RECEIPTS, LPGENW("Supports Message Receipts") },
- { JABBER_FEAT_USER_TUNE, JABBER_CAPS_USER_TUNE, LPGENW("Can report information about the music to which a user is listening") },
- { JABBER_FEAT_USER_TUNE_NOTIFY, JABBER_CAPS_USER_TUNE_NOTIFY, LPGENW("Receives information about the music to which a user is listening") },
- { JABBER_FEAT_PRIVATE_STORAGE, JABBER_CAPS_PRIVATE_STORAGE, LPGENW("Supports private XML Storage (for bookmarks and other)") },
- { JABBER_FEAT_ATTENTION, JABBER_CAPS_ATTENTION, LPGENW("Supports attention requests ('nudge')") },
- { JABBER_FEAT_ARCHIVE_AUTO, JABBER_CAPS_ARCHIVE_AUTO, LPGENW("Supports chat history retrieving") },
- { JABBER_FEAT_ARCHIVE_MANAGE, JABBER_CAPS_ARCHIVE_MANAGE, LPGENW("Supports chat history management") },
- { JABBER_FEAT_USER_ACTIVITY, JABBER_CAPS_USER_ACTIVITY, LPGENW("Can report information about user activity") },
- { JABBER_FEAT_USER_ACTIVITY_NOTIFY, JABBER_CAPS_USER_ACTIVITY_NOTIFY, LPGENW("Receives information about user activity") },
- { JABBER_FEAT_MIRANDA_NOTES, JABBER_CAPS_MIRANDA_NOTES, LPGENW("Supports Miranda NG notes extension") },
- { JABBER_FEAT_JINGLE, JABBER_CAPS_JINGLE, LPGENW("Supports Jingle") },
- { JABBER_FEAT_ROSTER_EXCHANGE, JABBER_CAPS_ROSTER_EXCHANGE, LPGENW("Supports Roster Exchange") },
- { JABBER_FEAT_DIRECT_MUC_INVITE, JABBER_CAPS_DIRECT_MUC_INVITE, LPGENW("Supports direct chat invitations (XEP-0249)") },
- { JABBER_FEAT_OMEMO_DEVICELIST_NOTIFY, JABBER_CAPS_OMEMO_DEVICELIST_NOTIFY, LPGENW("Receives information about OMEMO devices") },
- { JABBER_FEAT_CARBONS, JABBER_CAPS_CARBONS, LPGENW("Supports message carbons (XEP-0280)")},
+ { JABBER_FEAT_DISCO_INFO, JABBER_CAPS_DISCO_INFO, LPGEN("Supports Service Discovery info") },
+ { JABBER_FEAT_DISCO_ITEMS, JABBER_CAPS_DISCO_ITEMS, LPGEN("Supports Service Discovery items list") },
+ { JABBER_FEAT_ENTITY_CAPS, JABBER_CAPS_ENTITY_CAPS, LPGEN("Can inform about its Jabber capabilities") },
+ { JABBER_FEAT_SI, JABBER_CAPS_SI, LPGEN("Supports stream initiation (e.g., for filetransfers)") },
+ { JABBER_FEAT_SI_FT, JABBER_CAPS_SI_FT, LPGEN("Supports stream initiation for file transfers") },
+ { JABBER_FEAT_BYTESTREAMS, JABBER_CAPS_BYTESTREAMS, LPGEN("Supports file transfers via SOCKS5 Bytestreams") },
+ { JABBER_FEAT_IBB, JABBER_CAPS_IBB, LPGEN("Supports file transfers via In-Band Bytestreams") },
+ { JABBER_FEAT_OOB, JABBER_CAPS_OOB, LPGEN("Supports file transfers via Out-of-Band Bytestreams") },
+ { JABBER_FEAT_OOB2, JABBER_CAPS_OOB, LPGEN("Supports file transfers via Out-of-Band Bytestreams") },
+ { JABBER_FEAT_COMMANDS, JABBER_CAPS_COMMANDS, LPGEN("Supports execution of Ad-Hoc commands") },
+ { JABBER_FEAT_REGISTER, JABBER_CAPS_REGISTER, LPGEN("Supports in-band registration") },
+ { JABBER_FEAT_MUC, JABBER_CAPS_MUC, LPGEN("Supports multi-user chat") },
+ { JABBER_FEAT_CHATSTATES, JABBER_CAPS_CHATSTATES, LPGEN("Can report chat state in a chat session") },
+ { JABBER_FEAT_LAST_ACTIVITY, JABBER_CAPS_LAST_ACTIVITY, LPGEN("Can report information about the last activity of the user") },
+ { JABBER_FEAT_VERSION, JABBER_CAPS_VERSION, LPGEN("Can report own version information") },
+ { JABBER_FEAT_ENTITY_TIME, JABBER_CAPS_ENTITY_TIME, LPGEN("Can report local time of the user") },
+ { JABBER_FEAT_PING, JABBER_CAPS_PING, LPGEN("Can send and receive ping requests") },
+ { JABBER_FEAT_DATA_FORMS, JABBER_CAPS_DATA_FORMS, LPGEN("Supports data forms") },
+ { JABBER_FEAT_MESSAGE_EVENTS, JABBER_CAPS_MESSAGE_EVENTS, LPGEN("Can request and respond to events relating to the delivery, display, and composition of messages") },
+ { JABBER_FEAT_VCARD_TEMP, JABBER_CAPS_VCARD_TEMP, LPGEN("Supports vCard") },
+ { JABBER_FEAT_AVATAR, JABBER_CAPS_AVATAR, LPGEN("Supports iq-based avatars") },
+ { JABBER_FEAT_XHTML, JABBER_CAPS_XHTML, LPGEN("Supports XHTML formatting of chat messages") },
+ { JABBER_FEAT_AGENTS, JABBER_CAPS_AGENTS, LPGEN("Supports Jabber Browsing") },
+ { JABBER_FEAT_BROWSE, JABBER_CAPS_BROWSE, LPGEN("Supports Jabber Browsing") },
+ { JABBER_FEAT_FEATURE_NEG, JABBER_CAPS_FEATURE_NEG, LPGEN("Can negotiate options for specific features") },
+ { JABBER_FEAT_AMP, JABBER_CAPS_AMP, LPGEN("Can request advanced processing of message stanzas") },
+ { JABBER_FEAT_USER_MOOD, JABBER_CAPS_USER_MOOD, LPGEN("Can report information about user moods") },
+ { JABBER_FEAT_USER_MOOD_NOTIFY, JABBER_CAPS_USER_MOOD_NOTIFY, LPGEN("Receives information about user moods") },
+ { JABBER_FEAT_PUBSUB, JABBER_CAPS_PUBSUB, LPGEN("Supports generic publish-subscribe functionality") },
+ { JABBER_FEAT_SECUREIM, JABBER_CAPS_SECUREIM, LPGEN("Supports SecureIM plugin for Miranda NG") },
+ { JABBER_FEAT_MIROTR, JABBER_CAPS_MIROTR, LPGEN("Supports OTR (Off-the-Record Messaging)") },
+ { JABBER_FEAT_NEWGPG, JABBER_CAPS_NEWGPG, LPGEN("Supports New_GPG plugin for Miranda NG") },
+ { JABBER_FEAT_PRIVACY_LISTS, JABBER_CAPS_PRIVACY_LISTS, LPGEN("Blocks packets from other users/group chats using Privacy lists") },
+ { JABBER_FEAT_MESSAGE_RECEIPTS, JABBER_CAPS_MESSAGE_RECEIPTS, LPGEN("Supports Message Receipts") },
+ { JABBER_FEAT_USER_TUNE, JABBER_CAPS_USER_TUNE, LPGEN("Can report information about the music to which a user is listening") },
+ { JABBER_FEAT_USER_TUNE_NOTIFY, JABBER_CAPS_USER_TUNE_NOTIFY, LPGEN("Receives information about the music to which a user is listening") },
+ { JABBER_FEAT_PRIVATE_STORAGE, JABBER_CAPS_PRIVATE_STORAGE, LPGEN("Supports private XML Storage (for bookmarks and other)") },
+ { JABBER_FEAT_ATTENTION, JABBER_CAPS_ATTENTION, LPGEN("Supports attention requests ('nudge')") },
+ { JABBER_FEAT_ARCHIVE_AUTO, JABBER_CAPS_ARCHIVE_AUTO, LPGEN("Supports chat history retrieving") },
+ { JABBER_FEAT_ARCHIVE_MANAGE, JABBER_CAPS_ARCHIVE_MANAGE, LPGEN("Supports chat history management") },
+ { JABBER_FEAT_USER_ACTIVITY, JABBER_CAPS_USER_ACTIVITY, LPGEN("Can report information about user activity") },
+ { JABBER_FEAT_USER_ACTIVITY_NOTIFY, JABBER_CAPS_USER_ACTIVITY_NOTIFY, LPGEN("Receives information about user activity") },
+ { JABBER_FEAT_MIRANDA_NOTES, JABBER_CAPS_MIRANDA_NOTES, LPGEN("Supports Miranda NG notes extension") },
+ { JABBER_FEAT_JINGLE, JABBER_CAPS_JINGLE, LPGEN("Supports Jingle") },
+ { JABBER_FEAT_ROSTER_EXCHANGE, JABBER_CAPS_ROSTER_EXCHANGE, LPGEN("Supports Roster Exchange") },
+ { JABBER_FEAT_DIRECT_MUC_INVITE, JABBER_CAPS_DIRECT_MUC_INVITE, LPGEN("Supports direct chat invitations (XEP-0249)") },
+ { JABBER_FEAT_OMEMO_DEVICELIST_NOTIFY, JABBER_CAPS_OMEMO_DEVICELIST_NOTIFY, LPGEN("Receives information about OMEMO devices") },
+ { JABBER_FEAT_CARBONS, JABBER_CAPS_CARBONS, LPGEN("Supports message carbons (XEP-0280)")},
};
const int g_cJabberFeatCapPairs = _countof(g_JabberFeatCapPairs);
@@ -116,31 +116,30 @@ void CJabberProto::AddDefaultCaps()
wchar_t szOsBuffer[256]; szOsBuffer[0] = 0;
GetOSDisplayString(szOsBuffer, _countof(szOsBuffer));
- CJabberClientPartialCaps *pCaps = m_clientCapsManager.SetOwnCaps(JABBER_CAPS_MIRANDA_NODE, _T(__VERSION_STRING_DOTS), myCaps);
- pCaps->m_szOs = mir_wstrdup(L"Microsoft Windows");
- pCaps->m_szOsVer = mir_wstrdup(szOsBuffer);
- pCaps->m_szSoft = mir_wstrdup(L"Miranda NG Jabber Protocol");
- pCaps->m_szSoftMir = mir_wstrdup(szCoreVersion);
+ CJabberClientPartialCaps *pCaps = m_clientCapsManager.SetOwnCaps(JABBER_CAPS_MIRANDA_NODE, __VERSION_STRING_DOTS, myCaps);
+ pCaps->m_szOs = mir_strdup("Microsoft Windows");
+ pCaps->m_szOsVer = mir_utf8encodeW(szOsBuffer);
+ pCaps->m_szSoft = mir_strdup("Miranda NG Jabber Protocol");
+ pCaps->m_szSoftMir = mir_strdup(szCoreVersion);
}
-void CJabberProto::OnIqResultCapsDiscoInfo(HXML, CJabberIqInfo *pInfo)
+void CJabberProto::OnIqResultCapsDiscoInfo(const TiXmlElement*, CJabberIqInfo *pInfo)
{
pResourceStatus r(ResourceInfoFromJID(pInfo->GetFrom()));
if (r == nullptr)
return;
- HXML query = pInfo->GetChildNode();
+ auto *query = pInfo->GetChildNode();
if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT && query) {
JabberCapsBits jcbCaps = 0;
- HXML feature;
- for (int i = 1; (feature = XmlGetNthChild(query, L"feature", i)) != nullptr; i++) {
- const wchar_t *featureName = XmlGetAttrValue(feature, L"var");
+ for (auto *feature : TiXmlFilter(query, "feature")) {
+ const char *featureName = feature->Attribute("var");
if (!featureName)
continue;
for (auto &it : g_JabberFeatCapPairs) {
- if (!mir_wstrcmp(it.szFeature, featureName)) {
+ if (!mir_strcmp(it.szFeature, featureName)) {
jcbCaps |= it.jcbCap;
break;
}
@@ -155,28 +154,26 @@ void CJabberProto::OnIqResultCapsDiscoInfo(HXML, CJabberIqInfo *pInfo)
return;
}
- HXML identity;
- for (int i = 1; (identity = XmlGetNthChild(query, L"identity", i)) != nullptr; i++) {
- const wchar_t *identityName = XmlGetAttrValue(identity, L"name");
+ for (auto *identity : TiXmlFilter(query, "identity")) {
+ const char *identityName = identity->Attribute("name");
if (identityName)
pCaps->SetVer(identityName);
}
- HXML xform;
- for (int i = 1; (xform = XmlGetNthChild(query, L"x", i)) != nullptr; i++) {
- wchar_t *szFormTypeValue = XPath(xform, L"field[@var='FORM_TYPE']/value");
- if (!mir_wstrcmp(szFormTypeValue, L"urn:xmpp:dataforms:softwareinfo")) {
+ for (auto *xform : TiXmlFilter(query, "x")) {
+ const char *szFormTypeValue = XPath(xform, "field[@var='FORM_TYPE']/value");
+ if (!mir_strcmp(szFormTypeValue, "urn:xmpp:dataforms:softwareinfo")) {
JSONNode root;
- if (pCaps->m_szOs = mir_wstrdup(XPath(xform, L"field[@var='os']/value")))
- root.push_back(JSONNode("o", _T2A(pCaps->m_szOs).get()));
- if (pCaps->m_szOsVer = mir_wstrdup(XPath(xform, L"field[@var='os_version']/value")))
- root.push_back(JSONNode("ov", _T2A(pCaps->m_szOsVer).get()));
- if (pCaps->m_szSoft = mir_wstrdup(XPath(xform, L"field[@var='software']/value")))
- root.push_back(JSONNode("s", _T2A(pCaps->m_szSoft).get()));
- if (pCaps->m_szSoftVer = mir_wstrdup(XPath(xform, L"field[@var='software_version']/value")))
- root.push_back(JSONNode("sv", _T2A(pCaps->m_szSoftVer).get()));
- if (pCaps->m_szSoftMir = mir_wstrdup(XPath(xform, L"field[@var='x-miranda-core-version']/value")))
- root.push_back(JSONNode("sm", _T2A(pCaps->m_szSoftMir).get()));
+ if (pCaps->m_szOs = mir_strdup(XPath(xform, "field[@var='os']/value")))
+ root.push_back(JSONNode("o", pCaps->m_szOs));
+ if (pCaps->m_szOsVer = mir_strdup(XPath(xform, "field[@var='os_version']/value")))
+ root.push_back(JSONNode("ov", pCaps->m_szOsVer));
+ if (pCaps->m_szSoft = mir_strdup(XPath(xform, "field[@var='software']/value")))
+ root.push_back(JSONNode("s", pCaps->m_szSoft));
+ if (pCaps->m_szSoftVer = mir_strdup(XPath(xform, "field[@var='software_version']/value")))
+ root.push_back(JSONNode("sv", pCaps->m_szSoftVer));
+ if (pCaps->m_szSoftMir = mir_strdup(XPath(xform, "field[@var='x-miranda-core-version']/value")))
+ root.push_back(JSONNode("sm", pCaps->m_szSoftMir));
root.push_back(JSONNode("c", CMStringA(FORMAT, "%lld", jcbCaps)));
CMStringA szName(FORMAT, "%S#%S", pCaps->GetNode(), pCaps->GetHash());
@@ -200,12 +197,12 @@ void CJabberProto::OnIqResultCapsDiscoInfo(HXML, CJabberIqInfo *pInfo)
}
}
-JabberCapsBits CJabberProto::GetTotalJidCapabilities(const wchar_t *jid)
+JabberCapsBits CJabberProto::GetTotalJidCapabilities(const char *jid)
{
if (jid == nullptr)
return JABBER_RESOURCE_CAPS_NONE;
- wchar_t szBareJid[JABBER_MAX_JID_LEN];
+ char szBareJid[JABBER_MAX_JID_LEN];
JabberStripJid(jid, szBareJid, _countof(szBareJid));
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, szBareJid);
@@ -224,8 +221,8 @@ JabberCapsBits CJabberProto::GetTotalJidCapabilities(const wchar_t *jid)
if (item) {
for (auto &it : item->arResources) {
- wchar_t szFullJid[JABBER_MAX_JID_LEN];
- mir_snwprintf(szFullJid, L"%s/%s", szBareJid, it->m_tszResourceName);
+ char szFullJid[JABBER_MAX_JID_LEN];
+ mir_snprintf(szFullJid, "%s/%s", szBareJid, it->m_szResourceName);
pResourceStatus r(it);
JabberCapsBits jcb = GetResourceCapabilities(szFullJid, r);
if (!(jcb & JABBER_RESOURCE_CAPS_ERROR))
@@ -235,16 +232,16 @@ JabberCapsBits CJabberProto::GetTotalJidCapabilities(const wchar_t *jid)
return jcbToReturn;
}
-JabberCapsBits CJabberProto::GetResourceCapabilities(const wchar_t *jid)
+JabberCapsBits CJabberProto::GetResourceCapabilities(const char *jid)
{
- wchar_t fullJid[JABBER_MAX_JID_LEN];
+ char fullJid[JABBER_MAX_JID_LEN];
GetClientJID(jid, fullJid, _countof(fullJid));
pResourceStatus r(ResourceInfoFromJID(fullJid));
return GetResourceCapabilities(fullJid, r);
}
-JabberCapsBits CJabberProto::GetResourceCapabilities(const wchar_t *jid, pResourceStatus &r)
+JabberCapsBits CJabberProto::GetResourceCapabilities(const char *jid, pResourceStatus &r)
{
if (r == nullptr)
return JABBER_RESOURCE_CAPS_ERROR;
@@ -266,9 +263,9 @@ JabberCapsBits CJabberProto::GetResourceCapabilities(const wchar_t *jid, pResour
pCaps->SetCaps(JABBER_RESOURCE_CAPS_IN_PROGRESS, pInfo->GetIqId());
r->m_dwDiscoInfoRequestTime = pInfo->GetRequestTime();
- wchar_t queryNode[512];
- mir_snwprintf(queryNode, L"%s#%s", pCaps->GetNode(), pCaps->GetHash());
- m_ThreadInfo->send(XmlNodeIq(pInfo) << XQUERY(JABBER_FEAT_DISCO_INFO) << XATTR(L"node", queryNode));
+ char queryNode[512];
+ mir_snprintf(queryNode, "%s#%s", pCaps->GetNode(), pCaps->GetHash());
+ m_ThreadInfo->send(XmlNodeIq(pInfo) << XQUERY(JABBER_FEAT_DISCO_INFO) << XATTR("node", queryNode));
bRequestSent = true;
}
@@ -278,18 +275,18 @@ JabberCapsBits CJabberProto::GetResourceCapabilities(const wchar_t *jid, pResour
jcbCaps |= jcbMainCaps;
if (jcbMainCaps != JABBER_RESOURCE_CAPS_TIMEOUT && r->m_tszCapsExt) {
- wchar_t *caps = mir_wstrdup(r->m_tszCapsExt);
+ char *caps = mir_strdup(r->m_tszCapsExt);
- wchar_t *token = wcstok(caps, L" ");
+ char *token = strtok(caps, " ");
while (token) {
for (auto &it : g_JabberFeatCapPairsExt) {
- if (!mir_wstrcmp(it.szFeature, token)) {
+ if (!mir_strcmp(it.szFeature, token)) {
jcbCaps |= it.jcbCap;
break;
}
}
- token = wcstok(nullptr, L" ");
+ token = strtok(nullptr, " ");
}
mir_free(caps);
@@ -313,7 +310,7 @@ JabberCapsBits CJabberProto::GetResourceCapabilities(const wchar_t *jid, pResour
return JABBER_RESOURCE_CAPS_IN_PROGRESS;
}
-void CJabberProto::RequestOldCapsInfo(pResourceStatus &r, const wchar_t *fullJid)
+void CJabberProto::RequestOldCapsInfo(pResourceStatus &r, const char *fullJid)
{
CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE);
pInfo->SetTimeout(JABBER_RESOURCE_CAPS_QUERY_TIMEOUT);
@@ -322,20 +319,20 @@ void CJabberProto::RequestOldCapsInfo(pResourceStatus &r, const wchar_t *fullJid
m_ThreadInfo->send(XmlNodeIq(pInfo) << XQUERY(JABBER_FEAT_DISCO_INFO));
}
-void CJabberProto::GetCachedCaps(const wchar_t *szNode, const wchar_t *szVer, pResourceStatus &r)
+void CJabberProto::GetCachedCaps(const char *szNode, const char *szVer, pResourceStatus &r)
{
- CMStringA szName(FORMAT, "%S#%S", szNode, szVer);
+ CMStringA szName(FORMAT, "%s#%s", szNode, szVer);
ptrA szValue(db_get_sa(0, "JabberCaps", szName));
if (szValue != 0) {
JSONNode root = JSONNode::parse(szValue);
if (root) {
CMStringW wszCaps = root["c"].as_mstring();
r->m_pCaps = m_clientCapsManager.SetClientCaps(szNode, szVer, nullptr, _wtoi64(wszCaps));
- r->m_pCaps->m_szOs = mir_wstrdup(root["o"].as_mstring());
- r->m_pCaps->m_szOsVer = mir_wstrdup(root["ov"].as_mstring());
- r->m_pCaps->m_szSoft = mir_wstrdup(root["s"].as_mstring());
- r->m_pCaps->m_szSoftVer = mir_wstrdup(root["sv"].as_mstring());
- r->m_pCaps->m_szSoftMir = mir_wstrdup(root["sm"].as_mstring());
+ r->m_pCaps->m_szOs = mir_utf8encodeW(root["o"].as_mstring());
+ r->m_pCaps->m_szOsVer = mir_utf8encodeW(root["ov"].as_mstring());
+ r->m_pCaps->m_szSoft = mir_utf8encodeW(root["s"].as_mstring());
+ r->m_pCaps->m_szSoftVer = mir_utf8encodeW(root["sv"].as_mstring());
+ r->m_pCaps->m_szSoftMir = mir_utf8encodeW(root["sm"].as_mstring());
}
}
}
@@ -343,10 +340,10 @@ void CJabberProto::GetCachedCaps(const wchar_t *szNode, const wchar_t *szVer, pR
/////////////////////////////////////////////////////////////////////////////////////////
// CJabberClientPartialCaps class
-CJabberClientPartialCaps::CJabberClientPartialCaps(CJabberClientCaps *pParent, const wchar_t *szHash, const wchar_t *szVer)
+CJabberClientPartialCaps::CJabberClientPartialCaps(CJabberClientCaps *pParent, const char *szHash, const char *szVer)
: m_parent(pParent),
- m_szHash(mir_wstrdup(szHash)),
- m_szSoftVer(mir_wstrdup(szVer)),
+ m_szHash(mir_strdup(szHash)),
+ m_szSoftVer(mir_strdup(szVer)),
m_jcbCaps(JABBER_RESOURCE_CAPS_UNINIT),
m_pNext(nullptr),
m_nIqId(-1),
@@ -385,14 +382,14 @@ JabberCapsBits CJabberClientPartialCaps::GetCaps()
return m_jcbCaps;
}
-CJabberClientPartialCaps* CJabberClientCaps::FindByVersion(const wchar_t *szHash)
+CJabberClientPartialCaps* CJabberClientCaps::FindByVersion(const char *szHash)
{
if (m_pCaps == nullptr)
return nullptr;
CJabberClientPartialCaps *pCaps = m_pCaps;
while (pCaps) {
- if (!mir_wstrcmp(szHash, pCaps->GetHash()))
+ if (!mir_strcmp(szHash, pCaps->GetHash()))
return pCaps;
pCaps = pCaps->GetNext();
}
@@ -416,8 +413,8 @@ CJabberClientPartialCaps* CJabberClientCaps::FindById(int nIqId)
/////////////////////////////////////////////////////////////////////////////////////////
// CJabberClientCaps class
-CJabberClientCaps::CJabberClientCaps(const wchar_t *szNode) :
- m_szNode(mir_wstrdup(szNode))
+CJabberClientCaps::CJabberClientCaps(const char *szNode) :
+ m_szNode(mir_strdup(szNode))
{
m_pCaps = nullptr;
}
@@ -428,13 +425,13 @@ CJabberClientCaps::~CJabberClientCaps()
delete m_pCaps;
}
-JabberCapsBits CJabberClientCaps::GetPartialCaps(const wchar_t *szVer)
+JabberCapsBits CJabberClientCaps::GetPartialCaps(const char *szVer)
{
CJabberClientPartialCaps *pCaps = FindByVersion(szVer);
return (pCaps) ? pCaps->GetCaps() : JABBER_RESOURCE_CAPS_UNINIT;
}
-CJabberClientPartialCaps* CJabberClientCaps::SetPartialCaps(const wchar_t *szHash, const wchar_t *szVer, JabberCapsBits jcbCaps, int nIqId)
+CJabberClientPartialCaps* CJabberClientCaps::SetPartialCaps(const char *szHash, const char *szVer, JabberCapsBits jcbCaps, int nIqId)
{
CJabberClientPartialCaps *pCaps = FindByVersion(szHash);
if (!pCaps) {
@@ -452,7 +449,7 @@ CJabberClientPartialCaps* CJabberClientCaps::SetPartialCaps(const wchar_t *szHas
static int sttCompareNodes(const CJabberClientCaps *p1, const CJabberClientCaps *p2)
{
- return mir_wstrcmp(p1->GetNode(), p2->GetNode());
+ return mir_strcmp(p1->GetNode(), p2->GetNode());
}
CJabberClientCapsManager::CJabberClientCapsManager(CJabberProto *proto) :
@@ -483,13 +480,13 @@ void CJabberClientCapsManager::UpdateFeatHash()
CMStringA feat_buf(FORMAT, "client/pc//Miranda %d.%d.%d.%d<", __MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM);
for (auto &it : g_JabberFeatCapPairs)
if (jcb & it.jcbCap) {
- feat_buf.Append(_T2A(it.szFeature));
+ feat_buf.Append(it.szFeature);
feat_buf.AppendChar('<');
}
for (auto &it : ppro->m_lstJabberFeatCapPairsDynamic)
if (jcb & it->jcbCap) {
- feat_buf.Append(_T2A(it->szFeature));
+ feat_buf.Append(it->szFeature);
feat_buf.AppendChar('<');
}
@@ -500,7 +497,7 @@ void CJabberClientCapsManager::UpdateFeatHash()
feat_buf.Append(__VERSION_STRING_DOTS); feat_buf.AppendChar('<');
feat_buf.Append("x-miranda-core-version"); feat_buf.AppendChar('<');
- feat_buf.Append(_T2A(szCoreVersion)); feat_buf.AppendChar('<');
+ feat_buf.Append(szCoreVersion); feat_buf.AppendChar('<');
BYTE hash[MIR_SHA1_HASH_SIZE];
mir_sha1_hash((BYTE*)feat_buf.c_str(), feat_buf.GetLength(), hash);
@@ -508,12 +505,12 @@ void CJabberClientCapsManager::UpdateFeatHash()
m_szFeaturesCrc = szHash;
}
-const wchar_t* CJabberClientCapsManager::GetFeaturesCrc()
+const char* CJabberClientCapsManager::GetFeaturesCrc()
{
return m_szFeaturesCrc.c_str();
}
-CJabberClientCaps* CJabberClientCapsManager::FindClient(const wchar_t *szNode)
+CJabberClientCaps* CJabberClientCapsManager::FindClient(const char *szNode)
{
if (szNode == nullptr)
return nullptr;
@@ -521,29 +518,29 @@ CJabberClientCaps* CJabberClientCapsManager::FindClient(const wchar_t *szNode)
return m_arCaps.find((CJabberClientCaps*)&szNode);
}
-JabberCapsBits CJabberClientCapsManager::GetClientCaps(const wchar_t *szNode, const wchar_t *szVer)
+JabberCapsBits CJabberClientCapsManager::GetClientCaps(const char *szNode, const char *szVer)
{
mir_cslockfull lck(m_cs);
CJabberClientCaps *pClient = FindClient(szNode);
if (!pClient) {
lck.unlock();
- ppro->debugLogW(L"CAPS: get no caps for: %s, %s", szNode, szVer);
+ ppro->debugLogA("CAPS: get no caps for: %s, %s", szNode, szVer);
return JABBER_RESOURCE_CAPS_UNINIT;
}
JabberCapsBits jcbCaps = pClient->GetPartialCaps(szVer);
lck.unlock();
- ppro->debugLogW(L"CAPS: get caps %I64x for: %s, %s", jcbCaps, szNode, szVer);
+ ppro->debugLogA("CAPS: get caps %I64x for: %s, %s", jcbCaps, szNode, szVer);
return jcbCaps;
}
-CJabberClientPartialCaps* CJabberClientCapsManager::GetPartialCaps(const wchar_t *szNode, const wchar_t *szHash)
+CJabberClientPartialCaps* CJabberClientCapsManager::GetPartialCaps(const char *szNode, const char *szHash)
{
mir_cslock lck(m_cs);
CJabberClientCaps *pClient = FindClient(szNode);
return (pClient == nullptr) ? nullptr : pClient->FindByVersion(szHash);
}
-CJabberClientPartialCaps* CJabberClientCapsManager::SetClientCaps(const wchar_t *szNode, const wchar_t *szHash, const wchar_t *szVer, JabberCapsBits jcbCaps, int nIqId)
+CJabberClientPartialCaps* CJabberClientCapsManager::SetClientCaps(const char *szNode, const char *szHash, const char *szVer, JabberCapsBits jcbCaps, int nIqId)
{
mir_cslockfull lck(m_cs);
CJabberClientCaps *pClient = FindClient(szNode);
@@ -554,18 +551,18 @@ CJabberClientPartialCaps* CJabberClientCapsManager::SetClientCaps(const wchar_t
CJabberClientPartialCaps *res = pClient->SetPartialCaps(szHash, szVer, jcbCaps, nIqId);
lck.unlock();
- ppro->debugLogW(L"CAPS: set caps %I64x for: %s#%s => [%s]", jcbCaps, szHash, szNode, szVer);
+ ppro->debugLogA("CAPS: set caps %I64x for: %s#%s => [%s]", jcbCaps, szHash, szNode, szVer);
return res;
}
-bool CJabberClientCapsManager::HandleInfoRequest(HXML, CJabberIqInfo *pInfo, const wchar_t *szNode)
+bool CJabberClientCapsManager::HandleInfoRequest(const TiXmlElement*, CJabberIqInfo *pInfo, const char *szNode)
{
JabberCapsBits jcb = 0;
if (szNode) {
- wchar_t szExtCap[512], szExtCapWHash[560];
- mir_snwprintf(szExtCap, L"%s#%s", JABBER_CAPS_MIRANDA_NODE, m_szFeaturesCrc.c_str());
- if (!mir_wstrcmp(szExtCap, szNode)) {
+ char szExtCap[512], szExtCapWHash[560];
+ mir_snprintf(szExtCap, "%s#%s", JABBER_CAPS_MIRANDA_NODE, m_szFeaturesCrc.c_str());
+ if (!mir_strcmp(szExtCap, szNode)) {
szNode = nullptr;
goto LBL_All;
}
@@ -575,9 +572,9 @@ bool CJabberClientCapsManager::HandleInfoRequest(HXML, CJabberIqInfo *pInfo, con
continue;
// TODO: something better here
- mir_snwprintf(szExtCap, L"%s#%s", JABBER_CAPS_MIRANDA_NODE, it.szFeature);
- mir_snwprintf(szExtCapWHash, L"%s %s", szExtCap, m_szFeaturesCrc.c_str());
- if (!mir_wstrcmp(szNode, szExtCap) || !mir_wstrcmp(szNode, szExtCapWHash)) {
+ mir_snprintf(szExtCap, "%s#%s", JABBER_CAPS_MIRANDA_NODE, it.szFeature);
+ mir_snprintf(szExtCapWHash, "%s %s", szExtCap, m_szFeaturesCrc.c_str());
+ if (!mir_strcmp(szNode, szExtCap) || !mir_strcmp(szNode, szExtCapWHash)) {
jcb = it.jcbCap;
break;
}
@@ -586,9 +583,9 @@ bool CJabberClientCapsManager::HandleInfoRequest(HXML, CJabberIqInfo *pInfo, con
// check features registered through IJabberNetInterface::RegisterFeature() and IJabberNetInterface::AddFeatures()
for (auto &it : ppro->m_lstJabberFeatCapPairsDynamic) {
// TODO: something better here
- mir_snwprintf(szExtCap, L"%s#%s", JABBER_CAPS_MIRANDA_NODE, it->szExt);
- mir_snwprintf(szExtCapWHash, L"%s %s", szExtCap, m_szFeaturesCrc.c_str());
- if (!mir_wstrcmp(szNode, szExtCap) || !mir_wstrcmp(szNode, szExtCapWHash)) {
+ mir_snprintf(szExtCap, "%s#%s", JABBER_CAPS_MIRANDA_NODE, it->szExt);
+ mir_snprintf(szExtCapWHash, "%s %s", szExtCap, m_szFeaturesCrc.c_str());
+ if (!mir_strcmp(szNode, szExtCap) || !mir_strcmp(szNode, szExtCapWHash)) {
jcb = it->jcbCap;
break;
}
@@ -611,37 +608,37 @@ LBL_All:
if (!ppro->m_bAllowVersionRequests)
jcb &= ~JABBER_CAPS_VERSION;
- XmlNodeIq iq(L"result", pInfo);
+ XmlNodeIq iq("result", pInfo);
- HXML query = iq << XQUERY(JABBER_FEAT_DISCO_INFO);
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_DISCO_INFO);
if (szNode)
- query << XATTR(L"node", szNode);
+ query << XATTR("node", szNode);
- CMStringW szName(FORMAT, L"Miranda %d.%d.%d.%d", __MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM);
- query << XCHILD(L"identity") << XATTR(L"category", L"client") << XATTR(L"type", L"pc") << XATTR(L"name", szName);
+ CMStringA szName(FORMAT, "Miranda %d.%d.%d.%d", __MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM);
+ query << XCHILD("identity") << XATTR("category", "client") << XATTR("type", "pc") << XATTR("name", szName);
for (auto &it : g_JabberFeatCapPairs)
if (jcb & it.jcbCap)
- query << XCHILD(L"feature") << XATTR(L"var", it.szFeature);
+ query << XCHILD("feature") << XATTR("var", it.szFeature);
for (auto &it : ppro->m_lstJabberFeatCapPairsDynamic)
if (jcb & it->jcbCap)
- query << XCHILD(L"feature") << XATTR(L"var", it->szFeature);
+ query << XCHILD("feature") << XATTR("var", it->szFeature);
if (ppro->m_bAllowVersionRequests && !szNode) {
- HXML form = query << XCHILDNS(L"x", JABBER_FEAT_DATA_FORMS) << XATTR(L"type", L"result");
- form << XCHILD(L"field") << XATTR(L"var", L"FORM_TYPE") << XATTR(L"type", L"hidden")
- << XCHILD(L"value", L"urn:xmpp:dataforms:softwareinfo");
+ TiXmlElement *form = query << XCHILDNS("x", JABBER_FEAT_DATA_FORMS) << XATTR("type", "result");
+ form << XCHILD("field") << XATTR("var", "FORM_TYPE") << XATTR("type", "hidden")
+ << XCHILD("value", "urn:xmpp:dataforms:softwareinfo");
CJabberClientPartialCaps *pCaps = GetPartialCaps(JABBER_CAPS_MIRANDA_NODE, m_szFeaturesCrc);
if (pCaps) {
if (ppro->m_bShowOSVersion) {
- form << XCHILD(L"field") << XATTR(L"var", L"os") << XCHILD(L"value", pCaps->GetOs());
- form << XCHILD(L"field") << XATTR(L"var", L"os_version") << XCHILD(L"value", pCaps->GetOsVer());
+ form << XCHILD("field") << XATTR("var", "os") << XCHILD("value", pCaps->GetOs());
+ form << XCHILD("field") << XATTR("var", "os_version") << XCHILD("value", pCaps->GetOsVer());
}
- form << XCHILD(L"field") << XATTR(L"var", L"software") << XCHILD(L"value", pCaps->GetSoft());
- form << XCHILD(L"field") << XATTR(L"var", L"software_version") << XCHILD(L"value", pCaps->GetSoftVer());
- form << XCHILD(L"field") << XATTR(L"var", L"x-miranda-core-version") << XCHILD(L"value", pCaps->GetSoftMir());
+ form << XCHILD("field") << XATTR("var", "software") << XCHILD("value", pCaps->GetSoft());
+ form << XCHILD("field") << XATTR("var", "software_version") << XCHILD("value", pCaps->GetSoftVer());
+ form << XCHILD("field") << XATTR("var", "x-miranda-core-version") << XCHILD("value", pCaps->GetSoftMir());
}
}
diff --git a/protocols/JabberG/src/jabber_caps.h b/protocols/JabberG/src/jabber_caps.h
index 30ef883291..4c8e985990 100755
--- a/protocols/JabberG/src/jabber_caps.h
+++ b/protocols/JabberG/src/jabber_caps.h
@@ -44,123 +44,123 @@ typedef unsigned __int64 JabberCapsBits;
#define JABBER_RESOURCE_CAPS_NONE 0x0000000000000000
#endif
-#define JABBER_FEAT_DISCO_INFO L"http://jabber.org/protocol/disco#info"
+#define JABBER_FEAT_DISCO_INFO "http://jabber.org/protocol/disco#info"
#define JABBER_CAPS_DISCO_INFO ((JabberCapsBits)1)
-#define JABBER_FEAT_DISCO_ITEMS L"http://jabber.org/protocol/disco#items"
+#define JABBER_FEAT_DISCO_ITEMS "http://jabber.org/protocol/disco#items"
#define JABBER_CAPS_DISCO_ITEMS ((JabberCapsBits)1<<1)
-#define JABBER_FEAT_ENTITY_CAPS L"http://jabber.org/protocol/caps"
+#define JABBER_FEAT_ENTITY_CAPS "http://jabber.org/protocol/caps"
#define JABBER_CAPS_ENTITY_CAPS ((JabberCapsBits)1<<2)
-#define JABBER_FEAT_SI L"http://jabber.org/protocol/si"
+#define JABBER_FEAT_SI "http://jabber.org/protocol/si"
#define JABBER_CAPS_SI ((JabberCapsBits)1<<3)
-#define JABBER_FEAT_SI_FT L"http://jabber.org/protocol/si/profile/file-transfer"
+#define JABBER_FEAT_SI_FT "http://jabber.org/protocol/si/profile/file-transfer"
#define JABBER_CAPS_SI_FT ((JabberCapsBits)1<<4)
-#define JABBER_FEAT_BYTESTREAMS L"http://jabber.org/protocol/bytestreams"
+#define JABBER_FEAT_BYTESTREAMS "http://jabber.org/protocol/bytestreams"
#define JABBER_CAPS_BYTESTREAMS ((JabberCapsBits)1<<5)
-#define JABBER_FEAT_IBB L"http://jabber.org/protocol/ibb"
+#define JABBER_FEAT_IBB "http://jabber.org/protocol/ibb"
#define JABBER_CAPS_IBB ((JabberCapsBits)1<<6)
-#define JABBER_FEAT_OOB L"jabber:iq:oob"
-#define JABBER_FEAT_OOB2 L"jabber:x:oob"
+#define JABBER_FEAT_OOB "jabber:iq:oob"
+#define JABBER_FEAT_OOB2 "jabber:x:oob"
#define JABBER_CAPS_OOB ((JabberCapsBits)1<<7)
-#define JABBER_FEAT_COMMANDS L"http://jabber.org/protocol/commands"
+#define JABBER_FEAT_COMMANDS "http://jabber.org/protocol/commands"
#define JABBER_CAPS_COMMANDS ((JabberCapsBits)1<<8)
-#define JABBER_FEAT_REGISTER L"jabber:iq:register"
+#define JABBER_FEAT_REGISTER "jabber:iq:register"
#define JABBER_CAPS_REGISTER ((JabberCapsBits)1<<9)
-#define JABBER_FEAT_MUC L"http://jabber.org/protocol/muc"
+#define JABBER_FEAT_MUC "http://jabber.org/protocol/muc"
#define JABBER_CAPS_MUC ((JabberCapsBits)1<<10)
-#define JABBER_FEAT_CHATSTATES L"http://jabber.org/protocol/chatstates"
+#define JABBER_FEAT_CHATSTATES "http://jabber.org/protocol/chatstates"
#define JABBER_CAPS_CHATSTATES ((JabberCapsBits)1<<11)
-#define JABBER_FEAT_LAST_ACTIVITY L"jabber:iq:last"
+#define JABBER_FEAT_LAST_ACTIVITY "jabber:iq:last"
#define JABBER_CAPS_LAST_ACTIVITY ((JabberCapsBits)1<<12)
-#define JABBER_FEAT_VERSION L"jabber:iq:version"
+#define JABBER_FEAT_VERSION "jabber:iq:version"
#define JABBER_CAPS_VERSION ((JabberCapsBits)1<<13)
-#define JABBER_FEAT_ENTITY_TIME L"urn:xmpp:time"
+#define JABBER_FEAT_ENTITY_TIME "urn:xmpp:time"
#define JABBER_CAPS_ENTITY_TIME ((JabberCapsBits)1<<14)
-#define JABBER_FEAT_PING L"urn:xmpp:ping"
+#define JABBER_FEAT_PING "urn:xmpp:ping"
#define JABBER_CAPS_PING ((JabberCapsBits)1<<15)
-#define JABBER_FEAT_DATA_FORMS L"jabber:x:data"
+#define JABBER_FEAT_DATA_FORMS "jabber:x:data"
#define JABBER_CAPS_DATA_FORMS ((JabberCapsBits)1<<16)
-#define JABBER_FEAT_MESSAGE_EVENTS L"jabber:x:event"
+#define JABBER_FEAT_MESSAGE_EVENTS "jabber:x:event"
#define JABBER_CAPS_MESSAGE_EVENTS ((JabberCapsBits)1<<17)
-#define JABBER_FEAT_VCARD_TEMP L"vcard-temp"
+#define JABBER_FEAT_VCARD_TEMP "vcard-temp"
#define JABBER_CAPS_VCARD_TEMP ((JabberCapsBits)1<<18)
-#define JABBER_FEAT_AVATAR L"jabber:iq:avatar"
-#define JABBER_FEAT_SERVER_AVATAR L"storage:client:avatar"
+#define JABBER_FEAT_AVATAR "jabber:iq:avatar"
+#define JABBER_FEAT_SERVER_AVATAR "storage:client:avatar"
#define JABBER_CAPS_AVATAR ((JabberCapsBits)1<<19)
-#define JABBER_FEAT_XHTML L"http://jabber.org/protocol/xhtml-im"
+#define JABBER_FEAT_XHTML "http://jabber.org/protocol/xhtml-im"
#define JABBER_CAPS_XHTML ((JabberCapsBits)1<<20)
-#define JABBER_FEAT_AGENTS L"jabber:iq:agents"
+#define JABBER_FEAT_AGENTS "jabber:iq:agents"
#define JABBER_CAPS_AGENTS ((JabberCapsBits)1<<21)
-#define JABBER_FEAT_BROWSE L"jabber:iq:browse"
+#define JABBER_FEAT_BROWSE "jabber:iq:browse"
#define JABBER_CAPS_BROWSE ((JabberCapsBits)1<<22)
-#define JABBER_FEAT_FEATURE_NEG L"http://jabber.org/protocol/feature-neg"
+#define JABBER_FEAT_FEATURE_NEG "http://jabber.org/protocol/feature-neg"
#define JABBER_CAPS_FEATURE_NEG ((JabberCapsBits)1<<23)
-#define JABBER_FEAT_AMP L"http://jabber.org/protocol/amp"
+#define JABBER_FEAT_AMP "http://jabber.org/protocol/amp"
#define JABBER_CAPS_AMP ((JabberCapsBits)1<<24)
-#define JABBER_FEAT_USER_MOOD L"http://jabber.org/protocol/mood"
+#define JABBER_FEAT_USER_MOOD "http://jabber.org/protocol/mood"
#define JABBER_CAPS_USER_MOOD ((JabberCapsBits)1<<25)
-#define JABBER_FEAT_USER_MOOD_NOTIFY L"http://jabber.org/protocol/mood+notify"
+#define JABBER_FEAT_USER_MOOD_NOTIFY "http://jabber.org/protocol/mood+notify"
#define JABBER_CAPS_USER_MOOD_NOTIFY ((JabberCapsBits)1<<26)
-#define JABBER_FEAT_PUBSUB L"http://jabber.org/protocol/pubsub"
+#define JABBER_FEAT_PUBSUB "http://jabber.org/protocol/pubsub"
#define JABBER_CAPS_PUBSUB ((JabberCapsBits)1<<27)
-#define JABBER_FEAT_SECUREIM L"http://miranda-ng.org/caps/secureim"
+#define JABBER_FEAT_SECUREIM "http://miranda-ng.org/caps/secureim"
#define JABBER_CAPS_SECUREIM ((JabberCapsBits)1<<28)
-#define JABBER_FEAT_MIROTR L"http://miranda-ng.org/caps/mirotr"
+#define JABBER_FEAT_MIROTR "http://miranda-ng.org/caps/mirotr"
#define JABBER_CAPS_MIROTR ((JabberCapsBits)1<<42)
-#define JABBER_FEAT_NEWGPG L"http://miranda-ng.org/caps/new_gpg"
+#define JABBER_FEAT_NEWGPG "http://miranda-ng.org/caps/new_gpg"
#define JABBER_CAPS_NEWGPG ((JabberCapsBits)1<<43)
-#define JABBER_FEAT_OMEMO L"eu.siacs.conversations.axolotl"
-#define JABBER_CAPS_OMEMO ((JabberCapsBits)1<<46)
-#define JABBER_FEAT_OMEMO_DEVICELIST_NOTIFY JABBER_FEAT_OMEMO L".devicelist+notify"
-#define JABBER_CAPS_OMEMO_DEVICELIST_NOTIFY ((JabberCapsBits)1<<47)
+#define JABBER_FEAT_OMEMO "eu.siacs.conversations.axolotl"
+#define JABBER_CAPS_OMEMO ((JabberCapsBits)1<<46)
+#define JABBER_FEAT_OMEMO_DEVICELIST_NOTIFY JABBER_FEAT_OMEMO ".devicelist+notify"
+#define JABBER_CAPS_OMEMO_DEVICELIST_NOTIFY ((JabberCapsBits)1<<47)
#define JABBER_CAPS_PLATFORMX86 ((JabberCapsBits)1<<44)
#define JABBER_CAPS_PLATFORMX64 ((JabberCapsBits)1<<45)
-#define JABBER_FEAT_PRIVACY_LISTS L"jabber:iq:privacy"
+#define JABBER_FEAT_PRIVACY_LISTS "jabber:iq:privacy"
#define JABBER_CAPS_PRIVACY_LISTS ((JabberCapsBits)1<<29)
-#define JABBER_FEAT_MESSAGE_RECEIPTS L"urn:xmpp:receipts"
+#define JABBER_FEAT_MESSAGE_RECEIPTS "urn:xmpp:receipts"
#define JABBER_CAPS_MESSAGE_RECEIPTS ((JabberCapsBits)1<<30)
-#define JABBER_FEAT_USER_TUNE L"http://jabber.org/protocol/tune"
+#define JABBER_FEAT_USER_TUNE "http://jabber.org/protocol/tune"
#define JABBER_CAPS_USER_TUNE ((JabberCapsBits)1<<31)
-#define JABBER_FEAT_USER_TUNE_NOTIFY L"http://jabber.org/protocol/tune+notify"
+#define JABBER_FEAT_USER_TUNE_NOTIFY "http://jabber.org/protocol/tune+notify"
#define JABBER_CAPS_USER_TUNE_NOTIFY ((JabberCapsBits)1<<32)
-#define JABBER_FEAT_PRIVATE_STORAGE L"jabber:iq:private"
+#define JABBER_FEAT_PRIVATE_STORAGE "jabber:iq:private"
#define JABBER_CAPS_PRIVATE_STORAGE ((JabberCapsBits)1<<33)
-#define JABBER_FEAT_ARCHIVE L"urn:xmpp:archive"
-#define JABBER_FEAT_ARCHIVE_AUTO L"urn:xmpp:archive:auto"
+#define JABBER_FEAT_ARCHIVE "urn:xmpp:archive"
+#define JABBER_FEAT_ARCHIVE_AUTO "urn:xmpp:archive:auto"
#define JABBER_CAPS_ARCHIVE_AUTO ((JabberCapsBits)1<<34)
-#define JABBER_FEAT_ARCHIVE_MANAGE L"urn:xmpp:archive:manage"
+#define JABBER_FEAT_ARCHIVE_MANAGE "urn:xmpp:archive:manage"
#define JABBER_CAPS_ARCHIVE_MANAGE ((JabberCapsBits)1<<35)
-#define JABBER_FEAT_CAPTCHA L"urn:xmpp:captcha"
+#define JABBER_FEAT_CAPTCHA "urn:xmpp:captcha"
-#define JABBER_FEAT_ATTENTION L"urn:xmpp:attention:0"
+#define JABBER_FEAT_ATTENTION "urn:xmpp:attention:0"
#define JABBER_CAPS_ATTENTION ((JabberCapsBits)1<<36)
// deferred
-#define JABBER_FEAT_USER_ACTIVITY L"http://jabber.org/protocol/activity"
+#define JABBER_FEAT_USER_ACTIVITY "http://jabber.org/protocol/activity"
#define JABBER_CAPS_USER_ACTIVITY ((JabberCapsBits)1<<37)
-#define JABBER_FEAT_USER_ACTIVITY_NOTIFY L"http://jabber.org/protocol/activity+notify"
+#define JABBER_FEAT_USER_ACTIVITY_NOTIFY "http://jabber.org/protocol/activity+notify"
#define JABBER_CAPS_USER_ACTIVITY_NOTIFY ((JabberCapsBits)1<<38)
-#define JABBER_FEAT_MIRANDA_NOTES L"http://miranda-ng.org/storage#notes"
+#define JABBER_FEAT_MIRANDA_NOTES "http://miranda-ng.org/storage#notes"
#define JABBER_CAPS_MIRANDA_NOTES ((JabberCapsBits)1<<39)
-#define JABBER_FEAT_JINGLE L"urn:xmpp:jingle:1"
+#define JABBER_FEAT_JINGLE "urn:xmpp:jingle:1"
#define JABBER_CAPS_JINGLE ((JabberCapsBits)1<<40)
-#define JABBER_FEAT_ROSTER_EXCHANGE L"http://jabber.org/protocol/rosterx"
+#define JABBER_FEAT_ROSTER_EXCHANGE "http://jabber.org/protocol/rosterx"
#define JABBER_CAPS_ROSTER_EXCHANGE ((JabberCapsBits)1<<41)
-#define JABBER_FEAT_DIRECT_MUC_INVITE L"jabber:x:conference"
+#define JABBER_FEAT_DIRECT_MUC_INVITE "jabber:x:conference"
#define JABBER_CAPS_DIRECT_MUC_INVITE ((JabberCapsBits)1<<42)
-#define JABBER_FEAT_PUBSUB_EVENT L"http://jabber.org/protocol/pubsub#event"
-#define JABBER_FEAT_PUBSUB_NODE_CONFIG L"http://jabber.org/protocol/pubsub#node_config"
+#define JABBER_FEAT_PUBSUB_EVENT "http://jabber.org/protocol/pubsub#event"
+#define JABBER_FEAT_PUBSUB_NODE_CONFIG "http://jabber.org/protocol/pubsub#node_config"
-#define JABBER_FEAT_CARBONS L"urn:xmpp:carbons:2"
-#define JABBER_CAPS_CARBONS ((JabberCapsBits)1<<43)
+#define JABBER_FEAT_CARBONS "urn:xmpp:carbons:2"
+#define JABBER_CAPS_CARBONS ((JabberCapsBits)1<<43)
#define JABBER_CAPS_MESSAGE_EVENTS_NO_DELIVERY ((JabberCapsBits)1<<63)
#define JABBER_CAPS_OTHER_SPECIAL (JABBER_CAPS_MESSAGE_EVENTS_NO_DELIVERY|JABBER_RESOURCE_CAPS_ERROR) // must contain all the caps not listed in g_JabberFeatCapPairs, to prevent using these bits for features registered through IJabberNetInterface::RegisterFeature()
-#define JABBER_CAPS_MIRANDA_NODE L"http://miranda-ng.org/caps"
+#define JABBER_CAPS_MIRANDA_NODE "http://miranda-ng.org/caps"
#define JABBER_CAPS_MIRANDA_PARTIAL (JABBER_CAPS_DISCO_INFO | JABBER_CAPS_DISCO_ITEMS | JABBER_CAPS_MUC | JABBER_CAPS_ENTITY_CAPS | JABBER_CAPS_SI | JABBER_CAPS_SI_FT | \
JABBER_CAPS_BYTESTREAMS | JABBER_CAPS_IBB | JABBER_CAPS_OOB | JABBER_CAPS_CHATSTATES | JABBER_CAPS_AGENTS | JABBER_CAPS_BROWSE | \
JABBER_CAPS_VERSION | JABBER_CAPS_LAST_ACTIVITY | JABBER_CAPS_DATA_FORMS | JABBER_CAPS_MESSAGE_EVENTS | JABBER_CAPS_VCARD_TEMP | \
@@ -171,51 +171,51 @@ typedef unsigned __int64 JabberCapsBits;
JABBER_CAPS_USER_MOOD_NOTIFY | JABBER_CAPS_USER_TUNE_NOTIFY | JABBER_CAPS_USER_ACTIVITY_NOTIFY \
| JABBER_CAPS_PLATFORMX86 | JABBER_CAPS_PLATFORMX64)
-#define JABBER_XMLNS_FORWARD L"urn:xmpp:forward:0"
+#define JABBER_XMLNS_FORWARD "urn:xmpp:forward:0"
-#define JABBER_EXT_SECUREIM L"secureim"
-#define JABBER_EXT_MIROTR L"mirotr"
-#define JABBER_EXT_JINGLE L"jingle"
-#define JABBER_EXT_NEWGPG L"new_gpg"
-#define JABBER_EXT_OMEMO L"omemo"
-#define JABBER_EXT_NUDGE L"nudge"
-#define JABBER_EXT_COMMANDS L"cmds"
-#define JABBER_EXT_USER_MOOD L"mood"
-#define JABBER_EXT_USER_TUNE L"tune"
-#define JABBER_EXT_USER_ACTIVITY L"activity"
-#define JABBER_EXT_MIR_NOTES L"mir_notes"
-#define JABBER_EXT_PLATFORMX86 L"x86"
-#define JABBER_EXT_PLATFORMX64 L"x64"
+#define JABBER_EXT_SECUREIM "secureim"
+#define JABBER_EXT_MIROTR "mirotr"
+#define JABBER_EXT_JINGLE "jingle"
+#define JABBER_EXT_NEWGPG "new_gpg"
+#define JABBER_EXT_OMEMO "omemo"
+#define JABBER_EXT_NUDGE "nudge"
+#define JABBER_EXT_COMMANDS "cmds"
+#define JABBER_EXT_USER_MOOD "mood"
+#define JABBER_EXT_USER_TUNE "tune"
+#define JABBER_EXT_USER_ACTIVITY "activity"
+#define JABBER_EXT_MIR_NOTES "mir_notes"
+#define JABBER_EXT_PLATFORMX86 "x86"
+#define JABBER_EXT_PLATFORMX64 "x64"
-#define JABBER_FEAT_EXT_ADDRESSING L"http://jabber.org/protocol/address"
-#define JABBER_FEAT_NESTED_ROSTER_GROUPS L"roster:delimiter"
+#define JABBER_FEAT_EXT_ADDRESSING "http://jabber.org/protocol/address"
+#define JABBER_FEAT_NESTED_ROSTER_GROUPS "roster:delimiter"
-#define JABBER_FEAT_RC L"http://jabber.org/protocol/rc"
-#define JABBER_FEAT_RC_SET_STATUS L"http://jabber.org/protocol/rc#set-status"
-#define JABBER_FEAT_RC_SET_OPTIONS L"http://jabber.org/protocol/rc#set-options"
-#define JABBER_FEAT_RC_FORWARD L"http://jabber.org/protocol/rc#forward"
-#define JABBER_FEAT_RC_LEAVE_GROUPCHATS L"http://jabber.org/protocol/rc#leave-groupchats"
-#define JABBER_FEAT_RC_WS_LOCK L"http://miranda-ng.org/rc#lock_workstation"
-#define JABBER_FEAT_RC_QUIT_MIRANDA L"http://miranda-ng.org/rc#quit"
+#define JABBER_FEAT_RC "http://jabber.org/protocol/rc"
+#define JABBER_FEAT_RC_SET_STATUS "http://jabber.org/protocol/rc#set-status"
+#define JABBER_FEAT_RC_SET_OPTIONS "http://jabber.org/protocol/rc#set-options"
+#define JABBER_FEAT_RC_FORWARD "http://jabber.org/protocol/rc#forward"
+#define JABBER_FEAT_RC_LEAVE_GROUPCHATS "http://jabber.org/protocol/rc#leave-groupchats"
+#define JABBER_FEAT_RC_WS_LOCK "http://miranda-ng.org/rc#lock_workstation"
+#define JABBER_FEAT_RC_QUIT_MIRANDA "http://miranda-ng.org/rc#quit"
-#define JABBER_FEAT_IQ_ROSTER L"jabber:iq:roster"
-#define JABBER_FEAT_DELAY L"jabber:x:delay"
-#define JABBER_FEAT_ENTITY_TIME_OLD L"jabber:iq:time"
+#define JABBER_FEAT_IQ_ROSTER "jabber:iq:roster"
+#define JABBER_FEAT_DELAY "jabber:x:delay"
+#define JABBER_FEAT_ENTITY_TIME_OLD "jabber:iq:time"
-#define JABBER_FEAT_MUC_ADMIN L"http://jabber.org/protocol/muc#admin"
-#define JABBER_FEAT_MUC_OWNER L"http://jabber.org/protocol/muc#owner"
-#define JABBER_FEAT_MUC_USER L"http://jabber.org/protocol/muc#user"
+#define JABBER_FEAT_MUC_ADMIN "http://jabber.org/protocol/muc#admin"
+#define JABBER_FEAT_MUC_OWNER "http://jabber.org/protocol/muc#owner"
+#define JABBER_FEAT_MUC_USER "http://jabber.org/protocol/muc#user"
-#define JABBER_FEAT_NICK L"http://jabber.org/protocol/nick"
+#define JABBER_FEAT_NICK "http://jabber.org/protocol/nick"
-#define JABBER_FEAT_HTTP_AUTH L"http://jabber.org/protocol/http-auth"
+#define JABBER_FEAT_HTTP_AUTH "http://jabber.org/protocol/http-auth"
class CJabberClientPartialCaps
{
friend struct CJabberProto;
- ptrW m_szHash, m_szOs, m_szOsVer, m_szSoft, m_szSoftVer, m_szSoftMir;
+ ptrA m_szHash, m_szOs, m_szOsVer, m_szSoft, m_szSoftVer, m_szSoftMir;
JabberCapsBits m_jcbCaps;
int m_nIqId;
DWORD m_dwRequestTime;
@@ -224,7 +224,7 @@ class CJabberClientPartialCaps
CJabberClientPartialCaps *m_pNext;
public:
- CJabberClientPartialCaps(CJabberClientCaps *pParent, const wchar_t *szHash, const wchar_t *szVer);
+ CJabberClientPartialCaps(CJabberClientCaps *pParent, const char *szHash, const char *szVer);
~CJabberClientPartialCaps();
CJabberClientPartialCaps* SetNext(CJabberClientPartialCaps *pCaps);
@@ -235,42 +235,42 @@ public:
void SetCaps(JabberCapsBits jcbCaps, int nIqId = -1);
JabberCapsBits GetCaps();
- __inline const wchar_t* GetHash() const { return m_szHash.get(); }
- __inline const wchar_t* GetNode() const;
+ __inline const char* GetHash() const { return m_szHash.get(); }
+ __inline const char* GetNode() const;
- __inline const wchar_t* GetOs() const { return m_szOs.get(); }
- __inline const wchar_t* GetOsVer() const { return m_szOsVer.get(); }
- __inline const wchar_t* GetSoft() const { return m_szSoft.get(); }
- __inline const wchar_t* GetSoftVer() const { return m_szSoftVer.get(); }
- __inline const wchar_t* GetSoftMir() const { return m_szSoftMir.get(); }
+ __inline const char* GetOs() const { return m_szOs.get(); }
+ __inline const char* GetOsVer() const { return m_szOsVer.get(); }
+ __inline const char* GetSoft() const { return m_szSoft.get(); }
+ __inline const char* GetSoftVer() const { return m_szSoftVer.get(); }
+ __inline const char* GetSoftMir() const { return m_szSoftMir.get(); }
__inline int GetIqId() const { return m_nIqId; }
- __inline void SetVer(const wchar_t *szVer)
+ __inline void SetVer(const char *szVer)
{
- m_szSoft = mir_wstrdup(szVer);
+ m_szSoft = mir_strdup(szVer);
}
};
class CJabberClientCaps
{
- wchar_t *m_szNode;
+ char *m_szNode;
CJabberClientPartialCaps *m_pCaps;
public:
- CJabberClientCaps(const wchar_t *szNode);
+ CJabberClientCaps(const char *szNode);
~CJabberClientCaps();
- CJabberClientPartialCaps* FindByVersion(const wchar_t *szHash);
+ CJabberClientPartialCaps* FindByVersion(const char *szHash);
CJabberClientPartialCaps* FindById(int nIqId);
- JabberCapsBits GetPartialCaps(const wchar_t *szVer);
- CJabberClientPartialCaps* SetPartialCaps(const wchar_t *szHash, const wchar_t *szVer, JabberCapsBits jcbCaps, int nIqId = -1);
+ JabberCapsBits GetPartialCaps(const char *szVer);
+ CJabberClientPartialCaps* SetPartialCaps(const char *szHash, const char *szVer, JabberCapsBits jcbCaps, int nIqId = -1);
- __inline wchar_t* GetNode() const { return m_szNode; }
+ __inline char* GetNode() const { return m_szNode; }
};
-__inline const wchar_t* CJabberClientPartialCaps::GetNode() const { return m_parent->GetNode(); }
+__inline const char* CJabberClientPartialCaps::GetNode() const { return m_parent->GetNode(); }
class CJabberClientCapsManager
{
@@ -278,40 +278,40 @@ class CJabberClientCapsManager
OBJLIST<CJabberClientCaps> m_arCaps;
CJabberProto *ppro;
- CMStringW m_szFeaturesCrc;
+ CMStringA m_szFeaturesCrc;
protected:
- CJabberClientCaps *FindClient(const wchar_t *szNode);
+ CJabberClientCaps* FindClient(const char *szNode);
public:
CJabberClientCapsManager(CJabberProto *proto);
~CJabberClientCapsManager();
- const wchar_t* GetFeaturesCrc();
+ const char* GetFeaturesCrc();
void UpdateFeatHash();
- JabberCapsBits GetClientCaps(const wchar_t *szNode, const wchar_t *szHash);
- CJabberClientPartialCaps* GetPartialCaps(const wchar_t *szNode, const wchar_t *szHash);
+ JabberCapsBits GetClientCaps(const char *szNode, const char *szHash);
+ CJabberClientPartialCaps* GetPartialCaps(const char *szNode, const char *szHash);
- CJabberClientPartialCaps* SetClientCaps(const wchar_t *szNode, const wchar_t *szHash, const wchar_t *szVer, JabberCapsBits jcbCaps, int nIqId = -1);
- __inline CJabberClientPartialCaps* SetOwnCaps(const wchar_t *szNode, const wchar_t *szVer, JabberCapsBits jcbCaps, int nIqId = -1)
+ CJabberClientPartialCaps* SetClientCaps(const char *szNode, const char *szHash, const char *szVer, JabberCapsBits jcbCaps, int nIqId = -1);
+ __inline CJabberClientPartialCaps* SetOwnCaps(const char *szNode, const char *szVer, JabberCapsBits jcbCaps, int nIqId = -1)
{
return SetClientCaps(szNode, m_szFeaturesCrc, szVer, jcbCaps, nIqId);
}
- bool HandleInfoRequest(HXML iqNode, CJabberIqInfo *pInfo, const wchar_t *szNode);
+ bool HandleInfoRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, const char *szNode);
};
struct JabberFeatCapPair
{
- const wchar_t *szFeature;
+ const char *szFeature;
JabberCapsBits jcbCap;
- const wchar_t *tszDescription;
+ const char *tszDescription;
};
struct JabberFeatCapPairExt
{
- const wchar_t *szFeature;
+ const char *szFeature;
JabberCapsBits jcbCap;
LPCSTR szService;
@@ -322,10 +322,10 @@ struct JabberFeatCapPairExt
struct JabberFeatCapPairDynamic
{
- wchar_t *szExt;
- wchar_t *szFeature;
+ char *szExt;
+ char *szFeature;
JabberCapsBits jcbCap;
- wchar_t *szDescription;
+ char *szDescription;
};
extern const int g_cJabberFeatCapPairs;
diff --git a/protocols/JabberG/src/jabber_captcha.cpp b/protocols/JabberG/src/jabber_captcha.cpp
index e17a955737..148325e7a1 100644
--- a/protocols/JabberG/src/jabber_captcha.cpp
+++ b/protocols/JabberG/src/jabber_captcha.cpp
@@ -27,12 +27,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
struct CAPTCHA_FORM_PARAMS
{
- const wchar_t *from;
- const wchar_t *challenge;
- const wchar_t *fromjid;
- const wchar_t *sid;
- const wchar_t *to;
- const wchar_t *hint;
+ const char *from;
+ const char *challenge;
+ const char *fromjid;
+ const char *sid;
+ const char *to;
+ const char *hint;
HBITMAP bmp;
int w,h;
wchar_t Result[MAX_PATH];
@@ -47,10 +47,11 @@ INT_PTR CALLBACK JabberCaptchaFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
Window_SetSkinIcon_IcoLib(hwndDlg, IDI_KEYS);
params = (CAPTCHA_FORM_PARAMS*)lParam;
- const wchar_t *hint = params->hint;
+ const char *hint = params->hint;
if (hint == nullptr)
- hint = TranslateT("Enter the text you see");
- SetDlgItemText(hwndDlg, IDC_INSTRUCTION, TranslateW(hint));
+ SetDlgItemTextW(hwndDlg, IDC_INSTRUCTION, TranslateT("Enter the text you see"));
+ else
+ SetDlgItemTextW(hwndDlg, IDC_INSTRUCTION, TranslateW(Utf2T(hint)));
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)params);
return TRUE;
@@ -109,40 +110,40 @@ INT_PTR CALLBACK JabberCaptchaFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
return FALSE;
}
-bool CJabberProto::ProcessCaptcha(HXML node, HXML parentNode, ThreadData *info)
+bool CJabberProto::ProcessCaptcha(const TiXmlElement *node, const TiXmlElement *parentNode, ThreadData *info)
{
- HXML x = XmlGetChildByTag(node, "x", "xmlns", JABBER_FEAT_DATA_FORMS);
+ auto *x = XmlGetChildByTag(node, "x", "xmlns", JABBER_FEAT_DATA_FORMS);
if (x == nullptr)
return false;
- HXML y = XmlGetChildByTag(x, L"field", L"var", L"from");
+ auto *y = XmlGetChildByTag(x, "field", "var", "from");
if (y == nullptr)
return false;
- if ((y = XmlGetChild(y, "value")) == nullptr)
+ if ((y = y->FirstChildElement("value")) == nullptr)
return false;
CAPTCHA_FORM_PARAMS param;
- param.fromjid = XmlGetText(y);
+ param.fromjid = y->GetText();
- if ((y = XmlGetChildByTag(x, L"field", L"var", L"sid")) == nullptr)
+ if ((y = XmlGetChildByTag(x, "field", "var", "sid")) == nullptr)
return false;
- if ((y = XmlGetChild(y, "value")) == nullptr)
+ if ((y = y->FirstChildElement("value")) == nullptr)
return false;
- param.sid = XmlGetText(y);
+ param.sid = y->GetText();
- if ((y = XmlGetChildByTag(x, L"field", L"var", L"ocr")) == nullptr)
+ if ((y = XmlGetChildByTag(x, "field", "var", "ocr")) == nullptr)
return false;
- param.hint = XmlGetAttrValue (y, L"label");
+ param.hint = y->Attribute("label");
- param.from = XmlGetAttrValue(parentNode, L"from");
- param.to = XmlGetAttrValue(parentNode, L"to");
- param.challenge = XmlGetAttrValue(parentNode, L"id");
- HXML o = XmlGetChild(parentNode, "data");
- if (o == nullptr || XmlGetText(o) == nullptr)
+ param.from = parentNode->Attribute("from");
+ param.to = parentNode->Attribute("to");
+ param.challenge = parentNode->Attribute("id");
+ auto *o = parentNode->FirstChildElement("data");
+ if (o == nullptr || o->GetText() == nullptr)
return false;
size_t bufferLen;
- ptrA buffer((char*)mir_base64_decode( _T2A(XmlGetText(o)), &bufferLen));
+ ptrA buffer((char*)mir_base64_decode(o->GetText(), &bufferLen));
if (buffer == nullptr)
return false;
@@ -156,27 +157,27 @@ bool CJabberProto::ProcessCaptcha(HXML node, HXML parentNode, ThreadData *info)
if (mir_wstrcmp(param.Result, L"") == 0 || !res)
sendCaptchaError(info, param.from, param.to, param.challenge);
else
- sendCaptchaResult(param.Result, info, param.from, param.challenge, param.fromjid, param.sid);
+ sendCaptchaResult(T2Utf(param.Result), info, param.from, param.challenge, param.fromjid, param.sid);
return true;
}
-void CJabberProto::sendCaptchaResult(wchar_t* buf, ThreadData *info, const wchar_t *from, const wchar_t *challenge, const wchar_t *fromjid, const wchar_t *sid)
+void CJabberProto::sendCaptchaResult(char* buf, ThreadData *info, const char *from, const char *challenge, const char *fromjid, const char *sid)
{
- XmlNodeIq iq(L"set", SerialNext());
- HXML query= iq <<XATTR(L"to", from) << XCHILDNS(L"captcha", L"urn:xmpp:captcha") << XCHILDNS(L"x", JABBER_FEAT_DATA_FORMS) << XATTR(L"type", L"submit");
- query << XCHILD(L"field") << XATTR (L"var", L"FORM_TYPE") << XCHILD(L"value", L"urn:xmpp:captcha");
- query << XCHILD(L"field") << XATTR (L"var", L"from") << XCHILD(L"value", fromjid);
- query << XCHILD(L"field") << XATTR (L"var", L"challenge") << XCHILD(L"value", challenge);
- query << XCHILD(L"field") << XATTR (L"var", L"sid") << XCHILD(L"value", sid);
- query << XCHILD(L"field") << XATTR (L"var", L"ocr") << XCHILD(L"value", buf);
+ XmlNodeIq iq("set", SerialNext());
+ TiXmlElement *query= iq << XATTR("to", from) << XCHILDNS("captcha", "urn:xmpp:captcha") << XCHILDNS("x", JABBER_FEAT_DATA_FORMS) << XATTR("type", "submit");
+ query << XCHILD("field") << XATTR ("var", "FORM_TYPE") << XCHILD("value", "urn:xmpp:captcha");
+ query << XCHILD("field") << XATTR ("var", "from") << XCHILD("value", fromjid);
+ query << XCHILD("field") << XATTR ("var", "challenge") << XCHILD("value", challenge);
+ query << XCHILD("field") << XATTR ("var", "sid") << XCHILD("value", sid);
+ query << XCHILD("field") << XATTR ("var", "ocr") << XCHILD("value", buf);
info -> send (iq);
}
-void CJabberProto::sendCaptchaError(ThreadData *info, const wchar_t *from, const wchar_t *to, const wchar_t *challenge)
+void CJabberProto::sendCaptchaError(ThreadData *info, const char *from, const char *to, const char *challenge)
{
- XmlNode message(L"message");
- message << XATTR(L"type", L"error") << XATTR(L"to", from) << XATTR(L"id", challenge) << XATTR(L"from", to)
- << XCHILD(L"error") << XATTR(L"type", L"modify")
- << XCHILDNS(L"not-acceptable", L"urn:ietf:params:xml:ns:xmpp-stanzas");
+ XmlNode message("message");
+ message << XATTR("type", "error") << XATTR("to", from) << XATTR("id", challenge) << XATTR("from", to)
+ << XCHILD("error") << XATTR("type", "modify")
+ << XCHILDNS("not-acceptable", "urn:ietf:params:xml:ns:xmpp-stanzas");
info->send(message);
}
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp
index 8ea6368358..4ae86d90bb 100644
--- a/protocols/JabberG/src/jabber_chat.cpp
+++ b/protocols/JabberG/src/jabber_chat.cpp
@@ -127,8 +127,9 @@ int CJabberProto::GcInit(JABBER_LIST_ITEM *item)
for (auto &it : sttRoleItems)
it.translate();
- ptrW szNick(JabberNickFromJID(item->jid));
- SESSION_INFO *si = Chat_NewSession(GCW_CHATROOM, m_szModuleName, item->jid, szNick);
+ Utf2T wszJid(item->jid);
+ ptrA szNick(JabberNickFromJID(item->jid));
+ SESSION_INFO *si = Chat_NewSession(GCW_CHATROOM, m_szModuleName, wszJid, Utf2T(szNick));
if (si != nullptr) {
item->hContact = si->hContact;
@@ -140,21 +141,21 @@ int CJabberProto::GcInit(JABBER_LIST_ITEM *item)
}
}
- ptrW tszNick(getWStringA(si->hContact, "MyNick"));
+ ptrA tszNick(getUStringA(si->hContact, "MyNick"));
if (tszNick != nullptr) {
- if (!mir_wstrcmp(tszNick, szNick))
+ if (!mir_strcmp(tszNick, szNick))
delSetting(si->hContact, "MyNick");
else
- setWString(si->hContact, "MyNick", item->nick);
+ setUString(si->hContact, "MyNick", item->nick);
}
- else setWString(si->hContact, "MyNick", item->nick);
+ else setUString(si->hContact, "MyNick", item->nick);
- ptrW passw(getWStringA(si->hContact, "Password"));
- if (lstrcmp_null(passw, item->password)) {
+ ptrA passw(getUStringA(si->hContact, "Password"));
+ if (mir_strcmp(passw, item->password)) {
if (!item->password || !item->password[0])
delSetting(si->hContact, "Password");
else
- setWString(si->hContact, "Password", item->password);
+ setUString(si->hContact, "Password", item->password);
}
}
@@ -163,8 +164,8 @@ int CJabberProto::GcInit(JABBER_LIST_ITEM *item)
for (int i = _countof(sttStatuses) - 1; i >= 0; i--)
Chat_AddGroup(si, TranslateW(sttStatuses[i]));
- Chat_Control(m_szModuleName, item->jid, (item->bAutoJoin && m_bAutoJoinHidden) ? WINDOW_HIDDEN : SESSION_INITDONE);
- Chat_Control(m_szModuleName, item->jid, SESSION_ONLINE);
+ Chat_Control(m_szModuleName, wszJid, (item->bAutoJoin && m_bAutoJoinHidden) ? WINDOW_HIDDEN : SESSION_INITDONE);
+ Chat_Control(m_szModuleName, wszJid, SESSION_ONLINE);
return 0;
}
@@ -177,17 +178,17 @@ void CJabberProto::GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus
switch (type) {
case INFO_BAN:
if (m_bGcLogBans)
- buf.Format(TranslateT("User %s is now banned."), user->m_tszResourceName);
+ buf.Format(TranslateT("User %s is now banned."), user->m_szResourceName);
break;
case INFO_STATUS:
if (m_bGcLogStatuses) {
wchar_t *ptszDescr = Clist_GetStatusModeDescription(user->m_iStatus, 0);
- if (user->m_tszStatusMessage)
+ if (user->m_szStatusMessage)
buf.Format(TranslateT("User %s changed status to %s with message: %s"),
- user->m_tszResourceName, ptszDescr, user->m_tszStatusMessage);
+ user->m_szResourceName, ptszDescr, user->m_szStatusMessage);
else
- buf.Format(TranslateT("User %s changed status to %s"), user->m_tszResourceName, ptszDescr);
+ buf.Format(TranslateT("User %s changed status to %s"), user->m_szResourceName, ptszDescr);
}
break;
@@ -207,7 +208,7 @@ void CJabberProto::GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus
case AFFILIATION_OUTCAST: name = TranslateT("Outcast"); break;
}
if (name)
- buf.Format(TranslateT("Affiliation of %s was changed to '%s'."), user->m_tszResourceName, name);
+ buf.Format(TranslateT("Affiliation of %s was changed to '%s'."), user->m_szResourceName, name);
}
break;
@@ -222,7 +223,7 @@ void CJabberProto::GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus
}
if (name)
- buf.Format(TranslateT("Role of %s was changed to '%s'."), user->m_tszResourceName, name);
+ buf.Format(TranslateT("Role of %s was changed to '%s'."), user->m_szResourceName, name);
}
break;
}
@@ -230,9 +231,10 @@ void CJabberProto::GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus
if (!buf.IsEmpty()) {
buf.Replace(L"%", L"%%");
- GCEVENT gce = { m_szModuleName, item->jid, GC_EVENT_INFORMATION };
- gce.ptszNick = user->m_tszResourceName;
- gce.ptszUID = user->m_tszResourceName;
+ Utf2T wszRoomJid(item->jid), wszUserId(user->m_szResourceName);
+ GCEVENT gce = { m_szModuleName, wszRoomJid, GC_EVENT_INFORMATION };
+ gce.ptszNick = wszUserId;
+ gce.ptszUID = wszUserId;
gce.ptszText = buf;
gce.dwFlags = GCEF_ADDTOLOG;
gce.time = time(0);
@@ -240,28 +242,28 @@ void CJabberProto::GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus
}
}
-void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const wchar_t *resource, const wchar_t *nick, const wchar_t *jid, int action, HXML reason, int nStatusCode)
+void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const char *resource, const char *nick, const char *jid, int action, const TiXmlElement *reason, int nStatusCode)
{
int statusToSet = 0;
- const wchar_t *szReason = XmlGetText(reason);
+ const char *szReason = reason->GetText();
if (szReason == nullptr) {
if (nStatusCode == 322)
- szReason = TranslateT("because room is now members-only");
+ szReason = Translate("because room is now members-only");
else if (nStatusCode == 301)
- szReason = TranslateT("user banned");
+ szReason = Translate("user banned");
}
- ptrW myNick(mir_wstrdup(item->nick));
+ ptrA myNick(mir_strdup(item->nick));
if (myNick == nullptr)
myNick = JabberNickFromJID(m_szJabberJID);
- GCEVENT gce = { m_szModuleName, item->jid };
- gce.ptszNick = nick;
- gce.ptszUID = resource;
- if (jid != nullptr)
- gce.ptszUserInfo = jid;
- gce.ptszText = szReason;
+ Utf2T wszRoomJid(item->jid), wszNick(nick), wszUserId(resource), wszText(szReason), wszUserInfo(jid);
+ GCEVENT gce = { m_szModuleName, wszRoomJid };
+ gce.ptszNick = wszNick;
+ gce.ptszUID = wszUserId;
+ gce.ptszUserInfo = wszUserInfo;
+ gce.ptszText = wszText;
if (item->bChatActive == 2) {
gce.dwFlags |= GCEF_ADDTOLOG;
gce.time = time(0);
@@ -276,7 +278,7 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const wchar_t
default:
mir_cslock lck(m_csLists);
for (auto &JS : item->arResources) {
- if (!mir_wstrcmp(resource, JS->m_tszResourceName)) {
+ if (!mir_strcmp(resource, JS->m_szResourceName)) {
if (action != GC_EVENT_JOIN) {
switch (action) {
case 0:
@@ -287,7 +289,7 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const wchar_t
gce.ptszText = TranslateT("Moderator");
}
gce.ptszStatus = TranslateW(sttStatuses[JabberGcGetStatus(JS)]);
- gce.bIsMe = (mir_wstrcmp(nick, myNick) == 0);
+ gce.bIsMe = (mir_strcmp(nick, myNick) == 0);
statusToSet = JS->m_iStatus;
break;
}
@@ -300,47 +302,48 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const wchar_t
int flags = GC_SSE_ONLYLISTED;
if (statusToSet == ID_STATUS_AWAY || statusToSet == ID_STATUS_NA || statusToSet == ID_STATUS_DND)
flags += GC_SSE_ONLINE;
- Chat_SetStatusEx(m_szModuleName, item->jid, flags, nick);
+ Chat_SetStatusEx(m_szModuleName, wszRoomJid, flags, wszNick);
gce.iType = GC_EVENT_SETCONTACTSTATUS;
- gce.ptszText = nick;
- gce.ptszUID = resource;
+ gce.ptszText = wszNick;
+ gce.ptszUID = wszUserId;
gce.dwItemData = statusToSet;
Chat_Event(&gce);
}
}
-void CJabberProto::GcQuit(JABBER_LIST_ITEM *item, int code, HXML reason)
+void CJabberProto::GcQuit(JABBER_LIST_ITEM *item, int code, const TiXmlElement *reason)
{
- wchar_t *szMessage = nullptr;
+ CMStringA szMessage;
if (code != 307 && code != 301) {
- ptrW tszMessage(getWStringA("GcMsgQuit"));
- if (tszMessage != nullptr)
- szMessage = NEWWSTR_ALLOCA(tszMessage);
+ ptrA quitMessage(getUStringA("GcMsgQuit"));
+ if (quitMessage != nullptr)
+ szMessage = quitMessage;
else
- szMessage = TranslateW(JABBER_GC_MSG_QUIT);
+ szMessage = Translate(JABBER_GC_MSG_QUIT);
}
else {
- ptrW myNick(JabberNickFromJID(m_szJabberJID));
+ ptrA myNick(JabberNickFromJID(m_szJabberJID));
GcLogUpdateMemberStatus(item, myNick, myNick, nullptr, GC_EVENT_KICK, reason);
}
+ Utf2T wszRoomJid(item->jid);
if (code == 200)
- Chat_Terminate(m_szModuleName, item->jid);
+ Chat_Terminate(m_szModuleName, wszRoomJid);
else
- Chat_Control(m_szModuleName, item->jid, SESSION_OFFLINE);
+ Chat_Control(m_szModuleName, wszRoomJid, SESSION_OFFLINE);
db_unset(item->hContact, "CList", "Hidden");
item->bChatActive = false;
if (m_bJabberOnline) {
- wchar_t szPresenceTo[JABBER_MAX_JID_LEN];
- mir_snwprintf(szPresenceTo, L"%s/%s", item->jid, item->nick);
+ char szPresenceTo[JABBER_MAX_JID_LEN];
+ mir_snprintf(szPresenceTo, "%s/%s", item->jid, item->nick);
m_ThreadInfo->send(
- XmlNode(L"presence") << XATTR(L"to", szPresenceTo) << XATTR(L"type", L"unavailable")
- << XCHILD(L"status", szMessage));
+ XmlNode("presence") << XATTR("to", szPresenceTo) << XATTR("type", "unavailable")
+ << XCHILD("status", szMessage));
ListRemove(LIST_CHATROOM, item->jid);
}
@@ -490,15 +493,15 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam)
if (mir_strcmpi(gcmi->pszModule, m_szModuleName))
return 0;
- JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, gcmi->pszID);
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, T2Utf(gcmi->pszID));
if (item == nullptr)
return 0;
pResourceStatus me(nullptr), him(nullptr);
for (auto &p : item->arResources) {
- if (!mir_wstrcmp(p->m_tszResourceName, item->nick))
+ if (!mir_strcmp(p->m_szResourceName, item->nick))
me = p;
- if (!mir_wstrcmp(p->m_tszResourceName, gcmi->pszUID))
+ if (!mir_strcmp(p->m_szResourceName, T2Utf(gcmi->pszUID)))
him = p;
}
@@ -512,12 +515,12 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam)
sttSetupGcMenuItem(_countof(sttLogListItems), sttLogListItems, 0, FALSE);
int idx = IDM_LINK0;
- wchar_t *ptszStatusMsg = item->getTemp()->m_tszStatusMessage;
+ char *ptszStatusMsg = item->getTemp()->m_szStatusMessage;
if (ptszStatusMsg && *ptszStatusMsg) {
wchar_t *bufPtr = url_buf;
- for (wchar_t *p = wcsstr(ptszStatusMsg, L"http"); p && *p; p = wcsstr(p + 1, L"http")) {
- if (!wcsncmp(p, L"http://", 7) || !wcsncmp(p, L"https://", 8)) {
- mir_wstrncpy(bufPtr, p, _countof(url_buf) - (bufPtr - url_buf));
+ for (char *p = strstr(ptszStatusMsg, "http"); p && *p; p = strstr(p + 1, "http")) {
+ if (!strncmp(p, "http://", 7) || !strncmp(p, "https://", 8)) {
+ mir_wstrncpy(bufPtr, Utf2T(p), _countof(url_buf) - (bufPtr - url_buf));
gc_item *pItem = sttFindGcMenuItem(_countof(sttLogListItems), sttLogListItems, idx);
pItem->pszDesc = bufPtr;
pItem->uType = MENU_POPUPITEM;
@@ -558,7 +561,7 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam)
continue;
gc_item *pItem = sttFindGcMenuItem(_countof(sttListItems), sttListItems, idx);
- pItem->pszDesc = item->jid;
+ //!!!!!!!!!!!!!!!!!! pItem->pszDesc = item->jid;
pItem->uType = MENU_POPUPITEM;
if (++idx > IDM_LINK9)
break;
@@ -579,11 +582,11 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam)
pItem->bDisabled = !(force || it.check(me, him));
}
- if (him->m_tszRealJid && *him->m_tszRealJid) {
- mir_snwprintf(sttRJidBuf, TranslateT("Real &JID: %s"), him->m_tszRealJid);
+ if (him->m_szRealJid && *him->m_szRealJid) {
+ mir_snwprintf(sttRJidBuf, TranslateT("Real &JID: %s"), him->m_szRealJid);
if (wchar_t *tmp = wcschr(sttRJidBuf, '/')) *tmp = 0;
- if (MCONTACT hContact = HContactFromJID(him->m_tszRealJid)) {
+ if (MCONTACT hContact = HContactFromJID(him->m_szRealJid)) {
sttListItems[3].uType = MENU_HMENU;
sttListItems[3].dwID = (INT_PTR)Menu_BuildContactMenu(hContact);
sttShowGcMenuItems(_countof(sttListItems), sttListItems, sttRJidItems, 0);
@@ -632,11 +635,11 @@ class CGroupchatInviteDlg : public CJabberDlgBase
struct JabberGcLogInviteDlgJidData
{
HANDLE hItem;
- wchar_t jid[JABBER_MAX_JID_LEN];
+ char jid[JABBER_MAX_JID_LEN];
};
LIST<JabberGcLogInviteDlgJidData> m_newJids;
- wchar_t *m_room;
+ char *m_room;
CCtrlButton m_btnInvite;
CCtrlEdit m_txtNewJid;
@@ -644,10 +647,10 @@ class CGroupchatInviteDlg : public CJabberDlgBase
CCtrlEdit m_txtReason;
CCtrlClc m_clc;
- bool FindJid(const wchar_t *buf)
+ bool FindJid(const char *buf)
{
for (auto &it : m_newJids)
- if (!mir_wstrcmp(it->jid, buf))
+ if (!mir_strcmp(it->jid, buf))
return true;
return false;
@@ -676,20 +679,20 @@ class CGroupchatInviteDlg : public CJabberDlgBase
m_clc.SetTextColor(i, GetSysColor(COLOR_WINDOWTEXT));
}
- void InviteUser(wchar_t *pUser, wchar_t *text)
+ void InviteUser(char *pUser, char *text)
{
- XmlNode msg(L"message");
- HXML invite = msg << XATTR(L"to", m_room) << XATTRID(m_proto->SerialNext())
- << XCHILDNS(L"x", JABBER_FEAT_MUC_USER)
- << XCHILD(L"invite") << XATTR(L"to", pUser);
+ XmlNode msg("message");
+ TiXmlElement *invite = msg << XATTR("to", m_room) << XATTRID(m_proto->SerialNext())
+ << XCHILDNS("x", JABBER_FEAT_MUC_USER)
+ << XCHILD("invite") << XATTR("to", pUser);
if (text)
- invite << XCHILD(L"reason", text);
+ invite << XCHILD("reason", text);
m_proto->m_ThreadInfo->send(msg);
}
public:
- CGroupchatInviteDlg(CJabberProto *ppro, const wchar_t *room) :
+ CGroupchatInviteDlg(CJabberProto *ppro, const char *room) :
CSuper(ppro, IDD_GROUPCHAT_INVITE),
m_newJids(1),
m_btnInvite(this, IDC_INVITE),
@@ -698,7 +701,7 @@ public:
m_txtReason(this, IDC_REASON),
m_clc(this, IDC_CLIST)
{
- m_room = mir_wstrdup(room);
+ m_room = mir_strdup(room);
m_btnAddJid.OnClick = Callback(this, &CGroupchatInviteDlg::OnCommand_AddJid);
m_btnInvite.OnClick = Callback(this, &CGroupchatInviteDlg::OnCommand_Invite);
m_clc.OnNewContact =
@@ -730,11 +733,10 @@ public:
void OnCommand_AddJid(CCtrlButton*)
{
- wchar_t buf[JABBER_MAX_JID_LEN];
- m_txtNewJid.GetText(buf, _countof(buf));
+ ptrA szJid(m_txtNewJid.GetTextU());
m_txtNewJid.SetTextA("");
- MCONTACT hContact = m_proto->HContactFromJID(buf);
+ MCONTACT hContact = m_proto->HContactFromJID(szJid);
if (hContact) {
int hItem = SendDlgItemMessage(m_hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0);
if (hItem)
@@ -742,16 +744,17 @@ public:
return;
}
- if (FindJid(buf))
+ if (FindJid(szJid))
return;
JabberGcLogInviteDlgJidData *jidData = (JabberGcLogInviteDlgJidData *)mir_alloc(sizeof(JabberGcLogInviteDlgJidData));
- mir_wstrcpy(jidData->jid, buf);
+ mir_strcpy(jidData->jid, szJid);
+
+ CMStringW msg(FORMAT, TranslateT("%s (not on roster)"), Utf2T(szJid).get());
CLCINFOITEM cii = { 0 };
cii.cbSize = sizeof(cii);
cii.flags = CLCIIF_CHECKBOX;
- mir_snwprintf(buf, TranslateT("%s (not on roster)"), jidData->jid);
- cii.pszText = buf;
+ cii.pszText = msg;
jidData->hItem = m_clc.AddInfoItem(&cii);
m_clc.SetCheck(jidData->hItem, 1);
m_newJids.insert(jidData);
@@ -761,7 +764,7 @@ public:
{
if (!m_room) return;
- ptrW text(m_txtReason.GetText());
+ T2Utf text(ptrW(m_txtReason.GetText()));
// invite users from roster
for (auto &hContact : m_proto->AccContacts()) {
@@ -770,7 +773,7 @@ public:
if (HANDLE hItem = m_clc.FindContact(hContact)) {
if (m_clc.GetCheck(hItem)) {
- ptrW jid(m_proto->getWStringA(hContact, "jid"));
+ ptrA jid(m_proto->getUStringA(hContact, "jid"));
if (jid != nullptr)
InviteUser(jid, text);
}
@@ -789,20 +792,20 @@ public:
/////////////////////////////////////////////////////////////////////////////////////////
// Context menu processing
-void CJabberProto::AdminSet(const wchar_t *to, const wchar_t *ns, const wchar_t *szItem, const wchar_t *itemVal, const wchar_t *var, const wchar_t *varVal)
+void CJabberProto::AdminSet(const char *to, const char *ns, const char *szItem, const char *itemVal, const char *var, const char *varVal)
{
- m_ThreadInfo->send(XmlNodeIq(L"set", SerialNext(), to) << XQUERY(ns) << XCHILD(L"item") << XATTR(szItem, itemVal) << XATTR(var, varVal));
+ m_ThreadInfo->send(XmlNodeIq("set", SerialNext(), to) << XQUERY(ns) << XCHILD("item") << XATTR(szItem, itemVal) << XATTR(var, varVal));
}
-void CJabberProto::AdminSetReason(const wchar_t *to, const wchar_t *ns, const wchar_t *szItem, const wchar_t *itemVal, const wchar_t *var, const wchar_t *varVal, const wchar_t *rsn)
+void CJabberProto::AdminSetReason(const char *to, const char *ns, const char *szItem, const char *itemVal, const char *var, const char *varVal, const char *rsn)
{
- m_ThreadInfo->send(XmlNodeIq(L"set", SerialNext(), to) << XQUERY(ns) << XCHILD(L"item") << XATTR(szItem, itemVal) << XATTR(var, varVal) << XCHILD(L"reason", rsn));
+ m_ThreadInfo->send(XmlNodeIq("set", SerialNext(), to) << XQUERY(ns) << XCHILD("item") << XATTR(szItem, itemVal) << XATTR(var, varVal) << XCHILD("reason", rsn));
}
-void CJabberProto::AdminGet(const wchar_t *to, const wchar_t *ns, const wchar_t *var, const wchar_t *varVal, JABBER_IQ_HANDLER foo)
+void CJabberProto::AdminGet(const char *to, const char *ns, const char *var, const char *varVal, JABBER_IQ_HANDLER foo)
{
m_ThreadInfo->send(XmlNodeIq(AddIQ(foo, JABBER_IQ_TYPE_GET, to))
- << XQUERY(ns) << XCHILD(L"item") << XATTR(var, varVal));
+ << XQUERY(ns) << XCHILD("item") << XATTR(var, varVal));
}
// Member info dialog
@@ -843,13 +846,13 @@ static INT_PTR CALLBACK sttUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam
SendDlgItemMessage(hwndDlg, IDC_ICO_STATUS, STM_SETICON, (WPARAM)Skin_LoadProtoIcon(dat->ppro->m_szModuleName, dat->him->m_iStatus), 0);
- wchar_t buf[256];
- mir_snwprintf(buf, TranslateT("%s from\n%s"), dat->him->m_tszResourceName, dat->item->jid);
- SetDlgItemText(hwndDlg, IDC_HEADERBAR, buf);
+ char buf[256];
+ mir_snprintf(buf, Translate("%s from\n%s"), dat->him->m_szResourceName, dat->item->jid);
+ SetDlgItemTextUtf(hwndDlg, IDC_HEADERBAR, buf);
- SetDlgItemText(hwndDlg, IDC_TXT_NICK, dat->him->m_tszResourceName);
- SetDlgItemText(hwndDlg, IDC_TXT_JID, dat->him->m_tszRealJid ? dat->him->m_tszRealJid : TranslateT("Real JID not available"));
- SetDlgItemText(hwndDlg, IDC_TXT_STATUS, dat->him->m_tszStatusMessage);
+ SetDlgItemTextUtf(hwndDlg, IDC_TXT_NICK, dat->him->m_szResourceName);
+ SetDlgItemTextUtf(hwndDlg, IDC_TXT_JID, dat->him->m_szRealJid ? dat->him->m_szRealJid : Translate("Real JID not available"));
+ SetDlgItemTextUtf(hwndDlg, IDC_TXT_STATUS, dat->him->m_szStatusMessage);
for (auto &it : sttRoleItems) {
if ((it.value == dat->him->m_role) || it.check(dat->me, dat->him)) {
@@ -898,33 +901,33 @@ static INT_PTR CALLBACK sttUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam
if (dat->him->m_affiliation == value)
break;
- wchar_t szBareJid[JABBER_MAX_JID_LEN];
- JabberStripJid(dat->him->m_tszRealJid, szBareJid, _countof(szBareJid));
+ char szBareJid[JABBER_MAX_JID_LEN];
+ JabberStripJid(dat->him->m_szRealJid, szBareJid, _countof(szBareJid));
switch (value) {
case AFFILIATION_NONE:
- if (dat->him->m_tszRealJid)
- dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, L"jid", szBareJid, L"affiliation", L"none");
+ if (dat->him->m_szRealJid)
+ dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, "jid", szBareJid, "affiliation", "none");
else
- dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, L"nick", dat->him->m_tszResourceName, L"affiliation", L"none");
+ dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, "nick", dat->him->m_szResourceName, "affiliation", "none");
break;
case AFFILIATION_MEMBER:
- if (dat->him->m_tszRealJid)
- dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, L"jid", szBareJid, L"affiliation", L"member");
+ if (dat->him->m_szRealJid)
+ dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, "jid", szBareJid, "affiliation", "member");
else
- dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, L"nick", dat->him->m_tszResourceName, L"affiliation", L"member");
+ dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, "nick", dat->him->m_szResourceName, "affiliation", "member");
break;
case AFFILIATION_ADMIN:
- if (dat->him->m_tszRealJid)
- dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, L"jid", szBareJid, L"affiliation", L"admin");
+ if (dat->him->m_szRealJid)
+ dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, "jid", szBareJid, "affiliation", "admin");
else
- dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, L"nick", dat->him->m_tszResourceName, L"affiliation", L"admin");
+ dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, "nick", dat->him->m_szResourceName, "affiliation", "admin");
break;
case AFFILIATION_OWNER:
- if (dat->him->m_tszRealJid)
- dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, L"jid", szBareJid, L"affiliation", L"owner");
+ if (dat->him->m_szRealJid)
+ dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, "jid", szBareJid, "affiliation", "owner");
else
- dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, L"nick", dat->him->m_tszResourceName, L"affiliation", L"owner");
+ dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, "nick", dat->him->m_szResourceName, "affiliation", "owner");
}
break;
@@ -944,13 +947,13 @@ static INT_PTR CALLBACK sttUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam
switch (value) {
case ROLE_VISITOR:
- dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, L"nick", dat->him->m_tszResourceName, L"role", L"visitor");
+ dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, "nick", dat->him->m_szResourceName, "role", "visitor");
break;
case ROLE_PARTICIPANT:
- dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, L"nick", dat->him->m_tszResourceName, L"role", L"participant");
+ dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, "nick", dat->him->m_szResourceName, "role", "participant");
break;
case ROLE_MODERATOR:
- dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, L"nick", dat->him->m_tszResourceName, L"role", L"moderator");
+ dat->ppro->AdminSet(dat->item->jid, JABBER_FEAT_MUC_ADMIN, "nick", dat->him->m_szResourceName, "role", "moderator");
break;
}
}
@@ -975,7 +978,7 @@ static INT_PTR CALLBACK sttUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam
static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* gch)
{
- pResourceStatus me(item->findResource(item->nick)), him(item->findResource(gch->ptszUID));
+ pResourceStatus me(item->findResource(item->nick)), him(item->findResource(T2Utf(gch->ptszUID)));
if (him == nullptr || me == nullptr)
return;
@@ -986,8 +989,8 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK*
CMStringW szBuffer, szTitle;
if ((gch->dwData >= CLISTMENUIDMIN) && (gch->dwData <= CLISTMENUIDMAX)) {
- if (him->m_tszRealJid && *him->m_tszRealJid)
- if (MCONTACT hContact = ppro->HContactFromJID(him->m_tszRealJid))
+ if (him->m_szRealJid && *him->m_szRealJid)
+ if (MCONTACT hContact = ppro->HContactFromJID(him->m_szRealJid))
Clist_MenuProcessCommand(gch->dwData, MPCF_CONTACTMENU, hContact);
return;
}
@@ -995,36 +998,36 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK*
switch (gch->dwData) {
case IDM_SLAP:
if (ppro->m_bJabberOnline) {
- ptrW szMessage(ppro->getWStringA("GcMsgSlap"));
+ ptrA szMessage(ppro->getUStringA("GcMsgSlap"));
if (szMessage == nullptr)
- szMessage = mir_wstrdup(TranslateW(JABBER_GC_MSG_SLAP));
+ szMessage = mir_strdup(Translate(JABBER_GC_MSG_SLAP));
- wchar_t buf[256];
+ CMStringA buf;
// do not use snprintf to avoid possible problems with % symbol
- if (wchar_t *p = wcsstr(szMessage, L"%s")) {
+ if (char *p = strstr(szMessage, "%s")) {
*p = 0;
- mir_snwprintf(buf, L"%s%s%s", szMessage, him->m_tszResourceName, p + 2);
+ buf.Format("%s%s%s", szMessage, him->m_szResourceName, p + 2);
}
- else mir_wstrncpy(buf, szMessage, _countof(buf));
- Chat_UnescapeTags(buf);
+ else buf = szMessage;
+ buf.Replace("%%", "%");
ppro->m_ThreadInfo->send(
- XmlNode(L"message") << XATTR(L"to", item->jid) << XATTR(L"type", L"groupchat")
- << XCHILD(L"body", buf));
+ XmlNode("message") << XATTR("to", item->jid) << XATTR("type", "groupchat")
+ << XCHILD("body", buf));
}
break;
case IDM_VCARD:
{
- CMStringW jid(FORMAT, L"%s/%s", item->jid, him->m_tszResourceName);
+ CMStringA jid(FORMAT, "%s/%s", item->jid, him->m_szResourceName);
MCONTACT hContact = ppro->AddToListByJID(jid, PALF_TEMPORARY);
- ppro->setWString(hContact, "Nick", him->m_tszResourceName);
+ ppro->setUString(hContact, "Nick", him->m_szResourceName);
JABBER_LIST_ITEM *pTmp = ppro->ListAdd(LIST_VCARD_TEMP, jid, hContact);
- ppro->ListAddResource(LIST_VCARD_TEMP, jid, him->m_iStatus, him->m_tszStatusMessage, him->m_iPriority);
+ ppro->ListAddResource(LIST_VCARD_TEMP, jid, him->m_iStatus, him->m_szStatusMessage, him->m_iPriority);
- pTmp->findResource(him->m_tszResourceName)->m_pCaps = ppro->ListGetItemPtr(LIST_CHATROOM, item->jid)->findResource(him->m_tszResourceName)->m_pCaps;
+ pTmp->findResource(him->m_szResourceName)->m_pCaps = ppro->ListGetItemPtr(LIST_CHATROOM, item->jid)->findResource(him->m_szResourceName)->m_pCaps;
CallService(MS_USERINFO_SHOWDIALOG, hContact, 0);
}
@@ -1045,14 +1048,14 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK*
case IDM_KICK:
if ((GetTickCount() - dwLastBanKickTime) > BAN_KICK_INTERVAL) {
dwLastBanKickTime = GetTickCount();
- szBuffer.Format(L"%s: ", me->m_tszResourceName);
- szTitle.Format(TranslateT("Reason to kick %s"), him->m_tszResourceName);
- wchar_t *resourceName_copy = mir_wstrdup(him->m_tszResourceName); // copy resource name to prevent possible crash if user list rebuilds
+ szBuffer.Format(L"%s: ", me->m_szResourceName);
+ szTitle.Format(TranslateT("Reason to kick %s"), Utf2T(him->m_szResourceName).get());
+ char *resourceName_copy = mir_strdup(him->m_szResourceName); // copy resource name to prevent possible crash if user list rebuilds
if (ppro->EnterString(szBuffer, szTitle, ESF_MULTILINE, "gcReason_"))
ppro->m_ThreadInfo->send(
- XmlNodeIq(L"set", ppro->SerialNext(), item->jid) << XQUERY(JABBER_FEAT_MUC_ADMIN)
- << XCHILD(L"item") << XATTR(L"nick", resourceName_copy) << XATTR(L"role", L"none")
- << XCHILD(L"reason", szBuffer));
+ XmlNodeIq("set", ppro->SerialNext(), item->jid) << XQUERY(JABBER_FEAT_MUC_ADMIN)
+ << XCHILD("item") << XATTR("nick", resourceName_copy) << XATTR("role", "none")
+ << XCHILD("reason", T2Utf(szBuffer)));
mir_free(resourceName_copy);
}
@@ -1061,77 +1064,77 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK*
case IDM_SET_VISITOR:
if (him->m_role != ROLE_VISITOR)
- ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, L"nick", him->m_tszResourceName, L"role", L"visitor");
+ ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, "nick", him->m_szResourceName, "role", "visitor");
break;
case IDM_SET_PARTICIPANT:
if (him->m_role != ROLE_PARTICIPANT)
- ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, L"nick", him->m_tszResourceName, L"role", L"participant");
+ ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, "nick", him->m_szResourceName, "role", "participant");
break;
case IDM_SET_MODERATOR:
if (him->m_role != ROLE_MODERATOR)
- ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, L"nick", him->m_tszResourceName, L"role", L"moderator");
+ ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, "nick", him->m_szResourceName, "role", "moderator");
break;
case IDM_SET_NONE:
if (him->m_affiliation != AFFILIATION_NONE) {
- if (him->m_tszRealJid) {
- wchar_t szBareJid[JABBER_MAX_JID_LEN];
- JabberStripJid(him->m_tszRealJid, szBareJid, _countof(szBareJid));
- ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, L"jid", szBareJid, L"affiliation", L"none");
+ if (him->m_szRealJid) {
+ char szBareJid[JABBER_MAX_JID_LEN];
+ JabberStripJid(him->m_szRealJid, szBareJid, _countof(szBareJid));
+ ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, "jid", szBareJid, "affiliation", "none");
}
- else ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, L"nick", him->m_tszResourceName, L"affiliation", L"none");
+ else ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, "nick", him->m_szResourceName, "affiliation", "none");
}
break;
case IDM_SET_MEMBER:
if (him->m_affiliation != AFFILIATION_MEMBER) {
- if (him->m_tszRealJid) {
- wchar_t szBareJid[JABBER_MAX_JID_LEN];
- JabberStripJid(him->m_tszRealJid, szBareJid, _countof(szBareJid));
- ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, L"jid", szBareJid, L"affiliation", L"member");
+ if (him->m_szRealJid) {
+ char szBareJid[JABBER_MAX_JID_LEN];
+ JabberStripJid(him->m_szRealJid, szBareJid, _countof(szBareJid));
+ ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, "jid", szBareJid, "affiliation", "member");
}
- else ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, L"nick", him->m_tszResourceName, L"affiliation", L"member");
+ else ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, "nick", him->m_szResourceName, "affiliation", "member");
}
break;
case IDM_SET_ADMIN:
if (him->m_affiliation != AFFILIATION_ADMIN) {
- if (him->m_tszRealJid) {
- wchar_t szBareJid[JABBER_MAX_JID_LEN];
- JabberStripJid(him->m_tszRealJid, szBareJid, _countof(szBareJid));
- ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, L"jid", szBareJid, L"affiliation", L"admin");
+ if (him->m_szRealJid) {
+ char szBareJid[JABBER_MAX_JID_LEN];
+ JabberStripJid(him->m_szRealJid, szBareJid, _countof(szBareJid));
+ ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, "jid", szBareJid, "affiliation", "admin");
}
- else ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, L"nick", him->m_tszResourceName, L"affiliation", L"admin");
+ else ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, "nick", him->m_szResourceName, "affiliation", "admin");
}
break;
case IDM_SET_OWNER:
if (him->m_affiliation != AFFILIATION_OWNER) {
- if (him->m_tszRealJid) {
- wchar_t szBareJid[JABBER_MAX_JID_LEN];
- JabberStripJid(him->m_tszRealJid, szBareJid, _countof(szBareJid));
- ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, L"jid", szBareJid, L"affiliation", L"owner");
+ if (him->m_szRealJid) {
+ char szBareJid[JABBER_MAX_JID_LEN];
+ JabberStripJid(him->m_szRealJid, szBareJid, _countof(szBareJid));
+ ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, "jid", szBareJid, "affiliation", "owner");
}
- else ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, L"nick", him->m_tszResourceName, L"affiliation", L"owner");
+ else ppro->AdminSet(item->jid, JABBER_FEAT_MUC_ADMIN, "nick", him->m_szResourceName, "affiliation", "owner");
}
break;
case IDM_SET_BAN:
if ((GetTickCount() - dwLastBanKickTime) > BAN_KICK_INTERVAL) {
- if (him->m_tszRealJid && *him->m_tszRealJid) {
- wchar_t szVictimBareJid[JABBER_MAX_JID_LEN];
- JabberStripJid(him->m_tszRealJid, szVictimBareJid, _countof(szVictimBareJid));
+ if (him->m_szRealJid && *him->m_szRealJid) {
+ char szVictimBareJid[JABBER_MAX_JID_LEN];
+ JabberStripJid(him->m_szRealJid, szVictimBareJid, _countof(szVictimBareJid));
- szBuffer.Format(L"%s: ", me->m_tszResourceName);
- szTitle.Format(TranslateT("Reason to ban %s"), him->m_tszResourceName);
+ szBuffer.Format(L"%s: ", me->m_szResourceName);
+ szTitle.Format(TranslateT("Reason to ban %s"), him->m_szResourceName);
if (ppro->EnterString(szBuffer, szTitle, ESF_MULTILINE, "gcReason_"))
ppro->m_ThreadInfo->send(
- XmlNodeIq(L"set", ppro->SerialNext(), item->jid) << XQUERY(JABBER_FEAT_MUC_ADMIN)
- << XCHILD(L"item") << XATTR(L"jid", szVictimBareJid) << XATTR(L"affiliation", L"outcast")
- << XCHILD(L"reason", szBuffer));
+ XmlNodeIq("set", ppro->SerialNext(), item->jid) << XQUERY(JABBER_FEAT_MUC_ADMIN)
+ << XCHILD("item") << XATTR("jid", szVictimBareJid) << XATTR("affiliation", "outcast")
+ << XCHILD("reason", T2Utf(szBuffer)));
}
}
dwLastBanKickTime = GetTickCount();
@@ -1140,9 +1143,9 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK*
case IDM_LINK0: case IDM_LINK1: case IDM_LINK2: case IDM_LINK3: case IDM_LINK4:
case IDM_LINK5: case IDM_LINK6: case IDM_LINK7: case IDM_LINK8: case IDM_LINK9:
if ((GetTickCount() - dwLastBanKickTime) > BAN_KICK_INTERVAL) {
- wchar_t *resourceName_copy = NEWWSTR_ALLOCA(him->m_tszResourceName); // copy resource name to prevent possible crash if user list rebuilds
+ Utf2T resourceName_copy(him->m_szResourceName); // copy resource name to prevent possible crash if user list rebuilds
- wchar_t *szInviteTo = nullptr;
+ char *szInviteTo = nullptr;
int idx = gch->dwData - IDM_LINK0;
LISTFOREACH(i, ppro, LIST_CHATROOM)
{
@@ -1157,58 +1160,56 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK*
if (!szInviteTo) break;
- szTitle.Format(TranslateT("Invite %s to %s"), him->m_tszResourceName, szInviteTo);
+ szTitle.Format(TranslateT("Invite %s to %s"), Utf2T(him->m_szResourceName).get(), Utf2T(szInviteTo).get());
if (!ppro->EnterString(szBuffer, szTitle, ESF_MULTILINE))
break;
szTitle.Format(L"%s/%s", item->jid, resourceName_copy);
- XmlNode msg(L"message");
- msg << XATTR(L"to", szTitle) << XATTRID(ppro->SerialNext())
- << XCHILD(L"x", szBuffer) << XATTR(L"xmlns", JABBER_FEAT_DIRECT_MUC_INVITE) << XATTR(L"jid", szInviteTo)
- << XCHILD(L"invite") << XATTR(L"from", item->nick);
+ XmlNode msg("message");
+ msg << XATTR("to", T2Utf(szTitle)) << XATTRID(ppro->SerialNext())
+ << XCHILD("x", T2Utf(szBuffer)) << XATTR("xmlns", JABBER_FEAT_DIRECT_MUC_INVITE) << XATTR("jid", szInviteTo)
+ << XCHILD("invite") << XATTR("from", item->nick);
ppro->m_ThreadInfo->send(msg);
}
dwLastBanKickTime = GetTickCount();
break;
case IDM_CPY_NICK:
- JabberCopyText(g_clistApi.hwndContactList, him->m_tszResourceName);
+ JabberCopyText(g_clistApi.hwndContactList, Utf2T(him->m_szResourceName));
break;
case IDM_RJID_COPY:
case IDM_CPY_RJID:
- JabberCopyText(g_clistApi.hwndContactList, him->m_tszRealJid);
+ JabberCopyText(g_clistApi.hwndContactList, Utf2T(him->m_szRealJid));
break;
case IDM_CPY_INROOMJID:
- szBuffer.Format(L"%s/%s", item->jid, him->m_tszResourceName);
- JabberCopyText(g_clistApi.hwndContactList, szBuffer);
+ JabberCopyText(g_clistApi.hwndContactList, CMStringW(FORMAT, L"%s/%s", Utf2T(item->jid).get(), Utf2T(him->m_szResourceName).get()));
break;
case IDM_RJID_VCARD:
- if (him->m_tszRealJid && *him->m_tszRealJid) {
- wchar_t *jid = NEWWSTR_ALLOCA(him->m_tszRealJid);
- if (wchar_t *tmp = wcschr(jid, '/'))
+ if (him->m_szRealJid && *him->m_szRealJid) {
+ char *jid = NEWSTR_ALLOCA(him->m_szRealJid);
+ if (char *tmp = strchr(jid, '/'))
*tmp = 0;
MCONTACT hContact = ppro->AddToListByJID(jid, PALF_TEMPORARY);
ppro->ListAdd(LIST_VCARD_TEMP, jid, hContact);
- ppro->ListAddResource(LIST_VCARD_TEMP, jid, him->m_iStatus, him->m_tszStatusMessage, him->m_iPriority);
+ ppro->ListAddResource(LIST_VCARD_TEMP, jid, him->m_iStatus, him->m_szStatusMessage, him->m_iPriority);
CallService(MS_USERINFO_SHOWDIALOG, hContact, 0);
}
break;
case IDM_RJID_ADD:
- if (him->m_tszRealJid && *him->m_tszRealJid) {
+ if (him->m_szRealJid && *him->m_szRealJid) {
PROTOSEARCHRESULT psr = { 0 };
psr.cbSize = sizeof(psr);
- psr.flags = PSR_UNICODE;
- psr.id.w = NEWWSTR_ALLOCA(him->m_tszRealJid);
- if (wchar_t *tmp = wcschr(psr.id.w, '/'))
+ psr.id.a = NEWSTR_ALLOCA(him->m_szRealJid);
+ if (char *tmp = strchr(psr.id.a, '/'))
*tmp = 0;
- psr.nick.w = psr.id.w;
+ psr.nick.a = psr.id.a;
Contact_AddBySearch(ppro->m_szModuleName, &psr, g_clistApi.hwndContactList);
}
break;
@@ -1218,39 +1219,40 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK*
static void sttLogListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* gch)
{
CMStringW szBuffer, szTitle;
+ T2Utf roomJid(gch->ptszID);
switch (gch->dwData) {
case IDM_LST_PARTICIPANT:
- ppro->AdminGet(gch->ptszID, JABBER_FEAT_MUC_ADMIN, L"role", L"participant", &CJabberProto::OnIqResultMucGetVoiceList);
+ ppro->AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, "role", "participant", &CJabberProto::OnIqResultMucGetVoiceList);
break;
case IDM_LST_MEMBER:
- ppro->AdminGet(gch->ptszID, JABBER_FEAT_MUC_ADMIN, L"affiliation", L"member", &CJabberProto::OnIqResultMucGetMemberList);
+ ppro->AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, "affiliation", "member", &CJabberProto::OnIqResultMucGetMemberList);
break;
case IDM_LST_MODERATOR:
- ppro->AdminGet(gch->ptszID, JABBER_FEAT_MUC_ADMIN, L"role", L"moderator", &CJabberProto::OnIqResultMucGetModeratorList);
+ ppro->AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, "role", "moderator", &CJabberProto::OnIqResultMucGetModeratorList);
break;
case IDM_LST_BAN:
- ppro->AdminGet(gch->ptszID, JABBER_FEAT_MUC_ADMIN, L"affiliation", L"outcast", &CJabberProto::OnIqResultMucGetBanList);
+ ppro->AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, "affiliation", "outcast", &CJabberProto::OnIqResultMucGetBanList);
break;
case IDM_LST_ADMIN:
- ppro->AdminGet(gch->ptszID, JABBER_FEAT_MUC_ADMIN, L"affiliation", L"admin", &CJabberProto::OnIqResultMucGetAdminList);
+ ppro->AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, "affiliation", "admin", &CJabberProto::OnIqResultMucGetAdminList);
break;
case IDM_LST_OWNER:
- ppro->AdminGet(gch->ptszID, JABBER_FEAT_MUC_ADMIN, L"affiliation", L"owner", &CJabberProto::OnIqResultMucGetOwnerList);
+ ppro->AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, "affiliation", "owner", &CJabberProto::OnIqResultMucGetOwnerList);
break;
case IDM_TOPIC:
szTitle.Format(TranslateT("Set topic for %s"), gch->ptszID);
- szBuffer = item->getTemp()->m_tszStatusMessage;
+ szBuffer = item->getTemp()->m_szStatusMessage;
szBuffer.Replace(L"\n", L"\r\n");
if (ppro->EnterString(szBuffer, szTitle, ESF_RICHEDIT, "gcTopic_"))
ppro->m_ThreadInfo->send(
- XmlNode(L"message") << XATTR(L"to", gch->ptszID) << XATTR(L"type", L"groupchat") << XCHILD(L"subject", szBuffer));
+ XmlNode("message") << XATTR("to", roomJid) << XATTR("type", "groupchat") << XCHILD("subject", T2Utf(szBuffer)));
break;
case IDM_NICK:
@@ -1258,30 +1260,30 @@ static void sttLogListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* g
if (item->nick)
szBuffer = item->nick;
if (ppro->EnterString(szBuffer, szTitle, ESF_COMBO, "gcNick_")) {
- if (ppro->ListGetItemPtr(LIST_CHATROOM, gch->ptszID) != nullptr) {
- wchar_t text[1024];
- mir_snwprintf(text, L"%s/%s", gch->ptszID, szBuffer.c_str());
+ if (ppro->ListGetItemPtr(LIST_CHATROOM, roomJid) != nullptr) {
+ char text[1024];
+ mir_snprintf(text, "%s/%s", roomJid.get(), szBuffer.c_str());
ppro->SendPresenceTo(ppro->m_iStatus == ID_STATUS_INVISIBLE ? ID_STATUS_ONLINE : ppro->m_iStatus, text, nullptr);
}
}
break;
case IDM_INVITE:
- (new CGroupchatInviteDlg(ppro, gch->ptszID))->Show();
+ (new CGroupchatInviteDlg(ppro, roomJid))->Show();
break;
case IDM_CONFIG:
ppro->m_ThreadInfo->send(
- XmlNodeIq(ppro->AddIQ(&CJabberProto::OnIqResultGetMuc, JABBER_IQ_TYPE_GET, gch->ptszID))
+ XmlNodeIq(ppro->AddIQ(&CJabberProto::OnIqResultGetMuc, JABBER_IQ_TYPE_GET, roomJid))
<< XQUERY(JABBER_FEAT_MUC_OWNER));
break;
case IDM_BOOKMARKS:
- item = ppro->ListGetItemPtr(LIST_BOOKMARK, gch->ptszID);
+ item = ppro->ListGetItemPtr(LIST_BOOKMARK, roomJid);
if (item == nullptr) {
- item = ppro->ListGetItemPtr(LIST_CHATROOM, gch->ptszID);
+ item = ppro->ListGetItemPtr(LIST_CHATROOM, roomJid);
if (item != nullptr) {
- item->type = L"conference";
+ item->type = "conference";
MCONTACT hContact = ppro->HContactFromJID(item->jid);
item->name = Clist_GetContactDisplayName(hContact);
ppro->AddEditBookmark(item);
@@ -1293,8 +1295,8 @@ static void sttLogListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* g
szTitle.Format(TranslateT("Reason to destroy %s"), gch->ptszID);
if (ppro->EnterString(szBuffer, szTitle, ESF_MULTILINE, "gcReason_"))
ppro->m_ThreadInfo->send(
- XmlNodeIq(L"set", ppro->SerialNext(), gch->ptszID) << XQUERY(JABBER_FEAT_MUC_OWNER)
- << XCHILD(L"destroy") << XCHILD(L"reason", szBuffer));
+ XmlNodeIq("set", ppro->SerialNext(), roomJid) << XQUERY(JABBER_FEAT_MUC_OWNER)
+ << XCHILD("destroy") << XCHILD("reason", T2Utf(szBuffer)));
__fallthrough;
case IDM_LEAVE:
@@ -1314,9 +1316,9 @@ static void sttLogListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* g
case IDM_LINK5: case IDM_LINK6: case IDM_LINK7: case IDM_LINK8: case IDM_LINK9:
{
int idx = IDM_LINK0;
- for (wchar_t *p = wcsstr(item->getTemp()->m_tszStatusMessage, L"http://"); p && *p; p = wcsstr(p + 1, L"http://")) {
+ for (char *p = strstr(item->getTemp()->m_szStatusMessage, "http://"); p && *p; p = strstr(p + 1, "http://")) {
if (idx == gch->dwData) {
- char *bufPtr, *url = mir_u2a(p);
+ char *bufPtr, *url = mir_strdup(p);
for (bufPtr = url; *bufPtr && !isspace(*bufPtr); ++bufPtr);
*bufPtr++ = 0;
Utils_OpenUrl(url);
@@ -1330,11 +1332,11 @@ static void sttLogListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* g
break;
case IDM_CPY_RJID:
- JabberCopyText(g_clistApi.hwndContactList, item->jid);
+ JabberCopyText(g_clistApi.hwndContactList, Utf2T(item->jid));
break;
case IDM_CPY_TOPIC:
- JabberCopyText(g_clistApi.hwndContactList, item->getTemp()->m_tszStatusMessage);
+ JabberCopyText(g_clistApi.hwndContactList, Utf2T(item->getTemp()->m_szStatusMessage));
break;
}
}
@@ -1342,10 +1344,10 @@ static void sttLogListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* g
/////////////////////////////////////////////////////////////////////////////////////////
// Sends a private message to a chat user
-static void sttSendPrivateMessage(CJabberProto *ppro, JABBER_LIST_ITEM *item, const wchar_t *nick)
+static void sttSendPrivateMessage(CJabberProto *ppro, JABBER_LIST_ITEM *item, const char *nick)
{
- wchar_t szFullJid[JABBER_MAX_JID_LEN];
- mir_snwprintf(szFullJid, L"%s/%s", item->jid, nick);
+ char szFullJid[JABBER_MAX_JID_LEN];
+ mir_snprintf(szFullJid, "%s/%s", item->jid, nick);
MCONTACT hContact = ppro->DBCreateContact(szFullJid, nullptr, true, false);
if (hContact != 0) {
pResourceStatus r(item->findResource(nick));
@@ -1353,7 +1355,7 @@ static void sttSendPrivateMessage(CJabberProto *ppro, JABBER_LIST_ITEM *item, co
ppro->setWord(hContact, "Status", r->m_iStatus);
db_set_b(hContact, "CList", "Hidden", 1);
- ppro->setWString(hContact, "Nick", nick);
+ ppro->setUString(hContact, "Nick", nick);
db_set_dw(hContact, "Ignore", "Mask1", 0);
CallService(MS_MSG_SENDMESSAGE, hContact, 0);
}
@@ -1371,7 +1373,8 @@ int CJabberProto::JabberGcEventHook(WPARAM, LPARAM lParam)
if (mir_strcmpi(gch->pszModule, m_szModuleName))
return 0;
- JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, gch->ptszID);
+ T2Utf roomJid(gch->ptszID);
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, roomJid);
if (item == nullptr)
return 0;
@@ -1381,20 +1384,21 @@ int CJabberProto::JabberGcEventHook(WPARAM, LPARAM lParam)
rtrimw(gch->ptszText);
if (m_bJabberOnline) {
- wchar_t tszID[100];
+ char szId[100];
int64_t id = (_time64(nullptr) << 16) + (GetTickCount() & 0xFFFF);
+ _i64toa(id, szId, 36);
wchar_t *buf = NEWWSTR_ALLOCA(gch->ptszText);
Chat_UnescapeTags(buf);
m_ThreadInfo->send(
- XmlNode(L"message") << XATTR(L"id", _i64tot(id, tszID, 36)) << XATTR(L"to", item->jid) << XATTR(L"type", L"groupchat")
- << XCHILD(L"body", buf));
+ XmlNode("message") << XATTR("id", szId) << XATTR("to", item->jid) << XATTR("type", "groupchat")
+ << XCHILD("body", T2Utf(buf)));
}
}
break;
case GC_USER_PRIVMESS:
- sttSendPrivateMessage(this, item, gch->ptszUID);
+ sttSendPrivateMessage(this, item, roomJid);
break;
case GC_USER_LOGMENU:
@@ -1417,69 +1421,67 @@ int CJabberProto::JabberGcEventHook(WPARAM, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////////////
-void CJabberProto::AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const wchar_t* str, const wchar_t* rsn)
+void CJabberProto::AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const char *str, const char *rsn)
{
- const wchar_t *field = (jidListInfo->type == MUC_BANLIST || wcschr(str, '@')) ? L"jid" : L"nick";
- wchar_t *roomJid = jidListInfo->roomJid;
+ const char *field = (jidListInfo->type == MUC_BANLIST || strchr(str, '@')) ? "jid" : "nick";
+ char *roomJid = jidListInfo->roomJid;
if (jidListInfo->type == MUC_BANLIST) {
- AdminSetReason(roomJid, JABBER_FEAT_MUC_ADMIN, field, str, L"affiliation", L"outcast", rsn);
- AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, L"affiliation", L"outcast", &CJabberProto::OnIqResultMucGetBanList);
+ AdminSetReason(roomJid, JABBER_FEAT_MUC_ADMIN, field, str, "affiliation", "outcast", rsn);
+ AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, "affiliation", "outcast", &CJabberProto::OnIqResultMucGetBanList);
}
}
-void CJabberProto::AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const wchar_t* str)
+void CJabberProto::AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const char *str)
{
- const wchar_t *field = (jidListInfo->type == MUC_BANLIST || wcschr(str, '@')) ? L"jid" : L"nick";
- wchar_t *roomJid = jidListInfo->roomJid;
+ const char *field = (jidListInfo->type == MUC_BANLIST || strchr(str, '@')) ? "jid" : "nick";
+ char *roomJid = jidListInfo->roomJid;
switch (jidListInfo->type) {
case MUC_VOICELIST:
- AdminSet(roomJid, JABBER_FEAT_MUC_ADMIN, field, str, L"role", L"participant");
- AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, L"role", L"participant", &CJabberProto::OnIqResultMucGetVoiceList);
+ AdminSet(roomJid, JABBER_FEAT_MUC_ADMIN, field, str, "role", "participant");
+ AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, "role", "participant", &CJabberProto::OnIqResultMucGetVoiceList);
break;
case MUC_MEMBERLIST:
- AdminSet(roomJid, JABBER_FEAT_MUC_ADMIN, field, str, L"affiliation", L"member");
- AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, L"affiliation", L"member", &CJabberProto::OnIqResultMucGetMemberList);
+ AdminSet(roomJid, JABBER_FEAT_MUC_ADMIN, field, str, "affiliation", "member");
+ AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, "affiliation", "member", &CJabberProto::OnIqResultMucGetMemberList);
break;
case MUC_MODERATORLIST:
- AdminSet(roomJid, JABBER_FEAT_MUC_ADMIN, field, str, L"role", L"moderator");
- AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, L"role", L"moderator", &CJabberProto::OnIqResultMucGetModeratorList);
+ AdminSet(roomJid, JABBER_FEAT_MUC_ADMIN, field, str, "role", "moderator");
+ AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, "role", "moderator", &CJabberProto::OnIqResultMucGetModeratorList);
break;
case MUC_BANLIST:
- AdminSet(roomJid, JABBER_FEAT_MUC_ADMIN, field, str, L"affiliation", L"outcast");
- AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, L"affiliation", L"outcast", &CJabberProto::OnIqResultMucGetBanList);
+ AdminSet(roomJid, JABBER_FEAT_MUC_ADMIN, field, str, "affiliation", "outcast");
+ AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, "affiliation", "outcast", &CJabberProto::OnIqResultMucGetBanList);
break;
case MUC_ADMINLIST:
- AdminSet(roomJid, JABBER_FEAT_MUC_ADMIN, field, str, L"affiliation", L"admin");
- AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, L"affiliation", L"admin", &CJabberProto::OnIqResultMucGetAdminList);
+ AdminSet(roomJid, JABBER_FEAT_MUC_ADMIN, field, str, "affiliation", "admin");
+ AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, "affiliation", "admin", &CJabberProto::OnIqResultMucGetAdminList);
break;
case MUC_OWNERLIST:
- AdminSet(roomJid, JABBER_FEAT_MUC_ADMIN, field, str, L"affiliation", L"owner");
- AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, L"affiliation", L"owner", &CJabberProto::OnIqResultMucGetOwnerList);
+ AdminSet(roomJid, JABBER_FEAT_MUC_ADMIN, field, str, "affiliation", "owner");
+ AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, "affiliation", "owner", &CJabberProto::OnIqResultMucGetOwnerList);
break;
}
}
-void CJabberProto::DeleteMucListItem(JABBER_MUC_JIDLIST_INFO *jidListInfo, const wchar_t *jid)
+void CJabberProto::DeleteMucListItem(JABBER_MUC_JIDLIST_INFO *jidListInfo, const char *jid)
{
- wchar_t *roomJid = jidListInfo->roomJid;
-
switch (jidListInfo->type) {
case MUC_VOICELIST: // change role to visitor (from participant)
- AdminSet(roomJid, JABBER_FEAT_MUC_ADMIN, L"jid", jid, L"role", L"visitor");
+ AdminSet(jidListInfo->roomJid, JABBER_FEAT_MUC_ADMIN, "jid", jid, "role", "visitor");
break;
case MUC_BANLIST: // change affiliation to none (from outcast)
case MUC_MEMBERLIST: // change affiliation to none (from member)
- AdminSet(roomJid, JABBER_FEAT_MUC_ADMIN, L"jid", jid, L"affiliation", L"none");
+ AdminSet(jidListInfo->roomJid, JABBER_FEAT_MUC_ADMIN, "jid", jid, "affiliation", "none");
break;
case MUC_MODERATORLIST: // change role to participant (from moderator)
- AdminSet(roomJid, JABBER_FEAT_MUC_ADMIN, L"jid", jid, L"role", L"participant");
+ AdminSet(jidListInfo->roomJid, JABBER_FEAT_MUC_ADMIN, "jid", jid, "role", "participant");
break;
case MUC_ADMINLIST: // change affiliation to member (from admin)
- AdminSet(roomJid, JABBER_FEAT_MUC_ADMIN, L"jid", jid, L"affiliation", L"member");
+ AdminSet(jidListInfo->roomJid, JABBER_FEAT_MUC_ADMIN, "jid", jid, "affiliation", "member");
break;
case MUC_OWNERLIST: // change affiliation to admin (from owner)
- AdminSet(roomJid, JABBER_FEAT_MUC_ADMIN, L"jid", jid, L"affiliation", L"admin");
+ AdminSet(jidListInfo->roomJid, JABBER_FEAT_MUC_ADMIN, "jid", jid, "affiliation", "admin");
break;
}
}
diff --git a/protocols/JabberG/src/jabber_console.cpp b/protocols/JabberG/src/jabber_console.cpp
index a10d4dcef4..733a2a1c89 100644
--- a/protocols/JabberG/src/jabber_console.cpp
+++ b/protocols/JabberG/src/jabber_console.cpp
@@ -78,12 +78,12 @@ static void sttEmptyBuf(StringBuf *buf);
#define RTF_ENDPLAINXML "\\par"
#define RTF_SEPARATOR "\\sl-1\\slmult0\\highlight5\\cf5\\-\\par\\sl0"
-static void sttRtfAppendXml(StringBuf *buf, HXML node, DWORD flags, int indent);
+static void sttRtfAppendXml(StringBuf *buf, const TiXmlElement *node, DWORD flags, int indent);
-void CJabberProto::OnConsoleProcessXml(HXML node, DWORD flags)
+void CJabberProto::OnConsoleProcessXml(const TiXmlElement *node, DWORD flags)
{
if (node && m_pDlgConsole) {
- if (XmlGetName(node)) {
+ if (node->Name()) {
if (FilterXml(node, flags)) {
StringBuf buf = {};
sttAppendBufRaw(&buf, RTF_HEADER);
@@ -95,48 +95,46 @@ void CJabberProto::OnConsoleProcessXml(HXML node, DWORD flags)
}
}
else {
- for (int i=0; i < XmlGetChildCount(node); i++)
- OnConsoleProcessXml(XmlGetChild(node, i), flags);
+ for (auto *it : TiXmlEnum(node))
+ OnConsoleProcessXml(it, flags);
}
}
}
-bool CJabberProto::RecursiveCheckFilter(HXML node, DWORD flags)
+bool CJabberProto::RecursiveCheckFilter(const TiXmlElement *node, DWORD flags)
{
- for (int i = 0; i < XmlGetAttrCount(node); i++)
- if (JabberStrIStr(XmlGetAttr(node, i), m_filterInfo.pattern))
- return true;
+ // !!!!!!!!!!!!!!!!for (int i = 0; i < node->Attribute); i++)
+ // !!!!!!!!!!!!!!!! if (JabberStrIStr(XmlGetAttr(node, i), m_filterInfo.pattern))
+ // !!!!!!!!!!!!!!!! return true;
- for (int i = 0; i < XmlGetChildCount(node); i++)
- if (RecursiveCheckFilter(XmlGetChild(node, i), flags))
+ for (auto *it : TiXmlEnum(node))
+ if (RecursiveCheckFilter(it, flags))
return true;
return false;
}
-bool CJabberProto::FilterXml(HXML node, DWORD flags)
+bool CJabberProto::FilterXml(const TiXmlElement *node, DWORD flags)
{
- if (!m_filterInfo.msg && !mir_wstrcmp(XmlGetName(node), L"message")) return false;
- if (!m_filterInfo.presence && !mir_wstrcmp(XmlGetName(node), L"presence")) return false;
- if (!m_filterInfo.iq && !mir_wstrcmp(XmlGetName(node), L"iq")) return false;
+ if (!m_filterInfo.msg && !mir_strcmp(node->Name(), "message")) return false;
+ if (!m_filterInfo.presence && !mir_strcmp(node->Name(), "presence")) return false;
+ if (!m_filterInfo.iq && !mir_strcmp(node->Name(), "iq")) return false;
if (m_filterInfo.type == TFilterInfo::T_OFF) return true;
mir_cslock lck(m_filterInfo.csPatternLock);
- const wchar_t *attrValue;
+ const char *attrValue;
switch (m_filterInfo.type) {
case TFilterInfo::T_JID:
- attrValue = XmlGetAttrValue(node, (flags & JCPF_OUT) ? L"to" : L"from");
+ attrValue = node->Attribute((flags & JCPF_OUT) ? "to" : "from");
if (attrValue)
- return JabberStrIStr(attrValue, m_filterInfo.pattern) != nullptr;
+ return JabberStrIStr(Utf2T(attrValue), m_filterInfo.pattern) != nullptr;
break;
case TFilterInfo::T_XMLNS:
- if (XmlGetChildCount(node)) {
- attrValue = XmlGetAttrValue(XmlGetChild(node, 0), L"xmlns");
- if (attrValue)
- return JabberStrIStr(attrValue, m_filterInfo.pattern) != nullptr;
- }
+ attrValue = node->FirstChildElement(0)->Attribute("xmlns");
+ if (attrValue)
+ return JabberStrIStr(Utf2T(attrValue), m_filterInfo.pattern) != nullptr;
break;
case TFilterInfo::T_ANY:
@@ -191,10 +189,10 @@ static void sttEmptyBuf(StringBuf *buf)
buf->offset = 0;
}
-static void sttRtfAppendXml(StringBuf *buf, HXML node, DWORD flags, int indent)
+static void sttRtfAppendXml(StringBuf *buf, const TiXmlElement *node, DWORD flags, int indent)
{
char indentLevel[128];
- mir_snprintf(indentLevel, RTF_INDENT_FMT, (int)(indent*200));
+ mir_snprintf(indentLevel, RTF_INDENT_FMT, (int)(indent * 200));
sttAppendBufRaw(buf, RTF_BEGINTAG);
sttAppendBufRaw(buf, indentLevel);
@@ -202,10 +200,11 @@ static void sttRtfAppendXml(StringBuf *buf, HXML node, DWORD flags, int indent)
if (flags&JCPF_OUT) sttAppendBufRaw(buf, "\\highlight4 ");
sttAppendBufRaw(buf, "<");
sttAppendBufRaw(buf, RTF_BEGINTAGNAME);
- sttAppendBufW(buf, (wchar_t*)XmlGetName(node));
+ sttAppendBufRaw(buf, node->Name());
sttAppendBufRaw(buf, RTF_ENDTAGNAME);
- for (int i = 0; i < XmlGetAttrCount(node); i++) {
+ // !!!!!!!!!!!!!!!!
+ /*for (int i = 0; i < XmlGetAttrCount(node); i++) {
wchar_t *attr = (wchar_t*)xmlGetAttrName(node, i);
sttAppendBufRaw(buf, " ");
sttAppendBufRaw(buf, RTF_BEGINATTRNAME);
@@ -217,35 +216,36 @@ static void sttRtfAppendXml(StringBuf *buf, HXML node, DWORD flags, int indent)
sttAppendBufRaw(buf, "\"");
sttAppendBufRaw(buf, RTF_ENDATTRVAL);
}
+ */
- if (XmlGetChild(node) || XmlGetText(node)) {
+ if (!node->NoChildren() || node->GetText()) {
sttAppendBufRaw(buf, ">");
- if (XmlGetChild(node))
+ if (!node->NoChildren())
sttAppendBufRaw(buf, RTF_ENDTAG);
}
- if (XmlGetText(node)) {
- if (XmlGetChildCount(node)) {
+ if (node->GetText()) {
+ if (!node->NoChildren()) {
sttAppendBufRaw(buf, RTF_BEGINTEXT);
char indentTextLevel[128];
mir_snprintf(indentTextLevel, RTF_TEXTINDENT_FMT, (int)((indent + 1) * 200));
sttAppendBufRaw(buf, indentTextLevel);
}
- sttAppendBufT(buf, XmlGetText(node));
- if (XmlGetChild(node))
+ sttAppendBufT(buf, Utf2T(node->GetText()));
+ if (!node->NoChildren())
sttAppendBufRaw(buf, RTF_ENDTEXT);
}
- for (int i = 0; i < XmlGetChildCount(node); i++)
- sttRtfAppendXml(buf, XmlGetChild(node, i), flags & ~(JCPF_IN | JCPF_OUT), indent + 1);
+ for (auto *it : TiXmlEnum(node))
+ sttRtfAppendXml(buf, it, flags & ~(JCPF_IN | JCPF_OUT), indent + 1);
- if (XmlGetChildCount(node) || XmlGetText(node)) {
+ if (!node->NoChildren() || node->GetText()) {
sttAppendBufRaw(buf, RTF_BEGINTAG);
sttAppendBufRaw(buf, indentLevel);
sttAppendBufRaw(buf, "</");
sttAppendBufRaw(buf, RTF_BEGINTAGNAME);
- sttAppendBufT(buf, XmlGetName(node));
+ sttAppendBufRaw(buf, node->Name());
sttAppendBufRaw(buf, RTF_ENDTAGNAME);
sttAppendBufRaw(buf, ">");
}
@@ -311,7 +311,7 @@ static filter_modes[] =
{ TFilterInfo::T_OFF, L"disabled", "sd_filter_reset" },
};
-class CJabberDlgConsole: public CJabberDlgBase
+class CJabberDlgConsole : public CJabberDlgBase
{
typedef CJabberDlgBase CSuper;
@@ -328,7 +328,7 @@ protected:
void OnProtoRefresh(WPARAM wParam, LPARAM lParam);
};
-CJabberDlgConsole::CJabberDlgConsole(CJabberProto *proto):
+CJabberDlgConsole::CJabberDlgConsole(CJabberProto *proto) :
CJabberDlgBase(proto, IDD_CONSOLE)
{
}
@@ -347,7 +347,7 @@ bool CJabberDlgConsole::OnInitDialog()
m_proto->m_filterInfo.type = (TFilterInfo::Type)m_proto->getByte("consoleWnd_ftype", TFilterInfo::T_OFF);
*m_proto->m_filterInfo.pattern = 0;
- ptrW tszPattern( m_proto->getWStringA("consoleWnd_fpattern"));
+ ptrW tszPattern(m_proto->getWStringA("consoleWnd_fpattern"));
if (tszPattern != nullptr)
mir_wstrncpy(m_proto->m_filterInfo.pattern, tszPattern, _countof(m_proto->m_filterInfo.pattern));
@@ -427,11 +427,11 @@ void CJabberDlgConsole::OnProtoRefresh(WPARAM, LPARAM lParam)
StringBuf *buf = (StringBuf *)lParam;
buf->streamOffset = 0;
- EDITSTREAM es = {0};
+ EDITSTREAM es = { 0 };
es.dwCookie = (DWORD_PTR)buf;
es.pfnCallback = sttStreamInCallback;
- SCROLLINFO si = {0};
+ SCROLLINFO si = { 0 };
si.cbSize = sizeof(si);
si.fMask = SIF_ALL;
GetScrollInfo(GetDlgItem(m_hwnd, IDC_CONSOLE), SB_VERT, &si);
@@ -442,7 +442,7 @@ void CJabberDlgConsole::OnProtoRefresh(WPARAM, LPARAM lParam)
SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_EXGETSEL, 0, (LPARAM)&oldSel);
sel.cpMin = sel.cpMax = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_CONSOLE));
SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_EXSETSEL, 0, (LPARAM)&sel);
- SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_STREAMIN, SF_RTF|SFF_SELECTION, (LPARAM)&es);
+ SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_STREAMIN, SF_RTF | SFF_SELECTION, (LPARAM)&es);
SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_EXSETSEL, 0, (LPARAM)&oldSel);
// magic expression from tabsrmm :)
@@ -508,10 +508,9 @@ INT_PTR CJabberDlgConsole::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
wchar_t *textToSend = (wchar_t *)mir_alloc(length * sizeof(wchar_t));
GetDlgItemText(m_hwnd, IDC_CONSOLEIN, textToSend, length);
- int bytesProcessed = 0;
- XmlNode xmlTmp(textToSend, &bytesProcessed, nullptr);
- if (xmlTmp)
- m_proto->m_ThreadInfo->send(xmlTmp);
+ TiXmlDocument doc;
+ if (0 == doc.Parse(T2Utf(textToSend)))
+ m_proto->m_ThreadInfo->send(doc.ToElement());
else {
StringBuf buf = {};
sttAppendBufRaw(&buf, RTF_HEADER);
diff --git a/protocols/JabberG/src/jabber_disco.cpp b/protocols/JabberG/src/jabber_disco.cpp
index 388fd030c6..ed9898f5e1 100644
--- a/protocols/JabberG/src/jabber_disco.cpp
+++ b/protocols/JabberG/src/jabber_disco.cpp
@@ -54,120 +54,58 @@ enum { SD_OVERLAY_NONE, SD_OVERLAY_FAIL, SD_OVERLAY_PROGRESS, SD_OVERLAY_REGISTE
static struct
{
- wchar_t *feature;
- wchar_t *category;
- wchar_t *type;
+ char *feature;
+ char *category;
+ char *type;
char *iconName;
int iconIndex;
int listIndex;
} sttNodeIcons[] =
{
// standard identities: http://www.xmpp.org/registrar/disco-categories.html#directory
- // {nullptr, L"account", L"admin", nullptr, 0},
- // {nullptr, L"account", L"anonymous", nullptr, 0},
- // {nullptr, L"account", L"registered", nullptr, 0},
- {nullptr, L"account", nullptr, nullptr, SKINICON_STATUS_ONLINE},
-
- // {nullptr, L"auth", L"cert", nullptr, 0},
- // {nullptr, L"auth", L"generic", nullptr, 0},
- // {nullptr, L"auth", L"ldap", nullptr, 0},
- // {nullptr, L"auth", L"ntlm", nullptr, 0},
- // {nullptr, L"auth", L"pam", nullptr, 0},
- // {nullptr, L"auth", L"radius", nullptr, 0},
- {nullptr, L"auth", nullptr, "key", 0},
-
- /// {nullptr, L"automation", L"command-list", nullptr, 0},
- /// {nullptr, L"automation", L"command-node", nullptr, 0},
- // {nullptr, L"automation", L"rpc", nullptr, 0},
- // {nullptr, L"automation", L"soap", nullptr, 0},
- {nullptr, L"automation", nullptr, "adhoc", 0},
-
- // {nullptr, L"client", L"bot", nullptr, 0},
- // {nullptr, L"client", L"console", nullptr, 0},
- // {nullptr, L"client", L"handheld", nullptr, 0},
- // {nullptr, L"client", L"pc", nullptr, 0},
- // {nullptr, L"client", L"phone", nullptr, 0},
- // {nullptr, L"client", L"web", nullptr, 0},
- {nullptr, L"client", nullptr, nullptr, SKINICON_STATUS_ONLINE},
-
- // {nullptr, L"collaboration", L"whiteboard", nullptr, 0},
- {nullptr, L"collaboration", nullptr, "group", 0},
-
- // {nullptr, L"component", L"archive", nullptr, 0},
- // {nullptr, L"component", L"c2s", nullptr, 0},
- // {nullptr, L"component", L"generic", nullptr, 0},
- // {nullptr, L"component", L"load", nullptr, 0},
- // {nullptr, L"component", L"log", nullptr, 0},
- // {nullptr, L"component", L"presence", nullptr, 0},
- // {nullptr, L"component", L"router", nullptr, 0},
- // {nullptr, L"component", L"s2s", nullptr, 0},
- // {nullptr, L"component", L"sm", nullptr, 0},
- // {nullptr, L"component", L"stats", nullptr, 0},
-
- // {nullptr, L"conference", L"irc", nullptr, 0},
- // {nullptr, L"conference", L"text", nullptr, 0},
- {nullptr, L"conference", nullptr, "group", 0},
-
- {nullptr, L"directory", L"chatroom", "group", 0},
- {nullptr, L"directory", L"group", "group", 0},
- {nullptr, L"directory", L"user", nullptr, SKINICON_OTHER_FINDUSER},
- // {nullptr, L"directory", L"waitinglist", nullptr, 0},
- {nullptr, L"directory", nullptr, nullptr, SKINICON_OTHER_SEARCHALL},
-
- {nullptr, L"gateway", L"aim", "AIM", SKINICON_STATUS_ONLINE},
- {nullptr, L"gateway", L"gadu-gadu", "GG", SKINICON_STATUS_ONLINE},
- // {nullptr, L"gateway", L"http-ws", NUL, 0},
- {nullptr, L"gateway", L"icq", "ICQ", SKINICON_STATUS_ONLINE},
- {nullptr, L"gateway", L"msn", "MSN", SKINICON_STATUS_ONLINE},
- {nullptr, L"gateway", L"qq", "QQ", SKINICON_STATUS_ONLINE},
- // {nullptr, L"gateway", L"sms", nullptr, 0},
- // {nullptr, L"gateway", L"smtp", nullptr, 0},
- {nullptr, L"gateway", L"tlen", "TLEN", SKINICON_STATUS_ONLINE},
- {nullptr, L"gateway", L"yahoo", "YAHOO", SKINICON_STATUS_ONLINE},
- {nullptr, L"gateway", nullptr, "Agents", 0},
-
- // {nullptr, L"headline", L"newmail", nullptr, 0},
- {nullptr, L"headline", L"rss", "node_rss", 0},
- {nullptr, L"headline", L"weather", "node_weather", 0},
-
- // {nullptr, L"hierarchy", L"branch", nullptr, 0},
- // {nullptr, L"hierarchy", L"leaf", nullptr, 0},
-
- // {nullptr, L"proxy", L"bytestreams", nullptr, 0},
- {nullptr, L"proxy", nullptr, nullptr, SKINICON_EVENT_FILE},
-
- // {nullptr, L"pubsub", L"collection", nullptr, 0},
- // {nullptr, L"pubsub", L"leaf", nullptr, 0},
- // {nullptr, L"pubsub", L"pep", nullptr, 0},
- // {nullptr, L"pubsub", L"service", nullptr, 0},
-
- // {nullptr, L"server", L"im", nullptr, 0},
- {nullptr, L"server", nullptr, "node_server", 0},
-
- // {nullptr, L"store", L"berkeley", nullptr, 0},
- /// {nullptr, L"store", L"file", nullptr, 0},
- // {nullptr, L"store", L"generic", nullptr, 0},
- // {nullptr, L"store", L"ldap", nullptr, 0},
- // {nullptr, L"store", L"mysql", nullptr, 0},
- // {nullptr, L"store", L"oracle", nullptr, 0},
- // {nullptr, L"store", L"postgres", nullptr, 0},
- {nullptr, L"store", nullptr, "node_store", 0},
+ {nullptr, "account", nullptr, nullptr, SKINICON_STATUS_ONLINE},
+ {nullptr, "auth", nullptr, "key", 0},
+ {nullptr, "automation", nullptr, "adhoc", 0},
+ {nullptr, "client", nullptr, nullptr, SKINICON_STATUS_ONLINE},
+ {nullptr, "collaboration", nullptr, "group", 0},
+ {nullptr, "conference", nullptr, "group", 0},
+
+ {nullptr, "directory", "chatroom", "group", 0},
+ {nullptr, "directory", "group", "group", 0},
+ {nullptr, "directory", "user", nullptr, SKINICON_OTHER_FINDUSER},
+ {nullptr, "directory", nullptr, nullptr, SKINICON_OTHER_SEARCHALL},
+
+ {nullptr, "gateway", "aim", "AIM", SKINICON_STATUS_ONLINE},
+ {nullptr, "gateway", "gadu-gadu", "GG", SKINICON_STATUS_ONLINE},
+ {nullptr, "gateway", "icq", "ICQ", SKINICON_STATUS_ONLINE},
+ {nullptr, "gateway", "msn", "MSN", SKINICON_STATUS_ONLINE},
+ {nullptr, "gateway", "qq", "QQ", SKINICON_STATUS_ONLINE},
+ {nullptr, "gateway", "tlen", "TLEN", SKINICON_STATUS_ONLINE},
+ {nullptr, "gateway", "yahoo", "YAHOO", SKINICON_STATUS_ONLINE},
+ {nullptr, "gateway", nullptr, "Agents", 0},
+
+ {nullptr, "headline", "rss", "node_rss", 0},
+ {nullptr, "headline", "weather", "node_weather", 0},
+
+ {nullptr, "proxy", nullptr, nullptr, SKINICON_EVENT_FILE},
+
+ {nullptr, "server", nullptr, "node_server", 0},
+
+ {nullptr, "store", nullptr, "node_store", 0},
// icons for non-standard identities
- {nullptr, L"x-service", L"x-rss", "node_rss", 0},
- {nullptr, L"application", L"x-weather", "node_weather", 0},
- {nullptr, L"user", nullptr, nullptr, SKINICON_STATUS_ONLINE},
+ {nullptr, "x-service", "x-rss", "node_rss", 0},
+ {nullptr, "application", "x-weather", "node_weather", 0},
+ {nullptr, "user", nullptr, nullptr, SKINICON_STATUS_ONLINE},
// icon suggestions based on supported features
- {L"jabber:iq:gateway", nullptr, nullptr, "Agents", 0},
- {L"jabber:iq:search", nullptr, nullptr, nullptr, SKINICON_OTHER_FINDUSER},
- { JABBER_FEAT_COMMANDS, nullptr, nullptr, "adhoc", 0},
- { JABBER_FEAT_REGISTER, nullptr, nullptr, "key", 0},
+ {"jabber:iq:gateway", nullptr, nullptr, "Agents", 0},
+ {"jabber:iq:search", nullptr, nullptr, nullptr, SKINICON_OTHER_FINDUSER},
+ {JABBER_FEAT_COMMANDS, nullptr, nullptr, "adhoc", 0},
+ {JABBER_FEAT_REGISTER, nullptr, nullptr, "key", 0},
};
-static void sttApplyNodeIcon(HTREELISTITEM hItem, CJabberSDNode *pNode);
-
-void CJabberProto::OnIqResultServiceDiscoveryInfo(HXML iqNode, CJabberIqInfo *pInfo)
+void CJabberProto::OnIqResultServiceDiscoveryInfo(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
mir_cslockfull lck(m_SDManager.cs());
CJabberSDNode *pNode = m_SDManager.FindByIqId(pInfo->GetIqId(), TRUE);
@@ -175,17 +113,15 @@ void CJabberProto::OnIqResultServiceDiscoveryInfo(HXML iqNode, CJabberIqInfo *pI
return;
if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
- HXML query = XmlGetChild(iqNode, "query");
+ auto *query = iqNode->FirstChildElement("query");
if (query == nullptr)
pNode->SetInfoRequestId(JABBER_DISCO_RESULT_ERROR);
else {
- HXML feature;
- int i;
- for (i = 1; (feature = XmlGetNthChild(query, L"feature", i)) != nullptr; i++)
- pNode->AddFeature(XmlGetAttrValue(feature, L"var"));
- HXML identity;
- for (i = 1; (identity = XmlGetNthChild(query, L"identity", i)) != nullptr; i++)
- pNode->AddIdentity(XmlGetAttrValue(identity, L"category"), XmlGetAttrValue(identity, L"type"), XmlGetAttrValue(identity, L"name"));
+ for (auto *feature : TiXmlFilter(query, "feature"))
+ pNode->AddFeature(feature->Attribute("var"));
+
+ for (auto *identity : TiXmlFilter(query, "identity"))
+ pNode->AddIdentity(identity->Attribute("category"), identity->Attribute("type"), identity->Attribute("name"));
pNode->SetInfoRequestId(JABBER_DISCO_RESULT_OK);
pNode->SetInfoRequestErrorText(nullptr);
@@ -193,7 +129,7 @@ void CJabberProto::OnIqResultServiceDiscoveryInfo(HXML iqNode, CJabberIqInfo *pI
}
else {
if (pInfo->GetIqType() == JABBER_IQ_TYPE_ERROR) {
- HXML errorNode = XmlGetChild(iqNode, "error");
+ auto *errorNode = iqNode->FirstChildElement("error");
wchar_t *str = JabberErrorMsg(errorNode);
pNode->SetInfoRequestErrorText(str);
mir_free(str);
@@ -211,7 +147,7 @@ void CJabberProto::OnIqResultServiceDiscoveryInfo(HXML iqNode, CJabberIqInfo *pI
}
}
-void CJabberProto::OnIqResultServiceDiscoveryItems(HXML iqNode, CJabberIqInfo *pInfo)
+void CJabberProto::OnIqResultServiceDiscoveryItems(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
mir_cslockfull lck(m_SDManager.cs());
CJabberSDNode *pNode = m_SDManager.FindByIqId(pInfo->GetIqId(), FALSE);
@@ -219,13 +155,12 @@ void CJabberProto::OnIqResultServiceDiscoveryItems(HXML iqNode, CJabberIqInfo *p
return;
if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
- HXML query = XmlGetChild(iqNode, "query");
+ auto *query = iqNode->FirstChildElement("query");
if (query == nullptr)
pNode->SetItemsRequestId(JABBER_DISCO_RESULT_ERROR);
else {
- HXML item;
- for (int i = 1; (item = XmlGetNthChild(query, L"item", i)) != nullptr; i++)
- pNode->AddChildNode(XmlGetAttrValue(item, L"jid"), XmlGetAttrValue(item, L"node"), XmlGetAttrValue(item, L"name"));
+ for (auto *item : TiXmlEnum(query))
+ pNode->AddChildNode(item->Attribute("jid"), item->Attribute("node"), item->Attribute("name"));
pNode->SetItemsRequestId(JABBER_DISCO_RESULT_OK);
pNode->SetItemsRequestErrorText(nullptr);
@@ -233,10 +168,8 @@ void CJabberProto::OnIqResultServiceDiscoveryItems(HXML iqNode, CJabberIqInfo *p
}
else {
if (pInfo->GetIqType() == JABBER_IQ_TYPE_ERROR) {
- HXML errorNode = XmlGetChild(iqNode, "error");
- wchar_t *str = JabberErrorMsg(errorNode);
- pNode->SetItemsRequestErrorText(str);
- mir_free(str);
+ auto *errorNode = iqNode->FirstChildElement("error");
+ pNode->SetItemsRequestErrorText(JabberErrorMsg(errorNode));
}
else {
pNode->SetItemsRequestErrorText(L"request timeout.");
@@ -252,18 +185,17 @@ void CJabberProto::OnIqResultServiceDiscoveryItems(HXML iqNode, CJabberIqInfo *p
}
}
-void CJabberProto::OnIqResultServiceDiscoveryRootInfo(HXML iqNode, CJabberIqInfo *pInfo)
+void CJabberProto::OnIqResultServiceDiscoveryRootInfo(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
if (!pInfo->m_pUserData) return;
mir_cslockfull lck(m_SDManager.cs());
if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
- HXML query = XmlGetChild(iqNode, "query");
+ auto *query = iqNode->FirstChildElement("query");
if (query) {
- HXML feature;
- for (int i = 1; (feature = XmlGetNthChild(query, L"feature", i)) != nullptr; i++) {
- if (!mir_wstrcmp(XmlGetAttrValue(feature, L"var"), (wchar_t *)pInfo->m_pUserData)) {
- CJabberSDNode *pNode = m_SDManager.AddPrimaryNode(pInfo->GetReceiver(), XmlGetAttrValue(iqNode, L"node"), nullptr);
+ for (auto *feature : TiXmlFilter(query, "feature")) {
+ if (!mir_strcmp(feature->Attribute("var"), (char*)pInfo->m_pUserData)) {
+ CJabberSDNode *pNode = m_SDManager.AddPrimaryNode(pInfo->GetReceiver(), iqNode->Attribute("node"), nullptr);
SendBothRequests(pNode, nullptr);
break;
}
@@ -275,37 +207,36 @@ void CJabberProto::OnIqResultServiceDiscoveryRootInfo(HXML iqNode, CJabberIqInfo
UI_SAFE_NOTIFY(m_pDlgServiceDiscovery, WM_JABBER_REFRESH);
}
-void CJabberProto::OnIqResultServiceDiscoveryRootItems(HXML iqNode, CJabberIqInfo *pInfo)
+void CJabberProto::OnIqResultServiceDiscoveryRootItems(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
if (!pInfo->m_pUserData)
return;
- XmlNode packet(nullptr);
+ TiXmlDocument packet;
mir_cslockfull lck(m_SDManager.cs());
if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
- HXML query = XmlGetChild(iqNode, "query");
+ auto *query = iqNode->FirstChildElement("query");
if (query) {
- HXML item;
- for (int i = 1; (item = XmlGetNthChild(query, L"item", i)) != nullptr; i++) {
- const wchar_t *szJid = XmlGetAttrValue(item, L"jid");
- const wchar_t *szNode = XmlGetAttrValue(item, L"node");
+ for (auto *item : TiXmlFilter(query, "item")) {
+ const char *szJid = item->Attribute("jid");
+ const char *szNode = item->Attribute("node");
CJabberIqInfo *pNewInfo = AddIQ(&CJabberProto::OnIqResultServiceDiscoveryRootInfo, JABBER_IQ_TYPE_GET, szJid);
pNewInfo->m_pUserData = pInfo->m_pUserData;
pNewInfo->SetTimeout(30000);
XmlNodeIq iq(pNewInfo);
- iq << XQUERY(JABBER_FEAT_DISCO_INFO) << XATTR(L"node", szNode);
- XmlAddChild(packet, iq);
+ iq << XQUERY(JABBER_FEAT_DISCO_INFO) << XATTR("node", szNode);
+ packet.InsertEndChild(iq);
}
}
}
lck.unlock();
- if (XmlGetChild(packet, 0))
- m_ThreadInfo->send(packet);
+ if (packet.FirstChildElement())
+ m_ThreadInfo->send(packet.ToElement());
}
-BOOL CJabberProto::SendInfoRequest(CJabberSDNode *pNode, HXML parent)
+BOOL CJabberProto::SendInfoRequest(CJabberSDNode *pNode, TiXmlElement *parent)
{
if (!pNode || !m_bJabberOnline)
return FALSE;
@@ -317,12 +248,12 @@ BOOL CJabberProto::SendInfoRequest(CJabberSDNode *pNode, HXML parent)
pNode->SetInfoRequestId(pInfo->GetIqId());
XmlNodeIq iq(pInfo);
- HXML query = iq << XQUERY(JABBER_FEAT_DISCO_INFO);
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_DISCO_INFO);
if (pNode->GetNode())
- XmlAddAttr(query, L"node", pNode->GetNode());
+ query->SetAttribute("node", pNode->GetNode());
if (parent)
- XmlAddChild(parent, iq);
+ parent->InsertEndChild(iq);
else
m_ThreadInfo->send(iq);
}
@@ -335,7 +266,7 @@ BOOL CJabberProto::SendInfoRequest(CJabberSDNode *pNode, HXML parent)
return TRUE;
}
-BOOL CJabberProto::SendBothRequests(CJabberSDNode *pNode, HXML parent)
+BOOL CJabberProto::SendBothRequests(CJabberSDNode *pNode, TiXmlElement *parent)
{
if (!pNode || !m_bJabberOnline)
return FALSE;
@@ -347,12 +278,12 @@ BOOL CJabberProto::SendBothRequests(CJabberSDNode *pNode, HXML parent)
pNode->SetInfoRequestId(pInfo->GetIqId());
XmlNodeIq iq(pInfo);
- HXML query = iq << XQUERY(JABBER_FEAT_DISCO_INFO);
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_DISCO_INFO);
if (pNode->GetNode())
- XmlAddAttr(query, L"node", pNode->GetNode());
+ query->SetAttribute("node", pNode->GetNode());
if (parent)
- XmlAddChild(parent, iq);
+ parent->InsertEndChild(iq);
else
m_ThreadInfo->send(iq);
}
@@ -364,12 +295,12 @@ BOOL CJabberProto::SendBothRequests(CJabberSDNode *pNode, HXML parent)
pNode->SetItemsRequestId(pInfo->GetIqId());
XmlNodeIq iq(pInfo);
- HXML query = iq << XQUERY(JABBER_FEAT_DISCO_ITEMS);
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_DISCO_ITEMS);
if (pNode->GetNode())
- XmlAddAttr(query, L"node", pNode->GetNode());
+ query->SetAttribute("node", pNode->GetNode());
if (parent)
- XmlAddChild(parent, iq);
+ parent->InsertEndChild(iq);
else
m_ThreadInfo->send(iq);
}
@@ -408,13 +339,13 @@ void CJabberProto::PerformBrowse(HWND hwndDlg)
LISTFOREACH(i, this, LIST_ROSTER)
{
if ((item = ListGetItemPtrFromIndex(i)) != nullptr) {
- if (wcschr(item->jid, '@') == nullptr && wcschr(item->jid, '/') == nullptr && item->subscription != SUB_NONE) {
+ if (strchr(item->jid, '@') == nullptr && strchr(item->jid, '/') == nullptr && item->subscription != SUB_NONE) {
MCONTACT hContact = HContactFromJID(item->jid);
if (hContact != 0)
setByte(hContact, "IsTransport", TRUE);
if (m_lstTransports.getIndex(item->jid) == -1)
- m_lstTransports.insert(mir_wstrdup(item->jid));
+ m_lstTransports.insert(mir_strdup(item->jid));
CJabberSDNode *pNode = m_SDManager.AddPrimaryNode(item->jid, nullptr, nullptr);
SendBothRequests(pNode, nullptr);
@@ -424,25 +355,21 @@ void CJabberProto::PerformBrowse(HWND hwndDlg)
}
else if (!mir_wstrcmp(szJid, _T(SD_FAKEJID_CONFERENCES))) {
sttBrowseMode = SD_BROWSE_CONFERENCES;
- wchar_t *szServerJid = mir_a2u(m_ThreadInfo->conn.server);
- CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultServiceDiscoveryRootItems, JABBER_IQ_TYPE_GET, szServerJid);
+ CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultServiceDiscoveryRootItems, JABBER_IQ_TYPE_GET, m_ThreadInfo->conn.server);
pInfo->m_pUserData = (void*)JABBER_FEAT_MUC;
pInfo->SetTimeout(30000);
XmlNodeIq iq(pInfo);
iq << XQUERY(JABBER_FEAT_DISCO_ITEMS);
m_ThreadInfo->send(iq);
- mir_free(szServerJid);
}
else if (!mir_wstrcmp(szJid, _T(SD_FAKEJID_AGENTS))) {
sttBrowseMode = SD_BROWSE_AGENTS;
- wchar_t *szServerJid = mir_a2u(m_ThreadInfo->conn.server);
- CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultServiceDiscoveryRootItems, JABBER_IQ_TYPE_GET, szServerJid);
+ CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultServiceDiscoveryRootItems, JABBER_IQ_TYPE_GET, m_ThreadInfo->conn.server);
pInfo->m_pUserData = (void*)L"jabber:iq:gateway";
pInfo->SetTimeout(30000);
XmlNodeIq iq(pInfo);
iq << XQUERY(JABBER_FEAT_DISCO_ITEMS);
m_ThreadInfo->send(iq);
- mir_free(szServerJid);
}
else if (!mir_wstrcmp(szJid, _T(SD_FAKEJID_FAVORITES))) {
sttBrowseMode = SD_BROWSE_FAVORITES;
@@ -450,21 +377,21 @@ void CJabberProto::PerformBrowse(HWND hwndDlg)
for (int i = 0; i < count; i++) {
char setting[MAXMODULELABELLENGTH];
mir_snprintf(setting, "discoWnd_favName_%d", i);
- ptrW tszName(getWStringA(setting));
+ ptrA tszName(getUStringA(setting));
if (tszName == nullptr)
continue;
mir_snprintf(setting, "discoWnd_favJID_%d", i);
- ptrW dbvJid(getWStringA(setting));
+ ptrA dbvJid(getUStringA(setting));
mir_snprintf(setting, "discoWnd_favNode_%d", i);
- ptrW dbvNode(getWStringA(setting));
+ ptrA dbvNode(getUStringA(setting));
CJabberSDNode *pNode = m_SDManager.AddPrimaryNode(dbvJid, dbvNode, tszName);
SendBothRequests(pNode, nullptr);
}
}
else {
sttBrowseMode = SD_BROWSE_NORMAL;
- CJabberSDNode *pNode = m_SDManager.AddPrimaryNode(szJid, mir_wstrlen(szNode) ? szNode : nullptr, nullptr);
+ CJabberSDNode *pNode = m_SDManager.AddPrimaryNode(T2Utf(szJid), T2Utf(szNode), nullptr);
SendBothRequests(pNode, nullptr);
}
lck.unlock();
@@ -519,22 +446,24 @@ void CJabberProto::ApplyNodeIcon(HTREELISTITEM hItem, CJabberSDNode *pNode)
if (it.category) {
CJabberSDIdentity *iIdentity;
for (iIdentity = pNode->GetFirstIdentity(); iIdentity; iIdentity = iIdentity->GetNext())
- if (!mir_wstrcmp(iIdentity->GetCategory(), it.category) &&
- (!it.type || !mir_wstrcmp(iIdentity->GetType(), it.type))) {
+ if (!mir_strcmp(iIdentity->GetCategory(), it.category) &&
+ (!it.type || !mir_strcmp(iIdentity->GetType(), it.type))) {
iIcon = it.listIndex;
break;
}
- if (iIdentity) break;
+ if (iIdentity)
+ break;
}
if (it.feature) {
CJabberSDFeature *iFeature;
for (iFeature = pNode->GetFirstFeature(); iFeature; iFeature = iFeature->GetNext())
- if (!mir_wstrcmp(iFeature->GetVar(), it.feature)) {
+ if (!mir_strcmp(iFeature->GetVar(), it.feature)) {
iIcon = it.listIndex;
break;
}
- if (iFeature) break;
+ if (iFeature)
+ break;
}
}
@@ -550,10 +479,10 @@ BOOL CJabberProto::SyncTree(HTREELISTITEM hIndex, CJabberSDNode *pNode)
if (!pTmp->GetTreeItemHandle()) {
HTREELISTITEM hNewItem = TreeList_AddItem(
GetDlgItem(m_pDlgServiceDiscovery->GetHwnd(), IDC_TREE_DISCO), hIndex,
- pTmp->GetName() ? pTmp->GetName() : pTmp->GetJid(),
+ Utf2T(pTmp->GetName() ? pTmp->GetName() : pTmp->GetJid()),
(LPARAM)pTmp);
- TreeList_AppendColumn(hNewItem, pTmp->GetJid());
- TreeList_AppendColumn(hNewItem, pTmp->GetNode());
+ TreeList_AppendColumn(hNewItem, Utf2T(pTmp->GetJid()));
+ TreeList_AppendColumn(hNewItem, Utf2T(pTmp->GetNode()));
if (!pTmp->GetInfoRequestId())
TreeList_MakeFakeParent(hNewItem, TRUE);
else
@@ -578,7 +507,7 @@ class CJabberDlgDiscovery : public CJabberDlgBase
typedef CJabberDlgBase CSuper;
public:
- CJabberDlgDiscovery(CJabberProto *proto, wchar_t *jid);
+ CJabberDlgDiscovery(CJabberProto *proto, char *jid);
protected:
bool OnInitDialog() override;
@@ -588,7 +517,7 @@ protected:
int Resizer(UTILRESIZECONTROL *urc) override;
private:
- wchar_t *m_jid;
+ char *m_jid;
bool m_focusEditAfterBrowse;
CCtrlMButton m_btnViewAsTree;
@@ -608,7 +537,7 @@ private:
void lstDiscoTree_OnFilter(CCtrlFilterListView *);
};
-CJabberDlgDiscovery::CJabberDlgDiscovery(CJabberProto *proto, wchar_t *jid) :
+CJabberDlgDiscovery::CJabberDlgDiscovery(CJabberProto *proto, char *jid) :
CJabberDlgBase(proto, IDD_SERVICE_DISCOVERY),
m_jid(jid),
m_btnViewAsTree(this, IDC_BTN_VIEWTREE, proto->LoadIconEx("sd_view_tree"), "View as tree"),
@@ -635,7 +564,7 @@ bool CJabberDlgDiscovery::OnInitDialog()
Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_SERVICE_DISCOVERY));
if (m_jid) {
- SetDlgItemText(m_hwnd, IDC_COMBO_JID, m_jid);
+ SetDlgItemTextUtf(m_hwnd, IDC_COMBO_JID, m_jid);
SetDlgItemText(m_hwnd, IDC_COMBO_NODE, L"");
m_focusEditAfterBrowse = false;
}
@@ -904,19 +833,19 @@ void CJabberDlgDiscovery::btnRefresh_OnClick(CCtrlButton *)
if (!hItem)
return;
- XmlNode packet(nullptr);
+ TiXmlDocument packet;
mir_cslockfull lck(m_proto->m_SDManager.cs());
CJabberSDNode *pNode = (CJabberSDNode*)TreeList_GetData(hItem);
if (pNode) {
TreeList_ResetItem(GetDlgItem(m_hwnd, IDC_TREE_DISCO), hItem);
pNode->ResetInfo();
- m_proto->SendBothRequests(pNode, packet);
+ m_proto->SendBothRequests(pNode, packet.ToElement());
TreeList_MakeFakeParent(hItem, FALSE);
}
lck.unlock();
- if (XmlGetChild(packet, 0))
- m_proto->m_ThreadInfo->send(packet);
+ if (packet.FirstChildElement())
+ m_proto->m_ThreadInfo->send(packet.ToElement());
}
void CJabberDlgDiscovery::btnBrowse_OnClick(CCtrlButton *)
@@ -975,10 +904,10 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
if (!pNode->GetTreeItemHandle()) {
HTREELISTITEM hNewItem = TreeList_AddItem(
GetDlgItem(m_hwnd, IDC_TREE_DISCO), nullptr,
- pNode->GetName() ? pNode->GetName() : pNode->GetJid(),
+ Utf2T(pNode->GetName() ? pNode->GetName() : pNode->GetJid()),
(LPARAM)pNode);
- TreeList_AppendColumn(hNewItem, pNode->GetJid());
- TreeList_AppendColumn(hNewItem, pNode->GetNode());
+ TreeList_AppendColumn(hNewItem, Utf2T(pNode->GetJid()));
+ TreeList_AppendColumn(hNewItem, Utf2T(pNode->GetNode()));
pNode->SetTreeItemHandle(hNewItem);
}
}
@@ -1006,7 +935,7 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
if (iFirst < 0) return FALSE;
if (iLast < 0) iLast = ListView_GetItemCount(hwndList) - 1;
- XmlNode packet(nullptr);
+ TiXmlDocument packet;
{
mir_cslock lck(m_proto->m_SDManager.cs());
for (int i = iFirst; i <= iLast; i++) {
@@ -1021,11 +950,11 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
if (!pNode || pNode->GetInfoRequestId())
continue;
- m_proto->SendInfoRequest(pNode, packet);
+ m_proto->SendInfoRequest(pNode, packet.ToElement());
}
}
- if (XmlGetChild(packet, 0))
- m_proto->m_ThreadInfo->send(packet);
+ if (packet.FirstChildElement())
+ m_proto->m_ThreadInfo->send(packet.ToElement());
KillTimer(m_hwnd, AUTODISCO_TIMER);
m_proto->m_dwSDLastRefresh = GetTickCount();
@@ -1078,7 +1007,7 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
else if (pHeader->code == TVN_ITEMEXPANDED) {
NMTREEVIEW *pNmTreeView = (NMTREEVIEW *)lParam;
HTREELISTITEM hItem = (HTREELISTITEM)pNmTreeView->itemNew.hItem;
- XmlNode packet(nullptr);
+ XmlNode packet(0);
{
mir_cslock lck(m_proto->m_SDManager.cs());
CJabberSDNode *pNode = (CJabberSDNode*)TreeList_GetData(hItem);
@@ -1087,7 +1016,7 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
TreeList_MakeFakeParent(hItem, FALSE);
}
}
- if (XmlGetChild(packet))
+ if (packet.FirstChildElement())
m_proto->m_ThreadInfo->send(packet);
}
else if (pHeader->code == NM_CUSTOMDRAW) {
@@ -1174,36 +1103,36 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM
struct
{
- wchar_t *feature;
+ char *feature;
wchar_t *title;
int action;
DWORD flags;
}
static items[] =
{
- { nullptr, LPGENW("Contact Menu..."), SD_ACT_USERMENU, SD_FLG_NONODE},
- { nullptr, LPGENW("View vCard"), SD_ACT_VCARD, SD_FLG_NONODE},
- { JABBER_FEAT_MUC, LPGENW("Join chatroom"), SD_ACT_JOIN, SD_FLG_NORESOURCE},
- {nullptr},
- { nullptr, LPGENW("Refresh Info"), SD_ACT_REFRESH},
- { nullptr, LPGENW("Refresh Children"), SD_ACT_REFRESHCHILDREN},
- {nullptr},
- { nullptr, LPGENW("Add to favorites"), SD_ACT_FAVORITE},
- { nullptr, LPGENW("Add to roster"), SD_ACT_ROSTER, SD_FLG_NONODE | SD_FLG_NOTONROSTER},
- { JABBER_FEAT_MUC, LPGENW("Bookmark chatroom"), SD_ACT_BOOKMARK, SD_FLG_NORESOURCE | SD_FLG_HASUSER},
- { L"jabber:iq:search", LPGENW("Add search directory"), SD_ACT_ADDDIRECTORY},
- { JABBER_FEAT_BYTESTREAMS, LPGENW("Use this proxy"), SD_ACT_PROXY},
- {nullptr},
- { JABBER_FEAT_REGISTER, LPGENW("Register"), SD_ACT_REGISTER},
- { L"jabber:iq:gateway", LPGENW("Unregister"), SD_ACT_UNREGISTER, SD_FLG_ONROSTER | SD_FLG_SUBSCRIBED},
- { JABBER_FEAT_COMMANDS, LPGENW("Commands..."), SD_ACT_ADHOC},
- {nullptr},
- { L"jabber:iq:gateway", LPGENW("Logon"), SD_ACT_LOGON, SD_FLG_ONROSTER | SD_FLG_SUBSCRIBED | SD_FLG_ONLINE},
- { L"jabber:iq:gateway", LPGENW("Logoff"), SD_ACT_LOGOFF, SD_FLG_ONROSTER | SD_FLG_SUBSCRIBED | SD_FLG_NOTONLINE},
- {nullptr},
- { nullptr, LPGENW("Copy JID"), SD_ACT_COPYJID},
- { nullptr, LPGENW("Copy node name"), SD_ACT_COPYNODE},
- { nullptr, LPGENW("Copy node information"), SD_ACT_COPYINFO},
+ { nullptr, LPGENW("Contact Menu..."), SD_ACT_USERMENU, SD_FLG_NONODE},
+ { nullptr, LPGENW("View vCard"), SD_ACT_VCARD, SD_FLG_NONODE},
+ { JABBER_FEAT_MUC, LPGENW("Join chatroom"), SD_ACT_JOIN, SD_FLG_NORESOURCE},
+ { nullptr },
+ { nullptr, LPGENW("Refresh Info"), SD_ACT_REFRESH},
+ { nullptr, LPGENW("Refresh Children"), SD_ACT_REFRESHCHILDREN},
+ { nullptr },
+ { nullptr, LPGENW("Add to favorites"), SD_ACT_FAVORITE},
+ { nullptr, LPGENW("Add to roster"), SD_ACT_ROSTER, SD_FLG_NONODE | SD_FLG_NOTONROSTER},
+ { JABBER_FEAT_MUC, LPGENW("Bookmark chatroom"), SD_ACT_BOOKMARK, SD_FLG_NORESOURCE | SD_FLG_HASUSER},
+ { "jabber:iq:search", LPGENW("Add search directory"), SD_ACT_ADDDIRECTORY},
+ { JABBER_FEAT_BYTESTREAMS, LPGENW("Use this proxy"), SD_ACT_PROXY},
+ { nullptr },
+ { JABBER_FEAT_REGISTER, LPGENW("Register"), SD_ACT_REGISTER},
+ { "jabber:iq:gateway", LPGENW("Unregister"), SD_ACT_UNREGISTER, SD_FLG_ONROSTER | SD_FLG_SUBSCRIBED},
+ { JABBER_FEAT_COMMANDS, LPGENW("Commands..."), SD_ACT_ADHOC},
+ { nullptr },
+ { "jabber:iq:gateway", LPGENW("Logon"), SD_ACT_LOGON, SD_FLG_ONROSTER | SD_FLG_SUBSCRIBED | SD_FLG_ONLINE},
+ { "jabber:iq:gateway", LPGENW("Logoff"), SD_ACT_LOGOFF, SD_FLG_ONROSTER | SD_FLG_SUBSCRIBED | SD_FLG_NOTONLINE},
+ { nullptr },
+ { nullptr, LPGENW("Copy JID"), SD_ACT_COPYJID},
+ { nullptr, LPGENW("Copy node name"), SD_ACT_COPYNODE},
+ { nullptr, LPGENW("Copy node information"), SD_ACT_COPYINFO},
};
HMENU hMenu = CreatePopupMenu();
@@ -1226,9 +1155,9 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM
continue;
if ((it.flags & SD_FLG_NOTONLINE) && rosterItem && (rosterItem->getTemp()->m_iStatus == ID_STATUS_OFFLINE))
continue;
- if ((it.flags & SD_FLG_NORESOURCE) && wcschr(pNode->GetJid(), '/'))
+ if ((it.flags & SD_FLG_NORESOURCE) && strchr(pNode->GetJid(), '/'))
continue;
- if ((it.flags & SD_FLG_HASUSER) && !wcschr(pNode->GetJid(), '@'))
+ if ((it.flags & SD_FLG_HASUSER) && !strchr(pNode->GetJid(), '@'))
continue;
}
@@ -1251,8 +1180,8 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM
bool bFeatureOk = !bFilterItems;
if (bFilterItems)
- for (CJabberSDFeature *iFeature = pNode->GetFirstFeature(); iFeature; iFeature = iFeature->GetNext())
- if (!mir_wstrcmp(iFeature->GetVar(), it.feature)) {
+ for (auto *iFeature = pNode->GetFirstFeature(); iFeature; iFeature = iFeature->GetNext())
+ if (!mir_strcmp(iFeature->GetVar(), it.feature)) {
bFeatureOk = true;
break;
}
@@ -1290,14 +1219,14 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM
TreeList_MakeFakeParent(hItem, FALSE);
}
}
- if (XmlGetChild(packet))
+ if (!packet.NoChildren())
m_ThreadInfo->send(packet);
}
break;
case SD_ACT_REFRESHCHILDREN:
{
- XmlNode packet(nullptr);
+ TiXmlDocument packet;
{
mir_cslock lck(m_SDManager.cs());
for (int iChild = TreeList_GetChildrenCount(hItem); iChild--;) {
@@ -1306,28 +1235,28 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM
if (n) {
TreeList_ResetItem(GetDlgItem(m_pDlgServiceDiscovery->GetHwnd(), IDC_TREE_DISCO), hNode);
n->ResetInfo();
- SendBothRequests(n, packet);
+ SendBothRequests(n, packet.ToElement());
TreeList_MakeFakeParent(hNode, FALSE);
}
- if (XmlGetChildCount(packet) > 50) {
- m_ThreadInfo->send(packet);
- packet = XmlNode(nullptr);
- }
+ //!!!!!!!!!!!!!!!!!! if (packet > 50) {
+ m_ThreadInfo->send(packet.ToElement());
+ packet.Clear();
+ ///}
}
}
- if (XmlGetChildCount(packet))
- m_ThreadInfo->send(packet);
+ if (!packet.NoChildren())
+ m_ThreadInfo->send(packet.ToElement());
}
break;
case SD_ACT_COPYJID:
- JabberCopyText(m_pDlgServiceDiscovery->GetHwnd(), pNode->GetJid());
+ JabberCopyText(m_pDlgServiceDiscovery->GetHwnd(), Utf2T(pNode->GetJid()));
break;
case SD_ACT_COPYNODE:
- JabberCopyText(m_pDlgServiceDiscovery->GetHwnd(), pNode->GetNode());
+ JabberCopyText(m_pDlgServiceDiscovery->GetHwnd(), Utf2T(pNode->GetNode()));
break;
case SD_ACT_COPYINFO:
@@ -1343,11 +1272,11 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM
char setting[MAXMODULELABELLENGTH];
int count = getDword("discoWnd_favCount", 0);
mir_snprintf(setting, "discoWnd_favName_%d", count);
- setWString(setting, pNode->GetName() ? pNode->GetName() : pNode->GetJid());
+ setUString(setting, pNode->GetName() ? pNode->GetName() : pNode->GetJid());
mir_snprintf(setting, "discoWnd_favJID_%d", count);
- setWString(setting, pNode->GetJid());
+ setUString(setting, pNode->GetJid());
mir_snprintf(setting, "discoWnd_favNode_%d", count);
- setWString(setting, pNode->GetNode() ? pNode->GetNode() : L"");
+ setUString(setting, pNode->GetNode() ? pNode->GetNode() : "");
setDword("discoWnd_favCount", ++count);
}
break;
@@ -1367,7 +1296,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM
case SD_ACT_PROXY:
m_bBsDirect = FALSE;
m_bBsProxyManual = TRUE;
- setWString("BsProxyServer", pNode->GetJid());
+ setUString("BsProxyServer", pNode->GetJid());
break;
case SD_ACT_JOIN:
@@ -1383,10 +1312,10 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM
item = ListAdd(LIST_ROOM, pNode->GetJid());
if (item == nullptr)
break;
- item->name = mir_wstrdup(pNode->GetName());
+ item->name = mir_utf8decodeW(pNode->GetName());
}
- item->type = L"conference";
+ item->type = "conference";
AddEditBookmark(item);
}
}
@@ -1409,7 +1338,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM
case SD_ACT_VCARD:
{
- wchar_t *jid = pNode->GetJid();
+ char *jid = pNode->GetJid();
MCONTACT hContact = HContactFromJID(pNode->GetJid());
if (!hContact)
hContact = AddToListByJID(jid, PALF_TEMPORARY);
@@ -1435,14 +1364,14 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM
case SD_ACT_LOGON:
case SD_ACT_LOGOFF:
- m_ThreadInfo->send(XmlNode(L"presence") << XATTR(L"to", pNode->GetJid()) << XATTR(L"type", (res != SD_ACT_LOGON) ? L"unavailable" : nullptr));
+ m_ThreadInfo->send(XmlNode("presence") << XATTR("to", pNode->GetJid()) << XATTR("type", (res != SD_ACT_LOGON) ? "unavailable" : nullptr));
break;
case SD_ACT_UNREGISTER:
- m_ThreadInfo->send(XmlNodeIq(L"set", SerialNext(), pNode->GetJid()) << XQUERY(JABBER_FEAT_REGISTER) << XCHILD(L"remove"));
+ m_ThreadInfo->send(XmlNodeIq("set", SerialNext(), pNode->GetJid()) << XQUERY(JABBER_FEAT_REGISTER) << XCHILD("remove"));
- m_ThreadInfo->send(XmlNodeIq(L"set", SerialNext()) << XQUERY(JABBER_FEAT_IQ_ROSTER)
- << XCHILD(L"item") << XATTR(L"jid", pNode->GetJid()) << XATTR(L"subscription", L"remove"));
+ m_ThreadInfo->send(XmlNodeIq("set", SerialNext()) << XQUERY(JABBER_FEAT_IQ_ROSTER)
+ << XCHILD("item") << XATTR("jid", pNode->GetJid()) << XATTR("subscription", "remove"));
break;
default:
@@ -1455,12 +1384,12 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM
}
}
-void CJabberProto::LaunchServiceDiscovery(wchar_t *jid)
+void CJabberProto::LaunchServiceDiscovery(char *jid)
{
if (m_pDlgServiceDiscovery) {
SetForegroundWindow(m_pDlgServiceDiscovery->GetHwnd());
if (jid) {
- SetDlgItemText(m_pDlgServiceDiscovery->GetHwnd(), IDC_COMBO_JID, jid);
+ SetDlgItemTextUtf(m_pDlgServiceDiscovery->GetHwnd(), IDC_COMBO_JID, jid);
SetDlgItemTextA(m_pDlgServiceDiscovery->GetHwnd(), IDC_COMBO_NODE, "");
PostMessage(m_pDlgServiceDiscovery->GetHwnd(), WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
}
@@ -1479,18 +1408,18 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleServiceDiscovery(WPARAM, LPARAM)
INT_PTR __cdecl CJabberProto::OnMenuHandleServiceDiscoveryMyTransports(WPARAM, LPARAM)
{
- LaunchServiceDiscovery(_T(SD_FAKEJID_MYAGENTS));
+ LaunchServiceDiscovery(SD_FAKEJID_MYAGENTS);
return 0;
}
INT_PTR __cdecl CJabberProto::OnMenuHandleServiceDiscoveryTransports(WPARAM, LPARAM)
{
- LaunchServiceDiscovery(_T(SD_FAKEJID_AGENTS));
+ LaunchServiceDiscovery(SD_FAKEJID_AGENTS);
return 0;
}
INT_PTR __cdecl CJabberProto::OnMenuHandleServiceDiscoveryConferences(WPARAM, LPARAM)
{
- LaunchServiceDiscovery(_T(SD_FAKEJID_CONFERENCES));
+ LaunchServiceDiscovery(SD_FAKEJID_CONFERENCES);
return 0;
}
diff --git a/protocols/JabberG/src/jabber_disco.h b/protocols/JabberG/src/jabber_disco.h
index 80da740b02..1c3863dd9c 100644
--- a/protocols/JabberG/src/jabber_disco.h
+++ b/protocols/JabberG/src/jabber_disco.h
@@ -36,16 +36,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
class CJabberSDIdentity
{
protected:
- wchar_t *m_szCategory;
- wchar_t *m_szType;
- wchar_t *m_szName;
+ char *m_szCategory;
+ char *m_szType;
+ char *m_szName;
CJabberSDIdentity *m_pNext;
+
public:
- CJabberSDIdentity(const wchar_t *szCategory, const wchar_t *szType, const wchar_t *szName)
+ CJabberSDIdentity(const char *szCategory, const char *szType, const char *szName)
{
- m_szCategory = mir_wstrdup(szCategory);
- m_szType = mir_wstrdup(szType);
- m_szName = mir_wstrdup(szName);
+ m_szCategory = mir_strdup(szCategory);
+ m_szType = mir_strdup(szType);
+ m_szName = mir_strdup(szName);
m_pNext = nullptr;
}
~CJabberSDIdentity()
@@ -56,15 +57,15 @@ public:
if (m_pNext)
delete m_pNext;
}
- wchar_t *GetCategory()
+ char *GetCategory()
{
return m_szCategory;
}
- wchar_t *GetType()
+ char *GetType()
{
return m_szType;
}
- wchar_t *GetName()
+ char *GetName()
{
return m_szName;
}
@@ -84,12 +85,12 @@ class CJabberSDFeature;
class CJabberSDFeature
{
protected:
- wchar_t *m_szVar;
+ char *m_szVar;
CJabberSDFeature *m_pNext;
public:
- CJabberSDFeature(const wchar_t *szVar)
+ CJabberSDFeature(const char *szVar)
{
- m_szVar = szVar ? mir_wstrdup(szVar) : nullptr;
+ m_szVar = szVar ? mir_strdup(szVar) : nullptr;
m_pNext = nullptr;
}
~CJabberSDFeature()
@@ -98,7 +99,7 @@ public:
if (m_pNext)
delete m_pNext;
}
- wchar_t *GetVar()
+ char* GetVar()
{
return m_szVar;
}
@@ -117,9 +118,9 @@ public:
class CJabberSDNode
{
protected:
- wchar_t *m_szJid;
- wchar_t *m_szNode;
- wchar_t *m_szName;
+ char *m_szJid;
+ char *m_szNode;
+ char *m_szName;
CJabberSDIdentity *m_pIdentities;
CJabberSDFeature *m_pFeatures;
CJabberSDNode *m_pNext;
@@ -131,12 +132,13 @@ protected:
HTREELISTITEM m_hTreeItem;
wchar_t *m_szInfoError;
wchar_t *m_szItemsError;
+
public:
- CJabberSDNode(const wchar_t *szJid = nullptr, const wchar_t *szNode = nullptr, const wchar_t *szName = nullptr)
+ CJabberSDNode(const char *szJid = nullptr, const char *szNode = nullptr, const char *szName = nullptr)
{
- m_szJid = mir_wstrdup(szJid);
- m_szNode = mir_wstrdup(szNode);
- m_szName = mir_wstrdup(szName);
+ m_szJid = mir_strdup(szJid);
+ m_szNode = mir_strdup(szNode);
+ m_szName = mir_strdup(szName);
m_pIdentities = nullptr;
m_pFeatures = nullptr;
m_pNext = nullptr;
@@ -155,9 +157,9 @@ public:
}
BOOL RemoveAll()
{
- replaceStrW(m_szJid, nullptr);
- replaceStrW(m_szNode, nullptr);
- replaceStrW(m_szName, nullptr);
+ replaceStr(m_szJid, nullptr);
+ replaceStr(m_szNode, nullptr);
+ replaceStr(m_szName, nullptr);
replaceStrW(m_szInfoError, nullptr);
replaceStrW(m_szItemsError, nullptr);
if (m_pIdentities)
@@ -227,25 +229,25 @@ public:
{
return m_nItemsRequestId;
}
- BOOL SetJid(wchar_t *szJid)
+ BOOL SetJid(char *szJid)
{
- replaceStrW(m_szJid, szJid);
+ replaceStr(m_szJid, szJid);
return TRUE;
}
- wchar_t *GetJid()
+ char* GetJid()
{
return m_szJid;
}
- BOOL SetNode(wchar_t *szNode)
+ BOOL SetNode(char *szNode)
{
- replaceStrW(m_szNode, szNode);
+ replaceStr(m_szNode, szNode);
return TRUE;
}
- wchar_t *GetNode()
+ char* GetNode()
{
return m_szNode;
}
- wchar_t *GetName()
+ char *GetName()
{
return m_szName;
}
@@ -291,7 +293,7 @@ public:
}
return nullptr;
}
- BOOL AddFeature(const wchar_t *szFeature)
+ BOOL AddFeature(const char *szFeature)
{
if (!szFeature)
return FALSE;
@@ -305,7 +307,7 @@ public:
return TRUE;
}
- BOOL AddIdentity(const wchar_t *szCategory, const wchar_t *szType, const wchar_t *szName)
+ BOOL AddIdentity(const char *szCategory, const char *szType, const char*szName)
{
if (!szCategory || !szType)
return FALSE;
@@ -319,7 +321,7 @@ public:
return TRUE;
}
- BOOL AddChildNode(const wchar_t *szJid, const wchar_t *szNode, const wchar_t *szName)
+ BOOL AddChildNode(const char *szJid, const char *szNode, const char *szName)
{
if (!szJid)
return FALSE;
@@ -333,7 +335,7 @@ public:
return TRUE;
}
- BOOL SetItemsRequestErrorText(wchar_t *szError)
+ BOOL SetItemsRequestErrorText(const wchar_t *szError)
{
replaceStrW(m_szItemsError, szError);
return TRUE;
@@ -423,7 +425,7 @@ public:
return m_pPrimaryNodes;
}
- CJabberSDNode* AddPrimaryNode(const wchar_t *szJid, const wchar_t *szNode, const wchar_t *szName)
+ CJabberSDNode* AddPrimaryNode(const char *szJid, const char *szNode, const char *szName)
{
if (!szJid)
return nullptr;
diff --git a/protocols/JabberG/src/jabber_events.cpp b/protocols/JabberG/src/jabber_events.cpp
index ec6342eb60..e2d906792e 100644
--- a/protocols/JabberG/src/jabber_events.cpp
+++ b/protocols/JabberG/src/jabber_events.cpp
@@ -36,22 +36,22 @@ void CJabberProto::OnContactDeleted(MCONTACT hContact)
if (!m_bJabberOnline) // should never happen
return;
- ptrW jid(getWStringA(hContact, isChatRoom(hContact) ? "ChatRoomID" : "jid"));
- if (jid == nullptr)
+ ptrA jid(getUStringA(hContact, isChatRoom(hContact) ? "ChatRoomID" : "jid"));
+ if (jid)
return;
if (ListGetItemPtr(LIST_ROSTER, jid)) {
- if (!wcschr(jid, '@')) {
- wchar_t szStrippedJid[JABBER_MAX_JID_LEN];
+ if (!strchr(jid, '@')) {
+ char szStrippedJid[JABBER_MAX_JID_LEN];
JabberStripJid(m_ThreadInfo->fullJID, szStrippedJid, _countof(szStrippedJid));
- wchar_t *szDog = wcschr(szStrippedJid, '@');
- if (szDog && mir_wstrcmpi(szDog + 1, jid))
- m_ThreadInfo->send(XmlNodeIq(L"set", SerialNext(), jid) << XQUERY(JABBER_FEAT_REGISTER) << XCHILD(L"remove"));
+ char *szDog = strchr(szStrippedJid, '@');
+ if (szDog && mir_strcmpi(szDog + 1, jid))
+ m_ThreadInfo->send(XmlNodeIq("set", SerialNext(), jid) << XQUERY(JABBER_FEAT_REGISTER) << XCHILD("remove"));
}
// Remove from roster, server also handles the presence unsubscription process.
- m_ThreadInfo->send(XmlNodeIq(L"set", SerialNext())
- << XQUERY(JABBER_FEAT_IQ_ROSTER) << XCHILD(L"item") << XATTR(L"jid", jid) << XATTR(L"subscription", L"remove"));
+ m_ThreadInfo->send(XmlNodeIq("set", SerialNext())
+ << XQUERY(JABBER_FEAT_IQ_ROSTER) << XCHILD("item") << XATTR("jid", jid) << XATTR("subscription", "remove"));
ListRemove(LIST_ROSTER, jid);
}
@@ -60,30 +60,30 @@ void CJabberProto::OnContactDeleted(MCONTACT hContact)
/////////////////////////////////////////////////////////////////////////////////////////
// JabberDbSettingChanged - process database changes
-static wchar_t* sttSettingToTchar(DBCONTACTWRITESETTING *cws)
+static char* sttSettingToTchar(DBCONTACTWRITESETTING *cws)
{
switch (cws->value.type) {
case DBVT_ASCIIZ:
- return mir_a2u(cws->value.pszVal);
+ return mir_utf8encode(cws->value.pszVal);
case DBVT_UTF8:
- return mir_utf8decodeW(cws->value.pszVal);
+ return mir_strdup(cws->value.pszVal);
case DBVT_WCHAR:
- return mir_wstrdup(cws->value.pwszVal);
+ return mir_utf8encodeW(cws->value.pwszVal);
}
return nullptr;
}
void __cdecl CJabberProto::OnRenameGroup(DBCONTACTWRITESETTING *cws, MCONTACT hContact)
{
- JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, ptrW(getWStringA(hContact, "jid")));
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, ptrA(getUStringA(hContact, "jid")));
if (item == nullptr)
return;
- ptrW tszNick(db_get_wsa(hContact, "CList", "MyHandle"));
+ ptrA tszNick(db_get_utfa(hContact, "CList", "MyHandle"));
if (tszNick == nullptr)
- tszNick = getWStringA(hContact, "Nick");
+ tszNick = getUStringA(hContact, "Nick");
if (tszNick == nullptr)
tszNick = JabberNickFromJID(item->jid);
if (tszNick == nullptr)
@@ -96,8 +96,8 @@ void __cdecl CJabberProto::OnRenameGroup(DBCONTACTWRITESETTING *cws, MCONTACT hC
}
}
else {
- wchar_t *p = sttSettingToTchar(cws);
- if (cws->value.pszVal != nullptr && mir_wstrcmp(p, item->group)) {
+ char *p = sttSettingToTchar(cws);
+ if (cws->value.pszVal != nullptr && mir_strcmp(p, item->group)) {
debugLogW(L"Group set to %s", p);
if (p)
AddContactToRoster(item->jid, tszNick, p);
@@ -108,19 +108,19 @@ void __cdecl CJabberProto::OnRenameGroup(DBCONTACTWRITESETTING *cws, MCONTACT hC
void __cdecl CJabberProto::OnRenameContact(DBCONTACTWRITESETTING *cws, MCONTACT hContact)
{
- JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, ptrW(getWStringA(hContact, "jid")));
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, ptrA(getUStringA(hContact, "jid")));
if (item == nullptr)
return;
if (cws->value.type == DBVT_DELETED) {
wchar_t *nick = Clist_GetContactDisplayName(hContact, GCDNF_NOMYHANDLE);
- AddContactToRoster(item->jid, nick, item->group);
+ AddContactToRoster(item->jid, T2Utf(nick), item->group);
mir_free(nick);
return;
}
- ptrW newNick(sttSettingToTchar(cws));
- if (newNick && mir_wstrcmp(item->nick, newNick)) {
+ ptrA newNick(sttSettingToTchar(cws));
+ if (newNick && mir_strcmp(item->nick, newNick)) {
debugLogW(L"Renaming contact %s: %s -> %s", item->jid, item->nick, newNick);
AddContactToRoster(item->jid, newNick, item->group);
}
@@ -128,25 +128,25 @@ void __cdecl CJabberProto::OnRenameContact(DBCONTACTWRITESETTING *cws, MCONTACT
void __cdecl CJabberProto::OnAddContactForever(MCONTACT hContact)
{
- ptrW jid(getWStringA(hContact, "jid"));
+ ptrA jid(getUStringA(hContact, "jid"));
if (jid == nullptr)
return;
debugLogW(L"Add %s permanently to list", jid);
- ptrW nick(db_get_wsa(hContact, "CList", "MyHandle"));
+ ptrA nick(db_get_utfa(hContact, "CList", "MyHandle"));
if (nick == nullptr)
- nick = getWStringA(hContact, "Nick");
+ nick = getUStringA(hContact, "Nick");
if (nick == nullptr)
nick = JabberNickFromJID(jid);
if (nick == nullptr)
return;
- AddContactToRoster(jid, nick, ptrW(db_get_wsa(hContact, "CList", "Group")));
+ AddContactToRoster(jid, nick, ptrA(db_get_utfa(hContact, "CList", "Group")));
- XmlNode xPresence(L"presence"); xPresence << XATTR(L"to", jid) << XATTR(L"type", L"subscribe");
- ptrW myNick(getWStringA(0, "Nick"));
+ XmlNode xPresence("presence"); xPresence << XATTR("to", jid) << XATTR("type", "subscribe");
+ ptrA myNick(getUStringA(0, "Nick"));
if (myNick != nullptr)
- xPresence << XCHILD(L"nick", myNick) << XATTR(L"xmlns", JABBER_FEAT_NICK);
+ xPresence << XCHILD("nick", myNick) << XATTR("xmlns", JABBER_FEAT_NICK);
m_ThreadInfo->send(xPresence);
SendGetVcard(jid);
diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp
index 4c77f434c0..fa0e5c98ac 100644
--- a/protocols/JabberG/src/jabber_file.cpp
+++ b/protocols/JabberG/src/jabber_file.cpp
@@ -178,8 +178,8 @@ void JabberFileServerConnection(HNETLIBCONN hConnection, DWORD /*dwRemoteIP*/, v
NETLIBCONNINFO connInfo = {};
Netlib_GetConnectionInfo(hConnection, &connInfo);
- wchar_t szPort[10];
- mir_snwprintf(szPort, L"%d", connInfo.wPort);
+ char szPort[10];
+ _itoa(connInfo.wPort, szPort, 10);
ppro->debugLogA("File server incoming connection accepted: %s", connInfo.szIpPort);
JABBER_LIST_ITEM *item = ppro->ListGetItemPtr(LIST_FILE, szPort);
@@ -259,12 +259,12 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft)
HANDLE hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
ft->hFileEvent = hEvent;
- wchar_t szPort[20];
- mir_snwprintf(szPort, L"%d", nlb.wPort);
+ char szPort[20];
+ _itoa(nlb.wPort, szPort, 10);
JABBER_LIST_ITEM *item = ListAdd(LIST_FILE, szPort);
item->ft = ft;
- wchar_t *ptszResource = ListGetBestClientResourceNamePtr(ft->jid);
+ char *ptszResource = ListGetBestClientResourceNamePtr(ft->jid);
if (ptszResource != nullptr) {
ft->state = FT_CONNECTING;
for (int i = 0; i < ft->std.totalFiles && ft->state != FT_ERROR && ft->state != FT_DENIED; i++) {
@@ -296,14 +296,10 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft)
char szAddr[256];
mir_snprintf(szAddr, "http://%s:%d/%s", myAddr, nlb.wPort, pFileName.c_str());
- size_t len = mir_wstrlen(ptszResource) + mir_wstrlen(ft->jid) + 2;
- wchar_t *fulljid = (wchar_t *)alloca(sizeof(wchar_t) * len);
- mir_snwprintf(fulljid, len, L"%s/%s", ft->jid, ptszResource);
-
- XmlNodeIq iq(L"set", ft->szId, fulljid);
- HXML query = iq << XQUERY(JABBER_FEAT_OOB);
- query << XCHILD(L"url", _A2T(szAddr));
- query << XCHILD(L"desc", ft->szDescription);
+ XmlNodeIq iq("set", ft->szId, CMStringA(FORMAT, "%s/%s", ft->jid, ptszResource));
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_OOB);
+ query << XCHILD("url", szAddr);
+ query << XCHILD("desc", T2Utf(ft->szDescription));
m_ThreadInfo->send(iq);
debugLogA("Waiting for the file to be sent...");
diff --git a/protocols/JabberG/src/jabber_form.cpp b/protocols/JabberG/src/jabber_form.cpp
index 9b0afed74f..01eab07b01 100644
--- a/protocols/JabberG/src/jabber_form.cpp
+++ b/protocols/JabberG/src/jabber_form.cpp
@@ -104,33 +104,11 @@ void JabberFormCenterContent(HWND hwndStatic)
}
}
-void JabberFormSetInstruction(HWND hwndForm, const wchar_t *text)
+void JabberFormSetInstruction(HWND hwndForm, const char *text)
{
- if (!text) text = L"";
-
- size_t len = mir_wstrlen(text);
- size_t fixedLen = len;
- for (size_t i = 1; i < len; i++)
- if ((text[i - 1] == '\n') && (text[i] != '\r'))
- ++fixedLen;
-
- wchar_t *fixedText = nullptr;
- if (fixedLen != len) {
- fixedText = (wchar_t *)mir_alloc(sizeof(wchar_t) * (fixedLen + 1));
- wchar_t *p = fixedText;
- for (size_t i = 0; i < len; i++) {
- *p = text[i];
- if (i && (text[i] == '\n') && (text[i] != '\r')) {
- *p++ = '\r';
- *p = '\n';
- }
- ++p;
- }
- *p = 0;
- text = fixedText;
- }
-
- SetDlgItemText(hwndForm, IDC_INSTRUCTION, text);
+ CMStringW buf(text == nullptr ? "" : text);
+ buf.Replace(L"\n\r", L"\r\n");
+ SetDlgItemText(hwndForm, IDC_INSTRUCTION, buf);
RECT rcText;
GetWindowRect(GetDlgItem(hwndForm, IDC_INSTRUCTION), &rcText);
@@ -140,7 +118,7 @@ void JabberFormSetInstruction(HWND hwndForm, const wchar_t *text)
SetRect(&rcText, 0, 0, rcText.right - rcText.left, 0);
HDC hdcEdit = GetDC(GetDlgItem(hwndForm, IDC_INSTRUCTION));
HFONT hfntSave = (HFONT)SelectObject(hdcEdit, (HFONT)SendDlgItemMessage(hwndForm, IDC_INSTRUCTION, WM_GETFONT, 0, 0));
- DrawTextEx(hdcEdit, (wchar_t *)text, (int)mir_wstrlen(text), &rcText, DT_CALCRECT | DT_EDITCONTROL | DT_TOP | DT_WORDBREAK, nullptr);
+ DrawTextExW(hdcEdit, buf.GetBuffer(), buf.GetLength(), &rcText, DT_CALCRECT | DT_EDITCONTROL | DT_TOP | DT_WORDBREAK, nullptr);
SelectObject(hdcEdit, hfntSave);
ReleaseDC(GetDlgItem(hwndForm, IDC_INSTRUCTION), hdcEdit);
@@ -197,38 +175,38 @@ void JabberFormSetInstruction(HWND hwndForm, const wchar_t *text)
rcText.right - rcText.left,
rcText.bottom - rcText.top,
SWP_NOZORDER);
-
- if (fixedText) mir_free(fixedText);
}
-static TJabberFormControlType JabberFormTypeNameToId(const wchar_t *type)
+static TJabberFormControlType JabberFormTypeNameToId(const char *type)
{
- if (!mir_wstrcmp(type, L"text-private"))
+ if (!mir_strcmp(type, "text-private"))
return JFORM_CTYPE_TEXT_PRIVATE;
- if (!mir_wstrcmp(type, L"text-multi") || !mir_wstrcmp(type, L"jid-multi"))
+ if (!mir_strcmp(type, "text-multi") || !mir_strcmp(type, "jid-multi"))
return JFORM_CTYPE_TEXT_MULTI;
- if (!mir_wstrcmp(type, L"boolean"))
+ if (!mir_strcmp(type, "boolean"))
return JFORM_CTYPE_BOOLEAN;
- if (!mir_wstrcmp(type, L"list-single"))
+ if (!mir_strcmp(type, "list-single"))
return JFORM_CTYPE_LIST_SINGLE;
- if (!mir_wstrcmp(type, L"list-multi"))
+ if (!mir_strcmp(type, "list-multi"))
return JFORM_CTYPE_LIST_MULTI;
- if (!mir_wstrcmp(type, L"fixed"))
+ if (!mir_strcmp(type, "fixed"))
return JFORM_CTYPE_FIXED;
- if (!mir_wstrcmp(type, L"hidden"))
+ if (!mir_strcmp(type, "hidden"))
return JFORM_CTYPE_HIDDEN;
return JFORM_CTYPE_TEXT_SINGLE;
}
-void JabberFormLayoutSingleControl(TJabberFormControlInfo *item, TJabberFormLayoutInfo *layout_info, const wchar_t *labelStr, const wchar_t *valueStr)
+void JabberFormLayoutSingleControl(TJabberFormControlInfo *item, TJabberFormLayoutInfo *layout_info, const char *labelStr, const char *valueStr)
{
+ Utf2T wszLabel(labelStr), wszValue(valueStr);
+
RECT rcLabel = { 0 }, rcCtrl = { 0 };
if (item->hLabel) {
SetRect(&rcLabel, 0, 0, layout_info->width, 0);
HDC hdc = GetDC(item->hLabel);
HFONT hfntSave = (HFONT)SelectObject(hdc, (HFONT)SendMessage(item->hLabel, WM_GETFONT, 0, 0));
- DrawText(hdc, labelStr, -1, &rcLabel, DT_CALCRECT | DT_WORDBREAK);
+ DrawTextW(hdc, wszLabel, -1, &rcLabel, DT_CALCRECT | DT_WORDBREAK);
SelectObject(hdc, hfntSave);
ReleaseDC(item->hLabel, hdc);
}
@@ -248,7 +226,7 @@ void JabberFormLayoutSingleControl(TJabberFormControlInfo *item, TJabberFormLayo
SetRect(&rcCtrl, 0, 0, layout_info->width - 20, 0);
HDC hdc = GetDC(item->hCtrl);
HFONT hfntSave = (HFONT)SelectObject(hdc, (HFONT)SendMessage(item->hCtrl, WM_GETFONT, 0, 0));
- DrawText(hdc, labelStr, -1, &rcCtrl, DT_CALCRECT | DT_RIGHT | DT_WORDBREAK);
+ DrawText(hdc, wszLabel, -1, &rcCtrl, DT_CALCRECT | DT_RIGHT | DT_WORDBREAK);
SelectObject(hdc, hfntSave);
ReleaseDC(item->hCtrl, hdc);
rcCtrl.right += 20;
@@ -257,7 +235,7 @@ void JabberFormLayoutSingleControl(TJabberFormControlInfo *item, TJabberFormLayo
SetRect(&rcCtrl, 0, 0, layout_info->width, 0);
HDC hdc = GetDC(item->hCtrl);
HFONT hfntSave = (HFONT)SelectObject(hdc, (HFONT)SendMessage(item->hCtrl, WM_GETFONT, 0, 0));
- DrawText(hdc, valueStr, -1, &rcCtrl, DT_CALCRECT | DT_EDITCONTROL);
+ DrawText(hdc, wszValue, -1, &rcCtrl, DT_CALCRECT | DT_EDITCONTROL);
rcCtrl.right += 20;
SelectObject(hdc, hfntSave);
ReleaseDC(item->hCtrl, hdc);
@@ -281,10 +259,10 @@ void JabberFormLayoutSingleControl(TJabberFormControlInfo *item, TJabberFormLayo
}
#define JabberFormCreateLabel() \
- CreateWindow(L"static", labelStr, WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE, \
+ CreateWindow(L"static", wszLabel, WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE, \
0, 0, 0, 0, hwndStatic, (HMENU)-1, g_plugin.getInst(), nullptr)
-TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayoutInfo *layout_info, TJabberFormControlType type, const wchar_t *labelStr, const wchar_t *valueStr)
+HJFORMCTRL JabberFormAppendControl(HWND hwndStatic, HJFORMLAYOUT layout_info, TJabberFormControlType type, const char *labelStr, const char *valueStr)
{
TJabberFormControlList *controls = (TJabberFormControlList *)GetWindowLongPtr(hwndStatic, GWLP_USERDATA);
if (!controls) {
@@ -295,11 +273,12 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo
TJabberFormControlInfo *item = (TJabberFormControlInfo *)mir_alloc(sizeof(TJabberFormControlInfo));
item->type = type;
item->hLabel = item->hCtrl = nullptr;
+ Utf2T wszLabel(labelStr), wszValue(valueStr);
switch (type) {
case JFORM_CTYPE_TEXT_PRIVATE:
item->hLabel = JabberFormCreateLabel();
- item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, L"edit", valueStr,
+ item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, L"edit", wszValue,
WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD,
0, 0, 0, 0,
hwndStatic, (HMENU)layout_info->id, g_plugin.getInst(), nullptr);
@@ -308,7 +287,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo
case JFORM_CTYPE_TEXT_MULTI:
item->hLabel = JabberFormCreateLabel();
- item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, L"edit", valueStr,
+ item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, L"edit", wszValue,
WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN,
0, 0, 0, 0,
hwndStatic, (HMENU)layout_info->id, g_plugin.getInst(), nullptr);
@@ -317,11 +296,11 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo
break;
case JFORM_CTYPE_BOOLEAN:
- item->hCtrl = CreateWindowEx(0, L"button", labelStr,
+ item->hCtrl = CreateWindowEx(0, L"button", wszLabel,
WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX | BS_MULTILINE,
0, 0, 0, 0,
hwndStatic, (HMENU)layout_info->id, g_plugin.getInst(), nullptr);
- if (valueStr && !mir_wstrcmp(valueStr, L"1"))
+ if (valueStr && !mir_wstrcmp(wszValue, L"1"))
SendMessage(item->hCtrl, BM_SETCHECK, 1, 0);
++layout_info->id;
break;
@@ -345,7 +324,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo
break;
case JFORM_CTYPE_FIXED:
- item->hCtrl = CreateWindow(L"edit", valueStr,
+ item->hCtrl = CreateWindow(L"edit", wszValue,
WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_READONLY | ES_AUTOHSCROLL,
0, 0, 0, 0,
hwndStatic, (HMENU)-1, g_plugin.getInst(), nullptr);
@@ -356,7 +335,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo
case JFORM_CTYPE_TEXT_SINGLE:
item->hLabel = labelStr ? (JabberFormCreateLabel()) : nullptr;
- item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, L"edit", valueStr,
+ item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, L"edit", wszValue,
WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_AUTOHSCROLL,
0, 0, 0, 0,
hwndStatic, (HMENU)layout_info->id, g_plugin.getInst(), nullptr);
@@ -374,22 +353,25 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo
return item;
}
-static void JabberFormAddListItem(TJabberFormControlInfo *item, const wchar_t *text, bool selected)
+static void JabberFormAddListItem(TJabberFormControlInfo *item, const char *text, bool selected)
{
+ Utf2T wszText(text);
+
DWORD dwIndex;
switch (item->type) {
case JFORM_CTYPE_LIST_MULTI:
- dwIndex = SendMessage(item->hCtrl, LB_ADDSTRING, 0, (LPARAM)text);
+ dwIndex = SendMessage(item->hCtrl, LB_ADDSTRING, 0, wszText);
if (selected) SendMessage(item->hCtrl, LB_SETSEL, TRUE, dwIndex);
break;
+
case JFORM_CTYPE_LIST_SINGLE:
- dwIndex = SendMessage(item->hCtrl, CB_ADDSTRING, 0, (LPARAM)text);
+ dwIndex = SendMessage(item->hCtrl, CB_ADDSTRING, 0, wszText);
if (selected) SendMessage(item->hCtrl, CB_SETCURSEL, dwIndex, 0);
break;
}
}
-void JabberFormLayoutControls(HWND hwndStatic, TJabberFormLayoutInfo *layout_info, int *formHeight)
+void JabberFormLayoutControls(HWND hwndStatic, HJFORMLAYOUT layout_info, int *formHeight)
{
TJabberFormControlList *controls = (TJabberFormControlList *)GetWindowLongPtr(hwndStatic, GWLP_USERDATA);
if (!controls) return;
@@ -429,19 +411,17 @@ HJFORMLAYOUT JabberFormCreateLayout(HWND hwndStatic)
return layout_info;
}
-void JabberFormCreateUI(HWND hwndStatic, HXML xNode, int *formHeight, BOOL bCompact)
+void JabberFormCreateUI(HWND hwndStatic, TiXmlElement *xNode, int *formHeight, BOOL bCompact)
{
JabberFormDestroyUI(hwndStatic);
- HXML v, vs;
+ const char *typeName, *str, *valueText, *labelStr;
+ char *valueStr;
- const wchar_t *label, *typeName, *varStr, *str, *valueText;
- wchar_t *labelStr, *valueStr;
- RECT frameRect;
-
- if (xNode == nullptr || XmlGetName(xNode) == nullptr || mir_wstrcmp(XmlGetName(xNode), L"x") || hwndStatic == nullptr)
+ if (xNode == nullptr || xNode->Name() == nullptr || mir_strcmp(xNode->Name(), "x") || hwndStatic == nullptr)
return;
+ RECT frameRect;
GetClientRect(hwndStatic, &frameRect);
TJabberFormLayoutInfo layout_info;
@@ -454,99 +434,67 @@ void JabberFormCreateUI(HWND hwndStatic, HXML xNode, int *formHeight, BOOL bComp
layout_info.maxLabelWidth = layout_info.width * 2 / 5;
layout_info.offset = 10;
layout_info.y_pos = bCompact ? 0 : 14;
- for (int i = 0;; i++) {
- HXML n = XmlGetChild(xNode, i);
- if (!n)
- break;
-
- if (mir_wstrcmp(XmlGetName(n), L"field"))
+ for (auto *n : TiXmlFilter(xNode, "field")) {
+ if ((typeName = n->Attribute("type")) == nullptr)
continue;
- varStr = XmlGetAttrValue(n, L"var");
- if ((typeName = XmlGetAttrValue(n, L"type")) == nullptr)
- continue;
-
- if ((label = XmlGetAttrValue(n, L"label")) != nullptr)
- labelStr = mir_wstrdup(label);
+ if (auto *label = n->Attribute("label"))
+ labelStr = label;
else
- labelStr = mir_wstrdup(varStr);
+ labelStr = n->Attribute("var");
TJabberFormControlType type = JabberFormTypeNameToId(typeName);
- if ((v = XmlGetChild(n, "value")) != nullptr) {
- valueText = XmlGetText(v);
+ if (auto *v = n->FirstChildElement("value")) {
+ valueText = v->GetText();
if (type != JFORM_CTYPE_TEXT_MULTI)
- valueStr = mir_wstrdup(valueText);
+ valueStr = mir_strdup(valueText);
else {
- size_t size = 1;
- for (int j = 0;; j++) {
- v = XmlGetChild(n, j);
- if (!v)
- break;
- if (XmlGetName(v) && !mir_wstrcmp(XmlGetName(v), L"value") && XmlGetText(v))
- size += mir_wstrlen(XmlGetText(v)) + 2;
- }
- valueStr = (wchar_t*)mir_alloc(sizeof(wchar_t)*size);
- valueStr[0] = '\0';
- for (int j = 0;; j++) {
- v = XmlGetChild(n, j);
- if (!v)
- break;
- if (XmlGetName(v) && !mir_wstrcmp(XmlGetName(v), L"value") && XmlGetText(v)) {
- if (valueStr[0])
- mir_wstrcat(valueStr, L"\r\n");
- mir_wstrcat(valueStr, XmlGetText(v));
+ CMStringA tmp;
+ for (auto *it : TiXmlEnum(n)) {
+ if (it->Name() && !mir_strcmp(it->Name(), "value") && it->GetText()) {
+ if (!tmp.IsEmpty())
+ tmp.Append("\r\n");
+ tmp.Append(it->GetText());
}
}
+ valueStr = tmp.Detach();
}
}
else valueText = valueStr = nullptr;
TJabberFormControlInfo *item = JabberFormAppendControl(hwndStatic, &layout_info, type, labelStr, valueStr);
- mir_free(labelStr);
mir_free(valueStr);
if (type == JFORM_CTYPE_LIST_SINGLE) {
- for (int j = 0;; j++) {
- HXML o = XmlGetChild(n, j);
- if (o == nullptr)
- break;
-
- if (mir_wstrcmp(XmlGetName(o), L"option"))
+ for (auto *o : TiXmlFilter(n, "option")) {
+ auto *v = o->FirstChildElement("value");
+ if (v == nullptr || v->GetText() == nullptr)
continue;
- if ((v = XmlGetChild(o, "value")) == nullptr || XmlGetText(v) == nullptr)
- continue;
- if ((str = XmlGetAttrValue(o, L"label")) == nullptr)
- str = XmlGetText(v);
+ if ((str = o->Attribute("label")) == nullptr)
+ str = v->GetText();
if (str == nullptr)
continue;
- bool selected = !mir_wstrcmp(valueText, XmlGetText(v));
+ bool selected = !mir_strcmp(valueText, v->GetText());
JabberFormAddListItem(item, str, selected);
}
}
else if (type == JFORM_CTYPE_LIST_MULTI) {
- for (int j = 0;; j++) {
- HXML o = XmlGetChild(n, j);
- if (o == nullptr)
- break;
-
- if (mir_wstrcmp(XmlGetName(o), L"option"))
+ for (auto *o : TiXmlFilter(n, "option")) {
+ auto *v = o->FirstChildElement("value");
+ if (v == nullptr || v->GetText() == nullptr)
continue;
- if ((v = XmlGetChild(o, "value")) == nullptr || XmlGetText(v) == nullptr)
- continue;
- if ((str = XmlGetAttrValue(o, L"label")) == nullptr)
- str = XmlGetText(v);
+
+ if ((str = o->Attribute("label")) == nullptr)
+ str = v->GetText();
if (str == nullptr)
continue;
bool selected = false;
- for (int k = 0;; k++) {
- vs = XmlGetChild(n, k);
- if (!vs)
- break;
- if (!mir_wstrcmp(XmlGetName(vs), L"value") && !mir_wstrcmp(XmlGetText(vs), XmlGetText(v))) {
+ for (auto *vs : TiXmlEnum(n)) {
+ if (!mir_strcmp(vs->Name(), "value") && !mir_strcmp(vs->GetText(), v->GetText())) {
selected = true;
break;
}
@@ -570,104 +518,83 @@ void JabberFormDestroyUI(HWND hwndStatic)
}
}
-HXML JabberFormGetData(HWND hwndStatic, HXML xNode)
+TiXmlElement* JabberFormGetData(HWND hwndStatic, TiXmlDocument *doc, TiXmlElement *xNode)
{
- HWND hFrame, hCtrl;
- HXML n, v, o;
- int id, j, k, len;
- const wchar_t *varName, *type, *fieldStr, *labelText, *str2;
+ const char *varName, *type, *labelText, *str2;
wchar_t *p, *q, *str;
- if (xNode == nullptr || XmlGetName(xNode) == nullptr || mir_wstrcmp(XmlGetName(xNode), L"x") || hwndStatic == nullptr)
+ if (xNode == nullptr || xNode->Name() == nullptr || mir_strcmp(xNode->Name(), "x") || hwndStatic == nullptr)
return nullptr;
- hFrame = hwndStatic;
- id = 0;
- XmlNode x(L"x");
- x << XATTR(L"xmlns", JABBER_FEAT_DATA_FORMS) << XATTR(L"type", L"submit");
-
- for (int i = 0;; i++) {
- n = XmlGetChild(xNode, i);
- if (!n)
- break;
+ HWND hFrame = hwndStatic;
+ int id = 0;
+ XmlNode x("x");
+ x << XATTR("xmlns", JABBER_FEAT_DATA_FORMS) << XATTR("type", "submit");
- fieldStr = nullptr;
- if (mir_wstrcmp(XmlGetName(n), L"field"))
+ for (auto *n : TiXmlFilter(xNode, "field")) {
+ if ((varName = n->Attribute("var")) == nullptr || (type = n->Attribute("type")) == nullptr)
continue;
- if ((varName = XmlGetAttrValue(n, L"var")) == nullptr || (type = XmlGetAttrValue(n, L"type")) == nullptr)
- continue;
-
- hCtrl = GetDlgItem(hFrame, id);
- HXML field = x << XCHILD(L"field") << XATTR(L"var", varName);
+ HWND hCtrl = GetDlgItem(hFrame, id);
+ TiXmlElement *field = x << XCHILD("field") << XATTR("var", varName);
- if (!mir_wstrcmp(type, L"text-multi") || !mir_wstrcmp(type, L"jid-multi")) {
- len = GetWindowTextLength(GetDlgItem(hFrame, id));
+ if (!mir_strcmp(type, "text-multi") || !mir_strcmp(type, "jid-multi")) {
+ int len = GetWindowTextLength(GetDlgItem(hFrame, id));
str = (wchar_t*)mir_alloc(sizeof(wchar_t)*(len + 1));
GetDlgItemText(hFrame, id, str, len + 1);
p = str;
while (p != nullptr) {
if ((q = wcsstr(p, L"\r\n")) != nullptr)
*q = '\0';
- field << XCHILD(L"value", p);
+ field << XCHILD("value", T2Utf(p));
p = q ? q + 2 : nullptr;
}
mir_free(str);
id++;
}
- else if (!mir_wstrcmp(type, L"boolean")) {
+ else if (!mir_strcmp(type, "boolean")) {
wchar_t buf[10];
_itow(IsDlgButtonChecked(hFrame, id) == BST_CHECKED ? 1 : 0, buf, 10);
- field << XCHILD(L"value", buf);
+ field << XCHILD("value", T2Utf(buf));
id++;
}
- else if (!mir_wstrcmp(type, L"list-single")) {
- len = GetWindowTextLength(GetDlgItem(hFrame, id));
+ else if (!mir_strcmp(type, "list-single")) {
+ int len = GetWindowTextLength(GetDlgItem(hFrame, id));
str = (wchar_t*)mir_alloc(sizeof(wchar_t)*(len + 1));
GetDlgItemText(hFrame, id, str, len + 1);
- v = nullptr;
- for (j = 0;; j++) {
- o = XmlGetChild(n, j);
- if (!o)
- break;
-
- if (!mir_wstrcmp(XmlGetName(o), L"option")) {
- if ((v = XmlGetChild(o, "value")) != nullptr && XmlGetText(v)) {
- if ((str2 = XmlGetAttrValue(o, L"label")) == nullptr)
- str2 = XmlGetText(v);
- if (!mir_wstrcmp(str2, str))
- break;
+
+ for (auto *o : TiXmlFilter(n, "option")) {
+ auto *v = o->FirstChildElement("value");
+ if (v != nullptr && v->GetText()) {
+ if ((str2 = o->Attribute("label")) == nullptr)
+ str2 = v->GetText();
+ if (!mir_strcmp(str2, T2Utf(str))) {
+ field << XCHILD("value", v->GetText());
+ break;
}
}
}
- if (o)
- field << XCHILD(L"value", XmlGetText(v));
-
mir_free(str);
id++;
}
- else if (!mir_wstrcmp(type, L"list-multi")) {
+ else if (!mir_strcmp(type, "list-multi")) {
int count = SendMessage(hCtrl, LB_GETCOUNT, 0, 0);
- for (j = 0; j < count; j++) {
+ for (int j = 0; j < count; j++) {
if (SendMessage(hCtrl, LB_GETSEL, j, 0) > 0) {
// an entry is selected
- len = SendMessage(hCtrl, LB_GETTEXTLEN, j, 0);
+ int len = SendMessage(hCtrl, LB_GETTEXTLEN, j, 0);
if ((str = (wchar_t*)mir_alloc((len + 1) * sizeof(wchar_t))) != nullptr) {
SendMessage(hCtrl, LB_GETTEXT, j, (LPARAM)str);
- for (k = 0;; k++) {
- o = XmlGetChild(n, k);
- if (!o)
- break;
-
- if (XmlGetName(o) && !mir_wstrcmp(XmlGetName(o), L"option")) {
- if ((v = XmlGetChild(o, "value")) != nullptr && XmlGetText(v)) {
- if ((labelText = XmlGetAttrValue(o, L"label")) == nullptr)
- labelText = XmlGetText(v);
-
- if (!mir_wstrcmp(labelText, str))
- field << XCHILD(L"value", XmlGetText(v));
- }
+
+ for (auto *o : TiXmlFilter(n, "option")) {
+ auto *v = o->FirstChildElement("value");
+ if (v != nullptr && v->GetText()) {
+ if ((labelText = o->Attribute("label")) == nullptr)
+ labelText = v->GetText();
+
+ if (!mir_strcmp(labelText, T2Utf(str)))
+ field << XCHILD("value", v->GetText());
}
}
mir_free(str);
@@ -676,22 +603,22 @@ HXML JabberFormGetData(HWND hwndStatic, HXML xNode)
}
id++;
}
- else if (!mir_wstrcmp(type, L"fixed") || !mir_wstrcmp(type, L"hidden")) {
- v = XmlGetChild(n, "value");
- if (v != nullptr && XmlGetText(v) != nullptr)
- field << XCHILD(L"value", XmlGetText(v));
+ else if (!mir_strcmp(type, "fixed") || !mir_strcmp(type, "hidden")) {
+ auto *v = n->FirstChildElement("value");
+ if (v != nullptr && v->GetText() != nullptr)
+ field << XCHILD("value", v->GetText());
}
else { // everything else is considered "text-single" or "text-private"
- len = GetWindowTextLength(GetDlgItem(hFrame, id));
+ int len = GetWindowTextLength(GetDlgItem(hFrame, id));
str = (wchar_t*)mir_alloc(sizeof(wchar_t)*(len + 1));
GetDlgItemText(hFrame, id, str, len + 1);
- field << XCHILD(L"value", str);
+ field << XCHILD("value", T2Utf(str));
mir_free(str);
id++;
}
}
- return xmlCopyNode(x);
+ return x.ToElement()->DeepClone(doc)->ToElement();
}
struct JABBER_FORM_INFO
@@ -699,7 +626,8 @@ struct JABBER_FORM_INFO
~JABBER_FORM_INFO();
CJabberProto *ppro;
- HXML xNode;
+ TiXmlDocument doc;
+ TiXmlElement *xNode;
wchar_t defTitle[128]; // Default title if no <title/> in xNode
RECT frameRect; // Clipping region of the frame to scroll
int frameHeight; // Height of the frame (can be eliminated, redundant to frameRect)
@@ -720,22 +648,22 @@ static INT_PTR CALLBACK JabberFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
ShowWindow(GetDlgItem(hwndDlg, IDC_FRAME_TEXT), SW_HIDE);
jfi = (JABBER_FORM_INFO*)lParam;
if (jfi != nullptr) {
- HXML n;
+ TiXmlElement *n;
LONG frameExStyle;
// Set dialog title
- if (jfi->xNode != nullptr && (n = XmlGetChild(jfi->xNode, L"title")) != nullptr && XmlGetText(n) != nullptr)
- SetWindowText(hwndDlg, XmlGetText(n));
+ if (jfi->xNode != nullptr && (n = jfi->xNode->FirstChildElement("title")) != nullptr && n->GetText() != nullptr)
+ SetWindowText(hwndDlg, Utf2T(n->GetText()));
else
SetWindowText(hwndDlg, TranslateW(jfi->defTitle));
// Set instruction field
- if (jfi->xNode != nullptr && (n = XmlGetChild(jfi->xNode, L"instructions")) != nullptr && XmlGetText(n) != nullptr)
- JabberFormSetInstruction(hwndDlg, XmlGetText(n));
+ if (jfi->xNode != nullptr && (n = jfi->xNode->FirstChildElement("instructions")) != nullptr && n->GetText() != nullptr)
+ JabberFormSetInstruction(hwndDlg, n->GetText());
else {
- if (jfi->xNode != nullptr && (n = XmlGetChild(jfi->xNode, L"title")) != nullptr && XmlGetText(n) != nullptr)
- JabberFormSetInstruction(hwndDlg, XmlGetText(n));
+ if (jfi->xNode != nullptr && (n = jfi->xNode->FirstChildElement("title")) != nullptr && n->GetText() != nullptr)
+ JabberFormSetInstruction(hwndDlg, n->GetText());
else
- JabberFormSetInstruction(hwndDlg, TranslateW(jfi->defTitle));
+ JabberFormSetInstruction(hwndDlg, Translate(T2Utf(jfi->defTitle)));
}
// Create form
@@ -823,9 +751,8 @@ static INT_PTR CALLBACK JabberFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
switch (LOWORD(wParam)) {
case IDC_SUBMIT:
if (jfi != nullptr) {
- HXML n = JabberFormGetData(GetDlgItem(hwndDlg, IDC_FRAME), jfi->xNode);
+ TiXmlElement *n = JabberFormGetData(GetDlgItem(hwndDlg, IDC_FRAME), &jfi->doc, jfi->xNode);
(jfi->ppro->*(jfi->pfnSubmit))(n, jfi->userdata);
- xmlDestroyNode(n);
}
__fallthrough;
@@ -854,14 +781,14 @@ static VOID CALLBACK JabberFormCreateDialogApcProc(void* param)
CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FORM), nullptr, JabberFormDlgProc, (LPARAM)param);
}
-void CJabberProto::FormCreateDialog(HXML xNode, wchar_t* defTitle, JABBER_FORM_SUBMIT_FUNC pfnSubmit, void *userdata)
+void CJabberProto::FormCreateDialog(const TiXmlElement *xNode, char *defTitle, JABBER_FORM_SUBMIT_FUNC pfnSubmit, void *userdata)
{
JABBER_FORM_INFO *jfi = new JABBER_FORM_INFO;
memset(jfi, 0, sizeof(JABBER_FORM_INFO));
jfi->ppro = this;
- jfi->xNode = xmlCopyNode(xNode);
+ jfi->xNode = xNode->DeepClone(&jfi->doc)->ToElement();
if (defTitle)
- wcsncpy_s(jfi->defTitle, defTitle, _TRUNCATE);
+ wcsncpy_s(jfi->defTitle, Utf2T(defTitle), _TRUNCATE);
jfi->pfnSubmit = pfnSubmit;
jfi->userdata = userdata;
@@ -872,6 +799,5 @@ void CJabberProto::FormCreateDialog(HXML xNode, wchar_t* defTitle, JABBER_FORM_S
JABBER_FORM_INFO::~JABBER_FORM_INFO()
{
- xmlDestroyNode(xNode);
mir_free(userdata);
}
diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp
index 36e300ed38..5ba46f181e 100644
--- a/protocols/JabberG/src/jabber_ft.cpp
+++ b/protocols/JabberG/src/jabber_ft.cpp
@@ -75,12 +75,11 @@ void CJabberProto::FtCancel(filetransfer *ft)
///////////////// File sending using stream initiation /////////////////////////
-void CJabberProto::FtInitiate(wchar_t* jid, filetransfer *ft)
+void CJabberProto::FtInitiate(char* jid, filetransfer *ft)
{
- wchar_t *rs;
- wchar_t *filename, *p;
+ char *rs;
int i;
- wchar_t sid[9];
+ char sid[9];
if (jid == nullptr || ft == nullptr || !m_bJabberOnline || (rs = ListGetBestClientResourceNamePtr(jid)) == nullptr) {
if (ft) {
@@ -93,60 +92,58 @@ void CJabberProto::FtInitiate(wchar_t* jid, filetransfer *ft)
for (i = 0; i < 8; i++)
sid[i] = (rand() % 10) + '0';
sid[8] = '\0';
- if (ft->sid != nullptr) mir_free(ft->sid);
- ft->sid = mir_wstrdup(sid);
- filename = ft->std.pszFiles.w[ft->std.currentFileNumber];
- if ((p = wcsrchr(filename, '\\')) != nullptr)
+ replaceStr(ft->sid, sid);
+ wchar_t *filename = ft->std.pszFiles.w[ft->std.currentFileNumber];
+ if (wchar_t *p = wcsrchr(filename, '\\'))
filename = p + 1;
- wchar_t tszJid[512];
- mir_snwprintf(tszJid, L"%s/%s", jid, rs);
+ char tszJid[512];
+ mir_snprintf(tszJid, "%s/%s", jid, rs);
XmlNodeIq iq(AddIQ(&CJabberProto::OnFtSiResult, JABBER_IQ_TYPE_SET, tszJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO, -1, ft));
- HXML si = iq << XCHILDNS(L"si", JABBER_FEAT_SI) << XATTR(L"id", sid)
- << XATTR(L"mime-type", L"binary/octet-stream") << XATTR(L"profile", JABBER_FEAT_SI_FT);
- si << XCHILDNS(L"file", JABBER_FEAT_SI_FT) << XATTR(L"name", filename)
- << XATTRI64(L"size", ft->fileSize[ft->std.currentFileNumber]) << XCHILD(L"desc", ft->szDescription);
+ TiXmlElement *si = iq << XCHILDNS("si", JABBER_FEAT_SI) << XATTR("id", sid)
+ << XATTR("mime-type", "binary/octet-stream") << XATTR("profile", JABBER_FEAT_SI_FT);
+ si << XCHILDNS("file", JABBER_FEAT_SI_FT) << XATTR("name", T2Utf(filename))
+ << XATTRI64("size", ft->fileSize[ft->std.currentFileNumber]) << XCHILD("desc", T2Utf(ft->szDescription));
- HXML field = si << XCHILDNS(L"feature", JABBER_FEAT_FEATURE_NEG)
- << XCHILDNS(L"x", JABBER_FEAT_DATA_FORMS) << XATTR(L"type", L"form")
- << XCHILD(L"field") << XATTR(L"var", L"stream-method") << XATTR(L"type", L"list-single");
+ TiXmlElement *field = si << XCHILDNS("feature", JABBER_FEAT_FEATURE_NEG)
+ << XCHILDNS("x", JABBER_FEAT_DATA_FORMS) << XATTR("type", "form")
+ << XCHILD("field") << XATTR("var", "stream-method") << XATTR("type", "list-single");
BOOL bDirect = m_bBsDirect;
BOOL bProxy = m_bBsProxyManual;
// bytestreams support?
if (bDirect || bProxy)
- field << XCHILD(L"option") << XCHILD(L"value", JABBER_FEAT_BYTESTREAMS);
+ field << XCHILD("option") << XCHILD("value", JABBER_FEAT_BYTESTREAMS);
- field << XCHILD(L"option") << XCHILD(L"value", JABBER_FEAT_IBB);
+ field << XCHILD("option") << XCHILD("value", JABBER_FEAT_IBB);
m_ThreadInfo->send(iq);
}
-void CJabberProto::OnFtSiResult(HXML iqNode, CJabberIqInfo *pInfo)
+void CJabberProto::OnFtSiResult(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
- HXML siNode, featureNode, xNode, fieldNode, valueNode;
filetransfer *ft = (filetransfer *)pInfo->GetUserData();
- if (!ft) return;
+ if (!ft)
+ return;
if ((pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) && pInfo->m_szFrom && pInfo->m_szTo) {
- if ((siNode = XmlGetChild(iqNode, "si")) != nullptr) {
-
+ if (auto *siNode = iqNode->FirstChildElement("si")) {
// fix for very smart clients, like gajim
BOOL bDirect = m_bBsDirect;
BOOL bProxy = m_bBsProxyManual;
- if ((featureNode = XmlGetChild(siNode, "feature")) != nullptr) {
- if ((xNode = XmlGetChildByTag(featureNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS)) != nullptr) {
- if ((fieldNode = XmlGetChildByTag(xNode, "field", "var", L"stream-method")) != nullptr) {
- if ((valueNode = XmlGetChild(fieldNode, "value")) != nullptr && XmlGetText(valueNode) != nullptr) {
- if ((bDirect || bProxy) && !mir_wstrcmp(XmlGetText(valueNode), JABBER_FEAT_BYTESTREAMS)) {
+ if (auto *featureNode = siNode->FirstChildElement("feature")) {
+ if (auto *xNode = XmlGetChildByTag(featureNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS)) {
+ if (auto *fieldNode = XmlGetChildByTag(xNode, "field", "var", "stream-method")) {
+ if (auto *valueNode = fieldNode->FirstChildElement("value")) {
+ if ((bDirect || bProxy) && !mir_strcmp(valueNode->GetText(), JABBER_FEAT_BYTESTREAMS)) {
// Start Bytestream session
JABBER_BYTE_TRANSFER *jbt = new JABBER_BYTE_TRANSFER;
memset(jbt, 0, sizeof(JABBER_BYTE_TRANSFER));
- jbt->srcJID = mir_wstrdup(pInfo->m_szTo);
- jbt->dstJID = mir_wstrdup(pInfo->m_szFrom);
- jbt->sid = mir_wstrdup(ft->sid);
+ jbt->srcJID = mir_strdup(pInfo->m_szTo);
+ jbt->dstJID = mir_strdup(pInfo->m_szFrom);
+ jbt->sid = mir_strdup(ft->sid);
jbt->pfnSend = &CJabberProto::FtSend;
jbt->pfnFinal = &CJabberProto::FtSendFinal;
jbt->ft = ft;
@@ -154,12 +151,12 @@ void CJabberProto::OnFtSiResult(HXML iqNode, CJabberIqInfo *pInfo)
ft->jbt = jbt;
ForkThread((MyThreadFunc)&CJabberProto::ByteSendThread, jbt);
}
- else if (!mir_wstrcmp(XmlGetText(valueNode), JABBER_FEAT_IBB)) {
+ else if (!mir_strcmp(valueNode->GetText(), JABBER_FEAT_IBB)) {
JABBER_IBB_TRANSFER *jibb = (JABBER_IBB_TRANSFER *)mir_alloc(sizeof(JABBER_IBB_TRANSFER));
memset(jibb, 0, sizeof(JABBER_IBB_TRANSFER));
- jibb->srcJID = mir_wstrdup(pInfo->m_szTo);
- jibb->dstJID = mir_wstrdup(pInfo->m_szFrom);
- jibb->sid = mir_wstrdup(ft->sid);
+ jibb->srcJID = mir_strdup(pInfo->m_szTo);
+ jibb->dstJID = mir_strdup(pInfo->m_szFrom);
+ jibb->sid = mir_strdup(ft->sid);
jibb->pfnSend = &CJabberProto::FtIbbSend;
jibb->pfnFinal = &CJabberProto::FtSendFinal;
jibb->ft = ft;
@@ -237,21 +234,21 @@ BOOL CJabberProto::FtIbbSend(int blocksize, filetransfer *ft)
int numRead;
while ((numRead = _read(fd, buffer, blocksize)) > 0) {
int iqId = SerialNext();
- XmlNode msg(L"message");
- XmlAddAttr(msg, L"to", ft->jibb->dstJID);
+ XmlNode msg("message");
+ XmlAddAttr(msg, "to", ft->jibb->dstJID);
msg << XATTRID(iqId);
// let others send data too
Sleep(2);
- msg << XCHILD(L"data", _A2T(ptrA(mir_base64_encode(buffer, numRead)))) << XATTR(L"xmlns", JABBER_FEAT_IBB)
- << XATTR(L"sid", ft->jibb->sid) << XATTRI(L"seq", ft->jibb->wPacketId);
+ msg << XCHILD("data", ptrA(mir_base64_encode(buffer, numRead))) << XATTR("xmlns", JABBER_FEAT_IBB)
+ << XATTR("sid", ft->jibb->sid) << XATTRI("seq", ft->jibb->wPacketId);
- HXML ampNode = msg << XCHILDNS(L"amp", JABBER_FEAT_AMP);
- ampNode << XCHILD(L"rule") << XATTR(L"condition", L"deliver-at")
- << XATTR(L"value", L"stored") << XATTR(L"action", L"error");
- ampNode << XCHILD(L"rule") << XATTR(L"condition", L"match-resource")
- << XATTR(L"value", L"exact") << XATTR(L"action", L"error");
+ TiXmlElement *ampNode = msg << XCHILDNS("amp", JABBER_FEAT_AMP);
+ ampNode << XCHILD("rule") << XATTR("condition", "deliver-at")
+ << XATTR("value", "stored") << XATTR("action", "error");
+ ampNode << XCHILD("rule") << XATTR("condition", "match-resource")
+ << XATTR("value", "exact") << XATTR("action", "error");
ft->jibb->wPacketId++;
if (ft->jibb->state == JIBB_ERROR || ft->jibb->bStreamClosed || m_ThreadInfo->send(msg) == SOCKET_ERROR) {
@@ -294,46 +291,40 @@ void CJabberProto::FtSendFinal(BOOL success, filetransfer *ft)
///////////////// File receiving through stream initiation /////////////////////////
-void CJabberProto::FtHandleSiRequest(HXML iqNode)
+void CJabberProto::FtHandleSiRequest(const TiXmlElement *iqNode)
{
- const wchar_t *from, *sid, *str, *szId, *filename;
- HXML siNode, fileNode, featureNode, xNode, fieldNode, n;
- int i;
- unsigned __int64 filesize;
+ const char *from, *sid, *str, *szId, *filename;
+ const TiXmlElement *siNode, *fileNode, *featureNode, *xNode, *fieldNode;
if (!iqNode ||
- (from = XmlGetAttrValue(iqNode, L"from")) == nullptr ||
- (str = XmlGetAttrValue(iqNode, L"type")) == nullptr || mir_wstrcmp(str, L"set") ||
+ (from = iqNode->Attribute("from")) == nullptr ||
+ (str = iqNode->Attribute("type")) == nullptr || mir_strcmp(str, "set") ||
(siNode = XmlGetChildByTag(iqNode, "si", "xmlns", JABBER_FEAT_SI)) == nullptr)
return;
- szId = XmlGetAttrValue(iqNode, L"id");
- if ((sid = XmlGetAttrValue(siNode, L"id")) != nullptr &&
+ szId = iqNode->Attribute("id");
+ if ((sid = siNode->Attribute("id")) != nullptr &&
(fileNode = XmlGetChildByTag(siNode, "file", "xmlns", JABBER_FEAT_SI_FT)) != nullptr &&
- (filename = XmlGetAttrValue(fileNode, L"name")) != nullptr &&
- (str = XmlGetAttrValue(fileNode, L"size")) != nullptr) {
+ (filename = fileNode->Attribute("name")) != nullptr &&
+ (str = fileNode->Attribute("size")) != nullptr) {
- filesize = _wtoi64(str);
+ unsigned __int64 filesize = _atoi64(str);
if ((featureNode = XmlGetChildByTag(siNode, "feature", "xmlns", JABBER_FEAT_FEATURE_NEG)) != nullptr &&
(xNode = XmlGetChildByTag(featureNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS)) != nullptr &&
- (fieldNode = XmlGetChildByTag(xNode, "field", "var", L"stream-method")) != nullptr) {
+ (fieldNode = XmlGetChildByTag(xNode, "field", "var", "stream-method")) != nullptr) {
BOOL bIbbOnly = m_bBsOnlyIBB;
- HXML optionNode = nullptr;
+ const TiXmlElement *optionNode = nullptr;
JABBER_FT_TYPE ftType = FT_OOB;
if (!bIbbOnly) {
- for (i = 0; ; i++) {
- optionNode = XmlGetChild(fieldNode, i);
- if (!optionNode)
- break;
-
- if (!mir_wstrcmp(XmlGetName(optionNode), L"option")) {
- if ((n = XmlGetChild(optionNode, "value")) != nullptr && XmlGetText(n)) {
- if (!mir_wstrcmp(XmlGetText(n), JABBER_FEAT_BYTESTREAMS)) {
- ftType = FT_BYTESTREAM;
- break;
- }
+ for (auto *it : TiXmlFilter(fieldNode, "option")) {
+ auto *n = it->FirstChildElement("value");
+ if (n != nullptr && n->GetText()) {
+ if (!mir_strcmp(n->GetText(), JABBER_FEAT_BYTESTREAMS)) {
+ optionNode = it;
+ ftType = FT_BYTESTREAM;
+ break;
}
}
}
@@ -341,17 +332,13 @@ void CJabberProto::FtHandleSiRequest(HXML iqNode)
// try IBB only if bytestreams support not found or BsOnlyIBB flag exists
if (bIbbOnly || !optionNode) {
- for (i = 0; ; i++) {
- optionNode = XmlGetChild(fieldNode, i);
- if (!optionNode)
- break;
-
- if (!mir_wstrcmp(XmlGetName(optionNode), L"option")) {
- if ((n = XmlGetChild(optionNode, "value")) != nullptr && XmlGetText(n)) {
- if (!mir_wstrcmp(XmlGetText(n), JABBER_FEAT_IBB)) {
- ftType = FT_IBB;
- break;
- }
+ for (auto *it : TiXmlFilter(fieldNode, "option")) {
+ auto *n = it->FirstChildElement("value");
+ if (n != nullptr && n->GetText()) {
+ if (!mir_strcmp(n->GetText(), JABBER_FEAT_IBB)) {
+ optionNode = it;
+ ftType = FT_IBB;
+ break;
}
}
}
@@ -361,44 +348,38 @@ void CJabberProto::FtHandleSiRequest(HXML iqNode)
// Found known stream mechanism
filetransfer *ft = new filetransfer(this);
ft->dwExpectedRecvFileSize = filesize;
- ft->jid = mir_wstrdup(from);
+ ft->jid = mir_strdup(from);
ft->std.hContact = HContactFromJID(from);
- ft->sid = mir_wstrdup(sid);
- ft->szId = mir_wstrdup(szId);
+ ft->sid = mir_strdup(sid);
+ ft->szId = mir_strdup(szId);
ft->type = ftType;
ft->std.totalFiles = 1;
- ft->std.szCurrentFile.w = mir_wstrdup(filename);
+ ft->std.szCurrentFile.w = mir_utf8decodeW(filename);
ft->std.totalBytes = ft->std.currentFileSize = filesize;
+ CMStringW wszDescr;
+
PROTORECVFILE pre = { 0 };
pre.dwFlags = PRFF_UNICODE;
pre.fileCount = 1;
pre.timestamp = time(0);
pre.files.w = (wchar_t**)&filename;
pre.lParam = (LPARAM)ft;
- if ((n = XmlGetChild(fileNode, "desc")) != nullptr)
- pre.descr.w = (wchar_t*)XmlGetText(n);
+ if (auto *n = fileNode->FirstChildElement("desc"))
+ wszDescr = Utf2T(n->GetText());
+ pre.descr.w = wszDescr.GetBuffer();
ProtoChainRecvFile(ft->std.hContact, &pre);
return;
}
- else {
- // Unknown stream mechanism
- XmlNodeIq iq(L"error", szId, from);
- HXML e = iq << XCHILD(L"error") << XATTRI(L"code", 400) << XATTR(L"type", L"cancel");
- e << XCHILDNS(L"bad-request", L"urn:ietf:params:xml:ns:xmpp-stanzas");
- e << XCHILDNS(L"no-valid-streams", JABBER_FEAT_SI);
- m_ThreadInfo->send(iq);
- return;
- }
}
}
// Bad stream initiation, reply with bad-profile
- XmlNodeIq iq(L"error", szId, from);
- HXML e = iq << XCHILD(L"error") << XATTRI(L"code", 400) << XATTR(L"type", L"cancel");
- e << XCHILDNS(L"bad-request", L"urn:ietf:params:xml:ns:xmpp-stanzas");
- e << XCHILDNS(L"bad-profile", JABBER_FEAT_SI);
+ XmlNodeIq iq("error", szId, from);
+ TiXmlElement *e = iq << XCHILD("error") << XATTRI("code", 400) << XATTR("type", "cancel");
+ e << XCHILDNS("bad-request", "urn:ietf:params:xml:ns:xmpp-stanzas");
+ e << XCHILDNS("bad-profile", JABBER_FEAT_SI);
m_ThreadInfo->send(iq);
}
@@ -411,12 +392,12 @@ void CJabberProto::FtAcceptSiRequest(filetransfer *ft)
item->ft = ft;
m_ThreadInfo->send(
- XmlNodeIq(L"result", ft->szId, ft->jid)
- << XCHILDNS(L"si", JABBER_FEAT_SI)
- << XCHILDNS(L"feature", JABBER_FEAT_FEATURE_NEG)
- << XCHILDNS(L"x", JABBER_FEAT_DATA_FORMS) << XATTR(L"type", L"submit")
- << XCHILD(L"field") << XATTR(L"var", L"stream-method")
- << XCHILD(L"value", JABBER_FEAT_BYTESTREAMS));
+ XmlNodeIq("result", ft->szId, ft->jid)
+ << XCHILDNS("si", JABBER_FEAT_SI)
+ << XCHILDNS("feature", JABBER_FEAT_FEATURE_NEG)
+ << XCHILDNS("x", JABBER_FEAT_DATA_FORMS) << XATTR("type", "submit")
+ << XCHILD("field") << XATTR("var", "stream-method")
+ << XCHILD("value", JABBER_FEAT_BYTESTREAMS));
}
}
@@ -429,27 +410,26 @@ void CJabberProto::FtAcceptIbbRequest(filetransfer *ft)
item->ft = ft;
m_ThreadInfo->send(
- XmlNodeIq(L"result", ft->szId, ft->jid)
- << XCHILDNS(L"si", JABBER_FEAT_SI)
- << XCHILDNS(L"feature", JABBER_FEAT_FEATURE_NEG)
- << XCHILDNS(L"x", JABBER_FEAT_DATA_FORMS) << XATTR(L"type", L"submit")
- << XCHILD(L"field") << XATTR(L"var", L"stream-method")
- << XCHILD(L"value", JABBER_FEAT_IBB));
+ XmlNodeIq("result", ft->szId, ft->jid)
+ << XCHILDNS("si", JABBER_FEAT_SI)
+ << XCHILDNS("feature", JABBER_FEAT_FEATURE_NEG)
+ << XCHILDNS("x", JABBER_FEAT_DATA_FORMS) << XATTR("type", "submit")
+ << XCHILD("field") << XATTR("var", "stream-method")
+ << XCHILD("value", JABBER_FEAT_IBB));
}
}
-BOOL CJabberProto::FtHandleBytestreamRequest(HXML iqNode, CJabberIqInfo *pInfo)
+BOOL CJabberProto::FtHandleBytestreamRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
- HXML queryNode = pInfo->GetChildNode();
+ auto *queryNode = pInfo->GetChildNode();
- const wchar_t *sid;
- JABBER_LIST_ITEM *item;
+ const char *sid = queryNode->Attribute("sid");
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_FTRECV, sid);
- if ((sid = XmlGetAttrValue(queryNode, L"sid")) != nullptr && (item = ListGetItemPtr(LIST_FTRECV, sid)) != nullptr) {
+ if ((sid ) != nullptr && (item ) != nullptr) {
// Start Bytestream session
JABBER_BYTE_TRANSFER *jbt = new JABBER_BYTE_TRANSFER;
- memset(jbt, 0, sizeof(JABBER_BYTE_TRANSFER));
- jbt->iqNode = xmlCopyNode(iqNode);
+ jbt->iqNode = iqNode->DeepClone(&jbt->doc)->ToElement();
jbt->pfnRecv = &CJabberProto::FtReceive;
jbt->pfnFinal = &CJabberProto::FtReceiveFinal;
jbt->ft = item->ft;
@@ -463,28 +443,28 @@ BOOL CJabberProto::FtHandleBytestreamRequest(HXML iqNode, CJabberIqInfo *pInfo)
return TRUE;
}
-BOOL CJabberProto::FtHandleIbbRequest(HXML iqNode, BOOL bOpen)
+BOOL CJabberProto::FtHandleIbbRequest(const TiXmlElement *iqNode, BOOL bOpen)
{
if (iqNode == nullptr) return FALSE;
- const wchar_t *id = XmlGetAttrValue(iqNode, L"id");
- const wchar_t *from = XmlGetAttrValue(iqNode, L"from");
- const wchar_t *to = XmlGetAttrValue(iqNode, L"to");
+ const char *id = iqNode->Attribute("id");
+ const char *from = iqNode->Attribute("from");
+ const char *to = iqNode->Attribute("to");
if (!id || !from || !to) return FALSE;
- HXML ibbNode = XmlGetChildByTag(iqNode, bOpen ? "open" : "close", "xmlns", JABBER_FEAT_IBB);
+ auto *ibbNode = XmlGetChildByTag(iqNode, bOpen ? "open" : "close", "xmlns", JABBER_FEAT_IBB);
if (!ibbNode) return FALSE;
- const wchar_t *sid = XmlGetAttrValue(ibbNode, L"sid");
+ const char *sid = ibbNode->Attribute("sid");
if (!sid) return FALSE;
// already closed?
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_FTRECV, sid);
if (item == nullptr) {
m_ThreadInfo->send(
- XmlNodeIq(L"error", id, from)
- << XCHILD(L"error") << XATTRI(L"code", 404) << XATTR(L"type", L"cancel")
- << XCHILDNS(L"item-not-found", L"urn:ietf:params:xml:ns:xmpp-stanzas"));
+ XmlNodeIq("error", id, from)
+ << XCHILD("error") << XATTRI("code", 404) << XATTR("type", "cancel")
+ << XCHILDNS("item-not-found", "urn:ietf:params:xml:ns:xmpp-stanzas"));
return FALSE;
}
@@ -493,9 +473,9 @@ BOOL CJabberProto::FtHandleIbbRequest(HXML iqNode, BOOL bOpen)
if (!item->jibb) {
JABBER_IBB_TRANSFER *jibb = (JABBER_IBB_TRANSFER *)mir_alloc(sizeof(JABBER_IBB_TRANSFER));
memset(jibb, 0, sizeof(JABBER_IBB_TRANSFER));
- jibb->srcJID = mir_wstrdup(from);
- jibb->dstJID = mir_wstrdup(to);
- jibb->sid = mir_wstrdup(sid);
+ jibb->srcJID = mir_strdup(from);
+ jibb->dstJID = mir_strdup(to);
+ jibb->sid = mir_strdup(sid);
jibb->pfnRecv = &CJabberProto::FtReceive;
jibb->pfnFinal = &CJabberProto::FtReceiveFinal;
jibb->ft = item->ft;
@@ -503,14 +483,14 @@ BOOL CJabberProto::FtHandleIbbRequest(HXML iqNode, BOOL bOpen)
item->jibb = jibb;
ForkThread((MyThreadFunc)&CJabberProto::IbbReceiveThread, jibb);
- m_ThreadInfo->send(XmlNodeIq(L"result", id, from));
+ m_ThreadInfo->send(XmlNodeIq("result", id, from));
return TRUE;
}
// stream already open
m_ThreadInfo->send(
- XmlNodeIq(L"error", id, from)
- << XCHILD(L"error") << XATTRI(L"code", 404) << XATTR(L"type", L"cancel")
- << XCHILDNS(L"item-not-found", L"urn:ietf:params:xml:ns:xmpp-stanzas"));
+ XmlNodeIq("error", id, from)
+ << XCHILD("error") << XATTRI("code", 404) << XATTR("type", "cancel")
+ << XCHILDNS("item-not-found", "urn:ietf:params:xml:ns:xmpp-stanzas"));
return FALSE;
}
@@ -519,7 +499,7 @@ BOOL CJabberProto::FtHandleIbbRequest(HXML iqNode, BOOL bOpen)
item->jibb->bStreamClosed = TRUE;
SetEvent(item->jibb->hEvent);
- m_ThreadInfo->send(XmlNodeIq(L"result", id, from));
+ m_ThreadInfo->send(XmlNodeIq("result", id, from));
return TRUE;
}
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp
index b421cc2c3a..dda33f7879 100644
--- a/protocols/JabberG/src/jabber_groupchat.cpp
+++ b/protocols/JabberG/src/jabber_groupchat.cpp
@@ -33,19 +33,19 @@ int JabberGcGetStatus(JABBER_RESOURCE_STATUS *r);
struct JabberGcRecentInfo
{
- ptrW m_room, m_server, m_nick, m_password;
+ ptrA m_room, m_server, m_nick, m_password;
CJabberProto *ppro;
JabberGcRecentInfo(CJabberProto *proto)
{
ppro = proto;
}
- JabberGcRecentInfo(CJabberProto *proto, const wchar_t *room, const wchar_t *server, const wchar_t *nick = nullptr, const wchar_t *password = nullptr)
+ JabberGcRecentInfo(CJabberProto *proto, const char *room, const char *server, const char *nick = nullptr, const char *password = nullptr)
{
ppro = proto;
fillData(room, server, nick, password);
}
- JabberGcRecentInfo(CJabberProto *proto, const wchar_t *jid)
+ JabberGcRecentInfo(CJabberProto *proto, const char *jid)
{
ppro = proto;
fillData(jid);
@@ -65,7 +65,7 @@ struct JabberGcRecentInfo
m_room = m_server = m_nick = m_password = nullptr;
}
- BOOL equals(const wchar_t *room, const wchar_t *server, const wchar_t *nick = nullptr, const wchar_t *password = nullptr)
+ BOOL equals(const char *room, const char *server, const char *nick = nullptr, const char *password = nullptr)
{
return
null_strequals(m_room, room) &&
@@ -74,7 +74,7 @@ struct JabberGcRecentInfo
null_strequals(m_password, password);
}
- BOOL equalsnp(const wchar_t *room, const wchar_t *server, const wchar_t *nick = nullptr)
+ BOOL equalsnp(const char *room, const char *server, const char *nick = nullptr)
{
return
null_strequals(m_room, room) &&
@@ -84,29 +84,30 @@ struct JabberGcRecentInfo
void fillForm(HWND hwndDlg)
{
- SetDlgItemText(hwndDlg, IDC_SERVER, m_server ? m_server : L"");
- SetDlgItemText(hwndDlg, IDC_ROOM, m_room ? m_room : L"");
- SetDlgItemText(hwndDlg, IDC_NICK, m_nick ? m_nick : L"");
- SetDlgItemText(hwndDlg, IDC_PASSWORD, m_password ? m_password : L"");
+ SetDlgItemTextUtf(hwndDlg, IDC_SERVER, m_server ? m_server : "");
+ SetDlgItemTextUtf(hwndDlg, IDC_ROOM, m_room ? m_room : "");
+ SetDlgItemTextUtf(hwndDlg, IDC_NICK, m_nick ? m_nick : "");
+ SetDlgItemTextUtf(hwndDlg, IDC_PASSWORD, m_password ? m_password : "");
}
- void fillData(const wchar_t *room, const wchar_t *server, const wchar_t *nick = nullptr, const wchar_t *password = nullptr)
+ void fillData(const char *room, const char *server, const char *nick = nullptr, const char *password = nullptr)
{
- m_room = mir_wstrdup(room);
- m_server = mir_wstrdup(server);
- m_nick = mir_wstrdup(nick);
- m_password = mir_wstrdup(password);
+ m_room = mir_strdup(room);
+ m_server = mir_strdup(server);
+ m_nick = mir_strdup(nick);
+ m_password = mir_strdup(password);
}
- void fillData(const wchar_t *jid)
+ void fillData(const char *jid)
{
- wchar_t *room, *server, *nick = nullptr;
- room = NEWWSTR_ALLOCA(jid);
- server = wcschr(room, '@');
+ char *room, *server, *nick = nullptr;
+ room = NEWSTR_ALLOCA(jid);
+ server = strchr(room, '@');
if (server) {
*server++ = 0;
- nick = wcschr(server, '/');
- if (nick) *nick++ = 0;
+ nick = strchr(server, '/');
+ if (nick)
+ *nick++ = 0;
}
else {
server = room;
@@ -120,16 +121,16 @@ struct JabberGcRecentInfo
{
char setting[MAXMODULELABELLENGTH];
mir_snprintf(setting, "rcMuc_%d_server", iRecent);
- m_server = ppro->getWStringA(setting);
+ m_server = ppro->getUStringA(setting);
mir_snprintf(setting, "rcMuc_%d_room", iRecent);
- m_room = ppro->getWStringA(setting);
+ m_room = ppro->getUStringA(setting);
mir_snprintf(setting, "rcMuc_%d_nick", iRecent);
- m_nick = ppro->getWStringA(setting);
+ m_nick = ppro->getUStringA(setting);
mir_snprintf(setting, "password_rcMuc_%d", iRecent);
- m_password = ppro->getWStringA(0, setting);
+ m_password = ppro->getUStringA(0, setting);
return m_room || m_server || m_nick || m_password;
}
@@ -140,31 +141,31 @@ struct JabberGcRecentInfo
mir_snprintf(setting, "rcMuc_%d_server", iRecent);
if (m_server)
- ppro->setWString(setting, m_server);
+ ppro->setUString(setting, m_server);
else
ppro->delSetting(setting);
mir_snprintf(setting, "rcMuc_%d_room", iRecent);
if (m_room)
- ppro->setWString(setting, m_room);
+ ppro->setUString(setting, m_room);
else
ppro->delSetting(setting);
mir_snprintf(setting, "rcMuc_%d_nick", iRecent);
if (m_nick)
- ppro->setWString(setting, m_nick);
+ ppro->setUString(setting, m_nick);
else
ppro->delSetting(setting);
mir_snprintf(setting, "password_rcMuc_%d", iRecent);
if (m_password)
- ppro->setWString(setting, m_password);
+ ppro->setUString(setting, m_password);
else
ppro->delSetting(setting);
}
private:
- BOOL null_strequals(const wchar_t *str1, const wchar_t *str2)
+ BOOL null_strequals(const char *str1, const char *str2)
{
if (!str1 && !str2) return TRUE;
if (!str1 && str2 && !*str2) return TRUE;
@@ -173,7 +174,7 @@ private:
if (!str1 && str2) return FALSE;
if (!str2 && str1) return FALSE;
- return !mir_wstrcmp(str1, str2);
+ return !mir_strcmp(str1, str2);
}
};
@@ -185,19 +186,19 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleJoinGroupchat(WPARAM, LPARAM)
INT_PTR __cdecl CJabberProto::OnJoinChat(WPARAM hContact, LPARAM)
{
- ptrW jid(getWStringA(hContact, "ChatRoomID"));
+ ptrA jid(getUStringA(hContact, "ChatRoomID"));
if (jid == nullptr)
return 0;
- ptrW nick(getWStringA(hContact, "MyNick"));
+ ptrA nick(getUStringA(hContact, "MyNick"));
if (nick == nullptr)
- if ((nick = getWStringA("Nick")) == nullptr)
+ if ((nick = getUStringA("Nick")) == nullptr)
return 0;
- ptrW password(getWStringA(hContact, "Password"));
+ ptrA password(getUStringA(hContact, "Password"));
if (getWord(hContact, "Status", 0) != ID_STATUS_ONLINE) {
- wchar_t *p = wcschr(jid, '@');
+ char *p = strchr(jid, '@');
if (p != nullptr) {
*p++ = 0;
GroupchatJoinRoom(p, jid, nick, password);
@@ -209,7 +210,7 @@ INT_PTR __cdecl CJabberProto::OnJoinChat(WPARAM hContact, LPARAM)
INT_PTR __cdecl CJabberProto::OnLeaveChat(WPARAM hContact, LPARAM)
{
- ptrW jid(getWStringA(hContact, "ChatRoomID"));
+ ptrA jid(getUStringA(hContact, "ChatRoomID"));
if (jid != nullptr) {
if (getWord(hContact, "Status", 0) != ID_STATUS_OFFLINE) {
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, jid);
@@ -220,7 +221,7 @@ INT_PTR __cdecl CJabberProto::OnLeaveChat(WPARAM hContact, LPARAM)
return 0;
}
-void CJabberProto::GroupchatJoinRoom(const wchar_t *server, const wchar_t *room, const wchar_t *nick, const wchar_t *password, bool autojoin)
+void CJabberProto::GroupchatJoinRoom(const char *server, const char *room, const char *nick, const char *password, bool autojoin)
{
JabberGcRecentInfo info(this);
@@ -245,18 +246,18 @@ void CJabberProto::GroupchatJoinRoom(const wchar_t *server, const wchar_t *room,
info.saveRecent(0);
}
- wchar_t text[JABBER_MAX_JID_LEN + 1];
- mir_snwprintf(text, L"%s@%s/%s", room, server, nick);
+ char text[JABBER_MAX_JID_LEN + 1];
+ mir_snprintf(text, "%s@%s/%s", room, server, nick);
JABBER_LIST_ITEM *item = ListAdd(LIST_CHATROOM, text);
item->bAutoJoin = autojoin;
- replaceStrW(item->nick, nick);
- replaceStrW(item->password, info.m_password);
+ replaceStr(item->nick, nick);
+ replaceStr(item->password, info.m_password);
int status = (m_iStatus == ID_STATUS_INVISIBLE) ? ID_STATUS_ONLINE : m_iStatus;
- XmlNode x(L"x"); x << XATTR(L"xmlns", JABBER_FEAT_MUC);
+ XmlNode x("x"); x << XATTR("xmlns", JABBER_FEAT_MUC);
if (info.m_password && info.m_password[0])
- x << XCHILD(L"password", info.m_password);
+ x << XCHILD("password", info.m_password);
SendPresenceTo(status, text, x);
}
@@ -277,8 +278,8 @@ static int sttRoomListAppend(HWND hwndList, RoomInfo::Overlay overlay, const wch
{
RoomInfo *info = (RoomInfo *)mir_alloc(sizeof(RoomInfo));
info->overlay = overlay;
- info->line1 = line1 ? mir_wstrdup(line1) : nullptr;
- info->line2 = line2 ? mir_wstrdup(line2) : nullptr;
+ info->line1 = mir_wstrdup(line1);
+ info->line2 = mir_wstrdup(line2);
int id = SendMessage(hwndList, CB_ADDSTRING, 0, (LPARAM)name);
SendMessage(hwndList, CB_SETITEMDATA, id, (LPARAM)info);
@@ -286,7 +287,7 @@ static int sttRoomListAppend(HWND hwndList, RoomInfo::Overlay overlay, const wch
return id;
}
-void CJabberProto::OnIqResultDiscovery(HXML iqNode, CJabberIqInfo *pInfo)
+void CJabberProto::OnIqResultDiscovery(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
if (!iqNode || !pInfo)
return;
@@ -296,7 +297,7 @@ void CJabberProto::OnIqResultDiscovery(HXML iqNode, CJabberIqInfo *pInfo)
SendMessage(hwndList, CB_RESETCONTENT, 0, 0);
if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
- HXML query = XmlGetChild(iqNode, "query");
+ auto *query = iqNode->FirstChildElement("query");
if (query == nullptr) {
sttRoomListAppend(hwndList, RoomInfo::ROOM_FAIL,
TranslateT("Jabber Error"),
@@ -305,20 +306,18 @@ void CJabberProto::OnIqResultDiscovery(HXML iqNode, CJabberIqInfo *pInfo)
}
else {
bool found = false;
- HXML item;
- for (int i = 1; item = XmlGetNthChild(query, L"item", i); i++) {
- const wchar_t *jid = XmlGetAttrValue(item, L"jid");
- wchar_t *name = NEWWSTR_ALLOCA(jid);
+ for (auto *item : TiXmlFilter(query, "item")) {
+ const char *jid = item->Attribute("jid");
+ char *name = NEWSTR_ALLOCA(jid);
if (name) {
- if (wchar_t *p = wcschr(name, '@'))
+ if (char *p = strchr(name, '@'))
*p = 0;
}
- else name = L"";
+ else name = "";
sttRoomListAppend(hwndList,
ListGetItemPtr(LIST_BOOKMARK, jid) ? RoomInfo::ROOM_BOOKMARK : RoomInfo::ROOM_DEFAULT,
- XmlGetAttrValue(item, L"name"),
- jid, name);
+ Utf2T(item->Attribute("name")), Utf2T(jid), Utf2T(name));
found = true;
}
@@ -332,7 +331,7 @@ void CJabberProto::OnIqResultDiscovery(HXML iqNode, CJabberIqInfo *pInfo)
}
}
else if (pInfo->GetIqType() == JABBER_IQ_TYPE_ERROR) {
- HXML errorNode = XmlGetChild(iqNode, "error");
+ auto *errorNode = iqNode->FirstChildElement("error");
wchar_t *str = JabberErrorMsg(errorNode);
sttRoomListAppend(hwndList, RoomInfo::ROOM_FAIL,
TranslateT("Jabber Error"),
@@ -385,15 +384,15 @@ class CJabberDlgGcJoin : public CJabberDlgBase
{
typedef CJabberDlgBase CSuper;
- wchar_t *m_jid;
+ char *m_jid;
CCtrlButton btnOk;
public:
- CJabberDlgGcJoin(CJabberProto *proto, wchar_t *jid) :
+ CJabberDlgGcJoin(CJabberProto *proto, char *jid) :
CSuper(proto, IDD_GROUPCHAT_JOIN),
btnOk(this, IDOK),
- m_jid(mir_wstrdup(jid))
+ m_jid(mir_strdup(jid))
{
btnOk.OnClick = Callback(this, &CJabberDlgGcJoin::OnBtnOk);
}
@@ -420,7 +419,7 @@ protected:
if (hData) {
wchar_t *buf = (wchar_t *)GlobalLock(hData);
if (buf && wcschr(buf, '@') && !wcschr(buf, ' '))
- pInfo = new JabberGcRecentInfo(m_proto, buf);
+ pInfo = new JabberGcRecentInfo(m_proto, T2Utf(buf));
GlobalUnlock(hData);
}
CloseClipboard();
@@ -431,10 +430,10 @@ protected:
delete pInfo;
}
- ptrW tszNick(m_proto->getWStringA("Nick"));
+ ptrA tszNick(m_proto->getUStringA("Nick"));
if (tszNick == nullptr)
tszNick = JabberNickFromJID(m_proto->m_szJabberJID);
- SetDlgItemText(m_hwnd, IDC_NICK, tszNick);
+ SetDlgItemTextUtf(m_hwnd, IDC_NICK, tszNick);
TEXTMETRIC tm = { 0 };
HDC hdc = GetDC(m_hwnd);
@@ -458,13 +457,13 @@ protected:
int i;
for (i = 0; i < 5; i++) {
- wchar_t jid[JABBER_MAX_JID_LEN];
JabberGcRecentInfo info(m_proto);
if (!info.loadRecent(i))
break;
- mir_snwprintf(jid, L"%s@%s (%s)", info.m_room, info.m_server, info.m_nick ? info.m_nick : TranslateT("<no nick>"));
- SetDlgItemText(m_hwnd, IDC_RECENT1 + i, jid);
+ char jid[JABBER_MAX_JID_LEN];
+ mir_snprintf(jid, "%s@%s (%s)", info.m_room, info.m_server, info.m_nick ? info.m_nick : Translate("<no nick>"));
+ SetDlgItemTextUtf(m_hwnd, IDC_RECENT1 + i, jid);
}
sttJoinDlgShowRecentItems(m_hwnd, i);
return true;
@@ -485,18 +484,18 @@ protected:
{
wchar_t text[128];
GetDlgItemText(m_hwnd, IDC_SERVER, text, _countof(text));
- wchar_t *server = NEWWSTR_ALLOCA(text), *room;
+ T2Utf server(text);
- m_proto->ComboAddRecentString(m_hwnd, IDC_SERVER, "joinWnd_rcSvr", server);
+ m_proto->ComboAddRecentString(m_hwnd, IDC_SERVER, "joinWnd_rcSvr", text);
GetDlgItemText(m_hwnd, IDC_ROOM, text, _countof(text));
- room = NEWWSTR_ALLOCA(text);
+ T2Utf room(text);
GetDlgItemText(m_hwnd, IDC_NICK, text, _countof(text));
- wchar_t *nick = NEWWSTR_ALLOCA(text);
+ T2Utf nick(text);
GetDlgItemText(m_hwnd, IDC_PASSWORD, text, _countof(text));
- wchar_t *password = NEWWSTR_ALLOCA(text);
+ T2Utf password(text);
m_proto->GroupchatJoinRoom(server, room, nick, password);
}
@@ -619,7 +618,7 @@ protected:
if (*server) {
sttRoomListAppend(GetDlgItem(m_hwnd, IDC_ROOM), RoomInfo::ROOM_WAIT, TranslateT("Loading..."), TranslateT("Please wait for room list to download."), L"");
- CJabberIqInfo *pInfo = m_proto->AddIQ(&CJabberProto::OnIqResultDiscovery, JABBER_IQ_TYPE_GET, server, 0, -1, (void*)GetDlgItem(m_hwnd, IDC_ROOM));
+ CJabberIqInfo *pInfo = m_proto->AddIQ(&CJabberProto::OnIqResultDiscovery, JABBER_IQ_TYPE_GET, T2Utf(server), 0, -1, (void*)GetDlgItem(m_hwnd, IDC_ROOM));
pInfo->SetTimeout(30000);
XmlNodeIq iq(pInfo);
iq << XQUERY(JABBER_FEAT_DISCO_ITEMS);
@@ -645,7 +644,7 @@ protected:
{
JABBER_LIST_ITEM *item = nullptr;
if (item = m_proto->ListGetItemPtrFromIndex(i))
- if (!mir_wstrcmp(item->type, L"conference"))
+ if (!mir_strcmp(item->type, "conference"))
AppendMenu(hMenu, MF_STRING, (UINT_PTR)item, item->name);
}
AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr);
@@ -662,18 +661,18 @@ protected:
m_proto->OnMenuHandleBookmarks(0, 0);
else if (res) {
JABBER_LIST_ITEM *item = (JABBER_LIST_ITEM *)res;
- wchar_t *room = NEWWSTR_ALLOCA(item->jid);
+ char *room = NEWSTR_ALLOCA(item->jid);
if (room) {
- wchar_t *server = wcschr(room, '@');
+ char *server = strchr(room, '@');
if (server) {
*server++ = 0;
SendMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_SERVER, CBN_EDITCHANGE), (LPARAM)GetDlgItem(m_hwnd, IDC_SERVER));
- SetDlgItemText(m_hwnd, IDC_SERVER, server);
- SetDlgItemText(m_hwnd, IDC_ROOM, room);
- SetDlgItemText(m_hwnd, IDC_NICK, item->nick);
- SetDlgItemText(m_hwnd, IDC_PASSWORD, item->password);
+ SetDlgItemTextUtf(m_hwnd, IDC_SERVER, server);
+ SetDlgItemTextUtf(m_hwnd, IDC_ROOM, room);
+ SetDlgItemTextUtf(m_hwnd, IDC_NICK, item->nick);
+ SetDlgItemTextUtf(m_hwnd, IDC_PASSWORD, item->password);
}
}
}
@@ -705,7 +704,7 @@ protected:
}
};
-void CJabberProto::GroupchatJoinRoomByJid(HWND, wchar_t *jid)
+void CJabberProto::GroupchatJoinRoomByJid(HWND, char *jid)
{
if (m_pDlgJabberJoinGroupchat)
SetForegroundWindow(m_pDlgJabberJoinGroupchat->GetHwnd());
@@ -720,9 +719,9 @@ void CJabberProto::GroupchatJoinRoomByJid(HWND, wchar_t *jid)
struct JabberGroupchatChangeNicknameParam
{
- JabberGroupchatChangeNicknameParam(CJabberProto* ppro_, const wchar_t *jid_) :
+ JabberGroupchatChangeNicknameParam(CJabberProto* ppro_, const char *jid_) :
ppro(ppro_),
- jid(mir_wstrdup(jid_))
+ jid(mir_strdup(jid_))
{}
~JabberGroupchatChangeNicknameParam()
@@ -731,7 +730,7 @@ struct JabberGroupchatChangeNicknameParam
}
CJabberProto *ppro;
- wchar_t *jid;
+ char *jid;
};
static VOID CALLBACK JabberGroupchatChangeNickname(void* arg)
@@ -743,36 +742,37 @@ static VOID CALLBACK JabberGroupchatChangeNickname(void* arg)
JABBER_LIST_ITEM *item = param->ppro->ListGetItemPtr(LIST_CHATROOM, param->jid);
if (item != nullptr) {
CMStringW szBuffer, szTitle;
- szTitle.Format(TranslateT("Change nickname in <%s>"), item->name ? item->name : item->jid);
+ szTitle.Format(TranslateT("Change nickname in <%s>"), item->name ? item->name : Utf2T(item->jid));
if (item->nick)
szBuffer = item->nick;
if (param->ppro->EnterString(szBuffer, szTitle, ESF_COMBO, "gcNick_")) {
- replaceStrW(item->nick, szBuffer);
- param->ppro->SendPresenceTo(param->ppro->m_iStatus, CMStringW(FORMAT, L"%s/%s", item->jid, szBuffer.c_str()), nullptr);
+ T2Utf newNick(szBuffer);
+ replaceStr(item->nick, newNick);
+ param->ppro->SendPresenceTo(param->ppro->m_iStatus, CMStringA(FORMAT, "%s/%s", item->jid, newNick.get()), nullptr);
}
}
delete param;
}
-static int sttGetStatusCode(HXML node)
+static int sttGetStatusCode(const TiXmlElement *node)
{
- HXML statusNode = XmlGetChild(node, "status");
+ auto *statusNode = node->FirstChildElement("status");
if (statusNode == nullptr)
return -1;
- const wchar_t *statusCode = XmlGetAttrValue(statusNode, L"code");
+ const char *statusCode = statusNode->Attribute("code");
if (statusCode == nullptr)
return -1;
- return _wtol(statusCode);
+ return atol(statusCode);
}
-void CJabberProto::RenameParticipantNick(JABBER_LIST_ITEM *item, const wchar_t *oldNick, HXML itemNode)
+void CJabberProto::RenameParticipantNick(JABBER_LIST_ITEM *item, const char *oldNick, const TiXmlElement *itemNode)
{
- const wchar_t *jid = XmlGetAttrValue(itemNode, L"jid");
- const wchar_t *newNick = XmlGetAttrValue(itemNode, L"nick");
+ const char *jid = itemNode->Attribute("jid");
+ const char *newNick = itemNode->Attribute("nick");
if (newNick == nullptr)
return;
@@ -780,36 +780,36 @@ void CJabberProto::RenameParticipantNick(JABBER_LIST_ITEM *item, const wchar_t *
if (r == nullptr)
return;
- r->m_tszResourceName = mir_wstrdup(newNick);
+ r->m_szResourceName = mir_strdup(newNick);
- if (!mir_wstrcmp(item->nick, oldNick)) {
- replaceStrW(item->nick, newNick);
+ if (!mir_strcmp(item->nick, oldNick)) {
+ replaceStr(item->nick, newNick);
MCONTACT hContact = HContactFromJID(item->jid);
if (hContact != 0)
- setWString(hContact, "MyNick", newNick);
+ setUString(hContact, "MyNick", newNick);
}
- Chat_ChangeUserId(m_szModuleName, item->jid, oldNick, newNick);
+ Utf2T wszRoomId(item->jid), wszOld(oldNick), wszNew(newNick), wszInfo(jid);
+ Chat_ChangeUserId(m_szModuleName, wszRoomId, wszOld, wszNew);
- GCEVENT gce = { m_szModuleName, item->jid, GC_EVENT_NICK };
- if (jid != nullptr)
- gce.ptszUserInfo = jid;
+ GCEVENT gce = { m_szModuleName, wszRoomId, GC_EVENT_NICK };
+ gce.ptszUserInfo = wszInfo;
gce.time = time(0);
- gce.ptszNick = oldNick;
- gce.ptszUID = newNick;
- gce.ptszText = newNick;
+ gce.ptszNick = wszOld;
+ gce.ptszUID = wszNew;
+ gce.ptszText = wszNew;
Chat_Event(&gce);
}
-void CJabberProto::GroupchatProcessPresence(HXML node)
+void CJabberProto::GroupchatProcessPresence(const TiXmlElement *node)
{
- const wchar_t *from;
+ const char *from;
- if (!node || !XmlGetName(node) || mir_wstrcmp(XmlGetName(node), L"presence")) return;
- if ((from = XmlGetAttrValue(node, L"from")) == nullptr) return;
+ if (!node || !node->Name() || mir_strcmp(node->Name(), "presence")) return;
+ if ((from = node->Attribute("from")) == nullptr) return;
- const wchar_t *resource = wcschr(from, '/');
+ const char *resource = strchr(from, '/');
if (resource == nullptr || *++resource == '\0')
return;
@@ -819,22 +819,21 @@ void CJabberProto::GroupchatProcessPresence(HXML node)
pResourceStatus r(item->findResource(resource));
- HXML nNode = XmlGetChildByTag(node, "nick", "xmlns", JABBER_FEAT_NICK);
- const wchar_t *cnick = XmlGetText(nNode);
- const wchar_t *nick = cnick ? cnick : (r && r->m_tszNick ? r->m_tszNick : resource);
+ auto *nNode = XmlGetChildByTag(node, "nick", "xmlns", JABBER_FEAT_NICK);
+ const char *cnick = nNode->GetText();
+ const char *nick = cnick ? cnick : (r && r->m_szNick ? r->m_szNick : resource);
// process custom nick change
- if (cnick && r && r->m_tszNick && mir_wstrcmp(cnick, r->m_tszNick))
- r->m_tszNick = mir_wstrdup(cnick);
+ if (cnick && r && r->m_szNick && mir_strcmp(cnick, r->m_szNick))
+ r->m_szNick = mir_strdup(cnick);
- HXML xNode = XmlGetChildByTag(node, "x", "xmlns", JABBER_FEAT_MUC_USER);
- HXML itemNode = XmlGetChild(xNode, "item");
-
- const wchar_t *type = XmlGetAttrValue(node, L"type");
+ auto *xNode = XmlGetChildByTag(node, "x", "xmlns", JABBER_FEAT_MUC_USER);
+ auto *itemNode = xNode->FirstChildElement("item");
// entering room or a usual room presence
- if (type == nullptr || !mir_wstrcmp(type, L"available")) {
- if (ptrW(JabberNickFromJID(from)) == nullptr)
+ const char *type = node->Attribute("type");
+ if (type == nullptr || !mir_strcmp(type, "available")) {
+ if (ptrA(JabberNickFromJID(from)) == nullptr)
return;
GcInit(item);
@@ -842,25 +841,25 @@ void CJabberProto::GroupchatProcessPresence(HXML node)
// Update status of room participant
int status = ID_STATUS_ONLINE;
- const wchar_t *ptszShow = XmlGetText(XmlGetChild(node, "show"));
+ const char *ptszShow = node->FirstChildElement("show")->GetText();
if (ptszShow) {
- if (!mir_wstrcmp(ptszShow, L"away")) status = ID_STATUS_AWAY;
- else if (!mir_wstrcmp(ptszShow, L"xa")) status = ID_STATUS_NA;
- else if (!mir_wstrcmp(ptszShow, L"dnd")) status = ID_STATUS_DND;
- else if (!mir_wstrcmp(ptszShow, L"chat")) status = ID_STATUS_FREECHAT;
+ if (!mir_strcmp(ptszShow, "away")) status = ID_STATUS_AWAY;
+ else if (!mir_strcmp(ptszShow, "xa")) status = ID_STATUS_NA;
+ else if (!mir_strcmp(ptszShow, "dnd")) status = ID_STATUS_DND;
+ else if (!mir_strcmp(ptszShow, "chat")) status = ID_STATUS_FREECHAT;
}
- const wchar_t *str = XmlGetText(XmlGetChild(node, "status"));
+ const char *str = node->FirstChildElement("status")->GetText();
char priority = 0;
- if (const wchar_t *ptszPriority = XmlGetText(XmlGetChild(node, "priority")))
- priority = (char)_wtoi(ptszPriority);
+ if (auto *ptszPriority = node->FirstChildElement("priority")->GetText())
+ priority = atoi(ptszPriority);
bool bStatusChanged = false, bRoomCreated = false, bAffiliationChanged = false, bRoleChanged = false;
int newRes = ListAddResource(LIST_CHATROOM, from, status, str, priority, cnick) ? GC_EVENT_JOIN : 0;
if (pResourceStatus oldRes = ListFindResource(LIST_CHATROOM, from))
- if ((oldRes->m_iStatus != status) || lstrcmp_null(oldRes->m_tszStatusMessage, str))
+ if ((oldRes->m_iStatus != status) || mir_strcmp(oldRes->m_szStatusMessage, str))
bStatusChanged = true;
// Check additional MUC info for this user
@@ -871,18 +870,18 @@ void CJabberProto::GroupchatProcessPresence(HXML node)
JABBER_GC_AFFILIATION affiliation = r->m_affiliation;
JABBER_GC_ROLE role = r->m_role;
- if ((str = XmlGetAttrValue(itemNode, L"affiliation")) != nullptr) {
- if (!mir_wstrcmp(str, L"owner")) affiliation = AFFILIATION_OWNER;
- else if (!mir_wstrcmp(str, L"admin")) affiliation = AFFILIATION_ADMIN;
- else if (!mir_wstrcmp(str, L"member")) affiliation = AFFILIATION_MEMBER;
- else if (!mir_wstrcmp(str, L"none")) affiliation = AFFILIATION_NONE;
- else if (!mir_wstrcmp(str, L"outcast")) affiliation = AFFILIATION_OUTCAST;
+ if ((str = itemNode->Attribute("affiliation")) != nullptr) {
+ if (!mir_strcmp(str, "owner")) affiliation = AFFILIATION_OWNER;
+ else if (!mir_strcmp(str, "admin")) affiliation = AFFILIATION_ADMIN;
+ else if (!mir_strcmp(str, "member")) affiliation = AFFILIATION_MEMBER;
+ else if (!mir_strcmp(str, "none")) affiliation = AFFILIATION_NONE;
+ else if (!mir_strcmp(str, "outcast")) affiliation = AFFILIATION_OUTCAST;
}
- if ((str = XmlGetAttrValue(itemNode, L"role")) != nullptr) {
- if (!mir_wstrcmp(str, L"moderator")) role = ROLE_MODERATOR;
- else if (!mir_wstrcmp(str, L"participant")) role = ROLE_PARTICIPANT;
- else if (!mir_wstrcmp(str, L"visitor")) role = ROLE_VISITOR;
- else role = ROLE_NONE;
+ if ((str = itemNode->Attribute("role")) != nullptr) {
+ if (!mir_strcmp(str, "moderator")) role = ROLE_MODERATOR;
+ else if (!mir_strcmp(str, "participant")) role = ROLE_PARTICIPANT;
+ else if (!mir_strcmp(str, "visitor")) role = ROLE_VISITOR;
+ else role = ROLE_NONE;
}
if ((role != ROLE_NONE) && (JabberGcGetStatus(r) != JabberGcGetStatus(affiliation, role))) {
@@ -901,8 +900,8 @@ void CJabberProto::GroupchatProcessPresence(HXML node)
bRoleChanged = true;
}
- if (str = XmlGetAttrValue(itemNode, L"jid"))
- r->m_tszRealJid = mir_wstrdup(str);
+ if (str = itemNode->Attribute("jid"))
+ r->m_szRealJid = mir_strdup(str);
// XEP-0115: Entity Capabilities
OnProcessPresenceCapabilites(node, r);
@@ -929,8 +928,8 @@ void CJabberProto::GroupchatProcessPresence(HXML node)
// Check <created/>
if (bRoomCreated) {
- HXML n = XmlGetChild(node, "created");
- if (n != nullptr && (str = XmlGetAttrValue(n, L"xmlns")) != nullptr && !mir_wstrcmp(str, JABBER_FEAT_MUC_OWNER))
+ auto *n = node->FirstChildElement("created");
+ if (n != nullptr && (str = n->Attribute("xmlns")) != nullptr && !mir_strcmp(str, JABBER_FEAT_MUC_OWNER))
// A new room just created by me
// Request room config
m_ThreadInfo->send(
@@ -940,17 +939,17 @@ void CJabberProto::GroupchatProcessPresence(HXML node)
}
// leaving room
- else if (!mir_wstrcmp(type, L"unavailable")) {
- const wchar_t *str = nullptr;
+ else if (!mir_strcmp(type, "unavailable")) {
+ const char *str = nullptr;
if (xNode != nullptr && item->nick != nullptr) {
- HXML reasonNode = XmlGetChild(itemNode, "reason");
- str = XmlGetAttrValue(itemNode, L"jid");
+ auto *reasonNode = itemNode->FirstChildElement("reason");
+ str = itemNode->Attribute("jid");
int iStatus = sttGetStatusCode(xNode);
if (iStatus == 301 && r != nullptr)
GcLogShowInformation(item, r, INFO_BAN);
- if (!mir_wstrcmp(resource, item->nick)) {
+ if (!mir_strcmp(resource, item->nick)) {
switch (iStatus) {
case 301:
case 307:
@@ -978,7 +977,7 @@ void CJabberProto::GroupchatProcessPresence(HXML node)
}
}
- HXML statusNode = XmlGetChild(node, "status");
+ auto *statusNode = node->FirstChildElement("status");
GcLogUpdateMemberStatus(item, resource, nick, str, GC_EVENT_PART, statusNode);
ListRemoveResource(LIST_CHATROOM, from);
@@ -988,17 +987,17 @@ void CJabberProto::GroupchatProcessPresence(HXML node)
}
// processing room errors
- else if (!mir_wstrcmp(type, L"error")) {
+ else if (!mir_strcmp(type, "error")) {
int errorCode = 0;
- HXML errorNode = XmlGetChild(node, "error");
+ auto *errorNode = node->FirstChildElement("error");
ptrW str(JabberErrorMsg(errorNode, &errorCode));
if (errorCode == JABBER_ERROR_CONFLICT) {
- ptrW newNick(getWStringA("GcAltNick"));
+ ptrA newNick(getUStringA("GcAltNick"));
if (++item->iChatState == 1 && newNick != nullptr && newNick[0] != 0) {
- replaceStrW(item->nick, newNick);
- wchar_t text[1024] = { 0 };
- mir_snwprintf(text, L"%s/%s", item->jid, newNick);
+ replaceStr(item->nick, newNick);
+ char text[1024];
+ mir_snprintf(text, "%s/%s", item->jid, newNick);
SendPresenceTo(m_iStatus, text, nullptr);
}
else {
@@ -1015,65 +1014,66 @@ void CJabberProto::GroupchatProcessPresence(HXML node)
}
}
-void CJabberProto::GroupchatProcessMessage(HXML node)
+void CJabberProto::GroupchatProcessMessage(const TiXmlElement *node)
{
- HXML n, m;
- const wchar_t *from, *type, *p, *nick, *resource;
+ const TiXmlElement *n, *m;
+ const char *from, *type, *p, *nick, *resource;
JABBER_LIST_ITEM *item;
CMStringW imgLink;
- if (!XmlGetName(node) || mir_wstrcmp(XmlGetName(node), L"message")) return;
- if ((from = XmlGetAttrValue(node, L"from")) == nullptr) return;
+ if (!node->Name() || mir_strcmp(node->Name(), "message")) return;
+ if ((from = node->Attribute("from")) == nullptr) return;
if ((item = ListGetItemPtr(LIST_CHATROOM, from)) == nullptr) return;
- if ((type = XmlGetAttrValue(node, L"type")) == nullptr) return;
- if (!mir_wstrcmp(type, L"error"))
+ if ((type = node->Attribute("type")) == nullptr) return;
+ if (!mir_strcmp(type, "error"))
return;
- GCEVENT gce = { m_szModuleName, item->jid, 0 };
+ Utf2T roomJid(item->jid);
+ GCEVENT gce = { m_szModuleName, roomJid, 0 };
- const wchar_t *msgText = nullptr;
+ const char *msgText = nullptr;
- resource = wcschr(from, '/');
+ resource = strchr(from, '/');
if (resource != nullptr && *++resource == '\0')
resource = nullptr;
- if ((n = XmlGetChild(node, "subject")) != nullptr) {
- msgText = XmlGetText(n);
+ if ((n = node->FirstChildElement("subject")) != nullptr) {
+ msgText = n->GetText();
if (msgText == nullptr || msgText[0] == '\0')
return;
gce.iType = GC_EVENT_TOPIC;
- if (resource == nullptr && (m = XmlGetChild(node, "body")) != nullptr) {
- const wchar_t *tmpnick = XmlGetText(m);
+ if (resource == nullptr && (m = node->FirstChildElement("body")) != nullptr) {
+ const char *tmpnick = m->GetText();
if (tmpnick == nullptr || *tmpnick == 0)
return;
- const wchar_t *tmptr = wcsstr(tmpnick, L"has set the subject to:"); //ejabberd
+ const char *tmptr = strstr(tmpnick, "has set the subject to:"); //ejabberd
if (tmptr == nullptr)
- tmptr = wcsstr(tmpnick, TranslateT("has set the subject to:")); //ejabberd
+ tmptr = strstr(tmpnick, Translate("has set the subject to:")); //ejabberd
if (tmptr != nullptr && *tmptr != 0) {
*(wchar_t*)(--tmptr) = 0;
resource = tmpnick;
}
}
- item->getTemp()->m_tszStatusMessage = mir_wstrdup(msgText);
+ item->getTemp()->m_szStatusMessage = mir_strdup(msgText);
}
else {
imgLink = ExtractImage(node);
if ((n = XmlGetChildByTag(node, "body", "xml:lang", m_tszSelectedLang)) == nullptr)
- if ((n = XmlGetChild(node, "body")) == nullptr)
+ if ((n = node->FirstChildElement("body")) == nullptr)
return;
- msgText = XmlGetText(n);
+ msgText = n->GetText();
if (msgText == nullptr)
return;
if (resource == nullptr)
gce.iType = GC_EVENT_INFORMATION;
- else if (wcsncmp(msgText, L"/me ", 4) == 0 && mir_wstrlen(msgText) > 4) {
+ else if (strncmp(msgText, "/me ", 4) == 0 && mir_strlen(msgText) > 4) {
msgText += 4;
gce.iType = GC_EVENT_ACTION;
}
@@ -1084,8 +1084,8 @@ void CJabberProto::GroupchatProcessMessage(HXML node)
time_t msgTime = 0;
if (!JabberReadXep203delay(node, msgTime)) {
- HXML xDelay = XmlGetChildByTag(node, "x", "xmlns", L"jabber:x:delay");
- if (xDelay && (p = XmlGetAttrValue(xDelay, L"stamp")) != nullptr)
+ auto *xDelay = XmlGetChildByTag(node, "x", "xmlns", "jabber:x:delay");
+ if (xDelay && (p = xDelay->Attribute("stamp")) != nullptr)
msgTime = JabberIsoToUnixTime(p);
}
@@ -1096,19 +1096,20 @@ void CJabberProto::GroupchatProcessMessage(HXML node)
if (resource != nullptr) {
pResourceStatus r(item->findResource(resource));
- nick = (r && r->m_tszNick) ? r->m_tszNick : resource;
+ nick = (r && r->m_szNick) ? r->m_szNick : resource;
}
else nick = nullptr;
- CMStringW tszText(msgText);
+ CMStringW tszText(Utf2T(msgText).get());
tszText.Replace(L"%", L"%%");
tszText += imgLink;
- gce.ptszUID = resource;
- gce.ptszNick = nick;
+ Utf2T wszUserId(resource), wszNick(nick);
+ gce.ptszUID = wszUserId;
+ gce.ptszNick = wszNick;
gce.time = msgTime;
gce.ptszText = tszText;
- gce.bIsMe = nick == nullptr ? FALSE : (mir_wstrcmp(resource, item->nick) == 0);
+ gce.bIsMe = nick == nullptr ? FALSE : (mir_strcmp(resource, item->nick) == 0);
if (!isHistory)
gce.dwFlags |= GCEF_ADDTOLOG;
@@ -1121,7 +1122,7 @@ void CJabberProto::GroupchatProcessMessage(HXML node)
item->bChatActive = 2;
if (gce.iType == GC_EVENT_TOPIC)
- Chat_SetStatusbarText(m_szModuleName, item->jid, tszText);
+ Chat_SetStatusbarText(m_szModuleName, roomJid, tszText);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -1131,10 +1132,10 @@ class CGroupchatInviteAcceptDlg : public CJabberDlgBase
{
typedef CJabberDlgBase CSuper;
CCtrlButton m_accept;
- CMStringW m_roomJid, m_from, m_reason, m_password;
+ CMStringA m_roomJid, m_from, m_reason, m_password;
public:
- CGroupchatInviteAcceptDlg(CJabberProto *ppro, const wchar_t *roomJid, const wchar_t *from, const wchar_t *reason, const wchar_t *password) :
+ CGroupchatInviteAcceptDlg(CJabberProto *ppro, const char *roomJid, const char *from, const char *reason, const char *password) :
CSuper(ppro, IDD_GROUPCHAT_INVITE_ACCEPT),
m_roomJid(roomJid), m_from(from), m_reason(reason), m_password(password),
m_accept(this, IDC_ACCEPT)
@@ -1150,9 +1151,9 @@ public:
mir_snwprintf(buf, TranslateT("Group chat invitation to\n%s"), m_roomJid.c_str());
SetDlgItemText(m_hwnd, IDC_HEADERBAR, buf);
- SetDlgItemText(m_hwnd, IDC_FROM, m_from);
- SetDlgItemText(m_hwnd, IDC_REASON, m_reason);
- SetDlgItemText(m_hwnd, IDC_NICK, ptrW(JabberNickFromJID(m_proto->m_szJabberJID)));
+ SetDlgItemTextUtf(m_hwnd, IDC_FROM, m_from);
+ SetDlgItemTextUtf(m_hwnd, IDC_REASON, m_reason);
+ SetDlgItemTextUtf(m_hwnd, IDC_NICK, JabberNickFromJID(m_proto->m_szJabberJID));
Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_GROUP));
@@ -1164,7 +1165,7 @@ public:
{
wchar_t text[128];
GetDlgItemText(m_hwnd, IDC_NICK, text, _countof(text));
- m_proto->AcceptGroupchatInvite(m_roomJid, text, m_password);
+ m_proto->AcceptGroupchatInvite(m_roomJid, T2Utf(text), m_password);
EndDialog(m_hwnd, 0);
}
};
@@ -1175,7 +1176,7 @@ static void __stdcall sttShowDialog(void *pArg)
pDlg->Show();
}
-void CJabberProto::GroupchatProcessInvite(const wchar_t *roomJid, const wchar_t *from, const wchar_t *reason, const wchar_t *password)
+void CJabberProto::GroupchatProcessInvite(const char *roomJid, const char *from, const char *reason, const char *password)
{
if (roomJid == nullptr)
return;
@@ -1184,9 +1185,9 @@ void CJabberProto::GroupchatProcessInvite(const wchar_t *roomJid, const wchar_t
return;
if (m_bAutoAcceptMUC) {
- ptrW nick(getWStringA(HContactFromJID(m_szJabberJID), "MyNick"));
+ ptrA nick(getUStringA(HContactFromJID(m_szJabberJID), "MyNick"));
if (nick == nullptr)
- nick = getWStringA("Nick");
+ nick = getUStringA("Nick");
if (nick == nullptr)
nick = JabberNickFromJID(m_szJabberJID);
AcceptGroupchatInvite(roomJid, nick, password);
@@ -1194,11 +1195,11 @@ void CJabberProto::GroupchatProcessInvite(const wchar_t *roomJid, const wchar_t
else CallFunctionAsync(sttShowDialog, new CGroupchatInviteAcceptDlg(this, roomJid, from, reason, password));
}
-void CJabberProto::AcceptGroupchatInvite(const wchar_t *roomJid, const wchar_t *reason, const wchar_t *password)
+void CJabberProto::AcceptGroupchatInvite(const char *roomJid, const char *reason, const char *password)
{
- wchar_t room[256], *server, *p;
- wcsncpy_s(room, roomJid, _TRUNCATE);
- p = wcstok(room, L"@");
- server = wcstok(nullptr, L"@");
+ char room[256];
+ strncpy_s(room, roomJid, _TRUNCATE);
+ char *p = strtok(room, "@");
+ char *server = strtok(nullptr, "@");
GroupchatJoinRoom(server, p, reason, password);
}
diff --git a/protocols/JabberG/src/jabber_ibb.cpp b/protocols/JabberG/src/jabber_ibb.cpp
index 977dda973c..94a10847cd 100644
--- a/protocols/JabberG/src/jabber_ibb.cpp
+++ b/protocols/JabberG/src/jabber_ibb.cpp
@@ -32,7 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void JabberIbbFreeJibb(JABBER_IBB_TRANSFER *jibb)
{
- if (jibb) {
+ if (jibb) {
filetransfer* pft = jibb->ft;
if (pft)
pft->jibb = nullptr;
@@ -42,33 +42,34 @@ void JabberIbbFreeJibb(JABBER_IBB_TRANSFER *jibb)
mir_free(jibb->sid);
mir_free(jibb);
-} }
+ }
+}
-BOOL CJabberProto::OnFtHandleIbbIq(HXML iqNode, CJabberIqInfo *pInfo)
+BOOL CJabberProto::OnFtHandleIbbIq(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
- if (!mir_wstrcmp(pInfo->GetChildNodeName(), L"open"))
+ if (!mir_strcmp(pInfo->GetChildNodeName(), "open"))
FtHandleIbbRequest(iqNode, TRUE);
- else if (!mir_wstrcmp(pInfo->GetChildNodeName(), L"close"))
+ else if (!mir_strcmp(pInfo->GetChildNodeName(), "close"))
FtHandleIbbRequest(iqNode, FALSE);
- else if (!mir_wstrcmp(pInfo->GetChildNodeName(), L"data")) {
+ else if (!mir_strcmp(pInfo->GetChildNodeName(), "data")) {
BOOL bOk = FALSE;
- const wchar_t *sid = XmlGetAttrValue(pInfo->GetChildNode(), L"sid");
- const wchar_t *seq = XmlGetAttrValue(pInfo->GetChildNode(), L"seq");
- if (sid && seq && XmlGetText(pInfo->GetChildNode()))
- bOk = OnIbbRecvdData(XmlGetText(pInfo->GetChildNode()), sid, seq);
+ const char *sid = pInfo->GetChildNode()->Attribute("sid");
+ const char *seq = pInfo->GetChildNode()->Attribute("seq");
+ if (sid && seq && pInfo->GetChildNode()->GetText())
+ bOk = OnIbbRecvdData(pInfo->GetChildNode()->GetText(), sid, seq);
if (bOk)
- m_ThreadInfo->send( XmlNodeIq(L"result", pInfo));
+ m_ThreadInfo->send(XmlNodeIq("result", pInfo));
else
m_ThreadInfo->send(
- XmlNodeIq(L"error", pInfo)
- << XCHILD(L"error") << XATTRI(L"code", 404) << XATTR(L"type", L"cancel")
- << XCHILDNS(L"item-not-found", L"urn:ietf:params:xml:ns:xmpp-stanzas"));
+ XmlNodeIq("error", pInfo)
+ << XCHILD("error") << XATTRI("code", 404) << XATTR("type", "cancel")
+ << XCHILDNS("item-not-found", "urn:ietf:params:xml:ns:xmpp-stanzas"));
}
return TRUE;
}
-void CJabberProto::OnIbbInitiateResult(HXML, CJabberIqInfo *pInfo)
+void CJabberProto::OnIbbInitiateResult(const TiXmlElement*, CJabberIqInfo *pInfo)
{
JABBER_IBB_TRANSFER *jibb = (JABBER_IBB_TRANSFER *)pInfo->GetUserData();
if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT)
@@ -77,7 +78,7 @@ void CJabberProto::OnIbbInitiateResult(HXML, CJabberIqInfo *pInfo)
SetEvent(jibb->hEvent);
}
-void CJabberProto::OnIbbCloseResult(HXML, CJabberIqInfo *pInfo)
+void CJabberProto::OnIbbCloseResult(const TiXmlElement*, CJabberIqInfo *pInfo)
{
JABBER_IBB_TRANSFER *jibb = (JABBER_IBB_TRANSFER *)pInfo->GetUserData();
if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT)
@@ -98,8 +99,8 @@ void CJabberProto::IbbSendThread(JABBER_IBB_TRANSFER *jibb)
m_ThreadInfo->send(
XmlNodeIq(AddIQ(&CJabberProto::OnIbbInitiateResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb))
- << XCHILDNS(L"open", JABBER_FEAT_IBB) << XATTR(L"sid", jibb->sid) << XATTRI(L"block-size", JABBER_IBB_BLOCK_SIZE)
- << XATTR(L"stanza", L"message"));
+ << XCHILDNS("open", JABBER_FEAT_IBB) << XATTR("sid", jibb->sid) << XATTRI("block-size", JABBER_IBB_BLOCK_SIZE)
+ << XATTR("stanza", "message"));
WaitForSingleObject(jibb->hEvent, INFINITE);
CloseHandle(jibb->hEvent);
@@ -115,7 +116,7 @@ void CJabberProto::IbbSendThread(JABBER_IBB_TRANSFER *jibb)
m_ThreadInfo->send(
XmlNodeIq(AddIQ(&CJabberProto::OnIbbCloseResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb))
- << XCHILDNS(L"close", JABBER_FEAT_IBB) << XATTR(L"sid", jibb->sid));
+ << XCHILDNS("close", JABBER_FEAT_IBB) << XATTR("sid", jibb->sid));
WaitForSingleObject(jibb->hEvent, INFINITE);
CloseHandle(jibb->hEvent);
@@ -127,7 +128,7 @@ void CJabberProto::IbbSendThread(JABBER_IBB_TRANSFER *jibb)
else jibb->state = JIBB_ERROR;
}
- (this->*jibb->pfnFinal)((jibb->state==JIBB_DONE)?TRUE:FALSE, jibb->ft);
+ (this->*jibb->pfnFinal)((jibb->state == JIBB_DONE) ? TRUE : FALSE, jibb->ft);
jibb->ft = nullptr;
JabberIbbFreeJibb(jibb);
}
@@ -151,12 +152,12 @@ void __cdecl CJabberProto::IbbReceiveThread(JABBER_IBB_TRANSFER *jibb)
jibb->hEvent = nullptr;
if (jibb->state == JIBB_ERROR)
- m_ThreadInfo->send( XmlNodeIq(L"set", SerialNext(), jibb->dstJID) << XCHILDNS(L"close", JABBER_FEAT_IBB) << XATTR(L"sid", jibb->sid));
+ m_ThreadInfo->send(XmlNodeIq("set", SerialNext(), jibb->dstJID) << XCHILDNS("close", JABBER_FEAT_IBB) << XATTR("sid", jibb->sid));
if (jibb->bStreamClosed && jibb->dwTransferredSize == ft->dwExpectedRecvFileSize)
jibb->state = JIBB_DONE;
- (this->*jibb->pfnFinal)((jibb->state==JIBB_DONE)?TRUE:FALSE, jibb->ft);
+ (this->*jibb->pfnFinal)((jibb->state == JIBB_DONE) ? TRUE : FALSE, jibb->ft);
jibb->ft = nullptr;
ListRemove(LIST_FTRECV, jibb->sid);
@@ -164,12 +165,12 @@ void __cdecl CJabberProto::IbbReceiveThread(JABBER_IBB_TRANSFER *jibb)
JabberIbbFreeJibb(jibb);
}
-BOOL CJabberProto::OnIbbRecvdData(const wchar_t *data, const wchar_t *sid, const wchar_t *seq)
+BOOL CJabberProto::OnIbbRecvdData(const char *data, const char *sid, const char *seq)
{
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_FTRECV, sid);
if (item == nullptr) return FALSE;
- WORD wSeq = (WORD)_wtoi(seq);
+ WORD wSeq = (WORD)atoi(seq);
if (wSeq != item->jibb->wPacketId) {
if (item->jibb->hEvent)
SetEvent(item->jibb->hEvent);
@@ -179,7 +180,7 @@ BOOL CJabberProto::OnIbbRecvdData(const wchar_t *data, const wchar_t *sid, const
item->jibb->wPacketId++;
size_t length;
- ptrA decodedData((char*)mir_base64_decode( _T2A(data), &length));
+ ptrA decodedData((char*)mir_base64_decode(data, &length));
if (decodedData == nullptr)
return FALSE;
diff --git a/protocols/JabberG/src/jabber_ibb.h b/protocols/JabberG/src/jabber_ibb.h
index 4d6515d94f..89873663ae 100644
--- a/protocols/JabberG/src/jabber_ibb.h
+++ b/protocols/JabberG/src/jabber_ibb.h
@@ -28,10 +28,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
typedef enum { JIBB_INIT, JIBB_CONNECT, JIBB_SENDING, JIBB_RECVING, JIBB_DONE, JIBB_ERROR } JABBER_IBB_STATE;
-typedef struct {
- wchar_t *sid;
- wchar_t *srcJID;
- wchar_t *dstJID;
+struct JABBER_IBB_TRANSFER
+{
+ char *sid;
+ char *srcJID;
+ char *dstJID;
unsigned __int64 dwTransferredSize;
JABBER_IBB_STATE state;
HANDLE hEvent;
@@ -42,7 +43,6 @@ typedef struct {
int (CJabberProto::*pfnRecv)(HNETLIBCONN hConn, filetransfer *ft, char* buffer, int datalen);
void (CJabberProto::*pfnFinal)(BOOL success, filetransfer *ft);
filetransfer *ft;
-}
- JABBER_IBB_TRANSFER;
+};
#endif
diff --git a/protocols/JabberG/src/jabber_icolib.cpp b/protocols/JabberG/src/jabber_icolib.cpp
index 474411b3b5..ec8fdfedc8 100644
--- a/protocols/JabberG/src/jabber_icolib.cpp
+++ b/protocols/JabberG/src/jabber_icolib.cpp
@@ -41,38 +41,38 @@ HIMAGELIST hAdvancedStatusIcon = nullptr;
struct CTransportProtoTableItem
{
- wchar_t *mask;
+ char *mask;
char* proto;
};
static CTransportProtoTableItem TransportProtoTable[] =
{
- { L"|*icq*|jit*", "ICQ" },
- { L"msn*", "MSN" },
- { L"yahoo*", "YAHOO" },
- { L"mrim*", "MRA" },
- { L"aim*", "AIM" },
+ { "|*icq*|jit*", "ICQ" },
+ { "msn*", "MSN" },
+ { "yahoo*", "YAHOO" },
+ { "mrim*", "MRA" },
+ { "aim*", "AIM" },
//request #3094
- { L"|gg*|gadu*", "GaduGadu" },
- { L"tv*", "TV" },
- { L"dict*", "Dictionary" },
- { L"weather*", "Weather" },
- { L"skype*", "Skype" },
- { L"sms*", "SMS" },
- { L"smtp*", "SMTP" },
+ { "|gg*|gadu*", "GaduGadu" },
+ { "tv*", "TV" },
+ { "dict*", "Dictionary" },
+ { "weather*", "Weather" },
+ { "skype*", "Skype" },
+ { "sms*", "SMS" },
+ { "smtp*", "SMTP" },
//j2j
- { L"gtalk.*.*", "GTalk" },
- { L"|xmpp.*.*|j2j.*.*","Jabber2Jabber" },
+ { "gtalk.*.*", "GTalk" },
+ { "|xmpp.*.*|j2j.*.*","Jabber2Jabber" },
//jabbim.cz - services
- { L"disk*", "Jabber Disk" },
- { L"irc*", "IRC" },
- { L"rss*", "RSS" },
- { L"tlen*", "Tlen" },
+ { "disk*", "Jabber Disk" },
+ { "irc*", "IRC" },
+ { "rss*", "RSS" },
+ { "tlen*", "Tlen" },
// German social networks
- { L"studivz*", "StudiVZ" },
- { L"schuelervz*", "SchuelerVZ" },
- { L"meinvz*", "MeinVZ" },
+ { "studivz*", "StudiVZ" },
+ { "schuelervz*", "SchuelerVZ" },
+ { "meinvz*", "MeinVZ" },
};
static int skinIconStatusToResourceId[] = {IDI_OFFLINE,IDI_ONLINE,IDI_AWAY,IDI_DND,IDI_NA,IDI_NA,/*IDI_OCCUPIED,*/IDI_FREE4CHAT,IDI_INVISIBLE,IDI_ONTHEPHONE,IDI_OUTTOLUNCH};
@@ -199,9 +199,9 @@ static inline wchar_t qtoupper(wchar_t c)
return (c >= 'a' && c <= 'z') ? c - 'a' + 'A' : c;
}
-static BOOL WildComparei(const wchar_t *name, const wchar_t *mask)
+static BOOL WildComparei(const char *name, const char *mask)
{
- const wchar_t *last = nullptr;
+ const char *last = nullptr;
for (;; mask++, name++) {
if (*mask != '?' && qtoupper(*mask) != qtoupper(*name))
break;
@@ -226,7 +226,7 @@ static BOOL WildComparei(const wchar_t *name, const wchar_t *mask)
}
}
-static BOOL MatchMask(const wchar_t *name, const wchar_t *mask)
+static BOOL MatchMask(const char *name, const char *mask)
{
if (!mask || !name)
return mask == name;
@@ -234,7 +234,7 @@ static BOOL MatchMask(const wchar_t *name, const wchar_t *mask)
if (*mask != '|')
return WildComparei(name, mask);
- wchar_t *temp = NEWWSTR_ALLOCA(mask);
+ char *temp = NEWSTR_ALLOCA(mask);
for (int e = 1; mask[e] != '\0'; e++) {
int s = e;
while (mask[e] != '\0' && mask[e] != '|')
@@ -332,7 +332,7 @@ int CJabberProto::LoadAdvancedIcons(int iID)
return 0;
}
-int CJabberProto::GetTransportProtoID(wchar_t* TransportDomain)
+int CJabberProto::GetTransportProtoID(char *TransportDomain)
{
for (int i = 0; i < _countof(TransportProtoTable); i++)
if (MatchMask(TransportDomain, TransportProtoTable[i].mask))
@@ -389,7 +389,7 @@ INT_PTR __cdecl CJabberProto::JGetAdvancedStatusIcon(WPARAM hContact, LPARAM)
if (!getByte(hContact, "IsTransported", 0))
return -1;
- int iID = GetTransportProtoID(ptrW(getWStringA(hContact, "Transport")));
+ int iID = GetTransportProtoID(ptrA(getUStringA(hContact, "Transport")));
if (iID < 0)
return -1;
@@ -404,22 +404,22 @@ INT_PTR __cdecl CJabberProto::JGetAdvancedStatusIcon(WPARAM hContact, LPARAM)
/////////////////////////////////////////////////////////////////////////////////////////
// Transport check functions
-BOOL CJabberProto::DBCheckIsTransportedContact(const wchar_t *jid, MCONTACT hContact)
+BOOL CJabberProto::DBCheckIsTransportedContact(const char *jid, MCONTACT hContact)
{
// check if transport is already set
if (!jid || !hContact)
return FALSE;
// strip domain part from jid
- wchar_t *domain = wcschr((wchar_t*)jid, '@');
+ char *domain = (char*)strchr(jid, '@');
BOOL isAgent = (domain == nullptr) ? TRUE : FALSE;
BOOL isTransported = FALSE;
if (domain != nullptr)
- domain = NEWWSTR_ALLOCA(domain + 1);
+ domain = NEWSTR_ALLOCA(domain + 1);
else
- domain = NEWWSTR_ALLOCA(jid);
+ domain = NEWSTR_ALLOCA(jid);
- wchar_t *resourcepos = wcschr(domain, '/');
+ char *resourcepos = strchr(domain, '/');
if (resourcepos != nullptr)
*resourcepos = '\0';
@@ -431,12 +431,12 @@ BOOL CJabberProto::DBCheckIsTransportedContact(const wchar_t *jid, MCONTACT hCon
}
if (m_lstTransports.getIndex(domain) == -1 && isAgent) {
- m_lstTransports.insert(mir_wstrdup(domain));
+ m_lstTransports.insert(mir_strdup(domain));
setByte(hContact, "IsTransport", 1);
}
if (isTransported) {
- setWString(hContact, "Transport", domain);
+ setUString(hContact, "Transport", domain);
setByte(hContact, "IsTransported", 1);
}
return isTransported;
@@ -445,7 +445,7 @@ BOOL CJabberProto::DBCheckIsTransportedContact(const wchar_t *jid, MCONTACT hCon
void CJabberProto::CheckAllContactsAreTransported()
{
for (auto &hContact : AccContacts()) {
- ptrW jid(getWStringA(hContact, "jid"));
+ ptrA jid(getUStringA(hContact, "jid"));
if (jid)
DBCheckIsTransportedContact(jid, hContact);
}
@@ -474,11 +474,11 @@ static IconItem sharedIconList1[] =
{ LPGEN("AdHoc Command"), "adhoc", IDI_COMMAND },
{ LPGEN("XML Console"), "xmlconsole", IDI_CONSOLE },
{ LPGEN("OpenID Request"), "openid", IDI_HTTP_AUTH },
- { LPGEN("Add contact"), "addcontact", IDI_ADDCONTACT },
- { LPGEN("Delete"), "delete", IDI_DELETE },
- { LPGEN("Edit"), "edit", IDI_EDIT },
- { LPGEN("Open"), "open", IDI_OPEN },
- { LPGEN("Save"), "save", IDI_SAVE }
+ { LPGEN("Add contact"), "addcontact", IDI_ADDCONTACT },
+ { LPGEN("Delete"), "delete", IDI_DELETE },
+ { LPGEN("Edit"), "edit", IDI_EDIT },
+ { LPGEN("Open"), "open", IDI_OPEN },
+ { LPGEN("Save"), "save", IDI_SAVE }
};
static IconItem sharedIconList2[] =
diff --git a/protocols/JabberG/src/jabber_iq.cpp b/protocols/JabberG/src/jabber_iq.cpp
index 916e2963cb..162d60e7a6 100644
--- a/protocols/JabberG/src/jabber_iq.cpp
+++ b/protocols/JabberG/src/jabber_iq.cpp
@@ -85,52 +85,52 @@ void CJabberIqManager::Shutdown()
void CJabberIqManager::FillPermanentHandlers()
{
// version requests (XEP-0092)
- AddPermanentHandler(&CJabberProto::OnIqRequestVersion, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_VERSION, FALSE, L"query");
+ AddPermanentHandler(&CJabberProto::OnIqRequestVersion, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_VERSION, FALSE, "query");
// last activity (XEP-0012)
- AddPermanentHandler(&CJabberProto::OnIqRequestLastActivity, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_LAST_ACTIVITY, FALSE, L"query");
+ AddPermanentHandler(&CJabberProto::OnIqRequestLastActivity, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_LAST_ACTIVITY, FALSE, "query");
// ping requests (XEP-0199)
- AddPermanentHandler(&CJabberProto::OnIqRequestPing, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_PING, FALSE, L"ping");
+ AddPermanentHandler(&CJabberProto::OnIqRequestPing, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_PING, FALSE, "ping");
// entity time (XEP-0202)
- AddPermanentHandler(&CJabberProto::OnIqRequestTime, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_ENTITY_TIME, FALSE, L"time");
+ AddPermanentHandler(&CJabberProto::OnIqRequestTime, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_ENTITY_TIME, FALSE, "time");
// entity time (XEP-0090)
- AddPermanentHandler(&CJabberProto::OnIqProcessIqOldTime, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_ENTITY_TIME_OLD, FALSE, L"query");
+ AddPermanentHandler(&CJabberProto::OnIqProcessIqOldTime, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_ENTITY_TIME_OLD, FALSE, "query");
// old avatars support (deprecated XEP-0008)
- AddPermanentHandler(&CJabberProto::OnIqRequestAvatar, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_AVATAR, FALSE, L"query");
+ AddPermanentHandler(&CJabberProto::OnIqRequestAvatar, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_AVATAR, FALSE, "query");
// privacy lists (XEP-0016)
- AddPermanentHandler(&CJabberProto::OnIqRequestPrivacyLists, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_PRIVACY_LISTS, FALSE, L"query");
+ AddPermanentHandler(&CJabberProto::OnIqRequestPrivacyLists, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_PRIVACY_LISTS, FALSE, "query");
// in band bytestreams (XEP-0047)
AddPermanentHandler(&CJabberProto::OnFtHandleIbbIq, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE | JABBER_IQ_PARSE_CHILD_TAG_NAME | JABBER_IQ_PARSE_CHILD_TAG_XMLNS, JABBER_FEAT_IBB, FALSE, nullptr);
// socks5-bytestreams (XEP-0065)
- AddPermanentHandler(&CJabberProto::FtHandleBytestreamRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_BYTESTREAMS, FALSE, L"query");
+ AddPermanentHandler(&CJabberProto::FtHandleBytestreamRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_BYTESTREAMS, FALSE, "query");
// session initiation (XEP-0095)
- AddPermanentHandler(&CJabberProto::OnSiRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_SI, FALSE, L"si");
+ AddPermanentHandler(&CJabberProto::OnSiRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_SI, FALSE, "si");
// roster push requests
- AddPermanentHandler(&CJabberProto::OnRosterPushRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_IQ_ROSTER, FALSE, L"query");
+ AddPermanentHandler(&CJabberProto::OnRosterPushRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_IQ_ROSTER, FALSE, "query");
// OOB file transfers
- AddPermanentHandler(&CJabberProto::OnIqRequestOOB, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_OOB, FALSE, L"query");
+ AddPermanentHandler(&CJabberProto::OnIqRequestOOB, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_OOB, FALSE, "query");
// disco#items requests (XEP-0030, XEP-0050)
- AddPermanentHandler(&CJabberProto::OnHandleDiscoItemsRequest, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_DISCO_ITEMS, FALSE, L"query");
+ AddPermanentHandler(&CJabberProto::OnHandleDiscoItemsRequest, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_DISCO_ITEMS, FALSE, "query");
// disco#info requests (XEP-0030, XEP-0050, XEP-0115)
- AddPermanentHandler(&CJabberProto::OnHandleDiscoInfoRequest, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_DISCO_INFO, FALSE, L"query");
+ AddPermanentHandler(&CJabberProto::OnHandleDiscoInfoRequest, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_DISCO_INFO, FALSE, "query");
// ad-hoc commands (XEP-0050) for remote controlling (XEP-0146)
- AddPermanentHandler(&CJabberProto::HandleAdhocCommandRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_COMMANDS, FALSE, L"command");
+ AddPermanentHandler(&CJabberProto::HandleAdhocCommandRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_COMMANDS, FALSE, "command");
// http auth (XEP-0070)
- AddPermanentHandler(&CJabberProto::OnIqHttpAuth, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_HTTP_AUTH, FALSE, L"confirm");
+ AddPermanentHandler(&CJabberProto::OnIqHttpAuth, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_HTTP_AUTH, FALSE, "confirm");
}
void __cdecl CJabberProto::ExpirerThread(void* pParam)
@@ -171,7 +171,7 @@ void CJabberIqManager::ExpireInfo(CJabberIqInfo *pInfo)
if ((pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_HCONTACT) && (pInfo->m_szFrom))
pInfo->m_hContact = ppro->HContactFromJID(pInfo->m_szFrom);
- ppro->debugLogW(L"Expiring iq id %d, sent to %s", pInfo->m_nIqId, pInfo->m_szReceiver ? pInfo->m_szReceiver : L"server");
+ ppro->debugLogW(L"Expiring iq id %d, sent to %s", pInfo->m_nIqId, pInfo->m_szReceiver ? pInfo->m_szReceiver : "server");
pInfo->m_nIqType = JABBER_IQ_TYPE_FAIL;
(ppro->*(pInfo->m_pHandler))(nullptr, pInfo);
@@ -201,7 +201,7 @@ void CJabberIqManager::ExpireAll()
ExpireInfo(pInfo);
}
-CJabberIqInfo* CJabberIqManager::AddHandler(JABBER_IQ_HANDLER pHandler, int nIqType, const wchar_t *szReceiver, DWORD dwParamsToParse, int nIqId, void *pUserData, int iPriority)
+CJabberIqInfo* CJabberIqManager::AddHandler(JABBER_IQ_HANDLER pHandler, int nIqType, const char *szReceiver, DWORD dwParamsToParse, int nIqId, void *pUserData, int iPriority)
{
CJabberIqInfo *pInfo = new CJabberIqInfo();
pInfo->m_pHandler = pHandler;
@@ -238,19 +238,19 @@ bool CJabberIqManager::DeleteHandler(CJabberIqInfo *pInfo)
return false;
}
-bool CJabberIqManager::HandleIq(int nIqId, HXML pNode)
+bool CJabberIqManager::HandleIq(int nIqId, const TiXmlElement *pNode)
{
if (nIqId == -1 || pNode == nullptr)
return false;
- const wchar_t *szType = XmlGetAttrValue(pNode, L"type");
+ const char *szType = pNode->Attribute("type");
if (!szType)
return false;
int nIqType = JABBER_IQ_TYPE_FAIL;
- if (!mir_wstrcmpi(szType, L"result"))
+ if (!mir_strcmpi(szType, "result"))
nIqType = JABBER_IQ_TYPE_RESULT;
- else if (!mir_wstrcmpi(szType, L"error"))
+ else if (!mir_strcmpi(szType, "error"))
nIqType = JABBER_IQ_TYPE_ERROR;
else
return false;
@@ -263,24 +263,24 @@ bool CJabberIqManager::HandleIq(int nIqId, HXML pNode)
pInfo->m_nIqType = nIqType;
if (nIqType == JABBER_IQ_TYPE_RESULT) {
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_CHILD_TAG_NODE)
- pInfo->m_pChildNode = XmlGetChild(pNode, 0);
+ pInfo->m_pChildNode = pNode->FirstChildElement();
if (pInfo->m_pChildNode && (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_CHILD_TAG_NAME))
- pInfo->m_szChildTagName = (wchar_t*)XmlGetName(pInfo->m_pChildNode);
+ pInfo->m_szChildTagName = pInfo->m_pChildNode->Name();
if (pInfo->m_pChildNode && (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_CHILD_TAG_XMLNS))
- pInfo->m_szChildTagXmlns = (wchar_t*)XmlGetAttrValue(pNode, L"xmlns");
+ pInfo->m_szChildTagXmlns = pNode->Attribute("xmlns");
}
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_TO)
- pInfo->m_szTo = (wchar_t*)XmlGetAttrValue(pNode, L"to");
+ pInfo->m_szTo = pNode->Attribute("to");
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_FROM)
- pInfo->m_szFrom = (wchar_t*)XmlGetAttrValue(pNode, L"from");
+ pInfo->m_szFrom = pNode->Attribute("from");
if (pInfo->m_szFrom && (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_HCONTACT))
pInfo->m_hContact = ppro->HContactFromJID(pInfo->m_szFrom);
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_ID_STR)
- pInfo->m_szId = (wchar_t*)XmlGetAttrValue(pNode, L"id");
+ pInfo->m_szId = pNode->Attribute("id");
(ppro->*(pInfo->m_pHandler))(pNode, pInfo);
delete pInfo;
@@ -289,19 +289,19 @@ bool CJabberIqManager::HandleIq(int nIqId, HXML pNode)
return true;
}
-bool CJabberIqManager::HandleIqPermanent(HXML pNode)
+bool CJabberIqManager::HandleIqPermanent(const TiXmlElement *pNode)
{
for (auto &pInfo : m_arHandlers) {
// have to get all data here, in the loop, because there's always possibility that previous handler modified it
- const wchar_t *szType = XmlGetAttrValue(pNode, L"type");
+ const char *szType = pNode->Attribute("type");
if (!szType)
return FALSE;
CJabberIqInfo iqInfo;
iqInfo.m_nIqType = JABBER_IQ_TYPE_FAIL;
- if (!mir_wstrcmpi(szType, L"get"))
+ if (!mir_strcmpi(szType, "get"))
iqInfo.m_nIqType = JABBER_IQ_TYPE_GET;
- else if (!mir_wstrcmpi(szType, L"set"))
+ else if (!mir_strcmpi(szType, "set"))
iqInfo.m_nIqType = JABBER_IQ_TYPE_SET;
else
return FALSE;
@@ -309,27 +309,27 @@ bool CJabberIqManager::HandleIqPermanent(HXML pNode)
if (!(pInfo->m_nIqTypes & iqInfo.m_nIqType))
continue;
- HXML pFirstChild = XmlGetChild(pNode, 0);
- if (!pFirstChild || !XmlGetName(pFirstChild))
+ auto *pFirstChild = pNode->FirstChildElement();
+ if (!pFirstChild || !pFirstChild->Name())
return FALSE;
- const wchar_t *szTagName = XmlGetName(pFirstChild);
- const wchar_t *szXmlns = XmlGetAttrValue(pFirstChild, L"xmlns");
+ const char *szTagName = pFirstChild->Name();
+ const char *szXmlns = pFirstChild->Attribute("xmlns");
- if ((!pInfo->m_szXmlns || (szXmlns && !mir_wstrcmp(pInfo->m_szXmlns, szXmlns))) &&
- (!pInfo->m_szTag || !mir_wstrcmp(pInfo->m_szTag, szTagName))) {
+ if ((!pInfo->m_szXmlns || (szXmlns && !mir_strcmp(pInfo->m_szXmlns, szXmlns))) &&
+ (!pInfo->m_szTag || !mir_strcmp(pInfo->m_szTag, szTagName))) {
// node suits handler criteria, call the handler
iqInfo.m_pChildNode = pFirstChild;
- iqInfo.m_szChildTagName = (wchar_t*)szTagName;
- iqInfo.m_szChildTagXmlns = (wchar_t*)szXmlns;
- iqInfo.m_szId = (wchar_t*)XmlGetAttrValue(pNode, L"id");
+ iqInfo.m_szChildTagName = szTagName;
+ iqInfo.m_szChildTagXmlns = szXmlns;
+ iqInfo.m_szId = pNode->Attribute("id");
iqInfo.m_pUserData = pInfo->m_pUserData;
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_TO)
- iqInfo.m_szTo = (wchar_t*)XmlGetAttrValue(pNode, L"to");
+ iqInfo.m_szTo = pNode->Attribute("to");
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_FROM)
- iqInfo.m_szFrom = (wchar_t*)XmlGetAttrValue(pNode, L"from");
+ iqInfo.m_szFrom = pNode->Attribute("from");
if ((pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_HCONTACT) && (iqInfo.m_szFrom))
iqInfo.m_hContact = ppro->HContactFromJID(iqInfo.m_szFrom);
@@ -394,9 +394,9 @@ CJabberIqPermanentInfo* CJabberIqManager::AddPermanentHandler(
JABBER_PERMANENT_IQ_HANDLER pHandler,
int nIqTypes,
DWORD dwParamsToParse,
- const wchar_t *szXmlns,
+ const char *szXmlns,
BOOL bAllowPartialNs,
- const wchar_t *szTag,
+ const char *szTag,
void *pUserData,
IQ_USER_DATA_FREE_FUNC pUserDataFree,
int iPriority)
@@ -404,9 +404,9 @@ CJabberIqPermanentInfo* CJabberIqManager::AddPermanentHandler(
CJabberIqPermanentInfo *pInfo = new CJabberIqPermanentInfo();
pInfo->m_pHandler = pHandler;
pInfo->m_nIqTypes = nIqTypes ? nIqTypes : JABBER_IQ_TYPE_ANY;
- pInfo->m_szXmlns = mir_wstrdup(szXmlns);
+ pInfo->m_szXmlns = mir_strdup(szXmlns);
pInfo->m_bAllowPartialNs = bAllowPartialNs;
- pInfo->m_szTag = mir_wstrdup(szTag);
+ pInfo->m_szTag = mir_strdup(szTag);
pInfo->m_dwParamsToParse = dwParamsToParse;
pInfo->m_pUserData = pUserData;
pInfo->m_pUserDataFree = pUserDataFree;
diff --git a/protocols/JabberG/src/jabber_iq.h b/protocols/JabberG/src/jabber_iq.h
index 0defc02d8d..f7210f45eb 100644
--- a/protocols/JabberG/src/jabber_iq.h
+++ b/protocols/JabberG/src/jabber_iq.h
@@ -36,8 +36,8 @@ typedef void (*IQ_USER_DATA_FREE_FUNC)(void *pUserData);
// 2 minutes, milliseconds
#define JABBER_DEFAULT_IQ_REQUEST_TIMEOUT 120000
-typedef void (CJabberProto::*JABBER_IQ_HANDLER)(HXML iqNode, CJabberIqInfo *pInfo);
-typedef BOOL (CJabberProto::*JABBER_PERMANENT_IQ_HANDLER)(HXML iqNode, CJabberIqInfo *pInfo);
+typedef void (CJabberProto::*JABBER_IQ_HANDLER)(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+typedef BOOL (CJabberProto::*JABBER_PERMANENT_IQ_HANDLER)(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
#define JABBER_IQ_PARSE_CHILD_TAG_NODE (1)
#define JABBER_IQ_PARSE_CHILD_TAG_NAME ((1<<1)|JABBER_IQ_PARSE_CHILD_TAG_NODE)
@@ -55,23 +55,23 @@ protected:
friend class CJabberIqManager;
JABBER_IQ_HANDLER m_pHandler;
- int m_nIqId;
- DWORD m_dwParamsToParse;
- DWORD m_dwRequestTime;
- DWORD m_dwTimeout;
- wchar_t *m_szReceiver;
- int m_iPriority;
+ int m_nIqId;
+ DWORD m_dwParamsToParse;
+ DWORD m_dwRequestTime;
+ DWORD m_dwTimeout;
+ char* m_szReceiver;
+ int m_iPriority;
public:
- void *m_pUserData;
- int m_nIqType;
- wchar_t *m_szFrom;
- wchar_t *m_szChildTagXmlns;
- wchar_t *m_szChildTagName;
- HXML m_pChildNode;
- MCONTACT m_hContact;
- wchar_t *m_szTo;
- wchar_t *m_szId;
+ void* m_pUserData;
+ int m_nIqType;
+ const char* m_szFrom;
+ const char* m_szChildTagXmlns;
+ const char* m_szChildTagName;
+ const TiXmlElement *m_pChildNode;
+ MCONTACT m_hContact;
+ const char* m_szTo;
+ const char* m_szId;
public:
__forceinline CJabberIqInfo()
@@ -81,22 +81,23 @@ public:
{ mir_free(m_szReceiver);
}
- __forceinline void SetReceiver(const wchar_t *szReceiver) { replaceStrW(m_szReceiver, szReceiver); }
+ __forceinline void SetReceiver(const char *szReceiver) { replaceStr(m_szReceiver, szReceiver); }
__forceinline void SetParamsToParse(DWORD dwParamsToParse) { m_dwParamsToParse = dwParamsToParse; }
__forceinline void SetTimeout(DWORD dwTimeout) { m_dwTimeout = dwTimeout; }
- __forceinline int GetIqId() const { return m_nIqId; }
- __forceinline DWORD GetRequestTime() const { return m_dwRequestTime; }
- __forceinline int GetIqType() const { return m_nIqType; }
- __forceinline void* GetUserData() const { return m_pUserData; }
- __forceinline wchar_t* GetFrom() const { return m_szFrom; }
- __forceinline wchar_t* GetTo() const { return m_szTo; }
- __forceinline wchar_t* GetIdStr() const { return m_szId; }
- __forceinline MCONTACT GetHContact() const { return m_hContact; }
- __forceinline HXML GetChildNode() const { return m_pChildNode; }
- __forceinline wchar_t* GetChildNodeName() const { return m_szChildTagName; }
- __forceinline wchar_t* GetReceiver() const { return m_szReceiver; }
- __forceinline int GetPriority() const { return m_iPriority; }
+ __forceinline int GetIqId() const { return m_nIqId; }
+ __forceinline DWORD GetRequestTime() const { return m_dwRequestTime; }
+ __forceinline int GetIqType() const { return m_nIqType; }
+ __forceinline void* GetUserData() const { return m_pUserData; }
+ __forceinline const char* GetFrom() const { return m_szFrom; }
+ __forceinline const char* GetTo() const { return m_szTo; }
+ __forceinline const char* GetIdStr() const { return m_szId; }
+ __forceinline MCONTACT GetHContact() const { return m_hContact; }
+ __forceinline const char* GetChildNodeName() const { return m_szChildTagName; }
+ __forceinline const char* GetReceiver() const { return m_szReceiver; }
+ __forceinline int GetPriority() const { return m_iPriority; }
+
+ __forceinline const TiXmlElement *GetChildNode() const { return m_pChildNode; }
char* GetCharIqType()
{
@@ -117,8 +118,8 @@ class CJabberIqPermanentInfo : public MZeroedObject
JABBER_PERMANENT_IQ_HANDLER m_pHandler;
DWORD m_dwParamsToParse;
int m_nIqTypes;
- wchar_t *m_szXmlns;
- wchar_t *m_szTag;
+ char *m_szXmlns;
+ char *m_szTag;
BOOL m_bAllowPartialNs;
void *m_pUserData;
IQ_USER_DATA_FREE_FUNC m_pUserDataFree;
@@ -165,15 +166,15 @@ public:
void Shutdown();
// fucking params, maybe just return CJabberIqRequestInfo pointer ?
- CJabberIqInfo* AddHandler(JABBER_IQ_HANDLER pHandler, int nIqType, const wchar_t *szReceiver, DWORD dwParamsToParse, int nIqId, void *pUserData, int iPriority);
- CJabberIqPermanentInfo* AddPermanentHandler(JABBER_PERMANENT_IQ_HANDLER pHandler, int nIqTypes, DWORD dwParamsToParse, const wchar_t *szXmlns, BOOL bAllowPartialNs, const wchar_t *szTag, void *pUserData = nullptr, IQ_USER_DATA_FREE_FUNC pUserDataFree = nullptr, int iPriority = JH_PRIORITY_DEFAULT);
+ CJabberIqInfo* AddHandler(JABBER_IQ_HANDLER pHandler, int nIqType, const char *szReceiver, DWORD dwParamsToParse, int nIqId, void *pUserData, int iPriority);
+ CJabberIqPermanentInfo* AddPermanentHandler(JABBER_PERMANENT_IQ_HANDLER pHandler, int nIqTypes, DWORD dwParamsToParse, const char *szXmlns, BOOL bAllowPartialNs, const char *szTag, void *pUserData = nullptr, IQ_USER_DATA_FREE_FUNC pUserDataFree = nullptr, int iPriority = JH_PRIORITY_DEFAULT);
// returns TRUE when pInfo found, or FALSE otherwise
bool DeletePermanentHandler(CJabberIqPermanentInfo *pInfo);
bool DeleteHandler(CJabberIqInfo *pInfo);
- bool HandleIq(int nIqId, HXML pNode);
- bool HandleIqPermanent(HXML pNode);
+ bool HandleIq(int nIqId, const TiXmlElement *pNode);
+ bool HandleIqPermanent(const TiXmlElement *pNode);
void ExpireIq(int nIqId);
void ExpirerThread(void);
diff --git a/protocols/JabberG/src/jabber_iq_handlers.cpp b/protocols/JabberG/src/jabber_iq_handlers.cpp
index 23054d84fe..cab8e52428 100644
--- a/protocols/JabberG/src/jabber_iq_handlers.cpp
+++ b/protocols/JabberG/src/jabber_iq_handlers.cpp
@@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "jabber_rc.h"
#include "version.h"
-BOOL CJabberProto::OnIqRequestVersion(HXML, CJabberIqInfo *pInfo)
+BOOL CJabberProto::OnIqRequestVersion(const TiXmlElement*, CJabberIqInfo *pInfo)
{
if (!pInfo->GetFrom())
return TRUE;
@@ -36,16 +36,16 @@ BOOL CJabberProto::OnIqRequestVersion(HXML, CJabberIqInfo *pInfo)
if (!m_bAllowVersionRequests)
return FALSE;
- XmlNodeIq iq(L"result", pInfo);
- HXML query = iq << XQUERY(JABBER_FEAT_VERSION);
- query << XCHILD(L"name", L"Miranda NG Jabber");
- query << XCHILD(L"version", szCoreVersion);
+ XmlNodeIq iq("result", pInfo);
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_VERSION);
+ query << XCHILD("name", "Miranda NG Jabber");
+ query << XCHILD("version", szCoreVersion);
if (m_bShowOSVersion) {
wchar_t os[256] = { 0 };
if (!GetOSDisplayString(os, _countof(os)))
mir_wstrncpy(os, L"Microsoft Windows", _countof(os));
- query << XCHILD(L"os", os);
+ query << XCHILD("os", T2Utf(os));
}
m_ThreadInfo->send(iq);
@@ -53,18 +53,18 @@ BOOL CJabberProto::OnIqRequestVersion(HXML, CJabberIqInfo *pInfo)
}
// last activity (XEP-0012) support
-BOOL CJabberProto::OnIqRequestLastActivity(HXML, CJabberIqInfo *pInfo)
+BOOL CJabberProto::OnIqRequestLastActivity(const TiXmlElement*, CJabberIqInfo *pInfo)
{
m_ThreadInfo->send(
- XmlNodeIq(L"result", pInfo) << XQUERY(JABBER_FEAT_LAST_ACTIVITY)
- << XATTRI(L"seconds", m_tmJabberIdleStartTime ? time(0) - m_tmJabberIdleStartTime : 0));
+ XmlNodeIq("result", pInfo) << XQUERY(JABBER_FEAT_LAST_ACTIVITY)
+ << XATTRI("seconds", m_tmJabberIdleStartTime ? time(0) - m_tmJabberIdleStartTime : 0));
return TRUE;
}
// XEP-0199: XMPP Ping support
-BOOL CJabberProto::OnIqRequestPing(HXML, CJabberIqInfo *pInfo)
+BOOL CJabberProto::OnIqRequestPing(const TiXmlElement*, CJabberIqInfo *pInfo)
{
- m_ThreadInfo->send(XmlNodeIq(L"result", pInfo) << XATTR(L"from", m_ThreadInfo->fullJID));
+ m_ThreadInfo->send(XmlNodeIq("result", pInfo) << XATTR("from", m_ThreadInfo->fullJID));
return TRUE;
}
@@ -96,7 +96,7 @@ int GetGMTOffset(void)
}
// entity time (XEP-0202) support
-BOOL CJabberProto::OnIqRequestTime(HXML, CJabberIqInfo *pInfo)
+BOOL CJabberProto::OnIqRequestTime(const TiXmlElement*, CJabberIqInfo *pInfo)
{
wchar_t stime[100];
wchar_t szTZ[10];
@@ -106,43 +106,47 @@ BOOL CJabberProto::OnIqRequestTime(HXML, CJabberIqInfo *pInfo)
int nGmtOffset = GetGMTOffset();
mir_snwprintf(szTZ, L"%+03d:%02d", nGmtOffset / 60, nGmtOffset % 60);
- XmlNodeIq iq(L"result", pInfo);
- HXML timeNode = iq << XCHILDNS(L"time", JABBER_FEAT_ENTITY_TIME);
- timeNode << XCHILD(L"utc", stime); timeNode << XCHILD(L"tzo", szTZ);
+ XmlNodeIq iq("result", pInfo);
+ TiXmlElement *timeNode = iq << XCHILDNS("time", JABBER_FEAT_ENTITY_TIME);
+ timeNode << XCHILD("utc", T2Utf(stime)); timeNode << XCHILD("tzo", T2Utf(szTZ));
+
const wchar_t *szTZName = TimeZone_GetName(nullptr);
if (szTZName)
- timeNode << XCHILD(L"tz", szTZName);
+ timeNode << XCHILD("tz", T2Utf(szTZName));
+
m_ThreadInfo->send(iq);
return TRUE;
}
-BOOL CJabberProto::OnIqProcessIqOldTime(HXML, CJabberIqInfo *pInfo)
+BOOL CJabberProto::OnIqProcessIqOldTime(const TiXmlElement*, CJabberIqInfo *pInfo)
{
struct tm *gmt;
time_t ltime;
- wchar_t stime[100], *dtime;
+ char stime[100], *dtime;
_tzset();
time(&ltime);
gmt = gmtime(&ltime);
- mir_snwprintf(stime, L"%.4i%.2i%.2iT%.2i:%.2i:%.2i",
+ mir_snprintf(stime, "%.4i%.2i%.2iT%.2i:%.2i:%.2i",
gmt->tm_year + 1900, gmt->tm_mon + 1,
gmt->tm_mday, gmt->tm_hour, gmt->tm_min, gmt->tm_sec);
- dtime = _wctime(&ltime);
+ dtime = ctime(&ltime);
dtime[24] = 0;
- XmlNodeIq iq(L"result", pInfo);
- HXML queryNode = iq << XQUERY(JABBER_FEAT_ENTITY_TIME_OLD);
- queryNode << XCHILD(L"utc", stime);
+ XmlNodeIq iq("result", pInfo);
+ TiXmlElement *queryNode = iq << XQUERY(JABBER_FEAT_ENTITY_TIME_OLD);
+ queryNode << XCHILD("utc", stime);
+
const wchar_t *szTZName = TimeZone_GetName(nullptr);
if (szTZName)
- queryNode << XCHILD(L"tz", szTZName);
- queryNode << XCHILD(L"display", dtime);
+ queryNode << XCHILD("tz", T2Utf(szTZName));
+
+ queryNode << XCHILD("display", dtime);
m_ThreadInfo->send(iq);
return TRUE;
}
-BOOL CJabberProto::OnIqRequestAvatar(HXML, CJabberIqInfo *pInfo)
+BOOL CJabberProto::OnIqRequestAvatar(const TiXmlElement*, CJabberIqInfo *pInfo)
{
if (!m_bEnableAvatars)
return TRUE;
@@ -151,7 +155,7 @@ BOOL CJabberProto::OnIqRequestAvatar(HXML, CJabberIqInfo *pInfo)
if (pictureType == PA_FORMAT_UNKNOWN)
return TRUE;
- const wchar_t *szMimeType = ProtoGetAvatarMimeType(pictureType);
+ const char *szMimeType = ProtoGetAvatarMimeType(pictureType);
if (szMimeType == nullptr)
return TRUE;
@@ -173,119 +177,108 @@ BOOL CJabberProto::OnIqRequestAvatar(HXML, CJabberIqInfo *pInfo)
fclose(in);
ptrA str(mir_base64_encode(buffer, bytes));
- m_ThreadInfo->send(XmlNodeIq(L"result", pInfo) << XQUERY(JABBER_FEAT_AVATAR) << XCHILD(L"query", _A2T(str)) << XATTR(L"mimetype", szMimeType));
+ m_ThreadInfo->send(XmlNodeIq("result", pInfo) << XQUERY(JABBER_FEAT_AVATAR) << XCHILD("query", str) << XATTR("mimetype", szMimeType));
return TRUE;
}
-BOOL CJabberProto::OnSiRequest(HXML node, CJabberIqInfo *pInfo)
+BOOL CJabberProto::OnSiRequest(const TiXmlElement *node, CJabberIqInfo *pInfo)
{
- const wchar_t *szProfile = XmlGetAttrValue(pInfo->GetChildNode(), L"profile");
+ const char *szProfile = pInfo->GetChildNode()->Attribute("profile");
- if (szProfile && !mir_wstrcmp(szProfile, JABBER_FEAT_SI_FT))
+ if (szProfile && !mir_strcmp(szProfile, JABBER_FEAT_SI_FT))
FtHandleSiRequest(node);
else {
- XmlNodeIq iq(L"error", pInfo);
- HXML error = iq << XCHILD(L"error") << XATTRI(L"code", 400) << XATTR(L"type", L"cancel");
- error << XCHILDNS(L"bad-request", L"urn:ietf:params:xml:ns:xmpp-stanzas");
- error << XCHILD(L"bad-profile");
+ XmlNodeIq iq("error", pInfo);
+ TiXmlElement *error = iq << XCHILD("error") << XATTRI("code", 400) << XATTR("type", "cancel");
+ error << XCHILDNS("bad-request", "urn:ietf:params:xml:ns:xmpp-stanzas");
+ error << XCHILD("bad-profile");
m_ThreadInfo->send(iq);
}
return TRUE;
}
-BOOL CJabberProto::OnRosterPushRequest(HXML, CJabberIqInfo *pInfo)
+BOOL CJabberProto::OnRosterPushRequest(const TiXmlElement*, CJabberIqInfo *pInfo)
{
- HXML queryNode = pInfo->GetChildNode();
+ auto *queryNode = pInfo->GetChildNode();
// RFC 3921 #7.2 Business Rules
if (pInfo->GetFrom()) {
- wchar_t *szFrom = JabberPrepareJid(pInfo->GetFrom());
+ ptrA szFrom(JabberPrepareJid(pInfo->GetFrom()));
if (!szFrom)
return TRUE;
- wchar_t *szTo = JabberPrepareJid(m_ThreadInfo->fullJID);
- if (!szTo) {
- mir_free(szFrom);
+ ptrA szTo(JabberPrepareJid(m_ThreadInfo->fullJID));
+ if (!szTo)
return TRUE;
- }
-
- wchar_t *pDelimiter = wcschr(szFrom, '/');
- if (pDelimiter) *pDelimiter = 0;
-
- pDelimiter = wcschr(szTo, '/');
- if (pDelimiter) *pDelimiter = 0;
- BOOL bRetVal = mir_wstrcmp(szFrom, szTo) == 0;
+ char *pDelimiter = strchr(szFrom, '/');
+ if (pDelimiter)
+ *pDelimiter = 0;
- mir_free(szFrom);
- mir_free(szTo);
+ pDelimiter = strchr(szTo, '/');
+ if (pDelimiter)
+ *pDelimiter = 0;
// invalid JID
+ BOOL bRetVal = mir_strcmp(szFrom, szTo) == 0;
if (!bRetVal) {
- debugLogW(L"<iq/> attempt to hack via roster push from %s", pInfo->GetFrom());
+ debugLogA("<iq/> attempt to hack via roster push from %s", pInfo->GetFrom());
return TRUE;
}
}
- debugLogA("<iq/> Got roster push, query has %d children", XmlGetChildCount(queryNode));
- for (int i = 0;; i++) {
- HXML itemNode = XmlGetChild(queryNode, i);
- if (!itemNode)
- break;
-
- if (mir_wstrcmp(XmlGetName(itemNode), L"item") != 0)
- continue;
-
- const wchar_t *jid = XmlGetAttrValue(itemNode, L"jid"), *str = XmlGetAttrValue(itemNode, L"subscription");
+ debugLogA("<iq/> Got roster push");
+ for (auto *itemNode : TiXmlFilter(queryNode, "item")) {
+ const char *jid = itemNode->Attribute("jid"), *str = itemNode->Attribute("subscription");
if (jid == nullptr || str == nullptr)
continue;
// we will not add new account when subscription=remove
- if (!mir_wstrcmp(str, L"to") || !mir_wstrcmp(str, L"both") || !mir_wstrcmp(str, L"from") || !mir_wstrcmp(str, L"none")) {
- const wchar_t *name = XmlGetAttrValue(itemNode, L"name");
- ptrW nick((name != nullptr) ? mir_wstrdup(name) : JabberNickFromJID(jid));
+ if (!mir_strcmp(str, "to") || !mir_strcmp(str, "both") || !mir_strcmp(str, "from") || !mir_strcmp(str, "none")) {
+ const char *name = itemNode->Attribute("name");
+ ptrA nick((name != nullptr) ? mir_strdup(name) : JabberNickFromJID(jid));
if (nick != nullptr) {
MCONTACT hContact = HContactFromJID(jid, false);
if (hContact == 0)
hContact = DBCreateContact(jid, nick, false, false);
else
- setWString(hContact, "jid", jid);
+ db_set_utf(hContact, m_szModuleName, "jid", jid);
JABBER_LIST_ITEM *item = ListAdd(LIST_ROSTER, jid, hContact);
- replaceStrW(item->nick, nick);
+ replaceStr(item->nick, nick);
item->bRealContact = true;
- HXML groupNode = XmlGetChild(itemNode, "group");
- replaceStrW(item->group, XmlGetText(groupNode));
+ auto *groupNode = itemNode->FirstChildElement("group");
+ replaceStr(item->group, groupNode->GetText());
if (name != nullptr) {
- ptrW tszNick(getWStringA(hContact, "Nick"));
+ ptrA tszNick(getUStringA(hContact, "Nick"));
if (tszNick != nullptr) {
- if (mir_wstrcmp(nick, tszNick) != 0)
- db_set_ws(hContact, "CList", "MyHandle", nick);
+ if (mir_strcmp(nick, tszNick) != 0)
+ db_set_utf(hContact, "CList", "MyHandle", nick);
else
db_unset(hContact, "CList", "MyHandle");
}
- else db_set_ws(hContact, "CList", "MyHandle", nick);
+ else db_set_utf(hContact, "CList", "MyHandle", nick);
}
else db_unset(hContact, "CList", "MyHandle");
if (!m_bIgnoreRosterGroups) {
if (item->group != nullptr) {
- Clist_GroupCreate(0, item->group);
- db_set_ws(hContact, "CList", "Group", item->group);
+ Clist_GroupCreate(0, Utf2T(item->group));
+ db_set_utf(hContact, "CList", "Group", item->group);
}
else db_unset(hContact, "CList", "Group");
}
}
}
- if (JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid)) {
- if (!mir_wstrcmp(str, L"both"))
+ if (auto *item = ListGetItemPtr(LIST_ROSTER, jid)) {
+ if (!mir_strcmp(str, "both"))
item->subscription = SUB_BOTH;
- else if (!mir_wstrcmp(str, L"to"))
+ else if (!mir_strcmp(str, "to"))
item->subscription = SUB_TO;
- else if (!mir_wstrcmp(str, L"from"))
+ else if (!mir_strcmp(str, "from"))
item->subscription = SUB_FROM;
else
item->subscription = SUB_NONE;
@@ -295,7 +288,7 @@ BOOL CJabberProto::OnRosterPushRequest(HXML, CJabberIqInfo *pInfo)
// subscription = remove is to remove from roster list
// but we will just set the contact to offline and not actually
// remove, so that history will be retained.
- if (!mir_wstrcmp(str, L"remove")) {
+ if (!mir_strcmp(str, "remove")) {
SetContactOfflineStatus(item->hContact);
UpdateSubscriptionInfo(item->hContact, item);
}
@@ -311,26 +304,26 @@ BOOL CJabberProto::OnRosterPushRequest(HXML, CJabberIqInfo *pInfo)
return TRUE;
}
-BOOL CJabberProto::OnIqRequestOOB(HXML, CJabberIqInfo *pInfo)
+BOOL CJabberProto::OnIqRequestOOB(const TiXmlElement*, CJabberIqInfo *pInfo)
{
if (!pInfo->GetFrom() || !pInfo->GetHContact())
return TRUE;
- HXML n = XmlGetChild(pInfo->GetChildNode(), "url");
- if (!n || !XmlGetText(n))
+ auto *n = pInfo->GetChildNode()->FirstChildElement("url");
+ if (!n || !n->GetText())
return TRUE;
if (m_bBsOnlyIBB) {
// reject
- XmlNodeIq iq(L"error", pInfo);
- HXML e = XmlAddChild(iq, L"error", L"File transfer refused"); XmlAddAttr(e, L"code", 406);
+ XmlNodeIq iq("error", pInfo);
+ TiXmlElement *e = XmlAddChild(iq, "error", "File transfer refused"); e->SetAttribute("code", 406);
m_ThreadInfo->send(iq);
return TRUE;
}
filetransfer *ft = new filetransfer(this);
ft->std.totalFiles = 1;
- ft->jid = mir_wstrdup(pInfo->GetFrom());
+ ft->jid = mir_strdup(pInfo->GetFrom());
ft->std.hContact = pInfo->GetHContact();
ft->type = FT_OOB;
ft->httpHostName = nullptr;
@@ -338,7 +331,7 @@ BOOL CJabberProto::OnIqRequestOOB(HXML, CJabberIqInfo *pInfo)
ft->httpPath = nullptr;
// Parse the URL
- wchar_t *str = (wchar_t*)XmlGetText(n); // URL of the file to get
+ wchar_t *str = (wchar_t*)n->GetText(); // URL of the file to get
if (!wcsnicmp(str, L"http://", 7)) {
wchar_t *p = str + 7, *q;
if ((q = wcschr(p, '/')) != nullptr) {
@@ -359,11 +352,11 @@ BOOL CJabberProto::OnIqRequestOOB(HXML, CJabberIqInfo *pInfo)
ft->szId = JabberId2string(pInfo->GetIqId());
if (ft->httpHostName && ft->httpPath) {
- wchar_t *desc = nullptr;
+ const char *desc = nullptr;
debugLogA("Host=%s Port=%d Path=%s", ft->httpHostName, ft->httpPort, ft->httpPath);
- if ((n = XmlGetChild(pInfo->GetChildNode(), "desc")) != nullptr)
- desc = (wchar_t*)XmlGetText(n);
+ if ((n = pInfo->GetChildNode()->FirstChildElement("desc")) != nullptr)
+ desc = n->GetText();
wchar_t *str2;
debugLogW(L"description = %s", desc);
@@ -374,32 +367,32 @@ BOOL CJabberProto::OnIqRequestOOB(HXML, CJabberIqInfo *pInfo)
str2 = mir_wstrdup(str2);
JabberHttpUrlDecode(str2);
+ Utf2T wszDescr(desc);
PROTORECVFILE pre;
pre.dwFlags = PRFF_UNICODE;
pre.timestamp = time(0);
- pre.descr.w = desc;
+ pre.descr.w = wszDescr;
pre.files.w = &str2;
pre.fileCount = 1;
pre.lParam = (LPARAM)ft;
ProtoChainRecvFile(ft->std.hContact, &pre);
mir_free(str2);
}
- else {
- // reject
- XmlNodeIq iq(L"error", pInfo);
- HXML e = XmlAddChild(iq, L"error", L"File transfer refused"); XmlAddAttr(e, L"code", 406);
+ else { // reject
+ XmlNodeIq iq("error", pInfo);
+ TiXmlElement *e = XmlAddChild(iq, "error", "File transfer refused"); e->SetAttribute("code", 406);
m_ThreadInfo->send(iq);
delete ft;
}
return TRUE;
}
-BOOL CJabberProto::OnHandleDiscoInfoRequest(HXML iqNode, CJabberIqInfo *pInfo)
+BOOL CJabberProto::OnHandleDiscoInfoRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
if (!pInfo->GetChildNode())
return TRUE;
- const wchar_t *szNode = XmlGetAttrValue(pInfo->GetChildNode(), L"node");
+ const char *szNode = pInfo->GetChildNode()->Attribute("node");
// caps hack
if (m_clientCapsManager.HandleInfoRequest(iqNode, pInfo, szNode))
return TRUE;
@@ -410,31 +403,30 @@ BOOL CJabberProto::OnHandleDiscoInfoRequest(HXML iqNode, CJabberIqInfo *pInfo)
// another request, send empty result
m_ThreadInfo->send(
- XmlNodeIq(L"error", pInfo)
- << XCHILD(L"error") << XATTRI(L"code", 404) << XATTR(L"type", L"cancel")
- << XCHILDNS(L"item-not-found", L"urn:ietf:params:xml:ns:xmpp-stanzas"));
+ XmlNodeIq("error", pInfo)
+ << XCHILD("error") << XATTRI("code", 404) << XATTR("type", "cancel")
+ << XCHILDNS("item-not-found", "urn:ietf:params:xml:ns:xmpp-stanzas"));
return TRUE;
}
-BOOL CJabberProto::OnHandleDiscoItemsRequest(HXML iqNode, CJabberIqInfo *pInfo)
+BOOL CJabberProto::OnHandleDiscoItemsRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
if (!pInfo->GetChildNode())
return TRUE;
// ad-hoc commands check:
- const wchar_t *szNode = XmlGetAttrValue(pInfo->GetChildNode(), L"node");
+ const char *szNode = pInfo->GetChildNode()->Attribute("node");
if (szNode && m_adhocManager.HandleItemsRequest(iqNode, pInfo, szNode))
return TRUE;
// another request, send empty result
- XmlNodeIq iq(L"result", pInfo);
- HXML resultQuery = iq << XQUERY(JABBER_FEAT_DISCO_ITEMS);
+ XmlNodeIq iq("result", pInfo);
+ TiXmlElement *resultQuery = iq << XQUERY(JABBER_FEAT_DISCO_ITEMS);
if (szNode)
- XmlAddAttr(resultQuery, L"node", szNode);
+ resultQuery->SetAttribute("node", szNode);
if (!szNode && m_bEnableRemoteControl)
- resultQuery << XCHILD(L"item") << XATTR(L"jid", m_ThreadInfo->fullJID)
- << XATTR(L"node", JABBER_FEAT_COMMANDS) << XATTR(L"name", L"Ad-hoc commands");
+ resultQuery << XCHILD("item") << XATTR("jid", m_ThreadInfo->fullJID) << XATTR("node", JABBER_FEAT_COMMANDS) << XATTR("name", "Ad-hoc commands");
m_ThreadInfo->send(iq);
return TRUE;
@@ -456,7 +448,7 @@ BOOL CJabberProto::AddClistHttpAuthEvent(CJabberHttpAuthParams *pParams)
return TRUE;
}
-BOOL CJabberProto::OnIqHttpAuth(HXML node, CJabberIqInfo *pInfo)
+BOOL CJabberProto::OnIqHttpAuth(const TiXmlElement *node, CJabberIqInfo *pInfo)
{
if (!m_bAcceptHttpAuth)
return TRUE;
@@ -464,23 +456,23 @@ BOOL CJabberProto::OnIqHttpAuth(HXML node, CJabberIqInfo *pInfo)
if (!node || !pInfo->GetChildNode() || !pInfo->GetFrom() || !pInfo->GetIdStr())
return TRUE;
- HXML pConfirm = XmlGetChild(node, "confirm");
+ auto *pConfirm = node->FirstChildElement("confirm");
if (!pConfirm)
return TRUE;
- const wchar_t *szId = XmlGetAttrValue(pConfirm, L"id");
- const wchar_t *szMethod = XmlGetAttrValue(pConfirm, L"method");
- const wchar_t *szUrl = XmlGetAttrValue(pConfirm, L"url");
+ const char *szId = pConfirm->Attribute("id");
+ const char *szMethod = pConfirm->Attribute("method");
+ const char *szUrl = pConfirm->Attribute("url");
if (!szId || !szMethod || !szUrl)
return TRUE;
CJabberHttpAuthParams *pParams = (CJabberHttpAuthParams*)mir_calloc(sizeof(CJabberHttpAuthParams));
if (pParams) {
pParams->m_nType = CJabberHttpAuthParams::IQ;
- pParams->m_szFrom = mir_wstrdup(pInfo->GetFrom());
- pParams->m_szId = mir_wstrdup(szId);
- pParams->m_szMethod = mir_wstrdup(szMethod);
- pParams->m_szUrl = mir_wstrdup(szUrl);
+ pParams->m_szFrom = mir_strdup(pInfo->GetFrom());
+ pParams->m_szId = mir_strdup(szId);
+ pParams->m_szMethod = mir_strdup(szMethod);
+ pParams->m_szUrl = mir_strdup(szUrl);
AddClistHttpAuthEvent(pParams);
}
return TRUE;
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp
index f709f7bdd1..2eb7a03690 100755
--- a/protocols/JabberG/src/jabber_iqid.cpp
+++ b/protocols/JabberG/src/jabber_iqid.cpp
@@ -29,34 +29,30 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "jabber_caps.h"
#include "jabber_privacy.h"
-void CJabberProto::OnIqResultServerDiscoInfo(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultServerDiscoInfo(const TiXmlElement *iqNode, CJabberIqInfo*)
{
if (iqNode == nullptr)
return;
- const wchar_t *type = XmlGetAttrValue(iqNode, L"type");
- if (mir_wstrcmp(type, L"result"))
+ const char *type = iqNode->Attribute("type");
+ if (mir_strcmp(type, "result"))
return;
- HXML query = XmlGetChildByTag(iqNode, "query", "xmlns", JABBER_FEAT_DISCO_INFO);
+ auto *query = XmlGetChildByTag(iqNode, "query", "xmlns", JABBER_FEAT_DISCO_INFO);
if (query == nullptr)
return;
- HXML identity;
- for (int i = 1; (identity = XmlGetNthChild(query, L"identity", i)) != nullptr; i++) {
+ for (auto *identity : TiXmlFilter(query, "identity")) {
JABBER_DISCO_FIELD tmp = {
- XmlGetAttrValue(identity, L"category"),
- XmlGetAttrValue(identity, L"type"),
- XmlGetAttrValue(identity, L"name") };
+ identity->Attribute("category"),
+ identity->Attribute("type"),
+ identity->Attribute("name") };
- if (!mir_wstrcmp(tmp.category, L"pubsub") && !mir_wstrcmp(tmp.type, L"pep")) {
+ if (!mir_strcmp(tmp.category, "pubsub") && !mir_strcmp(tmp.type, "pep")) {
m_bPepSupported = true;
- if (m_bUseOMEMO)
- {
- //publish ndes, precreation is not required
+ if (m_bUseOMEMO) // publish ndes, precreation is not required
OmemoPublishNodes();
- }
EnableMenuItems(true);
RebuildInfoFrame();
@@ -67,14 +63,13 @@ void CJabberProto::OnIqResultServerDiscoInfo(HXML iqNode, CJabberIqInfo*)
}
if (m_ThreadInfo) {
- HXML feature;
- for (int i = 1; (feature = XmlGetNthChild(query, L"feature", i)) != nullptr; i++) {
- const wchar_t *featureName = XmlGetAttrValue(feature, L"var");
+ for (auto *feature : TiXmlFilter(query, "feature")) {
+ const char *featureName = feature->Attribute("var");
if (!featureName)
continue;
for (int j = 0; j < g_cJabberFeatCapPairs; j++) {
- if (!mir_wstrcmp(g_JabberFeatCapPairs[j].szFeature, featureName)) {
+ if (!mir_strcmp(g_JabberFeatCapPairs[j].szFeature, featureName)) {
m_ThreadInfo->jabberServerCaps |= g_JabberFeatCapPairs[j].jcbCap;
break;
}
@@ -85,14 +80,14 @@ void CJabberProto::OnIqResultServerDiscoInfo(HXML iqNode, CJabberIqInfo*)
OnProcessLoginRq(m_ThreadInfo, JABBER_LOGIN_SERVERINFO);
}
-void CJabberProto::OnIqResultNestedRosterGroups(HXML iqNode, CJabberIqInfo *pInfo)
+void CJabberProto::OnIqResultNestedRosterGroups(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
- const wchar_t *szGroupDelimeter = nullptr;
+ const char *szGroupDelimeter = nullptr;
bool bPrivateStorageSupport = false;
if (iqNode && pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
bPrivateStorageSupport = true;
- szGroupDelimeter = XPathFmt(iqNode, L"query[@xmlns='%s']/roster[@xmlns='%s']", JABBER_FEAT_PRIVATE_STORAGE, JABBER_FEAT_NESTED_ROSTER_GROUPS);
+ szGroupDelimeter = XPathFmt(iqNode, "query[@xmlns='%s']/roster[@xmlns='%s']", JABBER_FEAT_PRIVATE_STORAGE, JABBER_FEAT_NESTED_ROSTER_GROUPS);
if (szGroupDelimeter && !szGroupDelimeter[0])
szGroupDelimeter = nullptr; // "" as roster delimeter is not supported :)
}
@@ -102,25 +97,24 @@ void CJabberProto::OnIqResultNestedRosterGroups(HXML iqNode, CJabberIqInfo *pInf
return;
// is our default delimiter?
- if ((!szGroupDelimeter && bPrivateStorageSupport) || (szGroupDelimeter && mir_wstrcmp(szGroupDelimeter, L"\\")))
+ if ((!szGroupDelimeter && bPrivateStorageSupport) || (szGroupDelimeter && mir_strcmp(szGroupDelimeter, "\\")))
m_ThreadInfo->send(
- XmlNodeIq(L"set", SerialNext()) << XQUERY(JABBER_FEAT_PRIVATE_STORAGE)
- << XCHILD(L"roster", L"\\") << XATTR(L"xmlns", JABBER_FEAT_NESTED_ROSTER_GROUPS));
+ XmlNodeIq("set", SerialNext()) << XQUERY(JABBER_FEAT_PRIVATE_STORAGE)
+ << XCHILD("roster", "\\") << XATTR("xmlns", JABBER_FEAT_NESTED_ROSTER_GROUPS));
// roster request
- wchar_t *szUserData = mir_wstrdup(szGroupDelimeter ? szGroupDelimeter : L"\\");
+ char *szUserData = mir_strdup(szGroupDelimeter ? szGroupDelimeter : "\\");
m_ThreadInfo->send(
XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetRoster, JABBER_IQ_TYPE_GET, nullptr, 0, -1, (void*)szUserData))
- << XCHILDNS(L"query", JABBER_FEAT_IQ_ROSTER));
+ << XCHILDNS("query", JABBER_FEAT_IQ_ROSTER));
}
-void CJabberProto::OnIqResultNotes(HXML iqNode, CJabberIqInfo *pInfo)
+void CJabberProto::OnIqResultNotes(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
- if (iqNode && pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
- HXML hXmlData = XPathFmt(iqNode, L"query[@xmlns='%s']/storage[@xmlns='%s']",
- JABBER_FEAT_PRIVATE_STORAGE, JABBER_FEAT_MIRANDA_NOTES);
- if (hXmlData) m_notes.LoadXml(hXmlData);
- }
+ if (iqNode && pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT)
+ if (auto *query = XmlGetChildByTag(iqNode, "query", "xmlns", JABBER_FEAT_PRIVATE_STORAGE))
+ if (auto *storage = XmlGetChildByTag(query, "storage", "xmlns", JABBER_FEAT_MIRANDA_NOTES))
+ m_notes.LoadXml(storage);
}
void CJabberProto::OnProcessLoginRq(ThreadData *info, DWORD rq)
@@ -143,22 +137,22 @@ void CJabberProto::OnProcessLoginRq(ThreadData *info, DWORD rq)
LISTFOREACH(i, this, LIST_BOOKMARK)
{
JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i);
- if (item != nullptr && !mir_wstrcmp(item->type, L"conference") && item->bAutoJoin)
+ if (item != nullptr && !mir_strcmp(item->type, "conference") && item->bAutoJoin)
ll.insert(item);
}
for (auto &item : ll) {
- wchar_t room[256], text[128];
- wcsncpy_s(text, item->jid, _TRUNCATE);
- wcsncpy_s(room, text, _TRUNCATE);
- wchar_t *p = wcstok(room, L"@");
- wchar_t *server = wcstok(nullptr, L"@");
+ char room[256], text[128];
+ strncpy_s(text, item->jid, _TRUNCATE);
+ strncpy_s(room, text, _TRUNCATE);
+ char *p = strtok(room, "@");
+ char *server = strtok(nullptr, "@");
if (item->nick && item->nick[0])
GroupchatJoinRoom(server, p, item->nick, item->password, true);
else {
- ptrW nick(getWStringA(HContactFromJID(m_szJabberJID), "MyNick"));
+ ptrA nick(getUStringA(HContactFromJID(m_szJabberJID), "MyNick"));
if (nick == nullptr)
- nick = getWStringA("Nick");
+ nick = getUStringA("Nick");
if (nick == nullptr)
nick = JabberNickFromJID(m_szJabberJID);
@@ -187,25 +181,25 @@ void CJabberProto::OnLoggedIn()
pIqInfo->SetTimeout(30000);
m_ThreadInfo->send(
XmlNodeIq(pIqInfo) << XQUERY(JABBER_FEAT_PRIVATE_STORAGE)
- << XCHILDNS(L"roster", JABBER_FEAT_NESTED_ROSTER_GROUPS));
+ << XCHILDNS("roster", JABBER_FEAT_NESTED_ROSTER_GROUPS));
}
// Server-side notes
m_ThreadInfo->send(
XmlNodeIq(AddIQ(&CJabberProto::OnIqResultNotes, JABBER_IQ_TYPE_GET))
<< XQUERY(JABBER_FEAT_PRIVATE_STORAGE)
- << XCHILDNS(L"storage", JABBER_FEAT_MIRANDA_NOTES));
+ << XCHILDNS("storage", JABBER_FEAT_MIRANDA_NOTES));
m_ThreadInfo->send(
XmlNodeIq(AddIQ(&CJabberProto::OnIqResultDiscoBookmarks, JABBER_IQ_TYPE_GET))
- << XQUERY(JABBER_FEAT_PRIVATE_STORAGE) << XCHILDNS(L"storage", L"storage:bookmarks"));
+ << XQUERY(JABBER_FEAT_PRIVATE_STORAGE) << XCHILDNS("storage", "storage:bookmarks"));
}
m_bPepSupported = false;
m_ThreadInfo->jabberServerCaps = JABBER_RESOURCE_CAPS_NONE;
m_ThreadInfo->send(
- XmlNodeIq(AddIQ(&CJabberProto::OnIqResultServerDiscoInfo, JABBER_IQ_TYPE_GET, _A2T(m_ThreadInfo->conn.server)))
+ XmlNodeIq(AddIQ(&CJabberProto::OnIqResultServerDiscoInfo, JABBER_IQ_TYPE_GET, m_ThreadInfo->conn.server))
<< XQUERY(JABBER_FEAT_DISCO_INFO));
QueryPrivacyLists(m_ThreadInfo);
@@ -220,42 +214,41 @@ void CJabberProto::OnLoggedIn()
m_StrmMgmt.CheckState();
}
-void CJabberProto::OnIqResultGetAuth(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultGetAuth(const TiXmlElement *iqNode, CJabberIqInfo*)
{
// RECVED: result of the request for authentication method
// ACTION: send account authentication information to log in
debugLogA("<iq/> iqIdGetAuth");
- HXML queryNode;
- const wchar_t *type;
- if ((type = XmlGetAttrValue(iqNode, L"type")) == nullptr) return;
- if ((queryNode = XmlGetChild(iqNode, "query")) == nullptr) return;
+ const TiXmlElement *queryNode;
+ const char *type;
+ if ((type = iqNode->Attribute("type")) == nullptr) return;
+ if ((queryNode = iqNode->FirstChildElement("query")) == nullptr) return;
- if (!mir_wstrcmp(type, L"result")) {
+ if (!mir_strcmp(type, "result")) {
XmlNodeIq iq(AddIQ(&CJabberProto::OnIqResultSetAuth, JABBER_IQ_TYPE_SET));
- HXML query = iq << XQUERY(L"jabber:iq:auth");
- query << XCHILD(L"username", m_ThreadInfo->conn.username);
- if (XmlGetChild(queryNode, "digest") != nullptr && m_ThreadInfo->szStreamId) {
+ auto *query = iq << XQUERY("jabber:iq:auth");
+ query << XCHILD("username", m_ThreadInfo->conn.username);
+ if (queryNode->FirstChildElement("digest") != nullptr && m_ThreadInfo->szStreamId) {
JabberShaStrBuf buf;
- T2Utf str(m_ThreadInfo->conn.password);
char text[200];
- mir_snprintf(text, "%s%s", m_ThreadInfo->szStreamId, str);
- query << XCHILD(L"digest", _A2T(JabberSha1(text, buf)));
+ mir_snprintf(text, "%s%s", m_ThreadInfo->szStreamId, m_ThreadInfo->conn.password);
+ query << XCHILD("digest", JabberSha1(text, buf));
}
- else if (XmlGetChild(queryNode, "password") != nullptr)
- query << XCHILD(L"password", m_ThreadInfo->conn.password);
+ else if (queryNode->FirstChildElement("password") != nullptr)
+ query << XCHILD("password", m_ThreadInfo->conn.password);
else {
debugLogA("No known authentication mechanism accepted by the server.");
m_ThreadInfo->send("</stream:stream>");
return;
}
- if (XmlGetChild(queryNode, "resource") != nullptr)
- query << XCHILD(L"resource", m_ThreadInfo->resource);
+ if (queryNode->FirstChildElement("resource") != nullptr)
+ query << XCHILD("resource", m_ThreadInfo->resource);
m_ThreadInfo->send(iq);
}
- else if (!mir_wstrcmp(type, L"error")) {
+ else if (!mir_strcmp(type, "error")) {
m_ThreadInfo->send("</stream:stream>");
wchar_t text[128];
@@ -266,52 +259,53 @@ void CJabberProto::OnIqResultGetAuth(HXML iqNode, CJabberIqInfo*)
}
}
-void CJabberProto::OnIqResultSetAuth(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultSetAuth(const TiXmlElement *iqNode, CJabberIqInfo*)
{
- const wchar_t *type;
+ const char *type;
// RECVED: authentication result
// ACTION: if successfully logged in, continue by requesting roster list and set my initial status
debugLogA("<iq/> iqIdSetAuth");
- if ((type = XmlGetAttrValue(iqNode, L"type")) == nullptr) return;
+ if ((type = iqNode->Attribute("type")) == nullptr) return;
- if (!mir_wstrcmp(type, L"result")) {
- ptrW tszNick(getWStringA("Nick"));
+ if (!mir_strcmp(type, "result")) {
+ ptrA tszNick(getUStringA("Nick"));
if (tszNick == nullptr)
- setWString("Nick", m_ThreadInfo->conn.username);
+ setUString("Nick", m_ThreadInfo->conn.username);
OnLoggedIn();
}
// What to do if password error? etc...
- else if (!mir_wstrcmp(type, L"error")) {
- wchar_t text[128];
-
+ else if (!mir_strcmp(type, "error")) {
m_ThreadInfo->send("</stream:stream>");
- mir_snwprintf(text, TranslateT("Authentication failed for %s."), m_ThreadInfo->conn.username);
+
+ wchar_t text[128];
+ mir_snwprintf(text, TranslateT("Authentication failed for %s."), Utf2T(m_ThreadInfo->conn.username).get());
MsgPopup(0, text, TranslateT("Jabber Authentication"));
+
JLoginFailed(LOGINERR_WRONGPASSWORD);
m_ThreadInfo = nullptr; // To disallow auto reconnect
}
}
-void CJabberProto::OnIqResultBind(HXML iqNode, CJabberIqInfo *pInfo)
+void CJabberProto::OnIqResultBind(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
if (!m_ThreadInfo || !iqNode)
return;
if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
- const wchar_t *szJid = XPathT(iqNode, "bind[@xmlns='urn:ietf:params:xml:ns:xmpp-bind']/jid");
+ const char *szJid = XPath(iqNode, "bind[@xmlns='urn:ietf:params:xml:ns:xmpp-bind']/jid");
if (szJid) {
- if (!wcsncmp(m_ThreadInfo->fullJID, szJid, _countof(m_ThreadInfo->fullJID)))
+ if (!strncmp(m_ThreadInfo->fullJID, szJid, _countof(m_ThreadInfo->fullJID)))
debugLogW(L"Result Bind: %s confirmed ", m_ThreadInfo->fullJID);
else {
debugLogW(L"Result Bind: %s changed to %s", m_ThreadInfo->fullJID, szJid);
- wcsncpy_s(m_ThreadInfo->fullJID, szJid, _TRUNCATE);
+ strncpy_s(m_ThreadInfo->fullJID, szJid, _TRUNCATE);
}
}
if (m_ThreadInfo->bIsSessionAvailable)
m_ThreadInfo->send(
XmlNodeIq(AddIQ(&CJabberProto::OnIqResultSession, JABBER_IQ_TYPE_SET))
- << XCHILDNS(L"session", L"urn:ietf:params:xml:ns:xmpp-session"));
+ << XCHILDNS("session", "urn:ietf:params:xml:ns:xmpp-session"));
else
OnLoggedIn();
}
@@ -322,7 +316,7 @@ void CJabberProto::OnIqResultBind(HXML iqNode, CJabberIqInfo *pInfo)
}
}
-void CJabberProto::OnIqResultSession(HXML, CJabberIqInfo *pInfo)
+void CJabberProto::OnIqResultSession(const TiXmlElement*, CJabberIqInfo *pInfo)
{
if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT)
OnLoggedIn();
@@ -330,85 +324,69 @@ void CJabberProto::OnIqResultSession(HXML, CJabberIqInfo *pInfo)
void CJabberProto::GroupchatJoinByHContact(MCONTACT hContact, bool autojoin)
{
- ptrW roomjid(getWStringA(hContact, "ChatRoomID"));
+ ptrA roomjid(getUStringA(hContact, "ChatRoomID"));
if (roomjid == nullptr)
return;
- wchar_t *room = roomjid;
- wchar_t *server = wcschr(roomjid, '@');
+ char *room = roomjid;
+ char *server = strchr(roomjid, '@');
if (!server)
return;
server[0] = 0; server++;
- ptrW nick(getWStringA(hContact, "MyNick"));
+ ptrA nick(getUStringA(hContact, "MyNick"));
if (nick == nullptr) {
nick = JabberNickFromJID(m_szJabberJID);
if (nick == nullptr)
return;
}
- GroupchatJoinRoom(server, room, nick, ptrW(getWStringA(hContact, "Password")), autojoin);
+ GroupchatJoinRoom(server, room, nick, ptrA(getUStringA(hContact, "Password")), autojoin);
}
/////////////////////////////////////////////////////////////////////////////////////////
// JabberIqResultGetRoster - populates LIST_ROSTER and creates contact for any new rosters
-void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo)
+void CJabberProto::OnIqResultGetRoster(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
debugLogA("<iq/> iqIdGetRoster");
- wchar_t *szGroupDelimeter = (wchar_t *)pInfo->GetUserData();
- if (pInfo->GetIqType() != JABBER_IQ_TYPE_RESULT) {
- mir_free(szGroupDelimeter);
+ ptrA szGroupDelimeter((char *)pInfo->GetUserData());
+ if (pInfo->GetIqType() != JABBER_IQ_TYPE_RESULT)
return;
- }
- HXML queryNode = XmlGetChild(iqNode, "query");
- if (queryNode == nullptr) {
- mir_free(szGroupDelimeter);
+ auto *queryNode = iqNode->FirstChildElement("query");
+ if (queryNode == nullptr)
return;
- }
- if (mir_wstrcmp(XmlGetAttrValue(queryNode, L"xmlns"), JABBER_FEAT_IQ_ROSTER)) {
- mir_free(szGroupDelimeter);
+ if (mir_strcmp(queryNode->Attribute("xmlns"), JABBER_FEAT_IQ_ROSTER))
return;
- }
- if (!mir_wstrcmp(szGroupDelimeter, L"\\")) {
- mir_free(szGroupDelimeter);
+ if (!mir_strcmp(szGroupDelimeter, "\\"))
szGroupDelimeter = nullptr;
- }
LIST<void> chatRooms(10);
OBJLIST<JABBER_HTTP_AVATARS> *httpavatars = new OBJLIST<JABBER_HTTP_AVATARS>(20, JABBER_HTTP_AVATARS::compare);
- for (int i = 0;; i++) {
+ for (auto *itemNode : TiXmlFilter(queryNode, "item")) {
bool bIsTransport = false;
-
- HXML itemNode = XmlGetChild(queryNode, i);
- if (!itemNode)
- break;
-
- if (mir_wstrcmp(XmlGetName(itemNode), L"item"))
- continue;
-
- const wchar_t *str = XmlGetAttrValue(itemNode, L"subscription");
+ const char *str = itemNode->Attribute("subscription");
JABBER_SUBSCRIPTION sub;
if (str == nullptr) sub = SUB_NONE;
- else if (!mir_wstrcmp(str, L"both")) sub = SUB_BOTH;
- else if (!mir_wstrcmp(str, L"to")) sub = SUB_TO;
- else if (!mir_wstrcmp(str, L"from")) sub = SUB_FROM;
+ else if (!mir_strcmp(str, "both")) sub = SUB_BOTH;
+ else if (!mir_strcmp(str, "to")) sub = SUB_TO;
+ else if (!mir_strcmp(str, "from")) sub = SUB_FROM;
else sub = SUB_NONE;
- const wchar_t *jid = XmlGetAttrValue(itemNode, L"jid");
+ const char *jid = itemNode->Attribute("jid");
if (jid == nullptr)
continue;
- if (wcschr(jid, '@') == nullptr)
+ if (strchr(jid, '@') == nullptr)
bIsTransport = true;
- const wchar_t *name = XmlGetAttrValue(itemNode, L"name");
- wchar_t *nick = (name != nullptr) ? mir_wstrdup(name) : JabberNickFromJID(jid);
+ const char *name = itemNode->Attribute("name");
+ char *nick = (name != nullptr) ? mir_strdup(name) : JabberNickFromJID(jid);
if (nick == nullptr)
continue;
@@ -422,39 +400,35 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo)
mir_free(item->nick); item->nick = nick;
- HXML groupNode = XmlGetChild(itemNode, "group");
- replaceStrW(item->group, XmlGetText(groupNode));
+ auto *groupNode = itemNode->FirstChildElement("group");
+ replaceStr(item->group, groupNode->GetText());
// check group delimiters
if (item->group && szGroupDelimeter) {
- while (wchar_t *szPos = wcsstr(item->group, szGroupDelimeter)) {
+ while (char *szPos = strstr(item->group, szGroupDelimeter)) {
*szPos = 0;
- szPos += mir_wstrlen(szGroupDelimeter);
- wchar_t *szNewGroup = (wchar_t *)mir_alloc(sizeof(wchar_t) * (mir_wstrlen(item->group) + mir_wstrlen(szPos) + 2));
- mir_wstrcpy(szNewGroup, item->group);
- mir_wstrcat(szNewGroup, L"\\");
- mir_wstrcat(szNewGroup, szPos);
- mir_free(item->group);
- item->group = szNewGroup;
+ szPos += mir_strlen(szGroupDelimeter);
+ CMStringA szNewGroup(FORMAT, "%s\\%s", item->group, szPos);
+ replaceStr(item->group, szNewGroup.Detach());
}
}
if (name != nullptr) {
- ptrW tszNick(getWStringA(hContact, "Nick"));
+ ptrA tszNick(getUStringA(hContact, "Nick"));
if (tszNick != nullptr) {
- if (mir_wstrcmp(nick, tszNick) != 0)
- db_set_ws(hContact, "CList", "MyHandle", nick);
+ if (mir_strcmp(nick, tszNick) != 0)
+ db_set_utf(hContact, "CList", "MyHandle", nick);
else
db_unset(hContact, "CList", "MyHandle");
}
- else db_set_ws(hContact, "CList", "MyHandle", nick);
+ else db_set_utf(hContact, "CList", "MyHandle", nick);
}
else db_unset(hContact, "CList", "MyHandle");
if (isChatRoom(hContact)) {
- wchar_t *wszTitle = NEWWSTR_ALLOCA(jid);
- if (wchar_t *p = wcschr(wszTitle, '@')) *p = 0;
- Chat_NewSession(GCW_CHATROOM, m_szModuleName, jid, wszTitle);
+ char *wszTitle = NEWSTR_ALLOCA(jid);
+ if (char *p = strchr(wszTitle, '@')) *p = 0;
+ Chat_NewSession(GCW_CHATROOM, m_szModuleName, Utf2T(jid), Utf2T(wszTitle));
db_unset(hContact, "CList", "Hidden");
chatRooms.insert((HANDLE)hContact);
@@ -463,15 +437,15 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo)
if (!m_bIgnoreRosterGroups) {
if (item->group != nullptr) {
- Clist_GroupCreate(0, item->group);
+ Clist_GroupCreate(0, Utf2T(item->group));
// Don't set group again if already correct, or Miranda may show wrong group count in some case
- ptrW tszGroup(db_get_wsa(hContact, "CList", "Group"));
+ ptrA tszGroup(db_get_utfa(hContact, "CList", "Group"));
if (tszGroup != nullptr) {
- if (mir_wstrcmp(tszGroup, item->group))
- db_set_ws(hContact, "CList", "Group", item->group);
+ if (mir_strcmp(tszGroup, item->group))
+ db_set_utf(hContact, "CList", "Group", item->group);
}
- else db_set_ws(hContact, "CList", "Group", item->group);
+ else db_set_utf(hContact, "CList", "Group", item->group);
}
else db_unset(hContact, "CList", "Group");
}
@@ -483,7 +457,7 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo)
setByte(hContact, "IsTransport", false);
}
- const wchar_t *imagepath = XmlGetAttrValue(itemNode, L"vz:img");
+ const char *imagepath = itemNode->Attribute("vz:img");
if (imagepath)
httpavatars->insert(new JABBER_HTTP_AVATARS(imagepath, hContact));
}
@@ -526,24 +500,24 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo)
RebuildInfoFrame();
}
-void CJabberProto::OnIqResultGetRegister(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultGetRegister(const TiXmlElement *iqNode, CJabberIqInfo*)
{
// RECVED: result of the request for (agent) registration mechanism
// ACTION: activate (agent) registration input dialog
debugLogA("<iq/> iqIdGetRegister");
- HXML queryNode;
- const wchar_t *type;
- if ((type = XmlGetAttrValue(iqNode, L"type")) == nullptr) return;
- if ((queryNode = XmlGetChild(iqNode, "query")) == nullptr) return;
+ const TiXmlElement *queryNode;
+ const char *type;
+ if ((type = iqNode->Attribute("type")) == nullptr) return;
+ if ((queryNode = iqNode->FirstChildElement("query")) == nullptr) return;
- if (!mir_wstrcmp(type, L"result")) {
+ if (!mir_strcmp(type, "result")) {
if (m_hwndAgentRegInput)
- SendMessage(m_hwndAgentRegInput, WM_JABBER_REGINPUT_ACTIVATE, 1 /*success*/, (LPARAM)xmlCopyNode(iqNode));
+ SendMessage(m_hwndAgentRegInput, WM_JABBER_REGINPUT_ACTIVATE, 1 /*success*/, (LPARAM)iqNode);
}
- else if (!mir_wstrcmp(type, L"error")) {
+ else if (!mir_strcmp(type, "error")) {
if (m_hwndAgentRegInput) {
- HXML errorNode = XmlGetChild(iqNode, "error");
+ auto *errorNode = iqNode->FirstChildElement("error");
wchar_t *str = JabberErrorMsg(errorNode);
SendMessage(m_hwndAgentRegInput, WM_JABBER_REGINPUT_ACTIVATE, 0 /*error*/, (LPARAM)str);
mir_free(str);
@@ -551,17 +525,17 @@ void CJabberProto::OnIqResultGetRegister(HXML iqNode, CJabberIqInfo*)
}
}
-void CJabberProto::OnIqResultSetRegister(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultSetRegister(const TiXmlElement *iqNode, CJabberIqInfo*)
{
// RECVED: result of registration process
// ACTION: notify of successful agent registration
debugLogA("<iq/> iqIdSetRegister");
- const wchar_t *type, *from;
- if ((type = XmlGetAttrValue(iqNode, L"type")) == nullptr) return;
- if ((from = XmlGetAttrValue(iqNode, L"from")) == nullptr) return;
+ const char *type, *from;
+ if ((type = iqNode->Attribute("type")) == nullptr) return;
+ if ((from = iqNode->Attribute("from")) == nullptr) return;
- if (!mir_wstrcmp(type, L"result")) {
+ if (!mir_strcmp(type, "result")) {
MCONTACT hContact = HContactFromJID(from);
if (hContact != 0)
setByte(hContact, "IsTransport", true);
@@ -569,9 +543,9 @@ void CJabberProto::OnIqResultSetRegister(HXML iqNode, CJabberIqInfo*)
if (m_hwndRegProgress)
SendMessage(m_hwndRegProgress, WM_JABBER_REGDLG_UPDATE, 100, (LPARAM)TranslateT("Registration successful"));
}
- else if (!mir_wstrcmp(type, L"error")) {
+ else if (!mir_strcmp(type, "error")) {
if (m_hwndRegProgress) {
- HXML errorNode = XmlGetChild(iqNode, "error");
+ auto *errorNode = iqNode->FirstChildElement("error");
wchar_t *str = JabberErrorMsg(errorNode);
SendMessage(m_hwndRegProgress, WM_JABBER_REGDLG_UPDATE, 100, (LPARAM)str);
mir_free(str);
@@ -582,24 +556,24 @@ void CJabberProto::OnIqResultSetRegister(HXML iqNode, CJabberIqInfo*)
/////////////////////////////////////////////////////////////////////////////////////////
// JabberIqResultGetVcard - processes the server-side v-card
-void CJabberProto::OnIqResultGetVcardPhoto(HXML n, MCONTACT hContact, bool &hasPhoto)
+void CJabberProto::OnIqResultGetVcardPhoto(const TiXmlElement *n, MCONTACT hContact, bool &hasPhoto)
{
debugLogA("JabberIqResultGetVcardPhoto: %d", hasPhoto);
if (hasPhoto)
return;
- HXML o = XmlGetChild(n, "BINVAL");
- const wchar_t *ptszBinval = XmlGetText(o);
+ auto *o = n->FirstChildElement("BINVAL");
+ const char *ptszBinval = o->GetText();
if (o == nullptr || ptszBinval == nullptr)
return;
size_t bufferLen;
- ptrA buffer((char*)mir_base64_decode(_T2A(ptszBinval), &bufferLen));
+ ptrA buffer((char*)mir_base64_decode(ptszBinval, &bufferLen));
if (buffer == nullptr)
return;
- const wchar_t *szPicType = nullptr;
- if (const wchar_t *ptszType = XmlGetText(XmlGetChild(n, "TYPE")))
+ const char *szPicType = nullptr;
+ if (const char *ptszType = n->FirstChildElement("TYPE")->GetText())
if (ProtoGetAvatarFormatByMimeType(ptszType) != PA_FORMAT_UNKNOWN)
szPicType = ptszType;
@@ -632,7 +606,7 @@ void CJabberProto::OnIqResultGetVcardPhoto(HXML n, MCONTACT hContact, bool &hasP
debugLogW(L"My picture saved to %s", szAvatarFileName);
}
else {
- ptrW jid(getWStringA(hContact, "jid"));
+ ptrA jid(getUStringA(hContact, "jid"));
if (jid != nullptr) {
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid);
if (item == nullptr) {
@@ -642,9 +616,10 @@ void CJabberProto::OnIqResultGetVcardPhoto(HXML n, MCONTACT hContact, bool &hasP
}
if (item != nullptr) {
hasPhoto = true;
- if (item->photoFileName && mir_wstrcmp(item->photoFileName, szAvatarFileName))
- DeleteFile(item->photoFileName);
- replaceStrW(item->photoFileName, szAvatarFileName);
+ Utf2T oldFile(item->photoFileName);
+ if (item->photoFileName && mir_wstrcmp(oldFile, szAvatarFileName))
+ DeleteFile(oldFile);
+ replaceStr(item->photoFileName, T2Utf(szAvatarFileName));
debugLogW(L"Contact's picture saved to %s", szAvatarFileName);
OnIqResultGotAvatar(hContact, o, szPicType);
}
@@ -655,52 +630,51 @@ void CJabberProto::OnIqResultGetVcardPhoto(HXML n, MCONTACT hContact, bool &hasP
DeleteFile(szAvatarFileName);
}
-static wchar_t* sttGetText(HXML node, char* tag)
+static char* sttGetText(const TiXmlElement *node, const char *tag)
{
- HXML n = XmlGetChild(node, tag);
+ auto *n = node->FirstChildElement(tag);
if (n == nullptr)
return nullptr;
- return (wchar_t*)XmlGetText(n);
+ return (char*)n->GetText();
}
-void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultGetVcard(const TiXmlElement *iqNode, CJabberIqInfo*)
{
- HXML vCardNode, m, n, o;
- const wchar_t *type, *jid;
+ const TiXmlElement *vCardNode, *m, *o;
+ const char *type, *jid;
MCONTACT hContact;
DBVARIANT dbv;
debugLogA("<iq/> iqIdGetVcard");
- if ((type = XmlGetAttrValue(iqNode, L"type")) == nullptr) return;
- if ((jid = XmlGetAttrValue(iqNode, L"from")) == nullptr) return;
+ if ((type = iqNode->Attribute("type")) == nullptr) return;
+ if ((jid = iqNode->Attribute("from")) == nullptr) return;
int id = JabberGetPacketID(iqNode);
if (id == m_nJabberSearchID) {
m_nJabberSearchID = -1;
- if ((vCardNode = XmlGetChild(iqNode, "vCard")) != nullptr) {
- if (!mir_wstrcmp(type, L"result")) {
+ if ((vCardNode = iqNode->FirstChildElement("vCard")) != nullptr) {
+ if (!mir_strcmp(type, "result")) {
PROTOSEARCHRESULT psr = { 0 };
psr.cbSize = sizeof(psr);
- psr.flags = PSR_UNICODE;
- psr.nick.w = sttGetText(vCardNode, "NICKNAME");
- psr.firstName.w = sttGetText(vCardNode, "FN");
- psr.lastName.w = L"";
- psr.email.w = sttGetText(vCardNode, "EMAIL");
- psr.id.w = NEWWSTR_ALLOCA(jid);
+ psr.nick.a = sttGetText(vCardNode, "NICKNAME");
+ psr.firstName.a = sttGetText(vCardNode, "FN");
+ psr.lastName.a = "";
+ psr.email.a = sttGetText(vCardNode, "EMAIL");
+ psr.id.a = NEWSTR_ALLOCA(jid);
ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&psr);
ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
}
- else if (!mir_wstrcmp(type, L"error"))
+ else if (!mir_strcmp(type, "error"))
ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
}
else ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
return;
}
- size_t len = mir_wstrlen(m_szJabberJID);
- if (!wcsnicmp(jid, m_szJabberJID, len) && (jid[len] == '/' || jid[len] == '\0')) {
+ size_t len = mir_strlen(m_szJabberJID);
+ if (!strnicmp(jid, m_szJabberJID, len) && (jid[len] == '/' || jid[len] == '\0')) {
hContact = 0;
debugLogA("Vcard for myself");
}
@@ -710,13 +684,13 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*)
debugLogA("Other user's vcard");
}
- if (!mir_wstrcmp(type, L"error")) {
+ if (!mir_strcmp(type, "error")) {
if ((hContact = HContactFromJID(jid)) != 0)
ProtoBroadcastAck(hContact, ACKTYPE_GETINFO, ACKRESULT_FAILED, (HANDLE)1);
return;
}
- if (mir_wstrcmp(type, L"result"))
+ if (mir_strcmp(type, "result"))
return;
bool hasFn = false, hasNick = false, hasGiven = false, hasFamily = false, hasMiddle = false,
@@ -728,46 +702,45 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*)
hasOrgname = false, hasOrgunit = false, hasRole = false, hasTitle = false, hasDesc = false, hasPhoto = false;
int nEmail = 0, nPhone = 0, nYear, nMonth, nDay;
- if ((vCardNode = XmlGetChild(iqNode, "vCard")) != nullptr) {
- for (int i = 0;; i++) {
- n = XmlGetChild(vCardNode, i);
- if (!n)
- break;
- if (XmlGetName(n) == nullptr) continue;
- if (!mir_wstrcmp(XmlGetName(n), L"FN")) {
- if (XmlGetText(n) != nullptr) {
+ if ((vCardNode = iqNode->FirstChildElement("vCard")) != nullptr) {
+ for (auto *n : TiXmlEnum(vCardNode)) {
+ if (n->Name() == nullptr)
+ continue;
+
+ if (!mir_strcmp(n->Name(), "FN")) {
+ if (n->GetText() != nullptr) {
hasFn = true;
- setWString(hContact, "FullName", XmlGetText(n));
+ setUString(hContact, "FullName", n->GetText());
}
}
- else if (!mir_wstrcmp(XmlGetName(n), L"NICKNAME")) {
- if (XmlGetText(n) != nullptr) {
+ else if (!mir_strcmp(n->Name(), "NICKNAME")) {
+ if (n->GetText() != nullptr) {
hasNick = true;
- setWString(hContact, "Nick", XmlGetText(n));
+ setUString(hContact, "Nick", n->GetText());
}
}
- else if (!mir_wstrcmp(XmlGetName(n), L"N")) {
+ else if (!mir_strcmp(n->Name(), "N")) {
// First/Last name
if (!hasGiven && !hasFamily && !hasMiddle) {
- if ((m = XmlGetChild(n, "GIVEN")) != nullptr && XmlGetText(m) != nullptr) {
+ if ((m = n->FirstChildElement("GIVEN")) != nullptr && m->GetText() != nullptr) {
hasGiven = true;
- setWString(hContact, "FirstName", XmlGetText(m));
+ setUString(hContact, "FirstName", m->GetText());
}
- if ((m = XmlGetChild(n, "FAMILY")) != nullptr && XmlGetText(m) != nullptr) {
+ if ((m = n->FirstChildElement("FAMILY")) != nullptr && m->GetText() != nullptr) {
hasFamily = true;
- setWString(hContact, "LastName", XmlGetText(m));
+ setUString(hContact, "LastName", m->GetText());
}
- if ((m = XmlGetChild(n, "MIDDLE")) != nullptr && XmlGetText(m) != nullptr) {
+ if ((m = n->FirstChildElement("MIDDLE")) != nullptr && m->GetText() != nullptr) {
hasMiddle = true;
- setWString(hContact, "MiddleName", XmlGetText(m));
+ setUString(hContact, "MiddleName", m->GetText());
}
}
}
- else if (!mir_wstrcmp(XmlGetName(n), L"EMAIL")) {
+ else if (!mir_strcmp(n->Name(), "EMAIL")) {
// E-mail address(es)
- if ((m = XmlGetChild(n, "USERID")) == nullptr) // Some bad client put e-mail directly in <EMAIL/> instead of <USERID/>
+ if ((m = n->FirstChildElement("USERID")) == nullptr) // Some bad client put e-mail directly in <EMAIL/> instead of <USERID/>
m = n;
- if (XmlGetText(m) != nullptr) {
+ if (m->GetText() != nullptr) {
char text[100];
if (hContact != 0) {
if (nEmail == 0)
@@ -776,25 +749,25 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*)
mir_snprintf(text, "e-mail%d", nEmail - 1);
}
else mir_snprintf(text, "e-mail%d", nEmail);
- setWString(hContact, text, XmlGetText(m));
+ setUString(hContact, text, m->GetText());
if (hContact == 0) {
mir_snprintf(text, "e-mailFlag%d", nEmail);
int nFlag = 0;
- if (XmlGetChild(n, "HOME") != nullptr) nFlag |= JABBER_VCEMAIL_HOME;
- if (XmlGetChild(n, "WORK") != nullptr) nFlag |= JABBER_VCEMAIL_WORK;
- if (XmlGetChild(n, "INTERNET") != nullptr) nFlag |= JABBER_VCEMAIL_INTERNET;
- if (XmlGetChild(n, "X400") != nullptr) nFlag |= JABBER_VCEMAIL_X400;
+ if (n->FirstChildElement("HOME") != nullptr) nFlag |= JABBER_VCEMAIL_HOME;
+ if (n->FirstChildElement("WORK") != nullptr) nFlag |= JABBER_VCEMAIL_WORK;
+ if (n->FirstChildElement("INTERNET") != nullptr) nFlag |= JABBER_VCEMAIL_INTERNET;
+ if (n->FirstChildElement("X400") != nullptr) nFlag |= JABBER_VCEMAIL_X400;
setWord(text, nFlag);
}
nEmail++;
}
}
- else if (!mir_wstrcmp(XmlGetName(n), L"BDAY")) {
+ else if (!mir_strcmp(n->Name(), "BDAY")) {
// Birthday
- if (!hasBday && XmlGetText(n) != nullptr) {
+ if (!hasBday && n->GetText() != nullptr) {
if (hContact != 0) {
- if (swscanf(XmlGetText(n), L"%d-%d-%d", &nYear, &nMonth, &nDay) == 3) {
+ if (sscanf(n->GetText(), "%d-%d-%d", &nYear, &nMonth, &nDay) == 3) {
hasBday = true;
setWord(hContact, "BirthYear", (WORD)nYear);
setByte(hContact, "BirthMonth", (BYTE)nMonth);
@@ -811,220 +784,220 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*)
}
else {
hasBday = true;
- setWString("BirthDate", XmlGetText(n));
+ setUString("BirthDate", n->GetText());
}
}
}
- else if (!mir_wstrcmp(XmlGetName(n), L"GENDER")) {
+ else if (!mir_strcmp(n->Name(), "GENDER")) {
// Gender
- if (!hasGender && XmlGetText(n) != nullptr) {
+ if (!hasGender && n->GetText() != nullptr) {
if (hContact != 0) {
- if (XmlGetText(n)[0] && strchr("mMfF", XmlGetText(n)[0]) != nullptr) {
+ if (n->GetText()[0] && strchr("mMfF", n->GetText()[0]) != nullptr) {
hasGender = true;
- setByte(hContact, "Gender", (BYTE)toupper(XmlGetText(n)[0]));
+ setByte(hContact, "Gender", (BYTE)toupper(n->GetText()[0]));
}
}
else {
hasGender = true;
- setWString("GenderString", XmlGetText(n));
+ setUString("GenderString", n->GetText());
}
}
}
- else if (!mir_wstrcmp(XmlGetName(n), L"ADR")) {
- if (!hasHome && XmlGetChild(n, "HOME") != nullptr) {
+ else if (!mir_strcmp(n->Name(), "ADR")) {
+ if (!hasHome && n->FirstChildElement("HOME") != nullptr) {
// Home address
- wchar_t text[128];
+ char text[128];
hasHome = true;
- if ((m = XmlGetChild(n, "STREET")) != nullptr && XmlGetText(m) != nullptr) {
+ if ((m = n->FirstChildElement("STREET")) != nullptr && m->GetText() != nullptr) {
hasHomeStreet = true;
if (hContact != 0) {
- if ((o = XmlGetChild(n, "EXTADR")) != nullptr && XmlGetText(o) != nullptr)
- mir_snwprintf(text, L"%s\r\n%s", XmlGetText(m), XmlGetText(o));
- else if ((o = XmlGetChild(n, "EXTADD")) != nullptr && XmlGetText(o) != nullptr)
- mir_snwprintf(text, L"%s\r\n%s", XmlGetText(m), XmlGetText(o));
+ if ((o = n->FirstChildElement("EXTADR")) != nullptr && o->GetText() != nullptr)
+ mir_snprintf(text, "%s\r\n%s", m->GetText(), o->GetText());
+ else if ((o = n->FirstChildElement("EXTADD")) != nullptr && o->GetText() != nullptr)
+ mir_snprintf(text, "%s\r\n%s", m->GetText(), o->GetText());
else
- wcsncpy_s(text, XmlGetText(m), _TRUNCATE);
- text[_countof(text) - 1] = '\0';
- setWString(hContact, "Street", text);
+ strncpy_s(text, m->GetText(), _TRUNCATE);
+
+ setUString(hContact, "Street", text);
}
else {
- setWString(hContact, "Street", XmlGetText(m));
- if ((m = XmlGetChild(n, "EXTADR")) == nullptr)
- m = XmlGetChild(n, "EXTADD");
- if (m != nullptr && XmlGetText(m) != nullptr) {
+ setUString(hContact, "Street", m->GetText());
+ if ((m = n->FirstChildElement("EXTADR")) == nullptr)
+ m = n->FirstChildElement("EXTADD");
+ if (m != nullptr && m->GetText() != nullptr) {
hasHomeStreet2 = true;
- setWString(hContact, "Street2", XmlGetText(m));
+ setUString(hContact, "Street2", m->GetText());
}
}
}
- if ((m = XmlGetChild(n, "LOCALITY")) != nullptr && XmlGetText(m) != nullptr) {
+ if ((m = n->FirstChildElement("LOCALITY")) != nullptr && m->GetText() != nullptr) {
hasHomeLocality = true;
- setWString(hContact, "City", XmlGetText(m));
+ setUString(hContact, "City", m->GetText());
}
- if ((m = XmlGetChild(n, "REGION")) != nullptr && XmlGetText(m) != nullptr) {
+ if ((m = n->FirstChildElement("REGION")) != nullptr && m->GetText() != nullptr) {
hasHomeRegion = true;
- setWString(hContact, "State", XmlGetText(m));
+ setUString(hContact, "State", m->GetText());
}
- if ((m = XmlGetChild(n, "PCODE")) != nullptr && XmlGetText(m) != nullptr) {
+ if ((m = n->FirstChildElement("PCODE")) != nullptr && m->GetText() != nullptr) {
hasHomePcode = true;
- setWString(hContact, "ZIP", XmlGetText(m));
+ setUString(hContact, "ZIP", m->GetText());
}
- if ((m = XmlGetChild(n, "CTRY")) == nullptr || XmlGetText(m) == nullptr) // Some bad client use <COUNTRY/> instead of <CTRY/>
- m = XmlGetChild(n, "COUNTRY");
- if (m != nullptr && XmlGetText(m) != nullptr) {
+ if ((m = n->FirstChildElement("CTRY")) == nullptr || m->GetText() == nullptr) // Some bad client use <COUNTRY/> instead of <CTRY/>
+ m = n->FirstChildElement("COUNTRY");
+ if (m != nullptr && m->GetText() != nullptr) {
hasHomeCtry = true;
- setWString(hContact, "Country", XmlGetText(m));
+ setUString(hContact, "Country", m->GetText());
}
}
- if (!hasWork && XmlGetChild(n, "WORK") != nullptr) {
+ if (!hasWork && n->FirstChildElement("WORK") != nullptr) {
// Work address
hasWork = true;
- if ((m = XmlGetChild(n, "STREET")) != nullptr && XmlGetText(m) != nullptr) {
- wchar_t text[128];
+ if ((m = n->FirstChildElement("STREET")) != nullptr && m->GetText() != nullptr) {
+ char text[128];
hasWorkStreet = true;
if (hContact != 0) {
- if ((o = XmlGetChild(n, "EXTADR")) != nullptr && XmlGetText(o) != nullptr)
- mir_snwprintf(text, L"%s\r\n%s", XmlGetText(m), XmlGetText(o));
- else if ((o = XmlGetChild(n, "EXTADD")) != nullptr && XmlGetText(o) != nullptr)
- mir_snwprintf(text, L"%s\r\n%s", XmlGetText(m), XmlGetText(o));
+ if ((o = n->FirstChildElement("EXTADR")) != nullptr && o->GetText() != nullptr)
+ mir_snprintf(text, "%s\r\n%s", m->GetText(), o->GetText());
+ else if ((o = n->FirstChildElement("EXTADD")) != nullptr && o->GetText() != nullptr)
+ mir_snprintf(text, "%s\r\n%s", m->GetText(), o->GetText());
else
- wcsncpy_s(text, XmlGetText(m), _TRUNCATE);
+ strncpy_s(text, m->GetText(), _TRUNCATE);
text[_countof(text) - 1] = '\0';
- setWString(hContact, "CompanyStreet", text);
+ setUString(hContact, "CompanyStreet", text);
}
else {
- setWString(hContact, "CompanyStreet", XmlGetText(m));
- if ((m = XmlGetChild(n, "EXTADR")) == nullptr)
- m = XmlGetChild(n, "EXTADD");
- if (m != nullptr && XmlGetText(m) != nullptr) {
+ setUString(hContact, "CompanyStreet", m->GetText());
+ if ((m = n->FirstChildElement("EXTADR")) == nullptr)
+ m = n->FirstChildElement("EXTADD");
+ if (m != nullptr && m->GetText() != nullptr) {
hasWorkStreet2 = true;
- setWString(hContact, "CompanyStreet2", XmlGetText(m));
+ setUString(hContact, "CompanyStreet2", m->GetText());
}
}
}
- if ((m = XmlGetChild(n, "LOCALITY")) != nullptr && XmlGetText(m) != nullptr) {
+ if ((m = n->FirstChildElement("LOCALITY")) != nullptr && m->GetText() != nullptr) {
hasWorkLocality = true;
- setWString(hContact, "CompanyCity", XmlGetText(m));
+ setUString(hContact, "CompanyCity", m->GetText());
}
- if ((m = XmlGetChild(n, "REGION")) != nullptr && XmlGetText(m) != nullptr) {
+ if ((m = n->FirstChildElement("REGION")) != nullptr && m->GetText() != nullptr) {
hasWorkRegion = true;
- setWString(hContact, "CompanyState", XmlGetText(m));
+ setUString(hContact, "CompanyState", m->GetText());
}
- if ((m = XmlGetChild(n, "PCODE")) != nullptr && XmlGetText(m) != nullptr) {
+ if ((m = n->FirstChildElement("PCODE")) != nullptr && m->GetText() != nullptr) {
hasWorkPcode = true;
- setWString(hContact, "CompanyZIP", XmlGetText(m));
+ setUString(hContact, "CompanyZIP", m->GetText());
}
- if ((m = XmlGetChild(n, "CTRY")) == nullptr || XmlGetText(m) == nullptr) // Some bad client use <COUNTRY/> instead of <CTRY/>
- m = XmlGetChild(n, "COUNTRY");
- if (m != nullptr && XmlGetText(m) != nullptr) {
+ if ((m = n->FirstChildElement("CTRY")) == nullptr || m->GetText() == nullptr) // Some bad client use <COUNTRY/> instead of <CTRY/>
+ m = n->FirstChildElement("COUNTRY");
+ if (m != nullptr && m->GetText() != nullptr) {
hasWorkCtry = true;
- setWString(hContact, "CompanyCountry", XmlGetText(m));
+ setUString(hContact, "CompanyCountry", m->GetText());
}
}
}
- else if (!mir_wstrcmp(XmlGetName(n), L"TEL")) {
+ else if (!mir_strcmp(n->Name(), "TEL")) {
// Telephone/Fax/Cellular
- if ((m = XmlGetChild(n, "NUMBER")) != nullptr && XmlGetText(m) != nullptr) {
+ if ((m = n->FirstChildElement("NUMBER")) != nullptr && m->GetText() != nullptr) {
if (hContact != 0) {
- if (!hasFax && XmlGetChild(n, "FAX") != nullptr) {
+ if (!hasFax && n->FirstChildElement("FAX") != nullptr) {
hasFax = true;
- setWString(hContact, "Fax", XmlGetText(m));
+ setUString(hContact, "Fax", m->GetText());
}
- else if (!hasCell && XmlGetChild(n, "CELL") != nullptr) {
+ else if (!hasCell && n->FirstChildElement("CELL") != nullptr) {
hasCell = true;
- setWString(hContact, "Cellular", XmlGetText(m));
+ setUString(hContact, "Cellular", m->GetText());
}
else if (!hasPhone &&
- (XmlGetChild(n, "HOME") != nullptr || XmlGetChild(n, "WORK") != nullptr || XmlGetChild(n, "VOICE") != nullptr ||
- (XmlGetChild(n, "FAX") == nullptr &&
- XmlGetChild(n, "PAGER") == nullptr &&
- XmlGetChild(n, "MSG") == nullptr &&
- XmlGetChild(n, "CELL") == nullptr &&
- XmlGetChild(n, "VIDEO") == nullptr &&
- XmlGetChild(n, "BBS") == nullptr &&
- XmlGetChild(n, "MODEM") == nullptr &&
- XmlGetChild(n, "ISDN") == nullptr &&
- XmlGetChild(n, "PCS") == nullptr)))
+ (n->FirstChildElement("HOME") != nullptr || n->FirstChildElement("WORK") != nullptr || n->FirstChildElement("VOICE") != nullptr ||
+ (n->FirstChildElement("FAX") == nullptr &&
+ n->FirstChildElement("PAGER") == nullptr &&
+ n->FirstChildElement("MSG") == nullptr &&
+ n->FirstChildElement("CELL") == nullptr &&
+ n->FirstChildElement("VIDEO") == nullptr &&
+ n->FirstChildElement("BBS") == nullptr &&
+ n->FirstChildElement("MODEM") == nullptr &&
+ n->FirstChildElement("ISDN") == nullptr &&
+ n->FirstChildElement("PCS") == nullptr)))
{
hasPhone = true;
- setWString(hContact, "Phone", XmlGetText(m));
+ setUString(hContact, "Phone", m->GetText());
}
}
else {
char text[100];
mir_snprintf(text, "Phone%d", nPhone);
- setWString(text, XmlGetText(m));
+ setUString(text, m->GetText());
mir_snprintf(text, "PhoneFlag%d", nPhone);
int nFlag = 0;
- if (XmlGetChild(n, "HOME") != nullptr) nFlag |= JABBER_VCTEL_HOME;
- if (XmlGetChild(n, "WORK") != nullptr) nFlag |= JABBER_VCTEL_WORK;
- if (XmlGetChild(n, "VOICE") != nullptr) nFlag |= JABBER_VCTEL_VOICE;
- if (XmlGetChild(n, "FAX") != nullptr) nFlag |= JABBER_VCTEL_FAX;
- if (XmlGetChild(n, "PAGER") != nullptr) nFlag |= JABBER_VCTEL_PAGER;
- if (XmlGetChild(n, "MSG") != nullptr) nFlag |= JABBER_VCTEL_MSG;
- if (XmlGetChild(n, "CELL") != nullptr) nFlag |= JABBER_VCTEL_CELL;
- if (XmlGetChild(n, "VIDEO") != nullptr) nFlag |= JABBER_VCTEL_VIDEO;
- if (XmlGetChild(n, "BBS") != nullptr) nFlag |= JABBER_VCTEL_BBS;
- if (XmlGetChild(n, "MODEM") != nullptr) nFlag |= JABBER_VCTEL_MODEM;
- if (XmlGetChild(n, "ISDN") != nullptr) nFlag |= JABBER_VCTEL_ISDN;
- if (XmlGetChild(n, "PCS") != nullptr) nFlag |= JABBER_VCTEL_PCS;
+ if (n->FirstChildElement("HOME") != nullptr) nFlag |= JABBER_VCTEL_HOME;
+ if (n->FirstChildElement("WORK") != nullptr) nFlag |= JABBER_VCTEL_WORK;
+ if (n->FirstChildElement("VOICE") != nullptr) nFlag |= JABBER_VCTEL_VOICE;
+ if (n->FirstChildElement("FAX") != nullptr) nFlag |= JABBER_VCTEL_FAX;
+ if (n->FirstChildElement("PAGER") != nullptr) nFlag |= JABBER_VCTEL_PAGER;
+ if (n->FirstChildElement("MSG") != nullptr) nFlag |= JABBER_VCTEL_MSG;
+ if (n->FirstChildElement("CELL") != nullptr) nFlag |= JABBER_VCTEL_CELL;
+ if (n->FirstChildElement("VIDEO") != nullptr) nFlag |= JABBER_VCTEL_VIDEO;
+ if (n->FirstChildElement("BBS") != nullptr) nFlag |= JABBER_VCTEL_BBS;
+ if (n->FirstChildElement("MODEM") != nullptr) nFlag |= JABBER_VCTEL_MODEM;
+ if (n->FirstChildElement("ISDN") != nullptr) nFlag |= JABBER_VCTEL_ISDN;
+ if (n->FirstChildElement("PCS") != nullptr) nFlag |= JABBER_VCTEL_PCS;
setWord(text, nFlag);
nPhone++;
}
}
}
- else if (!mir_wstrcmp(XmlGetName(n), L"URL")) {
+ else if (!mir_strcmp(n->Name(), "URL")) {
// Homepage
- if (!hasUrl && XmlGetText(n) != nullptr) {
+ if (!hasUrl && n->GetText() != nullptr) {
hasUrl = true;
- setWString(hContact, "Homepage", XmlGetText(n));
+ setUString(hContact, "Homepage", n->GetText());
}
}
- else if (!mir_wstrcmp(XmlGetName(n), L"ORG")) {
+ else if (!mir_strcmp(n->Name(), "ORG")) {
if (!hasOrgname && !hasOrgunit) {
- if ((m = XmlGetChild(n, "ORGNAME")) != nullptr && XmlGetText(m) != nullptr) {
+ if ((m = n->FirstChildElement("ORGNAME")) != nullptr && m->GetText() != nullptr) {
hasOrgname = true;
- setWString(hContact, "Company", XmlGetText(m));
+ setUString(hContact, "Company", m->GetText());
}
- if ((m = XmlGetChild(n, "ORGUNIT")) != nullptr && XmlGetText(m) != nullptr) { // The real vCard can have multiple <ORGUNIT/> but we will only display the first one
+ if ((m = n->FirstChildElement("ORGUNIT")) != nullptr && m->GetText() != nullptr) { // The real vCard can have multiple <ORGUNIT/> but we will only display the first one
hasOrgunit = true;
- setWString(hContact, "CompanyDepartment", XmlGetText(m));
+ setUString(hContact, "CompanyDepartment", m->GetText());
}
}
}
- else if (!mir_wstrcmp(XmlGetName(n), L"ROLE")) {
- if (!hasRole && XmlGetText(n) != nullptr) {
+ else if (!mir_strcmp(n->Name(), "ROLE")) {
+ if (!hasRole && n->GetText() != nullptr) {
hasRole = true;
- setWString(hContact, "Role", XmlGetText(n));
+ setUString(hContact, "Role", n->GetText());
}
}
- else if (!mir_wstrcmp(XmlGetName(n), L"TITLE")) {
- if (!hasTitle && XmlGetText(n) != nullptr) {
+ else if (!mir_strcmp(n->Name(), "TITLE")) {
+ if (!hasTitle && n->GetText() != nullptr) {
hasTitle = true;
- setWString(hContact, "CompanyPosition", XmlGetText(n));
+ setUString(hContact, "CompanyPosition", n->GetText());
}
}
- else if (!mir_wstrcmp(XmlGetName(n), L"DESC")) {
- if (!hasDesc && XmlGetText(n) != nullptr) {
+ else if (!mir_strcmp(n->Name(), "DESC")) {
+ if (!hasDesc && n->GetText() != nullptr) {
hasDesc = true;
- CMStringW tszMemo(XmlGetText(n));
- tszMemo.Replace(L"\n", L"\r\n");
- setWString(hContact, "About", tszMemo);
+ CMStringA tszMemo(n->GetText());
+ tszMemo.Replace("\n", "\r\n");
+ setUString(hContact, "About", tszMemo);
}
}
- else if (!mir_wstrcmp(XmlGetName(n), L"PHOTO"))
+ else if (!mir_strcmp(n->Name(), "PHOTO"))
OnIqResultGetVcardPhoto(n, hContact, hasPhoto);
}
}
if (hasFn && !hasNick) {
- ptrW nick(getWStringA(hContact, "Nick"));
- ptrW jidNick(JabberNickFromJID(jid));
- if (!nick || (jidNick && !mir_wstrcmpi(nick, jidNick)))
+ ptrA nick(getUStringA(hContact, "Nick"));
+ ptrA jidNick(JabberNickFromJID(jid));
+ if (!nick || (jidNick && !mir_strcmpi(nick, jidNick)))
setWString(hContact, "Nick", ptrW(getWStringA(hContact, "FullName")));
}
if (!hasFn)
@@ -1143,7 +1116,7 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*)
}
if (id == m_ThreadInfo->resolveID) {
- const wchar_t *p = wcschr(jid, '@');
+ const char *p = strchr(jid, '@');
ResolveTransportNicks((p != nullptr) ? p + 1 : jid);
}
else {
@@ -1153,72 +1126,63 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*)
}
}
-void CJabberProto::OnIqResultSetVcard(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultSetVcard(const TiXmlElement *iqNode, CJabberIqInfo*)
{
debugLogA("<iq/> iqIdSetVcard");
- if (XmlGetAttrValue(iqNode, L"type"))
+ if (iqNode->Attribute("type"))
WindowList_Broadcast(m_hWindowList, WM_JABBER_REFRESH_VCARD, 0, 0);
}
-void CJabberProto::OnIqResultSetSearch(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultSetSearch(const TiXmlElement *iqNode, CJabberIqInfo*)
{
- HXML queryNode, n;
- const wchar_t *type, *jid;
+ const TiXmlElement *queryNode;
+ const char *type;
int id;
debugLogA("<iq/> iqIdGetSearch");
- if ((type = XmlGetAttrValue(iqNode, L"type")) == nullptr) return;
+ if ((type = iqNode->Attribute("type")) == nullptr) return;
if ((id = JabberGetPacketID(iqNode)) == -1) return;
- if (!mir_wstrcmp(type, L"result")) {
- if ((queryNode = XmlGetChild(iqNode, "query")) == nullptr)
+ if (!mir_strcmp(type, "result")) {
+ if ((queryNode = iqNode->FirstChildElement("query")) == nullptr)
return;
- PROTOSEARCHRESULT psr = { 0 };
+ PROTOSEARCHRESULT psr = {};
psr.cbSize = sizeof(psr);
- for (int i = 0;; i++) {
- HXML itemNode = XmlGetChild(queryNode, i);
- if (!itemNode)
- break;
-
- if (!mir_wstrcmp(XmlGetName(itemNode), L"item")) {
- if ((jid = XmlGetAttrValue(itemNode, L"jid")) != nullptr) {
- psr.id.w = (wchar_t*)jid;
- debugLogW(L"Result jid = %s", jid);
- if ((n = XmlGetChild(itemNode, "nick")) != nullptr && XmlGetText(n) != nullptr)
- psr.nick.w = (wchar_t*)XmlGetText(n);
- else
- psr.nick.w = L"";
- if ((n = XmlGetChild(itemNode, "first")) != nullptr && XmlGetText(n) != nullptr)
- psr.firstName.w = (wchar_t*)XmlGetText(n);
- else
- psr.firstName.w = L"";
- if ((n = XmlGetChild(itemNode, "last")) != nullptr && XmlGetText(n) != nullptr)
- psr.lastName.w = (wchar_t*)XmlGetText(n);
- else
- psr.lastName.w = L"";
- if ((n = XmlGetChild(itemNode, "email")) != nullptr && XmlGetText(n) != nullptr)
- psr.email.w = (wchar_t*)XmlGetText(n);
- else
- psr.email.w = L"";
- psr.flags = PSR_UNICODE;
- ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&psr);
- }
+ for (auto *itemNode : TiXmlFilter(queryNode, "item")) {
+ if (auto *jid = itemNode->Attribute("jid")) {
+ psr.id.w = mir_utf8decodeW(jid);
+ debugLogW(L"Result jid = %s", jid);
+ if (auto *p = itemNode->FirstChildElement("nick")->GetText())
+ psr.nick.w = mir_utf8decodeW(p);
+ if (auto *p = itemNode->FirstChildElement("first")->GetText())
+ psr.firstName.w = mir_utf8decodeW(p);
+ if (auto *p = itemNode->FirstChildElement("last")->GetText())
+ psr.lastName.w = mir_utf8decodeW(p);
+ if (auto *p = itemNode->FirstChildElement("email")->GetText())
+ psr.email.w = mir_utf8decodeW(p);
+ ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&psr);
+
+ replaceStrW(psr.id.w, 0);
+ replaceStrW(psr.nick.w, 0);
+ replaceStrW(psr.firstName.w, 0);
+ replaceStrW(psr.lastName.w, 0);
+ replaceStrW(psr.email.w, 0);
}
}
ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
}
- else if (!mir_wstrcmp(type, L"error"))
+ else if (!mir_strcmp(type, "error"))
ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
}
-void CJabberProto::OnIqResultExtSearch(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultExtSearch(const TiXmlElement *iqNode, CJabberIqInfo*)
{
- HXML queryNode;
+ const TiXmlElement *queryNode;
debugLogA("<iq/> iqIdGetExtSearch");
- const wchar_t *type = XmlGetAttrValue(iqNode, L"type");
+ const char *type = iqNode->Attribute("type");
if (type == nullptr)
return;
@@ -1226,82 +1190,75 @@ void CJabberProto::OnIqResultExtSearch(HXML iqNode, CJabberIqInfo*)
if (id == -1)
return;
- if (!mir_wstrcmp(type, L"result")) {
- if ((queryNode = XmlGetChild(iqNode, "query")) == nullptr) return;
- if ((queryNode = XmlGetChild(queryNode, "x")) == nullptr) return;
- for (int i = 0;; i++) {
- HXML itemNode = XmlGetChild(queryNode, i);
- if (!itemNode)
- break;
- if (mir_wstrcmp(XmlGetName(itemNode), L"item"))
- continue;
-
+ if (!mir_strcmp(type, "result")) {
+ if ((queryNode = iqNode->FirstChildElement("query")) == nullptr) return;
+ if ((queryNode = queryNode->FirstChildElement("x")) == nullptr) return;
+ for (auto *itemNode : TiXmlFilter(queryNode, "item")) {
PROTOSEARCHRESULT psr = { 0 };
psr.cbSize = sizeof(psr);
psr.flags = PSR_UNICODE;
- for (int j = 0;; j++) {
- HXML fieldNode = XmlGetChild(itemNode, j);
- if (!fieldNode)
- break;
-
- if (mir_wstrcmp(XmlGetName(fieldNode), L"field"))
- continue;
-
- const wchar_t *fieldName = XmlGetAttrValue(fieldNode, L"var");
+ for (auto *fieldNode : TiXmlFilter(itemNode, "field")) {
+ const char *fieldName = fieldNode->Attribute("var");
if (fieldName == nullptr)
continue;
- HXML n = XmlGetChild(fieldNode, "value");
+ auto *n = fieldNode->FirstChildElement("value");
if (n == nullptr)
continue;
- if (!mir_wstrcmp(fieldName, L"jid")) {
- psr.id.w = (wchar_t*)XmlGetText(n);
+ if (!mir_strcmp(fieldName, "jid")) {
+ psr.id.w = (wchar_t*)n->GetText();
debugLogW(L"Result jid = %s", psr.id.w);
}
- else if (!mir_wstrcmp(fieldName, L"nickname"))
- psr.nick.w = (XmlGetText(n) != nullptr) ? (wchar_t*)XmlGetText(n) : L"";
- else if (!mir_wstrcmp(fieldName, L"fn"))
- psr.firstName.w = (XmlGetText(n) != nullptr) ? (wchar_t*)XmlGetText(n) : L"";
- else if (!mir_wstrcmp(fieldName, L"given"))
- psr.firstName.w = (XmlGetText(n) != nullptr) ? (wchar_t*)XmlGetText(n) : L"";
- else if (!mir_wstrcmp(fieldName, L"family"))
- psr.lastName.w = (XmlGetText(n) != nullptr) ? (wchar_t*)XmlGetText(n) : L"";
- else if (!mir_wstrcmp(fieldName, L"email"))
- psr.email.w = (XmlGetText(n) != nullptr) ? (wchar_t*)XmlGetText(n) : L"";
+ else if (!mir_strcmp(fieldName, "nickname"))
+ psr.nick.w = mir_utf8decodeW(n->GetText());
+ else if (!mir_strcmp(fieldName, "fn"))
+ psr.firstName.w = mir_utf8decodeW(n->GetText());
+ else if (!mir_strcmp(fieldName, "given"))
+ psr.firstName.w = mir_utf8decodeW(n->GetText());
+ else if (!mir_strcmp(fieldName, "family"))
+ psr.lastName.w = mir_utf8decodeW(n->GetText());
+ else if (!mir_strcmp(fieldName, "email"))
+ psr.email.w = mir_utf8decodeW(n->GetText());
}
ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&psr);
+
+ replaceStrW(psr.id.w, 0);
+ replaceStrW(psr.nick.w, 0);
+ replaceStrW(psr.firstName.w, 0);
+ replaceStrW(psr.lastName.w, 0);
+ replaceStrW(psr.email.w, 0);
}
ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
}
- else if (!mir_wstrcmp(type, L"error"))
+ else if (!mir_strcmp(type, "error"))
ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
}
-void CJabberProto::OnIqResultSetPassword(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultSetPassword(const TiXmlElement *iqNode, CJabberIqInfo*)
{
debugLogA("<iq/> iqIdSetPassword");
- const wchar_t *type = XmlGetAttrValue(iqNode, L"type");
+ const char *type = iqNode->Attribute("type");
if (type == nullptr)
return;
- if (!mir_wstrcmp(type, L"result")) {
- wcsncpy_s(m_ThreadInfo->conn.password, m_ThreadInfo->tszNewPassword, _TRUNCATE);
+ if (!mir_strcmp(type, "result")) {
+ strncpy_s(m_ThreadInfo->conn.password, m_ThreadInfo->tszNewPassword, _TRUNCATE);
MessageBox(nullptr, TranslateT("Password is successfully changed. Don't forget to update your password in the Jabber protocol option."), TranslateT("Change Password"), MB_OK | MB_ICONINFORMATION | MB_SETFOREGROUND);
}
- else if (!mir_wstrcmp(type, L"error"))
+ else if (!mir_strcmp(type, "error"))
MessageBox(nullptr, TranslateT("Password cannot be changed."), TranslateT("Change Password"), MB_OK | MB_ICONSTOP | MB_SETFOREGROUND);
}
-void CJabberProto::OnIqResultGetVCardAvatar(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultGetVCardAvatar(const TiXmlElement *iqNode, CJabberIqInfo*)
{
debugLogA("<iq/> OnIqResultGetVCardAvatar");
- const wchar_t *from = XmlGetAttrValue(iqNode, L"from");
+ const char *from = iqNode->Attribute("from");
if (from == nullptr)
return;
@@ -1309,16 +1266,16 @@ void CJabberProto::OnIqResultGetVCardAvatar(HXML iqNode, CJabberIqInfo*)
if (hContact == 0)
return;
- const wchar_t *type;
- if ((type = XmlGetAttrValue(iqNode, L"type")) == nullptr) return;
- if (mir_wstrcmp(type, L"result")) return;
+ const char *type;
+ if ((type = iqNode->Attribute("type")) == nullptr) return;
+ if (mir_strcmp(type, "result")) return;
- HXML vCard = XmlGetChild(iqNode, "vCard");
+ auto *vCard = iqNode->FirstChildElement("vCard");
if (vCard == nullptr) return;
- vCard = XmlGetChild(vCard, "PHOTO");
+ vCard = vCard->FirstChildElement("PHOTO");
if (vCard == nullptr) return;
- if (XmlGetChildCount(vCard) == 0) {
+ if (vCard->NoChildren()) {
delSetting(hContact, "AvatarHash");
if (ptrW(getWStringA(hContact, "AvatarSaved")) != nullptr) {
delSetting(hContact, "AvatarSaved");
@@ -1327,8 +1284,8 @@ void CJabberProto::OnIqResultGetVCardAvatar(HXML iqNode, CJabberIqInfo*)
return;
}
- const wchar_t *mimeType = XmlGetText(XmlGetChild(vCard, "TYPE"));
- HXML n = XmlGetChild(vCard, "BINVAL");
+ const char *mimeType = vCard->FirstChildElement("TYPE")->GetText();
+ auto *n = vCard->FirstChildElement("BINVAL");
if (n == nullptr)
return;
@@ -1336,37 +1293,37 @@ void CJabberProto::OnIqResultGetVCardAvatar(HXML iqNode, CJabberIqInfo*)
OnIqResultGotAvatar(hContact, n, mimeType);
}
-void CJabberProto::OnIqResultGetClientAvatar(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultGetClientAvatar(const TiXmlElement *iqNode, CJabberIqInfo*)
{
- const wchar_t *type;
+ const char *type;
debugLogA("<iq/> iqIdResultGetClientAvatar");
- const wchar_t *from = XmlGetAttrValue(iqNode, L"from");
+ const char *from = iqNode->Attribute("from");
if (from == nullptr)
return;
MCONTACT hContact = HContactFromJID(from);
if (hContact == 0)
return;
- HXML n = nullptr;
- if ((type = XmlGetAttrValue(iqNode, L"type")) != nullptr && !mir_wstrcmp(type, L"result")) {
- HXML queryNode = XmlGetChild(iqNode, "query");
+ const TiXmlElement *n = nullptr;
+ if ((type = iqNode->Attribute("type")) != nullptr && !mir_strcmp(type, "result")) {
+ auto *queryNode = iqNode->FirstChildElement("query");
if (queryNode != nullptr) {
- const wchar_t *xmlns = XmlGetAttrValue(queryNode, L"xmlns");
- if (!mir_wstrcmp(xmlns, JABBER_FEAT_AVATAR))
- n = XmlGetChild(queryNode, "data");
+ const char *xmlns = queryNode->Attribute("xmlns");
+ if (!mir_strcmp(xmlns, JABBER_FEAT_AVATAR))
+ n = queryNode->FirstChildElement("data");
}
}
if (n != nullptr) {
- OnIqResultGotAvatar(hContact, n, XmlGetAttrValue(n, L"mimetype"));
+ OnIqResultGotAvatar(hContact, n, n->Attribute("mimetype"));
return;
}
- wchar_t szJid[JABBER_MAX_JID_LEN];
- mir_wstrncpy(szJid, from, _countof(szJid));
- wchar_t *res = wcschr(szJid, '/');
+ char szJid[JABBER_MAX_JID_LEN];
+ mir_strncpy(szJid, from, _countof(szJid));
+ char *res = strchr(szJid, '/');
if (res != nullptr)
*res = 0;
@@ -1376,11 +1333,11 @@ void CJabberProto::OnIqResultGetClientAvatar(HXML iqNode, CJabberIqInfo*)
m_ThreadInfo->send(iq);
}
-void CJabberProto::OnIqResultGetServerAvatar(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultGetServerAvatar(const TiXmlElement *iqNode, CJabberIqInfo*)
{
debugLogA("<iq/> iqIdResultGetServerAvatar");
- const wchar_t *from = XmlGetAttrValue(iqNode, L"from");
+ const char *from = iqNode->Attribute("from");
if (from == nullptr)
return;
@@ -1388,38 +1345,38 @@ void CJabberProto::OnIqResultGetServerAvatar(HXML iqNode, CJabberIqInfo*)
if (hContact == 0)
return;
- HXML n = nullptr;
- const wchar_t *type = XmlGetAttrValue(iqNode, L"type");
- if (!mir_wstrcmp(type, L"result")) {
- HXML queryNode = XmlGetChild(iqNode, "query");
+ const TiXmlElement *n = nullptr;
+ const char *type = iqNode->Attribute("type");
+ if (!mir_strcmp(type, "result")) {
+ auto *queryNode = iqNode->FirstChildElement("query");
if (queryNode != nullptr) {
- const wchar_t *xmlns = XmlGetAttrValue(queryNode, L"xmlns");
- if (!mir_wstrcmp(xmlns, JABBER_FEAT_SERVER_AVATAR))
- n = XmlGetChild(queryNode, "data");
+ const char *xmlns = queryNode->Attribute("xmlns");
+ if (!mir_strcmp(xmlns, JABBER_FEAT_SERVER_AVATAR))
+ n = queryNode->FirstChildElement("data");
}
}
if (n != nullptr) {
- OnIqResultGotAvatar(hContact, n, XmlGetAttrValue(n, L"mimetype"));
+ OnIqResultGotAvatar(hContact, n, n->Attribute("mimetype"));
return;
}
- wchar_t szJid[JABBER_MAX_JID_LEN];
- mir_wstrncpy(szJid, from, _countof(szJid));
- wchar_t *res = wcschr(szJid, '/');
+ char szJid[JABBER_MAX_JID_LEN];
+ mir_strncpy(szJid, from, _countof(szJid));
+ char *res = strchr(szJid, '/');
if (res != nullptr)
*res = 0;
// Try VCard photo
m_ThreadInfo->send(
- XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetVCardAvatar, JABBER_IQ_TYPE_GET, szJid)) << XCHILDNS(L"vCard", JABBER_FEAT_VCARD_TEMP));
+ XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetVCardAvatar, JABBER_IQ_TYPE_GET, szJid)) << XCHILDNS("vCard", JABBER_FEAT_VCARD_TEMP));
}
-void CJabberProto::OnIqResultGotAvatar(MCONTACT hContact, HXML n, const wchar_t *mimeType)
+void CJabberProto::OnIqResultGotAvatar(MCONTACT hContact, const TiXmlElement *n, const char *mimeType)
{
size_t resultLen;
- ptrA body((char*)mir_base64_decode(_T2A(XmlGetText(n)), &resultLen));
+ ptrA body((char*)mir_base64_decode(n->GetText(), &resultLen));
if (body == nullptr)
return;
@@ -1440,7 +1397,7 @@ void CJabberProto::OnIqResultGotAvatar(MCONTACT hContact, HXML n, const wchar_t
wchar_t tszFileName[MAX_PATH];
if (getByte(hContact, "AvatarType", PA_FORMAT_UNKNOWN) != (unsigned char)pictureType) {
GetAvatarFileName(hContact, tszFileName, _countof(tszFileName));
- DeleteFile(tszFileName);
+ DeleteFileW(tszFileName);
}
setByte(hContact, "AvatarType", pictureType);
@@ -1470,45 +1427,44 @@ void CJabberProto::OnIqResultGotAvatar(MCONTACT hContact, HXML n, const wchar_t
/////////////////////////////////////////////////////////////////////////////////////////
// Bookmarks
-void CJabberProto::OnIqResultDiscoBookmarks(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultDiscoBookmarks(const TiXmlElement *iqNode, CJabberIqInfo*)
{
// RECVED: list of bookmarks
// ACTION: refresh bookmarks dialog
debugLogA("<iq/> iqIdGetBookmarks");
- const wchar_t *type = XmlGetAttrValue(iqNode, L"type");
+ const char *type = iqNode->Attribute("type");
if (type == nullptr)
return;
- const wchar_t *jid;
- if (!mir_wstrcmp(type, L"result")) {
+ const char *jid;
+ if (!mir_strcmp(type, "result")) {
if (m_ThreadInfo && !(m_ThreadInfo->jabberServerCaps & JABBER_CAPS_PRIVATE_STORAGE)) {
m_ThreadInfo->jabberServerCaps |= JABBER_CAPS_PRIVATE_STORAGE;
EnableMenuItems(true);
}
- if (HXML storageNode = XPathT(iqNode, "query/storage[@xmlns='storage:bookmarks']")) {
+ if (auto *storageNode = XmlGetChildByTag(iqNode->FirstChildElement("query"), "storage", "xmlns", "storage:bookmarks")) {
ListRemoveList(LIST_BOOKMARK);
- HXML itemNode;
- for (int i = 0; itemNode = XmlGetChild(storageNode, i); i++) {
- if (const wchar_t *name = XmlGetName(itemNode)) {
- if (!mir_wstrcmp(name, L"conference") && (jid = XmlGetAttrValue(itemNode, L"jid"))) {
+ for (auto *itemNode : TiXmlEnum(storageNode)) {
+ if (const char *name = itemNode->Name()) {
+ if (!mir_strcmp(name, "conference") && (jid = itemNode->Attribute("jid"))) {
JABBER_LIST_ITEM *item = ListAdd(LIST_BOOKMARK, jid);
- item->name = mir_wstrdup(XmlGetAttrValue(itemNode, L"name"));
- item->type = mir_wstrdup(L"conference");
+ item->name = mir_utf8decodeW(itemNode->Attribute("name"));
+ item->type = mir_strdup("conference");
item->bUseResource = true;
- item->nick = mir_wstrdup(XPathT(itemNode, "nick"));
- item->password = mir_wstrdup(XPathT(itemNode, "password"));
+ item->nick = mir_strdup(XPath(itemNode, "nick"));
+ item->password = mir_strdup(XPath(itemNode, "password"));
- const wchar_t *autoJ = XmlGetAttrValue(itemNode, L"autojoin");
+ const char *autoJ = itemNode->Attribute("autojoin");
if (autoJ != nullptr)
- item->bAutoJoin = !mir_wstrcmp(autoJ, L"true") || !mir_wstrcmp(autoJ, L"1");
+ item->bAutoJoin = !mir_strcmp(autoJ, "true") || !mir_strcmp(autoJ, "1");
}
- else if (!mir_wstrcmp(name, L"url") && (jid = XmlGetAttrValue(itemNode, L"url"))) {
+ else if (!mir_strcmp(name, "url") && (jid = itemNode->Attribute("url"))) {
JABBER_LIST_ITEM *item = ListAdd(LIST_BOOKMARK, jid);
item->bUseResource = true;
- item->name = mir_wstrdup(XmlGetAttrValue(itemNode, L"name"));
- item->type = mir_wstrdup(L"url");
+ item->name = mir_utf8decodeW(itemNode->Attribute("name"));
+ item->type = mir_strdup("url");
}
}
}
@@ -1518,7 +1474,7 @@ void CJabberProto::OnIqResultDiscoBookmarks(HXML iqNode, CJabberIqInfo*)
OnProcessLoginRq(m_ThreadInfo, JABBER_LOGIN_BOOKMARKS);
}
}
- else if (!mir_wstrcmp(type, L"error")) {
+ else if (!mir_strcmp(type, "error")) {
if (m_ThreadInfo->jabberServerCaps & JABBER_CAPS_PRIVATE_STORAGE) {
m_ThreadInfo->jabberServerCaps &= ~JABBER_CAPS_PRIVATE_STORAGE;
EnableMenuItems(true);
@@ -1529,8 +1485,8 @@ void CJabberProto::OnIqResultDiscoBookmarks(HXML iqNode, CJabberIqInfo*)
void CJabberProto::SetBookmarkRequest(XmlNodeIq &iq)
{
- HXML query = iq << XQUERY(JABBER_FEAT_PRIVATE_STORAGE);
- HXML storage = query << XCHILDNS(L"storage", L"storage:bookmarks");
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_PRIVATE_STORAGE);
+ TiXmlElement *storage = query << XCHILDNS("storage", "storage:bookmarks");
LISTFOREACH(i, this, LIST_BOOKMARK)
{
@@ -1538,42 +1494,42 @@ void CJabberProto::SetBookmarkRequest(XmlNodeIq &iq)
if (item == nullptr || item->jid == nullptr)
continue;
- if (!mir_wstrcmp(item->type, L"conference")) {
- HXML itemNode = storage << XCHILD(L"conference") << XATTR(L"jid", item->jid);
+ if (!mir_strcmp(item->type, "conference")) {
+ TiXmlElement *itemNode = storage << XCHILD("conference") << XATTR("jid", item->jid);
if (item->name)
- itemNode << XATTR(L"name", item->name);
+ itemNode << XATTR("name", T2Utf(item->name));
if (item->bAutoJoin)
- itemNode << XATTRI(L"autojoin", 1);
+ itemNode << XATTRI("autojoin", 1);
if (item->nick)
- itemNode << XCHILD(L"nick", item->nick);
+ itemNode << XCHILD("nick", item->nick);
if (item->password)
- itemNode << XCHILD(L"password", item->password);
+ itemNode << XCHILD("password", item->password);
}
- if (!mir_wstrcmp(item->type, L"url")) {
- HXML itemNode = storage << XCHILD(L"url") << XATTR(L"url", item->jid);
+ if (!mir_strcmp(item->type, "url")) {
+ TiXmlElement *itemNode = storage << XCHILD("url") << XATTR("url", item->jid);
if (item->name)
- itemNode << XATTR(L"name", item->name);
+ itemNode << XATTR("name", T2Utf(item->name));
}
}
}
-void CJabberProto::OnIqResultSetBookmarks(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultSetBookmarks(const TiXmlElement *iqNode, CJabberIqInfo*)
{
// RECVED: server's response
// ACTION: refresh bookmarks list dialog
debugLogA("<iq/> iqIdSetBookmarks");
- const wchar_t *type = XmlGetAttrValue(iqNode, L"type");
+ const char *type = iqNode->Attribute("type");
if (type == nullptr)
return;
- if (!mir_wstrcmp(type, L"result")) {
+ if (!mir_strcmp(type, "result")) {
UI_SAFE_NOTIFY(m_pDlgBookmarks, WM_JABBER_REFRESH);
}
- else if (!mir_wstrcmp(type, L"error")) {
- HXML errorNode = XmlGetChild(iqNode, "error");
+ else if (!mir_strcmp(type, "error")) {
+ auto *errorNode = iqNode->FirstChildElement("error");
wchar_t *str = JabberErrorMsg(errorNode);
MessageBox(nullptr, str, TranslateT("Jabber Bookmarks Error"), MB_OK | MB_SETFOREGROUND);
mir_free(str);
@@ -1582,7 +1538,7 @@ void CJabberProto::OnIqResultSetBookmarks(HXML iqNode, CJabberIqInfo*)
}
// last activity (XEP-0012) support
-void CJabberProto::OnIqResultLastActivity(HXML iqNode, CJabberIqInfo *pInfo)
+void CJabberProto::OnIqResultLastActivity(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
pResourceStatus r(ResourceInfoFromJID(pInfo->m_szFrom));
if (r == nullptr)
@@ -1590,16 +1546,16 @@ void CJabberProto::OnIqResultLastActivity(HXML iqNode, CJabberIqInfo *pInfo)
time_t lastActivity = -1;
if (pInfo->m_nIqType == JABBER_IQ_TYPE_RESULT) {
- const wchar_t *szSeconds = XPathT(iqNode, "query[@xmlns='jabber:iq:last']/@seconds");
+ const char *szSeconds = XPath(iqNode, "query[@xmlns='jabber:iq:last']/@seconds");
if (szSeconds) {
- int nSeconds = _wtoi(szSeconds);
+ int nSeconds = atoi(szSeconds);
if (nSeconds > 0)
lastActivity = time(0) - nSeconds;
}
- const wchar_t *szLastStatusMessage = XPathT(iqNode, "query[@xmlns='jabber:iq:last']");
+ const char *szLastStatusMessage = XPath(iqNode, "query[@xmlns='jabber:iq:last']");
if (szLastStatusMessage) // replace only if it exists
- r->m_tszStatusMessage = mir_wstrdup(szLastStatusMessage);
+ r->m_szStatusMessage = mir_strdup(szLastStatusMessage);
}
r->m_dwIdleStartTime = lastActivity;
@@ -1608,17 +1564,17 @@ void CJabberProto::OnIqResultLastActivity(HXML iqNode, CJabberIqInfo *pInfo)
}
// entity time (XEP-0202) support
-void CJabberProto::OnIqResultEntityTime(HXML pIqNode, CJabberIqInfo *pInfo)
+void CJabberProto::OnIqResultEntityTime(const TiXmlElement *pIqNode, CJabberIqInfo *pInfo)
{
if (!pInfo->m_hContact)
return;
if (pInfo->m_nIqType == JABBER_IQ_TYPE_RESULT) {
- const wchar_t *szTzo = XPathFmt(pIqNode, L"time[@xmlns='%s']/tzo", JABBER_FEAT_ENTITY_TIME);
+ const char *szTzo = XPathFmt(pIqNode, "time[@xmlns='%s']/tzo", JABBER_FEAT_ENTITY_TIME);
if (szTzo && szTzo[0]) {
- const wchar_t *szMin = wcschr(szTzo, ':');
- int nTz = _wtoi(szTzo) * -2;
- nTz += (nTz < 0 ? -1 : 1) * (szMin ? _wtoi(szMin + 1) / 30 : 0);
+ const char *szMin = strchr(szTzo, ':');
+ int nTz = atoi(szTzo) * -2;
+ nTz += (nTz < 0 ? -1 : 1) * (szMin ? atoi(szMin + 1) / 30 : 0);
TIME_ZONE_INFORMATION tzinfo;
if (GetTimeZoneInformation(&tzinfo) == TIME_ZONE_ID_DAYLIGHT)
@@ -1626,9 +1582,9 @@ void CJabberProto::OnIqResultEntityTime(HXML pIqNode, CJabberIqInfo *pInfo)
setByte(pInfo->m_hContact, "Timezone", (signed char)nTz);
- const wchar_t *szTz = XPathFmt(pIqNode, L"time[@xmlns='%s']/tz", JABBER_FEAT_ENTITY_TIME);
+ const char *szTz = XPathFmt(pIqNode, "time[@xmlns='%s']/tz", JABBER_FEAT_ENTITY_TIME);
if (szTz)
- setWString(pInfo->m_hContact, "TzName", szTz);
+ setUString(pInfo->m_hContact, "TzName", szTz);
else
delSetting(pInfo->m_hContact, "TzName");
return;
diff --git a/protocols/JabberG/src/jabber_iqid_muc.cpp b/protocols/JabberG/src/jabber_iqid_muc.cpp
index 2d1e62c747..5a4bcade2e 100644
--- a/protocols/JabberG/src/jabber_iqid_muc.cpp
+++ b/protocols/JabberG/src/jabber_iqid_muc.cpp
@@ -27,43 +27,30 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "jabber_iq.h"
#include "jabber_caps.h"
-void CJabberProto::SetMucConfig(HXML node, void *from)
+void CJabberProto::SetMucConfig(TiXmlElement *node, void *from)
{
if (m_ThreadInfo && from) {
- XmlNodeIq iq(L"set", SerialNext(), (wchar_t*)from);
- HXML query = iq << XQUERY(JABBER_FEAT_MUC_OWNER);
- XmlAddChild(query, node);
+ XmlNodeIq iq("set", SerialNext(), (char*)from);
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_MUC_OWNER);
+ query->InsertEndChild(node);
m_ThreadInfo->send(iq);
}
}
// RECVED: room config form
// ACTION: show the form
-void CJabberProto::OnIqResultGetMuc(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultGetMuc(const TiXmlElement *iqNode, CJabberIqInfo*)
{
debugLogA("<iq/> iqIdGetMuc");
- const wchar_t *type = XmlGetAttrValue(iqNode, L"type");
- if (type == nullptr)
- return;
- const wchar_t *from = XmlGetAttrValue(iqNode, L"from");
- if (from == nullptr)
+ const char *type = iqNode->Attribute("type");
+ const char *from = iqNode->Attribute("from");
+ if (type == nullptr || from == nullptr)
return;
- if (!mir_wstrcmp(type, L"result")) {
- HXML queryNode = XmlGetChild(iqNode, L"query");
- if (queryNode != nullptr) {
- const wchar_t *str = XmlGetAttrValue(queryNode, L"xmlns");
- if (!mir_wstrcmp(str, JABBER_FEAT_MUC_OWNER)) {
- HXML xNode = XmlGetChild(queryNode, L"x");
- if (xNode != nullptr) {
- str = XmlGetAttrValue(xNode, L"xmlns");
- if (!mir_wstrcmp(str, JABBER_FEAT_DATA_FORMS))
- //LaunchForm(xNode);
- FormCreateDialog(xNode, L"Jabber Conference Room Configuration", &CJabberProto::SetMucConfig, mir_wstrdup(from));
- }
- }
- }
- }
+ if (!mir_strcmp(type, "result"))
+ if (auto *queryNode = XmlGetChildByTag(iqNode, "query", "xmlns", JABBER_FEAT_MUC_OWNER))
+ if (auto *xNode = XmlGetChildByTag(queryNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS))
+ FormCreateDialog(xNode, "Jabber Conference Room Configuration", &CJabberProto::SetMucConfig, mir_strdup(from));
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -121,34 +108,30 @@ class CJabberMucJidListDlg : public CJabberDlgBase
// Populate displayed list from iqNode
LVITEM lvi = {};
wchar_t tszItemText[JABBER_MAX_JID_LEN + 256];
- HXML iqNode = m_info->iqNode;
+ TiXmlElement *iqNode = m_info->iqNode;
if (iqNode != nullptr) {
- const wchar_t *from = XmlGetAttrValue(iqNode, L"from");
+ const char *from = iqNode->Attribute("from");
if (from != nullptr) {
- HXML queryNode = XmlGetChild(iqNode, L"query");
+ TiXmlElement *queryNode = iqNode->FirstChildElement("query");
if (queryNode != nullptr) {
lvi.iItem = 0;
- for (int i = 0;; i++) {
- HXML itemNode = XmlGetChild(queryNode, i);
- if (!itemNode)
- break;
-
- const wchar_t *jid = XmlGetAttrValue(itemNode, L"jid");
+ for (auto *itemNode : TiXmlEnum(queryNode)) {
+ const char *jid = itemNode->Attribute("jid");
if (jid == nullptr)
continue;
lvi.pszText = (wchar_t*)jid;
if (m_info->type == MUC_BANLIST) {
- const wchar_t *reason = XmlGetText(XmlGetChild(itemNode, L"reason"));
+ const char *reason = itemNode->FirstChildElement("reason")->GetText();
if (reason != nullptr) {
- mir_snwprintf(tszItemText, L"%s (%s)", jid, reason);
+ mir_snwprintf(tszItemText, L"%s (%s)", Utf2T(jid).get(), Utf2T(reason).get());
lvi.pszText = tszItemText;
}
}
else if (m_info->type == MUC_VOICELIST || m_info->type == MUC_MODERATORLIST) {
- const wchar_t *nick = XmlGetAttrValue(itemNode, L"nick");
+ const char *nick = itemNode->Attribute("nick");
if (nick != nullptr) {
- mir_snwprintf(tszItemText, L"%s (%s)", nick, jid);
+ mir_snwprintf(tszItemText, L"%s (%s)", Utf2T(nick).get(), Utf2T(jid).get());
lvi.pszText = tszItemText;
}
}
@@ -158,7 +141,7 @@ class CJabberMucJidListDlg : public CJabberDlgBase
lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
lvi.iSubItem = 0;
- lvi.lParam = (LPARAM)mir_wstrdup(jid);
+ lvi.lParam = (LPARAM)mir_strdup(jid);
m_list.InsertItem(&lvi);
lvi.iItem++;
}
@@ -275,14 +258,14 @@ public:
wchar_t title[256];
mir_wstrncpy(title, TranslateT("JID List"), _countof(title));
if (pInfo != nullptr) {
- HXML iqNode = pInfo->iqNode;
+ TiXmlElement *iqNode = pInfo->iqNode;
if (iqNode != nullptr) {
- const wchar_t *from = XmlGetAttrValue(iqNode, L"from");
+ const char *from = iqNode->Attribute("from");
if (from != nullptr) {
- pInfo->roomJid = mir_wstrdup(from);
- HXML queryNode = XmlGetChild(iqNode, L"query");
+ pInfo->roomJid = mir_strdup(from);
+ TiXmlElement *queryNode = iqNode->FirstChildElement("query");
if (queryNode != nullptr)
- mir_snwprintf(title, TranslateT("%s, %d items (%s)"), pInfo->type2str(), XmlGetChildCount(queryNode), from);
+ mir_snwprintf(title, TranslateT("%s, %d items (%s)"), pInfo->type2str(), XmlGetChildCount(queryNode), Utf2T(from).get());
}
}
}
@@ -326,17 +309,17 @@ public:
if (m_info->type == MUC_BANLIST) {
m_proto->EnterString(rsn, TranslateT("Reason to ban"), ESF_COMBO, "gcAddReason_");
if (szBuffer)
- m_proto->AddMucListItem(m_info, szBuffer, rsn);
+ m_proto->AddMucListItem(m_info, T2Utf(szBuffer), T2Utf(rsn));
else
- m_proto->AddMucListItem(m_info, szBuffer);
+ m_proto->AddMucListItem(m_info, T2Utf(szBuffer));
}
- else m_proto->AddMucListItem(m_info, szBuffer);
+ else m_proto->AddMucListItem(m_info, T2Utf(szBuffer));
}
else { // delete
wchar_t msgText[128];
mir_snwprintf(msgText, TranslateT("Removing %s?"), text);
if (MessageBox(m_hwnd, msgText, m_info->type2str(), MB_YESNO | MB_SETFOREGROUND) == IDYES) {
- m_proto->DeleteMucListItem(m_info, (wchar_t*)lvi.lParam);
+ m_proto->DeleteMucListItem(m_info, (char*)lvi.lParam);
mir_free((void *)lvi.lParam);
m_list.DeleteItem(hti.iItem);
}
@@ -362,15 +345,15 @@ static void CALLBACK JabberMucJidListCreateDialogApcProc(void* param)
if (jidListInfo == nullptr)
return;
- HXML iqNode = jidListInfo->iqNode;
+ TiXmlElement *iqNode = jidListInfo->iqNode;
if (iqNode == nullptr)
return;
- const wchar_t *from = XmlGetAttrValue(iqNode, L"from");
+ const char *from = iqNode->Attribute("from");
if (from == nullptr)
return;
- HXML queryNode = XmlGetChild(iqNode, L"query");
+ TiXmlElement *queryNode = iqNode->FirstChildElement("query");
if (queryNode == nullptr)
return;
@@ -387,19 +370,19 @@ static void CALLBACK JabberMucJidListCreateDialogApcProc(void* param)
}
}
-void CJabberProto::OnIqResultMucGetJidList(HXML iqNode, JABBER_MUC_JIDLIST_TYPE listType)
+void CJabberProto::OnIqResultMucGetJidList(const TiXmlElement *iqNode, JABBER_MUC_JIDLIST_TYPE listType)
{
- const wchar_t *type = XmlGetAttrValue(iqNode, L"type");
+ const char *type = iqNode->Attribute("type");
if (type == nullptr)
return;
- if (!mir_wstrcmp(type, L"result")) {
+ if (!mir_strcmp(type, "result")) {
JABBER_MUC_JIDLIST_INFO *jidListInfo = new JABBER_MUC_JIDLIST_INFO;
if (jidListInfo != nullptr) {
jidListInfo->type = listType;
jidListInfo->ppro = this;
jidListInfo->roomJid = nullptr; // Set in the dialog procedure
- if ((jidListInfo->iqNode = xmlCopyNode(iqNode)) != nullptr)
+ if ((jidListInfo->iqNode = iqNode->DeepClone(&jidListInfo->doc)->ToElement()) != nullptr)
CallFunctionAsync(JabberMucJidListCreateDialogApcProc, jidListInfo);
else
mir_free(jidListInfo);
@@ -441,37 +424,37 @@ CJabberMucJidListDlg*& CJabberProto::GetMucDlg(JABBER_MUC_JIDLIST_TYPE type)
/////////////////////////////////////////////////////////////////////////////////////////
-void CJabberProto::OnIqResultMucGetVoiceList(HXML iqNode, CJabberIqInfo *)
+void CJabberProto::OnIqResultMucGetVoiceList(const TiXmlElement *iqNode, CJabberIqInfo *)
{
debugLogA("<iq/> iqResultMucGetVoiceList");
OnIqResultMucGetJidList(iqNode, MUC_VOICELIST);
}
-void CJabberProto::OnIqResultMucGetMemberList(HXML iqNode, CJabberIqInfo *)
+void CJabberProto::OnIqResultMucGetMemberList(const TiXmlElement *iqNode, CJabberIqInfo *)
{
debugLogA("<iq/> iqResultMucGetMemberList");
OnIqResultMucGetJidList(iqNode, MUC_MEMBERLIST);
}
-void CJabberProto::OnIqResultMucGetModeratorList(HXML iqNode, CJabberIqInfo *)
+void CJabberProto::OnIqResultMucGetModeratorList(const TiXmlElement *iqNode, CJabberIqInfo *)
{
debugLogA("<iq/> iqResultMucGetModeratorList");
OnIqResultMucGetJidList(iqNode, MUC_MODERATORLIST);
}
-void CJabberProto::OnIqResultMucGetBanList(HXML iqNode, CJabberIqInfo *)
+void CJabberProto::OnIqResultMucGetBanList(const TiXmlElement *iqNode, CJabberIqInfo *)
{
debugLogA("<iq/> iqResultMucGetBanList");
OnIqResultMucGetJidList(iqNode, MUC_BANLIST);
}
-void CJabberProto::OnIqResultMucGetAdminList(HXML iqNode, CJabberIqInfo *)
+void CJabberProto::OnIqResultMucGetAdminList(const TiXmlElement *iqNode, CJabberIqInfo *)
{
debugLogA("<iq/> iqResultMucGetAdminList");
OnIqResultMucGetJidList(iqNode, MUC_ADMINLIST);
}
-void CJabberProto::OnIqResultMucGetOwnerList(HXML iqNode, CJabberIqInfo *)
+void CJabberProto::OnIqResultMucGetOwnerList(const TiXmlElement *iqNode, CJabberIqInfo *)
{
debugLogA("<iq/> iqResultMucGetOwnerList");
OnIqResultMucGetJidList(iqNode, MUC_OWNERLIST);
@@ -481,7 +464,6 @@ void CJabberProto::OnIqResultMucGetOwnerList(HXML iqNode, CJabberIqInfo *)
JABBER_MUC_JIDLIST_INFO::~JABBER_MUC_JIDLIST_INFO()
{
- xmlDestroyNode(iqNode);
mir_free(roomJid);
}
diff --git a/protocols/JabberG/src/jabber_list.cpp b/protocols/JabberG/src/jabber_list.cpp
index dd9b6eb984..214250e1cc 100644
--- a/protocols/JabberG/src/jabber_list.cpp
+++ b/protocols/JabberG/src/jabber_list.cpp
@@ -44,7 +44,7 @@ JABBER_LIST_ITEM::~JABBER_LIST_ITEM()
if (photoFileName) {
if (list == LIST_VCARD_TEMP)
- DeleteFile(photoFileName);
+ DeleteFile(Utf2T(photoFileName));
mir_free(photoFileName);
}
@@ -91,12 +91,12 @@ void CJabberProto::ListInit(void)
{
for (auto &hContact : AccContacts()) {
if (isChatRoom(hContact)) {
- ptrW jid(getWStringA(hContact, "ChatRoomID"));
+ ptrA jid(getUStringA(hContact, "ChatRoomID"));
if (jid != nullptr)
ListAdd(LIST_CHATROOM, jid, hContact);
}
else {
- ptrW jid(getWStringA(hContact, "jid"));
+ ptrA jid(getUStringA(hContact, "jid"));
if (jid != nullptr)
ListAdd(LIST_ROSTER, jid, hContact);
}
@@ -115,7 +115,7 @@ void CJabberProto::ListWipe(void)
/////////////////////////////////////////////////////////////////////////////////////////
// Adding & removing items
-JABBER_LIST_ITEM* CJabberProto::ListAdd(JABBER_LIST list, const wchar_t *jid, MCONTACT hContact)
+JABBER_LIST_ITEM* CJabberProto::ListAdd(JABBER_LIST list, const char *jid, MCONTACT hContact)
{
bool bUseResource = false;
mir_cslockfull lck(m_csLists);
@@ -127,15 +127,15 @@ JABBER_LIST_ITEM* CJabberProto::ListAdd(JABBER_LIST list, const wchar_t *jid, MC
return item;
}
- wchar_t *s = mir_wstrdup(jid);
- wchar_t *q = nullptr;
+ char *s = mir_strdup(jid);
+ char *q = nullptr;
// strip resource name if any
if (!((list == LIST_ROSTER) && ListGetItemPtr(LIST_CHATROOM, jid))) { // but only if it is not chat room contact
if (list != LIST_VCARD_TEMP) {
- wchar_t *p;
- if ((p = wcschr(s, '@')) != nullptr)
- if ((q = wcschr(p, '/')) != nullptr)
+ char *p;
+ if ((p = strchr(s, '@')) != nullptr)
+ if ((q = strchr(p, '/')) != nullptr)
*q = '\0';
}
}
@@ -163,7 +163,7 @@ JABBER_LIST_ITEM* CJabberProto::ListAdd(JABBER_LIST list, const wchar_t *jid, MC
return item;
}
-void CJabberProto::ListRemove(JABBER_LIST list, const wchar_t *jid)
+void CJabberProto::ListRemove(JABBER_LIST list, const char *jid)
{
mir_cslock lck(m_csLists);
JABBER_LIST_ITEM *LI = ListGetItemPtr(list, jid);
@@ -192,14 +192,14 @@ void CJabberProto::ListRemoveByIndex(int index)
/////////////////////////////////////////////////////////////////////////////////////////
// Getting & finding items
-JABBER_LIST_ITEM* CJabberProto::ListGetItemPtr(JABBER_LIST list, const wchar_t *jid)
+JABBER_LIST_ITEM* CJabberProto::ListGetItemPtr(JABBER_LIST list, const char *jid)
{
if (jid == nullptr)
return nullptr;
JABBER_LIST_ITEM *tmp = (JABBER_LIST_ITEM*)_alloca(sizeof(JABBER_LIST_ITEM));
tmp->list = list;
- tmp->jid = (wchar_t*)jid;
+ tmp->jid = (char*)jid;
tmp->bUseResource = false;
mir_cslock lck(m_csLists);
@@ -237,31 +237,31 @@ int CJabberProto::ListFindNext(JABBER_LIST list, int fromOffset)
/////////////////////////////////////////////////////////////////////////////////////////
// Resource related code
-pResourceStatus JABBER_LIST_ITEM::findResource(const wchar_t *resourceName) const
+pResourceStatus JABBER_LIST_ITEM::findResource(const char *resourceName) const
{
if (arResources.getCount() == 0 || resourceName == nullptr || *resourceName == 0)
return nullptr;
for (auto &it : arResources)
- if (!mir_wstrcmp(it->m_tszResourceName, resourceName))
+ if (!mir_strcmp(it->m_szResourceName, resourceName))
return it;
return nullptr;
}
-pResourceStatus CJabberProto::ListFindResource(JABBER_LIST list, const wchar_t *jid)
+pResourceStatus CJabberProto::ListFindResource(JABBER_LIST list, const char *jid)
{
mir_cslock lck(m_csLists);
JABBER_LIST_ITEM *LI = ListGetItemPtr(list, jid);
if (LI == nullptr)
return nullptr;
- const wchar_t *p = wcschr(jid, '@');
- const wchar_t *q = wcschr((p == nullptr) ? jid : p, '/');
+ const char *p = strchr(jid, '@');
+ const char *q = strchr((p == nullptr) ? jid : p, '/');
return (q == nullptr) ? nullptr : LI->findResource(q + 1);
}
-bool CJabberProto::ListAddResource(JABBER_LIST list, const wchar_t *jid, int status, const wchar_t *statusMessage, char priority, const wchar_t *nick)
+bool CJabberProto::ListAddResource(JABBER_LIST list, const char *jid, int status, const char *statusMessage, char priority, const char *nick)
{
mir_cslockfull lck(m_csLists);
JABBER_LIST_ITEM *LI = ListGetItemPtr(list, jid);
@@ -270,17 +270,17 @@ bool CJabberProto::ListAddResource(JABBER_LIST list, const wchar_t *jid, int sta
bool bIsNewResource = false;
- const wchar_t *p = wcschr(jid, '@');
- const wchar_t *q = wcschr((p == nullptr) ? jid : p, '/');
+ const char *p = strchr(jid, '@');
+ const char *q = strchr((p == nullptr) ? jid : p, '/');
if (q) {
- const wchar_t *resource = q + 1;
+ const char *resource = q + 1;
if (*resource == 0)
return false;
JABBER_RESOURCE_STATUS *r = LI->findResource(resource);
if (r != nullptr) { // Already exists, update status and statusMessage
r->m_iStatus = status;
- r->m_tszStatusMessage = mir_wstrdup(statusMessage);
+ r->m_szStatusMessage = mir_strdup(statusMessage);
r->m_iPriority = priority;
}
else { // Does not exist, add new resource
@@ -289,10 +289,10 @@ bool CJabberProto::ListAddResource(JABBER_LIST list, const wchar_t *jid, int sta
r->m_iStatus = status;
r->m_affiliation = AFFILIATION_NONE;
r->m_role = ROLE_NONE;
- r->m_tszResourceName = mir_wstrdup(resource);
- r->m_tszNick = mir_wstrdup(nick);
+ r->m_szResourceName = mir_strdup(resource);
+ r->m_szNick = mir_strdup(nick);
if (statusMessage)
- r->m_tszStatusMessage = mir_wstrdup(statusMessage);
+ r->m_szStatusMessage = mir_strdup(statusMessage);
r->m_iPriority = priority;
LI->arResources.insert(r);
}
@@ -301,7 +301,7 @@ bool CJabberProto::ListAddResource(JABBER_LIST list, const wchar_t *jid, int sta
else {
JABBER_RESOURCE_STATUS *r = LI->getTemp();
r->m_iStatus = status;
- r->m_tszStatusMessage = mir_wstrdup(statusMessage);
+ r->m_szStatusMessage = mir_strdup(statusMessage);
}
lck.unlock();
@@ -310,15 +310,15 @@ bool CJabberProto::ListAddResource(JABBER_LIST list, const wchar_t *jid, int sta
return bIsNewResource;
}
-void CJabberProto::ListRemoveResource(JABBER_LIST list, const wchar_t *jid)
+void CJabberProto::ListRemoveResource(JABBER_LIST list, const char *jid)
{
mir_cslockfull lck(m_csLists);
JABBER_LIST_ITEM *LI = ListGetItemPtr(list, jid);
if (LI == nullptr)
return;
- const wchar_t *p = wcschr(jid, '@');
- const wchar_t *q = wcschr((p == nullptr) ? jid : p, '/');
+ const char *p = strchr(jid, '@');
+ const char *q = strchr((p == nullptr) ? jid : p, '/');
if (q == nullptr)
return;
@@ -378,7 +378,7 @@ JABBER_RESOURCE_STATUS* JABBER_LIST_ITEM::getTemp()
return m_pItemResource;
}
-wchar_t* CJabberProto::ListGetBestClientResourceNamePtr(const wchar_t *jid)
+char* CJabberProto::ListGetBestClientResourceNamePtr(const char *jid)
{
mir_cslock lck(m_csLists);
JABBER_LIST_ITEM *LI = ListGetItemPtr(LIST_ROSTER, jid);
@@ -387,10 +387,10 @@ wchar_t* CJabberProto::ListGetBestClientResourceNamePtr(const wchar_t *jid)
pResourceStatus r(LI->getBestResource());
if (r != nullptr)
- return r->m_tszResourceName;
+ return r->m_szResourceName;
int status = ID_STATUS_OFFLINE;
- wchar_t *res = nullptr;
+ char *res = nullptr;
for (auto &it : LI->arResources) {
bool foundBetter = false;
switch (it->m_iStatus) {
@@ -415,7 +415,7 @@ wchar_t* CJabberProto::ListGetBestClientResourceNamePtr(const wchar_t *jid)
break;
}
if (foundBetter) {
- res = it->m_tszResourceName;
+ res = it->m_szResourceName;
status = it->m_iStatus;
}
}
diff --git a/protocols/JabberG/src/jabber_list.h b/protocols/JabberG/src/jabber_list.h
index 03ffe8a1de..c63aa5f6bf 100644
--- a/protocols/JabberG/src/jabber_list.h
+++ b/protocols/JabberG/src/jabber_list.h
@@ -90,20 +90,20 @@ public:
void Release();
int m_iStatus;
- ptrW m_tszResourceName;
- ptrW m_tszStatusMessage;
+ ptrA m_szResourceName;
+ ptrA m_szStatusMessage;
int m_iPriority; // resource priority, -128..+127
time_t m_dwIdleStartTime;// XEP-0012 support
// groupchat support
JABBER_GC_AFFILIATION m_affiliation;
JABBER_GC_ROLE m_role;
- ptrW m_tszNick;
- ptrW m_tszRealJid; // real jid for jabber conferences
+ ptrA m_szNick;
+ ptrA m_szRealJid; // real jid for jabber conferences
// XEP-0115 support
CJabberClientPartialCaps *m_pCaps;
- ptrW m_tszCapsExt;
+ ptrA m_tszCapsExt;
DWORD m_dwDiscoInfoRequestTime;
JabberCapsBits m_jcbCachedCaps;
@@ -150,14 +150,14 @@ struct JABBER_LIST_ITEM : public MZeroedObject
~JABBER_LIST_ITEM();
JABBER_LIST list;
- wchar_t* jid;
+ char *jid;
MCONTACT hContact;
// LIST_ROSTER
// jid = jid of the contact
- wchar_t* nick;
+ char *nick;
- pResourceStatus findResource(const wchar_t *resourceName) const;
+ pResourceStatus findResource(const char *resourceName) const;
pResourceStatus getBestResource() const;
JABBER_RESOURCE_MODE resourceMode;
LIST<JABBER_RESOURCE_STATUS> arResources; // array of resources
@@ -168,18 +168,18 @@ struct JABBER_LIST_ITEM : public MZeroedObject
*getTemp(); // allocates m_pItemResource if needed
JABBER_SUBSCRIPTION subscription;
- wchar_t* group;
- wchar_t* photoFileName;
- wchar_t* messageEventIdStr;
+ char *group;
+ char *photoFileName;
+ char *messageEventIdStr;
// LIST_AGENT
// jid = jid of the agent
- wchar_t* name;
- wchar_t* service;
+ wchar_t *name;
+ char *service;
// LIST_ROOM
// jid = room JID
- wchar_t* type; // room type
+ char *type; // room type
// LIST_CHATROOM
// jid = room JID
@@ -206,7 +206,7 @@ struct JABBER_LIST_ITEM : public MZeroedObject
//LIST_BOOKMARK
// jid = room JID
- wchar_t* password; // password for room
+ char *password; // password for room
bool bAutoJoin;
bool bUseResource;
@@ -218,11 +218,11 @@ struct JABBER_LIST_ITEM : public MZeroedObject
struct JABBER_HTTP_AVATARS
{
- char * Url;
+ char *Url;
MCONTACT hContact;
- JABBER_HTTP_AVATARS(const wchar_t *tUrl, MCONTACT thContact)
- : Url(mir_u2a(tUrl)), hContact(thContact) {}
+ JABBER_HTTP_AVATARS(const char *tUrl, MCONTACT thContact)
+ : Url(mir_strdup(tUrl)), hContact(thContact) {}
~JABBER_HTTP_AVATARS() { mir_free(Url); }
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp
index eebe467327..067fadf6a0 100644
--- a/protocols/JabberG/src/jabber_menu.cpp
+++ b/protocols/JabberG/src/jabber_menu.cpp
@@ -307,7 +307,7 @@ int CJabberProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM)
bool bIsTransport = getBool(hContact, "IsTransport", false);
if ((bIsChatRoom == GCW_CHATROOM) || bIsChatRoom == 0) {
- if (ptrW(getWStringA(hContact, bIsChatRoom ? (char*)"ChatRoomID" : (char*)"jid")) != nullptr) {
+ if (ptrW(getWStringA(hContact, bIsChatRoom ? "ChatRoomID" : "jid")) != nullptr) {
Menu_ShowItem(g_hMenuConvert, TRUE);
Menu_ModifyItem(g_hMenuConvert, bIsChatRoom ? LPGENW("&Convert to Contact") : LPGENW("&Convert to Chat Room"));
}
@@ -321,7 +321,7 @@ int CJabberProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM)
Menu_ModifyItem(g_hMenuDirectPresence[i + 1], nullptr, Skin_LoadProtoIcon(m_szModuleName, PresenceModeArray[i].mode));
if (bIsChatRoom) {
- ptrW roomid(getWStringA(hContact, "ChatRoomID"));
+ ptrA roomid(getUStringA(hContact, "ChatRoomID"));
if (roomid != nullptr) {
Menu_ShowItem(g_hMenuRosterAdd, FALSE);
@@ -339,7 +339,7 @@ int CJabberProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM)
Menu_ShowItem(g_hMenuRefresh, TRUE);
}
- ptrW jid(getWStringA(hContact, "jid"));
+ ptrA jid(getUStringA(hContact, "jid"));
if (jid == nullptr)
return 0;
@@ -374,7 +374,6 @@ int CJabberProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM)
mi.flags = CMIF_SYSTEM;
mi.pszService = text;
- CMStringW szTmp;
for (int i = 0; i < nMenuResourceItemsNew; i++) {
mir_snprintf(text, "/UseResource_%d", i);
if (i >= m_nMenuResourceItems) {
@@ -391,10 +390,13 @@ int CJabberProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM)
Menu_SetChecked(m_phMenuResourceItems[i], item->resourceMode == RSMODE_MANUAL && item->m_pManualResource == r);
if (ServiceExists(MS_FP_GETCLIENTICONT)) {
+ CMStringA szTmp;
FormatMirVer(r, szTmp);
- hIcon = Finger_GetClientIcon(szTmp, 0);
+ hIcon = Finger_GetClientIcon(Utf2T(szTmp), 0);
}
- szTmp.Format(L"%s [%s, %d]", r->m_tszResourceName, Clist_GetStatusModeDescription(r->m_iStatus, 0), r->m_iPriority);
+
+ CMStringW szTmp;
+ szTmp.Format(L"%s [%s, %d]", Utf2T(r->m_szResourceName), Clist_GetStatusModeDescription(r->m_iStatus, 0), r->m_iPriority);
Menu_ModifyItem(m_phMenuResourceItems[i], szTmp, hIcon);
DestroyIcon(hIcon);
}
@@ -424,22 +426,22 @@ INT_PTR __cdecl CJabberProto::OnMenuRosterAdd(WPARAM hContact, LPARAM)
if (!hContact)
return 0; // we do not add ourself to the roster. (buggy situation - should not happen)
- ptrW roomID(getWStringA(hContact, "ChatRoomID"));
+ ptrA roomID(getUStringA(hContact, "ChatRoomID"));
if (roomID == nullptr)
return 0;
if (ListGetItemPtr(LIST_ROSTER, roomID) == nullptr) {
- ptrW group(db_get_wsa(hContact, "CList", "Group"));
- ptrW nick(getWStringA(hContact, "Nick"));
+ ptrA group(db_get_utfa(hContact, "CList", "Group"));
+ ptrA nick(getUStringA(hContact, "Nick"));
AddContactToRoster(roomID, nick, group);
if (m_bAddRoster2Bookmarks == TRUE) {
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_BOOKMARK, roomID);
if (item == nullptr) {
item = new JABBER_LIST_ITEM();
- item->jid = mir_wstrdup(roomID);
- item->name = mir_wstrdup(nick);
- item->nick = getWStringA(hContact, "MyNick");
+ item->jid = mir_strdup(roomID);
+ item->name = mir_wstrdup(Utf2T(nick));
+ item->nick = getUStringA(hContact, "MyNick");
AddEditBookmark(item);
delete item;
}
@@ -451,9 +453,9 @@ INT_PTR __cdecl CJabberProto::OnMenuRosterAdd(WPARAM hContact, LPARAM)
INT_PTR __cdecl CJabberProto::OnMenuHandleRequestAuth(WPARAM hContact, LPARAM)
{
if (hContact != 0 && m_bJabberOnline) {
- ptrW jid(getWStringA(hContact, "jid"));
+ ptrA jid(getUStringA(hContact, "jid"));
if (jid != nullptr)
- m_ThreadInfo->send(XmlNode(L"presence") << XATTR(L"to", jid) << XATTR(L"type", L"subscribe"));
+ m_ThreadInfo->send(XmlNode("presence") << XATTR("to", jid) << XATTR("type", "subscribe"));
}
return 0;
}
@@ -461,9 +463,9 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleRequestAuth(WPARAM hContact, LPARAM)
INT_PTR __cdecl CJabberProto::OnMenuHandleGrantAuth(WPARAM hContact, LPARAM)
{
if (hContact != 0 && m_bJabberOnline) {
- ptrW jid(getWStringA(hContact, "jid"));
+ ptrA jid(getUStringA(hContact, "jid"));
if (jid != nullptr)
- m_ThreadInfo->send(XmlNode(L"presence") << XATTR(L"to", jid) << XATTR(L"type", L"subscribed"));
+ m_ThreadInfo->send(XmlNode("presence") << XATTR("to", jid) << XATTR("type", "subscribed"));
}
return 0;
}
@@ -471,9 +473,9 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleGrantAuth(WPARAM hContact, LPARAM)
INT_PTR __cdecl CJabberProto::OnMenuHandleRevokeAuth(WPARAM hContact, LPARAM)
{
if (hContact != 0 && m_bJabberOnline) {
- ptrW jid(getWStringA(hContact, "jid"));
+ ptrA jid(getUStringA(hContact, "jid"));
if (jid != nullptr)
- m_ThreadInfo->send(XmlNode(L"presence") << XATTR(L"to", jid) << XATTR(L"type", L"unsubscribed"));
+ m_ThreadInfo->send(XmlNode("presence") << XATTR("to", jid) << XATTR("type", "unsubscribed"));
}
return 0;
}
@@ -483,11 +485,11 @@ INT_PTR __cdecl CJabberProto::OnMenuTransportLogin(WPARAM hContact, LPARAM)
if (!getByte(hContact, "IsTransport", 0))
return 0;
- JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, ptrW(getWStringA(hContact, "jid")));
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, ptrA(getUStringA(hContact, "jid")));
if (item != nullptr) {
- XmlNode p(L"presence"); XmlAddAttr(p, L"to", item->jid);
+ XmlNode p("presence"); XmlAddAttr(p, "to", item->jid);
if (item->getTemp()->m_iStatus == ID_STATUS_ONLINE)
- XmlAddAttr(p, L"type", L"unavailable");
+ XmlAddAttr(p, "type", "unavailable");
m_ThreadInfo->send(p);
}
return 0;
@@ -498,7 +500,7 @@ INT_PTR __cdecl CJabberProto::OnMenuTransportResolve(WPARAM hContact, LPARAM)
if (!getByte(hContact, "IsTransport", 0))
return 0;
- ptrW jid(getWStringA(hContact, "jid"));
+ ptrA jid(getUStringA(hContact, "jid"));
if (jid != nullptr)
ResolveTransportNicks(jid);
return 0;
@@ -509,16 +511,16 @@ INT_PTR __cdecl CJabberProto::OnMenuBookmarkAdd(WPARAM hContact, LPARAM)
if (!hContact)
return 0; // we do not add ourself to the roster. (buggy situation - should not happen)
- ptrW roomID(getWStringA(hContact, "ChatRoomID"));
+ ptrA roomID(getUStringA(hContact, "ChatRoomID"));
if (roomID == nullptr)
return 0;
if (ListGetItemPtr(LIST_BOOKMARK, roomID) == nullptr) {
JABBER_LIST_ITEM *item = new JABBER_LIST_ITEM();
- item->jid = mir_wstrdup(roomID);
+ item->jid = mir_strdup(roomID);
item->name = Clist_GetContactDisplayName(hContact);
- item->type = L"conference";
- item->nick = getWStringA(hContact, "MyNick");
+ item->type = "conference";
+ item->nick = getUStringA(hContact, "MyNick");
AddEditBookmark(item);
delete item;
}
@@ -894,7 +896,7 @@ int CJabberProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam)
hDialogsList = WindowList_Create();
WindowList_Add(hDialogsList, event->hwndWindow, event->hContact);
- ptrW jid(getWStringA(event->hContact, "jid"));
+ ptrA jid(getUStringA(event->hContact, "jid"));
if (jid != nullptr) {
JABBER_LIST_ITEM *pItem = ListGetItemPtr(LIST_ROSTER, jid);
if (pItem && m_ThreadInfo && (m_ThreadInfo->jabberServerCaps & JABBER_CAPS_ARCHIVE_AUTO) && m_bEnableMsgArchive)
@@ -919,14 +921,14 @@ int CJabberProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam)
if (!bSupportTyping || !m_bJabberOnline)
return 0;
- wchar_t jid[JABBER_MAX_JID_LEN];
+ char jid[JABBER_MAX_JID_LEN];
if (GetClientJID(event->hContact, jid, _countof(jid))) {
pResourceStatus r(ResourceInfoFromJID(jid));
if (r && r->m_bMessageSessionActive) {
r->m_bMessageSessionActive = FALSE;
if (GetResourceCapabilities(jid) & JABBER_CAPS_CHATSTATES)
- m_ThreadInfo->send(XmlNode(L"message") << XATTR(L"to", jid) << XATTR(L"type", L"chat") << XATTRID(SerialNext()) << XCHILDNS(L"gone", JABBER_FEAT_CHATSTATES));
+ m_ThreadInfo->send(XmlNode("message") << XATTR("to", jid) << XATTR("type", "chat") << XATTRID(SerialNext()) << XCHILDNS("gone", JABBER_FEAT_CHATSTATES));
}
}
}
@@ -943,7 +945,7 @@ int CJabberProto::OnProcessSrmmIconClick(WPARAM hContact, LPARAM lParam)
if (!hContact)
return 0;
- JABBER_LIST_ITEM *LI = ListGetItemPtr(LIST_ROSTER, ptrW(getWStringA(hContact, "jid")));
+ JABBER_LIST_ITEM *LI = ListGetItemPtr(LIST_ROSTER, ptrA(getUStringA(hContact, "jid")));
if (LI == nullptr)
return 0;
@@ -951,14 +953,14 @@ int CJabberProto::OnProcessSrmmIconClick(WPARAM hContact, LPARAM lParam)
wchar_t buf[256];
mir_snwprintf(buf, TranslateT("Last active (%s)"),
- LI->m_pLastSeenResource ? LI->m_pLastSeenResource->m_tszResourceName : TranslateT("No activity yet, use server's choice"));
+ LI->m_pLastSeenResource ? Utf2T(LI->m_pLastSeenResource->m_szResourceName) : TranslateT("No activity yet, use server's choice"));
AppendMenu(hMenu, MF_STRING, MENUITEM_LASTSEEN, buf);
AppendMenu(hMenu, MF_STRING, MENUITEM_SERVER, TranslateT("Highest priority (server's choice)"));
AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr);
for (int i = 0; i < LI->arResources.getCount(); i++)
- AppendMenu(hMenu, MF_STRING, MENUITEM_RESOURCES + i, LI->arResources[i]->m_tszResourceName);
+ AppendMenu(hMenu, MF_STRING, MENUITEM_RESOURCES + i, Utf2T(LI->arResources[i]->m_szResourceName));
if (LI->resourceMode == RSMODE_LASTSEEN)
CheckMenuItem(hMenu, MENUITEM_LASTSEEN, MF_BYCOMMAND | MF_CHECKED);
@@ -993,7 +995,7 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleResource(WPARAM hContact, LPARAM, LPAR
if (!m_bJabberOnline || !hContact)
return 0;
- ptrW tszJid(getWStringA(hContact, "jid"));
+ ptrA tszJid(getUStringA(hContact, "jid"));
if (tszJid == nullptr)
return 0;
@@ -1024,10 +1026,10 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleDirectPresence(WPARAM hContact, LPARAM
if (!m_bJabberOnline || !hContact)
return 0;
- wchar_t *jid, text[1024];
- ptrW tszJid(getWStringA(hContact, "jid"));
+ char *jid, text[1024];
+ ptrA tszJid(getUStringA(hContact, "jid"));
if (tszJid == nullptr) {
- ptrW roomid(getWStringA(hContact, "ChatRoomID"));
+ ptrA roomid(getUStringA(hContact, "ChatRoomID"));
if (roomid == nullptr)
return 0;
@@ -1035,14 +1037,14 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleDirectPresence(WPARAM hContact, LPARAM
if (item == nullptr)
return 0;
- mir_snwprintf(text, L"%s/%s", item->jid, item->nick);
+ mir_snprintf(text, "%s/%s", item->jid, item->nick);
jid = text;
}
else jid = tszJid;
CMStringW szValue;
if (EnterString(szValue, TranslateT("Status Message"), ESF_MULTILINE))
- SendPresenceTo(res, jid, nullptr, szValue);
+ SendPresenceTo(res, jid, nullptr, T2Utf(szValue));
return 0;
}
diff --git a/protocols/JabberG/src/jabber_message_handlers.cpp b/protocols/JabberG/src/jabber_message_handlers.cpp
index 193250bf9a..24b3fa5156 100644
--- a/protocols/JabberG/src/jabber_message_handlers.cpp
+++ b/protocols/JabberG/src/jabber_message_handlers.cpp
@@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
-BOOL CJabberProto::OnMessageError(HXML node, ThreadData*, CJabberMessageInfo* pInfo)
+BOOL CJabberProto::OnMessageError(const TiXmlElement *node, ThreadData*, CJabberMessageInfo* pInfo)
{
// we check if is message delivery failure
int id = JabberGetPacketID(node);
@@ -39,9 +39,9 @@ BOOL CJabberProto::OnMessageError(HXML node, ThreadData*, CJabberMessageInfo* pI
ProtoBroadcastAck(pInfo->GetHContact(), ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)id, szErrText);
else {
wchar_t buf[512];
- HXML bodyNode = XmlGetChild(node, "body");
+ auto *bodyNode = node->FirstChildElement("body");
if (bodyNode)
- mir_snwprintf(buf, L"%s:\n%s\n%s", pInfo->GetFrom(), XmlGetText(bodyNode), szErrText);
+ mir_snwprintf(buf, L"%s:\n%s\n%s", pInfo->GetFrom(), bodyNode->GetText(), szErrText);
else
mir_snwprintf(buf, L"%s:\n%s", pInfo->GetFrom(), szErrText);
@@ -51,24 +51,24 @@ BOOL CJabberProto::OnMessageError(HXML node, ThreadData*, CJabberMessageInfo* pI
return TRUE;
}
-BOOL CJabberProto::OnMessageIbb(HXML, ThreadData*, CJabberMessageInfo* pInfo)
+BOOL CJabberProto::OnMessageIbb(const TiXmlElement*, ThreadData*, CJabberMessageInfo* pInfo)
{
BOOL bOk = FALSE;
- const wchar_t *sid = XmlGetAttrValue(pInfo->GetChildNode(), L"sid");
- const wchar_t *seq = XmlGetAttrValue(pInfo->GetChildNode(), L"seq");
- if (sid && seq && XmlGetText(pInfo->GetChildNode()))
- bOk = OnIbbRecvdData(XmlGetText(pInfo->GetChildNode()), sid, seq);
+ const char *sid = pInfo->GetChildNode()->Attribute("sid");
+ const char *seq = pInfo->GetChildNode()->Attribute("seq");
+ if (sid && seq && pInfo->GetChildNode()->GetText())
+ bOk = OnIbbRecvdData(pInfo->GetChildNode()->GetText(), sid, seq);
return TRUE;
}
-BOOL CJabberProto::OnMessagePubsubEvent(HXML node, ThreadData*, CJabberMessageInfo*)
+BOOL CJabberProto::OnMessagePubsubEvent(const TiXmlElement *node, ThreadData*, CJabberMessageInfo*)
{
OnProcessPubsubEvent(node);
return TRUE;
}
-BOOL CJabberProto::OnMessageGroupchat(HXML node, ThreadData*, CJabberMessageInfo* pInfo)
+BOOL CJabberProto::OnMessageGroupchat(const TiXmlElement *node, ThreadData*, CJabberMessageInfo* pInfo)
{
JABBER_LIST_ITEM *chatItem = ListGetItemPtr(LIST_CHATROOM, pInfo->GetFrom());
if (chatItem) // process GC message
diff --git a/protocols/JabberG/src/jabber_message_manager.cpp b/protocols/JabberG/src/jabber_message_manager.cpp
index 06a889aeb5..78bba000a1 100644
--- a/protocols/JabberG/src/jabber_message_manager.cpp
+++ b/protocols/JabberG/src/jabber_message_manager.cpp
@@ -43,29 +43,29 @@ CJabberMessageManager::~CJabberMessageManager()
void CJabberMessageManager::FillPermanentHandlers()
{
- AddPermanentHandler(&CJabberProto::OnMessageError, JABBER_MESSAGE_TYPE_ERROR, JABBER_MESSAGE_PARSE_FROM | JABBER_MESSAGE_PARSE_HCONTACT, nullptr, FALSE, L"error");
- AddPermanentHandler(&CJabberProto::OnMessageIbb, 0, 0, JABBER_FEAT_IBB, FALSE, L"data");
- AddPermanentHandler(&CJabberProto::OnMessagePubsubEvent, 0, 0, JABBER_FEAT_PUBSUB_EVENT, FALSE, L"event");
+ AddPermanentHandler(&CJabberProto::OnMessageError, JABBER_MESSAGE_TYPE_ERROR, JABBER_MESSAGE_PARSE_FROM | JABBER_MESSAGE_PARSE_HCONTACT, nullptr, FALSE, "error");
+ AddPermanentHandler(&CJabberProto::OnMessageIbb, 0, 0, JABBER_FEAT_IBB, FALSE, "data");
+ AddPermanentHandler(&CJabberProto::OnMessagePubsubEvent, 0, 0, JABBER_FEAT_PUBSUB_EVENT, FALSE, "event");
AddPermanentHandler(&CJabberProto::OnMessageGroupchat, JABBER_MESSAGE_TYPE_GROUPCHAT, JABBER_MESSAGE_PARSE_FROM, nullptr, FALSE, nullptr);
}
-bool CJabberMessageManager::HandleMessagePermanent(HXML node, ThreadData *pThreadData)
+bool CJabberMessageManager::HandleMessagePermanent(const TiXmlElement *node, ThreadData *pThreadData)
{
for (auto &it : m_arHandlers) {
// have to get all data here, in the loop, because there's always possibility that previous handler modified it
CJabberMessageInfo messageInfo;
- const wchar_t *szType = XmlGetAttrValue(node, L"type");
+ const char *szType = node->Attribute("type");
if (szType) {
- if (!mir_wstrcmpi(szType, L"normal"))
+ if (!mir_strcmpi(szType, "normal"))
messageInfo.m_nMessageType = JABBER_MESSAGE_TYPE_NORMAL;
- else if (!mir_wstrcmpi(szType, L"error"))
+ else if (!mir_strcmpi(szType, "error"))
messageInfo.m_nMessageType = JABBER_MESSAGE_TYPE_ERROR;
- else if (!mir_wstrcmpi(szType, L"chat"))
+ else if (!mir_strcmpi(szType, "chat"))
messageInfo.m_nMessageType = JABBER_MESSAGE_TYPE_CHAT;
- else if (!mir_wstrcmpi(szType, L"groupchat"))
+ else if (!mir_strcmpi(szType, "groupchat"))
messageInfo.m_nMessageType = JABBER_MESSAGE_TYPE_GROUPCHAT;
- else if (!mir_wstrcmpi(szType, L"headline"))
+ else if (!mir_strcmpi(szType, "headline"))
messageInfo.m_nMessageType = JABBER_MESSAGE_TYPE_HEADLINE;
else
return false;
@@ -73,26 +73,24 @@ bool CJabberMessageManager::HandleMessagePermanent(HXML node, ThreadData *pThrea
else messageInfo.m_nMessageType = JABBER_MESSAGE_TYPE_NORMAL;
if (it->m_nMessageTypes & messageInfo.m_nMessageType) {
- for (int i = XmlGetChildCount(node) - 1; i >= 0; i--) {
- // enumerate all children and see whether this node suits handler criteria
- HXML child = XmlGetChild(node, i);
+ // enumerate all children and see whether this node suits handler criteria
+ for (auto *child : TiXmlEnum(node)) {
+ const char *szTagName = child->Name();
+ const char *szXmlns = child->Attribute("xmlns");
- const wchar_t *szTagName = XmlGetName(child);
- const wchar_t *szXmlns = XmlGetAttrValue(child, L"xmlns");
-
- if ((!it->m_szXmlns || (szXmlns && !mir_wstrcmp(it->m_szXmlns, szXmlns))) && (!it->m_szTag || !mir_wstrcmp(it->m_szTag, szTagName))) {
+ if ((!it->m_szXmlns || (szXmlns && !mir_strcmp(it->m_szXmlns, szXmlns))) && (!it->m_szTag || !mir_strcmp(it->m_szTag, szTagName))) {
// node suits handler criteria, call the handler
messageInfo.m_hChildNode = child;
messageInfo.m_szChildTagName = szTagName;
messageInfo.m_szChildTagXmlns = szXmlns;
messageInfo.m_pUserData = it->m_pUserData;
- messageInfo.m_szFrom = XmlGetAttrValue(node, L"from"); // is necessary for ppro->debugLogA() below, that's why we must parse it even if JABBER_MESSAGE_PARSE_FROM flag is not set
+ messageInfo.m_szFrom = node->Attribute("from"); // is necessary for ppro->debugLogA() below, that's why we must parse it even if JABBER_MESSAGE_PARSE_FROM flag is not set
if (it->m_dwParamsToParse & JABBER_MESSAGE_PARSE_ID_STR)
- messageInfo.m_szId = XmlGetAttrValue(node, L"id");
+ messageInfo.m_szId = node->Attribute("id");
if (it->m_dwParamsToParse & JABBER_IQ_PARSE_TO)
- messageInfo.m_szTo = XmlGetAttrValue(node, L"to");
+ messageInfo.m_szTo = node->Attribute("to");
if (it->m_dwParamsToParse & JABBER_MESSAGE_PARSE_HCONTACT)
messageInfo.m_hContact = ppro->HContactFromJID(messageInfo.m_szFrom);
@@ -113,9 +111,9 @@ CJabberMessagePermanentInfo* CJabberMessageManager::AddPermanentHandler(
JABBER_PERMANENT_MESSAGE_HANDLER pHandler,
int nMessageTypes,
DWORD dwParamsToParse,
- const wchar_t *szXmlns,
+ const char *szXmlns,
BOOL bAllowPartialNs,
- const wchar_t *szTag,
+ const char *szTag,
void *pUserData,
MESSAGE_USER_DATA_FREE_FUNC pUserDataFree,
int iPriority)
@@ -123,9 +121,9 @@ CJabberMessagePermanentInfo* CJabberMessageManager::AddPermanentHandler(
CJabberMessagePermanentInfo* pInfo = new CJabberMessagePermanentInfo();
pInfo->m_pHandler = pHandler;
pInfo->m_nMessageTypes = nMessageTypes ? nMessageTypes : JABBER_MESSAGE_TYPE_ANY;
- pInfo->m_szXmlns = mir_wstrdup(szXmlns);
+ pInfo->m_szXmlns = mir_strdup(szXmlns);
pInfo->m_bAllowPartialNs = bAllowPartialNs;
- pInfo->m_szTag = mir_wstrdup(szTag);
+ pInfo->m_szTag = mir_strdup(szTag);
pInfo->m_dwParamsToParse = dwParamsToParse;
pInfo->m_pUserData = pUserData;
pInfo->m_pUserDataFree = pUserDataFree;
diff --git a/protocols/JabberG/src/jabber_message_manager.h b/protocols/JabberG/src/jabber_message_manager.h
index 9731e205ab..a6902c7d9f 100644
--- a/protocols/JabberG/src/jabber_message_manager.h
+++ b/protocols/JabberG/src/jabber_message_manager.h
@@ -30,12 +30,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "jabber_xml.h"
struct CJabberProto;
-typedef void (CJabberProto::*JABBER_MESSAGE_PFUNC)(HXML messageNode, void *usedata);
+typedef void (CJabberProto::*JABBER_MESSAGE_PFUNC)(const TiXmlElement *messageNode, void *usedata);
typedef void (*MESSAGE_USER_DATA_FREE_FUNC)(void *pUserData);
class CJabberMessageInfo;
-typedef BOOL (CJabberProto::*JABBER_PERMANENT_MESSAGE_HANDLER)(HXML messageNode, ThreadData *pThreadData, CJabberMessageInfo* pInfo);
+typedef BOOL (CJabberProto::*JABBER_PERMANENT_MESSAGE_HANDLER)(const TiXmlElement *messageNode, ThreadData *pThreadData, CJabberMessageInfo* pInfo);
#define JABBER_MESSAGE_PARSE_FROM (1<<3)
#define JABBER_MESSAGE_PARSE_HCONTACT ((1<<4)|JABBER_MESSAGE_PARSE_FROM)
@@ -47,19 +47,19 @@ class CJabberMessageInfo : public MZeroedObject
protected:
friend class CJabberMessageManager;
JABBER_PERMANENT_MESSAGE_HANDLER m_pHandler;
- CJabberMessageInfo* m_pNext;
+ CJabberMessageInfo *m_pNext;
public:
void *m_pUserData;
// parsed data
int m_nMessageType;
- const wchar_t *m_szFrom;
- const wchar_t *m_szChildTagXmlns;
- const wchar_t *m_szChildTagName;
- HXML m_hChildNode;
+ const char *m_szFrom;
+ const char *m_szChildTagXmlns;
+ const char *m_szChildTagName;
+ const TiXmlElement *m_hChildNode;
MCONTACT m_hContact;
- const wchar_t *m_szTo;
- const wchar_t *m_szId;
+ const char *m_szTo;
+ const char *m_szId;
public:
__forceinline int GetMessageType()
@@ -68,22 +68,22 @@ public:
__forceinline void* GetUserData()
{ return m_pUserData;
}
- __forceinline const wchar_t *GetFrom()
+ __forceinline const char* GetFrom()
{ return m_szFrom;
}
- __forceinline const wchar_t *GetTo()
+ __forceinline const char* GetTo()
{ return m_szTo;
}
- __forceinline const wchar_t *GetIdStr()
+ __forceinline const char* GetIdStr()
{ return m_szId;
}
__forceinline MCONTACT GetHContact()
{ return m_hContact;
}
- __forceinline HXML GetChildNode()
+ __forceinline const TiXmlElement* GetChildNode()
{ return m_hChildNode;
}
- __forceinline const wchar_t *GetChildNodeName()
+ __forceinline const char *GetChildNodeName()
{ return m_szChildTagName;
}
};
@@ -95,8 +95,8 @@ class CJabberMessagePermanentInfo : public MZeroedObject
JABBER_PERMANENT_MESSAGE_HANDLER m_pHandler;
DWORD m_dwParamsToParse;
int m_nMessageTypes;
- LPTSTR m_szXmlns;
- LPTSTR m_szTag;
+ char *m_szXmlns;
+ char *m_szTag;
BOOL m_bAllowPartialNs;
void *m_pUserData;
MESSAGE_USER_DATA_FREE_FUNC m_pUserDataFree;
@@ -125,10 +125,10 @@ public:
CJabberMessageManager(CJabberProto *proto);
~CJabberMessageManager();
- CJabberMessagePermanentInfo* AddPermanentHandler(JABBER_PERMANENT_MESSAGE_HANDLER pHandler, int nMessageTypes, DWORD dwParamsToParse, const wchar_t *szXmlns, BOOL bAllowPartialNs, const wchar_t *szTag, void *pUserData = nullptr, MESSAGE_USER_DATA_FREE_FUNC pUserDataFree = nullptr, int iPriority = JH_PRIORITY_DEFAULT);
+ CJabberMessagePermanentInfo* AddPermanentHandler(JABBER_PERMANENT_MESSAGE_HANDLER pHandler, int nMessageTypes, DWORD dwParamsToParse, const char *szXmlns, BOOL bAllowPartialNs, const char *szTag, void *pUserData = nullptr, MESSAGE_USER_DATA_FREE_FUNC pUserDataFree = nullptr, int iPriority = JH_PRIORITY_DEFAULT);
bool DeletePermanentHandler(CJabberMessagePermanentInfo *pInfo);
- bool HandleMessagePermanent(HXML node, ThreadData *pThreadData);
+ bool HandleMessagePermanent(const TiXmlElement *node, ThreadData *pThreadData);
void FillPermanentHandlers();
};
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp
index 4fccb9d3d1..490fbd7c35 100755
--- a/protocols/JabberG/src/jabber_misc.cpp
+++ b/protocols/JabberG/src/jabber_misc.cpp
@@ -30,25 +30,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
// JabberAddContactToRoster() - adds a contact to the roster
-void CJabberProto::AddContactToRoster(const wchar_t *jid, const wchar_t *nick, const wchar_t *grpName)
+void CJabberProto::AddContactToRoster(const char *jid, const char *nick, const char *grpName)
{
- XmlNodeIq iq(L"set", SerialNext());
- HXML query = iq << XQUERY(JABBER_FEAT_IQ_ROSTER)
- << XCHILD(L"item") << XATTR(L"jid", jid) << XATTR(L"name", nick);
+ XmlNodeIq iq("set", SerialNext());
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_IQ_ROSTER)
+ << XCHILD("item") << XATTR("jid", jid) << XATTR("name", nick);
if (grpName)
- query << XCHILD(L"group", grpName);
+ query << XCHILD("group", grpName);
m_ThreadInfo->send(iq);
}
///////////////////////////////////////////////////////////////////////////////
// JabberDBAddAuthRequest()
-void CJabberProto::DBAddAuthRequest(const wchar_t *jid, const wchar_t *nick)
+void CJabberProto::DBAddAuthRequest(const char *jid, const char *nick)
{
MCONTACT hContact = DBCreateContact(jid, nick, true, true);
delSetting(hContact, "Hidden");
- DB_AUTH_BLOB blob(hContact, T2Utf(nick), nullptr, nullptr, T2Utf(jid), nullptr);
+ DB_AUTH_BLOB blob(hContact, nick, nullptr, nullptr, jid, nullptr);
DBEVENTINFO dbei = {};
dbei.szModule = m_szModuleName;
@@ -64,7 +64,7 @@ void CJabberProto::DBAddAuthRequest(const wchar_t *jid, const wchar_t *nick)
///////////////////////////////////////////////////////////////////////////////
// JabberDBCreateContact()
-MCONTACT CJabberProto::DBCreateContact(const wchar_t *jid, const wchar_t *nick, bool temporary, bool stripResource)
+MCONTACT CJabberProto::DBCreateContact(const char *jid, const char *nick, bool temporary, bool stripResource)
{
if (jid == nullptr || jid[0] == '\0')
return 0;
@@ -74,24 +74,24 @@ MCONTACT CJabberProto::DBCreateContact(const wchar_t *jid, const wchar_t *nick,
return hContact;
// strip resource if present
- wchar_t szJid[JABBER_MAX_JID_LEN];
+ char szJid[JABBER_MAX_JID_LEN];
if (stripResource)
JabberStripJid(jid, szJid, _countof(szJid));
else
- wcsncpy_s(szJid, jid, _TRUNCATE);
+ strncpy_s(szJid, jid, _TRUNCATE);
MCONTACT hNewContact = db_add_contact();
Proto_AddToContact(hNewContact, m_szModuleName);
- setWString(hNewContact, "jid", szJid);
+ setUString(hNewContact, "jid", szJid);
if (nick != nullptr && *nick != '\0')
- setWString(hNewContact, "Nick", nick);
+ setUString(hNewContact, "Nick", nick);
if (temporary)
db_set_b(hNewContact, "CList", "NotOnList", 1);
else
SendGetVcard(szJid);
if (JABBER_LIST_ITEM *pItem = ListAdd(LIST_ROSTER, jid, hNewContact))
- pItem->bUseResource = wcschr(szJid, '/') != nullptr;
+ pItem->bUseResource = strchr(szJid, '/') != nullptr;
debugLogW(L"Create Jabber contact jid=%s, nick=%s", szJid, nick);
DBCheckIsTransportedContact(szJid, hNewContact);
@@ -171,7 +171,7 @@ void CJabberProto::GetAvatarFileName(MCONTACT hContact, wchar_t* pszDest, size_t
///////////////////////////////////////////////////////////////////////////////
// JabberResolveTransportNicks - massive vcard update
-void CJabberProto::ResolveTransportNicks(const wchar_t *jid)
+void CJabberProto::ResolveTransportNicks(const char *jid)
{
// Set all contacts to offline
MCONTACT hContact = m_ThreadInfo->resolveContact;
@@ -182,15 +182,15 @@ void CJabberProto::ResolveTransportNicks(const wchar_t *jid)
if (!getByte(hContact, "IsTransported", 0))
continue;
- ptrW dbJid(getWStringA(hContact, "jid")); if (dbJid == nullptr) continue;
- ptrW dbNick(getWStringA(hContact, "Nick")); if (dbNick == nullptr) continue;
+ ptrA dbJid(getUStringA(hContact, "jid")); if (dbJid == nullptr) continue;
+ ptrA dbNick(getUStringA(hContact, "Nick")); if (dbNick == nullptr) continue;
- wchar_t *p = wcschr(dbJid, '@');
+ char *p = strchr(dbJid, '@');
if (p == nullptr)
continue;
*p = 0;
- if (!mir_wstrcmp(jid, p + 1) && !mir_wstrcmp(dbJid, dbNick)) {
+ if (!mir_strcmp(jid, p + 1) && !mir_strcmp(dbJid, dbNick)) {
*p = '@';
m_ThreadInfo->resolveID = SendGetVcard(dbJid);
m_ThreadInfo->resolveContact = hContact;
@@ -245,26 +245,26 @@ void CJabberProto::SetServerStatus(int iNewStatus)
struct
{
- wchar_t *node;
- wchar_t *name;
+ char *node;
+ char *name;
}
static sttCapsNodeToName_Map[] =
{
- { L"http://miranda-im.org", L"Miranda IM Jabber" },
- { L"http://miranda-ng.org", L"Miranda NG Jabber" },
- { L"http://www.google.com", L"GTalk" },
- { L"http://mail.google.com", L"GMail" },
- { L"http://www.android.com", L"Android" },
- { L"http://qip.ru", L"QIP 2012" },
- { L"http://2010.qip.ru", L"QIP 2010"},
- { L"http://conversations.im", L"Conversations IM" }
+ { "http://miranda-im.org", "Miranda IM Jabber" },
+ { "http://miranda-ng.org", "Miranda NG Jabber" },
+ { "http://www.google.com", "GTalk" },
+ { "http://mail.google.com", "GMail" },
+ { "http://www.android.com", "Android" },
+ { "http://qip.ru", "QIP 2012" },
+ { "http://2010.qip.ru", "QIP 2010"},
+ { "http://conversations.im", "Conversations IM" }
};
-const wchar_t* CJabberProto::GetSoftName(const wchar_t *wszName)
+const char* CJabberProto::GetSoftName(const char *szName)
{
// search through known software list
for (auto &it : sttCapsNodeToName_Map)
- if (wcsstr(wszName, it.node))
+ if (strstr(szName, it.node))
return it.name;
return nullptr;
@@ -284,7 +284,7 @@ void CJabberProto::UpdateMirVer(JABBER_LIST_ITEM *item)
UpdateMirVer(hContact, pResourceStatus(item->m_pManualResource));
}
-void CJabberProto::FormatMirVer(const pResourceStatus &resource, CMStringW &res)
+void CJabberProto::FormatMirVer(const pResourceStatus &resource, CMStringA &res)
{
res.Empty();
if (resource == nullptr)
@@ -292,48 +292,48 @@ void CJabberProto::FormatMirVer(const pResourceStatus &resource, CMStringW &res)
// no caps info? set MirVer = resource name
if (resource->m_pCaps == nullptr) {
- debugLogW(L"JabberUpdateMirVer: for rc %s: %s", resource->m_tszResourceName, resource->m_tszResourceName);
- if (resource->m_tszResourceName)
- res = resource->m_tszResourceName;
+ debugLogA("JabberUpdateMirVer: for rc %s: %s", resource->m_szResourceName, resource->m_szResourceName);
+ if (resource->m_szResourceName)
+ res = resource->m_szResourceName;
}
// XEP-0115 caps mode
else {
CJabberClientPartialCaps *pCaps = resource->m_pCaps;
- debugLogW(L"JabberUpdateMirVer: for rc %s: %s#%s", resource->m_tszResourceName, pCaps->GetNode(), pCaps->GetHash());
+ debugLogA("JabberUpdateMirVer: for rc %s: %s#%s", resource->m_szResourceName, pCaps->GetNode(), pCaps->GetHash());
// unknown software
- const wchar_t *szDefaultName = GetSoftName(pCaps->GetNode());
+ const char *szDefaultName = GetSoftName(pCaps->GetNode());
res = (szDefaultName == nullptr) ? pCaps->GetSoft() : szDefaultName;
if (pCaps->GetSoftVer())
- res.AppendFormat(L" %s", pCaps->GetSoftVer());
+ res.AppendFormat(" %s", pCaps->GetSoftVer());
if (pCaps->GetSoftMir())
- res.AppendFormat(L" %s", pCaps->GetSoftMir());
+ res.AppendFormat(" %s", pCaps->GetSoftMir());
}
// attach additional info for fingerprint plguin
if (resource->m_tszCapsExt) {
- if (wcsstr(resource->m_tszCapsExt, JABBER_EXT_PLATFORMX86) && !wcsstr(res, L"x86"))
- res.Append(L" x86");
+ if (strstr(resource->m_tszCapsExt, JABBER_EXT_PLATFORMX86) && !strstr(res, "x86"))
+ res.Append(" x86");
- if (wcsstr(resource->m_tszCapsExt, JABBER_EXT_PLATFORMX64) && !wcsstr(res, L"x64"))
- res.Append(L" x64");
+ if (strstr(resource->m_tszCapsExt, JABBER_EXT_PLATFORMX64) && !strstr(res, "x64"))
+ res.Append(" x64");
- if (wcsstr(resource->m_tszCapsExt, JABBER_EXT_SECUREIM) && !wcsstr(res, L"(SecureIM)"))
- res.Append(L" (SecureIM)");
+ if (strstr(resource->m_tszCapsExt, JABBER_EXT_SECUREIM) && !strstr(res, "(SecureIM)"))
+ res.Append(" (SecureIM)");
- if (wcsstr(resource->m_tszCapsExt, JABBER_EXT_MIROTR) && !wcsstr(res, L"(MirOTR)"))
- res.Append(L" (MirOTR)");
+ if (strstr(resource->m_tszCapsExt, JABBER_EXT_MIROTR) && !strstr(res, "(MirOTR)"))
+ res.Append(" (MirOTR)");
- if (wcsstr(resource->m_tszCapsExt, JABBER_EXT_NEWGPG) && !wcsstr(res, L"(New_GPG)"))
- res.Append(L" (New_GPG)");
+ if (strstr(resource->m_tszCapsExt, JABBER_EXT_NEWGPG) && !strstr(res, "(New_GPG)"))
+ res.Append(" (New_GPG)");
- if (wcsstr(resource->m_tszCapsExt, JABBER_EXT_OMEMO) && !wcsstr(res, L"(omemo)"))
- res.Append(L" (omemo)");
+ if (strstr(resource->m_tszCapsExt, JABBER_EXT_OMEMO) && !strstr(res, "(omemo)"))
+ res.Append(" (omemo)");
}
- if (resource->m_tszResourceName && !wcsstr(res, resource->m_tszResourceName))
- if (wcsstr(res, L"Miranda IM") || wcsstr(res, L"Miranda NG") || m_bShowForeignResourceInMirVer)
- res.AppendFormat(L" [%s]", resource->m_tszResourceName);
+ if (resource->m_szResourceName && !strstr(res, resource->m_szResourceName))
+ if (strstr(res, "Miranda IM") || strstr(res, "Miranda NG") || m_bShowForeignResourceInMirVer)
+ res.AppendFormat(" [%s]", resource->m_szResourceName);
}
void CJabberProto::UpdateMirVer(MCONTACT hContact, const pResourceStatus &r)
@@ -341,21 +341,21 @@ void CJabberProto::UpdateMirVer(MCONTACT hContact, const pResourceStatus &r)
if (r == nullptr)
return;
- CMStringW tszMirVer;
+ CMStringA tszMirVer;
FormatMirVer(r, tszMirVer);
if (!tszMirVer.IsEmpty())
- setWString(hContact, "MirVer", tszMirVer);
+ setUString(hContact, "MirVer", tszMirVer);
- ptrW jid(getWStringA(hContact, "jid"));
+ ptrA jid(getUStringA(hContact, "jid"));
if (jid == nullptr)
return;
- wchar_t szFullJid[JABBER_MAX_JID_LEN];
- if (r->m_tszResourceName && !wcschr(jid, '/'))
- mir_snwprintf(szFullJid, L"%s/%s", jid, r->m_tszResourceName);
+ char szFullJid[JABBER_MAX_JID_LEN];
+ if (r->m_szResourceName && !strchr(jid, '/'))
+ mir_snprintf(szFullJid, "%s/%s", jid, r->m_szResourceName);
else
- mir_wstrncpy(szFullJid, jid, _countof(szFullJid));
- setWString(hContact, DBSETTING_DISPLAY_UID, szFullJid);
+ mir_strncpy(szFullJid, jid, _countof(szFullJid));
+ setUString(hContact, DBSETTING_DISPLAY_UID, szFullJid);
}
void CJabberProto::UpdateSubscriptionInfo(MCONTACT hContact, JABBER_LIST_ITEM *item)
@@ -443,28 +443,28 @@ void CJabberProto::MsgPopup(MCONTACT hContact, const wchar_t *szMsg, const wchar
}
}
-CMStringW CJabberProto::ExtractImage(HXML node)
+CMStringA CJabberProto::ExtractImage(const TiXmlElement *node)
{
- HXML nHtml, nBody, nImg;
- const wchar_t *src;
- CMStringW link;
-
- if ((nHtml = XmlGetChild(node, "html")) != nullptr &&
- (nBody = XmlGetChild(nHtml, "body")) != nullptr &&
- (nImg = XmlGetChild(nBody, "img")) != nullptr &&
- (src = XmlGetAttrValue(nImg, L"src")) != nullptr) {
-
- CMStringW strSrc(src);
- if (strSrc.Left(11).Compare(L"data:image/") == 0) {
- int end = strSrc.Find(L';');
+ const TiXmlElement *nHtml, *nBody, *nImg;
+ const char *src;
+ CMStringA link;
+
+ if ((nHtml = node->FirstChildElement("html")) != nullptr &&
+ (nBody = nHtml->FirstChildElement("body")) != nullptr &&
+ (nImg = nBody->FirstChildElement("img")) != nullptr &&
+ (src = nImg->Attribute("src")) != nullptr) {
+
+ CMStringA strSrc(src);
+ if (strSrc.Left(11).Compare("data:image/") == 0) {
+ int end = strSrc.Find(';');
if (end != -1) {
CMStringW ext(strSrc.c_str() + 11, end - 11);
int comma = strSrc.Find(L',', end);
if (comma != -1) {
- CMStringW image(strSrc.c_str() + comma + 1, strSrc.GetLength() - comma - 1);
- image.Replace(L"%2B", L"+");
- image.Replace(L"%2F", L"/");
- image.Replace(L"%3D", L"=");
+ CMStringA image(strSrc.c_str() + comma + 1, strSrc.GetLength() - comma - 1);
+ image.Replace("%2B", "+");
+ image.Replace("%2F", "/");
+ image.Replace("%3D", "=");
wchar_t tszTempPath[MAX_PATH], tszTempFile[MAX_PATH];
GetTempPath(_countof(tszTempPath), tszTempPath);
@@ -479,12 +479,12 @@ CMStringW CJabberProto::ExtractImage(HXML node)
if (h != INVALID_HANDLE_VALUE) {
DWORD n;
size_t bufferLen;
- ptrA buffer((char*)mir_base64_decode(_T2A(image), &bufferLen));
+ ptrA buffer((char*)mir_base64_decode(image, &bufferLen));
WriteFile(h, buffer, (DWORD)bufferLen, &n, nullptr);
CloseHandle(h);
- link = L" file:///";
- link += tszTempFile;
+ link = " file:///";
+ link += T2Utf(tszTempFile);
}
}
}
diff --git a/protocols/JabberG/src/jabber_notes.cpp b/protocols/JabberG/src/jabber_notes.cpp
index 2639959020..dea6a774e8 100644
--- a/protocols/JabberG/src/jabber_notes.cpp
+++ b/protocols/JabberG/src/jabber_notes.cpp
@@ -31,36 +31,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "jabber_privacy.h"
#include "jabber_notes.h"
-static wchar_t* StrTrimCopy(wchar_t *str)
-{
- if (!str) return nullptr;
- while (*str && iswspace(*str)) ++str;
- if (!*str) return mir_wstrdup(str);
-
- wchar_t *res = mir_wstrdup(str);
- for (wchar_t *p = res + mir_wstrlen(res) - 1; p >= res; --p) {
- if (iswspace(*p))
- *p = 0;
- else
- break;
- }
-
- return res;
-}
-
CNoteItem::CNoteItem()
{
- m_szTitle = m_szFrom = m_szText = m_szTags = m_szTagsStr = nullptr;
}
-CNoteItem::CNoteItem(HXML hXml, wchar_t *szFrom)
+CNoteItem::CNoteItem(const TiXmlElement *hXml, const char *szFrom)
{
- m_szTitle = m_szFrom = m_szText = m_szTags = m_szTagsStr = nullptr;
SetData(
- XPathT(hXml, "title"),
- szFrom ? szFrom : XPathT(hXml, "@from"),
- XPathT(hXml, "text"),
- XPathT(hXml, "@tags"));
+ XPath(hXml, "title"),
+ szFrom ? szFrom : XPath(hXml, "@from"),
+ Utf2T(XPath(hXml, "text")),
+ XPath(hXml, "@tags"));
}
CNoteItem::~CNoteItem()
@@ -72,7 +53,7 @@ CNoteItem::~CNoteItem()
mir_free(m_szTagsStr);
}
-void CNoteItem::SetData(wchar_t *title, wchar_t *from, wchar_t *text, wchar_t *tags)
+void CNoteItem::SetData(const char *title, const char *from, const wchar_t*text, const char *tags)
{
mir_free(m_szTitle);
mir_free(m_szFrom);
@@ -80,15 +61,15 @@ void CNoteItem::SetData(wchar_t *title, wchar_t *from, wchar_t *text, wchar_t *t
mir_free(m_szTags);
mir_free(m_szTagsStr);
- m_szTitle = StrTrimCopy(title);
+ m_szTitle = rtrim(mir_strdup(title));
m_szText = JabberStrFixLines(text);
- m_szFrom = StrTrimCopy(from);
+ m_szFrom = rtrim(mir_strdup(from));
- const wchar_t *szTags = tags;
- wchar_t *p = m_szTags = (wchar_t *)mir_alloc((mir_wstrlen(szTags) + 2 /*for double zero*/) * sizeof(wchar_t));
- wchar_t *q = m_szTagsStr = (wchar_t *)mir_alloc((mir_wstrlen(szTags) + 1) * sizeof(wchar_t));
+ auto *szTags = tags;
+ auto *p = m_szTags = (char *)mir_alloc(mir_strlen(szTags) + 2);
+ auto *q = m_szTagsStr = (char *)mir_alloc(mir_strlen(szTags) + 1);
for (; szTags && *szTags; ++szTags) {
- if (iswspace(*szTags))
+ if (isspace(*szTags))
continue;
if (*szTags == ',') {
@@ -103,13 +84,13 @@ void CNoteItem::SetData(wchar_t *title, wchar_t *from, wchar_t *text, wchar_t *t
q[0] = p[0] = p[1] = 0;
}
-bool CNoteItem::HasTag(const wchar_t *szTag)
+bool CNoteItem::HasTag(const char *szTag)
{
if (!szTag || !*szTag)
return true;
- for (wchar_t *p = m_szTags; p && *p; p = p + mir_wstrlen(p) + 1)
- if (!mir_wstrcmp(p, szTag))
+ for (auto *p = m_szTags; p && *p; p = p + mir_strlen(p) + 1)
+ if (!mir_strcmp(p, szTag))
return true;
return false;
@@ -118,28 +99,27 @@ bool CNoteItem::HasTag(const wchar_t *szTag)
int CNoteItem::cmp(const CNoteItem *p1, const CNoteItem *p2)
{
int ret = 0;
- if (ret = mir_wstrcmp(p1->m_szTitle, p2->m_szTitle)) return ret;
+ if (ret = mir_strcmp(p1->m_szTitle, p2->m_szTitle)) return ret;
if (ret = mir_wstrcmp(p1->m_szText, p2->m_szText)) return ret;
- if (ret = mir_wstrcmp(p1->m_szTagsStr, p2->m_szTagsStr)) return ret;
+ if (ret = mir_strcmp(p1->m_szTagsStr, p2->m_szTagsStr)) return ret;
if (p1 < p2) return -1;
if (p1 > p2) return 1;
return 0;
}
-void CNoteList::AddNote(HXML hXml, wchar_t *szFrom)
+void CNoteList::AddNote(TiXmlElement *hXml, const char *szFrom)
{
m_bIsModified = true;
insert(new CNoteItem(hXml, szFrom));
}
-void CNoteList::LoadXml(HXML hXml)
+void CNoteList::LoadXml(const TiXmlElement *hXml)
{
destroy();
m_bIsModified = false;
- int iCount = XmlGetChildCount(hXml);
- for (int i = 0; i < iCount; i++) {
- CNoteItem *pNote = new CNoteItem(xmlGetChild(hXml, i));
+ for (auto *it : TiXmlEnum(hXml)) {
+ CNoteItem *pNote = new CNoteItem(it);
if (pNote->IsNotEmpty())
insert(pNote);
else
@@ -147,15 +127,15 @@ void CNoteList::LoadXml(HXML hXml)
}
}
-void CNoteList::SaveXml(HXML hXmlParent)
+void CNoteList::SaveXml(TiXmlElement *hXmlParent)
{
m_bIsModified = false;
for (auto &it : *this) {
- HXML hXmlItem = hXmlParent << XCHILD(L"note");
- hXmlItem << XATTR(L"from", it->GetFrom()) << XATTR(L"tags", it->GetTagsStr());
- hXmlItem << XCHILD(L"title", it->GetTitle());
- hXmlItem << XCHILD(L"text", it->GetText());
+ TiXmlElement *hXmlItem = hXmlParent << XCHILD("note");
+ hXmlItem << XATTR("from", it->GetFrom()) << XATTR("tags", it->GetTagsStr());
+ hXmlItem << XCHILD("title", it->GetTitle());
+ hXmlItem << XCHILD("text", T2Utf(it->GetText()));
}
}
@@ -186,15 +166,9 @@ private:
void btnOk_OnClick(CCtrlButton *)
{
- wchar_t *szTitle = m_txtTitle.GetText();
- wchar_t *szText = m_txtText.GetText();
- wchar_t *szTags = m_txtTags.GetText();
- wchar_t *szFrom = mir_wstrdup(m_pNote->GetFrom());
- m_pNote->SetData(szTitle, szFrom, szText, szTags);
- mir_free(szTitle);
- mir_free(szText);
- mir_free(szTags);
- mir_free(szFrom);
+ T2Utf szTitle(ptrW(m_txtTitle.GetText()));
+ T2Utf szTags(ptrW(m_txtTags.GetText()));
+ m_pNote->SetData(szTitle, m_pNote->GetFrom(), ptrW(m_txtText.GetText()), szTags);
m_autoClose = false;
if (m_fnProcess) (m_proto->*m_fnProcess)(m_pNote, true);
@@ -249,9 +223,9 @@ bool CJabberDlgNoteItem::OnInitDialog()
SetWindowText(m_hwnd, buf);
}
- m_txtTitle.SetText(m_pNote->GetTitle());
+ m_txtTitle.SetText(Utf2T(m_pNote->GetTitle()));
m_txtText.SetText(m_pNote->GetText());
- m_txtTags.SetText(m_pNote->GetTagsStr());
+ m_txtTags.SetText(Utf2T(m_pNote->GetTagsStr()));
return true;
}
@@ -372,7 +346,7 @@ public:
rc.top += 2;
SelectObject(hdc, m_hfntBold);
- rc.top += DrawText(hdc, pNote->GetTitle(), -1, &rc, DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
+ rc.top += DrawText(hdc, Utf2T(pNote->GetTitle()), -1, &rc, DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
SelectObject(hdc, m_hfntNormal);
if (pNote->GetFrom()) {
wchar_t buf[256];
@@ -381,7 +355,7 @@ public:
}
rc.top += DrawText(hdc, pNote->GetText(), -1, &rc, DT_NOPREFIX | DT_WORDBREAK | DT_EXPANDTABS | DT_END_ELLIPSIS);
SelectObject(hdc, m_hfntSmall);
- rc.top += DrawText(hdc, pNote->GetTagsStr(), -1, &rc, DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
+ rc.top += DrawText(hdc, Utf2T(pNote->GetTagsStr()), -1, &rc, DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
rc.top += 5;
int h = min(255, max(0, rc.bottom - rc.top));
@@ -406,7 +380,7 @@ public:
SelectObject(hdc, m_hfntBold);
rcTmp = rc;
- DrawText(hdc, pNote->GetTitle(), -1, &rcTmp, DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS | DT_CALCRECT);
+ DrawText(hdc, Utf2T(pNote->GetTitle()), -1, &rcTmp, DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS | DT_CALCRECT);
lps->itemHeight += rcTmp.bottom;
SelectObject(hdc, m_hfntNormal);
if (pNote->GetFrom()) {
@@ -421,7 +395,7 @@ public:
lps->itemHeight += rcTmp.bottom;
SelectObject(hdc, m_hfntSmall);
rcTmp = rc;
- DrawText(hdc, pNote->GetTagsStr(), -1, &rcTmp, DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS | DT_CALCRECT);
+ DrawText(hdc, Utf2T(pNote->GetTagsStr()), -1, &rcTmp, DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS | DT_CALCRECT);
lps->itemHeight += rcTmp.bottom;
lps->itemHeight += 5;
@@ -467,31 +441,33 @@ private:
m_btnRemove.Enable(m_lstNotes.GetCurSel() != LB_ERR);
}
- void InsertTag(HTREEITEM htiRoot, const wchar_t *tag, bool bSelect)
+ void InsertTag(HTREEITEM htiRoot, const char *tag, bool bSelect)
{
+ Utf2T wszTag(tag);
+
TVINSERTSTRUCT tvi = {};
tvi.hParent = htiRoot;
tvi.hInsertAfter = TVI_LAST;
tvi.itemex.mask = TVIF_TEXT | TVIF_PARAM;
- tvi.itemex.pszText = (wchar_t *)tag;
- tvi.itemex.lParam = (LPARAM)mir_wstrdup(tag);
+ tvi.itemex.pszText = wszTag;
+ tvi.itemex.lParam = (LPARAM)mir_strdup(tag);
HTREEITEM hti = m_tvFilter.InsertItem(&tvi);
if (bSelect) m_tvFilter.SelectItem(hti);
}
- void PopulateTags(HTREEITEM htiRoot, wchar_t *szActiveTag)
+ void PopulateTags(HTREEITEM htiRoot, const char *szActiveTag)
{
- LIST<wchar_t> tagSet(5, wcscmp);
+ LIST<char> tagSet(5, strcmp);
for (auto &it : m_proto->m_notes) {
- wchar_t *tags = it->GetTags();
- for (wchar_t *tag = tags; tag && *tag; tag = tag + mir_wstrlen(tag) + 1)
+ char *tags = it->GetTags();
+ for (auto *tag = tags; tag && *tag; tag = tag + mir_strlen(tag) + 1)
if (!tagSet.find(tag))
tagSet.insert(tag);
}
bool selected = false;
for (auto &it : tagSet) {
- bool select = !mir_wstrcmp(szActiveTag, it);
+ bool select = !mir_strcmp(szActiveTag, it);
selected |= select;
InsertTag(htiRoot, it, select);
}
@@ -506,7 +482,7 @@ private:
tvi.mask = TVIF_HANDLE | TVIF_PARAM;
tvi.hItem = m_tvFilter.GetSelection();
m_tvFilter.GetItem(&tvi);
- wchar_t *szActiveTag = mir_wstrdup((wchar_t *)tvi.lParam);
+ char *szActiveTag = mir_strdup((char*)tvi.lParam);
m_tvFilter.DeleteAllItems();
@@ -526,7 +502,7 @@ private:
EnableControls();
}
- void ListItems(const wchar_t *tag)
+ void ListItems(const char *tag)
{
m_lstNotes.ResetContent();
for (auto &it : m_proto->m_notes)
@@ -588,23 +564,23 @@ private:
void tvFilter_OnDeleteItem(CCtrlTreeView::TEventInfo *e)
{
- wchar_t *szText = (wchar_t *)e->nmtv->itemOld.lParam;
+ char *szText = (char*)e->nmtv->itemNew.lParam;
mir_free(szText);
EnableControls();
}
void tvFilter_OnSelChanged(CCtrlTreeView::TEventInfo *e)
{
- wchar_t *szText = (wchar_t *)e->nmtv->itemNew.lParam;
+ char *szText = (char*)e->nmtv->itemNew.lParam;
ListItems(szText);
EnableControls();
}
void btnSave_OnClick(CCtrlButton *)
{
- XmlNodeIq iq(L"set");
- HXML query = iq << XQUERY(JABBER_FEAT_PRIVATE_STORAGE);
- HXML storage = query << XCHILDNS(L"storage", JABBER_FEAT_MIRANDA_NOTES);
+ XmlNodeIq iq("set");
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_PRIVATE_STORAGE);
+ TiXmlElement *storage = query << XCHILDNS("storage", JABBER_FEAT_MIRANDA_NOTES);
m_proto->m_notes.SaveXml(storage);
m_proto->m_ThreadInfo->send(iq);
EnableControls();
@@ -709,9 +685,9 @@ void CJabberProto::ProcessIncomingNote(CNoteItem *pNote, bool ok)
if (ok && pNote->IsNotEmpty()) {
m_notes.insert(pNote);
- XmlNodeIq iq(L"set");
- HXML query = iq << XQUERY(JABBER_FEAT_PRIVATE_STORAGE);
- HXML storage = query << XCHILDNS(L"storage", JABBER_FEAT_MIRANDA_NOTES);
+ XmlNodeIq iq("set");
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_PRIVATE_STORAGE);
+ TiXmlElement *storage = query << XCHILDNS("storage", JABBER_FEAT_MIRANDA_NOTES);
m_notes.SaveXml(storage);
m_ThreadInfo->send(iq);
}
@@ -725,9 +701,8 @@ void CJabberProto::ProcessOutgoingNote(CNoteItem *pNote, bool ok)
return;
}
- wchar_t buf[1024];
- mir_snwprintf(buf, L"Incoming note: %s\n\n%s\nTags: %s",
- pNote->GetTitle(), pNote->GetText(), pNote->GetTagsStr());
+ char buf[1024];
+ mir_snprintf(buf, "Incoming note: %s\n\n%s\nTags: %s", pNote->GetTitle(), pNote->GetText(), pNote->GetTagsStr());
JabberCapsBits jcb = GetResourceCapabilities(pNote->GetFrom());
@@ -736,20 +711,20 @@ void CJabberProto::ProcessOutgoingNote(CNoteItem *pNote, bool ok)
int nMsgId = SerialNext();
- XmlNode m(L"message");
- m << XATTR(L"type", L"chat") << XATTR(L"to", pNote->GetFrom()) << XATTRID(nMsgId);
- m << XCHILD(L"body", buf);
- HXML hXmlItem = m << XCHILDNS(L"x", JABBER_FEAT_MIRANDA_NOTES) << XCHILD(L"note");
- hXmlItem << XATTR(L"tags", pNote->GetTagsStr());
- hXmlItem << XCHILD(L"title", pNote->GetTitle());
- hXmlItem << XCHILD(L"text", pNote->GetText());
+ XmlNode m("message");
+ m << XATTR("type", "chat") << XATTR("to", pNote->GetFrom()) << XATTRID(nMsgId);
+ m << XCHILD("body", buf);
+ TiXmlElement *hXmlItem = m << XCHILDNS("x", JABBER_FEAT_MIRANDA_NOTES) << XCHILD("note");
+ hXmlItem << XATTR("tags", pNote->GetTagsStr());
+ hXmlItem << XCHILD("title", pNote->GetTitle());
+ hXmlItem << XCHILD("text", T2Utf(pNote->GetText()));
// message receipts XEP priority
if (jcb & JABBER_CAPS_MESSAGE_RECEIPTS)
- m << XCHILDNS(L"request", JABBER_FEAT_MESSAGE_RECEIPTS);
+ m << XCHILDNS("request", JABBER_FEAT_MESSAGE_RECEIPTS);
else if (jcb & JABBER_CAPS_MESSAGE_EVENTS) {
- HXML x = m << XCHILDNS(L"x", JABBER_FEAT_MESSAGE_EVENTS);
- x << XCHILD(L"delivered"); x << XCHILD(L"offline");
+ TiXmlElement *x = m << XCHILDNS("x", JABBER_FEAT_MESSAGE_EVENTS);
+ x << XCHILD("delivered"); x << XCHILD("offline");
}
else
nMsgId = -1;
@@ -758,13 +733,13 @@ void CJabberProto::ProcessOutgoingNote(CNoteItem *pNote, bool ok)
delete pNote;
}
-bool CJabberProto::OnIncomingNote(const wchar_t *szFrom, HXML hXml)
+bool CJabberProto::OnIncomingNote(const char *szFrom, const TiXmlElement *hXml)
{
if (!m_bAcceptNotes)
return false;
if (!szFrom || !hXml) return true;
- CNoteItem *pItem = new CNoteItem(hXml, (wchar_t *)szFrom);
+ CNoteItem *pItem = new CNoteItem(hXml, szFrom);
if (!pItem->IsNotEmpty()) {
delete pItem;
return true;
@@ -814,7 +789,7 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleNotes(WPARAM, LPARAM)
INT_PTR __cdecl CJabberProto::OnMenuSendNote(WPARAM wParam, LPARAM)
{
if (wParam) {
- CNoteItem *pItem = new CNoteItem(nullptr, ptrW(getWStringA(wParam, "jid")));
+ CNoteItem *pItem = new CNoteItem(nullptr, ptrA(getUStringA(wParam, "jid")));
CJabberDlgBase *pDlg = new CJabberDlgNoteItem(this, pItem, &CJabberProto::ProcessOutgoingNote);
pDlg->Show();
}
diff --git a/protocols/JabberG/src/jabber_notes.h b/protocols/JabberG/src/jabber_notes.h
index c501a501b0..c2867970b3 100644
--- a/protocols/JabberG/src/jabber_notes.h
+++ b/protocols/JabberG/src/jabber_notes.h
@@ -30,26 +30,27 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
class CNoteItem
{
private:
- wchar_t *m_szTitle;
- wchar_t *m_szFrom;
- wchar_t *m_szText;
- wchar_t *m_szTags;
- wchar_t *m_szTagsStr;
+ char *m_szTitle = 0;
+ char *m_szFrom = 0;
+ char *m_szTags = 0;
+ char *m_szTagsStr = 0;
+
+ wchar_t *m_szText = 0;
public:
CNoteItem();
- CNoteItem(HXML hXml, wchar_t *szFrom = nullptr);
+ CNoteItem(const TiXmlElement *hXml, const char *szFrom = nullptr);
~CNoteItem();
- void SetData(wchar_t *title, wchar_t *from, wchar_t *text, wchar_t *tags);
+ void SetData(const char *title, const char *from, const wchar_t *text, const char *tags);
- wchar_t *GetTitle() const { return m_szTitle; }
- wchar_t *GetFrom() const { return m_szFrom; }
- wchar_t *GetText() const { return m_szText; }
- wchar_t *GetTags() const { return m_szTags; }
- wchar_t *GetTagsStr() const { return m_szTagsStr; }
+ char* GetTitle() const { return m_szTitle; }
+ char* GetFrom() const { return m_szFrom; }
+ char* GetTags() const { return m_szTags; }
+ char* GetTagsStr() const { return m_szTagsStr; }
+ wchar_t* GetText() const { return m_szText; }
- bool HasTag(const wchar_t *szTag);
+ bool HasTag(const char *szTag);
bool IsNotEmpty()
{
@@ -76,9 +77,9 @@ public:
OBJLIST<CNoteItem>::remove(p);
}
- void AddNote(HXML hXml, wchar_t *szFrom = nullptr);
- void LoadXml(HXML hXml);
- void SaveXml(HXML hXmlParent);
+ void AddNote(TiXmlElement *hXml, const char *szFrom = nullptr);
+ void LoadXml(const TiXmlElement *hXml);
+ void SaveXml(TiXmlElement *hXmlParent);
bool IsModified() { return m_bIsModified; }
void Modify() { m_bIsModified = true; }
diff --git a/protocols/JabberG/src/jabber_omemo.cpp b/protocols/JabberG/src/jabber_omemo.cpp
index 70f8cbd50b..2d07e25ccd 100755
--- a/protocols/JabberG/src/jabber_omemo.cpp
+++ b/protocols/JabberG/src/jabber_omemo.cpp
@@ -372,16 +372,16 @@ complete:
signal_context *global_context = nullptr;
- struct incomming_message
+ struct incoming_message
{
- incomming_message(HXML x, wchar_t *j, time_t t)
+ incoming_message(TiXmlElement *x, char *j, time_t t)
{
node = x;
jid = j;
msgTime = t;
}
- HXML node;
- wchar_t *jid;
+ TiXmlElement *node;
+ char *jid;
time_t msgTime;
};
@@ -1226,12 +1226,10 @@ complete:
}
//void(*destroy_func)(void *user_data); //use first one as we have nothing special to destroy
- bool omemo_impl::create_session_store(MCONTACT hContact, const wchar_t *device_id)
+ bool omemo_impl::create_session_store(MCONTACT hContact, const char *device_id)
{
signal_store_backend_user_data *data[4];
- char *device_id_a = mir_u2a(device_id);
- DWORD device_id_int = strtoul(device_id_a, nullptr, 10);
- mir_free(device_id_a);
+ DWORD device_id_int = strtoul(device_id, nullptr, 10);
for (int i = 0; i < 4; i++) {
data[i] = (signal_store_backend_user_data*)mir_alloc(sizeof(signal_store_backend_user_data));
data[i]->hContact = hContact;
@@ -1281,21 +1279,18 @@ complete:
return true; //success
}
- bool omemo_impl::build_session(MCONTACT hContact, const wchar_t *jid, const wchar_t *dev_id, const wchar_t *key_id, const wchar_t *pre_key_public, const wchar_t *signed_pre_key_id,
- const wchar_t *signed_pre_key_public, const wchar_t *signed_pre_key_signature, const wchar_t *identity_key)
+ bool omemo_impl::build_session(MCONTACT hContact, const char *jid, const char *dev_id, const char *key_id, const char *pre_key_public, const char *signed_pre_key_id,
+ const char *signed_pre_key_public, const char *signed_pre_key_signature, const char *identity_key)
{
// Instantiate a session_builder for a recipient address.
- char *jid_str = mir_u2a(jid);
- char *dev_id_a = mir_u2a(dev_id);
- DWORD dev_id_int = strtoul(dev_id_a, nullptr, 10);
- mir_free(dev_id_a);
+ DWORD dev_id_int = strtoul(dev_id, nullptr, 10);
// libsignal does not copy structure, so we must allocate one manually, does it free it on exit ?
signal_protocol_address *address = (signal_protocol_address*)mir_alloc(sizeof(signal_protocol_address));
// rotten compillers support
- address->name = jid_str; // will libsignal free arrav for us on exit ?
- address->name_len = mir_strlen(jid_str);
+ address->name = jid; // will libsignal free arrav for us on exit ?
+ address->name_len = mir_strlen(jid);
address->device_id = dev_id_int;
session_builder *builder;
@@ -1306,37 +1301,33 @@ complete:
sessions[hContact][dev_id_int].builder = builder;
- unsigned int key_id_int = _wtoi(key_id);
+ unsigned int key_id_int = atoi(key_id);
- char *pre_key_a = mir_u2a(pre_key_public);
size_t key_buf_len;
- uint8_t *key_buf = (uint8_t*)mir_base64_decode(pre_key_a, &key_buf_len);
+ uint8_t *key_buf = (uint8_t*)mir_base64_decode(pre_key_public, &key_buf_len);
ec_public_key *prekey;
if (curve_decode_point(&prekey, key_buf, key_buf_len, global_context)) {
proto->debugLogA("Jabber OMEMO: error: curve_decode_point failed to parse prekey");
return false; //TODO: cleanup
}
- mir_free(pre_key_a);
mir_free(key_buf);
- unsigned int signed_pre_key_id_int = _wtoi(signed_pre_key_id);
- pre_key_a = mir_u2a(signed_pre_key_public);
- key_buf = (uint8_t*)mir_base64_decode(pre_key_a, &key_buf_len);
+
+ unsigned int signed_pre_key_id_int = atoi(signed_pre_key_id);
+ key_buf = (uint8_t*)mir_base64_decode(signed_pre_key_public, &key_buf_len);
ec_public_key *signed_prekey;
if (curve_decode_point(&signed_prekey, key_buf, key_buf_len, global_context)) {
proto->debugLogA("Jabber OMEMO: error: curve_decode_point failed to parse signed prekey");
return false; // TODO: cleanup
}
- mir_free(pre_key_a);
mir_free(key_buf); // TODO: check this
- //load identity key
+
+ // load identity key
ec_public_key *identity_key_p;
- pre_key_a = mir_u2a(identity_key);
- key_buf = (uint8_t*)mir_base64_decode(pre_key_a, &key_buf_len);
+ key_buf = (uint8_t*)mir_base64_decode(identity_key, &key_buf_len);
if (curve_decode_point(&identity_key_p, key_buf, key_buf_len, global_context)) {
proto->debugLogA("Jabber OMEMO: error: curve_decode_point failed to parse identity key");
return false; // TODO: cleanup
}
- mir_free(pre_key_a);
mir_free(key_buf); // TODO: check this
bool fp_trusted = false;
{
@@ -1373,14 +1364,11 @@ complete:
return false; //TODO: cleanup here
}
- pre_key_a = mir_u2a(signed_pre_key_signature);
- key_buf = (uint8_t*)mir_base64_decode(pre_key_a, &key_buf_len);
- mir_free(pre_key_a);
+ key_buf = (uint8_t*)mir_base64_decode(signed_pre_key_signature, &key_buf_len);
session_pre_key_bundle *retrieved_pre_key;
- uint32_t *registration_id = (uint32_t*)mir_alloc(sizeof(uint32_t)); //let's create some momory leak...
- *registration_id = 0;
- signal_protocol_identity_get_local_registration_id(sessions[hContact][dev_id_int].store_context, registration_id);
- session_pre_key_bundle_create(&retrieved_pre_key, *registration_id, dev_id_int, key_id_int, prekey, signed_pre_key_id_int, signed_prekey, key_buf, key_buf_len, identity_key_p);
+ uint32_t registration_id = 0;
+ signal_protocol_identity_get_local_registration_id(sessions[hContact][dev_id_int].store_context, &registration_id);
+ session_pre_key_bundle_create(&retrieved_pre_key, registration_id, dev_id_int, key_id_int, prekey, signed_pre_key_id_int, signed_prekey, key_buf, key_buf_len, identity_key_p);
mir_free(key_buf);
/* Build a session with a pre key retrieved from the server. */
@@ -1465,11 +1453,10 @@ void CJabberProto::OmemoPutMessageToOutgoingQueue(MCONTACT hContact, int unused_
m_omemo.outgoing_messages.push_back(omemo::outgoing_message(hContact, unused_unknown, msg));
}
-void CJabberProto::OmemoPutMessageToIncommingQueue(HXML node, const wchar_t *jid, time_t msgTime)
+void CJabberProto::OmemoPutMessageToIncommingQueue(const TiXmlElement *node, const char *jid, time_t msgTime)
{
- wchar_t *jid_ = mir_wstrdup(jid);
- HXML node_ = xmlCopyNode(node);
- m_omemo.incoming_messages.push_back(omemo::incomming_message(node_, jid_, msgTime));
+ TiXmlElement *node_ = node->DeepClone(&m_omemo.doc)->ToElement();
+ m_omemo.incoming_messages.push_back(omemo::incoming_message(node_, mir_strdup(jid), msgTime));
}
void CJabberProto::OmemoHandleMessageQueue()
@@ -1479,53 +1466,52 @@ void CJabberProto::OmemoHandleMessageQueue()
mir_free(i.pszSrc);
}
m_omemo.outgoing_messages.clear();
- std::list<omemo::incomming_message> tmp = m_omemo.incoming_messages;
+ std::list<omemo::incoming_message> tmp = m_omemo.incoming_messages;
m_omemo.incoming_messages.clear();
for (auto &i : tmp) {
if (!OmemoHandleMessage(i.node, i.jid, i.msgTime))
OmemoPutMessageToIncommingQueue(i.node, i.jid, i.msgTime);
- xmlFree(i.node);
+
+ m_omemo.doc.DeleteNode(i.node);
mir_free(i.jid);
}
}
DWORD JabberGetLastContactMessageTime(MCONTACT hContact);
-bool CJabberProto::OmemoHandleMessage(HXML node, wchar_t *jid, time_t msgTime)
+bool CJabberProto::OmemoHandleMessage(const TiXmlElement *node, const char *jid, time_t msgTime)
{
MCONTACT hContact = HContactFromJID(jid);
if (!OmemoCheckSession(hContact)) {
debugLogA("Jabber OMEMO: sessions not yet created, session creation launched");
return false;
}
- HXML header_node = XmlGetChild(node, L"header");
+ auto *header_node = node->FirstChildElement("header");
if (!header_node) {
debugLogA("Jabber OMEMO: error: omemo message does not contain header");
return true; //this should never happen
}
- HXML payload_node = XmlGetChild(node, L"payload");
+ auto *payload_node = node->FirstChildElement("payload");
if (!payload_node) {
debugLogA("Jabber OMEMO: omemo message does not contain payload, it's may be \"KeyTransportElement\" which is currently unused by our implementation");
return true; //this is "KeyTransportElement" which is currently unused
}
- const wchar_t *payload_base64w = XmlGetText(payload_node);
+ const char *payload_base64w = payload_node->GetText();
if (!payload_base64w) {
debugLogA("Jabber OMEMO: error: failed to get payload data");
return true; //this should never happen
}
- const wchar_t *iv_base64 = XmlGetText(XmlGetChild(header_node, L"iv"));
+ const char *iv_base64 = header_node->FirstChildElement("iv")->GetText();
if (!iv_base64) {
Netlib_Log(nullptr, "Jabber OMEMO: error: failed to get iv data");
return true;
}
- const wchar_t *sender_dev_id = XmlGetAttrValue(header_node, L"sid");
+ const char *sender_dev_id = header_node->Attribute("sid");
if (!sender_dev_id) {
debugLogA("Jabber OMEMO: error: failed to get sender device id");
return true;
}
- char *sender_device_id_a = mir_u2a(sender_dev_id);
- DWORD sender_dev_id_int = strtoul(sender_device_id_a, nullptr, 10);
- mir_free(sender_device_id_a);
+ DWORD sender_dev_id_int = strtoul(sender_dev_id, nullptr, 10);
auto &pSession = m_omemo.sessions[hContact][sender_dev_id_int];
if (!pSession.cipher || !pSession.builder || !pSession.store_context) {
@@ -1534,42 +1520,31 @@ bool CJabberProto::OmemoHandleMessage(HXML node, wchar_t *jid, time_t msgTime)
return false;
}
- HXML key_node;
DWORD own_id = m_omemo.GetOwnDeviceId();
- const wchar_t *encrypted_key_base64 = nullptr;
- for (int p = 1; (key_node = XmlGetNthChild(header_node, L"key", p)) != nullptr; p++) {
- const wchar_t *dev_id = xmlGetAttrValue(key_node, L"rid");
- char *dev_id_a = mir_u2a(dev_id);
- DWORD dev_id_int = strtoul(dev_id_a, nullptr, 10);
- mir_free(dev_id_a);
+ const char *encrypted_key_base64 = nullptr;
+ for (auto *it : TiXmlFilter(header_node, "key")) {
+ DWORD dev_id_int = it->IntAttribute("rid");
if (dev_id_int == own_id) {
- encrypted_key_base64 = XmlGetText(key_node);
+ encrypted_key_base64 = it->GetText();
break;
}
}
+
if (!encrypted_key_base64) {
debugLogA("Jabber OMEMO: message does not have decryption key for our device");
return true; //node does not contain key for our device
}
+
size_t encrypted_key_len;
- unsigned char *encrypted_key;
- {
- char *key_buf = mir_u2a(encrypted_key_base64);
- encrypted_key = (unsigned char*)mir_base64_decode(key_buf, &encrypted_key_len);
- mir_free(key_buf);
- }
+ unsigned char *encrypted_key = (unsigned char*)mir_base64_decode(encrypted_key_base64, &encrypted_key_len);
+
size_t iv_len;
- unsigned char *iv;
- {
- char *iv_buf = mir_u2a(iv_base64);
- iv = (unsigned char *)mir_base64_decode(iv_buf, &iv_len);
- mir_free(iv_buf);
- }
+ unsigned char *iv = (unsigned char *)mir_base64_decode(iv_base64, &iv_len);
+
signal_buffer *decrypted_key = nullptr;
bool decrypted = false;
- { //try to decrypt as pre_key_signal_message
-
-
+ {
+ //try to decrypt as pre_key_signal_message
pre_key_signal_message *pm = nullptr;
bool deserialized = false;
//TODO: cleanup before return on error
@@ -1581,11 +1556,9 @@ bool CJabberProto::OmemoHandleMessage(HXML node, wchar_t *jid, time_t msgTime)
break;
case SG_ERR_INVALID_PROTO_BUF:
debugLogA("Jabber OMEMO: error: pre_key_signal_message_deserialize failed SG_ERR_INVALID_PROTO_BUF\nTODO: use prekey tag in incomming message key element to avoid this");
- // return;
break;
default:
debugLogA("Jabber OMEMO: error: pre_key_signal_message_deserialize failed with unknown error");
- // return;
break;
}
}
@@ -1598,31 +1571,24 @@ bool CJabberProto::OmemoHandleMessage(HXML node, wchar_t *jid, time_t msgTime)
break;
case SG_ERR_INVALID_MESSAGE:
debugLogA("Jabber OMEMO: error: session_cipher_decrypt_pre_key_signal_message failed SG_ERR_INVALID_MESSAGE\nTODO: use prekey tag in incomming message key element to avoid this");
- // return;
break;
case SG_ERR_DUPLICATE_MESSAGE:
debugLogA("Jabber OMEMO: error: session_cipher_decrypt_pre_key_signal_message failed SG_ERR_DUPLICATE_MESSAGE");
- // return;
break;
case SG_ERR_LEGACY_MESSAGE:
debugLogA("Jabber OMEMO: error: session_cipher_decrypt_pre_key_signal_message failed SG_ERR_LEGACY_MESSAGE");
- // return;
break;
case SG_ERR_INVALID_KEY_ID:
debugLogA("Jabber OMEMO: error: session_cipher_decrypt_pre_key_signal_message failed SG_ERR_INVALID_KEY_ID");
- // return;
break;
case SG_ERR_INVALID_KEY:
debugLogA("Jabber OMEMO: error: session_cipher_decrypt_pre_key_signal_message failed SG_ERR_INVALID_KEY");
- // return;
break;
case SG_ERR_UNTRUSTED_IDENTITY:
debugLogA("Jabber OMEMO: error: session_cipher_decrypt_pre_key_signal_message failed SG_ERR_UNTRUSTED_IDENTITY");
- // return;
break;
default:
debugLogA("Jabber OMEMO: error: session_cipher_decrypt_pre_key_signal_message failed with unknown error");
- // return;
break;
}
}
@@ -1640,6 +1606,7 @@ bool CJabberProto::OmemoHandleMessage(HXML node, wchar_t *jid, time_t msgTime)
debugLogA("Jabber OMEMO: error: signal_message_deserialize failed with unknown error");
break;
}
+
if (deserialized && sm) {
ret = session_cipher_decrypt_signal_message(m_omemo.sessions[hContact][sender_dev_id_int].cipher, sm, nullptr, &decrypted_key);
switch (ret) {
@@ -1673,10 +1640,8 @@ bool CJabberProto::OmemoHandleMessage(HXML node, wchar_t *jid, time_t msgTime)
int dec_success = 0;
size_t payload_len = 0;
int outl = 0, round_len = 0, tag_len = 0;
- char *payload_base64 = mir_u2a(payload_base64w);
- unsigned char *payload = (unsigned char*)mir_base64_decode(payload_base64, &payload_len);
+ unsigned char *payload = (unsigned char*)mir_base64_decode(payload_base64w, &payload_len);
out = (char*)mir_alloc(payload_len + 32); //TODO: check this
- mir_free(payload_base64);
unsigned char key[16], *tag;
{
size_t buf_len = signal_buffer_len(decrypted_key);
@@ -1727,7 +1692,6 @@ bool CJabberProto::OmemoHandleMessage(HXML node, wchar_t *jid, time_t msgTime)
}
EVP_DecryptUpdate(ctx, (unsigned char*)out + outl, &round_len, payload + outl, int(payload_len - outl));
outl += round_len; */
-
dec_success = EVP_DecryptFinal_ex(ctx, (unsigned char*)out + outl, &round_len);
outl += round_len;
@@ -1756,48 +1720,44 @@ bool CJabberProto::OmemoHandleMessage(HXML node, wchar_t *jid, time_t msgTime)
return true;
}
-void CJabberProto::OmemoHandleDeviceList(HXML node)
+void CJabberProto::OmemoHandleDeviceList(const TiXmlElement *node)
{
if (!node)
return;
- HXML message = xmlGetParent(node);
- message = xmlGetParent(message);
- const wchar_t *jid = XmlGetAttrValue(message, L"from");
+ auto *message = node->Parent()->ToElement();
+ message = message->Parent()->ToElement();
+
+ const char *jid = message->Attribute("from");
MCONTACT hContact = HContactFromJID(jid);
- node = XmlGetChild(node, "item"); //get <item> node
+ node = node->FirstChildElement("item"); //get <item> node
if (!node) {
debugLogA("Jabber OMEMO: error: omemo devicelist does not have <item> node");
return;
}
- node = XmlGetChildByTag(node, L"list", L"xmlns", JABBER_FEAT_OMEMO); //<list xmlns = 'urn:xmpp:omemo:0'>
+ node = XmlGetChildByTag(node, "list", "xmlns", JABBER_FEAT_OMEMO); //<list xmlns = 'urn:xmpp:omemo:0'>
if (!node) {
debugLogA("Jabber OMEMO: error: omemo devicelist does not have <list> node");
return;
}
bool own_jid = false;
- if (wcsstr(m_ThreadInfo->fullJID, jid))
+ if (strstr(m_ThreadInfo->fullJID, jid))
own_jid = true;
- uint32_t current_id;
- const wchar_t *current_id_str;
if (own_jid) {
//check if our device exist
bool own_device_listed = false;
uint32_t own_id = m_omemo.GetOwnDeviceId();
char setting_name[64];
- HXML list_item;
int i = 0;
- for (int p = 1; (list_item = XmlGetNthChild(node, L"device", p)) != nullptr; p++, i++) {
- current_id_str = xmlGetAttrValue(list_item, L"id");
- char *current_id_str_a = mir_u2a(current_id_str);
- current_id = strtoul(current_id_str_a, nullptr, 10);
- mir_free(current_id_str_a);
+ for (auto *list_item : TiXmlFilter(node, "device")) {
+ uint32_t current_id = list_item->IntAttribute("id");
if (current_id == own_id)
own_device_listed = true;
- mir_snprintf(setting_name, "OmemoDeviceId%d", i);
+ mir_snprintf(setting_name, "OmemoDeviceId%d", i++);
setDword(setting_name, current_id);
}
+
DWORD val = 0;
mir_snprintf(setting_name, "OmemoDeviceId%d", i);
val = getDword(setting_name, 0);
@@ -1811,16 +1771,12 @@ void CJabberProto::OmemoHandleDeviceList(HXML node)
OmemoAnnounceDevice();
}
else {
- //store device id's
+ // store device id's
char setting_name[64];
- HXML list_item;
int i = 0;
- for (int p = 1; (list_item = XmlGetNthChild(node, L"device", p)) != nullptr; p++, i++) {
- current_id_str = xmlGetAttrValue(list_item, L"id");
- char *current_id_str_a = mir_u2a(current_id_str);
- current_id = strtoul(current_id_str_a, nullptr, 10);
- mir_free(current_id_str_a);
- mir_snprintf(setting_name, "OmemoDeviceId%d", i);
+ for (auto *list_item : TiXmlFilter(node, "device")) {
+ uint32_t current_id = list_item->IntAttribute("id");
+ mir_snprintf(setting_name, "OmemoDeviceId%d", i++);
setDword(hContact, setting_name, current_id);
}
@@ -1852,11 +1808,11 @@ void CJabberProto::OmemoAnnounceDevice()
// add own device id
// construct node
- wchar_t szBareJid[JABBER_MAX_JID_LEN];
- XmlNodeIq iq(L"set", SerialNext());
- iq << XATTR(L"from", JabberStripJid(m_ThreadInfo->fullJID, szBareJid, _countof_portable(szBareJid)));
- HXML publish_node = iq << XCHILDNS(L"pubsub", L"http://jabber.org/protocol/pubsub") << XCHILD(L"publish") << XATTR(L"node", JABBER_FEAT_OMEMO L".devicelist");
- HXML list_node = publish_node << XCHILDNS(L"item") << XCHILDNS(L"list", JABBER_FEAT_OMEMO);
+ char szBareJid[JABBER_MAX_JID_LEN];
+ XmlNodeIq iq("set", SerialNext());
+ iq << XATTR("from", JabberStripJid(m_ThreadInfo->fullJID, szBareJid, _countof_portable(szBareJid)));
+ TiXmlElement *publish_node = iq << XCHILDNS("pubsub", "http://jabber.org/protocol/pubsub") << XCHILD("publish") << XATTR("node", JABBER_FEAT_OMEMO ".devicelist");
+ TiXmlElement *list_node = publish_node << XCHILDNS("item") << XCHILDNS("list", JABBER_FEAT_OMEMO);
for (int i = 0; ; ++i) {
mir_snprintf(setting_name, "OmemoDeviceId%d", i);
@@ -1864,9 +1820,9 @@ void CJabberProto::OmemoAnnounceDevice()
if (val == 0)
break;
- list_node << XCHILD(L"device") << XATTRI64(L"id", val);
+ list_node << XCHILD("device") << XATTRI64("id", val);
}
- list_node << XCHILD(L"device") << XATTRI64(L"id", own_id);
+ list_node << XCHILD("device") << XATTRI64("id", own_id);
// send device list back
//TODOL handle response
@@ -1893,35 +1849,35 @@ void CJabberProto::OmemoSendBundle()
DWORD own_id = m_omemo.GetOwnDeviceId();
// construct bundle node
- wchar_t szBareJid[JABBER_MAX_JID_LEN];
- XmlNodeIq iq(L"set", SerialNext());
- iq << XATTR(L"from", JabberStripJid(m_ThreadInfo->fullJID, szBareJid, _countof_portable(szBareJid)));
+ char szBareJid[JABBER_MAX_JID_LEN];
+ XmlNodeIq iq("set", SerialNext());
+ iq << XATTR("from", JabberStripJid(m_ThreadInfo->fullJID, szBareJid, _countof_portable(szBareJid)));
- HXML publish_node = iq << XCHILDNS(L"pubsub", L"http://jabber.org/protocol/pubsub") << XCHILD(L"publish");
+ TiXmlElement *publish_node = iq << XCHILDNS("pubsub", "http://jabber.org/protocol/pubsub") << XCHILD("publish");
{
- wchar_t attr_val[128];
- mir_snwprintf(attr_val, L"%s.bundles:%u", JABBER_FEAT_OMEMO, own_id);
- publish_node << XATTR(L"node", attr_val);
+ char attr_val[128];
+ mir_snprintf(attr_val, "%s.bundles:%u", JABBER_FEAT_OMEMO, own_id);
+ publish_node << XATTR("node", attr_val);
}
- HXML bundle_node = publish_node << XCHILD(L"item") << XCHILDNS(L"bundle", JABBER_FEAT_OMEMO);
+ TiXmlElement *bundle_node = publish_node << XCHILD("item") << XCHILDNS("bundle", JABBER_FEAT_OMEMO);
// add signed pre key public
- bundle_node << XCHILD(L"signedPreKeyPublic", ptrW(getWStringA("OmemoSignedPreKeyPublic"))) << XATTR(L"signedPreKeyId", L"1");
+ bundle_node << XCHILD("signedPreKeyPublic", ptrA(getUStringA("OmemoSignedPreKeyPublic"))) << XATTRI("signedPreKeyId", 1);
// add pre key signature
- bundle_node << XCHILD(L"signedPreKeySignature", ptrW(getWStringA("OmemoSignedPreKeySignature")));
+ bundle_node << XCHILD("signedPreKeySignature", ptrA(getUStringA("OmemoSignedPreKeySignature")));
// add identity key
// it is must be a public key right ?, standart is a bit confusing...
- bundle_node << XCHILD(L"identityKey", ptrW(getWStringA("OmemoDevicePublicKey")));
+ bundle_node << XCHILD("identityKey", ptrA(getUStringA("OmemoDevicePublicKey")));
// add prekeys
- HXML prekeys_node = XmlAddChild(bundle_node, L"prekeys");
+ TiXmlElement *prekeys_node = XmlAddChild(bundle_node, "prekeys");
db_enum_settings_prekeys_cb_data *ud = new db_enum_settings_prekeys_cb_data;
db_enum_settings(0, &db_enum_settings_prekeys_cb, m_szModuleName, ud);
for (std::list<char*>::iterator i = ud->settings.begin(), end = ud->settings.end(); i != end; i++) {
- ptrW val(getWStringA(*i));
+ ptrA val(getUStringA(*i));
if (val) {
unsigned int key_id = 0;
char *p = *i, buf[5] = { 0 };
@@ -1932,7 +1888,7 @@ void CJabberProto::OmemoSendBundle()
memcpy(buf, p, i2);
buf[i2 + 1] = 0;
key_id = atoi(buf);
- prekeys_node << XCHILD(L"preKeyPublic", val) << XATTRI(L"preKeyId", key_id);
+ prekeys_node << XCHILD("preKeyPublic", val) << XATTRI("preKeyId", key_id);
}
mir_free(*i);
}
@@ -1941,11 +1897,11 @@ void CJabberProto::OmemoSendBundle()
char setting_name[64];
for (int i = 0;; i++) {
mir_snprintf(setting_name, "OmemoPreKey%dPublic", i);
- ptrW val(getWStringA(setting_name));
+ ptrA val(getUStringA(setting_name));
if (val == nullptr)
break;
- prekeys_node << XCHILD(L"preKeyPublic", val) << XATTRI(L"preKeyId", i + 1);
+ prekeys_node << XCHILD("preKeyPublic", val) << XATTRI("preKeyId", i + 1);
}
// send bundle
@@ -1978,17 +1934,18 @@ bool CJabberProto::OmemoCheckSession(MCONTACT hContact)
while (id) {
if (!checked) {
pending_check = true;
- wchar_t szBareJid[JABBER_MAX_JID_LEN];
- unsigned int *dev_id = (unsigned int*)mir_alloc(sizeof(unsigned int));
- *dev_id = id;
- XmlNodeIq iq(AddIQ(&CJabberProto::OmemoOnIqResultGetBundle, JABBER_IQ_TYPE_GET, nullptr, 0UL, -1, dev_id));
- iq << XATTR(L"from", JabberStripJid(m_ThreadInfo->fullJID, szBareJid, _countof_portable(szBareJid)));
- wchar_t *jid = ContactToJID(hContact);
- iq << XATTR(L"to", jid);
- HXML items = iq << XCHILDNS(L"pubsub", L"http://jabber.org/protocol/pubsub") << XCHILD(L"items");
- wchar_t bundle[64];
- mir_snwprintf(bundle, 63, L"%s%s%u", JABBER_FEAT_OMEMO, L".bundles:", id);
- XmlAddAttr(items, L"node", bundle);
+ XmlNodeIq iq(AddIQ(&CJabberProto::OmemoOnIqResultGetBundle, JABBER_IQ_TYPE_GET, nullptr, 0UL, -1, &id));
+
+ char szBareJid[JABBER_MAX_JID_LEN];
+ iq << XATTR("from", JabberStripJid(m_ThreadInfo->fullJID, szBareJid, _countof_portable(szBareJid)));
+
+ char *jid = ContactToJID(hContact);
+ iq << XATTR("to", jid);
+
+ TiXmlElement *items = iq << XCHILDNS("pubsub", "http://jabber.org/protocol/pubsub") << XCHILD("items");
+ char bundle[64];
+ mir_snprintf(bundle, "%s%s%u", JABBER_FEAT_OMEMO, ".bundles:", id);
+ XmlAddAttr(items, "node", bundle);
m_ThreadInfo->send(iq);
mir_free(jid);
break;
@@ -2010,16 +1967,16 @@ bool CJabberProto::OmemoCheckSession(MCONTACT hContact)
return false;
}
-void CJabberProto::OmemoOnIqResultGetBundle(HXML iqNode, CJabberIqInfo *pInfo)
+void CJabberProto::OmemoOnIqResultGetBundle(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
if (iqNode == nullptr)
return;
- const wchar_t *jid = XmlGetAttrValue(iqNode, L"from");
+ const char *jid = iqNode->Attribute("from");
MCONTACT hContact = HContactFromJID(jid);
- const wchar_t *type = XmlGetAttrValue(iqNode, L"type");
- if (mir_wstrcmp(type, L"result")) {
+ const char *type = iqNode->Attribute("type");
+ if (mir_strcmp(type, "result")) {
// failed to get bundle, do not try to build session
unsigned int *dev_id = (unsigned int*)pInfo->GetUserData();
char setting_name[64], setting_name2[64];
@@ -2045,69 +2002,62 @@ void CJabberProto::OmemoOnIqResultGetBundle(HXML iqNode, CJabberIqInfo *pInfo)
return;
}
- HXML pubsub = XmlGetChildByTag(iqNode, L"pubsub", L"xmlns", L"http://jabber.org/protocol/pubsub");
+ auto *pubsub = XmlGetChildByTag(iqNode, "pubsub", "xmlns", "http://jabber.org/protocol/pubsub");
if (!pubsub) {
debugLogA("Jabber OMEMO: error: device bundle does not contain pubsub node");
return;
}
- HXML items = XmlGetChild(pubsub, L"items");
- const wchar_t *items_node_val = XmlGetAttrValue(items, L"node");
- const wchar_t *device_id = items_node_val;
+ auto *items = pubsub->FirstChildElement("items");
+ const char *items_node_val = items->Attribute("node");
+ const char *device_id = items_node_val;
device_id += mir_wstrlen(JABBER_FEAT_OMEMO L".bundles:");
- HXML bundle = XmlGetChild(XmlGetChild(items, L"item"), L"bundle");
+
+ auto *bundle = items->FirstChildElement("item")->FirstChildElement("bundle");
if (!bundle) {
debugLogA("Jabber OMEMO: error: device bundle does not contain bundle node");
return;
}
- const wchar_t *signedPreKeyPublic = XmlGetText(XmlGetChild(bundle, L"signedPreKeyPublic"));
+ const char *signedPreKeyPublic = bundle->FirstChildElement("signedPreKeyPublic")->GetText();
if (!signedPreKeyPublic) {
debugLogA("Jabber OMEMO: error: device bundle does not contain signedPreKeyPublic node");
return;
}
- const wchar_t *signedPreKeyId = XmlGetAttrValue(XmlGetChild(bundle, L"signedPreKeyPublic"), L"signedPreKeyId");
+ const char *signedPreKeyId = bundle->FirstChildElement("signedPreKeyPublic")->Attribute("signedPreKeyId");
if (!signedPreKeyId) {
debugLogA("Jabber OMEMO: error: device bundle does not contain signedPreKeyId attr");
return;
}
- const wchar_t *signedPreKeySignature = XmlGetText(XmlGetChild(bundle, L"signedPreKeySignature"));
+ const char *signedPreKeySignature = bundle->FirstChildElement("signedPreKeySignature")->GetText();
if (!signedPreKeySignature) {
debugLogA("Jabber OMEMO: error: device bundle does not contain signedPreKeySignature node");
return;
}
- const wchar_t *identityKey = XmlGetText(XmlGetChild(bundle, L"identityKey"));
+ const char *identityKey = bundle->FirstChildElement("identityKey")->GetText();
if (!identityKey) {
debugLogA("Jabber OMEMO: error: device bundle does not contain identityKey node");
return;
}
- HXML prekeys = XmlGetChild(bundle, L"prekeys");
+
+ auto *prekeys = bundle->FirstChildElement("prekeys");
if (!prekeys) {
debugLogA("Jabber OMEMO: error: device bundle does not contain prekeys node");
return;
}
- unsigned char key_num = 0;
- while (key_num == 0)
- Utils_GetRandom(&key_num, 1);
- key_num = (key_num % (XmlGetChildCount(prekeys))) + 1;
-
- wchar_t key_num_str[4];
- mir_snwprintf(key_num_str, 3, L"%d", key_num);
- HXML prekey_node;
- for (int p = 1; (prekey_node = XmlGetNthChild(prekeys, L"preKeyPublic", p)) != nullptr && p <= key_num; p++)
- ;
+ auto *prekey_node = prekeys->FirstChildElement("preKeyPublic");
if (!prekey_node) {
debugLogA("Jabber OMEMO: error: device bundle does not contain preKeyPublic node");
return;
}
- const wchar_t *preKeyPublic = XmlGetText(prekey_node);
+ const char *preKeyPublic = prekey_node->GetText();
if (!preKeyPublic) {
debugLogA("Jabber OMEMO: error: failed to get preKeyPublic data");
return;
}
- const wchar_t *preKeyId = XmlGetAttrValue(prekey_node, L"preKeyId");
+ const char *preKeyId = prekey_node->Attribute("preKeyId");
if (!preKeyId) {
debugLogA("Jabber OMEMO: error: failed to get preKeyId data");
return;
@@ -2147,7 +2097,7 @@ void CJabberProto::OmemoOnIqResultGetBundle(HXML iqNode, CJabberIqInfo *pInfo)
OmemoCheckSession(hContact);
}
-unsigned int CJabberProto::OmemoEncryptMessage(XmlNode &msg, const wchar_t *msg_text, MCONTACT hContact)
+unsigned int CJabberProto::OmemoEncryptMessage(XmlNode &msg, const char *msg_text, MCONTACT hContact)
{
const EVP_CIPHER *cipher = EVP_aes_128_gcm();
unsigned char key[16], iv[12], tag[16] /*, aad[48]*/;
@@ -2158,32 +2108,29 @@ unsigned int CJabberProto::OmemoEncryptMessage(XmlNode &msg, const wchar_t *msg_
EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, _countof_portable(iv), nullptr);
EVP_EncryptInit(ctx, cipher, key, iv);
- char *in = mir_utf8encodeW(msg_text), *out;
- const size_t inl = strlen(in);
+ char *out;
+ const size_t inl = strlen(msg_text);
int tmp_len = 0, outl;
//EVP_EncryptUpdate(ctx, nullptr, &outl, aad, _countof_portable(aad));
out = (char*)mir_alloc(inl + _countof_portable(key) - 1);
for (;;) {
- EVP_EncryptUpdate(ctx, (unsigned char*)(out + tmp_len), &outl, (unsigned char*)(in + tmp_len), (int)(inl - tmp_len));
+ EVP_EncryptUpdate(ctx, (unsigned char*)(out + tmp_len), &outl, (unsigned char*)(msg_text + tmp_len), (int)(inl - tmp_len));
tmp_len += outl;
if (tmp_len >= (int)inl - 16 + 1) //cast to int is required here
break;
}
- EVP_EncryptFinal(ctx, (unsigned char*)(in + tmp_len), &outl);
+ EVP_EncryptFinal(ctx, (unsigned char*)(msg_text + tmp_len), &outl);
tmp_len += outl;
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, _countof_portable(tag), tag);
EVP_CIPHER_CTX_free(ctx);
- mir_free(in);
- HXML encrypted = msg << XCHILDNS(L"encrypted", JABBER_FEAT_OMEMO);
- HXML payload = encrypted << XCHILD(L"payload");
- char *payload_base64 = mir_base64_encode(out, tmp_len);
- wchar_t *payload_base64w = mir_a2u(payload_base64);
- mir_free(payload_base64);
- xmlSetText(payload, payload_base64w);
- mir_free(payload_base64w);
- HXML header = encrypted << XCHILD(L"header");
- header << XATTRI64(L"sid", m_omemo.GetOwnDeviceId());
+
+ TiXmlElement *encrypted = msg << XCHILDNS("encrypted", JABBER_FEAT_OMEMO);
+ TiXmlElement *payload = encrypted << XCHILD("payload");
+ payload->SetText(ptrA(mir_base64_encode(out, tmp_len)).get());
+
+ TiXmlElement *header = encrypted << XCHILD("header");
+ header << XATTRI64("sid", m_omemo.GetOwnDeviceId());
unsigned int session_count = 0;
char key_plus_tag[32] = { 0 };
memcpy(key_plus_tag, key, 16);
@@ -2205,26 +2152,24 @@ unsigned int CJabberProto::OmemoEncryptMessage(XmlNode &msg, const wchar_t *msg_
continue;
}
- HXML key_node = header << XCHILD(L"key");
- key_node << XATTRI64(L"rid", intdev_id);
+ TiXmlElement *key_node = header << XCHILD("key");
+ key_node << XATTRI64("rid", intdev_id);
int msg_type = ciphertext_message_get_type(encrypted_key);
if (msg_type == CIPHERTEXT_PREKEY_TYPE)
- key_node << XATTR(L"prekey", L"true");
+ key_node << XATTR("prekey", "true");
signal_buffer *serialized_encrypted_key = ciphertext_message_get_serialized(encrypted_key);
- char *key_base64 = mir_base64_encode(signal_buffer_data(serialized_encrypted_key), signal_buffer_len(serialized_encrypted_key));
- wchar_t *key_base64w = mir_a2u(key_base64);
- mir_free(key_base64);
- xmlSetText(key_node, key_base64w);
- mir_free(key_base64w);
+ ptrA key_base64(mir_base64_encode(signal_buffer_data(serialized_encrypted_key), signal_buffer_len(serialized_encrypted_key)));
+ key_node->SetText(key_base64.get());
+
SIGNAL_UNREF(encrypted_key);
session_count++;
}
- HXML iv_node = header << XCHILD(L"iv");
- xmlSetText(iv_node, _A2T(ptrA(mir_base64_encode(iv, _countof_portable(iv)))));
+ TiXmlElement *iv_node = header << XCHILD("iv");
+ iv_node->SetText(ptrA(mir_base64_encode(iv, _countof_portable(iv))).get());
- msg << XCHILDNS(L"store", L"urn:xmpp:hints");
+ msg << XCHILDNS("store", "urn:xmpp:hints");
if (!session_count)
debugLogA("Jabber OMEMO: error: message does not encrypted for any sessions");
diff --git a/protocols/JabberG/src/jabber_omemo.h b/protocols/JabberG/src/jabber_omemo.h
index 645d3c8116..1f828b046b 100755
--- a/protocols/JabberG/src/jabber_omemo.h
+++ b/protocols/JabberG/src/jabber_omemo.h
@@ -45,16 +45,18 @@ namespace omemo
unsigned long GetOwnDeviceId();
void RefreshDevice();
omemo_device* create_device();
- bool create_session_store(MCONTACT hContact, const wchar_t *device_id);
- bool build_session(MCONTACT hContact, const wchar_t *jid, const wchar_t *dev_id, const wchar_t *key_id, const wchar_t *pre_key_public, const wchar_t *signed_pre_key_id,
- const wchar_t *signed_pre_key_public, const wchar_t *signed_pre_key_signature, const wchar_t *identity_key);
+ bool create_session_store(MCONTACT hContact, const char *device_id);
+ bool build_session(MCONTACT hContact, const char *jid, const char *dev_id, const char *key_id, const char *pre_key_public, const char *signed_pre_key_id,
+ const char *signed_pre_key_public, const char *signed_pre_key_signature, const char *identity_key);
mir_cslockfull *signal_mutex;
std::map<MCONTACT, std::map<unsigned int, struct omemo_session_jabber_internal_ptrs>> sessions;
std::map<MCONTACT, bool> session_checked;
- std::list<struct incomming_message> incoming_messages;
+ std::list<struct incoming_message> incoming_messages;
std::list<struct outgoing_message> outgoing_messages;
+ TiXmlDocument doc;
+
private:
CJabberProto *proto;
mir_cs _signal_cs;
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp
index bb59223211..f4414e36fd 100755
--- a/protocols/JabberG/src/jabber_opt.cpp
+++ b/protocols/JabberG/src/jabber_opt.cpp
@@ -35,192 +35,192 @@ static BOOL(WINAPI *pfnEnableThemeDialogTexture)(HANDLE, DWORD) = nullptr;
#define STR_FORMAT L"%s %s@%S:%d?"
-struct { wchar_t *szCode; wchar_t *szDescription; } g_LanguageCodes[] = {
- { L"aa", LPGENW("Afar") },
- { L"ab", LPGENW("Abkhazian") },
- { L"af", LPGENW("Afrikaans") },
- { L"ak", LPGENW("Akan") },
- { L"sq", LPGENW("Albanian") },
- { L"am", LPGENW("Amharic") },
- { L"ar", LPGENW("Arabic") },
- { L"an", LPGENW("Aragonese") },
- { L"hy", LPGENW("Armenian") },
- { L"as", LPGENW("Assamese") },
- { L"av", LPGENW("Avaric") },
- { L"ae", LPGENW("Avestan") },
- { L"ay", LPGENW("Aymara") },
- { L"az", LPGENW("Azerbaijani") },
- { L"ba", LPGENW("Bashkir") },
- { L"bm", LPGENW("Bambara") },
- { L"eu", LPGENW("Basque") },
- { L"be", LPGENW("Belarusian") },
- { L"bn", LPGENW("Bengali") },
- { L"bh", LPGENW("Bihari") },
- { L"bi", LPGENW("Bislama") },
- { L"bs", LPGENW("Bosnian") },
- { L"br", LPGENW("Breton") },
- { L"bg", LPGENW("Bulgarian") },
- { L"my", LPGENW("Burmese") },
- { L"ca", LPGENW("Catalan; Valencian") },
- { L"ch", LPGENW("Chamorro") },
- { L"ce", LPGENW("Chechen") },
- { L"zh", LPGENW("Chinese") },
- { L"cu", LPGENW("Church Slavic; Old Slavonic") },
- { L"cv", LPGENW("Chuvash") },
- { L"kw", LPGENW("Cornish") },
- { L"co", LPGENW("Corsican") },
- { L"cr", LPGENW("Cree") },
- { L"cs", LPGENW("Czech") },
- { L"da", LPGENW("Danish") },
- { L"dv", LPGENW("Divehi; Dhivehi; Maldivian") },
- { L"nl", LPGENW("Dutch; Flemish") },
- { L"dz", LPGENW("Dzongkha") },
- { L"en", LPGENW("English") },
- { L"eo", LPGENW("Esperanto") },
- { L"et", LPGENW("Estonian") },
- { L"ee", LPGENW("Ewe") },
- { L"fo", LPGENW("Faroese") },
- { L"fj", LPGENW("Fijian") },
- { L"fi", LPGENW("Finnish") },
- { L"fr", LPGENW("French") },
- { L"fy", LPGENW("Western Frisian") },
- { L"ff", LPGENW("Fulah") },
- { L"ka", LPGENW("Georgian") },
- { L"de", LPGENW("German") },
- { L"gd", LPGENW("Gaelic; Scottish Gaelic") },
- { L"ga", LPGENW("Irish") },
- { L"gl", LPGENW("Galician") },
- { L"gv", LPGENW("Manx") },
- { L"el", LPGENW("Greek, Modern (1453-)") },
- { L"gn", LPGENW("Guarani") },
- { L"gu", LPGENW("Gujarati") },
- { L"ht", LPGENW("Haitian; Haitian Creole") },
- { L"ha", LPGENW("Hausa") },
- { L"he", LPGENW("Hebrew") },
- { L"hz", LPGENW("Herero") },
- { L"hi", LPGENW("Hindi") },
- { L"ho", LPGENW("Hiri Motu") },
- { L"hu", LPGENW("Hungarian") },
- { L"ig", LPGENW("Igbo") },
- { L"is", LPGENW("Icelandic") },
- { L"io", LPGENW("Ido") },
- { L"ii", LPGENW("Sichuan Yi") },
- { L"iu", LPGENW("Inuktitut") },
- { L"ie", LPGENW("Interlingue") },
- { L"ia", LPGENW("Interlingua (International Auxiliary Language Association)") },
- { L"id", LPGENW("Indonesian") },
- { L"ik", LPGENW("Inupiaq") },
- { L"it", LPGENW("Italian") },
- { L"jv", LPGENW("Javanese") },
- { L"ja", LPGENW("Japanese") },
- { L"kl", LPGENW("Kalaallisut; Greenlandic") },
- { L"kn", LPGENW("Kannada") },
- { L"ks", LPGENW("Kashmiri") },
- { L"kr", LPGENW("Kanuri") },
- { L"kk", LPGENW("Kazakh") },
- { L"km", LPGENW("Central Khmer") },
- { L"ki", LPGENW("Kikuyu; Gikuyu") },
- { L"rw", LPGENW("Kinyarwanda") },
- { L"ky", LPGENW("Kirghiz; Kyrgyz") },
- { L"kv", LPGENW("Komi") },
- { L"kg", LPGENW("Kongo") },
- { L"ko", LPGENW("Korean") },
- { L"kj", LPGENW("Kuanyama; Kwanyama") },
- { L"ku", LPGENW("Kurdish") },
- { L"lo", LPGENW("Lao") },
- { L"la", LPGENW("Latin") },
- { L"lv", LPGENW("Latvian") },
- { L"li", LPGENW("Limburgan; Limburger; Limburgish") },
- { L"ln", LPGENW("Lingala") },
- { L"lt", LPGENW("Lithuanian") },
- { L"lb", LPGENW("Luxembourgish; Letzeburgesch") },
- { L"lu", LPGENW("Luba-Katanga") },
- { L"lg", LPGENW("Ganda") },
- { L"mk", LPGENW("Macedonian") },
- { L"mh", LPGENW("Marshallese") },
- { L"ml", LPGENW("Malayalam") },
- { L"mi", LPGENW("Maori") },
- { L"mr", LPGENW("Marathi") },
- { L"ms", LPGENW("Malay") },
- { L"mg", LPGENW("Malagasy") },
- { L"mt", LPGENW("Maltese") },
- { L"mo", LPGENW("Moldavian") },
- { L"mn", LPGENW("Mongolian") },
- { L"na", LPGENW("Nauru") },
- { L"nv", LPGENW("Navajo; Navaho") },
- { L"nr", LPGENW("Ndebele, South; South Ndebele") },
- { L"nd", LPGENW("Ndebele, North; North Ndebele") },
- { L"ng", LPGENW("Ndonga") },
- { L"ne", LPGENW("Nepali") },
- { L"nn", LPGENW("Norwegian Nynorsk; Nynorsk, Norwegian") },
- { L"nb", LPGENW("Bokmaal, Norwegian; Norwegian Bokmaal") },
- { L"no", LPGENW("Norwegian") },
- { L"ny", LPGENW("Chichewa; Chewa; Nyanja") },
- { L"oc", LPGENW("Occitan (post 1500); Provencal") },
- { L"oj", LPGENW("Ojibwa") },
- { L"or", LPGENW("Oriya") },
- { L"om", LPGENW("Oromo") },
- { L"os", LPGENW("Ossetian; Ossetic") },
- { L"pa", LPGENW("Panjabi; Punjabi") },
- { L"fa", LPGENW("Persian") },
- { L"pi", LPGENW("Pali") },
- { L"pl", LPGENW("Polish") },
- { L"pt", LPGENW("Portuguese") },
- { L"ps", LPGENW("Pushto") },
- { L"qu", LPGENW("Quechua") },
- { L"rm", LPGENW("Romansh") },
- { L"ro", LPGENW("Romanian") },
- { L"rn", LPGENW("Rundi") },
- { L"ru", LPGENW("Russian") },
- { L"sg", LPGENW("Sango") },
- { L"sa", LPGENW("Sanskrit") },
- { L"sr", LPGENW("Serbian") },
- { L"hr", LPGENW("Croatian") },
- { L"si", LPGENW("Sinhala; Sinhalese") },
- { L"sk", LPGENW("Slovak") },
- { L"sl", LPGENW("Slovenian") },
- { L"se", LPGENW("Northern Sami") },
- { L"sm", LPGENW("Samoan") },
- { L"sn", LPGENW("Shona") },
- { L"sd", LPGENW("Sindhi") },
- { L"so", LPGENW("Somali") },
- { L"st", LPGENW("Sotho, Southern") },
- { L"es", LPGENW("Spanish; Castilian") },
- { L"sc", LPGENW("Sardinian") },
- { L"ss", LPGENW("Swati") },
- { L"su", LPGENW("Sundanese") },
- { L"sw", LPGENW("Swahili") },
- { L"sv", LPGENW("Swedish") },
- { L"ty", LPGENW("Tahitian") },
- { L"ta", LPGENW("Tamil") },
- { L"tt", LPGENW("Tatar") },
- { L"te", LPGENW("Telugu") },
- { L"tg", LPGENW("Tajik") },
- { L"tl", LPGENW("Tagalog") },
- { L"th", LPGENW("Thai") },
- { L"bo", LPGENW("Tibetan") },
- { L"ti", LPGENW("Tigrinya") },
- { L"to", LPGENW("Tonga (Tonga Islands)") },
- { L"tn", LPGENW("Tswana") },
- { L"ts", LPGENW("Tsonga") },
- { L"tk", LPGENW("Turkmen") },
- { L"tr", LPGENW("Turkish") },
- { L"tw", LPGENW("Twi") },
- { L"ug", LPGENW("Uighur; Uyghur") },
- { L"uk", LPGENW("Ukrainian") },
- { L"ur", LPGENW("Urdu") },
- { L"uz", LPGENW("Uzbek") },
- { L"ve", LPGENW("Venda") },
- { L"vi", LPGENW("Vietnamese") },
- { L"vo", LPGENW("Volapuk") },
- { L"cy", LPGENW("Welsh") },
- { L"wa", LPGENW("Walloon") },
- { L"wo", LPGENW("Wolof") },
- { L"xh", LPGENW("Xhosa") },
- { L"yi", LPGENW("Yiddish") },
- { L"yo", LPGENW("Yoruba") },
- { L"za", LPGENW("Zhuang; Chuang") },
- { L"zu", LPGENW("Zulu") },
+struct { char *szCode; wchar_t *szDescription; } g_LanguageCodes[] = {
+ { "aa", LPGENW("Afar") },
+ { "ab", LPGENW("Abkhazian") },
+ { "af", LPGENW("Afrikaans") },
+ { "ak", LPGENW("Akan") },
+ { "sq", LPGENW("Albanian") },
+ { "am", LPGENW("Amharic") },
+ { "ar", LPGENW("Arabic") },
+ { "an", LPGENW("Aragonese") },
+ { "hy", LPGENW("Armenian") },
+ { "as", LPGENW("Assamese") },
+ { "av", LPGENW("Avaric") },
+ { "ae", LPGENW("Avestan") },
+ { "ay", LPGENW("Aymara") },
+ { "az", LPGENW("Azerbaijani") },
+ { "ba", LPGENW("Bashkir") },
+ { "bm", LPGENW("Bambara") },
+ { "eu", LPGENW("Basque") },
+ { "be", LPGENW("Belarusian") },
+ { "bn", LPGENW("Bengali") },
+ { "bh", LPGENW("Bihari") },
+ { "bi", LPGENW("Bislama") },
+ { "bs", LPGENW("Bosnian") },
+ { "br", LPGENW("Breton") },
+ { "bg", LPGENW("Bulgarian") },
+ { "my", LPGENW("Burmese") },
+ { "ca", LPGENW("Catalan; Valencian") },
+ { "ch", LPGENW("Chamorro") },
+ { "ce", LPGENW("Chechen") },
+ { "zh", LPGENW("Chinese") },
+ { "cu", LPGENW("Church Slavic; Old Slavonic") },
+ { "cv", LPGENW("Chuvash") },
+ { "kw", LPGENW("Cornish") },
+ { "co", LPGENW("Corsican") },
+ { "cr", LPGENW("Cree") },
+ { "cs", LPGENW("Czech") },
+ { "da", LPGENW("Danish") },
+ { "dv", LPGENW("Divehi; Dhivehi; Maldivian") },
+ { "nl", LPGENW("Dutch; Flemish") },
+ { "dz", LPGENW("Dzongkha") },
+ { "en", LPGENW("English") },
+ { "eo", LPGENW("Esperanto") },
+ { "et", LPGENW("Estonian") },
+ { "ee", LPGENW("Ewe") },
+ { "fo", LPGENW("Faroese") },
+ { "fj", LPGENW("Fijian") },
+ { "fi", LPGENW("Finnish") },
+ { "fr", LPGENW("French") },
+ { "fy", LPGENW("Western Frisian") },
+ { "ff", LPGENW("Fulah") },
+ { "ka", LPGENW("Georgian") },
+ { "de", LPGENW("German") },
+ { "gd", LPGENW("Gaelic; Scottish Gaelic") },
+ { "ga", LPGENW("Irish") },
+ { "gl", LPGENW("Galician") },
+ { "gv", LPGENW("Manx") },
+ { "el", LPGENW("Greek, Modern (1453-)") },
+ { "gn", LPGENW("Guarani") },
+ { "gu", LPGENW("Gujarati") },
+ { "ht", LPGENW("Haitian; Haitian Creole") },
+ { "ha", LPGENW("Hausa") },
+ { "he", LPGENW("Hebrew") },
+ { "hz", LPGENW("Herero") },
+ { "hi", LPGENW("Hindi") },
+ { "ho", LPGENW("Hiri Motu") },
+ { "hu", LPGENW("Hungarian") },
+ { "ig", LPGENW("Igbo") },
+ { "is", LPGENW("Icelandic") },
+ { "io", LPGENW("Ido") },
+ { "ii", LPGENW("Sichuan Yi") },
+ { "iu", LPGENW("Inuktitut") },
+ { "ie", LPGENW("Interlingue") },
+ { "ia", LPGENW("Interlingua (International Auxiliary Language Association)") },
+ { "id", LPGENW("Indonesian") },
+ { "ik", LPGENW("Inupiaq") },
+ { "it", LPGENW("Italian") },
+ { "jv", LPGENW("Javanese") },
+ { "ja", LPGENW("Japanese") },
+ { "kl", LPGENW("Kalaallisut; Greenlandic") },
+ { "kn", LPGENW("Kannada") },
+ { "ks", LPGENW("Kashmiri") },
+ { "kr", LPGENW("Kanuri") },
+ { "kk", LPGENW("Kazakh") },
+ { "km", LPGENW("Central Khmer") },
+ { "ki", LPGENW("Kikuyu; Gikuyu") },
+ { "rw", LPGENW("Kinyarwanda") },
+ { "ky", LPGENW("Kirghiz; Kyrgyz") },
+ { "kv", LPGENW("Komi") },
+ { "kg", LPGENW("Kongo") },
+ { "ko", LPGENW("Korean") },
+ { "kj", LPGENW("Kuanyama; Kwanyama") },
+ { "ku", LPGENW("Kurdish") },
+ { "lo", LPGENW("Lao") },
+ { "la", LPGENW("Latin") },
+ { "lv", LPGENW("Latvian") },
+ { "li", LPGENW("Limburgan; Limburger; Limburgish") },
+ { "ln", LPGENW("Lingala") },
+ { "lt", LPGENW("Lithuanian") },
+ { "lb", LPGENW("Luxembourgish; Letzeburgesch") },
+ { "lu", LPGENW("Luba-Katanga") },
+ { "lg", LPGENW("Ganda") },
+ { "mk", LPGENW("Macedonian") },
+ { "mh", LPGENW("Marshallese") },
+ { "ml", LPGENW("Malayalam") },
+ { "mi", LPGENW("Maori") },
+ { "mr", LPGENW("Marathi") },
+ { "ms", LPGENW("Malay") },
+ { "mg", LPGENW("Malagasy") },
+ { "mt", LPGENW("Maltese") },
+ { "mo", LPGENW("Moldavian") },
+ { "mn", LPGENW("Mongolian") },
+ { "na", LPGENW("Nauru") },
+ { "nv", LPGENW("Navajo; Navaho") },
+ { "nr", LPGENW("Ndebele, South; South Ndebele") },
+ { "nd", LPGENW("Ndebele, North; North Ndebele") },
+ { "ng", LPGENW("Ndonga") },
+ { "ne", LPGENW("Nepali") },
+ { "nn", LPGENW("Norwegian Nynorsk; Nynorsk, Norwegian") },
+ { "nb", LPGENW("Bokmaal, Norwegian; Norwegian Bokmaal") },
+ { "no", LPGENW("Norwegian") },
+ { "ny", LPGENW("Chichewa; Chewa; Nyanja") },
+ { "oc", LPGENW("Occitan (post 1500); Provencal") },
+ { "oj", LPGENW("Ojibwa") },
+ { "or", LPGENW("Oriya") },
+ { "om", LPGENW("Oromo") },
+ { "os", LPGENW("Ossetian; Ossetic") },
+ { "pa", LPGENW("Panjabi; Punjabi") },
+ { "fa", LPGENW("Persian") },
+ { "pi", LPGENW("Pali") },
+ { "pl", LPGENW("Polish") },
+ { "pt", LPGENW("Portuguese") },
+ { "ps", LPGENW("Pushto") },
+ { "qu", LPGENW("Quechua") },
+ { "rm", LPGENW("Romansh") },
+ { "ro", LPGENW("Romanian") },
+ { "rn", LPGENW("Rundi") },
+ { "ru", LPGENW("Russian") },
+ { "sg", LPGENW("Sango") },
+ { "sa", LPGENW("Sanskrit") },
+ { "sr", LPGENW("Serbian") },
+ { "hr", LPGENW("Croatian") },
+ { "si", LPGENW("Sinhala; Sinhalese") },
+ { "sk", LPGENW("Slovak") },
+ { "sl", LPGENW("Slovenian") },
+ { "se", LPGENW("Northern Sami") },
+ { "sm", LPGENW("Samoan") },
+ { "sn", LPGENW("Shona") },
+ { "sd", LPGENW("Sindhi") },
+ { "so", LPGENW("Somali") },
+ { "st", LPGENW("Sotho, Southern") },
+ { "es", LPGENW("Spanish; Castilian") },
+ { "sc", LPGENW("Sardinian") },
+ { "ss", LPGENW("Swati") },
+ { "su", LPGENW("Sundanese") },
+ { "sw", LPGENW("Swahili") },
+ { "sv", LPGENW("Swedish") },
+ { "ty", LPGENW("Tahitian") },
+ { "ta", LPGENW("Tamil") },
+ { "tt", LPGENW("Tatar") },
+ { "te", LPGENW("Telugu") },
+ { "tg", LPGENW("Tajik") },
+ { "tl", LPGENW("Tagalog") },
+ { "th", LPGENW("Thai") },
+ { "bo", LPGENW("Tibetan") },
+ { "ti", LPGENW("Tigrinya") },
+ { "to", LPGENW("Tonga (Tonga Islands)") },
+ { "tn", LPGENW("Tswana") },
+ { "ts", LPGENW("Tsonga") },
+ { "tk", LPGENW("Turkmen") },
+ { "tr", LPGENW("Turkish") },
+ { "tw", LPGENW("Twi") },
+ { "ug", LPGENW("Uighur; Uyghur") },
+ { "uk", LPGENW("Ukrainian") },
+ { "ur", LPGENW("Urdu") },
+ { "uz", LPGENW("Uzbek") },
+ { "ve", LPGENW("Venda") },
+ { "vi", LPGENW("Vietnamese") },
+ { "vo", LPGENW("Volapuk") },
+ { "cy", LPGENW("Welsh") },
+ { "wa", LPGENW("Walloon") },
+ { "wo", LPGENW("Wolof") },
+ { "xh", LPGENW("Xhosa") },
+ { "yi", LPGENW("Yiddish") },
+ { "yo", LPGENW("Yoruba") },
+ { "za", LPGENW("Zhuang; Chuang") },
+ { "zu", LPGENW("Zulu") },
{ nullptr, nullptr }
};
@@ -453,7 +453,7 @@ protected:
for (int i = 0; g_LanguageCodes[i].szCode; i++) {
int iItem = m_cbLocale.AddString(TranslateW(g_LanguageCodes[i].szDescription), (LPARAM)g_LanguageCodes[i].szCode);
- if (!mir_wstrcmp(m_proto->m_tszSelectedLang, g_LanguageCodes[i].szCode))
+ if (!mir_strcmp(m_proto->m_tszSelectedLang, g_LanguageCodes[i].szCode))
m_cbLocale.SetCurSel(iItem);
}
@@ -489,12 +489,10 @@ protected:
int index = m_cbLocale.GetCurSel();
if (index >= 0) {
- wchar_t *szLanguageCode = (wchar_t *)m_cbLocale.GetItemData(index);
+ char *szLanguageCode = (char*)m_cbLocale.GetItemData(index);
if (szLanguageCode) {
- m_proto->setWString("XmlLang", szLanguageCode);
-
- mir_free(m_proto->m_tszSelectedLang);
- m_proto->m_tszSelectedLang = mir_wstrdup(szLanguageCode);
+ m_proto->setString("XmlLang", szLanguageCode);
+ replaceStr(m_proto->m_tszSelectedLang, szLanguageCode);
}
}
@@ -529,7 +527,7 @@ protected:
break;
case WM_JABBER_REFRESH:
- RefreshServers((HXML)lParam);
+ RefreshServers((TiXmlElement*)lParam);
break;
}
return CSuper::DlgProc(msg, wParam, lParam);
@@ -546,8 +544,8 @@ private:
SendMessage(m_hwnd, WM_NOTIFY, 0, (LPARAM)&pshn);
JABBER_CONN_DATA regInfo;
- m_txtUsername.GetText(regInfo.username, _countof(regInfo.username));
- m_txtPassword.GetText(regInfo.password, _countof(regInfo.password));
+ m_txtUsername.GetTextU(regInfo.username, _countof(regInfo.username));
+ m_txtPassword.GetTextU(regInfo.password, _countof(regInfo.password));
m_cbServer.GetTextA(regInfo.server, _countof(regInfo.server));
if (m_chkManualHost.GetState() == BST_CHECKED) {
regInfo.port = (WORD)m_txtManualPort.GetInt();
@@ -572,8 +570,8 @@ private:
if (res == IDYES)
m_proto->m_ThreadInfo->send(
- XmlNodeIq(L"set", m_proto->SerialNext(), m_proto->m_szJabberJID) << XQUERY(JABBER_FEAT_REGISTER)
- << XCHILD(L"remove"));
+ XmlNodeIq("set", m_proto->SerialNext(), m_proto->m_szJabberJID) << XQUERY(JABBER_FEAT_REGISTER)
+ << XCHILD("remove"));
}
void btnChangePassword_OnClick(CCtrlButton *)
@@ -665,8 +663,8 @@ private:
void CheckRegistration()
{
JABBER_CONN_DATA regInfo;
- m_txtUsername.GetText(regInfo.username, _countof(regInfo.username));
- m_txtPassword.GetText(regInfo.password, _countof(regInfo.password));
+ m_txtUsername.GetTextU(regInfo.username, _countof(regInfo.username));
+ m_txtPassword.GetTextU(regInfo.password, _countof(regInfo.password));
m_cbServer.GetTextA(regInfo.server, _countof(regInfo.server));
if (m_chkManualHost.GetState() == BST_CHECKED) {
regInfo.port = (WORD)m_txtManualPort.GetInt();
@@ -683,7 +681,7 @@ private:
EnableWindow(GetDlgItem(m_hwnd, IDC_BUTTON_REGISTER), FALSE);
}
- void RefreshServers(HXML node)
+ void RefreshServers(TiXmlElement *node)
{
m_gotservers = node != nullptr;
@@ -692,18 +690,13 @@ private:
if (bDropdown) m_cbServer.ShowDropdown(false);
m_cbServer.ResetContent();
- if (node) {
- for (int i = 0;; i++) {
- HXML n = XmlGetChild(node, i);
- if (!n)
- break;
-
- if (!mir_wstrcmp(XmlGetName(n), L"item"))
- if (const wchar_t *jid = XmlGetAttrValue(n, L"jid"))
- if (m_cbServer.FindString(jid, -1, true) == CB_ERR)
- m_cbServer.AddString(jid);
- }
- }
+ if (node)
+ for (auto *n : TiXmlFilter(node, "item"))
+ if (const char *jid = n->Attribute("jid")) {
+ Utf2T wszJid(jid);
+ if (m_cbServer.FindString(wszJid, -1, true) == CB_ERR)
+ m_cbServer.AddString(wszJid);
+ }
m_cbServer.SetText(server);
@@ -729,14 +722,12 @@ private:
NETLIBHTTPREQUEST *result = Netlib_HttpTransaction(wnd->GetProto()->m_hNetlibUser, &request);
if (result) {
if (result->resultCode == 200 && result->dataLength && result->pData) {
- wchar_t *buf = mir_a2u(result->pData);
- XmlNode node(buf, nullptr, nullptr);
- if (node) {
- HXML queryNode = XmlGetChild(node, L"query");
+ TiXmlDocument doc;
+ if (0 == doc.Parse(result->pData)) {
+ TiXmlElement *queryNode = doc.FirstChildElement("query");
SendMessage(hwnd, WM_JABBER_REFRESH, 0, (LPARAM)queryNode);
bIsError = false;
}
- mir_free(buf);
}
Netlib_FreeHttpRequest(result);
}
@@ -837,7 +828,7 @@ public:
{
JABBER_LIST_ITEM *item = m_proto->ListGetItemPtrFromIndex(index);
if (item != nullptr) {
- if (wcschr(item->jid, '@') == nullptr) {
+ if (strchr(item->jid, '@') == nullptr) {
MCONTACT hContact = m_proto->HContactFromJID(item->jid);
if (hContact != 0) {
if (bChecked) {
@@ -906,8 +897,8 @@ public:
m_otvOptions(this, IDC_OPTTREE)
{
CreateLink(m_txtAltNick, "GcAltNick", L"");
- CreateLink(m_txtSlap, "GcMsgSlap", TranslateW(JABBER_GC_MSG_SLAP));
- CreateLink(m_txtQuit, "GcMsgQuit", TranslateW(JABBER_GC_MSG_QUIT));
+ CreateLink(m_txtSlap, "GcMsgSlap", TranslateW(_T(JABBER_GC_MSG_SLAP)));
+ CreateLink(m_txtQuit, "GcMsgQuit", TranslateW(_T(JABBER_GC_MSG_QUIT)));
m_otvOptions.AddOption(LPGENW("General") L"/" LPGENW("Autoaccept multiuser chat invitations"), m_proto->m_bAutoAcceptMUC);
m_otvOptions.AddOption(LPGENW("General") L"/" LPGENW("Automatically join bookmarks on login"), m_proto->m_bAutoJoinBookmarks);
@@ -945,7 +936,7 @@ struct ROSTEREDITDAT
int subindex;
};
-static int _RosterInsertListItem(HWND hList, const wchar_t *jid, const wchar_t *nick, const wchar_t *group, const wchar_t *subscr, BOOL bChecked)
+static int _RosterInsertListItem(HWND hList, const char *jid, const char *nick, const char *group, const char *subscr, BOOL bChecked)
{
LVITEM item = { 0 };
item.mask = LVIF_TEXT | LVIF_STATE;
@@ -958,10 +949,10 @@ static int _RosterInsertListItem(HWND hList, const wchar_t *jid, const wchar_t *
ListView_SetCheckState(hList, index, bChecked);
- ListView_SetItemText(hList, index, 0, (wchar_t*)jid);
- ListView_SetItemText(hList, index, 1, (wchar_t*)nick);
- ListView_SetItemText(hList, index, 2, (wchar_t*)group);
- ListView_SetItemText(hList, index, 3, TranslateW(subscr));
+ ListView_SetItemText(hList, index, 0, Utf2T(jid));
+ ListView_SetItemText(hList, index, 1, Utf2T(nick));
+ ListView_SetItemText(hList, index, 2, Utf2T(group));
+ ListView_SetItemText(hList, index, 3, Utf2T(subscr));
return index;
}
@@ -1000,26 +991,22 @@ static void _RosterListClear(HWND hwndDlg)
ListView_SetColumnWidth(hList, 3, width * 10 / 100);
}
-void CJabberProto::_RosterHandleGetRequest(HXML node, CJabberIqInfo*)
+void CJabberProto::_RosterHandleGetRequest(const TiXmlElement *node, CJabberIqInfo*)
{
HWND hList = GetDlgItem(rrud.hwndDlg, IDC_ROSTER);
if (rrud.bRRAction == RRA_FILLLIST) {
_RosterListClear(rrud.hwndDlg);
- HXML query = XmlGetChild(node, "query");
+ auto *query = node->FirstChildElement("query");
if (query == nullptr) return;
- int i = 1;
- while (TRUE) {
- HXML item = XmlGetNthChild(query, L"item", i++);
- if (item == nullptr)
- break;
- const wchar_t *jid = XmlGetAttrValue(item, L"jid");
+ for (auto *item : TiXmlFilter(query, "item")) {
+ const char *jid = item->Attribute("jid");
if (jid == nullptr)
continue;
- const wchar_t *name = XmlGetAttrValue(item, L"name");
- const wchar_t *subscription = XmlGetAttrValue(item, L"subscription");
- const wchar_t *group = XmlGetText(XmlGetChild(item, "group"));
+ const char *name = item->Attribute("name");
+ const char *subscription = item->Attribute("subscription");
+ const char *group = item->FirstChildElement("group")->GetText();
_RosterInsertListItem(hList, jid, name, group, subscription, TRUE);
}
@@ -1038,9 +1025,9 @@ void CJabberProto::_RosterHandleGetRequest(HXML node, CJabberIqInfo*)
if (p) *p = 0;
}
if (ListView_FindItem(hList, -1, &lvfi) == -1) {
- ptrW tszName(db_get_wsa(hContact, "CList", "MyHandle"));
- ptrW tszGroup(db_get_wsa(hContact, "CList", "Group"));
- _RosterInsertListItem(hList, tszJid, tszName, tszGroup, nullptr, FALSE);
+ ptrA tszName(db_get_utfa(hContact, "CList", "MyHandle"));
+ ptrA tszGroup(db_get_utfa(hContact, "CList", "Group"));
+ _RosterInsertListItem(hList, T2Utf(tszJid), tszName, tszGroup, nullptr, FALSE);
}
}
rrud.bReadyToDownload = FALSE;
@@ -1053,56 +1040,58 @@ void CJabberProto::_RosterHandleGetRequest(HXML node, CJabberIqInfo*)
if (rrud.bRRAction == RRA_SYNCROSTER) {
SetDlgItemText(rrud.hwndDlg, IDC_UPLOAD, TranslateT("Uploading..."));
- HXML queryRoster = XmlGetChild(node, "query");
+ auto *queryRoster = node->FirstChildElement("query");
if (!queryRoster)
return;
XmlNodeIq iq(AddIQ(&CJabberProto::_RosterHandleGetRequest, JABBER_IQ_TYPE_SET));
- HXML query = iq << XCHILDNS(L"query", JABBER_FEAT_IQ_ROSTER);
+ TiXmlElement *query = iq << XCHILDNS("query", JABBER_FEAT_IQ_ROSTER);
int itemCount = 0;
int ListItemCount = ListView_GetItemCount(hList);
for (int index = 0; index < ListItemCount; index++) {
wchar_t jid[JABBER_MAX_JID_LEN] = L"";
- wchar_t name[260] = L"";
- wchar_t group[260] = L"";
- wchar_t subscr[260] = L"";
+ wchar_t name[260];
+ wchar_t group[260];
+ wchar_t subscr[260];
ListView_GetItemText(hList, index, 0, jid, _countof(jid));
ListView_GetItemText(hList, index, 1, name, _countof(name));
ListView_GetItemText(hList, index, 2, group, _countof(group));
ListView_GetItemText(hList, index, 3, subscr, _countof(subscr));
- HXML itemRoster = XmlGetChildByTag(queryRoster, "item", "jid", jid);
+
+ T2Utf szJid(jid), szName(name), szGroup(group), szSubscr(subscr);
+ auto *itemRoster = XmlGetChildByTag(queryRoster, "item", "jid", szJid);
BOOL bRemove = !ListView_GetCheckState(hList, index);
if (itemRoster && bRemove) {
//delete item
- query << XCHILD(L"item") << XATTR(L"jid", jid) << XATTR(L"subscription", L"remove");
+ query << XCHILD("item") << XATTR("jid", szJid) << XATTR("subscription", "remove");
itemCount++;
}
else if (!bRemove) {
BOOL bPushed = itemRoster ? TRUE : FALSE;
if (!bPushed) {
- const wchar_t *rosterName = XmlGetAttrValue(itemRoster, L"name");
- if ((rosterName != nullptr || name[0] != 0) && mir_wstrcmpi(rosterName, name))
+ const char *rosterName = itemRoster->Attribute("name");
+ if ((rosterName != nullptr || name[0] != 0) && mir_strcmpi(rosterName, szName))
bPushed = TRUE;
if (!bPushed) {
- rosterName = XmlGetAttrValue(itemRoster, L"subscription");
- if ((rosterName != nullptr || subscr[0] != 0) && mir_wstrcmpi(rosterName, subscr))
+ rosterName = itemRoster->Attribute("subscription");
+ if ((rosterName != nullptr || subscr[0] != 0) && mir_strcmpi(rosterName, T2Utf(subscr)))
bPushed = TRUE;
}
if (!bPushed) {
- const wchar_t *rosterGroup = XmlGetText(XmlGetChild(itemRoster, "group"));
- if ((rosterGroup != nullptr || group[0] != 0) && mir_wstrcmpi(rosterGroup, group))
+ const char *rosterGroup = itemRoster->FirstChildElement("group")->GetText();
+ if ((rosterGroup != nullptr || group[0] != 0) && mir_strcmpi(rosterGroup, szGroup))
bPushed = TRUE;
}
}
if (bPushed) {
- HXML item = query << XCHILD(L"item");
+ TiXmlElement *item = query << XCHILD("item");
if (mir_wstrlen(group))
- item << XCHILD(L"group", group);
+ item << XCHILD("group", szGroup);
if (mir_wstrlen(name))
- item << XATTR(L"name", name);
- item << XATTR(L"jid", jid) << XATTR(L"subscription", subscr[0] ? subscr : L"none");
+ item << XATTR("name", szName);
+ item << XATTR("jid", szJid) << XATTR("subscription", subscr[0] ? szSubscr : "none");
itemCount++;
}
}
@@ -1129,7 +1118,7 @@ void CJabberProto::_RosterSendRequest(HWND hwndDlg, BYTE rrAction)
m_ThreadInfo->send(
XmlNodeIq(AddIQ(&CJabberProto::_RosterHandleGetRequest, JABBER_IQ_TYPE_GET))
- << XCHILDNS(L"query", JABBER_FEAT_IQ_ROSTER));
+ << XCHILDNS("query", JABBER_FEAT_IQ_ROSTER));
}
static void _RosterItemEditEnd(HWND hEditor, ROSTEREDITDAT * edat, BOOL bCancel)
@@ -1201,21 +1190,21 @@ void CJabberProto::_RosterExportToFile(HWND hwndDlg)
ofn.lpstrDefExt = L"xml";
if (!GetSaveFileName(&ofn)) return;
- FILE * fp = fopent(filename, L"w");
+ FILE * fp = fopent(filename, L"wb");
if (!fp) return;
HWND hList = GetDlgItem(hwndDlg, IDC_ROSTER);
int ListItemCount = ListView_GetItemCount(hList);
- XmlNode root(L"Workbook");
- root << XATTR(L"xmlns", L"urn:schemas-microsoft-com:office:spreadsheet")
- << XATTR(L"xmlns:o", L"urn:schemas-microsoft-com:office:office")
- << XATTR(L"xmlns:x", L"urn:schemas-microsoft-com:office:excel")
- << XATTR(L"xmlns:ss", L"urn:schemas-microsoft-com:office:spreadsheet")
- << XATTR(L"xmlns:html", L"http://www.w3.org/TR/REC-html40");
- root << XCHILD(L"ExcelWorkbook")
- << XATTR(L"xmlns", L"urn:schemas-microsoft-com:office:excel");
- HXML table = root << XCHILD(L"Worksheet") << XATTR(L"ss:Name", L"Exported roster")
- << XCHILD(L"Table");
+ XmlNode root("Workbook");
+ root << XATTR("xmlns", "urn:schemas-microsoft-com:office:spreadsheet")
+ << XATTR("xmlns:o", "urn:schemas-microsoft-com:office:office")
+ << XATTR("xmlns:x", "urn:schemas-microsoft-com:office:excel")
+ << XATTR("xmlns:ss", "urn:schemas-microsoft-com:office:spreadsheet")
+ << XATTR("xmlns:html", "http://www.w3.org/TR/REC-html40");
+ root << XCHILD("ExcelWorkbook")
+ << XATTR("xmlns", "urn:schemas-microsoft-com:office:excel");
+ TiXmlElement *table = root << XCHILD("Worksheet") << XATTR("ss:Name", "Exported roster")
+ << XCHILD("Table");
for (int index = 0; index < ListItemCount; index++) {
wchar_t jid[JABBER_MAX_JID_LEN] = L"";
@@ -1227,29 +1216,30 @@ void CJabberProto::_RosterExportToFile(HWND hwndDlg)
ListView_GetItemText(hList, index, 2, group, _countof(group));
ListView_GetItemText(hList, index, 3, subscr, _countof(subscr));
- HXML node = table << XCHILD(L"Row");
- node << XCHILD(L"Cell") << XCHILD(L"Data", L"+") << XATTR(L"ss:Type", L"String");
- node << XCHILD(L"Cell") << XCHILD(L"Data", jid) << XATTR(L"ss:Type", L"String");
- node << XCHILD(L"Cell") << XCHILD(L"Data", name) << XATTR(L"ss:Type", L"String");
- node << XCHILD(L"Cell") << XCHILD(L"Data", group) << XATTR(L"ss:Type", L"String");
- node << XCHILD(L"Cell") << XCHILD(L"Data", subscr) << XATTR(L"ss:Type", L"String");
+ TiXmlElement *node = table << XCHILD("Row");
+ node << XCHILD("Cell") << XCHILD("Data", "+") << XATTR("ss:Type", "String");
+ node << XCHILD("Cell") << XCHILD("Data", T2Utf(jid)) << XATTR("ss:Type", "String");
+ node << XCHILD("Cell") << XCHILD("Data", T2Utf(name)) << XATTR("ss:Type", "String");
+ node << XCHILD("Cell") << XCHILD("Data", T2Utf(group)) << XATTR("ss:Type", "String");
+ node << XCHILD("Cell") << XCHILD("Data", T2Utf(subscr)) << XATTR("ss:Type", "String");
}
char header[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?mso-application progid=\"Excel.Sheet\"?>\n";
fwrite(header, 1, sizeof(header) - 1 /* for zero terminator */, fp);
- wchar_t *xtmp = xmlToString(root, nullptr);
- fputs(T2Utf(xtmp), fp);
- xmlFree(xtmp);
+ tinyxml2::XMLPrinter printer(0);
+ root.Print(&printer);
+ fputs(printer.CStr(), fp);
fclose(fp);
}
void CJabberProto::_RosterImportFromFile(HWND hwndDlg)
{
- char filename[MAX_PATH] = { 0 };
- char *filter = "XML for MS Excel (UTF-8 encoded)(*.xml)\0*.xml\0\0";
- OPENFILENAMEA ofn = { 0 };
+ wchar_t filename[MAX_PATH] = { 0 };
+ wchar_t *filter = L"XML for MS Excel (UTF-8 encoded)(*.xml)\0*.xml\0\0";
+
+ OPENFILENAME ofn = { 0 };
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
ofn.hwndOwner = hwndDlg;
ofn.hInstance = nullptr;
@@ -1258,86 +1248,64 @@ void CJabberProto::_RosterImportFromFile(HWND hwndDlg)
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.nMaxFile = _countof(filename);
ofn.nMaxFileTitle = MAX_PATH;
- ofn.lpstrDefExt = "xml";
- if (!GetOpenFileNameA(&ofn))
+ ofn.lpstrDefExt = L"xml";
+ if (!GetOpenFileNameW(&ofn))
return;
- FILE * fp = fopen(filename, "r");
+ FILE * fp = _wfopen(filename, L"rb");
if (!fp)
return;
- DWORD bufsize = _filelength(_fileno(fp));
- if (bufsize <= 0) {
- fclose(fp);
+ TiXmlDocument doc;
+ int ret = doc.LoadFile(fp);
+ fclose(fp);
+ if (ret != 0)
return;
- }
- char* buffer = (char*)mir_calloc(bufsize + 1); // zero-terminate it
- fread(buffer, 1, bufsize, fp);
- fclose(fp);
_RosterListClear(hwndDlg);
- wchar_t *newBuf = mir_utf8decodeW(buffer);
- mir_free(buffer);
-
- int nBytesProcessed = 0;
- XmlNode node(newBuf, &nBytesProcessed, nullptr);
- if (node) {
- HXML Workbook = XmlGetChild(node, L"Workbook");
- if (Workbook) {
- HXML Worksheet = XmlGetChild(Workbook, "Worksheet");
- if (Worksheet) {
- HXML Table = XmlGetChild(Worksheet, "Table");
- if (Table) {
- int index = 1;
- HWND hList = GetDlgItem(hwndDlg, IDC_ROSTER);
- while (TRUE) {
- HXML Row = XmlGetNthChild(Table, L"Row", index++);
- if (!Row)
- break;
-
- BOOL bAdd = FALSE;
- const wchar_t *jid = nullptr;
- const wchar_t *name = nullptr;
- const wchar_t *group = nullptr;
- const wchar_t *subscr = nullptr;
- HXML Cell = XmlGetNthChild(Row, L"Cell", 1);
- HXML Data = (Cell) ? XmlGetChild(Cell, "Data") : XmlNode();
- if (Data) {
- if (!mir_wstrcmpi(XmlGetText(Data), L"+")) bAdd = TRUE;
- else if (mir_wstrcmpi(XmlGetText(Data), L"-")) continue;
-
- Cell = XmlGetNthChild(Row, L"Cell", 2);
- if (Cell) Data = XmlGetChild(Cell, "Data");
- else Data = nullptr;
- if (Data) {
- jid = XmlGetText(Data);
- if (!jid || mir_wstrlen(jid) == 0) continue;
- }
+ const TiXmlElement *Table = TiXmlConst(&doc)["Workbook"]["Worksheet"]["Table"].ToElement();
+ if (Table) {
+ HWND hList = GetDlgItem(hwndDlg, IDC_ROSTER);
+ for (auto *Row : TiXmlFilter(Table, "Row")) {
+ BOOL bAdd = FALSE;
+ const char *jid = nullptr;
+ const char *name = nullptr;
+ const char *group = nullptr;
+ const char *subscr = nullptr;
+ auto *Cell = Row->FirstChildElement("Cell");
+ auto *Data = Cell->FirstChildElement("Data");
+ if (Data) {
+ if (!mir_strcmpi(Data->GetText(), "+")) bAdd = TRUE;
+ else if (mir_strcmpi(Data->GetText(), "-")) continue;
+
+ Cell = Cell->NextSiblingElement("Cell");
+ if (Cell) Data = Cell->FirstChildElement("Data");
+ else Data = nullptr;
+ if (Data) {
+ jid = Data->GetText();
+ if (!jid || mir_strlen(jid) == 0) continue;
+ }
- Cell = XmlGetNthChild(Row, L"Cell", 3);
- if (Cell) Data = XmlGetChild(Cell, "Data");
- else Data = nullptr;
- if (Data) name = XmlGetText(Data);
+ Cell = Cell->NextSiblingElement("Cell");
+ if (Cell) Data = Cell->FirstChildElement("Data");
+ else Data = nullptr;
+ if (Data) name = Data->GetText();
- Cell = XmlGetNthChild(Row, L"Cell", 4);
- if (Cell) Data = XmlGetChild(Cell, "Data");
- else Data = nullptr;
- if (Data) group = XmlGetText(Data);
+ Cell = Cell->NextSiblingElement("Cell");
+ if (Cell) Data = Cell->FirstChildElement("Data");
+ else Data = nullptr;
+ if (Data) group = Data->GetText();
- Cell = XmlGetNthChild(Row, L"Cell", 5);
- if (Cell) Data = XmlGetChild(Cell, "Data");
- else Data = nullptr;
- if (Data) subscr = XmlGetText(Data);
- }
- _RosterInsertListItem(hList, jid, name, group, subscr, bAdd);
- }
- }
+ Cell = Cell->NextSiblingElement("Cell");
+ if (Cell) Data = Cell->FirstChildElement("Data");
+ else Data = nullptr;
+ if (Data) subscr = Data->GetText();
}
+ _RosterInsertListItem(hList, jid, name, group, subscr, bAdd);
}
}
- mir_free(newBuf);
SendMessage(hwndDlg, JM_STATUSCHANGED, 0, 0);
}
@@ -1823,7 +1791,7 @@ protected:
{
switch (msg) {
case WM_JABBER_REFRESH:
- RefreshServers((HXML)lParam);
+ RefreshServers((TiXmlElement*)lParam);
break;
}
return CSuper::DlgProc(msg, wParam, lParam);
@@ -1841,8 +1809,8 @@ private:
SendMessage(m_hwnd, WM_NOTIFY, 0, (LPARAM)&pshn);
JABBER_CONN_DATA regInfo;
- m_txtUsername.GetText(regInfo.username, _countof(regInfo.username));
- m_txtPassword.GetText(regInfo.password, _countof(regInfo.password));
+ m_txtUsername.GetTextU(regInfo.username, _countof(regInfo.username));
+ m_txtPassword.GetTextU(regInfo.password, _countof(regInfo.password));
m_cbServer.GetTextA(regInfo.server, _countof(regInfo.server));
regInfo.port = (WORD)m_txtPort.GetInt();
if (m_chkManualHost.GetState() == BST_CHECKED)
@@ -1909,8 +1877,8 @@ private:
}
JABBER_CONN_DATA regInfo;
- m_txtUsername.GetText(regInfo.username, _countof(regInfo.username));
- m_txtPassword.GetText(regInfo.password, _countof(regInfo.password));
+ m_txtUsername.GetTextU(regInfo.username, _countof(regInfo.username));
+ m_txtPassword.GetTextU(regInfo.password, _countof(regInfo.password));
m_cbServer.GetTextA(regInfo.server, _countof(regInfo.server));
regInfo.port = m_txtPort.GetInt();
if (m_chkManualHost.GetState() == BST_CHECKED)
@@ -2149,7 +2117,7 @@ private:
m_btnRegister.Disable();
}
- void RefreshServers(HXML node)
+ void RefreshServers(TiXmlElement *node)
{
m_gotservers = node != nullptr;
@@ -2158,18 +2126,13 @@ private:
if (bDropdown) m_cbServer.ShowDropdown(false);
m_cbServer.ResetContent();
- if (node) {
- for (int i = 0;; i++) {
- HXML n = XmlGetChild(node, i);
- if (!n)
- break;
-
- if (!mir_wstrcmp(XmlGetName(n), L"item"))
- if (const wchar_t *jid = XmlGetAttrValue(n, L"jid"))
- if (m_cbServer.FindString(jid, -1, true) == CB_ERR)
- m_cbServer.AddString(jid);
- }
- }
+ if (node)
+ for (auto *n : TiXmlFilter(node, "item"))
+ if (const char *jid = n->Attribute("jid")) {
+ Utf2T wszJid(jid);
+ if (m_cbServer.FindString(wszJid, -1, true) == CB_ERR)
+ m_cbServer.AddString(wszJid);
+ }
m_cbServer.SetText(server);
@@ -2191,16 +2154,14 @@ private:
NETLIBHTTPREQUEST *result = Netlib_HttpTransaction(wnd->GetProto()->m_hNetlibUser, &request);
if (result && IsWindow(hwnd)) {
if ((result->resultCode == 200) && result->dataLength && result->pData) {
- wchar_t *ptszText = mir_a2u(result->pData);
- XmlNode node(ptszText, nullptr, nullptr);
- if (node) {
- HXML queryNode = XmlGetChild(node, L"query");
+ TiXmlDocument doc;
+ if (0 == doc.Parse(result->pData)) {
+ const TiXmlElement *queryNode = doc.FirstChildElement("query");
if (queryNode && IsWindow(hwnd)) {
SendMessage(hwnd, WM_JABBER_REFRESH, 0, (LPARAM)queryNode);
bIsError = false;
}
}
- mir_free(ptszText);
}
}
diff --git a/protocols/JabberG/src/jabber_password.cpp b/protocols/JabberG/src/jabber_password.cpp
index bb0a0bcc83..1fe7ed41f0 100644
--- a/protocols/JabberG/src/jabber_password.cpp
+++ b/protocols/JabberG/src/jabber_password.cpp
@@ -56,22 +56,22 @@ public:
if (!m_proto->m_bJabberOnline || m_proto->m_ThreadInfo == nullptr)
return false;
- ptrW newPass1(edtPass1.GetText()), newPass2(edtPass2.GetText());
- if (mir_wstrcmp(newPass1, newPass2)) {
+ ptrA newPass1(edtPass1.GetTextU()), newPass2(edtPass2.GetTextU());
+ if (mir_strcmp(newPass1, newPass2)) {
MessageBox(m_hwnd, TranslateT("New password does not match."), TranslateT("Change Password"), MB_OK|MB_ICONSTOP|MB_SETFOREGROUND);
return false;
}
- if (mir_wstrcmp(ptrW(edtOldPass.GetText()), m_proto->m_ThreadInfo->conn.password)) {
+ if (mir_strcmp(ptrA(edtOldPass.GetTextU()), m_proto->m_ThreadInfo->conn.password)) {
MessageBox(m_hwnd, TranslateT("Current password is incorrect."), TranslateT("Change Password"), MB_OK|MB_ICONSTOP|MB_SETFOREGROUND);
return false;
}
m_proto->m_ThreadInfo->tszNewPassword = newPass1.detach();
- XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultSetPassword, JABBER_IQ_TYPE_SET, _A2T(m_proto->m_ThreadInfo->conn.server)));
- HXML q = iq << XQUERY(JABBER_FEAT_REGISTER);
- q << XCHILD(L"username", m_proto->m_ThreadInfo->conn.username);
- q << XCHILD(L"password", m_proto->m_ThreadInfo->tszNewPassword);
+ XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultSetPassword, JABBER_IQ_TYPE_SET, m_proto->m_ThreadInfo->conn.server));
+ TiXmlElement *q = iq << XQUERY(JABBER_FEAT_REGISTER);
+ q << XCHILD("username", m_proto->m_ThreadInfo->conn.username);
+ q << XCHILD("password", m_proto->m_ThreadInfo->tszNewPassword);
m_proto->m_ThreadInfo->send(iq);
return true;
}
diff --git a/protocols/JabberG/src/jabber_presence_manager.cpp b/protocols/JabberG/src/jabber_presence_manager.cpp
index 5d4fbb92a7..27d2191fa7 100644
--- a/protocols/JabberG/src/jabber_presence_manager.cpp
+++ b/protocols/JabberG/src/jabber_presence_manager.cpp
@@ -64,7 +64,7 @@ bool CJabberPresenceManager::DeletePermanentHandler(CJabberPresencePermanentInfo
return m_arHandlers.remove(pInfo) == 1;
}
-bool CJabberPresenceManager::HandlePresencePermanent(HXML node, ThreadData *pThreadData)
+bool CJabberPresenceManager::HandlePresencePermanent(const TiXmlElement *node, ThreadData *pThreadData)
{
for (auto &it : m_arHandlers) {
CJabberPresenceInfo presenceInfo;
diff --git a/protocols/JabberG/src/jabber_presence_manager.h b/protocols/JabberG/src/jabber_presence_manager.h
index 97aab5aba3..21b1513be8 100644
--- a/protocols/JabberG/src/jabber_presence_manager.h
+++ b/protocols/JabberG/src/jabber_presence_manager.h
@@ -30,12 +30,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "jabber_xml.h"
struct CJabberProto;
-typedef void (CJabberProto::*JABBER_PRESENCE_PFUNC)(HXML node, void *usedata);
+typedef void (CJabberProto::*JABBER_PRESENCE_PFUNC)(const TiXmlElement *node, void *usedata);
typedef void (*PRESENCE_USER_DATA_FREE_FUNC)(void *pUserData);
class CJabberPresenceInfo;
-typedef BOOL (CJabberProto::*JABBER_PRESENCE_HANDLER)(HXML node, ThreadData *pThreadData, CJabberPresenceInfo* pInfo);
+typedef BOOL (CJabberProto::*JABBER_PRESENCE_HANDLER)(const TiXmlElement *node, ThreadData *pThreadData, CJabberPresenceInfo* pInfo);
class CJabberPresenceInfo
{
@@ -98,7 +98,7 @@ public:
CJabberPresencePermanentInfo* AddPermanentHandler(JABBER_PRESENCE_HANDLER pHandler, void *pUserData = nullptr, PRESENCE_USER_DATA_FREE_FUNC pUserDataFree = nullptr, int iPriority = JH_PRIORITY_DEFAULT);
bool DeletePermanentHandler(CJabberPresencePermanentInfo *pInfo);
- bool HandlePresencePermanent(HXML node, ThreadData *pThreadData);
+ bool HandlePresencePermanent(const TiXmlElement *node, ThreadData *pThreadData);
};
#endif
diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp
index 0bf03846e5..52eadfbe2f 100644
--- a/protocols/JabberG/src/jabber_privacy.cpp
+++ b/protocols/JabberG/src/jabber_privacy.cpp
@@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
const wchar_t JABBER_PL_BUSY_MSG[] = LPGENW("Sending request, please wait...");
-BOOL CJabberProto::OnIqRequestPrivacyLists(HXML, CJabberIqInfo *pInfo)
+BOOL CJabberProto::OnIqRequestPrivacyLists(const TiXmlElement*, CJabberIqInfo *pInfo)
{
if (pInfo->GetIqType() == JABBER_IQ_TYPE_SET) {
if (!m_pDlgPrivacyLists) {
@@ -39,12 +39,12 @@ BOOL CJabberProto::OnIqRequestPrivacyLists(HXML, CJabberIqInfo *pInfo)
}
else m_pDlgPrivacyLists->SetStatusText(TranslateT("Warning: privacy lists were changed on server."));
- m_ThreadInfo->send( XmlNodeIq(L"result", pInfo));
+ m_ThreadInfo->send(XmlNodeIq("result", pInfo));
}
return TRUE;
}
-void CJabberProto::OnIqResultPrivacyListModify(HXML, CJabberIqInfo *pInfo)
+void CJabberProto::OnIqResultPrivacyListModify(const TiXmlElement*, CJabberIqInfo *pInfo)
{
if (!pInfo->m_pUserData)
return;
@@ -56,7 +56,7 @@ void CJabberProto::OnIqResultPrivacyListModify(HXML, CJabberIqInfo *pInfo)
InterlockedDecrement(&pParam->m_dwCount);
if (!pParam->m_dwCount) {
- wchar_t szText[ 512 ];
+ wchar_t szText[512];
if (!pParam->m_bAllOk)
mir_snwprintf(szText, TranslateT("Error occurred while applying changes"));
else
@@ -68,25 +68,26 @@ void CJabberProto::OnIqResultPrivacyListModify(HXML, CJabberIqInfo *pInfo)
}
}
-void CJabberProto::OnIqResultPrivacyList(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultPrivacyList(const TiXmlElement *iqNode, CJabberIqInfo*)
{
if (iqNode == nullptr)
return;
- const wchar_t *type = XmlGetAttrValue(iqNode, L"type");
+ const char *type = iqNode->Attribute("type");
if (type == nullptr)
return;
- if ( mir_wstrcmp(type, L"result"))
+ if (mir_strcmp(type, "result"))
return;
- HXML query = XmlGetChild(iqNode , "query");
+ auto *query = iqNode->FirstChildElement("query");
if (query == nullptr)
return;
- HXML list = XmlGetChild(query, "list");
+ auto *list = query->FirstChildElement("list");
if (list == nullptr)
return;
- wchar_t *szListName = (wchar_t*)XmlGetAttrValue(list, L"name");
+
+ const char *szListName = (char*)list->Attribute("name");
if (!szListName)
return;
@@ -99,39 +100,37 @@ void CJabberProto::OnIqResultPrivacyList(HXML iqNode, CJabberIqInfo*)
return;
}
- HXML item;
- for (int i = 1; (item = XmlGetNthChild(list, L"item", i)) != nullptr; i++) {
- const wchar_t *itemType = XmlGetAttrValue(item, L"type");
+ for (auto *item : TiXmlFilter(list, "item")) {
+ const char *itemType = item->Attribute("type");
PrivacyListRuleType nItemType = Else;
if (itemType) {
- if (!mir_wstrcmpi(itemType, L"jid"))
+ if (!mir_strcmpi(itemType, "jid"))
nItemType = Jid;
- else if (!mir_wstrcmpi(itemType, L"group"))
+ else if (!mir_strcmpi(itemType, "group"))
nItemType = Group;
- else if (!mir_wstrcmpi(itemType, L"subscription"))
+ else if (!mir_strcmpi(itemType, "subscription"))
nItemType = Subscription;
}
- const wchar_t *itemValue = XmlGetAttrValue(item, L"value");
-
- const wchar_t *itemAction = XmlGetAttrValue(item, L"action");
+ const char *itemValue = item->Attribute("value");
+ const char *itemAction = item->Attribute("action");
BOOL bAllow = TRUE;
- if (itemAction && !mir_wstrcmpi(itemAction, L"deny"))
+ if (itemAction && !mir_strcmpi(itemAction, "deny"))
bAllow = FALSE;
- const wchar_t *itemOrder = XmlGetAttrValue(item, L"order");
+ const char *itemOrder = item->Attribute("order");
DWORD dwOrder = 0;
if (itemOrder)
- dwOrder = _wtoi(itemOrder);
+ dwOrder = atoi(itemOrder);
DWORD dwPackets = 0;
- if (XmlGetChild(item , "message"))
+ if (item->FirstChildElement("message"))
dwPackets |= JABBER_PL_RULE_TYPE_MESSAGE;
- if (XmlGetChild(item , "presence-in"))
+ if (item->FirstChildElement("presence-in"))
dwPackets |= JABBER_PL_RULE_TYPE_PRESENCE_IN;
- if (XmlGetChild(item , "presence-out"))
+ if (item->FirstChildElement("presence-out"))
dwPackets |= JABBER_PL_RULE_TYPE_PRESENCE_OUT;
- if (XmlGetChild(item , "iq"))
+ if (item->FirstChildElement("iq"))
dwPackets |= JABBER_PL_RULE_TYPE_IQ;
pList->AddRule(nItemType, itemValue, bAllow, dwOrder, dwPackets);
}
@@ -169,7 +168,7 @@ CPrivacyListRule* GetSelectedRule(HWND hDlg)
return (CPrivacyListRule*)nItemData;
}
-void CJabberProto::OnIqResultPrivacyListActive(HXML iqNode, CJabberIqInfo *pInfo)
+void CJabberProto::OnIqResultPrivacyListActive(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
CPrivacyList *pList = (CPrivacyList *)pInfo->GetUserData();
@@ -179,21 +178,21 @@ void CJabberProto::OnIqResultPrivacyListActive(HXML iqNode, CJabberIqInfo *pInfo
if (iqNode == nullptr)
return;
- const wchar_t *type = XmlGetAttrValue(iqNode, L"type");
+ const char *type = iqNode->Attribute("type");
if (type == nullptr)
return;
CMStringW szText;
- if (!mir_wstrcmp(type, L"result")) {
+ if (!mir_strcmp(type, "result")) {
mir_cslock lck(m_privacyListManager.m_cs);
if (pList) {
m_privacyListManager.SetActiveListName(pList->GetListName());
- szText.Format( TranslateT("Privacy list %s set as active"), pList->GetListName());
+ szText.Format(TranslateT("Privacy list %s set as active"), pList->GetListName());
}
else {
m_privacyListManager.SetActiveListName(nullptr);
- szText.Format( TranslateT("Active privacy list successfully declined"));
+ szText.Format(TranslateT("Active privacy list successfully declined"));
}
}
else szText = TranslateT("Error occurred while setting active list");
@@ -206,7 +205,7 @@ void CJabberProto::OnIqResultPrivacyListActive(HXML iqNode, CJabberIqInfo *pInfo
BuildPrivacyListsMenu(true);
}
-void CJabberProto::OnIqResultPrivacyListDefault(HXML iqNode, CJabberIqInfo *pInfo)
+void CJabberProto::OnIqResultPrivacyListDefault(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
if (m_pDlgPrivacyLists)
EnableWindow(GetDlgItem(m_pDlgPrivacyLists->GetHwnd(), IDC_SET_DEFAULT), TRUE);
@@ -214,15 +213,15 @@ void CJabberProto::OnIqResultPrivacyListDefault(HXML iqNode, CJabberIqInfo *pInf
if (iqNode == nullptr)
return;
- const wchar_t *type = XmlGetAttrValue(iqNode, L"type");
+ const char *type = iqNode->Attribute("type");
if (type == nullptr)
return;
- wchar_t szText[ 512 ];
+ wchar_t szText[512];
szText[0] = 0;
{
mir_cslock lck(m_privacyListManager.m_cs);
- if (!mir_wstrcmp(type, L"result")) {
+ if (!mir_strcmp(type, "result")) {
CPrivacyList *pList = (CPrivacyList *)pInfo->GetUserData();
if (pList) {
m_privacyListManager.SetDefaultListName(pList->GetListName());
@@ -242,12 +241,12 @@ void CJabberProto::OnIqResultPrivacyListDefault(HXML iqNode, CJabberIqInfo *pInf
}
}
-void CJabberProto::OnIqResultPrivacyLists(HXML iqNode, CJabberIqInfo *pInfo)
+void CJabberProto::OnIqResultPrivacyLists(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
if (pInfo->m_nIqType != JABBER_IQ_TYPE_RESULT)
return;
- HXML query = XmlGetChild(iqNode, "query");
+ auto *query = iqNode->FirstChildElement("query");
if (query == nullptr)
return;
@@ -257,33 +256,29 @@ void CJabberProto::OnIqResultPrivacyLists(HXML iqNode, CJabberIqInfo *pInfo)
mir_cslock lck(m_privacyListManager.m_cs);
m_privacyListManager.RemoveAllLists();
- for (int i = 1; ; i++) {
- HXML list = XmlGetNthChild(query, L"list", i);
- if (list == nullptr)
- break;
-
- const wchar_t *listName = XmlGetAttrValue(list, L"name");
+ for (auto *list : TiXmlFilter(query, "list")) {
+ const char *listName = list->Attribute("name");
if (listName) {
- m_privacyListManager.AddList((wchar_t*)listName);
+ m_privacyListManager.AddList(listName);
// Query contents only if list editior is visible!
if (m_pDlgPrivacyLists)
m_ThreadInfo->send(
XmlNodeIq(AddIQ(&CJabberProto::OnIqResultPrivacyList, JABBER_IQ_TYPE_GET))
- << XQUERY(JABBER_FEAT_PRIVACY_LISTS) << XCHILD(L"list") << XATTR(L"name", listName));
+ << XQUERY(JABBER_FEAT_PRIVACY_LISTS) << XCHILD("list") << XATTR("name", listName));
}
}
- const wchar_t *szName = nullptr;
- HXML node = XmlGetChild(query , "active");
+ const char *szName = nullptr;
+ auto *node = query->FirstChildElement("active");
if (node)
- szName = XmlGetAttrValue(node, L"name");
+ szName = node->Attribute("name");
m_privacyListManager.SetActiveListName(szName);
szName = nullptr;
- node = XmlGetChild(query , "default");
+ node = query->FirstChildElement("default");
if (node)
- szName = XmlGetAttrValue(node, L"name");
+ szName = node->Attribute("name");
m_privacyListManager.SetDefaultListName(szName);
}
UI_SAFE_NOTIFY(m_pDlgPrivacyLists, WM_JABBER_REFRESH);
@@ -293,14 +288,14 @@ void CJabberProto::OnIqResultPrivacyLists(HXML iqNode, CJabberIqInfo *pInfo)
/////////////////////////////////////////////////////////////////////////////////////////
// Add privacy list box
-class CJabberDlgPrivacyAddList: public CJabberDlgBase
+class CJabberDlgPrivacyAddList : public CJabberDlgBase
{
typedef CJabberDlgBase CSuper;
public:
- wchar_t szLine[512];
+ char szLine[512];
- CJabberDlgPrivacyAddList(CJabberProto *proto, HWND hwndParent):
+ CJabberDlgPrivacyAddList(CJabberProto *proto, HWND hwndParent) :
CJabberDlgBase(proto, IDD_PRIVACY_ADD_LIST),
m_txtName(this, IDC_EDIT_NAME),
m_btnOk(this, IDOK),
@@ -314,12 +309,12 @@ public:
void btnOk_OnClick(CCtrlButton*)
{
- GetDlgItemText(m_hwnd, IDC_EDIT_NAME, szLine, _countof(szLine));
+ m_txtName.GetTextU(szLine, _countof(szLine));
EndDialog(m_hwnd, 1);
}
void btnCancel_OnClick(CCtrlButton*)
{
- *szLine = 0;
+ szLine[0] = 0;
EndDialog(m_hwnd, 0);
}
@@ -331,7 +326,7 @@ private:
/////////////////////////////////////////////////////////////////////////////////////////
// Privacy rule editor
-class CJabberDlgPrivacyRule: public CJabberDlgBase
+class CJabberDlgPrivacyRule : public CJabberDlgBase
{
typedef CJabberDlgBase CSuper;
@@ -342,7 +337,7 @@ class CJabberDlgPrivacyRule: public CJabberDlgBase
public:
CPrivacyListRule *m_pRule;
- CJabberDlgPrivacyRule(CJabberProto *proto, HWND hwndParent, CPrivacyListRule *pRule):
+ CJabberDlgPrivacyRule(CJabberProto *proto, HWND hwndParent, CPrivacyListRule *pRule) :
CJabberDlgBase(proto, IDD_PRIVACY_RULE),
m_btnOk(this, IDOK),
m_btnCancel(this, IDCANCEL),
@@ -362,14 +357,14 @@ public:
m_proto->m_hwndPrivacyRule = m_hwnd;
- SendDlgItemMessage(m_hwnd, IDC_ICO_MESSAGE, STM_SETICON, (WPARAM)m_proto->LoadIconEx("pl_msg_allow"), 0);
- SendDlgItemMessage(m_hwnd, IDC_ICO_QUERY, STM_SETICON, (WPARAM)m_proto->LoadIconEx("pl_iq_allow"), 0);
- SendDlgItemMessage(m_hwnd, IDC_ICO_PRESENCEIN, STM_SETICON, (WPARAM)m_proto->LoadIconEx("pl_prin_allow"), 0);
+ SendDlgItemMessage(m_hwnd, IDC_ICO_MESSAGE, STM_SETICON, (WPARAM)m_proto->LoadIconEx("pl_msg_allow"), 0);
+ SendDlgItemMessage(m_hwnd, IDC_ICO_QUERY, STM_SETICON, (WPARAM)m_proto->LoadIconEx("pl_iq_allow"), 0);
+ SendDlgItemMessage(m_hwnd, IDC_ICO_PRESENCEIN, STM_SETICON, (WPARAM)m_proto->LoadIconEx("pl_prin_allow"), 0);
SendDlgItemMessage(m_hwnd, IDC_ICO_PRESENCEOUT, STM_SETICON, (WPARAM)m_proto->LoadIconEx("pl_prout_allow"), 0);
wchar_t *szTypes[] = { L"JID", L"Group", L"Subscription", L"Any" };
int i, nTypes[] = { Jid, Group, Subscription, Else };
- for (i=0; i < _countof(szTypes); i++) {
+ for (i = 0; i < _countof(szTypes); i++) {
LRESULT nItem = SendDlgItemMessage(m_hwnd, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateW(szTypes[i]));
SendDlgItemMessage(m_hwnd, IDC_COMBO_TYPE, CB_SETITEMDATA, nItem, nTypes[i]);
if (m_pRule->GetType() == nTypes[i])
@@ -403,7 +398,7 @@ public:
CheckDlgButton(m_hwnd, IDC_CHECK_PRESENCE_OUT, BST_CHECKED);
if (m_pRule->GetValue() && (m_pRule->GetType() == Jid || m_pRule->GetType() == Group))
- SetDlgItemText(m_hwnd, IDC_EDIT_VALUE, m_pRule->GetValue());
+ SetDlgItemTextUtf(m_hwnd, IDC_EDIT_VALUE, m_pRule->GetValue());
return true;
}
@@ -424,7 +419,7 @@ public:
SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_RESETCONTENT, 0, 0);
{
for (auto &hContact : m_proto->AccContacts()) {
- ptrW jid( m_proto->getWStringA(hContact, "jid"));
+ ptrW jid(m_proto->getWStringA(hContact, "jid"));
if (jid != nullptr)
SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_ADDSTRING, 0, jid);
}
@@ -440,8 +435,8 @@ public:
// FIXME: ugly code :)
if (m_pRule->GetValue()) {
- SetDlgItemText(m_hwnd, IDC_COMBO_VALUES, m_pRule->GetValue());
- LRESULT nSelPos = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_FINDSTRINGEXACT , -1, (LPARAM)m_pRule->GetValue());
+ SetDlgItemTextUtf(m_hwnd, IDC_COMBO_VALUES, m_pRule->GetValue());
+ LRESULT nSelPos = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_FINDSTRINGEXACT, -1, (LPARAM)m_pRule->GetValue());
if (nSelPos != CB_ERR)
SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_SETCURSEL, nSelPos, 0);
}
@@ -454,14 +449,14 @@ public:
SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_RESETCONTENT, 0, 0);
{
wchar_t *grpName;
- for (int i=1; (grpName = Clist_GroupGetName(i, nullptr)) != nullptr; i++)
+ for (int i = 1; (grpName = Clist_GroupGetName(i, nullptr)) != nullptr; i++)
SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_ADDSTRING, 0, (LPARAM)grpName);
}
// FIXME: ugly code :)
if (m_pRule->GetValue()) {
- SetDlgItemText(m_hwnd, IDC_COMBO_VALUES, m_pRule->GetValue());
- LRESULT nSelPos = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_FINDSTRINGEXACT , -1, (LPARAM)m_pRule->GetValue());
+ SetDlgItemTextUtf(m_hwnd, IDC_COMBO_VALUES, m_pRule->GetValue());
+ LRESULT nSelPos = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_FINDSTRINGEXACT, -1, (LPARAM)m_pRule->GetValue());
if (nSelPos != CB_ERR)
SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_SETCURSEL, nSelPos, 0);
}
@@ -472,7 +467,7 @@ public:
ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUE), SW_SHOW);
if (m_pRule->GetValue()) {
- LRESULT nSelected = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_SELECTSTRING, -1, (LPARAM)TranslateW(m_pRule->GetValue()));
+ LRESULT nSelected = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_SELECTSTRING, -1, (LPARAM)TranslateW(Utf2T(m_pRule->GetValue())));
if (nSelected == CB_ERR)
SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_SETCURSEL, 0, 0);
}
@@ -496,19 +491,17 @@ public:
switch (nItemData) {
case Jid:
case Group:
- {
- wchar_t szText[ 512 ];
- GetDlgItemText(m_hwnd, IDC_COMBO_VALUES, szText, _countof(szText));
- m_pRule->SetValue(szText);
- }
+ wchar_t szText[512];
+ GetDlgItemText(m_hwnd, IDC_COMBO_VALUES, szText, _countof(szText));
+ m_pRule->SetValue(T2Utf(szText));
break;
case Subscription:
nCurSel = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_GETCURSEL, 0, 0);
if (nCurSel != CB_ERR)
- m_pRule->SetValue((wchar_t*)SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_GETITEMDATA, nCurSel, 0));
+ m_pRule->SetValue((char*)SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_GETITEMDATA, nCurSel, 0));
else
- m_pRule->SetValue(L"none");
+ m_pRule->SetValue("none");
break;
default:
@@ -546,9 +539,9 @@ public:
void OnDestroy()
{
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_MESSAGE, STM_SETICON, 0, 0));
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_QUERY, STM_SETICON, 0, 0));
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_PRESENCEIN, STM_SETICON, 0, 0));
+ IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_MESSAGE, STM_SETICON, 0, 0));
+ IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_QUERY, STM_SETICON, 0, 0));
+ IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_PRESENCEIN, STM_SETICON, 0, 0));
IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_PRESENCEOUT, STM_SETICON, 0, 0));
m_proto->m_hwndPrivacyRule = nullptr;
}
@@ -556,7 +549,7 @@ public:
/////////////////////////////////////////////////////////////////////////////////////////
// Main privacy list dialog
-class CJabberDlgPrivacyLists: public CJabberDlgBase
+class CJabberDlgPrivacyLists : public CJabberDlgBase
{
typedef CJabberDlgBase CSuper;
@@ -574,9 +567,9 @@ protected:
int Resizer(UTILRESIZECONTROL *urc);
UI_MESSAGE_MAP(CJabberDlgPrivacyLists, CSuper);
- UI_MESSAGE(WM_MEASUREITEM, OnWmMeasureItem);
- UI_MESSAGE(WM_DRAWITEM, OnWmDrawItem);
- UI_MESSAGE(WM_GETMINMAXINFO, OnWmGetMinMaxInfo);
+ UI_MESSAGE(WM_MEASUREITEM, OnWmMeasureItem);
+ UI_MESSAGE(WM_DRAWITEM, OnWmDrawItem);
+ UI_MESSAGE(WM_GETMINMAXINFO, OnWmGetMinMaxInfo);
UI_MESSAGE_MAP_END();
BOOL OnWmMeasureItem(UINT msg, WPARAM wParam, LPARAM lParam);
@@ -612,14 +605,14 @@ protected:
void DrawRulesList(LPDRAWITEMSTRUCT lpdis);
void DrawLists(LPDRAWITEMSTRUCT lpdis);
- void CListResetOptions(HWND hwndList);
- void CListFilter(HWND hwndList);
- void CListResetIcons(HWND hwndList, HANDLE hItem, bool hide=false);
- void CListSetupIcons(HWND hwndList, HANDLE hItem, int iSlot, DWORD dwProcess, BOOL bAction);
- HANDLE CListAddContact(HWND hwndList, wchar_t *jid);
- void CListApplyList(HWND hwndList, CPrivacyList *pList = nullptr);
- DWORD CListGetPackets(HWND hwndList, HANDLE hItem, bool bAction);
- void CListBuildList(HWND hwndList, CPrivacyList *pList);
+ void CListResetOptions();
+ void CListFilter();
+ void CListResetIcons(HANDLE hItem, bool hide = false);
+ void CListSetupIcons(HANDLE hItem, int iSlot, DWORD dwProcess, BOOL bAction);
+ HANDLE CListAddContact(char *jid);
+ void CListApplyList(CPrivacyList *pList = nullptr);
+ DWORD CListGetPackets(HANDLE hItem, bool bAction);
+ void CListBuildList(CPrivacyList *pList);
void EnableEditorControls();
BOOL CanExit();
@@ -632,9 +625,9 @@ protected:
struct TJidData
{
HANDLE hItem;
- wchar_t *jid;
+ char *jid;
- static int cmp(const TJidData *p1, const TJidData *p2) { return mir_wstrcmp(p1->jid, p2->jid); }
+ static int cmp(const TJidData *p1, const TJidData *p2) { return mir_strcmp(p1->jid, p2->jid); }
};
HANDLE hItemDefault;
@@ -649,7 +642,7 @@ protected:
CPrivacyList *pList;
- TCLCInfo(): newJids(1, TJidData::cmp), bChanged(false), pList(nullptr) {}
+ TCLCInfo() : newJids(1, TJidData::cmp), bChanged(false), pList(nullptr) {}
~TCLCInfo()
{
for (auto &it : newJids) {
@@ -658,15 +651,15 @@ protected:
}
}
- void addJid(HANDLE hItem, wchar_t *jid)
+ void addJid(HANDLE hItem, char *jid)
{
TJidData *data = (TJidData *)mir_alloc(sizeof(TJidData));
data->hItem = hItem;
- data->jid = mir_wstrdup(jid);
+ data->jid = mir_strdup(jid);
newJids.insert(data);
}
- HANDLE findJid(wchar_t *jid)
+ HANDLE findJid(char *jid)
{
TJidData data = {};
data.jid = jid;
@@ -693,7 +686,8 @@ private:
CCtrlButton m_btnApply;
CCtrlListBox m_lbLists;
CCtrlListBox m_lbRules;
- CCtrlClc m_clcClist;
+ CCtrlClc m_clcClist;
+ CCtrlEdit m_edtNewJid;
};
int CJabberDlgPrivacyLists::idSimpleControls[] =
@@ -713,38 +707,39 @@ int CJabberDlgPrivacyLists::idAdvancedControls[] =
0
};
-CJabberDlgPrivacyLists::CJabberDlgPrivacyLists(CJabberProto *proto):
+CJabberDlgPrivacyLists::CJabberDlgPrivacyLists(CJabberProto *proto) :
CSuper(proto, IDD_PRIVACY_LISTS),
- m_btnSimple(this, IDC_BTN_SIMPLE, proto->LoadIconEx("group"), LPGEN("Simple mode")),
- m_btnAdvanced(this, IDC_BTN_ADVANCED, proto->LoadIconEx("sd_view_list"), LPGEN("Advanced mode")),
- m_btnAddJid(this, IDC_ADDJID, proto->LoadIconEx("addroster"), LPGEN("Add JID")),
- m_btnActivate(this, IDC_ACTIVATE, proto->LoadIconEx("pl_list_active"), LPGEN("Activate")),
- m_btnSetDefault(this, IDC_SET_DEFAULT, proto->LoadIconEx("pl_list_default"), LPGEN("Set default")),
- m_btnEditRule(this, IDC_EDIT_RULE, SKINICON_OTHER_RENAME, LPGEN("Edit rule")),
- m_btnAddRule(this, IDC_ADD_RULE, SKINICON_OTHER_ADDCONTACT, LPGEN("Add rule")),
- m_btnRemoveRule(this, IDC_REMOVE_RULE, SKINICON_OTHER_DELETE, LPGEN("Delete rule")),
- m_btnUpRule(this, IDC_UP_RULE, proto->LoadIconEx("arrow_up"), LPGEN("Move rule up")),
- m_btnDownRule(this, IDC_DOWN_RULE, proto->LoadIconEx("arrow_down"), LPGEN("Move rule down")),
- m_btnAddList(this, IDC_ADD_LIST, SKINICON_OTHER_ADDCONTACT, LPGEN("Add list...")),
- m_btnRemoveList(this, IDC_REMOVE_LIST, SKINICON_OTHER_DELETE, LPGEN("Remove list")),
- m_btnApply(this, IDC_APPLY),
- m_lbLists(this, IDC_LB_LISTS),
- m_lbRules(this, IDC_PL_RULES_LIST),
- m_clcClist(this, IDC_CLIST)
-{
- m_btnSimple.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnSimple_OnClick);
- m_btnAdvanced.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnAdvanced_OnClick);
- m_btnAddJid.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnAddJid_OnClick);
- m_btnActivate.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnActivate_OnClick);
+ m_btnSimple(this, IDC_BTN_SIMPLE, proto->LoadIconEx("group"), LPGEN("Simple mode")),
+ m_btnAdvanced(this, IDC_BTN_ADVANCED, proto->LoadIconEx("sd_view_list"), LPGEN("Advanced mode")),
+ m_btnAddJid(this, IDC_ADDJID, proto->LoadIconEx("addroster"), LPGEN("Add JID")),
+ m_btnActivate(this, IDC_ACTIVATE, proto->LoadIconEx("pl_list_active"), LPGEN("Activate")),
+ m_btnSetDefault(this, IDC_SET_DEFAULT, proto->LoadIconEx("pl_list_default"), LPGEN("Set default")),
+ m_btnEditRule(this, IDC_EDIT_RULE, SKINICON_OTHER_RENAME, LPGEN("Edit rule")),
+ m_btnAddRule(this, IDC_ADD_RULE, SKINICON_OTHER_ADDCONTACT, LPGEN("Add rule")),
+ m_btnRemoveRule(this, IDC_REMOVE_RULE, SKINICON_OTHER_DELETE, LPGEN("Delete rule")),
+ m_btnUpRule(this, IDC_UP_RULE, proto->LoadIconEx("arrow_up"), LPGEN("Move rule up")),
+ m_btnDownRule(this, IDC_DOWN_RULE, proto->LoadIconEx("arrow_down"), LPGEN("Move rule down")),
+ m_btnAddList(this, IDC_ADD_LIST, SKINICON_OTHER_ADDCONTACT, LPGEN("Add list...")),
+ m_btnRemoveList(this, IDC_REMOVE_LIST, SKINICON_OTHER_DELETE, LPGEN("Remove list")),
+ m_btnApply(this, IDC_APPLY),
+ m_lbLists(this, IDC_LB_LISTS),
+ m_lbRules(this, IDC_PL_RULES_LIST),
+ m_clcClist(this, IDC_CLIST),
+ m_edtNewJid(this, IDC_NEWJID)
+{
+ m_btnSimple.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnSimple_OnClick);
+ m_btnAdvanced.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnAdvanced_OnClick);
+ m_btnAddJid.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnAddJid_OnClick);
+ m_btnActivate.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnActivate_OnClick);
m_btnSetDefault.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnSetDefault_OnClick);
- m_btnEditRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnEditRule_OnClick);
- m_btnAddRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnAddRule_OnClick);
+ m_btnEditRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnEditRule_OnClick);
+ m_btnAddRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnAddRule_OnClick);
m_btnRemoveRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnRemoveRule_OnClick);
- m_btnUpRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnUpRule_OnClick);
- m_btnDownRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnDownRule_OnClick);
- m_btnAddList.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnAddList_OnClick);
+ m_btnUpRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnUpRule_OnClick);
+ m_btnDownRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnDownRule_OnClick);
+ m_btnAddList.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnAddList_OnClick);
m_btnRemoveList.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnRemoveList_OnClick);
- m_btnApply.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnApply_OnClick);
+ m_btnApply.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnApply_OnClick);
m_lbLists.OnSelChange = Callback(this, &CJabberDlgPrivacyLists::lbLists_OnSelChange);
m_lbLists.OnDblClick = Callback(this, &CJabberDlgPrivacyLists::lbLists_OnDblClick);
@@ -752,7 +747,7 @@ CJabberDlgPrivacyLists::CJabberDlgPrivacyLists(CJabberProto *proto):
m_lbRules.OnDblClick = Callback(this, &CJabberDlgPrivacyLists::lbRules_OnDblClick);
m_clcClist.OnNewContact =
- m_clcClist.OnListRebuilt = Callback(this, &CJabberDlgPrivacyLists::clcClist_OnUpdate);
+ m_clcClist.OnListRebuilt = Callback(this, &CJabberDlgPrivacyLists::clcClist_OnUpdate);
m_clcClist.OnOptionsChanged = Callback(this, &CJabberDlgPrivacyLists::clcClist_OnOptionsChanged);
m_clcClist.OnClick = Callback(this, &CJabberDlgPrivacyLists::clcClist_OnClick);
}
@@ -778,9 +773,9 @@ bool CJabberDlgPrivacyLists::OnInitDialog()
SendDlgItemMessage(m_hwnd, IDC_TXT_LISTS, WM_SETFONT, (WPARAM)hfnt, TRUE);
SendDlgItemMessage(m_hwnd, IDC_TXT_RULES, WM_SETFONT, (WPARAM)hfnt, TRUE);
- SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_CLIST), GWL_STYLE,
- GetWindowLongPtr(GetDlgItem(m_hwnd, IDC_CLIST), GWL_STYLE)|CLS_HIDEEMPTYGROUPS|CLS_USEGROUPS|CLS_GREYALTERNATE);
- m_clcClist.SetExStyle(CLS_EX_DISABLEDRAGDROP|CLS_EX_TRACKSELECT);
+ SetWindowLongPtr(m_clcClist.GetHwnd(), GWL_STYLE,
+ GetWindowLongPtr(m_clcClist.GetHwnd(), GWL_STYLE) | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE);
+ m_clcClist.SetExStyle(CLS_EX_DISABLEDRAGDROP | CLS_EX_TRACKSELECT);
HIMAGELIST hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 9, 9);
ImageList_AddIcon_Icolib(hIml, Skin_LoadIcon(SKINICON_OTHER_SMALLDOT));
@@ -798,7 +793,7 @@ bool CJabberDlgPrivacyLists::OnInitDialog()
m_btnSimple.MakePush();
m_btnAdvanced.MakePush();
- CLCINFOITEM cii = {0};
+ CLCINFOITEM cii = { 0 };
cii.cbSize = sizeof(cii);
cii.flags = CLCIIF_GROUPFONT;
@@ -813,11 +808,11 @@ bool CJabberDlgPrivacyLists::OnInitDialog()
cii.pszText = TranslateT("** Subscription: none **");
clc_info.hItemSubNone = m_clcClist.AddInfoItem(&cii);
- CListResetOptions(GetDlgItem(m_hwnd, IDC_CLIST));
- CListFilter(GetDlgItem(m_hwnd, IDC_CLIST));
- CListApplyList(GetDlgItem(m_hwnd, IDC_CLIST));
+ CListResetOptions();
+ CListFilter();
+ CListApplyList();
- if ( m_proto->getByte("plistsWnd_simpleMode", 1)) {
+ if (m_proto->getByte("plistsWnd_simpleMode", 1)) {
UIShowControls(m_hwnd, idSimpleControls, SW_SHOW);
UIShowControls(m_hwnd, idAdvancedControls, SW_HIDE);
CheckDlgButton(m_hwnd, IDC_BTN_SIMPLE, BST_CHECKED);
@@ -828,8 +823,8 @@ bool CJabberDlgPrivacyLists::OnInitDialog()
CheckDlgButton(m_hwnd, IDC_BTN_ADVANCED, BST_CHECKED);
}
- mir_subclassWindow( GetDlgItem(m_hwnd, IDC_LB_LISTS), LstListsSubclassProc);
- mir_subclassWindow( GetDlgItem(m_hwnd, IDC_PL_RULES_LIST), LstRulesSubclassProc);
+ mir_subclassWindow(GetDlgItem(m_hwnd, IDC_LB_LISTS), LstListsSubclassProc);
+ mir_subclassWindow(GetDlgItem(m_hwnd, IDC_PL_RULES_LIST), LstRulesSubclassProc);
SetStatusText(TranslateT("Loading..."));
@@ -907,7 +902,7 @@ BOOL CJabberDlgPrivacyLists::OnWmMeasureItem(UINT, WPARAM, LPARAM lParam)
if ((lpmis->CtlID != IDC_PL_RULES_LIST) && (lpmis->CtlID != IDC_LB_LISTS))
return FALSE;
- TEXTMETRIC tm = {0};
+ TEXTMETRIC tm = { 0 };
HDC hdc = GetDC(GetDlgItem(m_hwnd, lpmis->CtlID));
GetTextMetrics(hdc, &tm);
ReleaseDC(GetDlgItem(m_hwnd, lpmis->CtlID), hdc);
@@ -949,7 +944,7 @@ BOOL CJabberDlgPrivacyLists::OnWmDrawItem(UINT, WPARAM, LPARAM lParam)
else if (lpdis->CtlID == IDC_CANVAS) {
int totalWidth = -5; // spacing for last item
for (auto &it : drawItems) {
- SIZE sz = {0};
+ SIZE sz = { 0 };
it.text = TranslateW(it.textEng);
GetTextExtentPoint32(lpdis->hDC, it.text, (int)mir_wstrlen(it.text), &sz);
totalWidth += sz.cx + 18 + 5; // 18 pixels for icon, 5 pixel spacing
@@ -957,10 +952,10 @@ BOOL CJabberDlgPrivacyLists::OnWmDrawItem(UINT, WPARAM, LPARAM lParam)
COLORREF clText = GetSysColor(COLOR_BTNTEXT);
RECT rc = lpdis->rcItem;
- rc.left = (rc.left + rc.right - totalWidth)/2;
+ rc.left = (rc.left + rc.right - totalWidth) / 2;
for (auto &it : drawItems) {
- DrawIconEx(lpdis->hDC, rc.left, (rc.top+rc.bottom-16)/2, m_proto->LoadIconEx(it.icon),
+ DrawIconEx(lpdis->hDC, rc.left, (rc.top + rc.bottom - 16) / 2, m_proto->LoadIconEx(it.icon),
16, 16, 0, nullptr, DI_NORMAL);
rc.left += 18;
DrawNextRulePart(lpdis->hDC, clText, it.text, &rc);
@@ -990,7 +985,7 @@ void CJabberDlgPrivacyLists::ShowAdvancedList(CPrivacyList *pList)
CPrivacyListRule* pRule = pList->GetFirstRule();
while (pRule) {
bListEmpty = FALSE;
- wchar_t szTypeValue[ 512 ];
+ wchar_t szTypeValue[512];
switch (pRule->GetType()) {
case Jid:
mir_snwprintf(szTypeValue, L"If Jabber ID is '%s' then", pRule->GetValue());
@@ -1006,8 +1001,8 @@ void CJabberDlgPrivacyLists::ShowAdvancedList(CPrivacyList *pList)
break;
}
- wchar_t szPackets[ 512 ];
- szPackets[ 0 ] = '\0';
+ wchar_t szPackets[512];
+ szPackets[0] = '\0';
DWORD dwPackets = pRule->GetPackets();
if (!dwPackets)
@@ -1034,7 +1029,7 @@ void CJabberDlgPrivacyLists::ShowAdvancedList(CPrivacyList *pList)
}
}
- wchar_t szListItem[ 512 ];
+ wchar_t szListItem[512];
mir_snwprintf(szListItem, L"%s %s %s", szTypeValue, pRule->GetAction() ? L"allow" : L"deny", szPackets);
LRESULT nItemId = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_ADDSTRING, 0, (LPARAM)szListItem);
@@ -1055,7 +1050,7 @@ void CJabberDlgPrivacyLists::ShowAdvancedList(CPrivacyList *pList)
void CJabberDlgPrivacyLists::DrawNextRulePart(HDC hdc, COLORREF color, const wchar_t *text, RECT *rc)
{
SetTextColor(hdc, color);
- DrawText(hdc, text, -1, rc, DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER|DT_WORD_ELLIPSIS);
+ DrawText(hdc, text, -1, rc, DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);
SIZE sz;
GetTextExtentPoint32(hdc, text, (int)mir_wstrlen(text), &sz);
@@ -1124,9 +1119,9 @@ void CJabberDlgPrivacyLists::DrawRulesList(LPDRAWITEMSTRUCT lpdis)
clLine1 = GetSysColor(COLOR_WINDOWTEXT);
}
clLine2 = RGB(
- GetRValue(clLine1) * 0.66 + GetRValue(clBack) * 0.34,
- GetGValue(clLine1) * 0.66 + GetGValue(clBack) * 0.34,
- GetBValue(clLine1) * 0.66 + GetBValue(clBack) * 0.34);
+ GetRValue(clLine1) * 0.66 + GetRValue(clBack) * 0.34,
+ GetGValue(clLine1) * 0.66 + GetGValue(clBack) * 0.34,
+ GetBValue(clLine1) * 0.66 + GetBValue(clBack) * 0.34);
SetBkMode(lpdis->hDC, TRANSPARENT);
@@ -1152,11 +1147,12 @@ void CJabberDlgPrivacyLists::DrawRulesList(LPDRAWITEMSTRUCT lpdis)
rc.bottom -= (rc.bottom - rc.top) / 2;
rc.left += 25;
+ Utf2T wszRule(pRule->GetValue());
switch (pRule->GetType()) {
case Jid:
{
DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("If Jabber ID is '"), &rc);
- DrawNextRulePart(lpdis->hDC, clLine1, pRule->GetValue(), &rc);
+ DrawNextRulePart(lpdis->hDC, clLine1, wszRule, &rc);
DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("'"), &rc);
if (MCONTACT hContact = m_proto->HContactFromJID(pRule->GetValue())) {
@@ -1165,19 +1161,20 @@ void CJabberDlgPrivacyLists::DrawRulesList(LPDRAWITEMSTRUCT lpdis)
DrawNextRulePart(lpdis->hDC, clLine2, TranslateT(" (nickname: "), &rc);
DrawNextRulePart(lpdis->hDC, clLine1, szName, &rc);
DrawNextRulePart(lpdis->hDC, clLine2, TranslateT(")"), &rc);
- } }
+ }
+ }
break;
}
case Group:
DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("If group is '"), &rc);
- DrawNextRulePart(lpdis->hDC, clLine1, pRule->GetValue(), &rc);
+ DrawNextRulePart(lpdis->hDC, clLine1, wszRule, &rc);
DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("'"), &rc);
break;
case Subscription:
DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("If subscription is '"), &rc);
- DrawNextRulePart(lpdis->hDC, clLine1, pRule->GetValue(), &rc);
+ DrawNextRulePart(lpdis->hDC, clLine1, wszRule, &rc);
DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("'"), &rc);
break;
}
@@ -1190,11 +1187,11 @@ void CJabberDlgPrivacyLists::DrawRulesList(LPDRAWITEMSTRUCT lpdis)
DrawRuleAction(lpdis->hDC, clLine1, clLine2, pRule, &rc);
}
- DrawIconEx(lpdis->hDC, lpdis->rcItem.left+4, (lpdis->rcItem.top+lpdis->rcItem.bottom-16)/2,
+ DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 4, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
m_proto->LoadIconEx("main"), 16, 16, 0, nullptr, DI_NORMAL);
- if (pRule)
- DrawIconEx(lpdis->hDC, lpdis->rcItem.left+4, (lpdis->rcItem.top+lpdis->rcItem.bottom-16)/2,
+ if (pRule)
+ DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 4, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
m_proto->LoadIconEx(pRule->GetAction() ? "disco_ok" : "disco_fail"),
16, 16, 0, nullptr, DI_NORMAL);
@@ -1224,34 +1221,35 @@ void CJabberDlgPrivacyLists::DrawLists(LPDRAWITEMSTRUCT lpdis)
clLine1 = GetSysColor(COLOR_WINDOWTEXT);
}
clLine2 = RGB(
- GetRValue(clLine1) * 0.66 + GetRValue(clBack) * 0.34,
- GetGValue(clLine1) * 0.66 + GetGValue(clBack) * 0.34,
- GetBValue(clLine1) * 0.66 + GetBValue(clBack) * 0.34);
+ GetRValue(clLine1) * 0.66 + GetRValue(clBack) * 0.34,
+ GetGValue(clLine1) * 0.66 + GetGValue(clBack) * 0.34,
+ GetBValue(clLine1) * 0.66 + GetBValue(clBack) * 0.34);
SetBkMode(lpdis->hDC, TRANSPARENT);
- wchar_t *szDefault, *szActive;
- { mir_cslock lck(m_proto->m_privacyListManager.m_cs);
- szDefault = NEWWSTR_ALLOCA(m_proto->m_privacyListManager.GetDefaultListName());
- szActive = NEWWSTR_ALLOCA(m_proto->m_privacyListManager.GetActiveListName());
+ char *szDefault, *szActive;
+ {
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
+ szDefault = NEWSTR_ALLOCA(m_proto->m_privacyListManager.GetDefaultListName());
+ szActive = NEWSTR_ALLOCA(m_proto->m_privacyListManager.GetActiveListName());
}
RECT rc;
rc = lpdis->rcItem;
- rc.left +=3;
+ rc.left += 3;
bool bActive = false;
bool bDefault = false;
- wchar_t *szName;
+ char *szName;
if (!pList) {
if (!szActive) bActive = true;
if (!szDefault) bDefault = true;
- szName = TranslateT("<none>");
+ szName = Translate("<none>");
}
else {
- if (!mir_wstrcmp(pList->GetListName(), szActive)) bActive = true;
- if (!mir_wstrcmp(pList->GetListName(), szDefault)) bDefault = true;
+ if (!mir_strcmp(pList->GetListName(), szActive)) bActive = true;
+ if (!mir_strcmp(pList->GetListName(), szDefault)) bDefault = true;
szName = pList->GetListName();
}
@@ -1263,7 +1261,7 @@ void CJabberDlgPrivacyLists::DrawLists(LPDRAWITEMSTRUCT lpdis)
hfnt = (HFONT)SelectObject(lpdis->hDC, CreateFontIndirect(&lf));
}
- DrawNextRulePart(lpdis->hDC, clLine1, szName, &rc);
+ DrawNextRulePart(lpdis->hDC, clLine1, Utf2T(szName), &rc);
if (bActive && bDefault)
DrawNextRulePart(lpdis->hDC, clLine2, TranslateT(" (act., def.)"), &rc);
@@ -1272,12 +1270,12 @@ void CJabberDlgPrivacyLists::DrawLists(LPDRAWITEMSTRUCT lpdis)
else if (bDefault)
DrawNextRulePart(lpdis->hDC, clLine2, TranslateT(" (default)"), &rc);
- DrawIconEx(lpdis->hDC, lpdis->rcItem.right-16-4, (lpdis->rcItem.top+lpdis->rcItem.bottom-16)/2,
+ DrawIconEx(lpdis->hDC, lpdis->rcItem.right - 16 - 4, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
m_proto->LoadIconEx(bActive ? "pl_list_active" : "pl_list_any"),
16, 16, 0, nullptr, DI_NORMAL);
if (bDefault)
- DrawIconEx(lpdis->hDC, lpdis->rcItem.right-16-4, (lpdis->rcItem.top+lpdis->rcItem.bottom-16)/2,
+ DrawIconEx(lpdis->hDC, lpdis->rcItem.right - 16 - 4, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
m_proto->LoadIconEx("disco_ok"),
16, 16, 0, nullptr, DI_NORMAL);
@@ -1291,7 +1289,7 @@ void CJabberDlgPrivacyLists::DrawLists(LPDRAWITEMSTRUCT lpdis)
}
}
-void CJabberDlgPrivacyLists::CListResetOptions(HWND)
+void CJabberDlgPrivacyLists::CListResetOptions()
{
m_clcClist.SetBkBitmap(0, nullptr);
m_clcClist.SetBkColor(GetSysColor(COLOR_WINDOW));
@@ -1300,11 +1298,11 @@ void CJabberDlgPrivacyLists::CListResetOptions(HWND)
m_clcClist.SetIndent(10);
m_clcClist.SetHideEmptyGroups(false);
m_clcClist.SetHideOfflineRoot(false);
- for (int i=0; i <= FONTID_MAX; i++)
+ for (int i = 0; i <= FONTID_MAX; i++)
m_clcClist.SetTextColor(i, GetSysColor(COLOR_WINDOWTEXT));
}
-void CJabberDlgPrivacyLists::CListFilter(HWND)
+void CJabberDlgPrivacyLists::CListFilter()
{
for (auto &hContact : Contacts()) {
char *proto = GetContactProto(hContact);
@@ -1314,19 +1312,19 @@ void CJabberDlgPrivacyLists::CListFilter(HWND)
}
}
-void CJabberDlgPrivacyLists::CListResetIcons(HWND, HANDLE hItem, bool hide)
+void CJabberDlgPrivacyLists::CListResetIcons(HANDLE hItem, bool hide)
{
- for (int i=0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
m_clcClist.SetExtraImage(hItem, i, hide ? EMPTY_EXTRA_ICON : 0);
}
-void CJabberDlgPrivacyLists::CListSetupIcons(HWND, HANDLE hItem, int iSlot, DWORD dwProcess, BOOL bAction)
+void CJabberDlgPrivacyLists::CListSetupIcons(HANDLE hItem, int iSlot, DWORD dwProcess, BOOL bAction)
{
if (dwProcess && !m_clcClist.GetExtraImage(hItem, iSlot))
- m_clcClist.SetExtraImage(hItem, iSlot, iSlot*2 + (bAction?1:2));
+ m_clcClist.SetExtraImage(hItem, iSlot, iSlot * 2 + (bAction ? 1 : 2));
}
-HANDLE CJabberDlgPrivacyLists::CListAddContact(HWND hwndList, wchar_t *jid)
+HANDLE CJabberDlgPrivacyLists::CListAddContact(char *jid)
{
MCONTACT hContact = m_proto->HContactFromJID(jid);
if (hContact)
@@ -1334,43 +1332,45 @@ HANDLE CJabberDlgPrivacyLists::CListAddContact(HWND hwndList, wchar_t *jid)
HANDLE hItem = clc_info.findJid(jid);
if (!hItem) {
- CLCINFOITEM cii = {0};
+ Utf2T wzJid(jid);
+
+ CLCINFOITEM cii = { 0 };
cii.cbSize = sizeof(cii);
- cii.pszText = jid;
+ cii.pszText = wzJid;
hItem = m_clcClist.AddInfoItem(&cii);
- CListResetIcons(hwndList, hItem);
+ CListResetIcons(hItem);
clc_info.addJid(hItem, jid);
}
return hItem;
}
-void CJabberDlgPrivacyLists::CListApplyList(HWND hwndList, CPrivacyList *pList)
+void CJabberDlgPrivacyLists::CListApplyList(CPrivacyList *pList)
{
clc_info.pList = pList;
bool bHideIcons = pList ? false : true;
- CListResetIcons(hwndList, clc_info.hItemDefault, bHideIcons);
- CListResetIcons(hwndList, clc_info.hItemSubBoth, bHideIcons);
- CListResetIcons(hwndList, clc_info.hItemSubFrom, bHideIcons);
- CListResetIcons(hwndList, clc_info.hItemSubNone, bHideIcons);
- CListResetIcons(hwndList, clc_info.hItemSubTo, bHideIcons);
+ CListResetIcons(clc_info.hItemDefault, bHideIcons);
+ CListResetIcons(clc_info.hItemSubBoth, bHideIcons);
+ CListResetIcons(clc_info.hItemSubFrom, bHideIcons);
+ CListResetIcons(clc_info.hItemSubNone, bHideIcons);
+ CListResetIcons(clc_info.hItemSubTo, bHideIcons);
// group handles start with 1 (0 is "root")
for (MGROUP iGroup = 1; Clist_GroupGetName(iGroup, nullptr) != nullptr; iGroup++) {
HANDLE hItem = m_clcClist.FindGroup(iGroup);
if (hItem)
- CListResetIcons(hwndList, hItem, bHideIcons);
+ CListResetIcons(hItem, bHideIcons);
}
for (auto &hContact : Contacts()) {
HANDLE hItem = m_clcClist.FindContact(hContact);
if (hItem)
- CListResetIcons(hwndList, hItem, bHideIcons);
+ CListResetIcons(hItem, bHideIcons);
}
for (auto &it : clc_info.newJids)
- CListResetIcons(hwndList, it->hItem, bHideIcons);
+ CListResetIcons(it->hItem, bHideIcons);
if (!pList)
goto lbl_return;
@@ -1379,18 +1379,18 @@ void CJabberDlgPrivacyLists::CListApplyList(HWND hwndList, CPrivacyList *pList)
HANDLE hItem = nullptr;
switch (pRule->GetType()) {
case Jid:
- hItem = CListAddContact(hwndList, pRule->GetValue());
+ hItem = CListAddContact(pRule->GetValue());
break;
case Group:
- hItem = m_clcClist.FindGroup( Clist_GroupExists(pRule->GetValue()));
+ hItem = m_clcClist.FindGroup(Clist_GroupExists(Utf2T(pRule->GetValue())));
break;
case Subscription:
- if (!mir_wstrcmp(pRule->GetValue(), L"none")) hItem = clc_info.hItemSubNone;
- else if (!mir_wstrcmp(pRule->GetValue(), L"from")) hItem = clc_info.hItemSubFrom;
- else if (!mir_wstrcmp(pRule->GetValue(), L"to")) hItem = clc_info.hItemSubTo;
- else if (!mir_wstrcmp(pRule->GetValue(), L"both")) hItem = clc_info.hItemSubBoth;
+ if (!mir_strcmp(pRule->GetValue(), "none")) hItem = clc_info.hItemSubNone;
+ else if (!mir_strcmp(pRule->GetValue(), "from")) hItem = clc_info.hItemSubFrom;
+ else if (!mir_strcmp(pRule->GetValue(), "to")) hItem = clc_info.hItemSubTo;
+ else if (!mir_strcmp(pRule->GetValue(), "both")) hItem = clc_info.hItemSubBoth;
break;
case Else:
@@ -1403,40 +1403,40 @@ void CJabberDlgPrivacyLists::CListApplyList(HWND hwndList, CPrivacyList *pList)
DWORD dwPackets = pRule->GetPackets();
if (!dwPackets) dwPackets = JABBER_PL_RULE_TYPE_ALL;
- CListSetupIcons(hwndList, hItem, 0, dwPackets & JABBER_PL_RULE_TYPE_MESSAGE, pRule->GetAction());
- CListSetupIcons(hwndList, hItem, 1, dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_IN, pRule->GetAction());
- CListSetupIcons(hwndList, hItem, 2, dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_OUT, pRule->GetAction());
- CListSetupIcons(hwndList, hItem, 3, dwPackets & JABBER_PL_RULE_TYPE_IQ, pRule->GetAction());
+ CListSetupIcons(hItem, 0, dwPackets & JABBER_PL_RULE_TYPE_MESSAGE, pRule->GetAction());
+ CListSetupIcons(hItem, 1, dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_IN, pRule->GetAction());
+ CListSetupIcons(hItem, 2, dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_OUT, pRule->GetAction());
+ CListSetupIcons(hItem, 3, dwPackets & JABBER_PL_RULE_TYPE_IQ, pRule->GetAction());
}
lbl_return:
clc_info.bChanged = false;
}
-DWORD CJabberDlgPrivacyLists::CListGetPackets(HWND, HANDLE hItem, bool bAction)
+DWORD CJabberDlgPrivacyLists::CListGetPackets(HANDLE hItem, bool bAction)
{
DWORD result = 0;
int iIcon = m_clcClist.GetExtraImage(hItem, 0);
- if (bAction && (iIcon == 1)) result |= JABBER_PL_RULE_TYPE_MESSAGE;
+ if (bAction && (iIcon == 1)) result |= JABBER_PL_RULE_TYPE_MESSAGE;
else if (!bAction && (iIcon == 2)) result |= JABBER_PL_RULE_TYPE_MESSAGE;
iIcon = m_clcClist.GetExtraImage(hItem, 1);
- if (bAction && (iIcon == 3)) result |= JABBER_PL_RULE_TYPE_PRESENCE_IN;
+ if (bAction && (iIcon == 3)) result |= JABBER_PL_RULE_TYPE_PRESENCE_IN;
else if (!bAction && (iIcon == 4)) result |= JABBER_PL_RULE_TYPE_PRESENCE_IN;
iIcon = m_clcClist.GetExtraImage(hItem, 2);
- if (bAction && (iIcon == 5)) result |= JABBER_PL_RULE_TYPE_PRESENCE_OUT;
+ if (bAction && (iIcon == 5)) result |= JABBER_PL_RULE_TYPE_PRESENCE_OUT;
else if (!bAction && (iIcon == 6)) result |= JABBER_PL_RULE_TYPE_PRESENCE_OUT;
iIcon = m_clcClist.GetExtraImage(hItem, 3);
- if (bAction && (iIcon == 7)) result |= JABBER_PL_RULE_TYPE_IQ;
+ if (bAction && (iIcon == 7)) result |= JABBER_PL_RULE_TYPE_IQ;
else if (!bAction && (iIcon == 8)) result |= JABBER_PL_RULE_TYPE_IQ;
return result;
}
-void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList)
+void CJabberDlgPrivacyLists::CListBuildList(CPrivacyList *pList)
{
if (!pList || !clc_info.bChanged)
return;
@@ -1447,7 +1447,7 @@ void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList)
DWORD dwPackets = 0;
HANDLE hItem;
- wchar_t *szJid = nullptr;
+ char *szJid = nullptr;
pList->RemoveAllRules();
@@ -1455,23 +1455,23 @@ void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList)
hItem = it->hItem;
szJid = it->jid;
- if (dwPackets = CListGetPackets(hwndList, hItem, true))
+ if (dwPackets = CListGetPackets(hItem, true))
pList->AddRule(Jid, szJid, TRUE, dwOrder++, dwPackets);
- if (dwPackets = CListGetPackets(hwndList, hItem, false))
+ if (dwPackets = CListGetPackets(hItem, false))
pList->AddRule(Jid, szJid, FALSE, dwOrder++, dwPackets);
}
for (auto &hContact : Contacts()) {
hItem = m_clcClist.FindContact(hContact);
- ptrW jid( m_proto->getWStringA(hContact, "jid"));
+ ptrW jid(m_proto->getWStringA(hContact, "jid"));
if (jid == nullptr)
if ((jid = m_proto->getWStringA(hContact, "ChatRoomID")) == nullptr)
continue;
- if (dwPackets = CListGetPackets(hwndList, hItem, true))
+ if (dwPackets = CListGetPackets(hItem, true))
pList->AddRule(Jid, szJid, TRUE, dwOrder++, dwPackets);
- if (dwPackets = CListGetPackets(hwndList, hItem, false))
+ if (dwPackets = CListGetPackets(hItem, false))
pList->AddRule(Jid, szJid, FALSE, dwOrder++, dwPackets);
}
@@ -1479,45 +1479,45 @@ void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList)
wchar_t *grpName;
for (MGROUP iGroup = 1; (grpName = Clist_GroupGetName(iGroup, nullptr)) != nullptr; iGroup++) {
hItem = m_clcClist.FindGroup(iGroup);
- if (dwPackets = CListGetPackets(hwndList, hItem, true))
- pList->AddRule(Group, grpName, TRUE, dwOrder++, dwPackets);
- if (dwPackets = CListGetPackets(hwndList, hItem, false))
- pList->AddRule(Group, grpName, FALSE, dwOrder++, dwPackets);
+ if (dwPackets = CListGetPackets(hItem, true))
+ pList->AddRule(Group, T2Utf(grpName), TRUE, dwOrder++, dwPackets);
+ if (dwPackets = CListGetPackets(hItem, false))
+ pList->AddRule(Group, T2Utf(grpName), FALSE, dwOrder++, dwPackets);
}
hItem = clc_info.hItemSubBoth;
- szJid = L"both";
- if (dwPackets = CListGetPackets(hwndList, hItem, true))
+ szJid = "both";
+ if (dwPackets = CListGetPackets(hItem, true))
pList->AddRule(Subscription, szJid, TRUE, dwOrder++, dwPackets);
- if (dwPackets = CListGetPackets(hwndList, hItem, false))
+ if (dwPackets = CListGetPackets(hItem, false))
pList->AddRule(Subscription, szJid, FALSE, dwOrder++, dwPackets);
hItem = clc_info.hItemSubFrom;
- szJid = L"from";
- if (dwPackets = CListGetPackets(hwndList, hItem, true))
+ szJid = "from";
+ if (dwPackets = CListGetPackets(hItem, true))
pList->AddRule(Subscription, szJid, TRUE, dwOrder++, dwPackets);
- if (dwPackets = CListGetPackets(hwndList, hItem, false))
+ if (dwPackets = CListGetPackets(hItem, false))
pList->AddRule(Subscription, szJid, FALSE, dwOrder++, dwPackets);
hItem = clc_info.hItemSubNone;
- szJid = L"none";
- if (dwPackets = CListGetPackets(hwndList, hItem, true))
+ szJid = "none";
+ if (dwPackets = CListGetPackets(hItem, true))
pList->AddRule(Subscription, szJid, TRUE, dwOrder++, dwPackets);
- if (dwPackets = CListGetPackets(hwndList, hItem, false))
+ if (dwPackets = CListGetPackets(hItem, false))
pList->AddRule(Subscription, szJid, FALSE, dwOrder++, dwPackets);
hItem = clc_info.hItemSubTo;
- szJid = L"to";
- if (dwPackets = CListGetPackets(hwndList, hItem, true))
+ szJid = "to";
+ if (dwPackets = CListGetPackets(hItem, true))
pList->AddRule(Subscription, szJid, TRUE, dwOrder++, dwPackets);
- if (dwPackets = CListGetPackets(hwndList, hItem, false))
+ if (dwPackets = CListGetPackets(hItem, false))
pList->AddRule(Subscription, szJid, FALSE, dwOrder++, dwPackets);
hItem = clc_info.hItemDefault;
szJid = nullptr;
- if (dwPackets = CListGetPackets(hwndList, hItem, true))
+ if (dwPackets = CListGetPackets(hItem, true))
pList->AddRule(Else, szJid, TRUE, dwOrder++, dwPackets);
- if (dwPackets = CListGetPackets(hwndList, hItem, false))
+ if (dwPackets = CListGetPackets(hItem, false))
pList->AddRule(Else, szJid, FALSE, dwOrder++, dwPackets);
pList->Reorder();
@@ -1527,7 +1527,8 @@ void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList)
void CJabberDlgPrivacyLists::EnableEditorControls()
{
BOOL bListsLoaded, bListsModified;
- { mir_cslock lck(m_proto->m_privacyListManager.m_cs);
+ {
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
bListsLoaded = m_proto->m_privacyListManager.IsAllListsLoaded();
bListsModified = m_proto->m_privacyListManager.IsModified() || clc_info.bChanged;
}
@@ -1539,8 +1540,8 @@ void CJabberDlgPrivacyLists::EnableEditorControls()
bListSelected = bListSelected && (SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETCURSEL, 0, 0) != LB_ERR);
bListSelected = bListSelected && SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETITEMDATA, SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETCURSEL, 0, 0), 0);
+ m_edtNewJid.Enable(bListsLoaded && bListSelected);
EnableWindow(GetDlgItem(m_hwnd, IDC_TXT_OTHERJID), bListsLoaded && bListSelected);
- EnableWindow(GetDlgItem(m_hwnd, IDC_NEWJID), bListsLoaded && bListSelected);
EnableWindow(GetDlgItem(m_hwnd, IDC_ADDJID), bListsLoaded && bListSelected);
EnableWindow(GetDlgItem(m_hwnd, IDC_ADD_RULE), bListsLoaded && bListSelected);
@@ -1599,7 +1600,8 @@ LRESULT CALLBACK CJabberDlgPrivacyLists::LstRulesSubclassProc(HWND hwnd, UINT ms
BOOL CJabberDlgPrivacyLists::CanExit()
{
BOOL bModified;
- { mir_cslock lck(m_proto->m_privacyListManager.m_cs);
+ {
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
bModified = m_proto->m_privacyListManager.IsModified();
}
@@ -1621,7 +1623,7 @@ void CJabberDlgPrivacyLists::btnSimple_OnClick(CCtrlButton *)
CheckDlgButton(m_hwnd, IDC_BTN_ADVANCED, BST_UNCHECKED);
UIShowControls(m_hwnd, idSimpleControls, SW_SHOW);
UIShowControls(m_hwnd, idAdvancedControls, SW_HIDE);
- CListApplyList(GetDlgItem(m_hwnd, IDC_CLIST), GetSelectedList(m_hwnd));
+ CListApplyList(GetSelectedList(m_hwnd));
}
void CJabberDlgPrivacyLists::btnAdvanced_OnClick(CCtrlButton *)
@@ -1630,17 +1632,14 @@ void CJabberDlgPrivacyLists::btnAdvanced_OnClick(CCtrlButton *)
CheckDlgButton(m_hwnd, IDC_BTN_ADVANCED, BST_CHECKED);
UIShowControls(m_hwnd, idSimpleControls, SW_HIDE);
UIShowControls(m_hwnd, idAdvancedControls, SW_SHOW);
- CListBuildList(GetDlgItem(m_hwnd, IDC_CLIST), GetSelectedList(m_hwnd));
+ CListBuildList(GetSelectedList(m_hwnd));
PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_LB_LISTS, LBN_SELCHANGE), 0);
}
void CJabberDlgPrivacyLists::btnAddJid_OnClick(CCtrlButton *)
{
- int len = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_NEWJID))+1;
- wchar_t *buf = (wchar_t *)_alloca(sizeof(wchar_t) * len);
- GetDlgItemText(m_hwnd, IDC_NEWJID, buf, len);
- SetDlgItemText(m_hwnd, IDC_NEWJID, L"");
- CListAddContact(GetDlgItem(m_hwnd, IDC_CLIST), buf);
+ CListAddContact(ptrA(m_edtNewJid.GetTextU()));
+ m_edtNewJid.SetTextA("");
}
void CJabberDlgPrivacyLists::btnActivate_OnClick(CCtrlButton *)
@@ -1649,7 +1648,7 @@ void CJabberDlgPrivacyLists::btnActivate_OnClick(CCtrlButton *)
return;
mir_cslockfull lck(m_proto->m_privacyListManager.m_cs);
-
+
CPrivacyList *pList = GetSelectedList(m_hwnd);
if (pList && pList->IsModified()) {
lck.unlock();
@@ -1659,10 +1658,10 @@ void CJabberDlgPrivacyLists::btnActivate_OnClick(CCtrlButton *)
EnableWindow(GetDlgItem(m_hwnd, IDC_ACTIVATE), FALSE);
SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ACTIVATE), GWLP_USERDATA, (LONG_PTR)pList);
XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, nullptr, 0, -1, pList));
- HXML query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
- HXML active = query << XCHILD(L"active");
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
+ TiXmlElement *active = query << XCHILD("active");
if (pList)
- active << XATTR(L"name", pList->GetListName());
+ active << XATTR("name", pList->GetListName());
lck.unlock();
SetStatusText(TranslateW(JABBER_PL_BUSY_MSG));
@@ -1686,10 +1685,10 @@ void CJabberDlgPrivacyLists::btnSetDefault_OnClick(CCtrlButton *)
SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_SET_DEFAULT), GWLP_USERDATA, (LONG_PTR)pList);
XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListDefault, JABBER_IQ_TYPE_SET, nullptr, 0, -1, pList));
- HXML query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
- HXML defaultTag = query << XCHILD(L"default");
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
+ TiXmlElement *defaultTag = query << XCHILD("default");
if (pList)
- XmlAddAttr(defaultTag, L"name", pList->GetListName());
+ defaultTag->SetAttribute("name", pList->GetListName());
lck.unlock();
SetStatusText(TranslateW(JABBER_PL_BUSY_MSG));
@@ -1706,9 +1705,9 @@ void CJabberDlgPrivacyLists::lbLists_OnSelChange(CCtrlListBox *)
if (nErr == LB_ERR)
return;
if (nErr == 0) {
- if (IsWindowVisible(GetDlgItem(m_hwnd, IDC_CLIST))) {
- CListBuildList(GetDlgItem(m_hwnd, IDC_CLIST), clc_info.pList);
- CListApplyList(GetDlgItem(m_hwnd, IDC_CLIST), nullptr);
+ if (IsWindowVisible(m_clcClist.GetHwnd())) {
+ CListBuildList(clc_info.pList);
+ CListApplyList(nullptr);
}
else {
EnableWindow(GetDlgItem(m_hwnd, IDC_PL_RULES_LIST), FALSE);
@@ -1720,9 +1719,9 @@ void CJabberDlgPrivacyLists::lbLists_OnSelChange(CCtrlListBox *)
}
{
mir_cslock lck(m_proto->m_privacyListManager.m_cs);
- if (IsWindowVisible(GetDlgItem(m_hwnd, IDC_CLIST))) {
- CListBuildList(GetDlgItem(m_hwnd, IDC_CLIST), clc_info.pList);
- CListApplyList(GetDlgItem(m_hwnd, IDC_CLIST), (CPrivacyList*)nErr);
+ if (IsWindowVisible(m_clcClist.GetHwnd())) {
+ CListBuildList(clc_info.pList);
+ CListApplyList((CPrivacyList*)nErr);
}
else ShowAdvancedList((CPrivacyList*)nErr);
}
@@ -1768,7 +1767,7 @@ void CJabberDlgPrivacyLists::btnAddRule_OnClick(CCtrlButton*)
CPrivacyList *pList = GetSelectedList(m_hwnd);
if (pList) {
- CPrivacyListRule* pRule = new CPrivacyListRule(m_proto, Jid, L"", FALSE);
+ CPrivacyListRule* pRule = new CPrivacyListRule(m_proto, Jid, "", FALSE);
CJabberDlgPrivacyRule dlgPrivacyRule(m_proto, m_hwnd, pRule);
int nResult = dlgPrivacyRule.DoModal();
if (nResult) {
@@ -1839,9 +1838,9 @@ void CJabberDlgPrivacyLists::btnAddList_OnClick(CCtrlButton*)
// FIXME: line length is hard coded in dialog procedure
CJabberDlgPrivacyAddList dlgPrivacyAddList(m_proto, m_hwnd);
int nRetVal = dlgPrivacyAddList.DoModal();
- if (nRetVal && mir_wstrlen(dlgPrivacyAddList.szLine)) {
+ if (nRetVal && mir_strlen(dlgPrivacyAddList.szLine)) {
mir_cslockfull lck(m_proto->m_privacyListManager.m_cs);
-
+
CPrivacyList *pList = m_proto->m_privacyListManager.FindList(dlgPrivacyAddList.szLine);
if (pList == nullptr) {
m_proto->m_privacyListManager.AddList(dlgPrivacyAddList.szLine);
@@ -1859,7 +1858,7 @@ void CJabberDlgPrivacyLists::btnAddList_OnClick(CCtrlButton*)
SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETITEMDATA, nSelected, (LPARAM)pList);
SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETCURSEL, nSelected, 0);
}
-
+
lck.unlock();
PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
}
@@ -1871,10 +1870,9 @@ void CJabberDlgPrivacyLists::btnRemoveList_OnClick(CCtrlButton *)
CPrivacyList *pList = GetSelectedList(m_hwnd);
if (pList) {
- wchar_t *szListName = pList->GetListName();
- if ((m_proto->m_privacyListManager.GetActiveListName() && !mir_wstrcmp(szListName, m_proto->m_privacyListManager.GetActiveListName())) ||
- (m_proto->m_privacyListManager.GetDefaultListName() && !mir_wstrcmp(szListName, m_proto->m_privacyListManager.GetDefaultListName())))
- {
+ char *szListName = pList->GetListName();
+ if ((m_proto->m_privacyListManager.GetActiveListName() && !mir_strcmp(szListName, m_proto->m_privacyListManager.GetActiveListName())) ||
+ (m_proto->m_privacyListManager.GetDefaultListName() && !mir_strcmp(szListName, m_proto->m_privacyListManager.GetDefaultListName()))) {
lck.unlock();
MessageBox(m_hwnd, TranslateT("Can't remove active or default list"), TranslateT("Sorry"), MB_OK | MB_ICONSTOP);
return;
@@ -1896,8 +1894,8 @@ void CJabberDlgPrivacyLists::btnApply_OnClick(CCtrlButton *)
{
mir_cslock lck(m_proto->m_privacyListManager.m_cs);
- if (IsWindowVisible(GetDlgItem(m_hwnd, IDC_CLIST)))
- CListBuildList(GetDlgItem(m_hwnd, IDC_CLIST), clc_info.pList);
+ if (IsWindowVisible(m_clcClist.GetHwnd()))
+ CListBuildList(clc_info.pList);
CPrivacyListModifyUserParam *pUserData = nullptr;
CPrivacyList *pList = m_proto->m_privacyListManager.GetFirstList();
@@ -1918,39 +1916,39 @@ void CJabberDlgPrivacyLists::btnApply_OnClick(CCtrlButton *)
pUserData->m_dwCount++;
XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListModify, JABBER_IQ_TYPE_SET, nullptr, 0, -1, pUserData));
- HXML query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
- HXML listTag = query << XCHILD(L"list") << XATTR(L"name", pList->GetListName());
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
+ TiXmlElement *listTag = query << XCHILD("list") << XATTR("name", pList->GetListName());
while (pRule) {
- HXML itemTag = listTag << XCHILD(L"item");
+ TiXmlElement *itemTag = listTag << XCHILD("item");
switch (pRule->GetType()) {
case Jid:
- itemTag << XATTR(L"type", L"jid");
+ itemTag << XATTR("type", "jid");
break;
case Group:
- itemTag << XATTR(L"type", L"group");
+ itemTag << XATTR("type", "group");
break;
case Subscription:
- itemTag << XATTR(L"type", L"subscription");
+ itemTag << XATTR("type", "subscription");
break;
}
if (pRule->GetType() != Else)
- itemTag << XATTR(L"value", pRule->GetValue());
+ itemTag << XATTR("value", pRule->GetValue());
if (pRule->GetAction())
- itemTag << XATTR(L"action", L"allow");
+ itemTag << XATTR("action", "allow");
else
- itemTag << XATTR(L"action", L"deny");
- itemTag << XATTRI(L"order", pRule->GetOrder());
+ itemTag << XATTR("action", "deny");
+ itemTag << XATTRI("order", pRule->GetOrder());
DWORD dwPackets = pRule->GetPackets();
if (dwPackets != JABBER_PL_RULE_TYPE_ALL) {
if (dwPackets & JABBER_PL_RULE_TYPE_IQ)
- itemTag << XCHILD(L"iq");
+ itemTag << XCHILD("iq");
if (dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_IN)
- itemTag << XCHILD(L"presence-in");
+ itemTag << XCHILD("presence-in");
if (dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_OUT)
- itemTag << XCHILD(L"presence-out");
+ itemTag << XCHILD("presence-out");
if (dwPackets & JABBER_PL_RULE_TYPE_MESSAGE)
- itemTag << XCHILD(L"message");
+ itemTag << XCHILD("message");
}
pRule = pRule->GetNext();
}
@@ -1958,7 +1956,8 @@ void CJabberDlgPrivacyLists::btnApply_OnClick(CCtrlButton *)
m_proto->m_ThreadInfo->send(iq);
}
pList = pList->GetNext();
- } }
+ }
+ }
SetStatusText(TranslateW(JABBER_PL_BUSY_MSG));
PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
@@ -1966,8 +1965,8 @@ void CJabberDlgPrivacyLists::btnApply_OnClick(CCtrlButton *)
void CJabberDlgPrivacyLists::OnCommand_Close(HWND /*hwndCtrl*/, WORD /*idCtrl*/, WORD /*idCode*/)
{
- if (IsWindowVisible(GetDlgItem(m_hwnd, IDC_CLIST)))
- CListBuildList(GetDlgItem(m_hwnd, IDC_CLIST), clc_info.pList);
+ if (IsWindowVisible(m_clcClist.GetHwnd()))
+ CListBuildList(clc_info.pList);
if (CanExit())
DestroyWindow(m_hwnd);
@@ -1975,14 +1974,14 @@ void CJabberDlgPrivacyLists::OnCommand_Close(HWND /*hwndCtrl*/, WORD /*idCtrl*/,
void CJabberDlgPrivacyLists::clcClist_OnUpdate(CCtrlClc::TEventInfo*)
{
- CListFilter(GetDlgItem(m_hwnd, IDC_CLIST));
- CListApplyList(GetDlgItem(m_hwnd, IDC_CLIST), GetSelectedList(m_hwnd));
+ CListFilter();
+ CListApplyList(GetSelectedList(m_hwnd));
}
void CJabberDlgPrivacyLists::clcClist_OnOptionsChanged(CCtrlClc::TEventInfo*)
{
- CListResetOptions(GetDlgItem(m_hwnd, IDC_CLIST));
- CListApplyList(GetDlgItem(m_hwnd, IDC_CLIST), GetSelectedList(m_hwnd));
+ CListResetOptions();
+ CListApplyList(GetSelectedList(m_hwnd));
}
void CJabberDlgPrivacyLists::clcClist_OnClick(CCtrlClc::TEventInfo *evt)
@@ -2077,10 +2076,10 @@ INT_PTR __cdecl CJabberProto::menuSetPrivacyList(WPARAM, LPARAM, LPARAM iList)
}
XmlNodeIq iq(AddIQ(&CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, nullptr, 0, -1, pList));
- HXML query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
- HXML active = query << XCHILD(L"active");
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
+ TiXmlElement *active = query << XCHILD("active");
if (pList)
- active << XATTR(L"name", pList->GetListName());
+ active << XATTR("name", pList->GetListName());
lck.unlock();
m_ThreadInfo->send(iq);
@@ -2148,10 +2147,11 @@ void CJabberProto::BuildPrivacyListsMenu(bool bDeleteOld)
m_privacyMenuServiceAllocated = i;
}
+ Utf2T wszListName(pList->GetListName());
mi.position++;
mi.hIcolibItem = Skin_GetIconHandle(
- mir_wstrcmp(m_privacyListManager.GetActiveListName(), pList->GetListName()) ? SKINICON_OTHER_SMALLDOT : SKINICON_OTHER_EMPTYBLOB);
- mi.name.w = pList->GetListName();
+ mir_strcmp(m_privacyListManager.GetActiveListName(), pList->GetListName()) ? SKINICON_OTHER_SMALLDOT : SKINICON_OTHER_EMPTYBLOB);
+ mi.name.w = wszListName;
m_hPrivacyMenuItems.insert(Menu_AddProtoMenuItem(&mi, m_szModuleName));
}
}
diff --git a/protocols/JabberG/src/jabber_privacy.h b/protocols/JabberG/src/jabber_privacy.h
index a8747e7066..7cc1257746 100644
--- a/protocols/JabberG/src/jabber_privacy.h
+++ b/protocols/JabberG/src/jabber_privacy.h
@@ -58,10 +58,10 @@ class CPrivacyListRule
protected:
friend class CPrivacyList;
public:
- CPrivacyListRule(CJabberProto *ppro, PrivacyListRuleType type = Else, const wchar_t *szValue = L"", BOOL bAction = TRUE, DWORD dwOrder = 90, DWORD dwPackets = 0)
+ CPrivacyListRule(CJabberProto *ppro, PrivacyListRuleType type = Else, const char *szValue = "", BOOL bAction = TRUE, DWORD dwOrder = 90, DWORD dwPackets = 0)
{
m_proto = ppro;
- m_szValue = mir_wstrdup(szValue);
+ m_szValue = mir_strdup(szValue);
m_nType = type;
m_bAction = bAction;
m_dwOrder = dwOrder;
@@ -103,13 +103,13 @@ public:
m_nType = type;
return TRUE;
}
- __inline wchar_t* GetValue()
+ __inline char* GetValue()
{
return m_szValue;
}
- __inline BOOL SetValue(wchar_t *szValue)
+ __inline BOOL SetValue(const char *szValue)
{
- replaceStrW(m_szValue, szValue);
+ replaceStr(m_szValue, szValue);
return TRUE;
}
__inline DWORD GetPackets()
@@ -133,8 +133,8 @@ public:
CJabberProto* m_proto;
protected:
PrivacyListRuleType m_nType;
- wchar_t *m_szValue;
- BOOL m_bAction;
+ char *m_szValue;
+ BOOL m_bAction;
DWORD m_dwOrder;
DWORD m_dwPackets;
CPrivacyListRule *m_pNext;
@@ -145,7 +145,7 @@ class CPrivacyList
{
protected:
CPrivacyListRule *m_pRules;
- wchar_t *m_szListName;
+ char *m_szListName;
CPrivacyList *m_pNext;
BOOL m_bLoaded;
BOOL m_bModified;
@@ -153,10 +153,10 @@ protected:
public:
CJabberProto* m_proto;
- CPrivacyList(CJabberProto *ppro, wchar_t *szListName)
+ CPrivacyList(CJabberProto *ppro, const char *szListName)
{
m_proto = ppro;
- m_szListName = mir_wstrdup(szListName);
+ m_szListName = mir_strdup(szListName);
m_pRules = nullptr;
m_pNext = nullptr;
m_bLoaded = FALSE;
@@ -177,7 +177,7 @@ public:
m_pRules = nullptr;
return TRUE;
}
- __inline wchar_t* GetListName()
+ __inline char* GetListName()
{
return m_szListName;
}
@@ -195,7 +195,7 @@ public:
m_pNext = pNext;
return pRetVal;
}
- BOOL AddRule(PrivacyListRuleType type, const wchar_t *szValue, BOOL bAction, DWORD dwOrder, DWORD dwPackets)
+ BOOL AddRule(PrivacyListRuleType type, const char *szValue, BOOL bAction, DWORD dwOrder, DWORD dwPackets)
{
CPrivacyListRule *pRule = new CPrivacyListRule(m_proto, type, szValue, bAction, dwOrder, dwPackets);
if (!pRule)
@@ -319,8 +319,8 @@ public:
class CPrivacyListManager
{
protected:
- wchar_t *m_szActiveListName;
- wchar_t *m_szDefaultListName;
+ char *m_szActiveListName;
+ char *m_szDefaultListName;
CPrivacyList *m_pLists;
BOOL m_bModified;
@@ -342,19 +342,19 @@ public:
mir_free(m_szDefaultListName);
RemoveAllLists();
};
- void SetActiveListName(const wchar_t *szListName)
+ void SetActiveListName(const char *szListName)
{
- replaceStrW(m_szActiveListName, szListName);
+ replaceStr(m_szActiveListName, szListName);
}
- void SetDefaultListName(const wchar_t *szListName)
+ void SetDefaultListName(const char *szListName)
{
- replaceStrW(m_szDefaultListName, szListName);
+ replaceStr(m_szDefaultListName, szListName);
}
- wchar_t* GetDefaultListName()
+ char* GetDefaultListName()
{
return m_szDefaultListName;
}
- wchar_t* GetActiveListName()
+ char* GetActiveListName()
{
return m_szActiveListName;
}
@@ -365,11 +365,11 @@ public:
m_pLists = nullptr;
return TRUE;
}
- CPrivacyList* FindList(const wchar_t *szListName)
+ CPrivacyList* FindList(const char *szListName)
{
CPrivacyList *pList = m_pLists;
while (pList) {
- if (!mir_wstrcmp(pList->GetListName(), szListName))
+ if (!mir_strcmp(pList->GetListName(), szListName))
return pList;
pList = pList->GetNext();
}
@@ -379,7 +379,7 @@ public:
{
return m_pLists;
}
- BOOL AddList(wchar_t *szListName)
+ BOOL AddList(const char *szListName)
{
if (FindList(szListName))
return FALSE;
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index 678a7d5db7..b027388a67 100755
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -30,9 +30,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#pragma warning(disable:4355)
-static int compareTransports(const wchar_t *p1, const wchar_t *p2)
+static int compareTransports(const char *p1, const char *p2)
{
- return mir_wstrcmpi(p1, p2);
+ return mir_strcmpi(p1, p2);
}
static int compareListItems(const JABBER_LIST_ITEM *p1, const JABBER_LIST_ITEM *p2)
@@ -44,12 +44,12 @@ static int compareListItems(const JABBER_LIST_ITEM *p1, const JABBER_LIST_ITEM *
// resource must be used in the comparison
if ((p1->list == LIST_ROSTER && (p1->bUseResource == true || p2->bUseResource == true))
|| (p1->list == LIST_BOOKMARK) || (p1->list == LIST_VCARD_TEMP))
- return mir_wstrcmpi(p1->jid, p2->jid);
+ return mir_strcmpi(p1->jid, p2->jid);
- wchar_t szp1[JABBER_MAX_JID_LEN], szp2[JABBER_MAX_JID_LEN];
+ char szp1[JABBER_MAX_JID_LEN], szp2[JABBER_MAX_JID_LEN];
JabberStripJid(p1->jid, szp1, _countof(szp1));
JabberStripJid(p2->jid, szp2, _countof(szp2));
- return mir_wstrcmpi(szp1, szp2);
+ return mir_strcmpi(szp1, szp2);
}
CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) :
@@ -189,7 +189,7 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) :
m_iqManager.FillPermanentHandlers();
m_messageManager.FillPermanentHandlers();
m_adhocManager.FillDefaultNodes();
-
+
AddDefaultCaps();
IconsInit();
@@ -214,8 +214,8 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) :
db_set_resident(m_szModuleName, "Auth");
db_set_resident(m_szModuleName, "Grant");
- if ((m_tszSelectedLang = getWStringA("XmlLang")) == nullptr)
- m_tszSelectedLang = mir_wstrdup(L"en");
+ if ((m_tszSelectedLang = getUStringA("XmlLang")) == nullptr)
+ m_tszSelectedLang = mir_strdup("en");
}
@@ -310,15 +310,15 @@ void CJabberProto::OnModulesLoaded()
SetContactOfflineStatus(hContact);
if (getByte(hContact, "IsTransport", 0)) {
- ptrW jid(getWStringA(hContact, "jid"));
+ ptrA jid(getUStringA(hContact, "jid"));
if (jid == nullptr)
continue;
- wchar_t *resourcepos = wcschr(jid, '/');
+ char *resourcepos = strchr(jid, '/');
if (resourcepos != nullptr)
*resourcepos = '\0';
- m_lstTransports.insert(mir_wstrdup(jid));
+ m_lstTransports.insert(mir_strdup(jid));
}
}
}
@@ -354,7 +354,7 @@ void CJabberProto::OnShutdown()
////////////////////////////////////////////////////////////////////////////////////////
// JabberAddToList - adds a contact to the contact list
-MCONTACT CJabberProto::AddToListByJID(const wchar_t *newJid, DWORD flags)
+MCONTACT CJabberProto::AddToListByJID(const char *newJid, DWORD flags)
{
debugLogW(L"AddToListByJID jid = %s", newJid);
@@ -370,7 +370,7 @@ MCONTACT CJabberProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
if (psr->cbSize != sizeof(PROTOSEARCHRESULT) && psr->id.w == nullptr)
return 0;
- return AddToListByJID(psr->id.w, flags);
+ return AddToListByJID(T2Utf(psr->id.w), flags);
}
MCONTACT CJabberProto::AddToListByEvent(int flags, int /*iContact*/, MEVENT hDbEvent)
@@ -390,7 +390,7 @@ MCONTACT CJabberProto::AddToListByEvent(int flags, int /*iContact*/, MEVENT hDbE
return 0;
DB_AUTH_BLOB blob(dbei.pBlob);
- return AddToListByJID(ptrW(dbei.getString(blob.get_email())), flags);
+ return AddToListByJID(blob.get_email(), flags);
}
////////////////////////////////////////////////////////////////////////////////////////
@@ -414,18 +414,16 @@ int CJabberProto::Authorize(MEVENT hDbEvent)
return 1;
DB_AUTH_BLOB blob(dbei.pBlob);
- debugLogW(L"Send 'authorization allowed' to %s", blob.get_email());
-
- ptrW newJid(dbei.getString(blob.get_email()));
+ debugLogA("Send 'authorization allowed' to %s", blob.get_email());
- m_ThreadInfo->send(XmlNode(L"presence") << XATTR(L"to", newJid) << XATTR(L"type", L"subscribed"));
+ m_ThreadInfo->send(XmlNode("presence") << XATTR("to", blob.get_email()) << XATTR("type", "subscribed"));
// Automatically add this user to my roster if option is enabled
if (m_bAutoAdd) {
- JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, newJid);
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, blob.get_email());
if (item == nullptr || (item->subscription != SUB_BOTH && item->subscription != SUB_TO)) {
debugLogW(L"Try adding contact automatically jid = %s", blob.get_email());
- if (MCONTACT hContact = AddToListByJID(newJid, 0)) {
+ if (MCONTACT hContact = AddToListByJID(blob.get_email(), 0)) {
// Trigger actual add by removing the "NotOnList" added by AddToListByJID()
// See AddToListByJID() and JabberDbSettingChanged().
db_unset(hContact, "CList", "NotOnList");
@@ -433,7 +431,6 @@ int CJabberProto::Authorize(MEVENT hDbEvent)
}
}
- mir_free(newJid);
return 0;
}
@@ -464,15 +461,15 @@ int CJabberProto::AuthDeny(MEVENT hDbEvent, const wchar_t*)
if (mir_strcmp(dbei.szModule, m_szModuleName))
return 1;
- char *nick = (char*)(dbei.pBlob + sizeof(DWORD)*2);
+ char *nick = (char*)(dbei.pBlob + sizeof(DWORD) * 2);
char *firstName = nick + mir_strlen(nick) + 1;
char *lastName = firstName + mir_strlen(firstName) + 1;
char *jid = lastName + mir_strlen(lastName) + 1;
debugLogA("Send 'authorization denied' to %s", jid);
- ptrW newJid(dbei.flags & DBEF_UTF ? mir_utf8decodeW(jid) : mir_a2u(jid));
- m_ThreadInfo->send(XmlNode(L"presence") << XATTR(L"to", newJid) << XATTR(L"type", L"unsubscribed"));
+ ptrA newJid(dbei.flags & DBEF_UTF ? mir_strdup(jid) : mir_utf8encode(jid));
+ m_ThreadInfo->send(XmlNode("presence") << XATTR("to", newJid) << XATTR("type", "unsubscribed"));
return 0;
}
@@ -486,7 +483,7 @@ HANDLE CJabberProto::FileAllow(MCONTACT /*hContact*/, HANDLE hTransfer, const wc
filetransfer *ft = (filetransfer*)hTransfer;
ft->std.szWorkingDir.w = mir_wstrdup(szPath);
- size_t len = mir_wstrlen(ft->std.szWorkingDir.w)-1;
+ size_t len = mir_wstrlen(ft->std.szWorkingDir.w) - 1;
if (ft->std.szWorkingDir.w[len] == '/' || ft->std.szWorkingDir.w[len] == '\\')
ft->std.szWorkingDir.w[len] = 0;
@@ -544,16 +541,16 @@ int CJabberProto::FileDeny(MCONTACT, HANDLE hTransfer, const wchar_t *)
switch (ft->type) {
case FT_OOB:
- m_ThreadInfo->send(XmlNodeIq(L"error", ft->szId, ft->jid) << XCHILD(L"error", L"File transfer refused") << XATTRI(L"code", 406));
+ m_ThreadInfo->send(XmlNodeIq("error", ft->szId, ft->jid) << XCHILD("error", "File transfer refused") << XATTRI("code", 406));
break;
case FT_BYTESTREAM:
case FT_IBB:
m_ThreadInfo->send(
- XmlNodeIq(L"error", ft->szId, ft->jid)
- << XCHILD(L"error", L"File transfer refused") << XATTRI(L"code", 403) << XATTR(L"type", L"cancel")
- << XCHILDNS(L"forbidden", L"urn:ietf:params:xml:ns:xmpp-stanzas")
- << XCHILD(L"text", L"File transfer refused") << XATTR(L"xmlns", L"urn:ietf:params:xml:ns:xmpp-stanzas"));
+ XmlNodeIq("error", ft->szId, ft->jid)
+ << XCHILD("error", "File transfer refused") << XATTRI("code", 403) << XATTR("type", "cancel")
+ << XCHILDNS("forbidden", "urn:ietf:params:xml:ns:xmpp-stanzas")
+ << XCHILD("text", "File transfer refused") << XATTR("xmlns", "urn:ietf:params:xml:ns:xmpp-stanzas"));
break;
}
delete ft;
@@ -593,7 +590,7 @@ INT_PTR CJabberProto::GetCaps(int type, MCONTACT hContact)
case PFLAG_UNIQUEIDTEXT:
return (INT_PTR)Translate("JID");
case PFLAG_MAXCONTACTSPERPACKET:
- wchar_t szClientJid[JABBER_MAX_JID_LEN];
+ char szClientJid[JABBER_MAX_JID_LEN];
if (GetClientJID(hContact, szClientJid, _countof(szClientJid))) {
JabberCapsBits jcb = GetResourceCapabilities(szClientJid);
return ((~jcb & JABBER_CAPS_ROSTER_EXCHANGE) ? 0 : 50);
@@ -610,7 +607,7 @@ int CJabberProto::GetInfo(MCONTACT hContact, int /*infoType*/)
if (!m_bJabberOnline || isChatRoom(hContact))
return 1;
- wchar_t jid[JABBER_MAX_JID_LEN], szBareJid[JABBER_MAX_JID_LEN];
+ char jid[JABBER_MAX_JID_LEN], szBareJid[JABBER_MAX_JID_LEN];
if (!GetClientJID(hContact, jid, _countof(jid)))
return 1;
@@ -620,7 +617,7 @@ int CJabberProto::GetInfo(MCONTACT hContact, int /*infoType*/)
if (m_ThreadInfo) {
m_ThreadInfo->send(
XmlNodeIq(AddIQ(&CJabberProto::OnIqResultEntityTime, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_HCONTACT))
- << XCHILDNS(L"time", JABBER_FEAT_ENTITY_TIME));
+ << XCHILDNS("time", JABBER_FEAT_ENTITY_TIME));
// XEP-0012, last logoff time
XmlNodeIq iq2(AddIQ(&CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_FROM));
@@ -633,13 +630,13 @@ int CJabberProto::GetInfo(MCONTACT hContact, int /*infoType*/)
item = ListGetItemPtr(LIST_ROSTER, jid);
if (item == nullptr) {
- bool bHasResource = mir_wstrcmp(jid, szBareJid) != 0;
+ bool bHasResource = mir_strcmp(jid, szBareJid) != 0;
JABBER_LIST_ITEM *tmpItem = nullptr;
if (bHasResource && (tmpItem = ListGetItemPtr(LIST_CHATROOM, szBareJid))) {
- pResourceStatus him(tmpItem->findResource(szBareJid+mir_wstrlen(szBareJid)+1));
+ pResourceStatus him(tmpItem->findResource(szBareJid + mir_strlen(szBareJid) + 1));
if (him) {
item = ListAdd(LIST_VCARD_TEMP, jid, hContact);
- ListAddResource(LIST_VCARD_TEMP, jid, him->m_iStatus, him->m_tszStatusMessage, him->m_iPriority);
+ ListAddResource(LIST_VCARD_TEMP, jid, him->m_iStatus, him->m_szStatusMessage, him->m_iPriority);
}
}
else item = ListAdd(LIST_VCARD_TEMP, jid, hContact);
@@ -649,8 +646,8 @@ int CJabberProto::GetInfo(MCONTACT hContact, int /*infoType*/)
if (item->arResources.getCount()) {
for (auto &it : item->arResources) {
pResourceStatus r(it);
- wchar_t tmp[JABBER_MAX_JID_LEN];
- mir_snwprintf(tmp, L"%s/%s", szBareJid, r->m_tszResourceName);
+ char tmp[JABBER_MAX_JID_LEN];
+ mir_snprintf(tmp, "%s/%s", szBareJid, r->m_szResourceName);
if (r->m_jcbCachedCaps & JABBER_CAPS_DISCO_INFO) {
XmlNodeIq iq5(AddIQ(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE | JABBER_IQ_PARSE_HCONTACT));
@@ -658,7 +655,7 @@ int CJabberProto::GetInfo(MCONTACT hContact, int /*infoType*/)
m_ThreadInfo->send(iq5);
}
- if (!mir_wstrcmp(tmp, jid)) {
+ if (!mir_strcmp(tmp, jid)) {
XmlNodeIq iq3(AddIQ(&CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM));
iq3 << XQUERY(JABBER_FEAT_LAST_ACTIVITY);
m_ThreadInfo->send(iq3);
@@ -747,8 +744,8 @@ HANDLE CJabberProto::SearchByEmail(const wchar_t *email)
ptrA szServerName(getStringA("Jud"));
LPCSTR jid = szServerName == 0 ? "users.jabber.org" : szServerName;
- CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultSetSearch, JABBER_IQ_TYPE_SET, _A2T(jid));
- m_ThreadInfo->send(XmlNodeIq(pInfo) << XQUERY(L"jabber:iq:search") << XCHILD(L"email", email));
+ CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultSetSearch, JABBER_IQ_TYPE_SET, jid);
+ m_ThreadInfo->send(XmlNodeIq(pInfo) << XQUERY("jabber:iq:search") << XCHILD("email", T2Utf(email)));
return (HANDLE)pInfo->GetIqId();
}
@@ -766,33 +763,33 @@ HANDLE CJabberProto::SearchByName(const wchar_t *nick, const wchar_t *firstName,
CJabberIqInfo *pInfo = AddIQ(
(bIsExtFormat) ? &CJabberProto::OnIqResultExtSearch : &CJabberProto::OnIqResultSetSearch,
- JABBER_IQ_TYPE_SET, _A2T(szServerName == 0 ? "users.jabber.org" : szServerName));
+ JABBER_IQ_TYPE_SET, szServerName == 0 ? "users.jabber.org" : szServerName);
XmlNodeIq iq(pInfo);
- HXML query = iq << XQUERY(L"jabber:iq:search");
+ TiXmlElement *query = iq << XQUERY("jabber:iq:search");
if (bIsExtFormat) {
if (m_tszSelectedLang)
- iq << XATTR(L"xml:lang", m_tszSelectedLang);
+ iq << XATTR("xml:lang", m_tszSelectedLang);
- HXML x = query << XCHILDNS(L"x", JABBER_FEAT_DATA_FORMS) << XATTR(L"type", L"submit");
+ TiXmlElement *x = query << XCHILDNS("x", JABBER_FEAT_DATA_FORMS) << XATTR("type", "submit");
if (nick[0] != '\0')
- x << XCHILD(L"field") << XATTR(L"var", L"user") << XATTR(L"value", nick);
+ x << XCHILD("field") << XATTR("var", "user") << XATTR("value", T2Utf(nick));
if (firstName[0] != '\0')
- x << XCHILD(L"field") << XATTR(L"var", L"fn") << XATTR(L"value", firstName);
+ x << XCHILD("field") << XATTR("var", "fn") << XATTR("value", T2Utf(firstName));
if (lastName[0] != '\0')
- x << XCHILD(L"field") << XATTR(L"var", L"given") << XATTR(L"value", lastName);
+ x << XCHILD("field") << XATTR("var", "given") << XATTR("value", T2Utf(lastName));
}
else {
if (nick[0] != '\0')
- query << XCHILD(L"nick", nick);
+ query << XCHILD("nick", T2Utf(nick));
if (firstName[0] != '\0')
- query << XCHILD(L"first", firstName);
+ query << XCHILD("first", T2Utf(firstName));
if (lastName[0] != '\0')
- query << XCHILD(L"last", lastName);
+ query << XCHILD("last", T2Utf(lastName));
}
m_ThreadInfo->send(iq);
@@ -807,7 +804,7 @@ int CJabberProto::SendContacts(MCONTACT hContact, int, int nContacts, MCONTACT *
if (!m_bJabberOnline)
return 0;
- wchar_t szClientJid[JABBER_MAX_JID_LEN];
+ char szClientJid[JABBER_MAX_JID_LEN];
if (!GetClientJID(hContact, szClientJid, _countof(szClientJid)))
return 0;
@@ -815,16 +812,16 @@ int CJabberProto::SendContacts(MCONTACT hContact, int, int nContacts, MCONTACT *
if (~jcb & JABBER_CAPS_ROSTER_EXCHANGE)
return 0;
- XmlNode m(L"message");
- HXML x = m << XCHILDNS(L"x", JABBER_FEAT_ROSTER_EXCHANGE);
+ XmlNode m("message");
+ TiXmlElement *x = m << XCHILDNS("x", JABBER_FEAT_ROSTER_EXCHANGE);
for (int i = 0; i < nContacts; i++) {
- ptrW jid(getWStringA(hContactsList[i], "jid"));
+ ptrA jid(getUStringA(hContactsList[i], "jid"));
if (jid != nullptr)
- x << XCHILD(L"item") << XATTR(L"action", L"add") << XATTR(L"jid", jid);
+ x << XCHILD("item") << XATTR("action", "add") << XATTR("jid", jid);
}
- m << XATTR(L"to", szClientJid) << XATTRID(SerialNext());
+ m << XATTR("to", szClientJid) << XATTRID(SerialNext());
m_ThreadInfo->send(m);
return 1;
}
@@ -839,7 +836,7 @@ HANDLE CJabberProto::SendFile(MCONTACT hContact, const wchar_t *szDescription, w
if (getWord(hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE)
return nullptr;
- ptrW jid(getWStringA(hContact, "jid"));
+ ptrA jid(getUStringA(hContact, "jid"));
if (jid == nullptr)
return nullptr;
@@ -874,7 +871,7 @@ HANDLE CJabberProto::SendFile(MCONTACT hContact, const wchar_t *szDescription, w
|| (jcb == JABBER_RESOURCE_CAPS_NONE)
// XEP-0096 and OOB not supported?
|| !(jcb & (JABBER_CAPS_SI_FT | JABBER_CAPS_OOB))) {
- MsgPopup(hContact, TranslateT("No compatible file transfer mechanism exists"), item->jid);
+ MsgPopup(hContact, TranslateT("No compatible file transfer mechanism exists"), Utf2T(item->jid));
return nullptr;
}
@@ -905,7 +902,7 @@ HANDLE CJabberProto::SendFile(MCONTACT hContact, const wchar_t *szDescription, w
ft->std.szCurrentFile.w = mir_wstrdup(ppszFiles[0]);
ft->szDescription = mir_wstrdup(szDescription);
- ft->jid = mir_wstrdup(jid);
+ ft->jid = mir_strdup(jid);
if (jcb & JABBER_CAPS_SI_FT)
FtInitiate(item->jid, ft);
@@ -922,7 +919,8 @@ struct TFakeAckParams
{
inline TFakeAckParams(MCONTACT _hContact, const char* _msg, int _msgid = 0)
: hContact(_hContact), msg(_msg), msgid(_msgid)
- {}
+ {
+ }
MCONTACT hContact;
const char *msg;
@@ -943,19 +941,17 @@ void __cdecl CJabberProto::SendMessageAckThread(void* param)
static char PGP_PROLOG[] = "-----BEGIN PGP MESSAGE-----\r\n\r\n";
static char PGP_EPILOG[] = "\r\n-----END PGP MESSAGE-----\r\n";
-int CJabberProto::SendMsg(MCONTACT hContact, int unused_unknown, const char* pszSrc)
+int CJabberProto::SendMsg(MCONTACT hContact, int unused_unknown, const char *pszSrc)
{
- wchar_t szClientJid[JABBER_MAX_JID_LEN];
+ char szClientJid[JABBER_MAX_JID_LEN];
if (!m_bJabberOnline || !GetClientJID(hContact, szClientJid, _countof(szClientJid))) {
TFakeAckParams *param = new TFakeAckParams(hContact, Translate("Protocol is offline or no JID"));
ForkThread(&CJabberProto::SendMessageAckThread, param);
return 1;
}
- if (m_bUseOMEMO)
- {
- if (!OmemoCheckSession(hContact))
- {
+ if (m_bUseOMEMO) {
+ if (!OmemoCheckSession(hContact)) {
OmemoPutMessageToOutgoingQueue(hContact, unused_unknown, pszSrc);
int id = SerialNext();
TFakeAckParams *param = new TFakeAckParams(hContact, nullptr, id);
@@ -976,39 +972,30 @@ int CJabberProto::SendMsg(MCONTACT hContact, int unused_unknown, const char* psz
}
else isEncrypted = 0;
- wchar_t *msg;
- mir_utf8decode(NEWSTR_ALLOCA(pszSrc), &msg);
- if (msg == nullptr)
- return 0;
-
- wchar_t *msgType;
- if (ListGetItemPtr(LIST_CHATROOM, szClientJid) && wcschr(szClientJid, '/') == nullptr)
- msgType = L"groupchat";
+ char *msgType;
+ if (ListGetItemPtr(LIST_CHATROOM, szClientJid) && strchr(szClientJid, '/') == nullptr)
+ msgType = "groupchat";
else
- msgType = L"chat";
- XmlNode m(L"message");
+ msgType = "chat";
+ XmlNode m("message");
- if(m_bUseOMEMO && OmemoIsEnabled(hContact) && !mir_wstrcmp(msgType, L"chat")) //omemo enabled in options, omemo enabled for contact
- {
- //TODO: check if message encrypted for at least one session and return error if not
- if (!OmemoEncryptMessage(m, msg, hContact))
- {
+ // omemo enabled in options, omemo enabled for contact
+ if (m_bUseOMEMO && OmemoIsEnabled(hContact) && !mir_strcmp(msgType, "chat")) {
+ // TODO: check if message encrypted for at least one session and return error if not
+ if (!OmemoEncryptMessage(m, pszSrc, hContact)) {
TFakeAckParams *param = new TFakeAckParams(hContact, Translate("No valid OMEMO session exists"));
ForkThread(&CJabberProto::SendMessageAckThread, param);
return 0;
}
}
- else
- {
-
- XmlAddAttr(m, L"type", msgType);
+ else {
+ XmlAddAttr(m, "type", msgType);
if (!isEncrypted)
- m << XCHILD(L"body", msg);
+ m << XCHILD("body", pszSrc);
else {
- m << XCHILD(L"body", L"[This message is encrypted.]");
- m << XCHILD(L"x", msg) << XATTR(L"xmlns", L"jabber:x:encrypted");
+ m << XCHILD("body", "[This message is encrypted.]");
+ m << XCHILD("x", pszSrc) << XATTR("xmlns", "jabber:x:encrypted");
}
- mir_free(msg);
}
pResourceStatus r(ResourceInfoFromJID(szClientJid));
@@ -1021,7 +1008,7 @@ int CJabberProto::SendMsg(MCONTACT hContact, int unused_unknown, const char* psz
jcb = JABBER_RESOURCE_CAPS_NONE;
if (jcb & JABBER_CAPS_CHATSTATES)
- m << XCHILDNS(L"active", JABBER_FEAT_CHATSTATES);
+ m << XCHILDNS("active", JABBER_FEAT_CHATSTATES);
if (
// if message delivery check disabled by entity caps manager
@@ -1029,29 +1016,28 @@ int CJabberProto::SendMsg(MCONTACT hContact, int unused_unknown, const char* psz
// if client knows nothing about delivery
!(jcb & (JABBER_CAPS_MESSAGE_EVENTS | JABBER_CAPS_MESSAGE_RECEIPTS)) ||
// if message sent to groupchat
- !mir_wstrcmp(msgType, L"groupchat") ||
+ !mir_strcmp(msgType, "groupchat") ||
// if message delivery check disabled in settings
- !m_bMsgAck || !getByte(hContact, "MsgAck", true))
- {
- if (!mir_wstrcmp(msgType, L"groupchat"))
- XmlAddAttr(m, L"to", szClientJid);
+ !m_bMsgAck || !getByte(hContact, "MsgAck", true)) {
+ if (!mir_strcmp(msgType, "groupchat"))
+ XmlAddAttr(m, "to", szClientJid);
else {
id = SerialNext();
- XmlAddAttr(m, L"to", szClientJid); XmlAddAttrID(m, id);
+ XmlAddAttr(m, "to", szClientJid); XmlAddAttrID(m, id);
}
m_ThreadInfo->send(m);
ForkThread(&CJabberProto::SendMessageAckThread, new TFakeAckParams(hContact, nullptr, id));
}
else {
- XmlAddAttr(m, L"to", szClientJid); XmlAddAttrID(m, id);
+ XmlAddAttr(m, "to", szClientJid); XmlAddAttrID(m, id);
// message receipts XEP priority
if (jcb & JABBER_CAPS_MESSAGE_RECEIPTS)
- m << XCHILDNS(L"request", JABBER_FEAT_MESSAGE_RECEIPTS);
+ m << XCHILDNS("request", JABBER_FEAT_MESSAGE_RECEIPTS);
else if (jcb & JABBER_CAPS_MESSAGE_EVENTS) {
- HXML x = m << XCHILDNS(L"x", JABBER_FEAT_MESSAGE_EVENTS);
- x << XCHILD(L"delivered"); x << XCHILD(L"offline");
+ TiXmlElement *x = m << XCHILDNS("x", JABBER_FEAT_MESSAGE_EVENTS);
+ x << XCHILD("delivered"); x << XCHILD("offline");
}
m_ThreadInfo->send(m);
@@ -1075,14 +1061,14 @@ int CJabberProto::SetApparentMode(MCONTACT hContact, int mode)
if (!m_bJabberOnline)
return 0;
- ptrW jid(getWStringA(hContact, "jid"));
+ ptrA jid(getUStringA(hContact, "jid"));
if (jid == nullptr)
return 0;
switch (mode) {
case ID_STATUS_ONLINE:
if (m_iStatus == ID_STATUS_INVISIBLE || oldMode == ID_STATUS_OFFLINE)
- m_ThreadInfo->send(XmlNode(L"presence") << XATTR(L"to", jid));
+ m_ThreadInfo->send(XmlNode("presence") << XATTR("to", jid));
break;
case ID_STATUS_OFFLINE:
if (m_iStatus != ID_STATUS_INVISIBLE || oldMode == ID_STATUS_ONLINE)
@@ -1116,7 +1102,7 @@ int CJabberProto::SetStatus(int iNewStatus)
if (iNewStatus == ID_STATUS_OFFLINE) {
m_StrmMgmt.ResetState();
if (m_ThreadInfo) {
- if(m_bEnableStreamMgmt)
+ if (m_bEnableStreamMgmt)
m_StrmMgmt.SendAck();
m_ThreadInfo->send("</stream:stream>");
m_ThreadInfo->shutdown();
@@ -1150,24 +1136,24 @@ void __cdecl CJabberProto::GetAwayMsgThread(void *param)
MCONTACT hContact = (DWORD_PTR)param;
- ptrW jid(getWStringA(hContact, "jid"));
+ ptrA jid(getUStringA(hContact, "jid"));
if (jid != nullptr) {
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid);
if (item != nullptr) {
if (item->arResources.getCount() > 0) {
CMStringW str;
for (auto &r : item->arResources)
- if (r->m_tszStatusMessage)
- str.AppendFormat(L"(%s): %s\r\n", r->m_tszResourceName, r->m_tszStatusMessage);
+ if (r->m_szStatusMessage)
+ str.AppendFormat(L"(%s): %s\r\n", r->m_szResourceName, r->m_szStatusMessage);
str.TrimRight();
ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)str.c_str());
return;
}
- wchar_t *tszStatusMsg = item->getTemp()->m_tszStatusMessage;
+ Utf2T tszStatusMsg(item->getTemp()->m_szStatusMessage);
if (tszStatusMsg != nullptr) {
- ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)tszStatusMsg);
+ ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, tszStatusMsg);
return;
}
}
@@ -1187,7 +1173,7 @@ HANDLE CJabberProto::GetAwayMsg(MCONTACT hContact)
int CJabberProto::SetAwayMsg(int status, const wchar_t *msg)
{
- wchar_t **szMsg;
+ char **szMsg;
mir_cslockfull lck(m_csModeMsgMutex);
switch (status) {
@@ -1220,11 +1206,12 @@ int CJabberProto::SetAwayMsg(int status, const wchar_t *msg)
return 1;
}
- if ((*szMsg == nullptr && msg == nullptr) || (*szMsg != nullptr && msg != nullptr && !mir_wstrcmp(*szMsg, msg)))
+ T2Utf szNewMsg(msg);
+ if ((*szMsg == nullptr && msg == nullptr) || (*szMsg != nullptr && msg != nullptr && !mir_strcmp(*szMsg, szNewMsg)))
return 0; // Message is the same, no update needed
// Update with the new mode message
- replaceStrW(*szMsg, msg);
+ replaceStr(*szMsg, szNewMsg);
// Send a presence update if needed
lck.unlock();
@@ -1240,7 +1227,7 @@ int CJabberProto::UserIsTyping(MCONTACT hContact, int type)
{
if (!m_bJabberOnline) return 0;
- wchar_t szClientJid[JABBER_MAX_JID_LEN];
+ char szClientJid[JABBER_MAX_JID_LEN];
if (!GetClientJID(hContact, szClientJid, _countof(szClientJid)))
return 0;
@@ -1252,32 +1239,32 @@ int CJabberProto::UserIsTyping(MCONTACT hContact, int type)
if (jcb & JABBER_RESOURCE_CAPS_ERROR)
jcb = JABBER_RESOURCE_CAPS_NONE;
- XmlNode m(L"message"); XmlAddAttr(m, L"to", szClientJid);
+ XmlNode m("message"); XmlAddAttr(m, "to", szClientJid);
if (jcb & JABBER_CAPS_CHATSTATES) {
- m << XATTR(L"type", L"chat") << XATTRID(SerialNext());
+ m << XATTR("type", "chat") << XATTRID(SerialNext());
switch (type) {
case PROTOTYPE_SELFTYPING_OFF:
- m << XCHILDNS(L"paused", JABBER_FEAT_CHATSTATES);
+ m << XCHILDNS("paused", JABBER_FEAT_CHATSTATES);
m_ThreadInfo->send(m);
break;
case PROTOTYPE_SELFTYPING_ON:
- m << XCHILDNS(L"composing", JABBER_FEAT_CHATSTATES);
+ m << XCHILDNS("composing", JABBER_FEAT_CHATSTATES);
m_ThreadInfo->send(m);
break;
}
}
else if (jcb & JABBER_CAPS_MESSAGE_EVENTS) {
- HXML x = m << XCHILDNS(L"x", JABBER_FEAT_MESSAGE_EVENTS);
+ TiXmlElement *x = m << XCHILDNS("x", JABBER_FEAT_MESSAGE_EVENTS);
if (item->messageEventIdStr != nullptr)
- x << XCHILD(L"id", item->messageEventIdStr);
+ x << XCHILD("id", item->messageEventIdStr);
switch (type) {
case PROTOTYPE_SELFTYPING_OFF:
m_ThreadInfo->send(m);
break;
case PROTOTYPE_SELFTYPING_ON:
- x << XCHILD(L"composing");
+ x << XCHILD("composing");
m_ThreadInfo->send(m);
break;
}
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index 10f15af6f0..9860c6e580 100755
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -45,7 +45,7 @@ class CJabberMucJidListDlg;
enum TJabberGcLogInfoType { INFO_BAN, INFO_STATUS, INFO_CONFIG, INFO_AFFILIATION, INFO_ROLE };
-typedef UNIQUE_MAP<wchar_t,TCharKeyCmp> U_TCHAR_MAP;
+typedef UNIQUE_MAP<wchar_t, TCharKeyCmp> U_TCHAR_MAP;
#define JABBER_DEFAULT_RECENT_COUNT 10
@@ -65,7 +65,7 @@ struct TFilterInfo
volatile Type type;
mir_cs csPatternLock;
- wchar_t pattern[256];
+ wchar_t pattern[256];
};
struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
@@ -202,12 +202,12 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
HANDLE m_hThreadHandle;
- wchar_t *m_szJabberJID;
+ char *m_szJabberJID;
int m_nJabberSearchID;
time_t m_tmJabberLoggedInTime;
time_t m_tmJabberIdleStartTime;
UINT m_nJabberCodePage;
- wchar_t *m_tszSelectedLang;
+ char *m_tszSelectedLang;
mir_cs m_csModeMsgMutex;
JABBER_MODEMSGS m_modeMsgs;
@@ -235,7 +235,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
HANDLE m_hEventXStatusChanged;
// Transports list
- LIST<wchar_t> m_lstTransports;
+ LIST<char> m_lstTransports;
CJabberIqManager m_iqManager;
CJabberMessageManager m_messageManager;
@@ -304,34 +304,34 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
int __cdecl ContactMenuRunCommands(WPARAM wParam, LPARAM lParam);
HWND GetWindowFromIq(CJabberIqInfo *pInfo);
- BOOL HandleAdhocCommandRequest(HXML iqNode, CJabberIqInfo *pInfo);
+ BOOL HandleAdhocCommandRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
BOOL IsRcRequestAllowedByACL(CJabberIqInfo *pInfo);
- int AdhocSetStatusHandler(HXML iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession* pSession);
- int AdhocOptionsHandler(HXML iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession* pSession);
- int AdhocForwardHandler(HXML iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession* pSession);
- int AdhocLockWSHandler(HXML iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession* pSession);
- int AdhocQuitMirandaHandler(HXML iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession* pSession);
- int AdhocLeaveGroupchatsHandler(HXML iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession* pSession);
+ int AdhocSetStatusHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession);
+ int AdhocOptionsHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession);
+ int AdhocForwardHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession);
+ int AdhocLockWSHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession);
+ int AdhocQuitMirandaHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession);
+ int AdhocLeaveGroupchatsHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession);
- void OnIqResult_ListOfCommands(HXML iqNode, CJabberIqInfo*);
- void OnIqResult_CommandExecution(HXML iqNode, CJabberIqInfo*);
- void AdHoc_RequestListOfCommands(wchar_t * szResponder, HWND hwndDlg);
- int AdHoc_ExecuteCommand(HWND hwndDlg, wchar_t * jid, struct JabberAdHocData* dat);
- int AdHoc_SubmitCommandForm(HWND hwndDlg, JabberAdHocData * dat, wchar_t* action);
- int AdHoc_AddCommandRadio(HWND hFrame, wchar_t * labelStr, int id, int ypos, int value);
- int AdHoc_OnJAHMCommandListResult(HWND hwndDlg, HXML iqNode, JabberAdHocData* dat);
- int AdHoc_OnJAHMProcessResult(HWND hwndDlg, HXML workNode, JabberAdHocData* dat);
+ void OnIqResult_ListOfCommands(const TiXmlElement *iqNode, CJabberIqInfo*);
+ void OnIqResult_CommandExecution(const TiXmlElement *iqNode, CJabberIqInfo*);
+ void AdHoc_RequestListOfCommands(char *szResponder, HWND hwndDlg);
+ int AdHoc_ExecuteCommand(HWND hwndDlg, char *jid, struct JabberAdHocData *dat);
+ int AdHoc_SubmitCommandForm(HWND hwndDlg, JabberAdHocData *dat, char *action);
+ int AdHoc_AddCommandRadio(HWND hFrame, const char *labelStr, int id, int ypos, int value);
+ int AdHoc_OnJAHMCommandListResult(HWND hwndDlg, TiXmlElement *iqNode, JabberAdHocData *dat);
+ int AdHoc_OnJAHMProcessResult(HWND hwndDlg, TiXmlElement *workNode, JabberAdHocData *dat);
- void ContactMenuAdhocCommands(struct CJabberAdhocStartupParams* param);
+ void ContactMenuAdhocCommands(struct CJabberAdhocStartupParams *param);
//---- jabber_archive.c --------------------------------------------------------------
void EnableArchive(bool bEnable);
void RetrieveMessageArchive(MCONTACT hContact, JABBER_LIST_ITEM *pItem);
- void OnIqResultGetCollection(HXML iqNode, CJabberIqInfo*);
- void OnIqResultGetCollectionList(HXML iqNode, CJabberIqInfo*);
+ void OnIqResultGetCollection(const TiXmlElement *iqNode, CJabberIqInfo*);
+ void OnIqResultGetCollectionList(const TiXmlElement *iqNode, CJabberIqInfo*);
//---- jabber_bookmarks.c ------------------------------------------------------------
@@ -344,7 +344,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void ProcessIncomingNote(CNoteItem *pNote, bool ok);
void ProcessOutgoingNote(CNoteItem *pNote, bool ok);
- bool OnIncomingNote(const wchar_t *szFrom, HXML hXml);
+ bool OnIncomingNote(const char *szFrom, const TiXmlElement *hXml);
INT_PTR __cdecl OnMenuSendNote(WPARAM, LPARAM);
INT_PTR __cdecl OnMenuHandleNotes(WPARAM, LPARAM);
@@ -355,58 +355,58 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void __cdecl ByteSendThread(JABBER_BYTE_TRANSFER *jbt);
void __cdecl ByteReceiveThread(JABBER_BYTE_TRANSFER *jbt);
- void IqResultProxyDiscovery(HXML iqNode, CJabberIqInfo *pInfo);
- void ByteInitiateResult(HXML iqNode, CJabberIqInfo *pInfo);
+ void IqResultProxyDiscovery(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void ByteInitiateResult(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
void ByteSendViaProxy(JABBER_BYTE_TRANSFER *jbt);
int ByteSendParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen);
- void IqResultStreamActivate(HXML iqNode, CJabberIqInfo *pInfo);
+ void IqResultStreamActivate(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
int ByteReceiveParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen);
int ByteSendProxyParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen);
//---- jabber_caps.cpp ---------------------------------------------------------------
void AddDefaultCaps();
- void RequestOldCapsInfo(pResourceStatus &r, const wchar_t *fullJid);
- void GetCachedCaps(const wchar_t *szNode, const wchar_t *szVer, class pResourceStatus &r);
+ void RequestOldCapsInfo(pResourceStatus &r, const char *fullJid);
+ void GetCachedCaps(const char *szNode, const char *szVer, class pResourceStatus &r);
- JabberCapsBits GetTotalJidCapabilities(const wchar_t *jid);
- JabberCapsBits GetResourceCapabilities(const wchar_t *jid);
- JabberCapsBits GetResourceCapabilities(const wchar_t *jid, pResourceStatus &r);
+ JabberCapsBits GetTotalJidCapabilities(const char *jid);
+ JabberCapsBits GetResourceCapabilities(const char *jid);
+ JabberCapsBits GetResourceCapabilities(const char *jid, pResourceStatus &r);
//---- jabber_captcha.cpp ------------------------------------------------------------
- void sendCaptchaResult(wchar_t* buf, ThreadData *info, const wchar_t *from, const wchar_t *challenge, const wchar_t *fromjid, const wchar_t *sid);
- void sendCaptchaError(ThreadData *info, const wchar_t *from, const wchar_t *to, const wchar_t *challenge);
+ void sendCaptchaResult(char* buf, ThreadData *info, const char *from, const char *challenge, const char *fromjid, const char *sid);
+ void sendCaptchaError(ThreadData *info, const char *from, const char *to, const char *challenge);
//---- jabber_chat.cpp ---------------------------------------------------------------
int GcInit(JABBER_LIST_ITEM *item);
- void GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const wchar_t *resource, const wchar_t *nick, const wchar_t *jid, int action, HXML reason, int nStatusCode = -1);
+ void GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const char *resource, const char *nick, const char *jid, int action, const TiXmlElement *reason, int nStatusCode = -1);
void GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus &user, TJabberGcLogInfoType type);
- void GcQuit(JABBER_LIST_ITEM* jid, int code, HXML reason);
+ void GcQuit(JABBER_LIST_ITEM* jid, int code, const TiXmlElement *reason);
- void AdminSet(const wchar_t *to, const wchar_t *ns, const wchar_t *szItem, const wchar_t *itemVal, const wchar_t *var, const wchar_t *varVal);
- void AdminGet(const wchar_t *to, const wchar_t *ns, const wchar_t *var, const wchar_t *varVal, JABBER_IQ_HANDLER foo);
- void AdminSetReason(const wchar_t *to, const wchar_t *ns, const wchar_t *szItem, const wchar_t *itemVal, const wchar_t *var, const wchar_t *varVal, const wchar_t *rsn);
- void AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const wchar_t* str);
- void AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const wchar_t* str, const wchar_t* rsn);
- void DeleteMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const wchar_t* jid);
+ void AdminSet(const char *to, const char *ns, const char *szItem, const char *itemVal, const char *var, const char *varVal);
+ void AdminGet(const char *to, const char *ns, const char *var, const char *varVal, JABBER_IQ_HANDLER foo);
+ void AdminSetReason(const char *to, const char *ns, const char *szItem, const char *itemVal, const char *var, const char *varVal, const char *rsn);
+ void AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const char *str);
+ void AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const char *str, const char *reason);
+ void DeleteMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const char* jid);
//---- jabber_omemo.cpp --------------------------------------------------------------
- bool OmemoHandleMessage(HXML node, wchar_t *jid, time_t msgTime);
+ bool OmemoHandleMessage(const TiXmlElement *node, const char *jid, time_t msgTime);
void OmemoPutMessageToOutgoingQueue(MCONTACT hContact, int, const char* pszSrc);
- void OmemoPutMessageToIncommingQueue(HXML node, const wchar_t *jid, time_t msgTime);
+ void OmemoPutMessageToIncommingQueue(const TiXmlElement *node, const char *jid, time_t msgTime);
void OmemoHandleMessageQueue();
- void OmemoHandleDeviceList(HXML node);
+ void OmemoHandleDeviceList(const TiXmlElement *node);
void OmemoInitDevice();
void OmemoAnnounceDevice();
void OmemoSendBundle();
void OmemoPublishNodes();
bool OmemoCheckSession(MCONTACT hContact);
- unsigned int OmemoEncryptMessage(XmlNode &msg, const wchar_t *msg_text, MCONTACT hContact);
+ unsigned int OmemoEncryptMessage(XmlNode &msg, const char *msg_text, MCONTACT hContact);
bool OmemoIsEnabled(MCONTACT hContact);
- void OmemoOnIqResultGetBundle(HXML iqNode, CJabberIqInfo *pInfo);
+ void OmemoOnIqResultGetBundle(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
omemo::omemo_impl m_omemo;
@@ -418,46 +418,46 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void ConsoleInit(void);
void ConsoleUninit(void);
- bool FilterXml(HXML node, DWORD flags);
- bool RecursiveCheckFilter(HXML node, DWORD flags);
+ bool FilterXml(const TiXmlElement *node, DWORD flags);
+ bool RecursiveCheckFilter(const TiXmlElement *node, DWORD flags);
//---- jabber_disco.cpp --------------------------------------------------------------
- void LaunchServiceDiscovery(wchar_t *jid);
+ void LaunchServiceDiscovery(char *jid);
INT_PTR __cdecl OnMenuHandleServiceDiscovery(WPARAM wParam, LPARAM lParam);
INT_PTR __cdecl OnMenuHandleServiceDiscoveryMyTransports(WPARAM wParam, LPARAM lParam);
INT_PTR __cdecl OnMenuHandleServiceDiscoveryTransports(WPARAM wParam, LPARAM lParam);
INT_PTR __cdecl OnMenuHandleServiceDiscoveryConferences(WPARAM wParam, LPARAM lParam);
- void OnIqResultServiceDiscoveryInfo(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultServiceDiscoveryItems(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultServiceDiscoveryRootInfo(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultServiceDiscoveryRootItems(HXML iqNode, CJabberIqInfo *pInfo);
- BOOL SendInfoRequest(CJabberSDNode *pNode, HXML parent);
- BOOL SendBothRequests(CJabberSDNode *pNode, HXML parent);
+ void OnIqResultServiceDiscoveryInfo(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultServiceDiscoveryItems(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultServiceDiscoveryRootInfo(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultServiceDiscoveryRootItems(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ BOOL SendInfoRequest(CJabberSDNode *pNode, TiXmlElement *parent);
+ BOOL SendBothRequests(CJabberSDNode *pNode, TiXmlElement *parent);
void PerformBrowse(HWND hwndDlg);
BOOL IsNodeRegistered(CJabberSDNode *pNode);
void ApplyNodeIcon(HTREELISTITEM hItem, CJabberSDNode *pNode);
BOOL SyncTree(HTREELISTITEM hIndex, CJabberSDNode *pNode);
void ServiceDiscoveryShowMenu(CJabberSDNode *node, HTREELISTITEM hItem, POINT pt);
- void OnIqResultCapsDiscoInfo(HXML iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultCapsDiscoInfo(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
- void RegisterAgent(HWND hwndDlg, wchar_t* jid);
+ void RegisterAgent(HWND hwndDlg, char* jid);
//---- jabber_file.cpp ---------------------------------------------------------------
int FileReceiveParse(filetransfer *ft, char* buffer, int datalen);
int FileSendParse(HNETLIBCONN s, filetransfer *ft, char* buffer, int datalen);
- void GroupchatJoinRoomByJid(HWND hwndParent, wchar_t *jid);
+ void GroupchatJoinRoomByJid(HWND hwndParent, char *jid);
- void RenameParticipantNick(JABBER_LIST_ITEM *item, const wchar_t *oldNick, HXML itemNode);
- void AcceptGroupchatInvite(const wchar_t *roomJid, const wchar_t *reason, const wchar_t *password);
+ void RenameParticipantNick(JABBER_LIST_ITEM *item, const char *oldNick, const TiXmlElement *itemNode);
+ void AcceptGroupchatInvite(const char *roomJid, const char *reason, const char *password);
//---- jabber_form.c -----------------------------------------------------------------
- void FormCreateDialog(HXML xNode, wchar_t* defTitle, JABBER_FORM_SUBMIT_FUNC pfnSubmit, void *userdata);
+ void FormCreateDialog(const TiXmlElement *xNode, char* defTitle, JABBER_FORM_SUBMIT_FUNC pfnSubmit, void *userdata);
//---- jabber_ft.c -------------------------------------------------------------------
@@ -465,12 +465,12 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void __cdecl FileServerThread(filetransfer *ft);
void FtCancel(filetransfer *ft);
- void FtInitiate(wchar_t* jid, filetransfer *ft);
- void FtHandleSiRequest(HXML iqNode);
+ void FtInitiate(char* jid, filetransfer *ft);
+ void FtHandleSiRequest(const TiXmlElement *iqNode);
void FtAcceptSiRequest(filetransfer *ft);
void FtAcceptIbbRequest(filetransfer *ft);
- BOOL FtHandleBytestreamRequest(HXML iqNode, CJabberIqInfo *pInfo);
- BOOL FtHandleIbbRequest(HXML iqNode, BOOL bOpen);
+ BOOL FtHandleBytestreamRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ BOOL FtHandleIbbRequest(const TiXmlElement *iqNode, BOOL bOpen);
//---- jabber_groupchat.c ------------------------------------------------------------
@@ -479,11 +479,11 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
INT_PTR __cdecl OnJoinChat(WPARAM wParam, LPARAM lParam);
INT_PTR __cdecl OnLeaveChat(WPARAM wParam, LPARAM lParam);
- void GroupchatJoinRoom(const wchar_t *server, const wchar_t *room, const wchar_t *nick, const wchar_t *password, bool autojoin = false);
- void GroupchatProcessPresence(HXML node);
- void GroupchatProcessMessage(HXML node);
- void GroupchatProcessInvite(const wchar_t *roomJid, const wchar_t *from, const wchar_t *reason, const wchar_t *password);
- void OnIqResultDiscovery(HXML iqNode, CJabberIqInfo *pInfo);
+ void GroupchatJoinRoom(const char *server, const char *room, const char *nick, const char *password, bool autojoin = false);
+ void GroupchatProcessPresence(const TiXmlElement *node);
+ void GroupchatProcessMessage(const TiXmlElement *node);
+ void GroupchatProcessInvite(const char *roomJid, const char *from, const char *reason, const char *password);
+ void OnIqResultDiscovery(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
//---- jabber_icolib.cpp -------------------------------------------------------------
@@ -493,76 +493,76 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
HANDLE GetIconHandle(int iconId);
HICON LoadIconEx(const char* name, bool big = false);
int LoadAdvancedIcons(int iID);
- int GetTransportProtoID(wchar_t* TransportDomain);
+ int GetTransportProtoID(char* TransportDomain);
int GetTransportStatusIconIndex(int iID, int Status);
- BOOL DBCheckIsTransportedContact(const wchar_t *jid, MCONTACT hContact);
+ BOOL DBCheckIsTransportedContact(const char *jid, MCONTACT hContact);
void CheckAllContactsAreTransported(void);
INT_PTR __cdecl JGetAdvancedStatusIcon(WPARAM wParam, LPARAM lParam);
//---- jabber_iq.c -------------------------------------------------------------------
- __forceinline CJabberIqInfo* AddIQ(JABBER_IQ_HANDLER pHandler, int nIqType = JABBER_IQ_TYPE_GET, const wchar_t *szReceiver = nullptr, DWORD dwParamsToParse = 0, int nIqId = -1, void *pUserData = nullptr, int iPriority = JH_PRIORITY_DEFAULT)
+ __forceinline CJabberIqInfo* AddIQ(JABBER_IQ_HANDLER pHandler, int nIqType = JABBER_IQ_TYPE_GET, const char *szReceiver = nullptr, DWORD dwParamsToParse = 0, int nIqId = -1, void *pUserData = nullptr, int iPriority = JH_PRIORITY_DEFAULT)
{
return m_iqManager.AddHandler(pHandler, nIqType, szReceiver, dwParamsToParse, nIqId, pUserData, iPriority);
}
void __cdecl ExpirerThread(void*);
- void OnIqResultBind(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultDiscoBookmarks(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultEntityTime(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultExtSearch(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultGetAuth(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultGetVCardAvatar(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultGetClientAvatar(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultGetServerAvatar(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultGotAvatar(MCONTACT hContact, HXML n, const wchar_t *mimeType);
- void OnIqResultGetMuc(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultGetRegister(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultGetVcard(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultLastActivity(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultMucGetAdminList(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultMucGetBanList(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultMucGetMemberList(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultMucGetModeratorList(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultMucGetOwnerList(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultMucGetVoiceList(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultNestedRosterGroups(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultNotes(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultSession(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultSetAuth(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultSetBookmarks(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultSetPassword(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultSetRegister(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultSetSearch(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultSetVcard(HXML iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultBind(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultDiscoBookmarks(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultEntityTime(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultExtSearch(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultGetAuth(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultGetVCardAvatar(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultGetClientAvatar(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultGetServerAvatar(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultGotAvatar(MCONTACT hContact, const TiXmlElement *n, const char *mimeType);
+ void OnIqResultGetMuc(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultGetRegister(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultGetRoster(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultGetVcard(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultLastActivity(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultMucGetAdminList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultMucGetBanList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultMucGetMemberList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultMucGetModeratorList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultMucGetOwnerList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultMucGetVoiceList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultNestedRosterGroups(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultNotes(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultSession(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultSetAuth(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultSetBookmarks(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultSetPassword(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultSetRegister(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultSetSearch(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultSetVcard(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
void OnProcessLoginRq(ThreadData *info, DWORD rq);
void OnLoggedIn(void);
//---- jabber_iq_handlers.cpp -------------------------------------------------------
- BOOL OnIqRequestVersion(HXML node, CJabberIqInfo *pInfo);
- BOOL OnIqRequestLastActivity(HXML node, CJabberIqInfo *pInfo);
- BOOL OnIqRequestPing(HXML node, CJabberIqInfo *pInfo);
- BOOL OnIqRequestTime(HXML node, CJabberIqInfo *pInfo);
- BOOL OnIqProcessIqOldTime(HXML node, CJabberIqInfo *pInfo);
- BOOL OnIqRequestAvatar(HXML node, CJabberIqInfo *pInfo);
- BOOL OnSiRequest(HXML node, CJabberIqInfo *pInfo);
- BOOL OnRosterPushRequest(HXML node, CJabberIqInfo *pInfo);
- BOOL OnIqRequestOOB(HXML node, CJabberIqInfo *pInfo);
- BOOL OnIqHttpAuth(HXML node, CJabberIqInfo *pInfo);
+ BOOL OnIqRequestVersion(const TiXmlElement *node, CJabberIqInfo *pInfo);
+ BOOL OnIqRequestLastActivity(const TiXmlElement *node, CJabberIqInfo *pInfo);
+ BOOL OnIqRequestPing(const TiXmlElement *node, CJabberIqInfo *pInfo);
+ BOOL OnIqRequestTime(const TiXmlElement *node, CJabberIqInfo *pInfo);
+ BOOL OnIqProcessIqOldTime(const TiXmlElement *node, CJabberIqInfo *pInfo);
+ BOOL OnIqRequestAvatar(const TiXmlElement *node, CJabberIqInfo *pInfo);
+ BOOL OnSiRequest(const TiXmlElement *node, CJabberIqInfo *pInfo);
+ BOOL OnRosterPushRequest(const TiXmlElement *node, CJabberIqInfo *pInfo);
+ BOOL OnIqRequestOOB(const TiXmlElement *node, CJabberIqInfo *pInfo);
+ BOOL OnIqHttpAuth(const TiXmlElement *node, CJabberIqInfo *pInfo);
BOOL AddClistHttpAuthEvent(CJabberHttpAuthParams *pParams);
void __cdecl IbbSendThread(JABBER_IBB_TRANSFER *jibb);
void __cdecl IbbReceiveThread(JABBER_IBB_TRANSFER *jibb);
- void OnIbbInitiateResult(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIbbCloseResult(HXML iqNode, CJabberIqInfo *pInfo);
- BOOL OnFtHandleIbbIq(HXML iqNode, CJabberIqInfo *pInfo);
- BOOL OnIbbRecvdData(const wchar_t *data, const wchar_t *sid, const wchar_t *seq);
+ void OnIbbInitiateResult(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIbbCloseResult(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ BOOL OnFtHandleIbbIq(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ BOOL OnIbbRecvdData(const char *data, const char *sid, const char *seq);
- void OnFtSiResult(HXML iqNode, CJabberIqInfo *pInfo);
+ void OnFtSiResult(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
BOOL FtIbbSend(int blocksize, filetransfer *ft);
BOOL FtSend(HNETLIBCONN hConn, filetransfer *ft);
void FtSendFinal(BOOL success, filetransfer *ft);
@@ -579,39 +579,39 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
CJabberMucJidListDlg *m_pDlgMucBanList, *m_pDlgMucAdminList, *m_pDlgMucOwnerList;
CJabberMucJidListDlg *& GetMucDlg(JABBER_MUC_JIDLIST_TYPE);
- void SetMucConfig(HXML node, void *from);
+ void SetMucConfig(TiXmlElement *node, void *from);
void MucShutdown(void);
- void OnIqResultMucGetJidList(HXML iqNode, JABBER_MUC_JIDLIST_TYPE listType);
+ void OnIqResultMucGetJidList(const TiXmlElement *iqNode, JABBER_MUC_JIDLIST_TYPE listType);
//---- jabber_message_handlers.cpp ---------------------------------------------------
- BOOL OnMessageError(HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo);
- BOOL OnMessageIbb(HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo);
- BOOL OnMessagePubsubEvent(HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo);
- BOOL OnMessageGroupchat(HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo);
+ BOOL OnMessageError(const TiXmlElement *node, ThreadData *pThreadData, CJabberMessageInfo* pInfo);
+ BOOL OnMessageIbb(const TiXmlElement *node, ThreadData *pThreadData, CJabberMessageInfo* pInfo);
+ BOOL OnMessagePubsubEvent(const TiXmlElement *node, ThreadData *pThreadData, CJabberMessageInfo* pInfo);
+ BOOL OnMessageGroupchat(const TiXmlElement *node, ThreadData *pThreadData, CJabberMessageInfo* pInfo);
//---- jabber_list.cpp ---------------------------------------------------------------
- JABBER_LIST_ITEM* ListAdd(JABBER_LIST list, const wchar_t *jid, MCONTACT hContact = 0);
- JABBER_LIST_ITEM* ListGetItemPtr(JABBER_LIST list, const wchar_t *jid);
+ JABBER_LIST_ITEM* ListAdd(JABBER_LIST list, const char *jid, MCONTACT hContact = 0);
+ JABBER_LIST_ITEM* ListGetItemPtr(JABBER_LIST list, const char *jid);
JABBER_LIST_ITEM* ListGetItemPtrFromIndex(int index);
void ListInit(void);
void ListWipe(void);
- void ListRemove(JABBER_LIST list, const wchar_t *jid);
+ void ListRemove(JABBER_LIST list, const char *jid);
void ListRemoveList(JABBER_LIST list);
void ListRemoveByIndex(int index);
int ListFindNext(JABBER_LIST list, int fromOffset);
- pResourceStatus ListFindResource(JABBER_LIST list, const wchar_t *jid);
+ pResourceStatus ListFindResource(JABBER_LIST list, const char *jid);
- bool ListAddResource(JABBER_LIST list, const wchar_t *jid, int status, const wchar_t *statusMessage, char priority = 0, const wchar_t *nick = nullptr);
- void ListRemoveResource(JABBER_LIST list, const wchar_t *jid);
- wchar_t* ListGetBestClientResourceNamePtr(const wchar_t *jid);
+ bool ListAddResource(JABBER_LIST list, const char *jid, int status, const char *statusMessage, char priority = 0, const char *nick = nullptr);
+ void ListRemoveResource(JABBER_LIST list, const char *jid);
+ char* ListGetBestClientResourceNamePtr(const char *jid);
- void OnIqResultServerDiscoInfo(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultGetVcardPhoto(HXML n, MCONTACT hContact, bool &hasPhoto);
+ void OnIqResultServerDiscoInfo(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultGetVcardPhoto(const TiXmlElement *n, MCONTACT hContact, bool &hasPhoto);
void SetBookmarkRequest(XmlNodeIq &iqId);
//---- jabber_menu.cpp ---------------------------------------------------------------
@@ -646,22 +646,22 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
INT_PTR __cdecl OnGetEventTextChatStates(WPARAM wParam, LPARAM lParam);
INT_PTR __cdecl OnGetEventTextPresence(WPARAM wParam, LPARAM lParam);
- void AddContactToRoster(const wchar_t *jid, const wchar_t *nick, const wchar_t *grpName);
- void DBAddAuthRequest(const wchar_t *jid, const wchar_t *nick);
+ void AddContactToRoster(const char *jid, const char *nick, const char *grpName);
+ void DBAddAuthRequest(const char *jid, const char *nick);
BOOL AddDbPresenceEvent(MCONTACT hContact, BYTE btEventType);
- MCONTACT DBCreateContact(const wchar_t *jid, const wchar_t *nick, bool temporary, bool stripResource);
- void GetAvatarFileName(MCONTACT hContact, wchar_t* pszDest, size_t cbLen);
- void ResolveTransportNicks(const wchar_t *jid);
+ MCONTACT DBCreateContact(const char *jid, const char *nick, bool temporary, bool stripResource);
+ void GetAvatarFileName(MCONTACT hContact, wchar_t *pszDest, size_t cbLen);
+ void ResolveTransportNicks(const char *jid);
void SetServerStatus(int iNewStatus);
- void FormatMirVer(const pResourceStatus &resource, CMStringW&);
+ void FormatMirVer(const pResourceStatus &resource, CMStringA &res);
void UpdateMirVer(JABBER_LIST_ITEM *item);
void UpdateMirVer(MCONTACT hContact, const pResourceStatus&);
void UpdateSubscriptionInfo(MCONTACT hContact, JABBER_LIST_ITEM *item);
void SetContactOfflineStatus(MCONTACT hContact);
void InitPopups(void);
void MsgPopup(MCONTACT hContact, const wchar_t *szMsg, const wchar_t *szTitle);
- CMStringW ExtractImage(HXML node);
- const wchar_t* GetSoftName(const wchar_t *wszName);
+ CMStringA ExtractImage(const TiXmlElement *node);
+ const char* GetSoftName(const char *wszName);
//---- jabber_opt.cpp ----------------------------------------------------------------
INT_PTR __cdecl OnMenuHandleRosterControl(WPARAM wParam, LPARAM lParam);
@@ -669,7 +669,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void _RosterExportToFile(HWND hwndDlg);
void _RosterImportFromFile(HWND hwndDlg);
void _RosterSendRequest(HWND hwndDlg, BYTE rrAction);
- void _RosterHandleGetRequest(HXML node, CJabberIqInfo*);
+ void _RosterHandleGetRequest(const TiXmlElement *node, CJabberIqInfo*);
//---- jabber_password.cpp --------------------------------------------------------------
@@ -686,12 +686,12 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void QueryPrivacyLists(ThreadData *pThreadInfo = nullptr);
- BOOL OnIqRequestPrivacyLists(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultPrivacyList(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultPrivacyLists(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultPrivacyListActive(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultPrivacyListDefault(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultPrivacyListModify(HXML iqNode, CJabberIqInfo *pInfo);
+ BOOL OnIqRequestPrivacyLists(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultPrivacyList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultPrivacyLists(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultPrivacyListActive(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultPrivacyListDefault(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultPrivacyListModify(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
//---- jabber_proto.cpp --------------------------------------------------------------
@@ -699,7 +699,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void __cdecl GetAwayMsgThread(void* hContact);
void __cdecl SendMessageAckThread(void* hContact);
- MCONTACT AddToListByJID(const wchar_t *newJid, DWORD flags);
+ MCONTACT AddToListByJID(const char *newJid, DWORD flags);
void InfoFrame_OnSetup(CJabberInfoFrame_Event *evt);
void InfoFrame_OnTransport(CJabberInfoFrame_Event *evt);
@@ -710,12 +710,12 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
//---- jabber_search.cpp -------------------------------------------------------------
- void SearchReturnResults(HANDLE id, void* pvUsersInfo, U_TCHAR_MAP* pmAllFields);
- void OnIqResultAdvancedSearch(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultGetSearchFields(HXML iqNode, CJabberIqInfo *pInfo);
+ void SearchReturnResults(HANDLE id, void* pvUsersInfo, U_TCHAR_MAP *pmAllFields);
+ void OnIqResultAdvancedSearch(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultGetSearchFields(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
int SearchRenewFields(HWND hwndDlg, JabberSearchData * dat);
- void SearchDeleteFromRecent(const wchar_t *szAddr, bool deleteLastFromDB);
- void SearchAddToRecent(const wchar_t *szAddr, HWND hwndDialog = nullptr);
+ void SearchDeleteFromRecent(const char *szAddr, bool deleteLastFromDB);
+ void SearchAddToRecent(const char *szAddr, HWND hwndDialog = nullptr);
//---- jabber_std.cpp ----------------------------------------------
void JLoginFailed(int errorCode);
@@ -737,11 +737,11 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
INT_PTR __cdecl OnHttpAuthRequest(WPARAM wParam, LPARAM lParam);
INT_PTR __cdecl JabberGetApi(WPARAM wParam, LPARAM lParam);
- void ExternalTempIqHandler(HXML node, CJabberIqInfo *pInfo);
- BOOL ExternalIqHandler(HXML node, CJabberIqInfo *pInfo);
- BOOL ExternalMessageHandler(HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo);
- BOOL ExternalPresenceHandler(HXML node, ThreadData *pThreadData, CJabberPresenceInfo* pInfo);
- BOOL ExternalSendHandler(HXML node, ThreadData *pThreadData, CJabberSendInfo* pInfo);
+ void ExternalTempIqHandler(const TiXmlElement *node, CJabberIqInfo *pInfo);
+ BOOL ExternalIqHandler(const TiXmlElement *node, CJabberIqInfo *pInfo);
+ BOOL ExternalMessageHandler(const TiXmlElement *node, ThreadData *pThreadData, CJabberMessageInfo* pInfo);
+ BOOL ExternalPresenceHandler(const TiXmlElement *node, ThreadData *pThreadData, CJabberPresenceInfo* pInfo);
+ BOOL ExternalSendHandler(const TiXmlElement *node, ThreadData *pThreadData, CJabberSendInfo* pInfo);
BOOL SendHttpAuthReply(CJabberHttpAuthParams *pParams, BOOL bAuthorized);
@@ -759,73 +759,73 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
bool isKerberosAvailable;
bool isAuthAvailable;
bool isSessionAvailable;
- wchar_t *m_gssapiHostName;
+ char *m_gssapiHostName;
} AUTHMECHS;
AUTHMECHS m_AuthMechs;
void __cdecl ServerThread(JABBER_CONN_DATA *info);
- void OnProcessFailure(HXML node, ThreadData *info);
- void OnProcessFailed(HXML node, ThreadData *info);
- void OnProcessEnabled(HXML node, ThreadData *info);
- void OnProcessError(HXML node, ThreadData *info);
- void OnProcessSuccess(HXML node, ThreadData *info);
- void OnProcessChallenge(HXML node, ThreadData *info);
- void OnProcessProceed(HXML node, ThreadData *info);
- void OnProcessCompressed(HXML node, ThreadData *info);
- void OnProcessMessage(HXML node, ThreadData *info);
- void OnProcessPresence(HXML node, ThreadData *info);
- void OnProcessPresenceCapabilites(HXML node, pResourceStatus &resource);
- void OnProcessPubsubEvent(HXML node);
+ void OnProcessFailure(const TiXmlElement *node, ThreadData *info);
+ void OnProcessFailed(const TiXmlElement *node, ThreadData *info);
+ void OnProcessEnabled(const TiXmlElement *node, ThreadData *info);
+ void OnProcessError(const TiXmlElement *node, ThreadData *info);
+ void OnProcessSuccess(const TiXmlElement *node, ThreadData *info);
+ void OnProcessChallenge(const TiXmlElement *node, ThreadData *info);
+ void OnProcessProceed(const TiXmlElement *node, ThreadData *info);
+ void OnProcessCompressed(const TiXmlElement *node, ThreadData *info);
+ void OnProcessMessage(const TiXmlElement *node, ThreadData *info);
+ void OnProcessPresence(const TiXmlElement *node, ThreadData *info);
+ void OnProcessPresenceCapabilites(const TiXmlElement *node, pResourceStatus &resource);
+ void OnProcessPubsubEvent(const TiXmlElement *node);
//XEP-0198 specific types handlers
- void OnProcessSMa(HXML node, ThreadData *info);
- void OnProcessSMr(HXML node, ThreadData *info);
+ void OnProcessSMa(const TiXmlElement *node, ThreadData *info);
+ void OnProcessSMr(const TiXmlElement *node, ThreadData *info);
- void OnProcessStreamOpening(HXML node, ThreadData *info);
- void OnProcessProtocol(HXML node, ThreadData *info);
+ void OnProcessStreamOpening(const TiXmlElement *node, ThreadData *info);
+ void OnProcessProtocol(const TiXmlElement *node, ThreadData *info);
- void UpdateJidDbSettings(const wchar_t *jid);
- MCONTACT CreateTemporaryContact(const wchar_t *szJid, JABBER_LIST_ITEM* chatItem);
+ void UpdateJidDbSettings(const char *jid);
+ MCONTACT CreateTemporaryContact(const char *szJid, JABBER_LIST_ITEM* chatItem);
void PerformRegistration(ThreadData *info);
void PerformIqAuth(ThreadData *info);
void PerformAuthentication(ThreadData *info);
- void OnProcessFeatures(HXML node, ThreadData *info);
+ void OnProcessFeatures(const TiXmlElement *node, ThreadData *info);
void xmlStreamInitialize(char *which);
void xmlStreamInitializeNow(ThreadData *info);
- BOOL OnProcessJingle(HXML node);
- void OnProcessIq(HXML node);
- void SetRegConfig(HXML node, void *from);
- void OnProcessRegIq(HXML node, ThreadData *info);
- void OnPingReply(HXML node, CJabberIqInfo *pInfo);
+ BOOL OnProcessJingle(const TiXmlElement *node);
+ void OnProcessIq(const TiXmlElement *node);
+ void SetRegConfig(TiXmlElement *node, void *from);
+ void OnProcessRegIq(const TiXmlElement *node, ThreadData *info);
+ void OnPingReply(const TiXmlElement *node, CJabberIqInfo *pInfo);
- bool ProcessCaptcha(HXML node, HXML parentNode, ThreadData *info);
+ bool ProcessCaptcha(const TiXmlElement *node, const TiXmlElement *parentNode, ThreadData *info);
void EnableCarbons(bool bEnable);
//---- jabber_util.c -----------------------------------------------------------------
- pResourceStatus ResourceInfoFromJID(const wchar_t *jid);
+ pResourceStatus ResourceInfoFromJID(const char *jid);
- MCONTACT HContactFromJID(const wchar_t *jid, bool bStripResource = true);
- MCONTACT ChatRoomHContactFromJID(const wchar_t *jid);
+ MCONTACT HContactFromJID(const char *jid, bool bStripResource = true);
+ MCONTACT ChatRoomHContactFromJID(const char *jid);
void SendVisibleInvisiblePresence(bool invisible);
- void SendPresenceTo(int status, const wchar_t* to, HXML extra, const wchar_t *msg = nullptr);
+ void SendPresenceTo(int status, const char* to, TiXmlElement *extra, const char *msg = nullptr);
void SendPresence(int m_iStatus, bool bSendToAll);
void RebuildInfoFrame(void);
void InitInfoFrame(void);
// returns buf or nullptr on error
- wchar_t* GetClientJID(MCONTACT hContact, wchar_t *dest, size_t destLen);
- wchar_t* GetClientJID(const wchar_t *jid, wchar_t *dest, size_t destLen);
+ char* GetClientJID(MCONTACT hContact, char *dest, size_t destLen);
+ char* GetClientJID(const char *jid, char *dest, size_t destLen);
void ComboLoadRecentStrings(HWND hwndDlg, UINT idcCombo, char *param, int recentCount=JABBER_DEFAULT_RECENT_COUNT);
void ComboAddRecentString(HWND hwndDlg, UINT idcCombo, char *param, const wchar_t *string, int recentCount=JABBER_DEFAULT_RECENT_COUNT);
BOOL EnterString(CMStringW &result, const wchar_t *caption, int type, char *windowName=nullptr, int recentCount=JABBER_DEFAULT_RECENT_COUNT, int timeout=0);
- bool IsMyOwnJID(const wchar_t *szJID);
+ bool IsMyOwnJID(const char *szJID);
void __cdecl LoadHttpAvatars(void* param);
@@ -836,8 +836,8 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
wchar_t m_szPhotoFileName[MAX_PATH];
void OnUserInfoInit_VCard(WPARAM, LPARAM);
- int SendGetVcard(const wchar_t *jid);
- void AppendVcardFromDB(HXML n, char* tag, char* key);
+ int SendGetVcard(const char *jid);
+ void AppendVcardFromDB(TiXmlElement *n, char* tag, char* key);
void SetServerVcard(BOOL bPhotoChanged, wchar_t* szPhotoFileName);
void SaveVcardToDB(HWND hwndPage, int iPage);
@@ -852,12 +852,12 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
//---- jabber_xml.c ------------------------------------------------------------------
int OnXmlParse(char* buffer);
- void OnConsoleProcessXml(HXML node, DWORD flags);
+ void OnConsoleProcessXml(const TiXmlElement *node, DWORD flags);
//---- jabber_xmlns.c ----------------------------------------------------------------
- BOOL OnHandleDiscoInfoRequest(HXML iqNode, CJabberIqInfo *pInfo);
- BOOL OnHandleDiscoItemsRequest(HXML iqNode, CJabberIqInfo *pInfo);
+ BOOL OnHandleDiscoInfoRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ BOOL OnHandleDiscoItemsRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
//---- jabber_xstatus.c --------------------------------------------------------------
@@ -872,9 +872,9 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void ResetAdvStatus(MCONTACT hContact, const char *pszSlot);
void WriteAdvStatus(MCONTACT hContact, const char *pszSlot, const wchar_t *pszMode, const char *pszIcon, const wchar_t *pszTitle, const wchar_t *pszText);
char* ReadAdvStatusA(MCONTACT hContact, const char *pszSlot, const char *pszValue);
- wchar_t* ReadAdvStatusT(MCONTACT hContact, const char *pszSlot, const char *pszValue);
+ wchar_t *ReadAdvStatusT(MCONTACT hContact, const char *pszSlot, const char *pszValue);
- BOOL SendPepTune(wchar_t* szArtist, wchar_t* szLength, wchar_t* szSource, wchar_t* szTitle, wchar_t* szTrack, wchar_t* szUri);
+ BOOL SendPepTune(wchar_t *szArtist, wchar_t *szLength, wchar_t *szSource, wchar_t *szTitle, wchar_t *szTrack, wchar_t *szUri);
void XStatusInit(void);
@@ -901,36 +901,34 @@ private:
int m_nMenuResourceItems;
HGENMENU *m_phMenuResourceItems;
+ JabberFeatCapPairDynamic* FindFeature(const char *szFeature);
+
public:
- DWORD STDMETHODCALLTYPE GetFlags() const; // Set of JIF_* flags.
- int STDMETHODCALLTYPE GetVersion() const; // Returns version of IJabberInterface.
- DWORD STDMETHODCALLTYPE GetJabberVersion() const; // Returns Jabber plugin version.
-
- MCONTACT STDMETHODCALLTYPE ContactFromJID(const wchar_t *jid); // Returns contact handle for given JID.
- LPTSTR STDMETHODCALLTYPE ContactToJID(MCONTACT hContact); // Returns JID of hContact. You must free the result using mir_free().
- LPTSTR STDMETHODCALLTYPE GetBestResourceName(const wchar_t *jid); // Returns best resource name for given JID. You must free the result using mir_free().
- LPTSTR STDMETHODCALLTYPE GetResourceList(const wchar_t *jid); // Returns all resource names for a given JID in format "resource1\0resource2\0resource3\0\0" (all resources are separated by \0 character and the whole string is terminated with two \0 characters). You must free the string using mir_free().
- char* STDMETHODCALLTYPE GetModuleName() const; // Returns Jabber module name.
-
- int STDMETHODCALLTYPE SerialNext(); // Returns id that can be used for next message sent through SendXmlNode().
- int STDMETHODCALLTYPE SendXmlNode(HXML node); // Sends XML node.
-
- HJHANDLER STDMETHODCALLTYPE AddPresenceHandler(JABBER_HANDLER_FUNC Func, void *pUserData, int iPriority);
- HJHANDLER STDMETHODCALLTYPE AddMessageHandler(JABBER_HANDLER_FUNC Func, int iMsgTypes, const wchar_t *szXmlns, const wchar_t *szTag, void *pUserData, int iPriority);
- HJHANDLER STDMETHODCALLTYPE AddIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, const wchar_t *szXmlns, const wchar_t *szTag, void *pUserData, int iPriority);
- HJHANDLER STDMETHODCALLTYPE AddTemporaryIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, int iIqId, void *pUserData, DWORD dwTimeout, int iPriority);
- HJHANDLER STDMETHODCALLTYPE AddSendHandler(JABBER_HANDLER_FUNC Func, void *pUserData, int iPriority);
- int STDMETHODCALLTYPE RemoveHandler(HJHANDLER hHandler);
-
- int STDMETHODCALLTYPE RegisterFeature(const wchar_t *szFeature, const wchar_t *szDescription);
- int STDMETHODCALLTYPE AddFeatures(const wchar_t *szFeatures); // Adds features to the list of features returned by the client.
- int STDMETHODCALLTYPE RemoveFeatures(const wchar_t *szFeatures); // Removes features from the list of features returned by the client.
- LPTSTR STDMETHODCALLTYPE GetResourceFeatures(const wchar_t *jid); // Returns all features supported by JID in format "feature1\0feature2\0...\0featureN\0\0". You must free returned string using mir_free().
+ DWORD STDMETHODCALLTYPE GetFlags() const override; // Set of JIF_* flags.
+ int STDMETHODCALLTYPE GetVersion() const override; // Returns version of IJabberInterface.
+ DWORD STDMETHODCALLTYPE GetJabberVersion() const override; // Returns Jabber plugin version.
+
+ MCONTACT STDMETHODCALLTYPE ContactFromJID(const char *jid) override; // Returns contact handle for given JID.
+ char* STDMETHODCALLTYPE ContactToJID(MCONTACT hContact) override; // Returns JID of hContact. You must free the result using mir_free().
+ char* STDMETHODCALLTYPE GetBestResourceName(const char *jid) override; // Returns best resource name for given JID. You must free the result using mir_free().
+ char* STDMETHODCALLTYPE GetResourceList(const char *jid) override; // Returns all resource names for a given JID in format "resource1\0resource2\0resource3\0\0" (all resources are separated by \0 character and the whole string is terminated with two \0 characters). You must free the string using mir_free().
+ char* STDMETHODCALLTYPE GetModuleName() const override; // Returns Jabber module name.
+
+ int STDMETHODCALLTYPE SerialNext() override; // Returns id that can be used for next message sent through SendXmlNode().
+
+ HJHANDLER STDMETHODCALLTYPE AddPresenceHandler(JABBER_HANDLER_FUNC Func, void *pUserData, int iPriority) override;
+ HJHANDLER STDMETHODCALLTYPE AddMessageHandler(JABBER_HANDLER_FUNC Func, int iMsgTypes, const char *szXmlns, const char *szTag, void *pUserData, int iPriority) override;
+ HJHANDLER STDMETHODCALLTYPE AddIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, const char *szXmlns, const char *szTag, void *pUserData, int iPriority) override;
+ HJHANDLER STDMETHODCALLTYPE AddTemporaryIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, int iIqId, void *pUserData, DWORD dwTimeout, int iPriority) override;
+ HJHANDLER STDMETHODCALLTYPE AddSendHandler(JABBER_HANDLER_FUNC Func, void *pUserData, int iPriority) override;
+ int STDMETHODCALLTYPE RemoveHandler(HJHANDLER hHandler) override;
+
+ int STDMETHODCALLTYPE RegisterFeature(const char *szFeature, const char *szDescription) override;
+ int STDMETHODCALLTYPE AddFeatures(const char *szFeatures) override; // Adds features to the list of features returned by the client.
+ int STDMETHODCALLTYPE RemoveFeatures(const char *szFeatures) override; // Removes features from the list of features returned by the client.
+ char* STDMETHODCALLTYPE GetResourceFeatures(const char *jid) override; // Returns all features supported by JID in format "feature1\0feature2\0...\0featureN\0\0". You must free returned string using mir_free().
- HNETLIBUSER STDMETHODCALLTYPE GetHandle(); // Returns connection handle
-
-private:
- JabberFeatCapPairDynamic *FindFeature(const wchar_t *szFeature);
+ HNETLIBUSER STDMETHODCALLTYPE GetHandle() override; // Returns connection handle
};
#endif
diff --git a/protocols/JabberG/src/jabber_rc.cpp b/protocols/JabberG/src/jabber_rc.cpp
index 75a947a22c..26e3b801b4 100644
--- a/protocols/JabberG/src/jabber_rc.cpp
+++ b/protocols/JabberG/src/jabber_rc.cpp
@@ -36,7 +36,7 @@ CJabberAdhocSession::CJabberAdhocSession(CJabberProto* global)
m_bAutofreeUserData = FALSE;
m_dwStage = 0;
ppro = global;
- m_szSessionId.Format(L"%u%u", ppro->SerialNext(), GetTickCount());
+ m_szSessionId.Format("%u%u", ppro->SerialNext(), GetTickCount());
m_dwStartTime = GetTickCount();
}
@@ -48,7 +48,7 @@ BOOL CJabberProto::IsRcRequestAllowedByACL(CJabberIqInfo *pInfo)
return IsMyOwnJID(pInfo->GetFrom());
}
-BOOL CJabberProto::HandleAdhocCommandRequest(HXML iqNode, CJabberIqInfo *pInfo)
+BOOL CJabberProto::HandleAdhocCommandRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
if (!pInfo->GetChildNode())
return TRUE;
@@ -58,33 +58,33 @@ BOOL CJabberProto::HandleAdhocCommandRequest(HXML iqNode, CJabberIqInfo *pInfo)
return TRUE;
}
- const wchar_t *szNode = XmlGetAttrValue(pInfo->GetChildNode(), L"node");
+ const char *szNode = pInfo->GetChildNode()->Attribute("node");
if (!szNode)
return TRUE;
- m_adhocManager.HandleCommandRequest(iqNode, pInfo, (wchar_t*)szNode);
+ m_adhocManager.HandleCommandRequest(iqNode, pInfo, szNode);
return TRUE;
}
-BOOL CJabberAdhocManager::HandleItemsRequest(HXML, CJabberIqInfo *pInfo, const wchar_t *szNode)
+BOOL CJabberAdhocManager::HandleItemsRequest(const TiXmlElement*, CJabberIqInfo *pInfo, const char *szNode)
{
if (!szNode || !m_pProto->m_bEnableRemoteControl || !m_pProto->IsRcRequestAllowedByACL(pInfo))
return FALSE;
- if (!mir_wstrcmp(szNode, JABBER_FEAT_COMMANDS)) {
- XmlNodeIq iq(L"result", pInfo);
- HXML resultQuery = iq << XQUERY(JABBER_FEAT_DISCO_ITEMS) << XATTR(L"node", JABBER_FEAT_COMMANDS);
+ if (!mir_strcmp(szNode, JABBER_FEAT_COMMANDS)) {
+ XmlNodeIq iq("result", pInfo);
+ TiXmlElement *resultQuery = iq << XQUERY(JABBER_FEAT_DISCO_ITEMS) << XATTR("node", JABBER_FEAT_COMMANDS);
{
mir_cslock lck(m_cs);
CJabberAdhocNode* pNode = GetFirstNode();
while (pNode) {
- wchar_t *szJid = pNode->GetJid();
+ const char *szJid = pNode->GetJid();
if (!szJid)
szJid = m_pProto->m_ThreadInfo->fullJID;
- resultQuery << XCHILD(L"item") << XATTR(L"jid", szJid)
- << XATTR(L"node", pNode->GetNode()) << XATTR(L"name", pNode->GetName());
+ resultQuery << XCHILD("item") << XATTR("jid", szJid)
+ << XATTR("node", pNode->GetNode()) << XATTR("name", pNode->GetName());
pNode = pNode->GetNext();
}
@@ -96,22 +96,22 @@ BOOL CJabberAdhocManager::HandleItemsRequest(HXML, CJabberIqInfo *pInfo, const w
return FALSE;
}
-BOOL CJabberAdhocManager::HandleInfoRequest(HXML, CJabberIqInfo *pInfo, const wchar_t *szNode)
+BOOL CJabberAdhocManager::HandleInfoRequest(const TiXmlElement*, CJabberIqInfo *pInfo, const char *szNode)
{
if (!szNode || !m_pProto->m_bEnableRemoteControl || !m_pProto->IsRcRequestAllowedByACL(pInfo))
return FALSE;
// FIXME: same code twice
- if (!mir_wstrcmp(szNode, JABBER_FEAT_COMMANDS)) {
- XmlNodeIq iq(L"result", pInfo);
- HXML resultQuery = iq << XQUERY(JABBER_FEAT_DISCO_INFO) << XATTR(L"node", JABBER_FEAT_COMMANDS);
- resultQuery << XCHILD(L"identity") << XATTR(L"name", L"Ad-hoc commands")
- << XATTR(L"category", L"automation") << XATTR(L"type", L"command-node");
+ if (!mir_strcmp(szNode, JABBER_FEAT_COMMANDS)) {
+ XmlNodeIq iq("result", pInfo);
+ TiXmlElement *resultQuery = iq << XQUERY(JABBER_FEAT_DISCO_INFO) << XATTR("node", JABBER_FEAT_COMMANDS);
+ resultQuery << XCHILD("identity") << XATTR("name", "Ad-hoc commands")
+ << XATTR("category", "automation") << XATTR("type", "command-node");
- resultQuery << XCHILD(L"feature") << XATTR(L"var", JABBER_FEAT_COMMANDS);
- resultQuery << XCHILD(L"feature") << XATTR(L"var", JABBER_FEAT_DATA_FORMS);
- resultQuery << XCHILD(L"feature") << XATTR(L"var", JABBER_FEAT_DISCO_INFO);
- resultQuery << XCHILD(L"feature") << XATTR(L"var", JABBER_FEAT_DISCO_ITEMS);
+ resultQuery << XCHILD("feature") << XATTR("var", JABBER_FEAT_COMMANDS);
+ resultQuery << XCHILD("feature") << XATTR("var", JABBER_FEAT_DATA_FORMS);
+ resultQuery << XCHILD("feature") << XATTR("var", JABBER_FEAT_DISCO_INFO);
+ resultQuery << XCHILD("feature") << XATTR("var", JABBER_FEAT_DISCO_ITEMS);
m_pProto->m_ThreadInfo->send(iq);
return TRUE;
@@ -122,24 +122,24 @@ BOOL CJabberAdhocManager::HandleInfoRequest(HXML, CJabberIqInfo *pInfo, const wc
if (pNode == nullptr)
return FALSE;
- XmlNodeIq iq(L"result", pInfo);
- HXML resultQuery = iq << XQUERY(JABBER_FEAT_DISCO_INFO) << XATTR(L"node", JABBER_FEAT_DISCO_INFO);
- resultQuery << XCHILD(L"identity") << XATTR(L"name", pNode->GetName())
- << XATTR(L"category", L"automation") << XATTR(L"type", L"command-node");
+ XmlNodeIq iq("result", pInfo);
+ TiXmlElement *resultQuery = iq << XQUERY(JABBER_FEAT_DISCO_INFO) << XATTR("node", JABBER_FEAT_DISCO_INFO);
+ resultQuery << XCHILD("identity") << XATTR("name", pNode->GetName())
+ << XATTR("category", "automation") << XATTR("type", "command-node");
- resultQuery << XCHILD(L"feature") << XATTR(L"var", JABBER_FEAT_COMMANDS);
- resultQuery << XCHILD(L"feature") << XATTR(L"var", JABBER_FEAT_DATA_FORMS);
- resultQuery << XCHILD(L"feature") << XATTR(L"var", JABBER_FEAT_DISCO_INFO);
+ resultQuery << XCHILD("feature") << XATTR("var", JABBER_FEAT_COMMANDS);
+ resultQuery << XCHILD("feature") << XATTR("var", JABBER_FEAT_DATA_FORMS);
+ resultQuery << XCHILD("feature") << XATTR("var", JABBER_FEAT_DISCO_INFO);
lck.unlock();
m_pProto->m_ThreadInfo->send(iq);
return TRUE;
}
-BOOL CJabberAdhocManager::HandleCommandRequest(HXML iqNode, CJabberIqInfo *pInfo, const wchar_t *szNode)
+BOOL CJabberAdhocManager::HandleCommandRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, const char *szNode)
{
// ATTN: ACL and db settings checked in calling function
- HXML commandNode = pInfo->GetChildNode();
+ auto *commandNode = pInfo->GetChildNode();
mir_cslockfull lck(m_cs);
CJabberAdhocNode* pNode = FindNode(szNode);
@@ -147,25 +147,25 @@ BOOL CJabberAdhocManager::HandleCommandRequest(HXML iqNode, CJabberIqInfo *pInfo
lck.unlock();
m_pProto->m_ThreadInfo->send(
- XmlNodeIq(L"error", pInfo)
- << XCHILD(L"error") << XATTR(L"type", L"cancel")
- << XCHILDNS(L"item-not-found", L"urn:ietf:params:xml:ns:xmpp-stanzas"));
+ XmlNodeIq("error", pInfo)
+ << XCHILD("error") << XATTR("type", "cancel")
+ << XCHILDNS("item-not-found", "urn:ietf:params:xml:ns:xmpp-stanzas"));
return FALSE;
}
- const wchar_t *szSessionId = XmlGetAttrValue(commandNode, L"sessionid");
+ const char *szSessionId = commandNode->Attribute("sessionid");
- CJabberAdhocSession* pSession = nullptr;
+ CJabberAdhocSession *pSession = nullptr;
if (szSessionId) {
pSession = FindSession(szSessionId);
if (!pSession) {
lck.unlock();
- XmlNodeIq iq(L"error", pInfo);
- HXML errorNode = iq << XCHILD(L"error") << XATTR(L"type", L"modify");
- errorNode << XCHILDNS(L"bad-request", L"urn:ietf:params:xml:ns:xmpp-stanzas");
- errorNode << XCHILDNS(L"bad-sessionid", JABBER_FEAT_COMMANDS);
+ XmlNodeIq iq("error", pInfo);
+ TiXmlElement *errorNode = iq << XCHILD("error") << XATTR("type", "modify");
+ errorNode << XCHILDNS("bad-request", "urn:ietf:params:xml:ns:xmpp-stanzas");
+ errorNode << XCHILDNS("bad-sessionid", JABBER_FEAT_COMMANDS);
m_pProto->m_ThreadInfo->send(iq);
return FALSE;
}
@@ -177,9 +177,9 @@ BOOL CJabberAdhocManager::HandleCommandRequest(HXML iqNode, CJabberIqInfo *pInfo
lck.unlock();
m_pProto->m_ThreadInfo->send(
- XmlNodeIq(L"error", pInfo)
- << XCHILD(L"error") << XATTR(L"type", L"cancel")
- << XCHILDNS(L"forbidden", L"urn:ietf:params:xml:ns:xmpp-stanzas"));
+ XmlNodeIq("error", pInfo)
+ << XCHILD("error") << XATTR("type", "cancel")
+ << XCHILDNS("forbidden", "urn:ietf:params:xml:ns:xmpp-stanzas"));
return FALSE;
}
@@ -190,20 +190,20 @@ BOOL CJabberAdhocManager::HandleCommandRequest(HXML iqNode, CJabberIqInfo *pInfo
if (nResultCode == JABBER_ADHOC_HANDLER_STATUS_COMPLETED) {
m_pProto->m_ThreadInfo->send(
- XmlNodeIq(L"result", pInfo)
- << XCHILDNS(L"command", JABBER_FEAT_COMMANDS) << XATTR(L"node", szNode)
- << XATTR(L"sessionid", pSession->GetSessionId()) << XATTR(L"status", L"completed")
- << XCHILD(L"note", TranslateT("Command completed successfully")) << XATTR(L"type", L"info"));
+ XmlNodeIq("result", pInfo)
+ << XCHILDNS("command", JABBER_FEAT_COMMANDS) << XATTR("node", szNode)
+ << XATTR("sessionid", pSession->GetSessionId()) << XATTR("status", "completed")
+ << XCHILD("note", Translate("Command completed successfully")) << XATTR("type", "info"));
RemoveSession(pSession);
pSession = nullptr;
}
else if (nResultCode == JABBER_ADHOC_HANDLER_STATUS_CANCEL) {
m_pProto->m_ThreadInfo->send(
- XmlNodeIq(L"result", pInfo)
- << XCHILDNS(L"command", JABBER_FEAT_COMMANDS) << XATTR(L"node", szNode)
- << XATTR(L"sessionid", pSession->GetSessionId()) << XATTR(L"status", L"canceled")
- << XCHILD(L"note", TranslateT("Error occurred during processing command")) << XATTR(L"type", L"error"));
+ XmlNodeIq("result", pInfo)
+ << XCHILDNS("command", JABBER_FEAT_COMMANDS) << XATTR("node", szNode)
+ << XATTR("sessionid", pSession->GetSessionId()) << XATTR("status", "canceled")
+ << XCHILD("note", Translate("Error occurred during processing command")) << XATTR("type", "error"));
RemoveSession(pSession);
pSession = nullptr;
@@ -218,173 +218,173 @@ BOOL CJabberAdhocManager::HandleCommandRequest(HXML iqNode, CJabberIqInfo *pInfo
BOOL CJabberAdhocManager::FillDefaultNodes()
{
- AddNode(nullptr, JABBER_FEAT_RC_SET_STATUS, TranslateT("Set status"), &CJabberProto::AdhocSetStatusHandler);
- AddNode(nullptr, JABBER_FEAT_RC_SET_OPTIONS, TranslateT("Set options"), &CJabberProto::AdhocOptionsHandler);
- AddNode(nullptr, JABBER_FEAT_RC_FORWARD, TranslateT("Forward unread messages"), &CJabberProto::AdhocForwardHandler);
- AddNode(nullptr, JABBER_FEAT_RC_LEAVE_GROUPCHATS, TranslateT("Leave group chats"), &CJabberProto::AdhocLeaveGroupchatsHandler);
- AddNode(nullptr, JABBER_FEAT_RC_WS_LOCK, TranslateT("Lock workstation"), &CJabberProto::AdhocLockWSHandler);
- AddNode(nullptr, JABBER_FEAT_RC_QUIT_MIRANDA, TranslateT("Quit Miranda NG"), &CJabberProto::AdhocQuitMirandaHandler);
+ AddNode(nullptr, JABBER_FEAT_RC_SET_STATUS, Translate("Set status"), &CJabberProto::AdhocSetStatusHandler);
+ AddNode(nullptr, JABBER_FEAT_RC_SET_OPTIONS, Translate("Set options"), &CJabberProto::AdhocOptionsHandler);
+ AddNode(nullptr, JABBER_FEAT_RC_FORWARD, Translate("Forward unread messages"), &CJabberProto::AdhocForwardHandler);
+ AddNode(nullptr, JABBER_FEAT_RC_LEAVE_GROUPCHATS, Translate("Leave group chats"), &CJabberProto::AdhocLeaveGroupchatsHandler);
+ AddNode(nullptr, JABBER_FEAT_RC_WS_LOCK, Translate("Lock workstation"), &CJabberProto::AdhocLockWSHandler);
+ AddNode(nullptr, JABBER_FEAT_RC_QUIT_MIRANDA, Translate("Quit Miranda NG"), &CJabberProto::AdhocQuitMirandaHandler);
return TRUE;
}
-static char *StatusModeToDbSetting(int status,const char *suffix)
+static char *StatusModeToDbSetting(int status, const char *suffix)
{
char *prefix;
static char str[64];
- switch(status) {
- case ID_STATUS_AWAY: prefix="Away"; break;
- case ID_STATUS_NA: prefix="Na"; break;
- case ID_STATUS_DND: prefix="Dnd"; break;
- case ID_STATUS_OCCUPIED: prefix="Occupied"; break;
- case ID_STATUS_FREECHAT: prefix="FreeChat"; break;
- case ID_STATUS_ONLINE: prefix="On"; break;
- case ID_STATUS_OFFLINE: prefix="Off"; break;
- case ID_STATUS_INVISIBLE: prefix="Inv"; break;
- case ID_STATUS_ONTHEPHONE: prefix="Otp"; break;
- case ID_STATUS_OUTTOLUNCH: prefix="Otl"; break;
- case ID_STATUS_IDLE: prefix="Idl"; break;
- default: return nullptr;
+ switch (status) {
+ case ID_STATUS_AWAY: prefix = "Away"; break;
+ case ID_STATUS_NA: prefix = "Na"; break;
+ case ID_STATUS_DND: prefix = "Dnd"; break;
+ case ID_STATUS_OCCUPIED: prefix = "Occupied"; break;
+ case ID_STATUS_FREECHAT: prefix = "FreeChat"; break;
+ case ID_STATUS_ONLINE: prefix = "On"; break;
+ case ID_STATUS_OFFLINE: prefix = "Off"; break;
+ case ID_STATUS_INVISIBLE: prefix = "Inv"; break;
+ case ID_STATUS_ONTHEPHONE: prefix = "Otp"; break;
+ case ID_STATUS_OUTTOLUNCH: prefix = "Otl"; break;
+ case ID_STATUS_IDLE: prefix = "Idl"; break;
+ default: return nullptr;
}
- mir_strcpy(str,prefix); mir_strcat(str,suffix);
+ mir_strcpy(str, prefix); mir_strcat(str, suffix);
return str;
}
-int CJabberProto::AdhocSetStatusHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhocSession* pSession)
+int CJabberProto::AdhocSetStatusHandler(const TiXmlElement*, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession)
{
if (pSession->GetStage() == 0) {
// first form
pSession->SetStage(1);
- XmlNodeIq iq(L"result", pInfo);
- HXML xNode = iq
- << XCHILDNS(L"command", JABBER_FEAT_COMMANDS) << XATTR(L"node", JABBER_FEAT_RC_SET_STATUS)
- << XATTR(L"sessionid", pSession->GetSessionId()) << XATTR(L"status", L"executing")
- << XCHILDNS(L"x", JABBER_FEAT_DATA_FORMS) << XATTR(L"type", L"form");
+ XmlNodeIq iq("result", pInfo);
+ TiXmlElement *xNode = iq
+ << XCHILDNS("command", JABBER_FEAT_COMMANDS) << XATTR("node", JABBER_FEAT_RC_SET_STATUS)
+ << XATTR("sessionid", pSession->GetSessionId()) << XATTR("status", "executing")
+ << XCHILDNS("x", JABBER_FEAT_DATA_FORMS) << XATTR("type", "form");
- xNode << XCHILD(L"title", TranslateT("Change Status"));
- xNode << XCHILD(L"instructions", TranslateT("Choose the status and status message"));
+ xNode << XCHILD("title", Translate("Change Status"));
+ xNode << XCHILD("instructions", Translate("Choose the status and status message"));
- xNode << XCHILD(L"field") << XATTR(L"type", L"hidden") << XATTR(L"var", L"FORM_TYPE")
- << XATTR(L"value", JABBER_FEAT_RC);
+ xNode << XCHILD("field") << XATTR("type", "hidden") << XATTR("var", "FORM_TYPE")
+ << XATTR("value", JABBER_FEAT_RC);
- HXML fieldNode = xNode << XCHILD(L"field") << XATTR(L"label", TranslateT("Status"))
- << XATTR(L"type", L"list-single") << XATTR(L"var", L"status");
+ TiXmlElement *fieldNode = xNode << XCHILD("field") << XATTR("label", Translate("Status"))
+ << XATTR("type", "list-single") << XATTR("var", "status");
- fieldNode << XCHILD(L"required");
+ fieldNode << XCHILD("required");
int status = CallService(MS_CLIST_GETSTATUSMODE, 0, 0);
switch (status) {
case ID_STATUS_INVISIBLE:
- fieldNode << XCHILD(L"value", L"invisible");
+ fieldNode << XCHILD("value", "invisible");
break;
case ID_STATUS_AWAY:
case ID_STATUS_ONTHEPHONE:
case ID_STATUS_OUTTOLUNCH:
- fieldNode << XCHILD(L"value", L"away");
+ fieldNode << XCHILD("value", "away");
break;
case ID_STATUS_NA:
- fieldNode << XCHILD(L"value", L"xa");
+ fieldNode << XCHILD("value", "xa");
break;
case ID_STATUS_DND:
case ID_STATUS_OCCUPIED:
- fieldNode << XCHILD(L"value", L"dnd");
+ fieldNode << XCHILD("value", "dnd");
break;
case ID_STATUS_FREECHAT:
- fieldNode << XCHILD(L"value", L"chat");
+ fieldNode << XCHILD("value", "chat");
break;
case ID_STATUS_ONLINE:
default:
- fieldNode << XCHILD(L"value", L"online");
+ fieldNode << XCHILD("value", "online");
break;
}
- fieldNode << XCHILD(L"option") << XATTR(L"label", TranslateT("Free for chat")) << XCHILD(L"value", L"chat");
- fieldNode << XCHILD(L"option") << XATTR(L"label", TranslateT("Online")) << XCHILD(L"value", L"online");
- fieldNode << XCHILD(L"option") << XATTR(L"label", TranslateT("Away")) << XCHILD(L"value", L"away");
- fieldNode << XCHILD(L"option") << XATTR(L"label", TranslateT("Extended away (Not available)")) << XCHILD(L"value", L"xa");
- fieldNode << XCHILD(L"option") << XATTR(L"label", TranslateT("Do not disturb")) << XCHILD(L"value", L"dnd");
- fieldNode << XCHILD(L"option") << XATTR(L"label", TranslateT("Invisible")) << XCHILD(L"value", L"invisible");
- fieldNode << XCHILD(L"option") << XATTR(L"label", TranslateT("Offline")) << XCHILD(L"value", L"offline");
+ fieldNode << XCHILD("option") << XATTR("label", Translate("Free for chat")) << XCHILD("value", "chat");
+ fieldNode << XCHILD("option") << XATTR("label", Translate("Online")) << XCHILD("value", "online");
+ fieldNode << XCHILD("option") << XATTR("label", Translate("Away")) << XCHILD("value", "away");
+ fieldNode << XCHILD("option") << XATTR("label", Translate("Extended away (Not available)")) << XCHILD("value", "xa");
+ fieldNode << XCHILD("option") << XATTR("label", Translate("Do not disturb")) << XCHILD("value", "dnd");
+ fieldNode << XCHILD("option") << XATTR("label", Translate("Invisible")) << XCHILD("value", "invisible");
+ fieldNode << XCHILD("option") << XATTR("label", Translate("Offline")) << XCHILD("value", "offline");
// priority
- wchar_t szPriority[ 256 ];
- mir_snwprintf(szPriority, L"%d", (int)getDword("Priority", 5));
- xNode << XCHILD(L"field") << XATTR(L"label", TranslateT("Priority")) << XATTR(L"type", L"text-single")
- << XATTR(L"var", L"status-priority") << XCHILD(L"value", szPriority);
+ char szPriority[20];
+ itoa(getDword("Priority", 5), szPriority, 10);
+ xNode << XCHILD("field") << XATTR("label", Translate("Priority")) << XATTR("type", "text-single")
+ << XATTR("var", "status-priority") << XCHILD("value", szPriority);
// status message text
- xNode << XCHILD(L"field") << XATTR(L"label", TranslateT("Status message"))
- << XATTR(L"type", L"text-multi") << XATTR(L"var", L"status-message");
+ xNode << XCHILD("field") << XATTR("label", Translate("Status message"))
+ << XATTR("type", "text-multi") << XATTR("var", "status-message");
// global status
- fieldNode = xNode << XCHILD(L"field") << XATTR(L"label", TranslateT("Change global status"))
- << XATTR(L"type", L"boolean") << XATTR(L"var", L"status-global");
+ fieldNode = xNode << XCHILD("field") << XATTR("label", Translate("Change global status"))
+ << XATTR("type", "boolean") << XATTR("var", "status-global");
ptrW tszStatusMsg((wchar_t*)CallService(MS_AWAYMSG_GETSTATUSMSGW, status, 0));
if (tszStatusMsg)
- fieldNode << XCHILD(L"value", tszStatusMsg);
+ fieldNode << XCHILD("value", T2Utf(tszStatusMsg));
m_ThreadInfo->send(iq);
return JABBER_ADHOC_HANDLER_STATUS_EXECUTING;
}
-
+
if (pSession->GetStage() == 1) {
// result form here
- HXML commandNode = pInfo->GetChildNode();
- HXML xNode = XmlGetChildByTag(commandNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS);
+ auto *commandNode = pInfo->GetChildNode();
+ auto *xNode = XmlGetChildByTag(commandNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS);
if (!xNode)
return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
- HXML fieldNode = XmlGetChildByTag(xNode, "field", "var", L"status"), valueNode;
+ auto *fieldNode = XmlGetChildByTag(xNode, "field", "var", "status");
if (!fieldNode)
return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
- const wchar_t *ptszValue = XmlGetText( XmlGetChild(fieldNode , "value"));
- if (ptszValue == nullptr)
+ const char *pszValue = fieldNode->FirstChildElement("value")->GetText();
+ if (pszValue == nullptr)
return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
int status;
- if (!mir_wstrcmp(ptszValue, L"away")) status = ID_STATUS_AWAY;
- else if (!mir_wstrcmp(ptszValue, L"xa")) status = ID_STATUS_NA;
- else if (!mir_wstrcmp(ptszValue, L"dnd")) status = ID_STATUS_DND;
- else if (!mir_wstrcmp(ptszValue, L"chat")) status = ID_STATUS_FREECHAT;
- else if (!mir_wstrcmp(ptszValue, L"online")) status = ID_STATUS_ONLINE;
- else if (!mir_wstrcmp(ptszValue, L"invisible")) status = ID_STATUS_INVISIBLE;
- else if (!mir_wstrcmp(ptszValue, L"offline")) status = ID_STATUS_OFFLINE;
+ if (!mir_strcmp(pszValue, "away")) status = ID_STATUS_AWAY;
+ else if (!mir_strcmp(pszValue, "xa")) status = ID_STATUS_NA;
+ else if (!mir_strcmp(pszValue, "dnd")) status = ID_STATUS_DND;
+ else if (!mir_strcmp(pszValue, "chat")) status = ID_STATUS_FREECHAT;
+ else if (!mir_strcmp(pszValue, "online")) status = ID_STATUS_ONLINE;
+ else if (!mir_strcmp(pszValue, "invisible")) status = ID_STATUS_INVISIBLE;
+ else if (!mir_strcmp(pszValue, "offline")) status = ID_STATUS_OFFLINE;
else
return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
int priority = -9999;
- fieldNode = XmlGetChildByTag(xNode, "field", "var", L"status-priority");
- if (fieldNode && (valueNode = XmlGetChild(fieldNode , "value")))
- if (ptszValue = XmlGetText(valueNode))
- priority = _wtoi(ptszValue);
+ if (fieldNode = XmlGetChildByTag(xNode, "field", "var", "status-priority"))
+ if (auto *valueNode = fieldNode->FirstChildElement("value"))
+ if (pszValue = valueNode->GetText())
+ priority = atoi(pszValue);
if (priority >= -128 && priority <= 127)
setDword("Priority", priority);
- const wchar_t *szStatusMessage = nullptr;
- fieldNode = XmlGetChildByTag(xNode, "field", "var", L"status-message");
- if (fieldNode && (valueNode = XmlGetChild(fieldNode , "value")))
- szStatusMessage = XmlGetText(valueNode);
+ const char *szStatusMessage = nullptr;
+ if (fieldNode = XmlGetChildByTag(xNode, "field", "var", "status-message"))
+ if (auto *valueNode = fieldNode->FirstChildElement("value"))
+ szStatusMessage = valueNode->GetText();
// skip f...ng away dialog
int nNoDlg = db_get_b(0, "SRAway", StatusModeToDbSetting(status, "NoDlg"), 0);
db_set_b(0, "SRAway", StatusModeToDbSetting(status, "NoDlg"), 1);
- db_set_ws(0, "SRAway", StatusModeToDbSetting(status, "Msg"), szStatusMessage ? szStatusMessage : L"");
+ db_set_utf(0, "SRAway", StatusModeToDbSetting(status, "Msg"), szStatusMessage ? szStatusMessage : "");
- fieldNode = XmlGetChildByTag(xNode, "field", "var", L"status-global");
- if (fieldNode && (valueNode = XmlGetChild(fieldNode , "value"))) {
- if ((ptszValue = XmlGetText(valueNode)) != nullptr && _wtoi(ptszValue))
- Clist_SetStatusMode(status);
- else
- CallProtoService(m_szModuleName, PS_SETSTATUS, status, 0);
- }
- SetAwayMsg(status, szStatusMessage);
+ if (fieldNode = XmlGetChildByTag(xNode, "field", "var", "status-global"))
+ if (auto *valueNode = fieldNode->FirstChildElement("value"))
+ if ((pszValue = valueNode->GetText()) != nullptr && atoi(pszValue))
+ Clist_SetStatusMode(status);
+ else
+ CallProtoService(m_szModuleName, PS_SETSTATUS, status, 0);
+
+ SetAwayMsg(status, Utf2T(szStatusMessage));
// return NoDlg setting
db_set_b(0, "SRAway", StatusModeToDbSetting(status, "NoDlg"), (BYTE)nNoDlg);
@@ -394,38 +394,38 @@ int CJabberProto::AdhocSetStatusHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhoc
return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
}
-int CJabberProto::AdhocOptionsHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhocSession* pSession)
+int CJabberProto::AdhocOptionsHandler(const TiXmlElement*, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession)
{
if (pSession->GetStage() == 0) {
// first form
pSession->SetStage(1);
- XmlNodeIq iq(L"result", pInfo);
- HXML xNode = iq
- << XCHILDNS(L"command", JABBER_FEAT_COMMANDS) << XATTR(L"node", JABBER_FEAT_RC_SET_OPTIONS)
- << XATTR(L"sessionid", pSession->GetSessionId()) << XATTR(L"status", L"executing")
- << XCHILDNS(L"x", JABBER_FEAT_DATA_FORMS) << XATTR(L"type", L"form");
+ XmlNodeIq iq("result", pInfo);
+ TiXmlElement *xNode = iq
+ << XCHILDNS("command", JABBER_FEAT_COMMANDS) << XATTR("node", JABBER_FEAT_RC_SET_OPTIONS)
+ << XATTR("sessionid", pSession->GetSessionId()) << XATTR("status", "executing")
+ << XCHILDNS("x", JABBER_FEAT_DATA_FORMS) << XATTR("type", "form");
- xNode << XCHILD(L"title", TranslateT("Set Options"));
- xNode << XCHILD(L"instructions", TranslateT("Set the desired options"));
+ xNode << XCHILD("title", Translate("Set Options"));
+ xNode << XCHILD("instructions", Translate("Set the desired options"));
- xNode << XCHILD(L"field") << XATTR(L"type", L"hidden") << XATTR(L"var", L"FORM_TYPE")
- << XATTR(L"value", JABBER_FEAT_RC);
+ xNode << XCHILD("field") << XATTR("type", "hidden") << XATTR("var", "FORM_TYPE")
+ << XATTR("value", JABBER_FEAT_RC);
// Automatically Accept File Transfers
- wchar_t szTmpBuff[ 1024 ];
- mir_snwprintf(szTmpBuff, L"%d", db_get_b(0, "SRFile", "AutoAccept", 0));
- xNode << XCHILD(L"field") << XATTR(L"label", TranslateT("Automatically Accept File Transfers"))
- << XATTR(L"type", L"boolean") << XATTR(L"var", L"auto-files") << XCHILD(L"value", szTmpBuff);
+ char szTmpBuff[20];
+ _itoa_s(db_get_b(0, "SRFile", "AutoAccept", 0), szTmpBuff, 10);
+ xNode << XCHILD("field") << XATTR("label", Translate("Automatically Accept File Transfers"))
+ << XATTR("type", "boolean") << XATTR("var", "auto-files") << XCHILD("value", szTmpBuff);
// Use sounds
- mir_snwprintf(szTmpBuff, L"%d", db_get_b(0, "Skin", "UseSound", 0));
- xNode << XCHILD(L"field") << XATTR(L"label", TranslateT("Play sounds"))
- << XATTR(L"type", L"boolean") << XATTR(L"var", L"sounds") << XCHILD(L"value", szTmpBuff);
+ _itoa_s(db_get_b(0, "Skin", "UseSound", 0), szTmpBuff, 10);
+ xNode << XCHILD("field") << XATTR("label", Translate("Play sounds"))
+ << XATTR("type", "boolean") << XATTR("var", "sounds") << XCHILD("value", szTmpBuff);
// Disable remote controlling
- xNode << XCHILD(L"field") << XATTR(L"label", TranslateT("Disable remote controlling (check twice what you are doing)"))
- << XATTR(L"type", L"boolean") << XATTR(L"var", L"enable-rc") << XCHILD(L"value", L"0");
+ xNode << XCHILD("field") << XATTR("label", Translate("Disable remote controlling (check twice what you are doing)"))
+ << XATTR("type", "boolean") << XATTR("var", "enable-rc") << XCHILD("value", "0");
m_ThreadInfo->send(iq);
return JABBER_ADHOC_HANDLER_STATUS_EXECUTING;
@@ -433,28 +433,28 @@ int CJabberProto::AdhocOptionsHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhocSe
if (pSession->GetStage() == 1) {
// result form here
- HXML commandNode = pInfo->GetChildNode();
- HXML xNode = XmlGetChildByTag(commandNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS);
+ auto *commandNode = pInfo->GetChildNode();
+ auto *xNode = XmlGetChildByTag(commandNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS);
if (!xNode)
return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
// Automatically Accept File Transfers
- HXML fieldNode = XmlGetChildByTag(xNode, "field", "var", L"auto-files"), valueNode;
- if (fieldNode && (valueNode = XmlGetChild(fieldNode , "value")))
- if (XmlGetText(valueNode))
- db_set_b(0, "SRFile", "AutoAccept", (BYTE)_wtoi(XmlGetText(valueNode)));
+ if (auto *fieldNode = XmlGetChildByTag(xNode, "field", "var", "auto-files"))
+ if (auto *valueNode = fieldNode->FirstChildElement("value"))
+ if (valueNode->GetText())
+ db_set_b(0, "SRFile", "AutoAccept", (BYTE)atoi(valueNode->GetText()));
// Use sounds
- fieldNode = XmlGetChildByTag(xNode, "field", "var", L"sounds");
- if (fieldNode && (valueNode = XmlGetChild(fieldNode , "value")))
- if (XmlGetText(valueNode))
- db_set_b(0, "Skin", "UseSound", (BYTE)_wtoi(XmlGetText(valueNode)));
+ if (auto *fieldNode = XmlGetChildByTag(xNode, "field", "var", "sounds"))
+ if (auto *valueNode = fieldNode->FirstChildElement("value"))
+ if (valueNode->GetText())
+ db_set_b(0, "Skin", "UseSound", (BYTE)atoi(valueNode->GetText()));
// Disable remote controlling
- fieldNode = XmlGetChildByTag(xNode, "field", "var", L"enable-rc");
- if (fieldNode && (valueNode = XmlGetChild(fieldNode , "value")))
- if (XmlGetText(valueNode) && _wtoi(XmlGetText(valueNode)))
- m_bEnableRemoteControl = 0;
+ if (auto *fieldNode = XmlGetChildByTag(xNode, "field", "var", "enable-rc"))
+ if (auto *valueNode = fieldNode->FirstChildElement("value"))
+ if (valueNode->GetText() && atoi(valueNode->GetText()))
+ m_bEnableRemoteControl = 0;
return JABBER_ADHOC_HANDLER_STATUS_COMPLETED;
}
@@ -465,7 +465,7 @@ int CJabberProto::RcGetUnreadEventsCount()
{
int nEventsSent = 0;
for (auto &hContact : AccContacts()) {
- ptrW jid( getWStringA(hContact, "jid"));
+ ptrW jid(getWStringA(hContact, "jid"));
if (jid == nullptr) continue;
for (MEVENT hDbEvent = db_event_firstUnread(hContact); hDbEvent; hDbEvent = db_event_next(hContact, hDbEvent)) {
@@ -489,19 +489,16 @@ int CJabberProto::RcGetUnreadEventsCount()
return nEventsSent;
}
-int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhocSession* pSession)
+int CJabberProto::AdhocForwardHandler(const TiXmlElement*, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession)
{
- wchar_t szMsg[ 1024 ];
if (pSession->GetStage() == 0) {
int nUnreadEvents = RcGetUnreadEventsCount();
if (!nUnreadEvents) {
- mir_snwprintf(szMsg, TranslateT("There is no messages to forward"));
-
m_ThreadInfo->send(
- XmlNodeIq(L"result", pInfo)
- << XCHILDNS(L"command", JABBER_FEAT_COMMANDS) << XATTR(L"node", JABBER_FEAT_RC_FORWARD)
- << XATTR(L"sessionid", pSession->GetSessionId()) << XATTR(L"status", L"completed")
- << XCHILD(L"note", szMsg) << XATTR(L"type", L"info"));
+ XmlNodeIq("result", pInfo)
+ << XCHILDNS("command", JABBER_FEAT_COMMANDS) << XATTR("node", JABBER_FEAT_RC_FORWARD)
+ << XATTR("sessionid", pSession->GetSessionId()) << XATTR("status", "completed")
+ << XCHILD("note", Translate("There is no messages to forward")) << XATTR("type", "info"));
return JABBER_ADHOC_HANDLER_STATUS_REMOVE_SESSION;
}
@@ -509,24 +506,24 @@ int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhocSe
// first form
pSession->SetStage(1);
- XmlNodeIq iq(L"result", pInfo);
- HXML xNode = iq
- << XCHILDNS(L"command", JABBER_FEAT_COMMANDS) << XATTR(L"node", JABBER_FEAT_RC_FORWARD)
- << XATTR(L"sessionid", pSession->GetSessionId()) << XATTR(L"status", L"executing")
- << XCHILDNS(L"x", JABBER_FEAT_DATA_FORMS) << XATTR(L"type", L"form");
+ XmlNodeIq iq("result", pInfo);
+ TiXmlElement *xNode = iq
+ << XCHILDNS("command", JABBER_FEAT_COMMANDS) << XATTR("node", JABBER_FEAT_RC_FORWARD)
+ << XATTR("sessionid", pSession->GetSessionId()) << XATTR("status", "executing")
+ << XCHILDNS("x", JABBER_FEAT_DATA_FORMS) << XATTR("type", "form");
- xNode << XCHILD(L"title", TranslateT("Forward options"));
+ xNode << XCHILD("title", Translate("Forward options"));
- mir_snwprintf(szMsg, TranslateT("%d message(s) to be forwarded"), nUnreadEvents);
- xNode << XCHILD(L"instructions", szMsg);
+ char szMsg[1024];
+ mir_snprintf(szMsg, Translate("%d message(s) to be forwarded"), nUnreadEvents);
+ xNode << XCHILD("instructions", szMsg);
- xNode << XCHILD(L"field") << XATTR(L"type", L"hidden") << XATTR(L"var", L"FORM_TYPE")
- << XCHILD(L"value", JABBER_FEAT_RC);
+ xNode << XCHILD("field") << XATTR("type", "hidden") << XATTR("var", "FORM_TYPE")
+ << XCHILD("value", JABBER_FEAT_RC);
// remove clist events
- xNode << XCHILD(L"field") << XATTR(L"label", TranslateT("Mark messages as read")) << XATTR(L"type", L"boolean")
- << XATTR(L"var", L"remove-clist-events") << XCHILD(L"value",
- m_bRcMarkMessagesAsRead == 1 ? L"1" : L"0");
+ xNode << XCHILD("field") << XATTR("label", Translate("Mark messages as read")) << XATTR("type", "boolean")
+ << XATTR("var", "remove-clist-events") << XCHILD("value", m_bRcMarkMessagesAsRead == 1 ? "1" : "0");
m_ThreadInfo->send(iq);
return JABBER_ADHOC_HANDLER_STATUS_EXECUTING;
@@ -534,27 +531,27 @@ int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhocSe
if (pSession->GetStage() == 1) {
// result form here
- HXML commandNode = pInfo->GetChildNode();
- HXML xNode = XmlGetChildByTag(commandNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS);
+ auto *commandNode = pInfo->GetChildNode();
+ auto *xNode = XmlGetChildByTag(commandNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS);
if (!xNode)
return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
BOOL bRemoveCListEvents = TRUE;
// remove clist events
- HXML fieldNode = XmlGetChildByTag(xNode,"field", "var", L"remove-clist-events"), valueNode;
- if (fieldNode && (valueNode = XmlGetChild(fieldNode , "value")))
- if (XmlGetText(valueNode) && !_wtoi(XmlGetText(valueNode)))
+ auto *fieldNode = XmlGetChildByTag(xNode, "field", "var", "remove-clist-events");
+ if (auto *valueNode = fieldNode->FirstChildElement("value"))
+ if (valueNode->GetText() && !atoi(valueNode->GetText()))
bRemoveCListEvents = FALSE;
m_bRcMarkMessagesAsRead = bRemoveCListEvents ? 1 : 0;
int nEventsSent = 0;
for (auto &hContact : AccContacts()) {
- ptrW tszJid( getWStringA(hContact, "jid"));
+ ptrA tszJid(getUStringA(hContact, "jid"));
if (tszJid == nullptr)
continue;
-
+
for (MEVENT hDbEvent = db_event_firstUnread(hContact); hDbEvent; hDbEvent = db_event_next(hContact, hDbEvent)) {
DBEVENTINFO dbei = {};
dbei.cbBlob = db_event_getBlobSize(hDbEvent);
@@ -569,33 +566,33 @@ int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhocSe
if (dbei.eventType != EVENTTYPE_MESSAGE || (dbei.flags & (DBEF_READ | DBEF_SENT)))
continue;
- ptrW szEventText( DbEvent_GetTextW(&dbei, CP_ACP));
+ ptrW szEventText(DbEvent_GetTextW(&dbei, CP_ACP));
if (szEventText == nullptr)
continue;
- XmlNode msg(L"message");
- msg << XATTR(L"to", pInfo->GetFrom()) << XATTRID(SerialNext())
- << XCHILD(L"body", szEventText);
-
- HXML addressesNode = msg << XCHILDNS(L"addresses", JABBER_FEAT_EXT_ADDRESSING);
- wchar_t szOFrom[JABBER_MAX_JID_LEN];
+ XmlNode msg("message");
+ msg << XATTR("to", pInfo->GetFrom()) << XATTRID(SerialNext())
+ << XCHILD("body", T2Utf(szEventText));
- size_t cbBlob = mir_strlen((LPSTR)dbei.pBlob)+1;
+ TiXmlElement *addressesNode = msg << XCHILDNS("addresses", JABBER_FEAT_EXT_ADDRESSING);
+
+ char szOFrom[JABBER_MAX_JID_LEN];
+ size_t cbBlob = mir_strlen((LPSTR)dbei.pBlob) + 1;
if (cbBlob < dbei.cbBlob) { // rest of message contains a sender's resource
- ptrW szOResource( mir_utf8decodeW((LPSTR)dbei.pBlob + cbBlob+1));
- mir_snwprintf(szOFrom, L"%s/%s", tszJid, szOResource);
- } else
- wcsncpy_s(szOFrom, tszJid, _TRUNCATE);
+ ptrW szOResource(mir_utf8decodeW((LPSTR)dbei.pBlob + cbBlob + 1));
+ mir_snprintf(szOFrom, "%s/%s", tszJid, szOResource);
+ }
+ else strncpy_s(szOFrom, tszJid, _TRUNCATE);
- addressesNode << XCHILD(L"address") << XATTR(L"type", L"ofrom") << XATTR(L"jid", szOFrom);
- addressesNode << XCHILD(L"address") << XATTR(L"type", L"oto") << XATTR(L"jid", m_ThreadInfo->fullJID);
+ addressesNode << XCHILD("address") << XATTR("type", "ofrom") << XATTR("jid", szOFrom);
+ addressesNode << XCHILD("address") << XATTR("type", "oto") << XATTR("jid", m_ThreadInfo->fullJID);
time_t ltime = (time_t)dbei.timestamp;
struct tm *gmt = gmtime(&ltime);
- wchar_t stime[512];
- mir_snwprintf(stime, L"%.4i-%.2i-%.2iT%.2i:%.2i:%.2iZ", gmt->tm_year + 1900, gmt->tm_mon + 1, gmt->tm_mday,
+ char stime[512];
+ mir_snprintf(stime, "%.4i-%.2i-%.2iT%.2i:%.2i:%.2iZ", gmt->tm_year + 1900, gmt->tm_mon + 1, gmt->tm_mday,
gmt->tm_hour, gmt->tm_min, gmt->tm_sec);
- msg << XCHILDNS(L"delay", L"urn:xmpp:delay") << XATTR(L"stamp", stime);
+ msg << XCHILDNS("delay", "urn:xmpp:delay") << XATTR("stamp", stime);
m_ThreadInfo->send(msg);
@@ -607,13 +604,11 @@ int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhocSe
}
}
- mir_snwprintf(szMsg, TranslateT("%d message(s) forwarded"), nEventsSent);
-
m_ThreadInfo->send(
- XmlNodeIq(L"result", pInfo)
- << XCHILDNS(L"command", JABBER_FEAT_COMMANDS) << XATTR(L"node", JABBER_FEAT_RC_FORWARD)
- << XATTR(L"sessionid", pSession->GetSessionId()) << XATTR(L"status", L"completed")
- << XCHILD(L"note", szMsg) << XATTR(L"type", L"info"));
+ XmlNodeIq("result", pInfo)
+ << XCHILDNS("command", JABBER_FEAT_COMMANDS) << XATTR("node", JABBER_FEAT_RC_FORWARD)
+ << XATTR("sessionid", pSession->GetSessionId()) << XATTR("status", "completed")
+ << XCHILD("note", CMStringA(FORMAT, Translate("%d message(s) forwarded"), nEventsSent)) << XATTR("type", "info"));
return JABBER_ADHOC_HANDLER_STATUS_REMOVE_SESSION;
}
@@ -621,21 +616,21 @@ int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhocSe
return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
}
-int CJabberProto::AdhocLockWSHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhocSession* pSession)
+int CJabberProto::AdhocLockWSHandler(const TiXmlElement*, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession)
{
BOOL bOk = LockWorkStation();
- wchar_t szMsg[ 1024 ];
+ char szMsg[1024];
if (bOk)
- mir_snwprintf(szMsg, TranslateT("Workstation successfully locked"));
+ mir_snprintf(szMsg, Translate("Workstation successfully locked"));
else
- mir_snwprintf(szMsg, TranslateT("Error %d occurred during workstation lock"), GetLastError());
+ mir_snprintf(szMsg, Translate("Error %d occurred during workstation lock"), GetLastError());
m_ThreadInfo->send(
- XmlNodeIq(L"result", pInfo)
- << XCHILDNS(L"command", JABBER_FEAT_COMMANDS) << XATTR(L"node", JABBER_FEAT_RC_WS_LOCK)
- << XATTR(L"sessionid", pSession->GetSessionId()) << XATTR(L"status", L"completed")
- << XCHILD(L"note", szMsg) << XATTR(L"type", bOk ? L"info" : L"error"));
+ XmlNodeIq("result", pInfo)
+ << XCHILDNS("command", JABBER_FEAT_COMMANDS) << XATTR("node", JABBER_FEAT_RC_WS_LOCK)
+ << XATTR("sessionid", pSession->GetSessionId()) << XATTR("status", "completed")
+ << XCHILD("note", szMsg) << XATTR("type", bOk ? "info" : "error"));
return JABBER_ADHOC_HANDLER_STATUS_REMOVE_SESSION;
}
@@ -645,27 +640,27 @@ static void __stdcall JabberQuitMirandaIMThread(void*)
CallService("CloseAction", 0, 0);
}
-int CJabberProto::AdhocQuitMirandaHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhocSession* pSession)
+int CJabberProto::AdhocQuitMirandaHandler(const TiXmlElement*, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession)
{
if (pSession->GetStage() == 0) {
// first form
pSession->SetStage(1);
- XmlNodeIq iq(L"result", pInfo);
- HXML xNode = iq
- << XCHILDNS(L"command", JABBER_FEAT_COMMANDS) << XATTR(L"node", JABBER_FEAT_RC_QUIT_MIRANDA)
- << XATTR(L"sessionid", pSession->GetSessionId()) << XATTR(L"status", L"executing")
- << XCHILDNS(L"x", JABBER_FEAT_DATA_FORMS) << XATTR(L"type", L"form");
+ XmlNodeIq iq("result", pInfo);
+ TiXmlElement *xNode = iq
+ << XCHILDNS("command", JABBER_FEAT_COMMANDS) << XATTR("node", JABBER_FEAT_RC_QUIT_MIRANDA)
+ << XATTR("sessionid", pSession->GetSessionId()) << XATTR("status", "executing")
+ << XCHILDNS("x", JABBER_FEAT_DATA_FORMS) << XATTR("type", "form");
- xNode << XCHILD(L"title", TranslateT("Confirmation needed"));
- xNode << XCHILD(L"instructions", TranslateT("Please confirm Miranda NG shutdown"));
+ xNode << XCHILD("title", Translate("Confirmation needed"));
+ xNode << XCHILD("instructions", Translate("Please confirm Miranda NG shutdown"));
- xNode << XCHILD(L"field") << XATTR(L"type", L"hidden") << XATTR(L"var", L"FORM_TYPE")
- << XCHILD(L"value", JABBER_FEAT_RC);
+ xNode << XCHILD("field") << XATTR("type", "hidden") << XATTR("var", "FORM_TYPE")
+ << XCHILD("value", JABBER_FEAT_RC);
// I Agree checkbox
- xNode << XCHILD(L"field") << XATTR(L"label", L"I agree") << XATTR(L"type", L"boolean")
- << XATTR(L"var", L"allow-shutdown") << XCHILD(L"value", L"0");
+ xNode << XCHILD("field") << XATTR("label", "I agree") << XATTR("type", "boolean")
+ << XATTR("var", "allow-shutdown") << XCHILD("value", "0");
m_ThreadInfo->send(iq);
return JABBER_ADHOC_HANDLER_STATUS_EXECUTING;
@@ -673,17 +668,15 @@ int CJabberProto::AdhocQuitMirandaHandler(HXML, CJabberIqInfo *pInfo, CJabberAdh
if (pSession->GetStage() == 1) {
// result form here
- HXML commandNode = pInfo->GetChildNode();
- HXML xNode = XmlGetChildByTag(commandNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS);
+ auto *commandNode = pInfo->GetChildNode();
+ auto *xNode = XmlGetChildByTag(commandNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS);
if (!xNode)
return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
- HXML fieldNode, valueNode;
-
// I Agree checkbox
- fieldNode = XmlGetChildByTag(xNode,"field", "var", L"allow-shutdown");
- if (fieldNode && (valueNode = XmlGetChild(fieldNode , "value")))
- if (XmlGetText(valueNode) && _wtoi(XmlGetText(valueNode)))
+ auto *fieldNode = XmlGetChildByTag(xNode, "field", "var", "allow-shutdown");
+ if (auto *valueNode = fieldNode->FirstChildElement("value"))
+ if (valueNode->GetText() && atoi(valueNode->GetText()))
CallFunctionAsync(JabberQuitMirandaIMThread, nullptr);
return JABBER_ADHOC_HANDLER_STATUS_COMPLETED;
@@ -691,7 +684,7 @@ int CJabberProto::AdhocQuitMirandaHandler(HXML, CJabberIqInfo *pInfo, CJabberAdh
return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
}
-int CJabberProto::AdhocLeaveGroupchatsHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhocSession* pSession)
+int CJabberProto::AdhocLeaveGroupchatsHandler(const TiXmlElement*, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession)
{
int i = 0;
if (pSession->GetStage() == 0) {
@@ -708,42 +701,39 @@ int CJabberProto::AdhocLeaveGroupchatsHandler(HXML, CJabberIqInfo *pInfo, CJabbe
}
if (!nChatsCount) {
- wchar_t szMsg[ 1024 ];
- mir_snwprintf(szMsg, TranslateT("There is no group chats to leave"));
-
m_ThreadInfo->send(
- XmlNodeIq(L"result", pInfo)
- << XCHILDNS(L"command", JABBER_FEAT_COMMANDS) << XATTR(L"node", JABBER_FEAT_RC_LEAVE_GROUPCHATS)
- << XATTR(L"sessionid", pSession->GetSessionId()) << XATTR(L"status", L"completed")
- << XCHILD(L"note", szMsg) << XATTR(L"type", L"info"));
+ XmlNodeIq("result", pInfo)
+ << XCHILDNS("command", JABBER_FEAT_COMMANDS) << XATTR("node", JABBER_FEAT_RC_LEAVE_GROUPCHATS)
+ << XATTR("sessionid", pSession->GetSessionId()) << XATTR("status", "completed")
+ << XCHILD("note", Translate("There is no group chats to leave")) << XATTR("type", "info"));
return JABBER_ADHOC_HANDLER_STATUS_REMOVE_SESSION;
}
pSession->SetStage(1);
- XmlNodeIq iq(L"result", pInfo);
- HXML xNode = iq
- << XCHILDNS(L"command", JABBER_FEAT_COMMANDS) << XATTR(L"node", JABBER_FEAT_RC_LEAVE_GROUPCHATS)
- << XATTR(L"sessionid", pSession->GetSessionId()) << XATTR(L"status", L"executing")
- << XCHILDNS(L"x", JABBER_FEAT_DATA_FORMS) << XATTR(L"type", L"form");
+ XmlNodeIq iq("result", pInfo);
+ TiXmlElement *xNode = iq
+ << XCHILDNS("command", JABBER_FEAT_COMMANDS) << XATTR("node", JABBER_FEAT_RC_LEAVE_GROUPCHATS)
+ << XATTR("sessionid", pSession->GetSessionId()) << XATTR("status", "executing")
+ << XCHILDNS("x", JABBER_FEAT_DATA_FORMS) << XATTR("type", "form");
- xNode << XCHILD(L"title", TranslateT("Leave group chats"));
- xNode << XCHILD(L"instructions", TranslateT("Choose the group chats you want to leave"));
+ xNode << XCHILD("title", Translate("Leave group chats"));
+ xNode << XCHILD("instructions", Translate("Choose the group chats you want to leave"));
- xNode << XCHILD(L"field") << XATTR(L"type", L"hidden") << XATTR(L"var", L"FORM_TYPE")
- << XATTR(L"value", JABBER_FEAT_RC);
+ xNode << XCHILD("field") << XATTR("type", "hidden") << XATTR("var", "FORM_TYPE")
+ << XATTR("value", JABBER_FEAT_RC);
// Groupchats
- HXML fieldNode = xNode << XCHILD(L"field") << XATTR(L"label", nullptr) << XATTR(L"type", L"list-multi") << XATTR(L"var", L"groupchats");
- fieldNode << XCHILD(L"required");
+ TiXmlElement *fieldNode = xNode << XCHILD("field") << XATTR("label", nullptr) << XATTR("type", "list-multi") << XATTR("var", "groupchats");
+ fieldNode << XCHILD("required");
{
mir_cslock lck(m_csLists);
LISTFOREACH_NODEF(i, this, LIST_CHATROOM)
{
JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i);
if (item != nullptr)
- fieldNode << XCHILD(L"option") << XATTR(L"label", item->jid) << XCHILD(L"value", item->jid);
+ fieldNode << XCHILD("option") << XATTR("label", item->jid) << XCHILD("value", item->jid);
}
}
@@ -753,21 +743,18 @@ int CJabberProto::AdhocLeaveGroupchatsHandler(HXML, CJabberIqInfo *pInfo, CJabbe
if (pSession->GetStage() == 1) {
// result form here
- HXML commandNode = pInfo->GetChildNode();
- HXML xNode = XmlGetChildByTag(commandNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS);
+ auto *commandNode = pInfo->GetChildNode();
+ auto *xNode = XmlGetChildByTag(commandNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS);
if (!xNode)
return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
// Groupchat list here:
- HXML fieldNode = XmlGetChildByTag(xNode,"field", "var", L"groupchats");
+ auto *fieldNode = XmlGetChildByTag(xNode, "field", "var", "groupchats");
if (fieldNode) {
- for (i=0; i < XmlGetChildCount(fieldNode); i++) {
- HXML valueNode = XmlGetChild(fieldNode, i);
- if (valueNode && XmlGetName(valueNode) && XmlGetText(valueNode) && !mir_wstrcmp(XmlGetName(valueNode), L"value")) {
- JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, XmlGetText(valueNode));
- if (item)
- GcQuit(item, 0, nullptr);
- }
+ for (auto *valueNode : TiXmlFilter(fieldNode, "value")) {
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, valueNode->GetText());
+ if (item)
+ GcQuit(item, 0, nullptr);
}
}
diff --git a/protocols/JabberG/src/jabber_rc.h b/protocols/JabberG/src/jabber_rc.h
index 3efc04ce87..93c006f6b0 100644
--- a/protocols/JabberG/src/jabber_rc.h
+++ b/protocols/JabberG/src/jabber_rc.h
@@ -34,7 +34,7 @@ class CJabberAdhocSession;
#define JABBER_ADHOC_HANDLER_STATUS_COMPLETED 2
#define JABBER_ADHOC_HANDLER_STATUS_CANCEL 3
#define JABBER_ADHOC_HANDLER_STATUS_REMOVE_SESSION 4
-typedef int (CJabberProto::*JABBER_ADHOC_HANDLER)(HXML iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession* pSession);
+typedef int (CJabberProto::*JABBER_ADHOC_HANDLER)(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession);
// 5 minutes to fill out form :)
#define JABBER_ADHOC_SESSION_EXPIRE_TIME 300000
@@ -42,7 +42,7 @@ typedef int (CJabberProto::*JABBER_ADHOC_HANDLER)(HXML iqNode, CJabberIqInfo *pI
class CJabberAdhocSession
{
protected:
- CMStringW m_szSessionId;
+ CMStringA m_szSessionId;
CJabberAdhocSession* m_pNext;
DWORD m_dwStartTime;
@@ -74,7 +74,7 @@ public:
{
return m_dwStartTime;
}
- const wchar_t *GetSessionId()
+ const char* GetSessionId()
{
return m_szSessionId;
}
@@ -102,19 +102,19 @@ class CJabberAdhocNode;
class CJabberAdhocNode
{
protected:
- wchar_t *m_szJid;
- wchar_t *m_szNode;
- wchar_t *m_szName;
+ char *m_szJid;
+ char *m_szNode;
+ char *m_szName;
CJabberAdhocNode* m_pNext;
JABBER_ADHOC_HANDLER m_pHandler;
CJabberProto *m_pProto;
public:
- CJabberAdhocNode(CJabberProto* pProto, wchar_t* szJid, wchar_t* szNode, wchar_t* szName, JABBER_ADHOC_HANDLER pHandler)
+ CJabberAdhocNode(CJabberProto* pProto, const char *szJid, const char *szNode, const char *szName, JABBER_ADHOC_HANDLER pHandler)
{
memset(this, 0, sizeof(CJabberAdhocNode));
- replaceStrW(m_szJid, szJid);
- replaceStrW(m_szNode, szNode);
- replaceStrW(m_szName, szName);
+ replaceStr(m_szJid, szJid);
+ replaceStr(m_szNode, szNode);
+ replaceStr(m_szName, szName);
m_pHandler = pHandler;
m_pProto = pProto;
}
@@ -127,7 +127,7 @@ public:
if (m_pNext)
delete m_pNext;
}
- CJabberAdhocNode* GetNext()
+ CJabberAdhocNode* GetNext() const
{
return m_pNext;
}
@@ -137,19 +137,19 @@ public:
m_pNext = pNext;
return pRetVal;
}
- wchar_t* GetJid()
+ char* GetJid() const
{
return m_szJid;
}
- wchar_t* GetNode()
+ char* GetNode() const
{
return m_szNode;
}
- wchar_t* GetName()
+ char* GetName() const
{
return m_szName;
}
- BOOL CallHandler(HXML iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession* pSession)
+ BOOL CallHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession)
{
if (m_pHandler == nullptr)
return FALSE;
@@ -165,11 +165,11 @@ protected:
CJabberAdhocSession* m_pSessions;
mir_cs m_cs;
- CJabberAdhocSession* FindSession(const wchar_t *szSession)
+ CJabberAdhocSession* FindSession(const char *szSession)
{
- CJabberAdhocSession* pSession = m_pSessions;
+ CJabberAdhocSession *pSession = m_pSessions;
while (pSession) {
- if (!mir_wstrcmp(pSession->GetSessionId(), szSession))
+ if (!mir_strcmp(pSession->GetSessionId(), szSession))
return pSession;
pSession = pSession->GetNext();
}
@@ -178,7 +178,7 @@ protected:
CJabberAdhocSession* AddNewSession()
{
- CJabberAdhocSession* pSession = new CJabberAdhocSession(m_pProto);
+ CJabberAdhocSession *pSession = new CJabberAdhocSession(m_pProto);
if (!pSession)
return nullptr;
@@ -188,18 +188,18 @@ protected:
return pSession;
}
- CJabberAdhocNode* FindNode(const wchar_t *szNode)
+ CJabberAdhocNode* FindNode(const char *szNode)
{
CJabberAdhocNode* pNode = m_pNodes;
while (pNode) {
- if (!mir_wstrcmp(pNode->GetNode(), szNode))
+ if (!mir_strcmp(pNode->GetNode(), szNode))
return pNode;
pNode = pNode->GetNext();
}
return nullptr;
}
- BOOL RemoveSession(CJabberAdhocSession* pSession)
+ BOOL RemoveSession(CJabberAdhocSession *pSession)
{
if (!m_pSessions)
return FALSE;
@@ -229,7 +229,7 @@ protected:
if (!m_pSessions)
return FALSE;
- CJabberAdhocSession* pSession = m_pSessions;
+ CJabberAdhocSession *pSession = m_pSessions;
if (pSession->GetSessionStartTime() < dwExpireTime) {
m_pSessions = pSession->GetNext();
pSession->SetNext(nullptr);
@@ -264,7 +264,8 @@ public:
}
BOOL FillDefaultNodes();
- BOOL AddNode(wchar_t* szJid, wchar_t* szNode, wchar_t* szName, JABBER_ADHOC_HANDLER pHandler)
+
+ BOOL AddNode(const char *szJid, const char *szNode, const char *szName, JABBER_ADHOC_HANDLER pHandler)
{
CJabberAdhocNode* pNode = new CJabberAdhocNode(m_pProto, szJid, szNode, szName, pHandler);
if (!pNode)
@@ -287,9 +288,9 @@ public:
return m_pNodes;
}
- BOOL HandleItemsRequest(HXML iqNode, CJabberIqInfo *pInfo, const wchar_t *szNode);
- BOOL HandleInfoRequest(HXML iqNode, CJabberIqInfo *pInfo, const wchar_t *szNode);
- BOOL HandleCommandRequest(HXML iqNode, CJabberIqInfo *pInfo, const wchar_t *szNode);
+ BOOL HandleItemsRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, const char *szNode);
+ BOOL HandleInfoRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, const char *szNode);
+ BOOL HandleCommandRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, const char *szNode);
BOOL ExpireSessions()
{
diff --git a/protocols/JabberG/src/jabber_search.cpp b/protocols/JabberG/src/jabber_search.cpp
index f43e7bc2bb..04e8427255 100644
--- a/protocols/JabberG/src/jabber_search.cpp
+++ b/protocols/JabberG/src/jabber_search.cpp
@@ -106,7 +106,7 @@ static int JabberSearchAddField(HWND hwndDlg, Data* FieldDat)
int Order = (FieldDat->bHidden) ? -1 : FieldDat->Order;
HWND hwndLabel = CreateWindowEx(0, L"STATIC", (const wchar_t *)TranslateW(FieldDat->Label), WS_CHILD, CornerX, CornerY + Order * 40, width, 13, hwndParent, nullptr, g_plugin.getInst(), nullptr);
- HWND hwndVar = CreateWindowEx(0 | WS_EX_CLIENTEDGE, L"EDIT", (const wchar_t *)FieldDat->defValue, WS_CHILD | WS_TABSTOP, CornerX + 5, CornerY + Order * 40 + 14, width, 20, hwndParent, nullptr, g_plugin.getInst(), nullptr);
+ HWND hwndVar = CreateWindowEx(0 | WS_EX_CLIENTEDGE, L"EDIT", FieldDat->defValue, WS_CHILD | WS_TABSTOP, CornerX + 5, CornerY + Order * 40 + 14, width, 20, hwndParent, nullptr, g_plugin.getInst(), nullptr);
SendMessage(hwndLabel, WM_SETFONT, (WPARAM)hFont, 0);
SendMessage(hwndVar, WM_SETFONT, (WPARAM)hFont, 0);
if (!FieldDat->bHidden) {
@@ -132,43 +132,39 @@ static int JabberSearchAddField(HWND hwndDlg, Data* FieldDat)
////////////////////////////////////////////////////////////////////////////////
// Available search field request result handler (XEP-0055. Examples 2, 7)
-void CJabberProto::OnIqResultGetSearchFields(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultGetSearchFields(const TiXmlElement *iqNode, CJabberIqInfo*)
{
if (!searchHandleDlg)
return;
- const wchar_t *type = XmlGetAttrValue(iqNode, L"type");
+ const char *type = iqNode->Attribute("type");
if (type == nullptr)
return;
- if (!mir_wstrcmp(type, L"result")) {
- HXML queryNode = XmlGetNthChild(iqNode, L"query", 1);
- HXML xNode = XmlGetChildByTag(queryNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS);
+ if (!mir_strcmp(type, "result")) {
+ auto *queryNode = iqNode->FirstChildElement("query");
+ auto *xNode = XmlGetChildByTag(queryNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS);
ShowWindow(searchHandleDlg, SW_HIDE);
if (xNode) {
- //1. Form
- PostMessage(searchHandleDlg, WM_USER + 11, (WPARAM)xmlCopyNode(xNode), 0);
- HXML xcNode = XmlGetNthChild(xNode, L"instructions", 1);
+ // 1. Form
+ PostMessage(searchHandleDlg, WM_USER + 11, (WPARAM)xNode, 0);
+ auto *xcNode = xNode->FirstChildElement("instructions");
if (xcNode)
- SetDlgItemText(searchHandleDlg, IDC_INSTRUCTIONS, XmlGetText(xcNode));
+ SetDlgItemTextUtf(searchHandleDlg, IDC_INSTRUCTIONS, xcNode->GetText());
}
else {
int Order = 0;
- for (int i = 0;; i++) {
- HXML chNode = XmlGetChild(queryNode, i);
- if (!chNode)
- break;
-
- if (!mir_wstrcmpi(XmlGetName(chNode), L"instructions") && XmlGetText(chNode))
- SetDlgItemText(searchHandleDlg, IDC_INSTRUCTIONS, TranslateW(XmlGetText(chNode)));
- else if (XmlGetName(chNode)) {
+ for (auto *chNode : TiXmlEnum(queryNode)) {
+ if (!mir_strcmpi(chNode->Name(), "instructions") && chNode->GetText())
+ SetDlgItemText(searchHandleDlg, IDC_INSTRUCTIONS, TranslateW(Utf2T(chNode->GetText())));
+ else if (chNode->Name()) {
Data *MyData = (Data*)malloc(sizeof(Data));
memset(MyData, 0, sizeof(Data));
- MyData->Label = mir_wstrdup(XmlGetName(chNode));
- MyData->Var = mir_wstrdup(XmlGetName(chNode));
- MyData->defValue = mir_wstrdup(XmlGetText(chNode));
+ MyData->Label = mir_utf8decodeW(chNode->Name());
+ MyData->Var = mir_utf8decodeW(chNode->Name());
+ MyData->defValue = mir_utf8decodeW(chNode->GetText());
MyData->Order = Order;
if (MyData->defValue) MyData->bReadOnly = TRUE;
PostMessage(searchHandleDlg, WM_USER + 10, FALSE, (LPARAM)MyData);
@@ -177,23 +173,24 @@ void CJabberProto::OnIqResultGetSearchFields(HXML iqNode, CJabberIqInfo*)
}
}
- const wchar_t *szFrom = XmlGetAttrValue(iqNode, L"from");
+ const char *szFrom = iqNode->Attribute("from");
if (szFrom)
SearchAddToRecent(szFrom, searchHandleDlg);
PostMessage(searchHandleDlg, WM_USER + 10, 0, 0);
ShowWindow(searchHandleDlg, SW_SHOW);
}
- else if (!mir_wstrcmp(type, L"error")) {
- const wchar_t *code = nullptr;
- const wchar_t *description = nullptr;
- wchar_t buff[255];
- HXML errorNode = XmlGetChild(iqNode, "error");
+ else if (!mir_strcmp(type, "error")) {
+ const char *code = "";
+ const char *description = "";
+ auto *errorNode = iqNode->FirstChildElement("error");
if (errorNode) {
- code = XmlGetAttrValue(errorNode, L"code");
- description = XmlGetText(errorNode);
+ code = errorNode->Attribute("code");
+ description = errorNode->GetText();
}
- mir_snwprintf(buff, TranslateT("Error %s %s\r\nPlease select other server"), code ? code : L"", description ? description : L"");
- SetDlgItemText(searchHandleDlg, IDC_INSTRUCTIONS, buff);
+
+ char buff[255];
+ mir_snprintf(buff, Translate("Error %s %s\r\nPlease select other server"), code, description);
+ SetDlgItemTextUtf(searchHandleDlg, IDC_INSTRUCTIONS, buff);
}
else SetDlgItemText(searchHandleDlg, IDC_INSTRUCTIONS, TranslateT("Error: unknown reply received\r\nPlease select other server"));
}
@@ -296,78 +293,68 @@ wchar_t* CopyKey(wchar_t* key)
////////////////////////////////////////////////////////////////////////////////
// Search field request result handler (XEP-0055. Examples 3, 8)
-void CJabberProto::OnIqResultAdvancedSearch(HXML iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultAdvancedSearch(const TiXmlElement *iqNode, CJabberIqInfo*)
{
- const wchar_t *type;
+ const char *type;
int id;
U_TCHAR_MAP mColumnsNames(10);
- LIST<void> SearchResults(2);
+ LIST<void> SearchResults(2);
- if (((id = JabberGetPacketID(iqNode)) == -1) || ((type = XmlGetAttrValue(iqNode, L"type")) == nullptr)) {
+ if (((id = JabberGetPacketID(iqNode)) == -1) || ((type = iqNode->Attribute("type")) == nullptr)) {
ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
return;
}
- if (!mir_wstrcmp(type, L"result")) {
- HXML queryNode = XmlGetNthChild(iqNode, L"query", 1);
- HXML xNode = XmlGetChildByTag(queryNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS);
+ if (!mir_strcmp(type, "result")) {
+ auto *queryNode = iqNode->FirstChildElement("query");
+ auto *xNode = XmlGetChildByTag(queryNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS);
if (xNode) {
- //1. Form search results info
- HXML reportNode = XmlGetNthChild(xNode, L"reported", 1);
- if (reportNode) {
- int i = 1;
- while (HXML fieldNode = XmlGetNthChild(reportNode, L"field", i++)) {
- wchar_t *var = (wchar_t*)XmlGetAttrValue(fieldNode, L"var");
- if (var) {
- wchar_t *Label = (wchar_t*)XmlGetAttrValue(fieldNode, L"label");
- mColumnsNames.insert(var, (Label != nullptr) ? Label : var);
- }
+ // 1. Form search results info
+ for (auto *fieldNode : TiXmlFilter(xNode->FirstChildElement("reported"), "field")) {
+ const char *var = fieldNode->Attribute("var");
+ if (var) {
+ Utf2T wszVar(var), wszLabel(fieldNode->Attribute("label"));
+ mColumnsNames.insert(wszVar, (wszLabel != nullptr) ? wszLabel: wszVar);
}
}
- int i = 1;
- HXML itemNode;
- while (itemNode = XmlGetNthChild(xNode, L"item", i++)) {
+ for (auto *itemNode : TiXmlFilter(xNode, "item")) {
U_TCHAR_MAP *pUserColumn = new U_TCHAR_MAP(10);
- int j = 1;
- while (HXML fieldNode = XmlGetNthChild(itemNode, L"field", j++)) {
- if (wchar_t* var = (wchar_t*)XmlGetAttrValue(fieldNode, L"var")) {
- if (wchar_t* Text = (wchar_t*)XmlGetText(XmlGetChild(fieldNode, L"value"))) {
- if (!mColumnsNames[var])
- mColumnsNames.insert(var, var);
- pUserColumn->insert(var, Text);
+ for (auto *fieldNode : TiXmlFilter(itemNode, "field")) {
+ if (const char* var = fieldNode->Attribute("var")) {
+ if (const char* Text = fieldNode->FirstChildElement("value")->GetText()) {
+ Utf2T wszVar(var), wszText(Text);
+ if (!mColumnsNames[wszVar])
+ mColumnsNames.insert(wszVar, wszVar);
+ pUserColumn->insert(wszVar, wszText);
}
}
}
- SearchResults.insert((void*)pUserColumn);
+ SearchResults.insert(pUserColumn);
}
}
else {
- //2. Field list search results info
- int i = 1;
- while (HXML itemNode = XmlGetNthChild(queryNode, L"item", i++)) {
+ // 2. Field list search results info
+ for (auto *itemNode : TiXmlFilter(queryNode, "item")) {
U_TCHAR_MAP *pUserColumn = new U_TCHAR_MAP(10);
- wchar_t *jid = (wchar_t*)XmlGetAttrValue(itemNode, L"jid");
+ Utf2T jid(itemNode->Attribute("jid"));
wchar_t *keyReturned;
mColumnsNames.insertCopyKey(L"jid", L"jid", &keyReturned, CopyKey, DestroyKey);
mColumnsNames.insert(L"jid", keyReturned);
pUserColumn->insertCopyKey(L"jid", jid, nullptr, CopyKey, DestroyKey);
- for (int j = 0;; j++) {
- HXML child = XmlGetChild(itemNode, j);
- if (!child)
- break;
-
- const wchar_t *szColumnName = XmlGetName(child);
+ for (auto *child : TiXmlEnum(itemNode)) {
+ const char *szColumnName = child->Name();
if (szColumnName) {
- const wchar_t *ptszChild = XmlGetText(child);
- if (ptszChild && *ptszChild) {
- mColumnsNames.insertCopyKey((wchar_t*)szColumnName, L"", &keyReturned, CopyKey, DestroyKey);
- mColumnsNames.insert((wchar_t*)szColumnName, keyReturned);
- pUserColumn->insertCopyKey((wchar_t*)szColumnName, (wchar_t*)ptszChild, nullptr, CopyKey, DestroyKey);
+ const char *pszChild = child->GetText();
+ if (pszChild && *pszChild) {
+ Utf2T wszVar(szColumnName), wszText(pszChild);
+ mColumnsNames.insertCopyKey(wszVar, L"", &keyReturned, CopyKey, DestroyKey);
+ mColumnsNames.insert(wszVar, keyReturned);
+ pUserColumn->insertCopyKey(wszVar, wszText, nullptr, CopyKey, DestroyKey);
}
}
}
@@ -376,22 +363,23 @@ void CJabberProto::OnIqResultAdvancedSearch(HXML iqNode, CJabberIqInfo*)
}
}
}
- else if (!mir_wstrcmp(type, L"error")) {
- const wchar_t *code = nullptr;
- const wchar_t *description = nullptr;
- wchar_t buff[255];
- HXML errorNode = XmlGetChild(iqNode, "error");
+ else if (!mir_strcmp(type, "error")) {
+ const char *code = "";
+ const char *description = "";
+ auto *errorNode = iqNode->FirstChildElement("error");
if (errorNode) {
- code = XmlGetAttrValue(errorNode, L"code");
- description = XmlGetText(errorNode);
+ code = errorNode->Attribute("code");
+ description = errorNode->GetText();
}
- mir_snwprintf(buff, TranslateT("Error %s %s\r\nTry to specify more detailed"), code ? code : L"", description ? description : L"");
ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
+
+ char buff[255];
+ mir_snprintf(buff, Translate("Error %s %s\r\nTry to specify more detailed"), code, description);
if (searchHandleDlg)
- SetDlgItemText(searchHandleDlg, IDC_INSTRUCTIONS, buff);
+ SetDlgItemTextUtf(searchHandleDlg, IDC_INSTRUCTIONS, buff);
else
- MessageBox(nullptr, buff, TranslateT("Search error"), MB_OK | MB_ICONSTOP);
+ MessageBox(nullptr, Utf2T(buff), TranslateT("Search error"), MB_OK | MB_ICONSTOP);
return;
}
@@ -428,9 +416,6 @@ static void JabberSearchFreeData(HWND hwndDlg, JabberSearchData * dat)
}
else EnumChildWindows(GetDlgItem(hwndDlg, IDC_FRAME), DeleteChildWindowsProc, 0);
- if (dat->xNode)
- xmlDestroyNode(dat->xNode);
-
SendDlgItemMessage(hwndDlg, IDC_FRAME, WM_SETFONT, (WPARAM)SendMessage(hwndDlg, WM_GETFONT, 0, 0), 0);
dat->nJSInfCount = 0;
ShowWindow(GetDlgItem(hwndDlg, IDC_VSCROLL), SW_HIDE);
@@ -473,8 +458,8 @@ int CJabberProto::SearchRenewFields(HWND hwndDlg, JabberSearchData *dat)
searchHandleDlg = hwndDlg;
- CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultGetSearchFields, JABBER_IQ_TYPE_GET, szServerName);
- m_ThreadInfo->send(XmlNodeIq(pInfo) << XQUERY(L"jabber:iq:search"));
+ CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultGetSearchFields, JABBER_IQ_TYPE_GET, T2Utf(szServerName));
+ m_ThreadInfo->send(XmlNodeIq(pInfo) << XQUERY("jabber:iq:search"));
return pInfo->GetIqId();
}
@@ -485,22 +470,22 @@ static void JabberSearchAddUrlToRecentCombo(HWND hwndDlg, const wchar_t *szAddr)
SendDlgItemMessage(hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, (LPARAM)szAddr);
}
-void CJabberProto::SearchDeleteFromRecent(const wchar_t *szAddr, bool deleteLastFromDB)
+void CJabberProto::SearchDeleteFromRecent(const char *szAddr, bool deleteLastFromDB)
{
// search in recent
for (int i = 0; i < 10; i++) {
char key[30];
mir_snprintf(key, "RecentlySearched_%d", i);
- ptrW szValue(getWStringA(key));
- if (szValue == nullptr || mir_wstrcmpi(szAddr, szValue))
+ ptrA szValue(getUStringA(key));
+ if (szValue == nullptr || mir_strcmpi(szAddr, szValue))
continue;
for (int j = i; j < 10; j++) {
mir_snprintf(key, "RecentlySearched_%d", j + 1);
- szValue = getWStringA(key);
+ szValue = getUStringA(key);
if (szValue != nullptr) {
mir_snprintf(key, "RecentlySearched_%d", j);
- setWString(0, key, szValue);
+ setUString(0, key, szValue);
}
else {
if (deleteLastFromDB) {
@@ -514,7 +499,7 @@ void CJabberProto::SearchDeleteFromRecent(const wchar_t *szAddr, bool deleteLast
}
}
-void CJabberProto::SearchAddToRecent(const wchar_t *szAddr, HWND hwndDialog)
+void CJabberProto::SearchAddToRecent(const char *szAddr, HWND hwndDialog)
{
char key[30];
SearchDeleteFromRecent(szAddr, true);
@@ -529,9 +514,9 @@ void CJabberProto::SearchAddToRecent(const wchar_t *szAddr, HWND hwndDialog)
}
mir_snprintf(key, "RecentlySearched_%d", 0);
- setWString(key, szAddr);
+ setUString(key, szAddr);
if (hwndDialog)
- JabberSearchAddUrlToRecentCombo(hwndDialog, szAddr);
+ JabberSearchAddUrlToRecentCombo(hwndDialog, Utf2T(szAddr));
}
static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -541,7 +526,7 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
{
- dat = (JabberSearchData *)mir_calloc(sizeof(JabberSearchData));
+ dat = new JabberSearchData();
dat->ppro = (CJabberProto*)lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
@@ -553,7 +538,7 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR
//TO DO: Add Transports here
for (auto &it : dat->ppro->m_lstTransports)
if (it != nullptr)
- JabberSearchAddUrlToRecentCombo(hwndDlg, it);
+ JabberSearchAddUrlToRecentCombo(hwndDlg, Utf2T(it));
for (int i = 0; i < 10; i++) {
char key[30];
@@ -614,8 +599,15 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR
case WM_USER + 11:
{
dat->fSearchRequestIsXForm = TRUE;
- dat->xNode = (HXML)wParam;
- JabberFormCreateUI(GetDlgItem(hwndDlg, IDC_FRAME), dat->xNode, &dat->CurrentHeight, TRUE);
+ if (dat->xNode) {
+ dat->doc.DeleteNode(dat->xNode);
+ dat->xNode = nullptr;
+ }
+ TiXmlElement *pNode = (TiXmlElement*)wParam;
+ if (pNode) {
+ dat->xNode = pNode->DeepClone(&dat->doc)->ToElement();
+ JabberFormCreateUI(GetDlgItem(hwndDlg, IDC_FRAME), dat->xNode, &dat->CurrentHeight, TRUE);
+ }
ShowWindow(GetDlgItem(hwndDlg, IDC_FRAME), SW_SHOW);
dat->nJSInfCount = 1;
}
@@ -698,7 +690,7 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR
case WM_DESTROY:
JabberSearchFreeData(hwndDlg, dat);
JabberFormDestroyUI(GetDlgItem(hwndDlg, IDC_FRAME));
- mir_free(dat);
+ delete dat;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
return TRUE;
}
@@ -740,27 +732,26 @@ HWND CJabberProto::SearchAdvanced(HWND hwndDlg)
GetDlgItemText(hwndDlg, IDC_SERVER, szServerName, _countof(szServerName));
// formating query
- CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultAdvancedSearch, JABBER_IQ_TYPE_SET, szServerName);
+ CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultAdvancedSearch, JABBER_IQ_TYPE_SET, T2Utf(szServerName));
XmlNodeIq iq(pInfo);
- HXML query = iq << XQUERY(L"jabber:iq:search");
+ TiXmlElement *query = iq << XQUERY("jabber:iq:search");
if (m_tszSelectedLang)
- iq << XATTR(L"xml:lang", m_tszSelectedLang); // i'm sure :)
+ iq << XATTR("xml:lang", m_tszSelectedLang); // i'm sure :)
// next can be 2 cases:
// Forms: XEP-0055 Example 7
if (dat->fSearchRequestIsXForm) {
fRequestNotEmpty = TRUE;
- HXML n = JabberFormGetData(GetDlgItem(hwndDlg, IDC_FRAME), dat->xNode);
- XmlAddChild(query, n);
- xmlDestroyNode(n);
+ TiXmlElement *n = JabberFormGetData(GetDlgItem(hwndDlg, IDC_FRAME), &iq, dat->xNode);
+ query->InsertEndChild(n);
}
else { //and Simple fields: XEP-0055 Example 3
for (int i = 0; i < dat->nJSInfCount; i++) {
wchar_t szFieldValue[100];
GetWindowText(dat->pJSInf[i].hwndValueItem, szFieldValue, _countof(szFieldValue));
if (szFieldValue[0] != 0) {
- XmlAddChild(query, dat->pJSInf[i].szFieldName, szFieldValue);
+ XmlAddChild(query, T2Utf(dat->pJSInf[i].szFieldName), T2Utf(szFieldValue));
fRequestNotEmpty = TRUE;
}
}
diff --git a/protocols/JabberG/src/jabber_search.h b/protocols/JabberG/src/jabber_search.h
index 887c1bff9b..49fc5a2d01 100644
--- a/protocols/JabberG/src/jabber_search.h
+++ b/protocols/JabberG/src/jabber_search.h
@@ -28,19 +28,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#pragma once
-typedef struct _tagJabberSearchFieldsInfo
+struct JabberSearchFieldsInfo
{
wchar_t * szFieldName;
wchar_t * szFieldCaption;
HWND hwndCaptionItem;
HWND hwndValueItem;
-} JabberSearchFieldsInfo;
+};
-typedef struct _tagJabberSearchData
+struct JabberSearchData : public MZeroedObject
{
struct CJabberProto *ppro;
- JabberSearchFieldsInfo * pJSInf;
- HXML xNode;
+ JabberSearchFieldsInfo *pJSInf;
+ TiXmlDocument doc;
+ TiXmlElement *xNode;
int nJSInfCount;
int lastRequestIq;
int CurrentHeight;
@@ -48,10 +49,9 @@ typedef struct _tagJabberSearchData
int frameHeight;
RECT frameRect;
BOOL fSearchRequestIsXForm;
+};
-}JabberSearchData;
-
-typedef struct tag_Data
+struct Data
{
wchar_t *Label;
wchar_t * Var;
@@ -60,20 +60,10 @@ typedef struct tag_Data
BOOL bReadOnly;
int Order;
-} Data;
+};
static HWND searchHandleDlg = nullptr;
-//local functions declarations
-static int JabberSearchFrameProc(HWND hwnd, int msg, WPARAM wParam, LPARAM lParam);
-static int JabberSearchAddField(HWND hwndDlg, Data* FieldDat);
-static void JabberIqResultGetSearchFields(HXML iqNode, void *userdata);
-static void JabberSearchFreeData(HWND hwndDlg, JabberSearchData * dat);
-static void JabberSearchRefreshFrameScroll(HWND hwndDlg, JabberSearchData * dat);
-static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-static void JabberSearchDeleteFromRecent(wchar_t * szAddr, BOOL deleteLastFromDB);
-void SearchAddToRecent(wchar_t * szAddr, HWND hwnd);
-
// Implementation of MAP class (the list
template <typename _KEYTYPE, int(*COMPARATOR)(_KEYTYPE*, _KEYTYPE*) >
class UNIQUE_MAP
@@ -103,7 +93,7 @@ private:
int _nextOrder;
LIST<_RECORD> _Records;
- static int _KeysEqual(const _RECORD* p1, const _RECORD* p2)
+ static int _KeysEqual(const _RECORD *p1, const _RECORD *p2)
{
if (COMPARATOR)
return (int)(COMPARATOR((p1->_key), (p2->_key)));
@@ -253,3 +243,8 @@ inline int TCharKeyCmp(wchar_t* a, wchar_t* b)
{
return (int)(mir_wstrcmpi(a, b));
}
+
+inline int CharKeyCmp(char *a, char *b)
+{
+ return mir_strcmpi(a, b);
+}
diff --git a/protocols/JabberG/src/jabber_secur.cpp b/protocols/JabberG/src/jabber_secur.cpp
index d932e97103..5d807f51d6 100644
--- a/protocols/JabberG/src/jabber_secur.cpp
+++ b/protocols/JabberG/src/jabber_secur.cpp
@@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/////////////////////////////////////////////////////////////////////////////////////////
// ntlm auth - LanServer based authorization
-TNtlmAuth::TNtlmAuth(ThreadData *info, const char *mechanism, const wchar_t *hostname) :
+TNtlmAuth::TNtlmAuth(ThreadData *info, const char *mechanism, const char *hostname) :
TJabberAuth(info)
{
szName = mechanism;
@@ -106,19 +106,19 @@ char* TNtlmAuth::getInitialRequest()
// This generates login method advertisement packet
if (info->conn.password[0] != 0)
- return Netlib_NtlmCreateResponse(hProvider, "", info->conn.username, info->conn.password, complete);
+ return Netlib_NtlmCreateResponse(hProvider, "", Utf2T(info->conn.username), Utf2T(info->conn.password), complete);
return Netlib_NtlmCreateResponse(hProvider, "", nullptr, nullptr, complete);
}
-char* TNtlmAuth::getChallenge(const wchar_t *challenge)
+char* TNtlmAuth::getChallenge(const char *challenge)
{
if (!hProvider)
return nullptr;
- ptrA text((!mir_wstrcmp(challenge, L"=")) ? mir_strdup("") : mir_u2a(challenge));
+ const char *text((!mir_strcmp(challenge, "=")) ? "" : challenge);
if (info->conn.password[0] != 0)
- return Netlib_NtlmCreateResponse(hProvider, text, info->conn.username, info->conn.password, complete);
+ return Netlib_NtlmCreateResponse(hProvider, text, Utf2T(info->conn.username), Utf2T(info->conn.password), complete);
return Netlib_NtlmCreateResponse(hProvider, text, nullptr, nullptr, complete);
}
@@ -137,7 +137,7 @@ TMD5Auth::~TMD5Auth()
{
}
-char* TMD5Auth::getChallenge(const wchar_t *challenge)
+char* TMD5Auth::getChallenge(const char *challenge)
{
if (iCallCount > 0)
return nullptr;
@@ -145,7 +145,7 @@ char* TMD5Auth::getChallenge(const wchar_t *challenge)
iCallCount++;
size_t resultLen;
- ptrA text((char*)mir_base64_decode( _T2A(challenge), &resultLen));
+ ptrA text((char*)mir_base64_decode(challenge, &resultLen));
TStringPairs pairs(text);
const char *realm = pairs["realm"], *nonce = pairs["nonce"];
@@ -157,15 +157,14 @@ char* TMD5Auth::getChallenge(const wchar_t *challenge)
Utils_GetRandom(digest, sizeof(digest));
mir_snprintf(cnonce, "%08x%08x%08x%08x", htonl(digest[0]), htonl(digest[1]), htonl(digest[2]), htonl(digest[3]));
- T2Utf uname(info->conn.username), passw(info->conn.password);
- ptrA serv(mir_utf8encode(info->conn.server));
+ ptrA serv(mir_utf8encode(info->conn.server));
mir_md5_init(&ctx);
- mir_md5_append(&ctx, (BYTE*)(char*)uname, (int)mir_strlen(uname));
+ mir_md5_append(&ctx, (BYTE*)info->conn.username, (int)mir_strlen(info->conn.username));
mir_md5_append(&ctx, (BYTE*)":", 1);
mir_md5_append(&ctx, (BYTE*)realm, (int)mir_strlen(realm));
mir_md5_append(&ctx, (BYTE*)":", 1);
- mir_md5_append(&ctx, (BYTE*)(char*)passw, (int)mir_strlen(passw));
+ mir_md5_append(&ctx, (BYTE*)info->conn.password, (int)mir_strlen(info->conn.password));
mir_md5_finish(&ctx, (BYTE*)hash1);
mir_md5_init(&ctx);
@@ -198,7 +197,7 @@ char* TMD5Auth::getChallenge(const wchar_t *challenge)
int cbLen = mir_snprintf(buf, 8000,
"username=\"%s\",realm=\"%s\",nonce=\"%s\",cnonce=\"%s\",nc=%08d,"
"qop=auth,digest-uri=\"xmpp/%s\",charset=utf-8,response=%08x%08x%08x%08x",
- uname, realm, nonce, cnonce, iCallCount, serv,
+ info->conn.username, realm, nonce, cnonce, iCallCount, serv,
htonl(digest[0]), htonl(digest[1]), htonl(digest[2]), htonl(digest[3]));
return mir_base64_encode(buf, cbLen);
@@ -231,7 +230,7 @@ void TScramAuth::Hi(BYTE* res, char* passw, size_t passwLen, char* salt, size_t
for (int i = 0; i < ind; i++) {
unsigned int len;
- HMAC(EVP_sha1(), (BYTE*)passw, passwLen, u, bufLen, u, &len);
+ HMAC(EVP_sha1(), (BYTE*)passw, (unsigned)passwLen, u, (unsigned)bufLen, u, &len);
bufLen = MIR_SHA1_HASH_SIZE;
for (unsigned j = 0; j < MIR_SHA1_HASH_SIZE; j++)
@@ -239,13 +238,13 @@ void TScramAuth::Hi(BYTE* res, char* passw, size_t passwLen, char* salt, size_t
}
}
-char* TScramAuth::getChallenge(const wchar_t *challenge)
+char* TScramAuth::getChallenge(const char *challenge)
{
size_t chlLen, saltLen = 0;
ptrA snonce, salt;
int ind = -1;
- ptrA chl((char*)mir_base64_decode(_T2A(challenge), &chlLen));
+ ptrA chl((char*)mir_base64_decode(challenge, &chlLen));
for (char *p = strtok(NEWSTR_ALLOCA(chl), ","); p != nullptr; p = strtok(nullptr, ",")) {
if (*p == 'r' && p[1] == '=') { // snonce
@@ -262,11 +261,8 @@ char* TScramAuth::getChallenge(const wchar_t *challenge)
if (snonce == nullptr || salt == nullptr || ind == -1)
return nullptr;
- ptrA passw(mir_utf8encodeW(info->conn.password));
- size_t passwLen = mir_strlen(passw);
-
BYTE saltedPassw[MIR_SHA1_HASH_SIZE];
- Hi(saltedPassw, passw, passwLen, salt, saltLen, ind);
+ Hi(saltedPassw, info->conn.password, mir_strlen(info->conn.password), salt, saltLen, ind);
BYTE clientKey[MIR_SHA1_HASH_SIZE];
unsigned int len;
@@ -305,22 +301,20 @@ char* TScramAuth::getChallenge(const wchar_t *challenge)
char* TScramAuth::getInitialRequest()
{
- T2Utf uname(info->conn.username);
-
unsigned char nonce[24];
Utils_GetRandom(nonce, sizeof(nonce));
cnonce = mir_base64_encode(nonce, sizeof(nonce));
char buf[4096];
- int cbLen = mir_snprintf(buf, "n,,n=%s,r=%s", uname, cnonce);
+ int cbLen = mir_snprintf(buf, "n,,n=%s,r=%s", info->conn.username, cnonce);
msg1 = mir_strdup(buf + 3);
return mir_base64_encode(buf, cbLen);
}
-bool TScramAuth::validateLogin(const wchar_t *challenge)
+bool TScramAuth::validateLogin(const char *challenge)
{
size_t chlLen;
- ptrA chl((char*)mir_base64_decode(_T2A(challenge), &chlLen));
+ ptrA chl((char*)mir_base64_decode(challenge, &chlLen));
return chl && strncmp((char*)chl + 2, serverSignature, chlLen - 2) == 0;
}
@@ -340,16 +334,13 @@ TPlainAuth::~TPlainAuth()
char* TPlainAuth::getInitialRequest()
{
- 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);
+ CMStringA buf;
if (bOld)
- size = mir_snprintf(toEncode, size, "%s@%s%c%s%c%s", uname, info->conn.server, 0, uname, 0, passw);
+ buf.Format("%s@%s%c%s%c%s", info->conn.username, info->conn.server, 0, info->conn.username, 0, info->conn.password);
else
- size = mir_snprintf(toEncode, size, "%c%s%c%s", 0, uname, 0, passw);
+ buf.Format("%c%s%c%s", 0, info->conn.username, 0, info->conn.password);
- return mir_base64_encode(toEncode, size);
+ return mir_base64_encode(buf, buf.GetLength());
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -372,12 +363,12 @@ char* TJabberAuth::getInitialRequest()
return nullptr;
}
-char* TJabberAuth::getChallenge(const wchar_t*)
+char* TJabberAuth::getChallenge(const char*)
{
return nullptr;
}
-bool TJabberAuth::validateLogin(const wchar_t*)
+bool TJabberAuth::validateLogin(const char*)
{
return true;
}
diff --git a/protocols/JabberG/src/jabber_secur.h b/protocols/JabberG/src/jabber_secur.h
index 1b6944448a..719f4eda74 100644
--- a/protocols/JabberG/src/jabber_secur.h
+++ b/protocols/JabberG/src/jabber_secur.h
@@ -39,8 +39,8 @@ public:
virtual ~TJabberAuth();
virtual char* getInitialRequest();
- virtual char* getChallenge(const wchar_t *challenge);
- virtual bool validateLogin(const wchar_t *challenge);
+ virtual char* getChallenge(const char *challenge);
+ virtual bool validateLogin(const char *challenge);
inline const char* getName() const
{ return szName;
@@ -77,7 +77,7 @@ public:
TMD5Auth(ThreadData*);
virtual ~TMD5Auth();
- virtual char* getChallenge(const wchar_t *challenge);
+ virtual char* getChallenge(const char *challenge);
};
class TScramAuth : public TJabberAuth
@@ -90,8 +90,8 @@ public:
virtual ~TScramAuth();
virtual char* getInitialRequest();
- virtual char* getChallenge(const wchar_t *challenge);
- virtual bool validateLogin(const wchar_t *challenge);
+ virtual char* getChallenge(const char *challenge);
+ virtual bool validateLogin(const char *challenge);
void Hi(BYTE* res , char* passw, size_t passwLen, char* salt, size_t saltLen, int ind);
};
@@ -103,13 +103,13 @@ class TNtlmAuth : public TJabberAuth
typedef TJabberAuth CSuper;
HANDLE hProvider;
- const wchar_t *szHostName;
+ const char *szHostName;
public:
- TNtlmAuth(ThreadData*, const char* mechanism, const wchar_t *hostname = nullptr);
+ TNtlmAuth(ThreadData*, const char* mechanism, const char *hostname = nullptr);
virtual ~TNtlmAuth();
virtual char* getInitialRequest();
- virtual char* getChallenge(const wchar_t *challenge);
+ virtual char* getChallenge(const char *challenge);
bool getSpn(wchar_t* szSpn, size_t dwSpnLen);
};
diff --git a/protocols/JabberG/src/jabber_send_manager.cpp b/protocols/JabberG/src/jabber_send_manager.cpp
index 82da06c7ca..656c1a492e 100644
--- a/protocols/JabberG/src/jabber_send_manager.cpp
+++ b/protocols/JabberG/src/jabber_send_manager.cpp
@@ -60,7 +60,7 @@ bool CJabberSendManager::DeletePermanentHandler(CJabberSendPermanentInfo *pInfo)
return m_arHandlers.remove(pInfo) == 1;
}
-bool CJabberSendManager::HandleSendPermanent(HXML node, ThreadData *pThreadData)
+bool CJabberSendManager::HandleSendPermanent(TiXmlElement *node, ThreadData *pThreadData)
{
for (auto &pInfo : m_arHandlers) {
CJabberSendInfo sendInfo;
diff --git a/protocols/JabberG/src/jabber_send_manager.h b/protocols/JabberG/src/jabber_send_manager.h
index 99da9ee560..0026896325 100644
--- a/protocols/JabberG/src/jabber_send_manager.h
+++ b/protocols/JabberG/src/jabber_send_manager.h
@@ -30,12 +30,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "jabber_xml.h"
struct CJabberProto;
-typedef void (CJabberProto::*JABBER_SEND_PFUNC)(HXML node, void *usedata);
+typedef void (CJabberProto::*JABBER_SEND_PFUNC)(const TiXmlElement *node, void *usedata);
typedef void (*SEND_USER_DATA_FREE_FUNC)(void *pUserData);
class CJabberSendInfo;
-typedef BOOL (CJabberProto::*JABBER_SEND_HANDLER)(HXML node, ThreadData *pThreadData, CJabberSendInfo* pInfo);
+typedef BOOL (CJabberProto::*JABBER_SEND_HANDLER)(const TiXmlElement *node, ThreadData *pThreadData, CJabberSendInfo* pInfo);
class CJabberSendInfo
{
@@ -99,7 +99,7 @@ public:
CJabberSendPermanentInfo* AddPermanentHandler(JABBER_SEND_HANDLER pHandler, void *pUserData = nullptr, SEND_USER_DATA_FREE_FUNC pUserDataFree = nullptr, int iPriority = JH_PRIORITY_DEFAULT);
bool DeletePermanentHandler(CJabberSendPermanentInfo *pInfo);
- bool HandleSendPermanent(HXML node, ThreadData *pThreadData);
+ bool HandleSendPermanent(TiXmlElement *node, ThreadData *pThreadData);
};
#endif
diff --git a/protocols/JabberG/src/jabber_std.cpp b/protocols/JabberG/src/jabber_std.cpp
deleted file mode 100644
index 4c0b21bdc7..0000000000
--- a/protocols/JabberG/src/jabber_std.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-
-Jabber Protocol Plugin for Miranda NG
-
-Copyright (c) 2002-04 Santithorn Bunchua
-Copyright (c) 2005-12 George Hazan
-Copyright (C) 2012-19 Miranda NG team
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-
-#include "stdafx.h"
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-void CJabberProto::JLoginFailed(int errorCode)
-{
- m_savedPassword = nullptr;
- ProtoBroadcastAck(0, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, errorCode);
-}
diff --git a/protocols/JabberG/src/jabber_strm_mgmt.cpp b/protocols/JabberG/src/jabber_strm_mgmt.cpp
index 0e09b50863..0d75f9e8fd 100755
--- a/protocols/JabberG/src/jabber_strm_mgmt.cpp
+++ b/protocols/JabberG/src/jabber_strm_mgmt.cpp
@@ -23,27 +23,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
#include "jabber_strm_mgmt.h"
-strm_mgmt::strm_mgmt(CJabberProto *_proto) : proto(_proto), m_bStrmMgmtPendingEnable(false),
-m_bStrmMgmtEnabled(false),
-m_bStrmMgmtResumeSupported(false),
-bSessionResumed(false)
+strm_mgmt::strm_mgmt(CJabberProto *_proto) :
+ proto(_proto)
{
-
}
-void strm_mgmt::OnProcessEnabled(HXML node, ThreadData * /*info*/)
+void strm_mgmt::OnProcessEnabled(const TiXmlElement *node, ThreadData * /*info*/)
{
m_bStrmMgmtEnabled = true;
- auto val = XmlGetAttrValue(node, L"max");
- if(val)
- m_nStrmMgmtResumeMaxSeconds = _wtoi(val);
- val = XmlGetAttrValue(node, L"resume");
+ auto *val = node->Attribute("max");
if (val)
- {
- if (mir_wstrcmp(val, L"true") || mir_wstrcmp(val, L"1"))
- {
+ m_nStrmMgmtResumeMaxSeconds = atoi(val);
+ val = node->Attribute("resume");
+ if (val) {
+ if (mir_strcmp(val, "true") || mir_strcmp(val, "1")) {
m_bStrmMgmtResumeSupported = true;
- m_sStrmMgmtResumeId = XmlGetAttrValue(node, L"id");
+ m_sStrmMgmtResumeId = node->Attribute("id");
}
}
//TODO: handle 'location'
@@ -51,30 +46,29 @@ void strm_mgmt::OnProcessEnabled(HXML node, ThreadData * /*info*/)
m_nStrmMgmtSrvHCount = 0;
}
-void strm_mgmt::OnProcessResumed(HXML node, ThreadData * /*info*/)
+void strm_mgmt::OnProcessResumed(const TiXmlElement *node, ThreadData * /*info*/)
{
- if (mir_wstrcmp(XmlGetAttrValue(node, L"xmlns"), L"urn:xmpp:sm:3"))
+ if (mir_strcmp(node->Attribute("xmlns"), "urn:xmpp:sm:3"))
return;
- auto var = XmlGetAttrValue(node, L"previd");
+ auto *var = node->Attribute("previd");
if (!var)
return;
if (m_sStrmMgmtResumeId != var)
return; //TODO: unknown session, what we should do ?
- var = XmlGetAttrValue(node, L"h");
+ var = node->Attribute("h");
if (!var)
return;
bSessionResumed = true;
m_bStrmMgmtEnabled = true;
m_bStrmMgmtPendingEnable = false;
- m_nStrmMgmtSrvHCount = _wtoi(var);
+ m_nStrmMgmtSrvHCount = atoi(var);
int size = m_nStrmMgmtLocalSCount - m_nStrmMgmtSrvHCount;
//FinishLoginProcess(info);
proto->OnLoggedIn();
proto->ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)proto->m_iStatus, proto->m_iDesiredStatus);
- if (size < 0)
- {
+ if (size < 0) {
proto->debugLogA("strm_mgmt: error: locally sent nodes count %d, server side received count %d", m_nStrmMgmtLocalSCount, m_nStrmMgmtSrvHCount);
m_nStrmMgmtLocalSCount = m_nStrmMgmtSrvHCount; //temporary workaround
//TODO: this should never happen, indicates server side bug
@@ -82,24 +76,22 @@ void strm_mgmt::OnProcessResumed(HXML node, ThreadData * /*info*/)
}
else if (size > 0 && !NodeCache.empty()) //TODO: NodeCache cannot be empty if size >0, it's a bug
ResendNodes(size);
- else
- {
+ else {
for (auto i : NodeCache)
- xmlFree(i);
+ xmlStorage.DeleteNode(i);
NodeCache.clear();
}
}
-void strm_mgmt::OnProcessSMa(HXML node)
+void strm_mgmt::OnProcessSMa(const TiXmlElement *node)
{
- if (mir_wstrcmp(XmlGetAttrValue(node, L"xmlns"), L"urn:xmpp:sm:3"))
+ if (mir_strcmp(node->Attribute("xmlns"), "urn:xmpp:sm:3"))
return;
- auto val = XmlGetAttrValue(node, L"h");
- m_nStrmMgmtSrvHCount = _wtoi(val);
+
+ m_nStrmMgmtSrvHCount = node->IntAttribute("h");
proto->debugLogA("strm_mgmt: info: locally sent nodes count %d, server side received count %d", m_nStrmMgmtLocalSCount, m_nStrmMgmtSrvHCount);
int size = m_nStrmMgmtLocalSCount - m_nStrmMgmtSrvHCount;
- if (size < 0)
- {
+ if (size < 0) {
proto->debugLogA("strm_mgmt: error: locally sent nodes count %d, server side received count %d", m_nStrmMgmtLocalSCount, m_nStrmMgmtSrvHCount);
m_nStrmMgmtLocalSCount = m_nStrmMgmtSrvHCount; //temporary workaround
//TODO: this should never happen, indicates server side bug
@@ -107,10 +99,9 @@ void strm_mgmt::OnProcessSMa(HXML node)
}
else if (size > 0 && !NodeCache.empty()) //TODO: NodeCache cannot be empty if size >0, it's a bug
ResendNodes(size);
- else
- {
+ else {
for (auto i : NodeCache)
- xmlFree(i);
+ xmlStorage.DeleteNode(i);
NodeCache.clear();
}
}
@@ -118,50 +109,42 @@ void strm_mgmt::OnProcessSMa(HXML node)
void strm_mgmt::ResendNodes(uint32_t size)
{
proto->debugLogA("strm_mgmt: info: resending %d missed nodes", size);
- if (size < NodeCache.size())
- {
+ if (size < NodeCache.size()) {
proto->debugLogA("strm_mgmt: info: resending nodes: need to resend %d nodes, nodes in cache %d, cleaning cache to match resending node count", size, NodeCache.size());
const size_t diff = NodeCache.size() - size;
- if (diff)
- {
+ if (diff) {
size_t diff_tmp = diff;
- for (auto i : NodeCache)
- {
- if (diff_tmp > 0)
- {
- xmlFree(i);
+ for (auto i : NodeCache) {
+ if (diff_tmp > 0) {
+ xmlStorage.DeleteNode(i);
diff_tmp--;
}
}
diff_tmp = diff;
- while (diff_tmp)
- {
+ while (diff_tmp) {
NodeCache.pop_front();
diff_tmp--;
}
}
}
- std::list<HXML> tmp_list = NodeCache;
+ std::list<TiXmlElement*> tmp_list = NodeCache;
NodeCache.clear();
m_nStrmMgmtLocalSCount = m_nStrmMgmtSrvHCount; //we have handled missed nodes, set our counter to match server side value
for (auto i : tmp_list)
- {
proto->m_ThreadInfo->send(i);
- //proto->m_ThreadInfo->send_no_strm_mgmt(i); //freed by send ?
- //xmlFree(i);
- }
}
-void strm_mgmt::OnProcessSMr(HXML node)
+void strm_mgmt::OnProcessSMr(const TiXmlElement *node)
{
- if (!mir_wstrcmp(XmlGetAttrValue(node, L"xmlns"), L"urn:xmpp:sm:3"))
+ if (!mir_strcmp(node->Attribute("xmlns"), "urn:xmpp:sm:3"))
SendAck();
}
-void strm_mgmt::OnProcessFailed(HXML node, ThreadData * info) //used failed instead of failure, notes: https://xmpp.org/extensions/xep-0198.html#errors
+void strm_mgmt::OnProcessFailed(const TiXmlElement *node, ThreadData * info) //used failed instead of failure, notes: https://xmpp.org/extensions/xep-0198.html#errors
{
- if (mir_wstrcmp(XmlGetAttrValue(node, L"xmlns"), L"urn:xmpp:sm:3"))
+ if (mir_strcmp(node->Attribute("xmlns"), "urn:xmpp:sm:3"))
return;
+
proto->debugLogW(L"strm_mgmt: error: Failed to resume session %s", m_sStrmMgmtResumeId.c_str());
m_bStrmMgmtEnabled = false;
@@ -172,23 +155,19 @@ void strm_mgmt::OnProcessFailed(HXML node, ThreadData * info) //used failed inst
for (auto &hContact : proto->AccContacts())
proto->SetContactOfflineStatus(hContact);
- {
- HXML subnode = XmlGetChild(node, L"item-not-found");
- if (subnode)
- {
- m_bStrmMgmtPendingEnable = true;
- FinishLoginProcess(info);
- }
- else
- EnableStrmMgmt(); //resume failed, try to enable strm_mgmt instead
+ auto *subnode = node->FirstChildElement("item-not-found");
+ if (subnode) {
+ m_bStrmMgmtPendingEnable = true;
+ FinishLoginProcess(info);
}
+ else EnableStrmMgmt(); //resume failed, try to enable strm_mgmt instead
}
-void strm_mgmt::CheckStreamFeatures(HXML node)
+void strm_mgmt::CheckStreamFeatures(const TiXmlElement *node)
{
if (!IsResumeIdPresent())
ResetState(); //this may be necessary to reset counters if session resume id is not set
- if (mir_wstrcmp(XmlGetName(node), L"sm") || !XmlGetAttrValue(node, L"xmlns") || mir_wstrcmp(XmlGetAttrValue(node, L"xmlns"), L"urn:xmpp:sm:3")) //we work only with version 3 or higher of sm
+ if (mir_strcmp(node->Name(), "sm") || !node->Attribute("xmlns") || mir_strcmp(node->Attribute("xmlns"), "urn:xmpp:sm:3")) //we work only with version 3 or higher of sm
return;
if (!(proto->m_bJabberOnline))
m_bStrmMgmtPendingEnable = true;
@@ -205,12 +184,12 @@ void strm_mgmt::CheckState()
EnableStrmMgmt();
}
-void strm_mgmt::HandleOutgoingNode(HXML node)
+void strm_mgmt::HandleOutgoingNode(TiXmlElement *node)
{
if (!m_bStrmMgmtEnabled)
return;
m_nStrmMgmtLocalSCount++;
- NodeCache.push_back(xmlCopyNode(node));
+ NodeCache.push_back(node->DeepClone(&xmlStorage)->ToElement());
if ((m_nStrmMgmtLocalSCount - m_nStrmMgmtSrvHCount) >= m_nStrmMgmtCacheSize)
RequestAck();
}
@@ -226,13 +205,13 @@ void strm_mgmt::ResetState()
m_sStrmMgmtResumeId.clear();
}
-void strm_mgmt::HandleIncommingNode(HXML node)
+void strm_mgmt::HandleIncommingNode(const TiXmlElement *node)
{
- if (m_bStrmMgmtEnabled && mir_wstrcmp(XmlGetName(node), L"r") && mir_wstrcmp(XmlGetName(node), L"a")) //TODO: something better
+ if (m_bStrmMgmtEnabled && mir_strcmp(node->Name(), "r") && mir_strcmp(node->Name(), "a")) //TODO: something better
m_nStrmMgmtLocalHCount++;
- else if (!mir_wstrcmp(XmlGetName(node), L"r"))
+ else if (!mir_strcmp(node->Name(), "r"))
OnProcessSMr(node);
- else if (!mir_wstrcmp(XmlGetName(node), L"a"))
+ else if (!mir_strcmp(node->Name(), "a"))
OnProcessSMa(node);
}
@@ -240,20 +219,17 @@ void strm_mgmt::EnableStrmMgmt()
{
if (m_bStrmMgmtEnabled)
return;
- if (m_sStrmMgmtResumeId.empty())
- {
- XmlNode enable_sm(L"enable");
- XmlAddAttr(enable_sm, L"xmlns", L"urn:xmpp:sm:3");
- XmlAddAttr(enable_sm, L"resume", L"true"); //enable resumption (most useful part of this xep)
+ if (m_sStrmMgmtResumeId.empty()) {
+ XmlNode enable_sm("enable");
+ XmlAddAttr(enable_sm, "xmlns", "urn:xmpp:sm:3");
+ XmlAddAttr(enable_sm, "resume", "true"); //enable resumption (most useful part of this xep)
proto->m_ThreadInfo->send(enable_sm);
m_nStrmMgmtLocalSCount = 1; //TODO: this MUST be 0, i have bug somewhere, feel free to fix it.
}
else //resume session
{
- XmlNode enable_sm(L"resume");
- XmlAddAttr(enable_sm, L"xmlns", L"urn:xmpp:sm:3");
- xmlAddAttrInt(enable_sm, L"h", m_nStrmMgmtLocalHCount);
- XmlAddAttr(enable_sm, L"previd", m_sStrmMgmtResumeId.c_str());
+ XmlNode enable_sm("resume");
+ enable_sm << XATTR("xmlns", "urn:xmpp:sm:3") << XATTRI("h", m_nStrmMgmtLocalHCount) << XATTR("previd", m_sStrmMgmtResumeId.c_str());
proto->m_ThreadInfo->send(enable_sm);
}
}
@@ -263,9 +239,8 @@ void strm_mgmt::SendAck()
if (!m_bStrmMgmtEnabled)
return;
proto->debugLogA("strm_mgmt: info: sending ack: locally received node count %d", m_nStrmMgmtLocalHCount);
- XmlNode enable_sm(L"a");
- XmlAddAttr(enable_sm, L"xmlns", L"urn:xmpp:sm:3");
- xmlAddAttrInt(enable_sm, L"h", m_nStrmMgmtLocalHCount);
+ XmlNode enable_sm("a");
+ enable_sm << XATTR("xmlns", "urn:xmpp:sm:3") << XATTRI("h", m_nStrmMgmtLocalHCount);
proto->m_ThreadInfo->send_no_strm_mgmt(enable_sm);
}
@@ -273,8 +248,8 @@ void strm_mgmt::RequestAck()
{
if (!m_bStrmMgmtEnabled)
return;
- XmlNode enable_sm(L"r");
- XmlAddAttr(enable_sm, L"xmlns", L"urn:xmpp:sm:3");
+
+ XmlNode enable_sm("r"); enable_sm << XATTR("xmlns", "urn:xmpp:sm:3");
proto->m_ThreadInfo->send_no_strm_mgmt(enable_sm);
}
@@ -291,12 +266,11 @@ bool strm_mgmt::IsResumeIdPresent()
void strm_mgmt::FinishLoginProcess(ThreadData *info)
{
- if (info->auth)
- { //We are already logged-in
+ if (info->auth) { //We are already logged-in
info->send(
XmlNodeIq(proto->AddIQ(&CJabberProto::OnIqResultBind, JABBER_IQ_TYPE_SET))
- << XCHILDNS(L"bind", L"urn:ietf:params:xml:ns:xmpp-bind")
- << XCHILD(L"resource", info->resource));
+ << XCHILDNS("bind", "urn:ietf:params:xml:ns:xmpp-bind")
+ << XCHILD("resource", info->resource));
if (proto->m_AuthMechs.isSessionAvailable)
info->bIsSessionAvailable = TRUE;
@@ -306,5 +280,4 @@ void strm_mgmt::FinishLoginProcess(ThreadData *info)
//mechanisms not available and we are not logged in
proto->PerformIqAuth(info);
-
}
diff --git a/protocols/JabberG/src/jabber_strm_mgmt.h b/protocols/JabberG/src/jabber_strm_mgmt.h
index 60a17bfc97..5c249e6fad 100755
--- a/protocols/JabberG/src/jabber_strm_mgmt.h
+++ b/protocols/JabberG/src/jabber_strm_mgmt.h
@@ -29,28 +29,28 @@ struct CJabberProto;
class strm_mgmt
{
- void OnProcessSMa(HXML node);
- void OnProcessSMr(HXML node);
+ void OnProcessSMa(const TiXmlElement *node);
+ void OnProcessSMr(const TiXmlElement *node);
void ResendNodes(uint32_t count);
void FinishLoginProcess(ThreadData *info);
-
CJabberProto *proto;
+ TiXmlDocument xmlStorage;
uint32_t m_nStrmMgmtSrvHCount, m_nStrmMgmtLocalHCount, m_nStrmMgmtLocalSCount, m_nStrmMgmtResumeMaxSeconds;
const uint32_t m_nStrmMgmtCacheSize = 10;
- bool m_bStrmMgmtPendingEnable, m_bStrmMgmtEnabled, m_bStrmMgmtResumeSupported, bSessionResumed;
- std::wstring m_sStrmMgmtResumeId;
- std::list<HXML> NodeCache;
+ bool m_bStrmMgmtPendingEnable = false, m_bStrmMgmtEnabled = false, m_bStrmMgmtResumeSupported = false, bSessionResumed = false;
+ std::string m_sStrmMgmtResumeId;
+ std::list<TiXmlElement*> NodeCache;
public:
strm_mgmt(CJabberProto *proto);
void EnableStrmMgmt();
- void HandleOutgoingNode(HXML node);
- void HandleIncommingNode(HXML node);
- void OnProcessEnabled(HXML node, ThreadData *info);
- void OnProcessResumed(HXML node, ThreadData *info);
- void OnProcessFailed(HXML node, ThreadData * info);
- void CheckStreamFeatures(HXML node);
+ void HandleOutgoingNode(TiXmlElement *node);
+ void HandleIncommingNode(const TiXmlElement *node);
+ void OnProcessEnabled(const TiXmlElement *node, ThreadData *info);
+ void OnProcessResumed(const TiXmlElement *node, ThreadData *info);
+ void OnProcessFailed(const TiXmlElement *node, ThreadData * info);
+ void CheckStreamFeatures(const TiXmlElement *node);
void CheckState();
void ResetState();
void SendAck();
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp
index faa9ebecac..b10b80159e 100644
--- a/protocols/JabberG/src/jabber_svc.cpp
+++ b/protocols/JabberG/src/jabber_svc.cpp
@@ -37,7 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
INT_PTR __cdecl CJabberProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam)
{
- wchar_t *szStatus = nullptr;
+ char *szStatus = nullptr;
mir_cslock lck(m_csModeMsgMutex);
switch (wParam ? (int)wParam : m_iStatus) {
@@ -64,7 +64,7 @@ INT_PTR __cdecl CJabberProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam)
}
if (szStatus)
- return (lParam & SGMA_UNICODE) ? (INT_PTR)mir_wstrdup(szStatus) : (INT_PTR)mir_u2a(szStatus);
+ return (lParam & SGMA_UNICODE) ? (INT_PTR)mir_utf8decodeW(szStatus) : (INT_PTR)mir_utf8decode(szStatus, 0);
return 0;
}
@@ -91,14 +91,14 @@ INT_PTR __cdecl CJabberProto::JabberGetAvatar(WPARAM wParam, LPARAM lParam)
INT_PTR __cdecl CJabberProto::JabberGetAvatarCaps(WPARAM wParam, LPARAM lParam)
{
- switch(wParam) {
+ switch (wParam) {
case AF_MAXSIZE:
{
POINT* size = (POINT*)lParam;
if (size)
size->x = size->y = 96;
}
- return 0;
+ return 0;
case AF_FORMATSUPPORTED: // Jabber supports avatars of virtually all formats
return 1;
@@ -119,7 +119,7 @@ INT_PTR __cdecl CJabberProto::JabberGetAvatarInfo(WPARAM wParam, LPARAM lParam)
PROTO_AVATAR_INFORMATION* pai = (PROTO_AVATAR_INFORMATION*)lParam;
- ptrA szHashValue( getStringA(pai->hContact, "AvatarHash"));
+ ptrA szHashValue(getStringA(pai->hContact, "AvatarHash"));
if (szHashValue == nullptr) {
debugLogA("No avatar");
return GAIR_NOAVATAR;
@@ -132,7 +132,7 @@ INT_PTR __cdecl CJabberProto::JabberGetAvatarInfo(WPARAM wParam, LPARAM lParam)
pai->format = (pai->hContact == 0) ? PA_FORMAT_PNG : getByte(pai->hContact, "AvatarType", 0);
if (::_waccess(pai->filename, 0) == 0) {
- ptrA szSavedHash( getStringA(pai->hContact, "AvatarSaved"));
+ ptrA szSavedHash(getStringA(pai->hContact, "AvatarSaved"));
if (szSavedHash != nullptr && !mir_strcmp(szSavedHash, szHashValue)) {
debugLogA("Avatar is Ok: %s == %s", szSavedHash, szHashValue);
return GAIR_SUCCESS;
@@ -140,24 +140,24 @@ INT_PTR __cdecl CJabberProto::JabberGetAvatarInfo(WPARAM wParam, LPARAM lParam)
}
if ((wParam & GAIF_FORCE) != 0 && pai->hContact != 0 && m_bJabberOnline) {
- ptrW tszJid( getWStringA(pai->hContact, "jid"));
+ ptrA tszJid(getUStringA(pai->hContact, "jid"));
if (tszJid != nullptr) {
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, tszJid);
if (item != nullptr) {
BOOL isXVcard = getByte(pai->hContact, "AvatarXVcard", 0);
- wchar_t szJid[JABBER_MAX_JID_LEN]; szJid[0] = 0;
+ char szJid[JABBER_MAX_JID_LEN]; szJid[0] = 0;
if (item->arResources.getCount() != 0 && !isXVcard)
- if (wchar_t *bestResName = ListGetBestClientResourceNamePtr(tszJid))
- mir_snwprintf(szJid, L"%s/%s", tszJid, bestResName);
+ if (char *bestResName = ListGetBestClientResourceNamePtr(tszJid))
+ mir_snprintf(szJid, "%s/%s", tszJid, bestResName);
if (szJid[0] == 0)
- wcsncpy_s(szJid, tszJid, _TRUNCATE);
+ strncpy_s(szJid, tszJid, _TRUNCATE);
debugLogW(L"Rereading %s for %s", isXVcard ? JABBER_FEAT_VCARD_TEMP : JABBER_FEAT_AVATAR, szJid);
m_ThreadInfo->send((isXVcard) ?
- XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetVCardAvatar, JABBER_IQ_TYPE_GET, szJid)) << XCHILDNS(L"vCard", JABBER_FEAT_VCARD_TEMP) :
+ XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetVCardAvatar, JABBER_IQ_TYPE_GET, szJid)) << XCHILDNS("vCard", JABBER_FEAT_VCARD_TEMP) :
XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetClientAvatar, JABBER_IQ_TYPE_GET, szJid)) << XQUERY(JABBER_FEAT_AVATAR));
return GAIR_WAITFOR;
}
@@ -178,7 +178,7 @@ INT_PTR __cdecl CJabberProto::OnGetEventTextChatStates(WPARAM pEvent, LPARAM dat
if (dbei->pBlob[0] == JABBER_DB_EVENT_CHATSTATES_GONE) {
if (datatype == DBVT_WCHAR)
return (INT_PTR)mir_wstrdup(TranslateT("closed chat session"));
-
+
return (INT_PTR)mir_strdup(Translate("closed chat session"));
}
}
@@ -242,7 +242,7 @@ INT_PTR __cdecl CJabberProto::JabberSetAvatar(WPARAM, LPARAM lParam)
}
else if (tszFileName == nullptr || tszFileName[0] == 0) {
// Remove avatar
- wchar_t tFileName[ MAX_PATH ];
+ wchar_t tFileName[MAX_PATH];
GetAvatarFileName(0, tFileName, MAX_PATH);
DeleteFile(tFileName);
@@ -257,7 +257,7 @@ INT_PTR __cdecl CJabberProto::JabberSetAvatar(WPARAM, LPARAM lParam)
}
long dwPngSize = _filelength(fileIn);
- char *pResult = new char[ dwPngSize ];
+ char *pResult = new char[dwPngSize];
if (pResult == nullptr) {
_close(fileIn);
mir_free(tszFileName);
@@ -277,7 +277,7 @@ INT_PTR __cdecl CJabberProto::JabberSetAvatar(WPARAM, LPARAM lParam)
GetAvatarFileName(0, tFileName, MAX_PATH);
DeleteFile(tFileName);
- char buf[MIR_SHA1_HASH_SIZE*2+1];
+ char buf[MIR_SHA1_HASH_SIZE * 2 + 1];
bin2hex(digest, sizeof(digest), buf);
m_bAvatarType = ProtoGetBufferFormat(pResult);
@@ -319,7 +319,8 @@ INT_PTR __cdecl CJabberProto::ServiceSendXML(WPARAM, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////
// "/GCGetToolTipText" - gets tooltip text
-static const wchar_t *JabberEnum2AffilationStr[] = { LPGENW("None"), LPGENW("Outcast"), LPGENW("Member"), LPGENW("Admin"), LPGENW("Owner") },
+static const wchar_t
+ *JabberEnum2AffilationStr[] = { LPGENW("None"), LPGENW("Outcast"), LPGENW("Member"), LPGENW("Admin"), LPGENW("Owner") },
*JabberEnum2RoleStr[] = { LPGENW("None"), LPGENW("Visitor"), LPGENW("Participant"), LPGENW("Moderator") };
static void appendString(bool bIsTipper, const wchar_t *tszTitle, const wchar_t *tszValue, CMStringW &out)
@@ -337,14 +338,15 @@ static void appendString(bool bIsTipper, const wchar_t *tszTitle, const wchar_t
INT_PTR __cdecl CJabberProto::JabberGCGetToolTipText(WPARAM wParam, LPARAM lParam)
{
- if (!wParam || !lParam)
+ const wchar_t *pwszRoomId((wchar_t*)wParam), *pwszUserId((wchar_t*)lParam);
+ if (!pwszRoomId || !pwszUserId)
return 0; //room global tooltip not supported yet
- JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, (wchar_t*)wParam);
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, T2Utf(pwszRoomId));
if (item == nullptr)
return 0; //no room found
- pResourceStatus info( item->findResource((wchar_t*)lParam));
+ pResourceStatus info(item->findResource(T2Utf(pwszUserId)));
if (info == nullptr)
return 0; //no info found
@@ -359,18 +361,18 @@ INT_PTR __cdecl CJabberProto::JabberGCGetToolTipText(WPARAM wParam, LPARAM lPara
//JID:
CMStringW outBuf;
- if (wcschr(info->m_tszResourceName, '@') != nullptr)
- appendString(bIsTipper, LPGENW("JID:"), info->m_tszResourceName, outBuf);
+ if (strchr(info->m_szResourceName, '@') != nullptr)
+ appendString(bIsTipper, LPGENW("JID:"), pwszUserId, outBuf);
else if (lParam) //or simple nick
- appendString(bIsTipper, LPGENW("Nick:"), (wchar_t*)lParam, outBuf);
+ appendString(bIsTipper, LPGENW("Nick:"), pwszUserId, outBuf);
// status
- if (info->m_iStatus >= ID_STATUS_OFFLINE && info->m_iStatus <= ID_STATUS_IDLE )
+ if (info->m_iStatus >= ID_STATUS_OFFLINE && info->m_iStatus <= ID_STATUS_IDLE)
appendString(bIsTipper, LPGENW("Status:"), Clist_GetStatusModeDescription(info->m_iStatus, 0), outBuf);
// status text
- if (info->m_tszStatusMessage)
- appendString(bIsTipper, LPGENW("Status message:"), info->m_tszStatusMessage, outBuf);
+ if (info->m_szStatusMessage)
+ appendString(bIsTipper, LPGENW("Status message:"), Utf2T(info->m_szStatusMessage), outBuf);
// Role
appendString(bIsTipper, LPGENW("Role:"), TranslateW(JabberEnum2RoleStr[info->m_role]), outBuf);
@@ -379,8 +381,8 @@ INT_PTR __cdecl CJabberProto::JabberGCGetToolTipText(WPARAM wParam, LPARAM lPara
appendString(bIsTipper, LPGENW("Affiliation:"), TranslateW(JabberEnum2AffilationStr[info->m_affiliation]), outBuf);
// real jid
- if (info->m_tszRealJid)
- appendString(bIsTipper, LPGENW("Real JID:"), info->m_tszRealJid, outBuf);
+ if (info->m_szRealJid)
+ appendString(bIsTipper, LPGENW("Real JID:"), Utf2T(info->m_szRealJid), outBuf);
return (outBuf.IsEmpty() ? 0 : (INT_PTR)mir_wstrdup(outBuf));
}
@@ -393,7 +395,7 @@ INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI(WPARAM, LPARAM lParam)
return 1;
// skip leading prefix
- wchar_t szUri[ 1024 ];
+ wchar_t szUri[1024];
wcsncpy_s(szUri, arg, _TRUNCATE);
wchar_t *szJid = wcschr(szUri, ':');
if (szJid == nullptr)
@@ -417,6 +419,7 @@ INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI(WPARAM, LPARAM lParam)
if (szSecondParam)
*(szSecondParam++) = 0;
+ T2Utf jid(szJid);
// no command or message command
if (!szCommand || (szCommand && !mir_wstrcmpi(szCommand, L"message"))) {
// message
@@ -424,9 +427,9 @@ INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI(WPARAM, LPARAM lParam)
return 1;
wchar_t *szMsgBody = nullptr;
- MCONTACT hContact = HContactFromJID(szJid, false);
+ MCONTACT hContact = HContactFromJID(jid, false);
if (hContact == 0)
- hContact = DBCreateContact(szJid, szJid, true, true);
+ hContact = DBCreateContact(jid, jid, true, true);
if (hContact == 0)
return 1;
@@ -444,9 +447,9 @@ INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI(WPARAM, LPARAM lParam)
CallService(MS_MSG_SENDMESSAGEW, hContact, (LPARAM)szMsgBody);
return 0;
}
-
+
if (!mir_wstrcmpi(szCommand, L"roster")) {
- if (!HContactFromJID(szJid)) {
+ if (!HContactFromJID(jid)) {
PROTOSEARCHRESULT psr = { 0 };
psr.cbSize = sizeof(psr);
psr.flags = PSR_UNICODE;
@@ -456,19 +459,19 @@ INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI(WPARAM, LPARAM lParam)
}
return 0;
}
-
+
// chat join invitation
if (!mir_wstrcmpi(szCommand, L"join")) {
- GroupchatJoinRoomByJid(nullptr, szJid);
+ GroupchatJoinRoomByJid(nullptr, jid);
return 0;
}
-
+
// service discovery request
if (!mir_wstrcmpi(szCommand, L"disco")) {
OnMenuHandleServiceDiscovery(0, (LPARAM)szJid);
return 0;
}
-
+
// ad-hoc commands
if (!mir_wstrcmpi(szCommand, L"command")) {
if (szSecondParam) {
@@ -479,16 +482,16 @@ INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI(WPARAM, LPARAM lParam)
}
else szSecondParam = nullptr;
}
- CJabberAdhocStartupParams* pStartupParams = new CJabberAdhocStartupParams(this, szJid, szSecondParam);
+ CJabberAdhocStartupParams* pStartupParams = new CJabberAdhocStartupParams(this, jid, T2Utf(szSecondParam));
ContactMenuRunCommands(0, (LPARAM)pStartupParams);
return 0;
}
-
+
// send file
if (!mir_wstrcmpi(szCommand, L"sendfile")) {
- MCONTACT hContact = HContactFromJID(szJid, false);
+ MCONTACT hContact = HContactFromJID(jid, false);
if (hContact == 0)
- hContact = DBCreateContact(szJid, szJid, true, true);
+ hContact = DBCreateContact(jid, jid, true, true);
if (hContact == 0)
return 1;
CallService(MS_FILE_SENDFILE, hContact, 0);
@@ -504,20 +507,20 @@ INT_PTR __cdecl CJabberProto::JabberSendNudge(WPARAM hContact, LPARAM)
if (!m_bJabberOnline)
return 0;
- ptrW jid( getWStringA(hContact, "jid"));
+ ptrA jid(getUStringA(hContact, "jid"));
if (jid == nullptr)
return 0;
- wchar_t tszJid[JABBER_MAX_JID_LEN];
- wchar_t *szResource = ListGetBestClientResourceNamePtr(jid);
+ char tszJid[JABBER_MAX_JID_LEN];
+ char *szResource = ListGetBestClientResourceNamePtr(jid);
if (szResource)
- mir_snwprintf(tszJid, L"%s/%s", jid, szResource);
+ mir_snprintf(tszJid, "%s/%s", jid, szResource);
else
- wcsncpy_s(tszJid, jid, _TRUNCATE);
+ strncpy_s(tszJid, jid, _TRUNCATE);
m_ThreadInfo->send(
- XmlNode(L"message") << XATTR(L"type", L"headline") << XATTR(L"to", tszJid)
- << XCHILDNS(L"attention", JABBER_FEAT_ATTENTION));
+ XmlNode("message") << XATTR("type", "headline") << XATTR("to", tszJid)
+ << XCHILDNS("attention", JABBER_FEAT_ATTENTION));
return 0;
}
@@ -527,29 +530,29 @@ BOOL CJabberProto::SendHttpAuthReply(CJabberHttpAuthParams *pParams, BOOL bAutho
return FALSE;
if (pParams->m_nType == CJabberHttpAuthParams::IQ) {
- XmlNodeIq iq(bAuthorized ? L"result" : L"error", pParams->m_szIqId, pParams->m_szFrom);
+ XmlNodeIq iq(bAuthorized ? "result" : "error", pParams->m_szIqId, pParams->m_szFrom);
if (!bAuthorized) {
- iq << XCHILDNS(L"confirm", JABBER_FEAT_HTTP_AUTH) << XATTR(L"id", pParams->m_szId)
- << XATTR(L"method", pParams->m_szMethod) << XATTR(L"url", pParams->m_szUrl);
- iq << XCHILD(L"error") << XATTRI(L"code", 401) << XATTR(L"type", L"auth")
- << XCHILDNS(L"not-authorized", L"urn:ietf:params:xml:xmpp-stanzas");
+ iq << XCHILDNS("confirm", JABBER_FEAT_HTTP_AUTH) << XATTR("id", pParams->m_szId)
+ << XATTR("method", pParams->m_szMethod) << XATTR("url", pParams->m_szUrl);
+ iq << XCHILD("error") << XATTRI("code", 401) << XATTR("type", "auth")
+ << XCHILDNS("not-authorized", "urn:ietf:params:xml:xmpp-stanzas");
}
m_ThreadInfo->send(iq);
}
else if (pParams->m_nType == CJabberHttpAuthParams::MSG) {
- XmlNode msg(L"message");
- msg << XATTR(L"to", pParams->m_szFrom);
+ XmlNode msg("message");
+ msg << XATTR("to", pParams->m_szFrom);
if (!bAuthorized)
- msg << XATTR(L"type", L"error");
+ msg << XATTR("type", "error");
if (pParams->m_szThreadId)
- msg << XCHILD(L"thread", pParams->m_szThreadId);
+ msg << XCHILD("thread", pParams->m_szThreadId);
- msg << XCHILDNS(L"confirm", JABBER_FEAT_HTTP_AUTH) << XATTR(L"id", pParams->m_szId)
- << XATTR(L"method", pParams->m_szMethod) << XATTR(L"url", pParams->m_szUrl);
+ msg << XCHILDNS("confirm", JABBER_FEAT_HTTP_AUTH) << XATTR("id", pParams->m_szId)
+ << XATTR("method", pParams->m_szMethod) << XATTR("url", pParams->m_szUrl);
if (!bAuthorized)
- msg << XCHILD(L"error") << XATTRI(L"code", 401) << XATTR(L"type", L"auth")
- << XCHILDNS(L"not-authorized", L"urn:ietf:params:xml:xmpp-stanzas");
+ msg << XCHILD("error") << XATTRI("code", 401) << XATTR("type", "auth")
+ << XCHILDNS("not-authorized", "urn:ietf:params:xml:xmpp-stanzas");
m_ThreadInfo->send(msg);
}
@@ -558,12 +561,12 @@ BOOL CJabberProto::SendHttpAuthReply(CJabberHttpAuthParams *pParams, BOOL bAutho
return TRUE;
}
-class CJabberDlgHttpAuth: public CJabberDlgBase
+class CJabberDlgHttpAuth : public CJabberDlgBase
{
typedef CJabberDlgBase CSuper;
public:
- CJabberDlgHttpAuth(CJabberProto *proto, HWND hwndParent, CJabberHttpAuthParams *pParams):
+ CJabberDlgHttpAuth(CJabberProto *proto, HWND hwndParent, CJabberHttpAuthParams *pParams) :
CSuper(proto, IDD_HTTP_AUTH),
m_txtInfo(this, IDC_EDIT_HTTP_AUTH_INFO),
m_btnAuth(this, IDOK),
@@ -582,10 +585,10 @@ public:
Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_OPEN));
- SetDlgItemText(m_hwnd, IDC_TXT_URL, m_pParams->m_szUrl);
- SetDlgItemText(m_hwnd, IDC_TXT_FROM, m_pParams->m_szFrom);
- SetDlgItemText(m_hwnd, IDC_TXT_ID, m_pParams->m_szId);
- SetDlgItemText(m_hwnd, IDC_TXT_METHOD, m_pParams->m_szMethod);
+ SetDlgItemTextUtf(m_hwnd, IDC_TXT_URL, m_pParams->m_szUrl);
+ SetDlgItemTextUtf(m_hwnd, IDC_TXT_FROM, m_pParams->m_szFrom);
+ SetDlgItemTextUtf(m_hwnd, IDC_TXT_ID, m_pParams->m_szId);
+ SetDlgItemTextUtf(m_hwnd, IDC_TXT_METHOD, m_pParams->m_szMethod);
return true;
}
@@ -610,7 +613,7 @@ public:
}
UI_MESSAGE_MAP(CJabberDlgHttpAuth, CSuper);
- UI_MESSAGE(WM_CTLCOLORSTATIC, OnCtlColorStatic);
+ UI_MESSAGE(WM_CTLCOLORSTATIC, OnCtlColorStatic);
UI_MESSAGE_MAP_END();
INT_PTR OnCtlColorStatic(UINT, WPARAM, LPARAM)
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp
index 4f9fc51c71..843fcc6608 100755
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -64,7 +64,7 @@ struct JabberPasswordDlgParam
WORD dlgResult;
wchar_t onlinePassword[128];
HANDLE hEventPasswdDlg;
- wchar_t *ptszJid;
+ char *pszJid;
};
static INT_PTR CALLBACK JabberPasswordDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -79,7 +79,7 @@ static INT_PTR CALLBACK JabberPasswordDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
wchar_t text[512];
- mir_snwprintf(text, TranslateT("Enter password for %s"), param->ptszJid);
+ mir_snwprintf(text, TranslateT("Enter password for %s"), Utf2T(param->pszJid).get());
SetDlgItemText(hwndDlg, IDC_JID, text);
CheckDlgButton(hwndDlg, IDC_SAVEPASSWORD, param->pro->getByte("SaveSessionPassword", 0) ? BST_CHECKED : BST_UNCHECKED);
@@ -124,7 +124,7 @@ static VOID CALLBACK JabberPasswordCreateDialogApcProc(void* param)
/////////////////////////////////////////////////////////////////////////////////////////
// Jabber keep-alive thread
-void CJabberProto::OnPingReply(HXML, CJabberIqInfo *pInfo)
+void CJabberProto::OnPingReply(const TiXmlElement*, CJabberIqInfo *pInfo)
{
if (!pInfo)
return;
@@ -140,6 +140,14 @@ void CJabberProto::OnPingReply(HXML, CJabberIqInfo *pInfo)
/////////////////////////////////////////////////////////////////////////////////////////
+void CJabberProto::JLoginFailed(int errorCode)
+{
+ m_savedPassword = nullptr;
+ ProtoBroadcastAck(0, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, errorCode);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
static int CompareDNS(const DNS_SRV_DATAA* dns1, const DNS_SRV_DATAA* dns2)
{
return (int)dns1->wPriority - (int)dns2->wPriority;
@@ -196,34 +204,30 @@ void CJabberProto::xmlStreamInitializeNow(ThreadData *info)
m_szXmlStreamToBeInitialized = nullptr;
}
- HXML n = xmlCreateNode(L"xml", nullptr, 1) << XATTR(L"version", L"1.0") << XATTR(L"encoding", L"UTF-8");
+ XmlNode n("xml"); n << XATTR("version", "1.0") << XATTR("encoding", "UTF-8");
- HXML stream = n << XCHILDNS(L"stream:stream", L"jabber:client") << XATTR(L"to", _A2T(info->conn.server))
- << XATTR(L"xmlns:stream", L"http://etherx.jabber.org/streams");
+ TiXmlElement *stream = n << XCHILDNS("stream:stream", "jabber:client") << XATTR("to", info->conn.server)
+ << XATTR("xmlns:stream", "http://etherx.jabber.org/streams");
if (m_tszSelectedLang)
- XmlAddAttr(stream, L"xml:lang", m_tszSelectedLang);
+ XmlAddAttr(stream, "xml:lang", m_tszSelectedLang);
if (!m_bDisable3920auth)
- XmlAddAttr(stream, L"version", L"1.0");
+ XmlAddAttr(stream, "version", "1.0");
- LPTSTR xmlQuery = xmlToString(n, nullptr);
- T2Utf buf(xmlQuery);
- int bufLen = (int)mir_strlen(buf);
- if (bufLen > 2) {
- strdel((char*)buf + bufLen - 2, 1);
- bufLen--;
- }
+ tinyxml2::XMLPrinter printer(0, true);
+ n.Print(&printer);
+ CMStringA buf(printer.CStr());
+ if (buf.GetLength() > 2)
+ buf.Delete(buf.GetLength() - 2, 1);
- info->send(buf, bufLen);
- xmlFree(xmlQuery);
- xmlDestroyNode(n);
+ info->send(buf.GetBuffer(), buf.GetLength());
}
void CJabberProto::ServerThread(JABBER_CONN_DATA *pParam)
{
ThreadData info(this, pParam);
- ptrW tszValue;
+ ptrA tszValue;
debugLogA("Thread started: type=%d", info.bIsReg);
Thread_SetName("Jabber: ServerThread");
@@ -249,18 +253,18 @@ void CJabberProto::ServerThread(JABBER_CONN_DATA *pParam)
m_ThreadInfo = &info;
- if ((tszValue = getWStringA("LoginName")) != nullptr)
- wcsncpy_s(info.conn.username, tszValue, _TRUNCATE);
+ if ((tszValue = getUStringA("LoginName")) != nullptr)
+ strncpy_s(info.conn.username, tszValue, _TRUNCATE);
- if (*rtrimw(info.conn.username) == '\0') {
+ if (*rtrim(info.conn.username) == '\0') {
DWORD dwSize = _countof(info.conn.username);
- if (GetUserName(info.conn.username, &dwSize))
- setWString("LoginName", info.conn.username);
+ if (GetUserNameA(info.conn.username, &dwSize))
+ setString("LoginName", info.conn.username);
else
info.conn.username[0] = 0;
}
- if (*rtrimw(info.conn.username) == '\0') {
+ if (*rtrim(info.conn.username) == '\0') {
debugLogA("Thread ended, login name is not configured");
JLoginFailed(LOGINERR_BADUSERID);
@@ -283,31 +287,31 @@ LBL_FatalError:
if (m_bHostNameAsResource) {
DWORD dwCompNameLen = _countof(info.resource) - 1;
- if (!GetComputerName(info.resource, &dwCompNameLen))
- mir_wstrcpy(info.resource, L"Miranda");
+ if (!GetComputerNameA(info.resource, &dwCompNameLen))
+ strncpy_s(info.resource, "Miranda", _TRUNCATE);
}
else {
- if ((tszValue = getWStringA("Resource")) != nullptr)
- wcsncpy_s(info.resource, tszValue, _TRUNCATE);
+ if ((tszValue = getUStringA("Resource")) != nullptr)
+ strncpy_s(info.resource, tszValue, _TRUNCATE);
else
- mir_wstrcpy(info.resource, L"Miranda");
+ mir_strcpy(info.resource, "Miranda");
}
- wchar_t jidStr[512];
- mir_snwprintf(jidStr, L"%s@%S/%s", info.conn.username, info.conn.server, info.resource);
- wcsncpy_s(info.fullJID, jidStr, _TRUNCATE);
+ char jidStr[512];
+ mir_snprintf(jidStr, "%s@%S/%s", info.conn.username, info.conn.server, info.resource);
+ strncpy_s(info.fullJID, jidStr, _TRUNCATE);
if (m_bUseDomainLogin) // in the case of NTLM auth we have no need in password
info.conn.password[0] = 0;
else if (!m_bSavePassword) { // we have to enter a password manually. have we done it before?
if (m_savedPassword != nullptr)
- wcsncpy_s(info.conn.password, m_savedPassword, _TRUNCATE);
+ strncpy_s(info.conn.password, T2Utf(m_savedPassword), _TRUNCATE);
else {
- mir_snwprintf(jidStr, L"%s@%S", info.conn.username, info.conn.server);
+ mir_snprintf(jidStr, "%s@%S", info.conn.username, info.conn.server);
JabberPasswordDlgParam param;
param.pro = this;
- param.ptszJid = jidStr;
+ param.pszJid = jidStr;
param.hEventPasswdDlg = CreateEvent(nullptr, FALSE, FALSE, nullptr);
CallFunctionAsync(JabberPasswordCreateDialogApcProc, &param);
WaitForSingleObject(param.hEventPasswdDlg, INFINITE);
@@ -320,17 +324,17 @@ LBL_FatalError:
}
m_savedPassword = (param.saveOnlinePassword) ? mir_wstrdup(param.onlinePassword) : nullptr;
- wcsncpy_s(info.conn.password, param.onlinePassword, _TRUNCATE);
+ strncpy_s(info.conn.password, T2Utf(param.onlinePassword), _TRUNCATE);
}
}
else {
- ptrW tszPassw(getWStringA(0, "Password"));
+ ptrA tszPassw(getUStringA(0, "Password"));
if (tszPassw == nullptr) {
JLoginFailed(LOGINERR_BADUSERID);
debugLogA("Thread ended, password is not configured");
goto LBL_FatalError;
}
- wcsncpy_s(info.conn.password, tszPassw, _TRUNCATE);
+ strncpy_s(info.conn.password, tszPassw, _TRUNCATE);
}
}
else {
@@ -396,11 +400,9 @@ LBL_FatalError:
// User may change status to OFFLINE while we are connecting above
if (m_iDesiredStatus != ID_STATUS_OFFLINE || info.bIsReg) {
if (!info.bIsReg) {
- size_t len = mir_wstrlen(info.conn.username) + mir_strlen(info.conn.server) + 1;
- m_szJabberJID = (wchar_t*)mir_alloc(sizeof(wchar_t)*(len + 1));
- mir_snwprintf(m_szJabberJID, len + 1, L"%s@%S", info.conn.username, info.conn.server);
+ m_szJabberJID = CMStringA(FORMAT, "%s@%S", info.conn.username, info.conn.server).Detach();
m_bSendKeepAlive = m_bKeepAlive != 0;
- setWString("jid", m_szJabberJID); // store jid in database
+ setUString("jid", m_szJabberJID); // store jid in database
ListInit();
}
@@ -430,7 +432,7 @@ LBL_FatalError:
if (info.jabberServerCaps & JABBER_CAPS_PING) {
CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnPingReply, JABBER_IQ_TYPE_GET, nullptr, 0, -1, this);
pInfo->SetTimeout(m_iConnectionKeepAliveTimeout);
- info.send(XmlNodeIq(pInfo) << XATTR(L"from", info.fullJID) << XCHILDNS(L"ping", JABBER_FEAT_PING));
+ info.send(XmlNodeIq(pInfo) << XATTR("from", info.fullJID) << XCHILDNS("ping", JABBER_FEAT_PING));
}
}
else
@@ -449,38 +451,13 @@ LBL_FatalError:
recvRest:
info.buffer[datalen] = '\0';
- ptrW str(mir_utf8decodeW(info.buffer));
+ TiXmlDocument root;
+ if (0 == root.Parse(info.buffer, datalen))
+ for (auto *n : TiXmlEnum(&root))
+ OnProcessProtocol(n, &info);
int bytesParsed = 0;
- XmlNode root(str, &bytesParsed, tag);
- if (root && tag) {
- char *p = strstr(info.buffer, "stream:stream");
- if (p) p = strchr(p, '>');
- if (p)
- bytesParsed = p - info.buffer + 1;
- else {
- root = XmlNode();
- bytesParsed = 0;
- }
- }
- else {
- if (root)
- str[bytesParsed] = 0;
- bytesParsed = (root) ? mir_utf8lenW(str) : 0;
- }
-
debugLogA("bytesParsed = %d", bytesParsed);
- if (root) tag = nullptr;
-
- if (XmlGetName(root) == nullptr) {
- for (int i = 0;; i++) {
- HXML n = XmlGetChild(root, i);
- if (!n)
- break;
- OnProcessProtocol(n, &info);
- }
- }
- else OnProcessProtocol(root, &info);
if (bytesParsed > 0) {
if (bytesParsed < datalen)
@@ -502,7 +479,8 @@ recvRest:
xmlStreamInitializeNow(&info);
tag = L"stream:stream";
}
- if (root && datalen)
+
+ if (root.FirstChild() && datalen)
goto recvRest;
}
@@ -568,7 +546,7 @@ recvRest:
void CJabberProto::PerformRegistration(ThreadData *info)
{
iqIdRegGetReg = SerialNext();
- info->send(XmlNodeIq(L"get", iqIdRegGetReg, nullptr) << XQUERY(JABBER_FEAT_REGISTER));
+ info->send(XmlNodeIq("get", iqIdRegGetReg, nullptr) << XQUERY(JABBER_FEAT_REGISTER));
SendMessage(info->conn.reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 50, (LPARAM)TranslateT("Requesting registration instruction..."));
}
@@ -577,22 +555,22 @@ void CJabberProto::PerformIqAuth(ThreadData *info)
{
if (!info->bIsReg) {
info->send(XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetAuth, JABBER_IQ_TYPE_GET))
- << XQUERY(L"jabber:iq:auth") << XCHILD(L"username", info->conn.username));
+ << XQUERY("jabber:iq:auth") << XCHILD("username", info->conn.username));
}
else PerformRegistration(info);
}
/////////////////////////////////////////////////////////////////////////////////////////
-void CJabberProto::OnProcessStreamOpening(HXML node, ThreadData *info)
+void CJabberProto::OnProcessStreamOpening(const TiXmlElement *node, ThreadData *info)
{
- if (mir_wstrcmp(XmlGetName(node), L"stream:stream"))
+ if (mir_strcmp(node->Name(), "stream:stream"))
return;
if (!info->bIsReg) {
- const wchar_t *sid = XmlGetAttrValue(node, L"id");
+ const char *sid = node->Attribute("id");
if (sid != nullptr)
- info->szStreamId = mir_u2a(sid);
+ info->szStreamId = mir_strdup(sid);
}
if (info->proto->m_bDisable3920auth)
@@ -682,50 +660,40 @@ void CJabberProto::PerformAuthentication(ThreadData *info)
info->auth = auth;
if (!request) request = auth->getInitialRequest();
- info->send(XmlNode(L"auth", _A2T(request)) << XATTR(L"xmlns", L"urn:ietf:params:xml:ns:xmpp-sasl")
- << XATTR(L"mechanism", _A2T(auth->getName())));
+ info->send(XmlNode("auth", request) << XATTR("xmlns", "urn:ietf:params:xml:ns:xmpp-sasl")
+ << XATTR("mechanism", auth->getName()));
mir_free(request);
}
/////////////////////////////////////////////////////////////////////////////////////////
-void CJabberProto::OnProcessFeatures(HXML node, ThreadData *info)
+void CJabberProto::OnProcessFeatures(const TiXmlElement *node, ThreadData *info)
{
bool isRegisterAvailable = false;
bool areMechanismsDefined = false;
- for (int i = 0;; i++) {
- HXML n = XmlGetChild(node, i);
- if (!n)
- break;
-
- if (!mir_wstrcmp(XmlGetName(n), L"starttls")) {
+ for (auto *n : TiXmlEnum(node)) {
+ if (!mir_strcmp(n->Name(), "starttls")) {
if (!info->conn.useSSL && m_bUseTLS) {
debugLogA("Requesting TLS");
- info->send(XmlNode(XmlGetName(n)) << XATTR(L"xmlns", L"urn:ietf:params:xml:ns:xmpp-tls"));
+ info->send(XmlNode(n->Name()) << XATTR("xmlns", "urn:ietf:params:xml:ns:xmpp-tls"));
return;
}
}
- if (!mir_wstrcmp(XmlGetName(n), L"compression") && m_bEnableZlib == TRUE) {
+ if (!mir_strcmp(n->Name(), "compression") && m_bEnableZlib == TRUE) {
debugLogA("Server compression available");
- for (int k = 0;; k++) {
- HXML c = XmlGetChild(n, k);
- if (!c)
- break;
-
- if (!mir_wstrcmp(XmlGetName(c), L"method")) {
- if (!mir_wstrcmp(XmlGetText(c), L"zlib") && info->zlibInit() == TRUE) {
- debugLogA("Requesting Zlib compression");
- info->send(XmlNode(L"compress") << XATTR(L"xmlns", L"http://jabber.org/protocol/compress")
- << XCHILD(L"method", L"zlib"));
- return;
- }
+ for (auto *c : TiXmlFilter(n, "method")) {
+ if (!mir_strcmp(c->GetText(), "zlib") && info->zlibInit() == TRUE) {
+ debugLogA("Requesting Zlib compression");
+ info->send(XmlNode("compress") << XATTR("xmlns", "http://jabber.org/protocol/compress")
+ << XCHILD("method", "zlib"));
+ return;
}
}
}
- if (!mir_wstrcmp(XmlGetName(n), L"mechanisms")) {
+ if (!mir_strcmp(n->Name(), "mechanisms")) {
m_AuthMechs.isPlainAvailable = false;
m_AuthMechs.isPlainOldAvailable = false;
m_AuthMechs.isMd5Available = false;
@@ -737,32 +705,27 @@ void CJabberProto::OnProcessFeatures(HXML node, ThreadData *info)
areMechanismsDefined = true;
//JabberLog("%d mechanisms\n",n->numChild);
- for (int k = 0;; k++) {
- HXML c = XmlGetChild(n, k);
- if (!c)
- break;
-
- if (!mir_wstrcmp(XmlGetName(c), L"mechanism")) {
- const wchar_t *ptszMechanism = XmlGetText(c);
- if (!mir_wstrcmp(ptszMechanism, L"PLAIN")) m_AuthMechs.isPlainOldAvailable = m_AuthMechs.isPlainAvailable = true;
- else if (!mir_wstrcmp(ptszMechanism, L"DIGEST-MD5")) m_AuthMechs.isMd5Available = true;
- else if (!mir_wstrcmp(ptszMechanism, L"SCRAM-SHA-1")) m_AuthMechs.isScramAvailable = true;
- else if (!mir_wstrcmp(ptszMechanism, L"NTLM")) m_AuthMechs.isNtlmAvailable = true;
- else if (!mir_wstrcmp(ptszMechanism, L"GSS-SPNEGO")) m_AuthMechs.isSpnegoAvailable = true;
- else if (!mir_wstrcmp(ptszMechanism, L"GSSAPI")) m_AuthMechs.isKerberosAvailable = true;
+ for (auto *c : TiXmlEnum(n)) {
+ if (!mir_strcmp(c->Name(), "mechanism")) {
+ const char *szMechanism = c->GetText();
+ if (!mir_strcmp(szMechanism, "PLAIN")) m_AuthMechs.isPlainOldAvailable = m_AuthMechs.isPlainAvailable = true;
+ else if (!mir_strcmp(szMechanism, "DIGEST-MD5")) m_AuthMechs.isMd5Available = true;
+ else if (!mir_strcmp(szMechanism, "SCRAM-SHA-1")) m_AuthMechs.isScramAvailable = true;
+ else if (!mir_strcmp(szMechanism, "NTLM")) m_AuthMechs.isNtlmAvailable = true;
+ else if (!mir_strcmp(szMechanism, "GSS-SPNEGO")) m_AuthMechs.isSpnegoAvailable = true;
+ else if (!mir_strcmp(szMechanism, "GSSAPI")) m_AuthMechs.isKerberosAvailable = true;
}
- else if (!mir_wstrcmp(XmlGetName(c), L"hostname")) {
- const wchar_t *mech = XmlGetAttrValue(c, L"mechanism");
- if (mech && mir_wstrcmpi(mech, L"GSSAPI") == 0) {
- m_AuthMechs.m_gssapiHostName = mir_wstrdup(XmlGetText(c));
- }
+ else if (!mir_strcmp(c->Name(), "hostname")) {
+ const char *mech = c->Attribute("mechanism");
+ if (mech && mir_strcmpi(mech, "GSSAPI") == 0)
+ m_AuthMechs.m_gssapiHostName = mir_strdup(c->GetText());
}
}
}
- else if (!mir_wstrcmp(XmlGetName(n), L"register")) isRegisterAvailable = true;
- else if (!mir_wstrcmp(XmlGetName(n), L"auth")) m_AuthMechs.isAuthAvailable = true;
- else if (!mir_wstrcmp(XmlGetName(n), L"session")) m_AuthMechs.isSessionAvailable = true;
- else if (m_bEnableStreamMgmt && !mir_wstrcmp(XmlGetName(n), L"sm"))
+ else if (!mir_strcmp(n->Name(), "register")) isRegisterAvailable = true;
+ else if (!mir_strcmp(n->Name(), "auth")) m_AuthMechs.isAuthAvailable = true;
+ else if (!mir_strcmp(n->Name(), "session")) m_AuthMechs.isSessionAvailable = true;
+ else if (m_bEnableStreamMgmt && !mir_strcmp(n->Name(), "sm"))
m_StrmMgmt.CheckStreamFeatures(n);
}
@@ -781,8 +744,8 @@ void CJabberProto::OnProcessFeatures(HXML node, ThreadData *info)
if (info->auth) { //We are already logged-in
info->send(
XmlNodeIq(AddIQ(&CJabberProto::OnIqResultBind, JABBER_IQ_TYPE_SET))
- << XCHILDNS(L"bind", L"urn:ietf:params:xml:ns:xmpp-bind")
- << XCHILD(L"resource", info->resource));
+ << XCHILDNS("bind", "urn:ietf:params:xml:ns:xmpp-bind")
+ << XCHILD("resource", info->resource));
if (m_AuthMechs.isSessionAvailable)
info->bIsSessionAvailable = TRUE;
@@ -795,52 +758,46 @@ void CJabberProto::OnProcessFeatures(HXML node, ThreadData *info)
}
}
-void CJabberProto::OnProcessFailure(HXML node, ThreadData *info)
+void CJabberProto::OnProcessFailure(const TiXmlElement *node, ThreadData *info)
{
- const wchar_t *type;
- //failure xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"
- if ((type = XmlGetAttrValue(node, L"xmlns")) == nullptr) return;
- if (!mir_wstrcmp(type, L"urn:ietf:params:xml:ns:xmpp-sasl")) {
+ // failure xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"
+ const char *type = node->Attribute("xmlns");
+ if (!mir_strcmp(type, "urn:ietf:params:xml:ns:xmpp-sasl"))
PerformAuthentication(info);
- }
}
-void CJabberProto::OnProcessFailed(HXML node, ThreadData *info) //used failed instead of failure, notes: https://xmpp.org/extensions/xep-0198.html#errors
+void CJabberProto::OnProcessFailed(const TiXmlElement *node, ThreadData *info) //used failed instead of failure, notes: https://xmpp.org/extensions/xep-0198.html#errors
{
m_StrmMgmt.OnProcessFailed(node, info);
}
-void CJabberProto::OnProcessEnabled(HXML node, ThreadData * info)
+void CJabberProto::OnProcessEnabled(const TiXmlElement *node, ThreadData * info)
{
- if (m_bEnableStreamMgmt && !mir_wstrcmp(XmlGetAttrValue(node, L"xmlns"), L"urn:xmpp:sm:3"))
+ if (m_bEnableStreamMgmt && !mir_strcmp(node->Attribute("xmlns"), "urn:xmpp:sm:3"))
m_StrmMgmt.OnProcessEnabled(node, info);
}
-void CJabberProto::OnProcessError(HXML node, ThreadData *info)
+void CJabberProto::OnProcessError(const TiXmlElement *node, ThreadData *info)
{
//failure xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"
- if (!XmlGetChild(node, 0))
+ if (!node->FirstChildElement(0))
return;
bool skipMsg = false;
CMStringW buff;
- for (int i = 0;; i++) {
- HXML n = XmlGetChild(node, i);
- if (!n)
- break;
-
- const wchar_t *name = XmlGetName(n);
- const wchar_t *desc = XmlGetText(n);
+ for (auto *n : TiXmlEnum(node)) {
+ const char *name = n->Name();
+ const char *desc = n->GetText();
if (desc)
buff.AppendFormat(L"%s: %s\r\n", name, desc);
else
buff.AppendFormat(L"%s\r\n", name);
- if (!mir_wstrcmp(name, L"conflict"))
+ if (!mir_strcmp(name, "conflict"))
ProtoBroadcastAck(0, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, LOGINERR_OTHERLOCATION);
- else if (!mir_wstrcmp(name, L"see-other-host")) {
+ else if (!mir_strcmp(name, "see-other-host")) {
skipMsg = true;
}
}
@@ -852,99 +809,99 @@ void CJabberProto::OnProcessError(HXML node, ThreadData *info)
info->send("</stream:stream>");
}
-void CJabberProto::OnProcessSuccess(HXML node, ThreadData *info)
+void CJabberProto::OnProcessSuccess(const TiXmlElement *node, ThreadData *info)
{
- const wchar_t *type;
+ const char *type;
// int iqId;
// RECVED: <success ...
// ACTION: if successfully logged in, continue by requesting roster list and set my initial status
- if ((type = XmlGetAttrValue(node, L"xmlns")) == nullptr)
+ if ((type = node->Attribute("xmlns")) == nullptr)
return;
- if (!mir_wstrcmp(type, L"urn:ietf:params:xml:ns:xmpp-sasl")) {
- if (!info->auth->validateLogin(XmlGetText(node))) {
+ if (!mir_strcmp(type, "urn:ietf:params:xml:ns:xmpp-sasl")) {
+ if (!info->auth->validateLogin(node->GetText())) {
info->send("</stream:stream>");
return;
}
debugLogA("Success: Logged-in.");
- ptrW tszNick(getWStringA("Nick"));
+ ptrA tszNick(getUStringA("Nick"));
if (tszNick == nullptr)
- setWString("Nick", info->conn.username);
+ setUString("Nick", info->conn.username);
xmlStreamInitialize("after successful sasl");
}
else debugLogW(L"Success: unknown action %s.", type);
}
-void CJabberProto::OnProcessChallenge(HXML node, ThreadData *info)
+void CJabberProto::OnProcessChallenge(const TiXmlElement *node, ThreadData *info)
{
if (info->auth == nullptr) {
debugLogA("No previous auth have been made, exiting...");
return;
}
- if (mir_wstrcmp(XmlGetAttrValue(node, L"xmlns"), L"urn:ietf:params:xml:ns:xmpp-sasl"))
+ if (mir_strcmp(node->Attribute("xmlns"), "urn:ietf:params:xml:ns:xmpp-sasl"))
return;
- char* challenge = info->auth->getChallenge(XmlGetText(node));
- info->send(XmlNode(L"response", _A2T(challenge)) << XATTR(L"xmlns", L"urn:ietf:params:xml:ns:xmpp-sasl"));
+ char* challenge = info->auth->getChallenge(node->GetText());
+ info->send(XmlNode("response", challenge) << XATTR("xmlns", "urn:ietf:params:xml:ns:xmpp-sasl"));
mir_free(challenge);
}
-void CJabberProto::OnProcessProtocol(HXML node, ThreadData *info)
+void CJabberProto::OnProcessProtocol(const TiXmlElement *node, ThreadData *info)
{
OnConsoleProcessXml(node, JCPF_IN);
if (m_bEnableStreamMgmt)
m_StrmMgmt.HandleIncommingNode(node);
- if (!mir_wstrcmp(XmlGetName(node), L"proceed"))
+ if (!mir_strcmp(node->Name(), "proceed"))
OnProcessProceed(node, info);
- else if (!mir_wstrcmp(XmlGetName(node), L"compressed"))
+ else if (!mir_strcmp(node->Name(), "compressed"))
OnProcessCompressed(node, info);
- else if (!mir_wstrcmp(XmlGetName(node), L"stream:features"))
+ else if (!mir_strcmp(node->Name(), "stream:features"))
OnProcessFeatures(node, info);
- else if (!mir_wstrcmp(XmlGetName(node), L"stream:stream"))
+ else if (!mir_strcmp(node->Name(), "stream:stream"))
OnProcessStreamOpening(node, info);
- else if (!mir_wstrcmp(XmlGetName(node), L"success"))
+ else if (!mir_strcmp(node->Name(), "success"))
OnProcessSuccess(node, info);
- else if (!mir_wstrcmp(XmlGetName(node), L"failure"))
+ else if (!mir_strcmp(node->Name(), "failure"))
OnProcessFailure(node, info);
- else if (!mir_wstrcmp(XmlGetName(node), L"stream:error"))
+ else if (!mir_strcmp(node->Name(), "stream:error"))
OnProcessError(node, info);
- else if (!mir_wstrcmp(XmlGetName(node), L"challenge"))
+ else if (!mir_strcmp(node->Name(), "challenge"))
OnProcessChallenge(node, info);
else if (!info->bIsReg) {
- if (!mir_wstrcmp(XmlGetName(node), L"message"))
+ if (!mir_strcmp(node->Name(), "message"))
OnProcessMessage(node, info);
- else if (!mir_wstrcmp(XmlGetName(node), L"presence"))
+ else if (!mir_strcmp(node->Name(), "presence"))
OnProcessPresence(node, info);
- else if (!mir_wstrcmp(XmlGetName(node), L"iq"))
+ else if (!mir_strcmp(node->Name(), "iq"))
OnProcessIq(node);
- else if (!mir_wstrcmp(XmlGetName(node), L"failed"))
+ else if (!mir_strcmp(node->Name(), "failed"))
OnProcessFailed(node, info);
- else if (!mir_wstrcmp(XmlGetName(node), L"enabled"))
+ else if (!mir_strcmp(node->Name(), "enabled"))
OnProcessEnabled(node, info);
- else if (m_bEnableStreamMgmt && !mir_wstrcmp(XmlGetName(node), L"resumed"))
+ else if (m_bEnableStreamMgmt && !mir_strcmp(node->Name(), "resumed"))
m_StrmMgmt.OnProcessResumed(node, info);
else
debugLogA("Invalid top-level tag (only <message/> <presence/> and <iq/> allowed)");
}
else {
- if (!mir_wstrcmp(XmlGetName(node), L"iq"))
+ if (!mir_strcmp(node->Name(), "iq"))
OnProcessRegIq(node, info);
else
debugLogA("Invalid top-level tag (only <iq/> allowed)");
}
}
-void CJabberProto::OnProcessProceed(HXML node, ThreadData *info)
+void CJabberProto::OnProcessProceed(const TiXmlElement *node, ThreadData *info)
{
- const wchar_t *type;
- if ((type = XmlGetAttrValue(node, L"xmlns")) != nullptr && !mir_wstrcmp(type, L"error"))
+ const char *type;
+ if ((type = node->Attribute("xmlns")) != nullptr && !mir_strcmp(type, "error"))
return;
- if (!mir_wstrcmp(type, L"urn:ietf:params:xml:ns:xmpp-tls")) {
+ if (!mir_strcmp(type, "urn:ietf:params:xml:ns:xmpp-tls")) {
debugLogA("Starting TLS...");
char* gtlk = strstr(info->conn.manualHost, "google.com");
@@ -961,14 +918,14 @@ void CJabberProto::OnProcessProceed(HXML node, ThreadData *info)
}
}
-void CJabberProto::OnProcessCompressed(HXML node, ThreadData *info)
+void CJabberProto::OnProcessCompressed(const TiXmlElement *node, ThreadData *info)
{
debugLogA("Compression confirmed");
- const wchar_t *type = XmlGetAttrValue(node, L"xmlns");
- if (type != nullptr && !mir_wstrcmp(type, L"error"))
+ const char *type = node->Attribute("xmlns");
+ if (type != nullptr && !mir_strcmp(type, "error"))
return;
- if (mir_wstrcmp(type, L"http://jabber.org/protocol/compress"))
+ if (mir_strcmp(type, "http://jabber.org/protocol/compress"))
return;
debugLogA("Starting Zlib stream compression...");
@@ -979,13 +936,13 @@ void CJabberProto::OnProcessCompressed(HXML node, ThreadData *info)
xmlStreamInitialize("after successful Zlib init");
}
-void CJabberProto::OnProcessPubsubEvent(HXML node)
+void CJabberProto::OnProcessPubsubEvent(const TiXmlElement *node)
{
- const wchar_t *from = XmlGetAttrValue(node, L"from");
+ const char *from = node->Attribute("from");
if (!from)
return;
- HXML eventNode = XmlGetChildByTag(node, "event", "xmlns", JABBER_FEAT_PUBSUB_EVENT);
+ auto *eventNode = XmlGetChildByTag(node, "event", "xmlns", JABBER_FEAT_PUBSUB_EVENT);
if (!eventNode)
return;
@@ -995,9 +952,8 @@ void CJabberProto::OnProcessPubsubEvent(HXML node)
if (!hContact)
return;
- HXML itemsNode;
if (m_bUseOMEMO) {
- itemsNode = XmlGetChildByTag(eventNode, L"items", L"node", JABBER_FEAT_OMEMO L".devicelist");
+ auto *itemsNode = XmlGetChildByTag(eventNode, "items", "node", JABBER_FEAT_OMEMO ".devicelist");
if (itemsNode) {
OmemoHandleDeviceList(itemsNode);
return;
@@ -1005,31 +961,32 @@ void CJabberProto::OnProcessPubsubEvent(HXML node)
//TODO:handle omemo device list
}
- if (m_bEnableUserTune && (itemsNode = XmlGetChildByTag(eventNode, "items", "node", JABBER_FEAT_USER_TUNE))) {
+ if (m_bEnableUserTune)
+ if (auto *itemsNode = XmlGetChildByTag(eventNode, "items", "node", JABBER_FEAT_USER_TUNE)) {
// node retract?
- if (XmlGetChild(itemsNode, "retract")) {
+ if (itemsNode->FirstChildElement("retract")) {
SetContactTune(hContact, nullptr, nullptr, nullptr, nullptr, nullptr);
return;
}
- HXML tuneNode = XPath(itemsNode, L"item/tune[@xmlns='" JABBER_FEAT_USER_TUNE L"']");
+ auto *tuneNode = XmlGetChildByTag(itemsNode->FirstChildElement("item"), "tune", "xmlns", JABBER_FEAT_USER_TUNE);
if (!tuneNode)
return;
- const wchar_t *szArtist = XPathT(tuneNode, "artist");
- const wchar_t *szLength = XPathT(tuneNode, "length");
- const wchar_t *szSource = XPathT(tuneNode, "source");
- const wchar_t *szTitle = XPathT(tuneNode, "title");
- const wchar_t *szTrack = XPathT(tuneNode, "track");
+ const char *szArtist = XPath(tuneNode, "artist");
+ const char *szLength = XPath(tuneNode, "length");
+ const char *szSource = XPath(tuneNode, "source");
+ const char *szTitle = XPath(tuneNode, "title");
+ const char *szTrack = XPath(tuneNode, "track");
wchar_t szLengthInTime[32];
szLengthInTime[0] = 0;
if (szLength) {
- int nLength = _wtoi(szLength);
+ int nLength = atoi(szLength);
mir_snwprintf(szLengthInTime, L"%02d:%02d:%02d", nLength / 3600, (nLength / 60) % 60, nLength % 60);
}
- SetContactTune(hContact, szArtist, szLength ? szLengthInTime : nullptr, szSource, szTitle, szTrack);
+ SetContactTune(hContact, Utf2T(szArtist), szLength ? szLengthInTime : nullptr, Utf2T(szSource), Utf2T(szTitle), Utf2T(szTrack));
}
}
@@ -1055,12 +1012,12 @@ DWORD JabberGetLastContactMessageTime(MCONTACT hContact)
return dwTime;
}
-MCONTACT CJabberProto::CreateTemporaryContact(const wchar_t *szJid, JABBER_LIST_ITEM* chatItem)
+MCONTACT CJabberProto::CreateTemporaryContact(const char *szJid, JABBER_LIST_ITEM* chatItem)
{
if (chatItem == nullptr)
- return DBCreateContact(szJid, ptrW(JabberNickFromJID(szJid)), true, true);
+ return DBCreateContact(szJid, ptrA(JabberNickFromJID(szJid)), true, true);
- const wchar_t *p = wcschr(szJid, '/');
+ const char *p = strchr(szJid, '/');
if (p != nullptr && p[1] != '\0')
p++;
else
@@ -1074,23 +1031,23 @@ MCONTACT CJabberProto::CreateTemporaryContact(const wchar_t *szJid, JABBER_LIST_
return hContact;
}
-void CJabberProto::OnProcessMessage(HXML node, ThreadData *info)
+void CJabberProto::OnProcessMessage(const TiXmlElement *node, ThreadData *info)
{
- if (!XmlGetName(node) || mir_wstrcmp(XmlGetName(node), L"message"))
+ if (!node->Name() || mir_strcmp(node->Name(), "message"))
return;
- const wchar_t *from, *type = XmlGetAttrValue(node, L"type");
- if ((from = XmlGetAttrValue(node, L"from")) == nullptr)
+ const char *from, *type = node->Attribute("type");
+ if ((from = node->Attribute("from")) == nullptr)
return;
- const wchar_t *idStr = XmlGetAttrValue(node, L"id");
+ const char *idStr = node->Attribute("id");
pResourceStatus pFromResource(ResourceInfoFromJID(from));
// Message receipts delivery request. Reply here, before a call to HandleMessagePermanent() to make sure message receipts are handled for external plugins too.
- if ((!type || mir_wstrcmpi(type, L"error")) && XmlGetChildByTag(node, "request", "xmlns", JABBER_FEAT_MESSAGE_RECEIPTS)) {
+ if ((!type || mir_strcmpi(type, "error")) && XmlGetChildByTag(node, "request", "xmlns", JABBER_FEAT_MESSAGE_RECEIPTS)) {
info->send(
- XmlNode(L"message") << XATTR(L"to", from) << XATTR(L"id", idStr)
- << XCHILDNS(L"received", JABBER_FEAT_MESSAGE_RECEIPTS) << XATTR(L"id", idStr));
+ XmlNode("message") << XATTR("to", from) << XATTR("id", idStr)
+ << XCHILDNS("received", JABBER_FEAT_MESSAGE_RECEIPTS) << XATTR("id", idStr));
if (pFromResource)
pFromResource->m_jcbManualDiscoveredCaps |= JABBER_CAPS_MESSAGE_RECEIPTS;
@@ -1100,7 +1057,7 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info)
return;
// Handle carbons. The message MUST be coming from our bare JID.
- HXML carbon = nullptr;
+ const TiXmlElement *carbon = nullptr;
bool carbonSent = false; //2 cases: received or sent.
if (IsMyOwnJID(from)) {
carbon = XmlGetChildByTag(node, "received", "xmlns", JABBER_FEAT_CARBONS);
@@ -1114,26 +1071,26 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info)
if (!m_bEnableCarbons)
return;
- HXML forwarded = nullptr;
- HXML message = nullptr;
+ const TiXmlElement *forwarded = nullptr;
+ const TiXmlElement *message = nullptr;
// Carbons MUST have forwarded/message content
if (!(forwarded = XmlGetChildByTag(carbon, "forwarded", "xmlns", JABBER_XMLNS_FORWARD))
- || !(message = XmlGetChild(forwarded, "message")))
+ || !(message = forwarded->FirstChildElement("message")))
return;
//Unwrap the carbon in any case
node = message;
- type = XmlGetAttrValue(node, L"type");
+ type = node->Attribute("type");
if (!carbonSent) {
// Received should just be treated like incoming messages, except maybe not flash the flasher. Simply unwrap.
- from = XmlGetAttrValue(node, L"from");
+ from = node->Attribute("from");
if (from == nullptr)
return;
}
else {
// Sent should set SENT flag and invert from/to.
- from = XmlGetAttrValue(node, L"to");
+ from = node->Attribute("to");
if (from == nullptr)
return;
}
@@ -1143,44 +1100,30 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info)
MCONTACT hContact = HContactFromJID(from);
JABBER_LIST_ITEM *chatItem = ListGetItemPtr(LIST_CHATROOM, from);
if (chatItem) {
- HXML xCaptcha = XmlGetChild(node, "captcha");
+ auto *xCaptcha = node->FirstChildElement("captcha");
if (xCaptcha)
if (ProcessCaptcha(xCaptcha, node, info))
return;
}
- const wchar_t *szMessage = nullptr;
- HXML bodyNode = XmlGetChildByTag(node, "body", "xml:lang", m_tszSelectedLang);
+ CMStringA szMessage;
+ auto *bodyNode = XmlGetChildByTag(node, "body", "xml:lang", m_tszSelectedLang);
if (bodyNode == nullptr)
- bodyNode = XmlGetChild(node, "body");
- if (bodyNode != nullptr)
- szMessage = XmlGetText(bodyNode);
+ bodyNode = node->FirstChildElement("body");
- const wchar_t *ptszSubject = XmlGetText(XmlGetChild(node, "subject"));
+ const char *ptszSubject = node->FirstChildElement("subject")->GetText();
if (ptszSubject && *ptszSubject) {
- size_t cbLen = (szMessage ? mir_wstrlen(szMessage) : 0) + mir_wstrlen(ptszSubject) + 128;
- wchar_t *szTmp = (wchar_t *)alloca(sizeof(wchar_t) * cbLen);
- szTmp[0] = 0;
- if (szMessage)
- mir_wstrcat(szTmp, L"Subject: ");
- mir_wstrcat(szTmp, ptszSubject);
- if (szMessage) {
- mir_wstrcat(szTmp, L"\r\n");
- mir_wstrcat(szTmp, szMessage);
- }
- szMessage = szTmp;
- }
-
- HXML n;
- if (szMessage && (n = XmlGetChildByTag(node, "addresses", "xmlns", JABBER_FEAT_EXT_ADDRESSING))) {
- HXML addressNode = XmlGetChildByTag(n, "address", "type", L"ofrom");
+ szMessage.Append("Subject: ");
+ szMessage.Append(ptszSubject);
+ szMessage.Append("\r\n");
+ }
+
+ if (szMessage) if (auto *n = XmlGetChildByTag(node, "addresses", "xmlns", JABBER_FEAT_EXT_ADDRESSING)) {
+ auto *addressNode = XmlGetChildByTag(n, "address", "type", "ofrom");
if (addressNode) {
- const wchar_t *szJid = XmlGetAttrValue(addressNode, L"jid");
+ const char *szJid = addressNode->Attribute("jid");
if (szJid) {
- size_t cbLen = mir_wstrlen(szMessage) + 1000;
- wchar_t *p = (wchar_t*)alloca(sizeof(wchar_t) * cbLen);
- mir_snwprintf(p, cbLen, TranslateT("Message redirected from: %s\r\n%s"), from, szMessage);
- szMessage = p;
+ szMessage.AppendFormat(Translate("Message redirected from: %s\r\n"), from);
from = szJid;
// rewrite hContact
hContact = HContactFromJID(from);
@@ -1188,6 +1131,9 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info)
}
}
+ if (bodyNode != nullptr)
+ szMessage.Append(bodyNode->GetText());
+
// If message is from a stranger (not in roster), item is nullptr
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, from);
if (item == nullptr)
@@ -1195,10 +1141,10 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info)
time_t msgTime = 0;
bool isChatRoomInvitation = false;
- const wchar_t *inviteRoomJid = nullptr;
- const wchar_t *inviteFromJid = nullptr;
- const wchar_t *inviteReason = nullptr;
- const wchar_t *invitePassword = nullptr;
+ const char *inviteRoomJid = nullptr;
+ const char *inviteFromJid = nullptr;
+ const char *inviteReason = nullptr;
+ const char *invitePassword = nullptr;
bool isDelivered = false;
// check chatstates availability
@@ -1221,7 +1167,7 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info)
}
// message receipts delivery notification
- if (n = XmlGetChildByTag(node, "received", "xmlns", JABBER_FEAT_MESSAGE_RECEIPTS)) {
+ if (auto *n = XmlGetChildByTag(node, "received", "xmlns", JABBER_FEAT_MESSAGE_RECEIPTS)) {
int nPacketId = JabberGetPacketID(n);
if (nPacketId == -1)
nPacketId = JabberGetPacketID(node);
@@ -1252,10 +1198,10 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info)
db_event_add(hContact, &dbei);
}
- if ((n = XmlGetChildByTag(node, "confirm", "xmlns", JABBER_FEAT_HTTP_AUTH)) && m_bAcceptHttpAuth) {
- const wchar_t *szId = XmlGetAttrValue(n, L"id");
- const wchar_t *szMethod = XmlGetAttrValue(n, L"method");
- const wchar_t *szUrl = XmlGetAttrValue(n, L"url");
+ if (auto *n = XmlGetChildByTag(node, "confirm", "xmlns", JABBER_FEAT_HTTP_AUTH)) if (m_bAcceptHttpAuth) {
+ const char *szId = n->Attribute("id");
+ const char *szMethod = n->Attribute("method");
+ const char *szUrl = n->Attribute("url");
if (!szId || !szMethod || !szUrl)
return;
@@ -1265,81 +1211,67 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info)
memset(pParams, 0, sizeof(CJabberHttpAuthParams));
pParams->m_nType = CJabberHttpAuthParams::MSG;
- pParams->m_szFrom = mir_wstrdup(from);
- const wchar_t *ptszThread = XmlGetText(XmlGetChild(node, "thread"));
+ pParams->m_szFrom = mir_strdup(from);
+ const char *ptszThread = node->FirstChildElement("thread")->GetText();
if (ptszThread && *ptszThread)
- pParams->m_szThreadId = mir_wstrdup(ptszThread);
- pParams->m_szId = mir_wstrdup(szId);
- pParams->m_szMethod = mir_wstrdup(szMethod);
- pParams->m_szUrl = mir_wstrdup(szUrl);
+ pParams->m_szThreadId = mir_strdup(ptszThread);
+ pParams->m_szId = mir_strdup(szId);
+ pParams->m_szMethod = mir_strdup(szMethod);
+ pParams->m_szUrl = mir_strdup(szUrl);
AddClistHttpAuthEvent(pParams);
return;
}
// parsing extensions
- HXML xNode;
- for (int i = 0; (xNode = XmlGetChild(node, i)) != nullptr; i++) {
+ for (auto *xNode : TiXmlEnum(node)) {
if (m_bUseOMEMO) {
- if ((xNode = XmlGetNthChild(node, L"encrypted", i + 1)) != nullptr) {
- const wchar_t *ptszXmlns = XmlGetAttrValue(xNode, L"xmlns");
- if (ptszXmlns == nullptr)
- continue;
-
- if (!mir_wstrcmp(ptszXmlns, JABBER_FEAT_OMEMO)) {
- const wchar_t *jid = xmlGetAttrValue(node, L"from");
- if (jid) {
- if (!OmemoHandleMessage(xNode, (wchar_t*)jid, msgTime))
- OmemoPutMessageToIncommingQueue(xNode, (wchar_t*)jid, msgTime);
- return; //we do not want any additional processing
- }
+ if (!mir_strcmp(xNode->Name(), "encrypted") && xNode->Attribute("xmlns", JABBER_FEAT_OMEMO)) {
+ const char *jid = xNode->Attribute("from");
+ if (jid) {
+ if (!OmemoHandleMessage(xNode, jid, msgTime))
+ OmemoPutMessageToIncommingQueue(xNode, jid, msgTime);
+ return; //we do not want any additional processing
}
}
}
- if ((xNode = XmlGetNthChild(node, L"x", i + 1)) == nullptr)
+ if (0 != mir_strcmp(xNode->Name(), "x"))
continue;
- const wchar_t *ptszXmlns = XmlGetAttrValue(xNode, L"xmlns");
- if (ptszXmlns == nullptr)
+ const char *pszXmlns = xNode->Attribute("xmlns");
+ if (pszXmlns == nullptr)
continue;
- if (!mir_wstrcmp(ptszXmlns, JABBER_FEAT_MIRANDA_NOTES)) {
- if (OnIncomingNote(from, XmlGetChild(xNode, "note")))
+ if (!mir_strcmp(pszXmlns, JABBER_FEAT_MIRANDA_NOTES)) {
+ if (OnIncomingNote(from, xNode->FirstChildElement("note")))
return;
}
- else if (!mir_wstrcmp(ptszXmlns, L"jabber:x:encrypted")) {
- const wchar_t *ptszText = XmlGetText(xNode);
+ else if (!mir_strcmp(pszXmlns, "jabber:x:encrypted")) {
+ const char *ptszText = xNode->GetText();
if (ptszText == nullptr)
return;
- //XEP-0027 is not strict enough, different clients have different implementations
- //additional validation is required
- wchar_t *prolog = L"-----BEGIN PGP MESSAGE-----";
- wchar_t *prolog_newline = L"\r\n\r\n";
- wchar_t *epilog = L"\r\n-----END PGP MESSAGE-----\r\n";
-
- size_t len = 0;
- wchar_t *tempstring = nullptr;
- if (!wcsstr(ptszText, prolog)) {
- len = mir_wstrlen(prolog) + mir_wstrlen(prolog_newline) + mir_wstrlen(ptszText) + mir_wstrlen(epilog) + 3;
- tempstring = (wchar_t*)_alloca(sizeof(wchar_t)*len);
- mir_snwprintf(tempstring, len, L"%s%s%s%s", prolog, prolog_newline, ptszText, epilog);
- }
- else {
- len = mir_wstrlen(ptszText) + 3;
- tempstring = (wchar_t*)_alloca(sizeof(wchar_t)*len);
- mir_snwprintf(tempstring, len, L"%s", ptszText);
- }
+ // XEP-0027 is not strict enough, different clients have different implementations
+ // additional validation is required
+ char *prolog = "-----BEGIN PGP MESSAGE-----";
+ char *prolog_newline = "\r\n\r\n";
+ char *epilog = "\r\n-----END PGP MESSAGE-----\r\n";
- szMessage = tempstring;
+ CMStringA tempstring;
+ if (!strstr(ptszText, prolog))
+ tempstring.Format("%s%s%s%s", prolog, prolog_newline, ptszText, epilog);
+ else
+ tempstring = ptszText;
+
+ szMessage += tempstring;
}
- else if (!mir_wstrcmp(ptszXmlns, JABBER_FEAT_DELAY) && msgTime == 0) {
- const wchar_t *ptszTimeStamp = XmlGetAttrValue(xNode, L"stamp");
+ else if (!mir_strcmp(pszXmlns, JABBER_FEAT_DELAY) && msgTime == 0) {
+ const char *ptszTimeStamp = xNode->Attribute("stamp");
if (ptszTimeStamp != nullptr)
msgTime = JabberIsoToUnixTime(ptszTimeStamp);
}
- else if (!mir_wstrcmp(ptszXmlns, JABBER_FEAT_MESSAGE_EVENTS)) {
+ else if (!mir_strcmp(pszXmlns, JABBER_FEAT_MESSAGE_EVENTS)) {
// set events support only if we discovered caps and if events not already set
JabberCapsBits jcbCaps = GetResourceCapabilities(from);
@@ -1350,88 +1282,79 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info)
// pFromResource->m_jcbManualDiscoveredCaps |= (JABBER_CAPS_MESSAGE_EVENTS | JABBER_CAPS_MESSAGE_EVENTS_NO_DELIVERY);
if (bodyNode == nullptr) {
- HXML idNode = XmlGetChild(xNode, "id");
- if (XmlGetChild(xNode, "delivered") != nullptr || XmlGetChild(xNode, "offline") != nullptr) {
+ auto *idNode = xNode->FirstChildElement("id");
+ if (xNode->FirstChildElement("delivered") != nullptr || xNode->FirstChildElement("offline") != nullptr) {
int id = -1;
- if (idNode != nullptr && XmlGetText(idNode) != nullptr)
- if (!wcsncmp(XmlGetText(idNode), _T(JABBER_IQID), mir_strlen(JABBER_IQID)))
- id = _wtoi((XmlGetText(idNode)) + mir_strlen(JABBER_IQID));
+ if (idNode != nullptr && idNode->GetText() != nullptr)
+ if (!strncmp(idNode->GetText(), JABBER_IQID, mir_strlen(JABBER_IQID)))
+ id = atoi((idNode->GetText()) + mir_strlen(JABBER_IQID));
if (id != -1)
ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)id, 0);
}
- if (hContact && XmlGetChild(xNode, "composing") != nullptr)
+ if (hContact && xNode->FirstChildElement("composing") != nullptr)
CallService(MS_PROTO_CONTACTISTYPING, hContact, 60);
// Maybe a cancel to the previous composing
- HXML child = XmlGetChild(xNode, 0);
+ auto *child = xNode->FirstChildElement(0);
if (hContact && (!child || (child && idNode != nullptr)))
CallService(MS_PROTO_CONTACTISTYPING, hContact, PROTOTYPE_CONTACTTYPING_OFF);
}
else {
// Check whether any event is requested
- if (!isDelivered && (n = XmlGetChild(xNode, "delivered")) != nullptr) {
+ if (!isDelivered && xNode->FirstChildElement("delivered")) {
isDelivered = true;
- XmlNode m(L"message"); m << XATTR(L"to", from);
- HXML x = m << XCHILDNS(L"x", JABBER_FEAT_MESSAGE_EVENTS);
- x << XCHILD(L"delivered");
- x << XCHILD(L"id", idStr);
+ XmlNode m("message"); m << XATTR("to", from);
+ TiXmlElement *x = m << XCHILDNS("x", JABBER_FEAT_MESSAGE_EVENTS);
+ x << XCHILD("delivered");
+ x << XCHILD("id", idStr);
info->send(m);
}
- if (item != nullptr && XmlGetChild(xNode, "composing") != nullptr) {
+
+ if (item != nullptr && xNode->FirstChildElement("composing") != nullptr) {
if (item->messageEventIdStr)
mir_free(item->messageEventIdStr);
- item->messageEventIdStr = (idStr == nullptr) ? nullptr : mir_wstrdup(idStr);
+ item->messageEventIdStr = (idStr == nullptr) ? nullptr : mir_strdup(idStr);
}
}
}
- else if (!mir_wstrcmp(ptszXmlns, JABBER_FEAT_OOB2)) {
- const wchar_t *ptszUrl = XmlGetText(XmlGetChild(xNode, "url"));
- if (ptszUrl != nullptr && *ptszUrl) {
- size_t cbLen = (szMessage ? mir_wstrlen(szMessage) : 0) + mir_wstrlen(ptszUrl) + 32;
- wchar_t *szTmp = (wchar_t *)alloca(sizeof(wchar_t)* cbLen);
- mir_wstrcpy(szTmp, ptszUrl);
- if (szMessage) {
- mir_wstrcat(szTmp, L"\r\n");
- mir_wstrcat(szTmp, szMessage);
- }
- szMessage = szTmp;
+ else if (!mir_strcmp(pszXmlns, JABBER_FEAT_OOB2)) {
+ const char *pszUrl = xNode->FirstChildElement("url")->GetText();
+ if (pszUrl != nullptr && *pszUrl) {
+ if (!szMessage.IsEmpty())
+ szMessage.Append("\r\n");
+ szMessage.Append(pszUrl);
}
}
- else if (!mir_wstrcmp(ptszXmlns, JABBER_FEAT_MUC_USER)) {
- HXML inviteNode = XmlGetChild(xNode, L"invite");
+ else if (!mir_strcmp(pszXmlns, JABBER_FEAT_MUC_USER)) {
+ auto *inviteNode = xNode->FirstChildElement("invite");
if (inviteNode != nullptr) {
- inviteFromJid = XmlGetAttrValue(inviteNode, L"from");
- inviteReason = XmlGetText(XmlGetChild(inviteNode, L"reason"));
+ inviteFromJid = inviteNode->Attribute("from");
+ inviteReason = inviteNode->FirstChildElement("reason")->GetText();
inviteRoomJid = from;
if (inviteReason == nullptr)
inviteReason = szMessage;
isChatRoomInvitation = true;
- invitePassword = XmlGetText(XmlGetChild(xNode, "password"));
+ invitePassword = xNode->FirstChildElement("password")->GetText();
}
}
- else if (!mir_wstrcmp(ptszXmlns, JABBER_FEAT_ROSTER_EXCHANGE) &&
- item != nullptr && (item->subscription == SUB_BOTH || item->subscription == SUB_TO)) {
- wchar_t chkJID[JABBER_MAX_JID_LEN] = L"@";
+ else if (!mir_strcmp(pszXmlns, JABBER_FEAT_ROSTER_EXCHANGE) && item != nullptr && (item->subscription == SUB_BOTH || item->subscription == SUB_TO)) {
+ char chkJID[JABBER_MAX_JID_LEN] = "@";
JabberStripJid(from, chkJID + 1, _countof(chkJID) - 1);
- for (int j = 1;; j++) {
- HXML iNode = XmlGetNthChild(xNode, L"item", j);
- if (iNode == nullptr)
- break;
-
- const wchar_t *action = XmlGetAttrValue(iNode, L"action");
- const wchar_t *jid = XmlGetAttrValue(iNode, L"jid");
- const wchar_t *nick = XmlGetAttrValue(iNode, L"name");
- const wchar_t *group = XmlGetText(XmlGetChild(iNode, L"group"));
- if (action && jid && wcsstr(jid, chkJID)) {
- if (!mir_wstrcmp(action, L"add")) {
+ for (auto *iNode : TiXmlFilter(xNode, "item")) {
+ const char *action = iNode->Attribute("action");
+ const char *jid = iNode->Attribute("jid");
+ const char *nick = iNode->Attribute("name");
+ const char *group = iNode->FirstChildElement("group")->GetText();
+ if (action && jid && strstr(jid, chkJID)) {
+ if (!mir_strcmp(action, "add")) {
MCONTACT cc = DBCreateContact(jid, nick, false, false);
if (group)
- db_set_ws(cc, "CList", "Group", group);
+ db_set_utf(cc, "CList", "Group", group);
}
- else if (!mir_wstrcmp(action, L"delete")) {
+ else if (!mir_strcmp(action, "delete")) {
MCONTACT cc = HContactFromJID(jid);
if (cc)
db_delete_contact(cc);
@@ -1439,11 +1362,11 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info)
}
}
}
- else if (!isChatRoomInvitation && !mir_wstrcmp(ptszXmlns, JABBER_FEAT_DIRECT_MUC_INVITE)) {
- inviteRoomJid = XmlGetAttrValue(xNode, L"jid");
+ else if (!isChatRoomInvitation && !mir_strcmp(pszXmlns, JABBER_FEAT_DIRECT_MUC_INVITE)) {
+ inviteRoomJid = xNode->Attribute("jid");
inviteFromJid = from;
if (inviteReason == nullptr)
- inviteReason = XmlGetText(xNode);
+ inviteReason = xNode->GetText();
if (!inviteReason)
inviteReason = szMessage;
isChatRoomInvitation = true;
@@ -1470,13 +1393,11 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info)
}
// all service info was already processed
- if (szMessage == nullptr)
+ if (szMessage.IsEmpty())
return;
- CMStringW tmp(szMessage);
- tmp += ExtractImage(node);
- tmp.Replace(L"\n", L"\r\n");
- ptrA buf(mir_utf8encodeW(tmp));
+ szMessage += ExtractImage(node);
+ szMessage.Replace("\n", "\r\n");
if (item != nullptr) {
if (pFromResource) {
@@ -1508,12 +1429,12 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info)
recv.flags |= PREF_SENT;
}
recv.timestamp = (DWORD)msgTime;
- recv.szMessage = buf;
+ recv.szMessage = szMessage.GetBuffer();
ProtoChainRecvMsg(hContact, &recv);
}
// XEP-0115: Entity Capabilities
-void CJabberProto::OnProcessPresenceCapabilites(HXML node, pResourceStatus &r)
+void CJabberProto::OnProcessPresenceCapabilites(const TiXmlElement *node, pResourceStatus &r)
{
if (r == nullptr)
return;
@@ -1522,27 +1443,26 @@ void CJabberProto::OnProcessPresenceCapabilites(HXML node, pResourceStatus &r)
if (r->m_pCaps != nullptr)
return;
- const wchar_t *from = XmlGetAttrValue(node, L"from");
+ const char *from = node->Attribute("from");
if (from == nullptr)
return;
- HXML n = XmlGetChildByTag(node, "c", "xmlns", JABBER_FEAT_ENTITY_CAPS);
+ auto *n = XmlGetChildByTag(node, "c", "xmlns", JABBER_FEAT_ENTITY_CAPS);
if (n == nullptr)
return;
- const wchar_t *szNode = XmlGetAttrValue(n, L"node");
- const wchar_t *szVer = XmlGetAttrValue(n, L"ver");
- const wchar_t *szExt = XmlGetAttrValue(n, L"ext");
+ const char *szNode = n->Attribute("node");
+ const char *szVer = n->Attribute("ver");
+ const char *szExt = n->Attribute("ext");
if (szNode == nullptr || szVer == nullptr)
return;
- const wchar_t *szHash = XmlGetAttrValue(n, L"hash");
+ const char *szHash = n->Attribute("hash");
if (szHash == nullptr) { // old version
- ptrA szVerUtf(mir_utf8encodeW(szVer));
BYTE hashOut[MIR_SHA1_HASH_SIZE];
- mir_sha1_hash((BYTE*)szVerUtf.get(), mir_strlen(szVerUtf), hashOut);
- wchar_t szHashOut[MIR_SHA1_HASH_SIZE * 2 + 1];
- bin2hexW(hashOut, _countof(hashOut), szHashOut);
+ mir_sha1_hash((BYTE*)szVer, mir_strlen(szVer), hashOut);
+ char szHashOut[MIR_SHA1_HASH_SIZE * 2 + 1];
+ bin2hex(hashOut, _countof(hashOut), szHashOut);
r->m_pCaps = m_clientCapsManager.GetPartialCaps(szNode, szHashOut);
if (r->m_pCaps == nullptr)
GetCachedCaps(szNode, szHashOut, r);
@@ -1562,15 +1482,15 @@ void CJabberProto::OnProcessPresenceCapabilites(HXML node, pResourceStatus &r)
GetCachedCaps(szNode, szVer, r);
if (r->m_pCaps == nullptr) {
- r->m_pCaps = m_clientCapsManager.SetClientCaps(szNode, szVer, L"", JABBER_RESOURCE_CAPS_UNINIT);
+ r->m_pCaps = m_clientCapsManager.SetClientCaps(szNode, szVer, "", JABBER_RESOURCE_CAPS_UNINIT);
GetResourceCapabilities(from, r);
}
}
- r->m_tszCapsExt = mir_wstrdup(szExt);
+ r->m_tszCapsExt = mir_strdup(szExt);
}
-void CJabberProto::UpdateJidDbSettings(const wchar_t *jid)
+void CJabberProto::UpdateJidDbSettings(const char *jid)
{
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid);
if (item == nullptr)
@@ -1583,10 +1503,10 @@ void CJabberProto::UpdateJidDbSettings(const wchar_t *jid)
int status = ID_STATUS_OFFLINE;
if (!item->arResources.getCount()) {
// set offline only if jid has resources
- if (wcschr(jid, '/') == nullptr)
+ if (strchr(jid, '/') == nullptr)
status = item->getTemp()->m_iStatus;
- if (item->getTemp()->m_tszStatusMessage)
- db_set_ws(hContact, "CList", "StatusMsg", item->getTemp()->m_tszStatusMessage);
+ if (item->getTemp()->m_szStatusMessage)
+ db_set_utf(hContact, "CList", "StatusMsg", item->getTemp()->m_szStatusMessage);
else
db_unset(hContact, "CList", "StatusMsg");
}
@@ -1609,16 +1529,16 @@ void CJabberProto::UpdateJidDbSettings(const wchar_t *jid)
item->getTemp()->m_iStatus = status;
if (nSelectedResource != -1) {
pResourceStatus r(item->arResources[nSelectedResource]);
- debugLogW(L"JabberUpdateJidDbSettings: updating jid %s to rc %s", item->jid, r->m_tszResourceName);
- if (r->m_tszStatusMessage)
- db_set_ws(hContact, "CList", "StatusMsg", r->m_tszStatusMessage);
+ debugLogW(L"JabberUpdateJidDbSettings: updating jid %s to rc %s", item->jid, r->m_szResourceName);
+ if (r->m_szStatusMessage)
+ db_set_utf(hContact, "CList", "StatusMsg", r->m_szStatusMessage);
else
db_unset(hContact, "CList", "StatusMsg");
UpdateMirVer(hContact, r);
}
else delSetting(hContact, DBSETTING_DISPLAY_UID);
- if (wcschr(jid, '@') != nullptr || m_bShowTransport == TRUE)
+ if (strchr(jid, '@') != nullptr || m_bShowTransport == TRUE)
if (getWord(hContact, "Status", ID_STATUS_OFFLINE) != status)
setWord(hContact, "Status", (WORD)status);
@@ -1632,12 +1552,12 @@ void CJabberProto::UpdateJidDbSettings(const wchar_t *jid)
MenuUpdateSrmmIcon(item);
}
-void CJabberProto::OnProcessPresence(HXML node, ThreadData *info)
+void CJabberProto::OnProcessPresence(const TiXmlElement *node, ThreadData *info)
{
- if (!node || !XmlGetName(node) || mir_wstrcmp(XmlGetName(node), L"presence"))
+ if (!node || !node->Name() || mir_strcmp(node->Name(), "presence"))
return;
- const wchar_t *from = XmlGetAttrValue(node, L"from");
+ const char *from = node->Attribute("from");
if (from == nullptr)
return;
@@ -1651,22 +1571,22 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info)
MCONTACT hContact;
bool bSelfPresence = false;
- wchar_t szBareFrom[JABBER_MAX_JID_LEN];
+ char szBareFrom[JABBER_MAX_JID_LEN];
JabberStripJid(from, szBareFrom, _countof(szBareFrom));
- wchar_t szBareOurJid[JABBER_MAX_JID_LEN];
+ char szBareOurJid[JABBER_MAX_JID_LEN];
JabberStripJid(info->fullJID, szBareOurJid, _countof(szBareOurJid));
- if (!mir_wstrcmpi(szBareFrom, szBareOurJid))
+ if (!mir_strcmpi(szBareFrom, szBareOurJid))
bSelfPresence = true;
- const wchar_t *type = XmlGetAttrValue(node, L"type");
- if (type == nullptr || !mir_wstrcmp(type, L"available")) {
- ptrW nick(JabberNickFromJID(from));
+ const char *type = node->Attribute("type");
+ if (type == nullptr || !mir_strcmp(type, "available")) {
+ ptrA nick(JabberNickFromJID(from));
if (nick == nullptr)
return;
if ((hContact = HContactFromJID(from)) == 0) {
- if (!mir_wstrcmpi(info->fullJID, from) || (!bSelfPresence && !ListGetItemPtr(LIST_ROSTER, from))) {
+ if (!mir_strcmpi(info->fullJID, from) || (!bSelfPresence && !ListGetItemPtr(LIST_ROSTER, from))) {
debugLogW(L"SKIP Receive presence online from %s (who is not in my roster and not in list - skiping)", from);
return;
}
@@ -1678,20 +1598,20 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info)
}
DBCheckIsTransportedContact(from, hContact);
int status = ID_STATUS_ONLINE;
- if (HXML showNode = XmlGetChild(node, "show")) {
- if (const wchar_t *show = XmlGetText(showNode)) {
- if (!mir_wstrcmp(show, L"away")) status = ID_STATUS_AWAY;
- else if (!mir_wstrcmp(show, L"xa")) status = ID_STATUS_NA;
- else if (!mir_wstrcmp(show, L"dnd")) status = ID_STATUS_DND;
- else if (!mir_wstrcmp(show, L"chat")) status = ID_STATUS_FREECHAT;
+ if (auto *showNode = node->FirstChildElement("show")) {
+ if (const char *show = showNode->GetText()) {
+ if (!mir_strcmp(show, "away")) status = ID_STATUS_AWAY;
+ else if (!mir_strcmp(show, "xa")) status = ID_STATUS_NA;
+ else if (!mir_strcmp(show, "dnd")) status = ID_STATUS_DND;
+ else if (!mir_strcmp(show, "chat")) status = ID_STATUS_FREECHAT;
}
}
char priority = 0;
- if (const wchar_t *ptszPriority = XmlGetText(XmlGetChild(node, "priority")))
- priority = (char)_wtoi(ptszPriority);
+ if (const char *ptszPriority = node->FirstChildElement("priority")->GetText())
+ priority = atoi(ptszPriority);
- ListAddResource(LIST_ROSTER, from, status, XmlGetText(XmlGetChild(node, "status")), priority);
+ ListAddResource(LIST_ROSTER, from, status, node->FirstChildElement("status")->GetText(), priority);
// XEP-0115: Entity Capabilities
pResourceStatus r(ResourceInfoFromJID(from));
@@ -1700,43 +1620,42 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info)
UpdateJidDbSettings(from);
- if (wcschr(from, '@') == nullptr) {
+ if (strchr(from, '@') == nullptr) {
UI_SAFE_NOTIFY(m_pDlgServiceDiscovery, WM_JABBER_TRANSPORT_REFRESH);
}
debugLogW(L"%s (%s) online, set contact status to %s", nick, from, Clist_GetStatusModeDescription(status, 0));
if (m_bEnableAvatars) {
- HXML xNode;
bool bHasAvatar = false, bRemovedAvatar = false;
debugLogA("Avatar enabled");
- for (int i = 1; (xNode = XmlGetNthChild(node, L"x", i)) != nullptr; i++) {
- if (!bHasAvatar && !mir_wstrcmp(XmlGetAttrValue(xNode, L"xmlns"), L"jabber:x:avatar")) {
- const wchar_t *ptszHash = XmlGetText(XmlGetChild(xNode, "hash"));
+ for (auto *xNode : TiXmlFilter(node, "x")) {
+ if (!bHasAvatar && !mir_strcmp(xNode->Attribute("xmlns"), "jabber:x:avatar")) {
+ const char *ptszHash = xNode->FirstChildElement("hash")->GetText();
if (ptszHash != nullptr) {
delSetting(hContact, "AvatarXVcard");
debugLogA("AvatarXVcard deleted");
- setWString(hContact, "AvatarHash", ptszHash);
+ setString(hContact, "AvatarHash", ptszHash);
bHasAvatar = true;
- ptrW saved(getWStringA(hContact, "AvatarSaved"));
- if (saved == nullptr || mir_wstrcmp(saved, ptszHash)) {
+ ptrA saved(getStringA(hContact, "AvatarSaved"));
+ if (saved == nullptr || mir_strcmp(saved, ptszHash)) {
debugLogA("Avatar was changed");
ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, nullptr, 0);
}
}
else bRemovedAvatar = true;
}
- else if (!mir_wstrcmp(XmlGetAttrValue(xNode, L"xmlns"), L"vcard-temp:x:update")) {
- HXML xPhoto = XmlGetChild(xNode, "photo");
+ else if (!mir_strcmp(xNode->Attribute("xmlns"), "vcard-temp:x:update")) {
+ auto *xPhoto = xNode->FirstChildElement("photo");
if (xPhoto && !bHasAvatar) {
- const wchar_t *txt = XmlGetText(xPhoto);
- if (mir_wstrlen(txt)) {
+ const char *txt = xPhoto->GetText();
+ if (mir_strlen(txt)) {
setByte(hContact, "AvatarXVcard", 1);
debugLogA("AvatarXVcard set");
- setWString(hContact, "AvatarHash", txt);
+ setString(hContact, "AvatarHash", txt);
bHasAvatar = true;
- ptrW saved(getWStringA(hContact, "AvatarSaved"));
- if (saved == nullptr || mir_wstrcmp(saved, txt)) {
+ ptrA saved(getStringA(hContact, "AvatarSaved"));
+ if (saved == nullptr || mir_strcmp(saved, txt)) {
debugLogA("Avatar was changed. Using vcard-temp:x:update");
ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, nullptr, 0);
}
@@ -1744,12 +1663,12 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info)
else bRemovedAvatar = true;
}
- const wchar_t *txt = xmlGetAttrValue(xNode, L"vcard");
- if (mir_wstrlen(txt)) {
- ptrW saved(getWStringA(hContact, "VCardHash"));
- if (saved == nullptr || mir_wstrcmp(saved, txt)) {
+ const char *txt = xNode->Attribute("vcard");
+ if (mir_strlen(txt)) {
+ ptrA saved(getStringA(hContact, "VCardHash"));
+ if (saved == nullptr || mir_strcmp(saved, txt)) {
debugLogA("Vcard was changed, let's read it");
- setWString(hContact, "VCardHash", txt);
+ setString(hContact, "VCardHash", txt);
SendGetVcard(from);
}
}
@@ -1769,7 +1688,7 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info)
return;
}
- if (!mir_wstrcmp(type, L"unavailable")) {
+ if (!mir_strcmp(type, "unavailable")) {
hContact = HContactFromJID(from);
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, from);
if (item != nullptr) {
@@ -1786,38 +1705,38 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info)
// set status only if no more available resources
if (!item->arResources.getCount()) {
item->getTemp()->m_iStatus = ID_STATUS_OFFLINE;
- item->getTemp()->m_tszStatusMessage = mir_wstrdup(XmlGetText(XmlGetChild(node, "status")));
+ item->getTemp()->m_szStatusMessage = mir_strdup(node->FirstChildElement("status")->GetText());
}
}
else debugLogW(L"SKIP Receive presence offline from %s (who is not in my roster)", from);
UpdateJidDbSettings(from);
- if (wcschr(from, '@') == nullptr)
+ if (strchr(from, '@') == nullptr)
UI_SAFE_NOTIFY(m_pDlgServiceDiscovery, WM_JABBER_TRANSPORT_REFRESH);
DBCheckIsTransportedContact(from, hContact);
return;
}
- if (!mir_wstrcmp(type, L"subscribe")) {
+ if (!mir_strcmp(type, "subscribe")) {
if (hContact = HContactFromJID(from))
AddDbPresenceEvent(hContact, JABBER_DB_EVENT_PRESENCE_SUBSCRIBE);
- ptrW tszNick(JabberNickFromJID(from));
- HXML xNick = XmlGetChildByTag(node, "nick", "xmlns", JABBER_FEAT_NICK);
+ ptrA tszNick(JabberNickFromJID(from));
+ auto *xNick = XmlGetChildByTag(node, "nick", "xmlns", JABBER_FEAT_NICK);
if (xNick != nullptr) {
- const wchar_t *xszNick = XmlGetText(xNick);
+ const char *xszNick = xNick->GetText();
if (xszNick != nullptr && *xszNick) {
- debugLogW(L"Grabbed nick from presence: %s", xszNick);
- tszNick = mir_wstrdup(xszNick);
+ debugLogA("Grabbed nick from presence: %s", xszNick);
+ tszNick = mir_strdup(xszNick);
}
}
// automatically send authorization allowed to agent/transport
- if (wcschr(from, '@') == nullptr || m_bAutoAcceptAuthorization) {
+ if (strchr(from, '@') == nullptr || m_bAutoAcceptAuthorization) {
ListAdd(LIST_ROSTER, from, hContact);
- info->send(XmlNode(L"presence") << XATTR(L"to", from) << XATTR(L"type", L"subscribed"));
+ info->send(XmlNode("presence") << XATTR("to", from) << XATTR("type", "subscribed"));
if (m_bAutoAdd == TRUE) {
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, from);
@@ -1826,7 +1745,7 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info)
if ((hContact = AddToListByJID(from, 0)) != 0) {
if (item)
item->hContact = hContact;
- setWString(hContact, "Nick", tszNick);
+ setUString(hContact, "Nick", tszNick);
db_unset(hContact, "CList", "NotOnList");
}
}
@@ -1840,19 +1759,19 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info)
return;
}
- if (!mir_wstrcmp(type, L"unsubscribe"))
+ if (!mir_strcmp(type, "unsubscribe"))
if (hContact = HContactFromJID(from))
AddDbPresenceEvent(hContact, JABBER_DB_EVENT_PRESENCE_UNSUBSCRIBE);
- if (!mir_wstrcmp(type, L"unsubscribed"))
+ if (!mir_strcmp(type, "unsubscribed"))
if (hContact = HContactFromJID(from))
AddDbPresenceEvent(hContact, JABBER_DB_EVENT_PRESENCE_UNSUBSCRIBED);
- if (!mir_wstrcmp(type, L"error"))
+ if (!mir_strcmp(type, "error"))
if (hContact = HContactFromJID(from))
AddDbPresenceEvent(hContact, JABBER_DB_EVENT_PRESENCE_ERROR);
- if (!mir_wstrcmp(type, L"subscribed")) {
+ if (!mir_strcmp(type, "subscribed")) {
if (hContact = HContactFromJID(from))
AddDbPresenceEvent(hContact, JABBER_DB_EVENT_PRESENCE_SUBSCRIBED);
@@ -1860,7 +1779,7 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info)
if (item->subscription == SUB_FROM) item->subscription = SUB_BOTH;
else if (item->subscription == SUB_NONE) {
item->subscription = SUB_TO;
- if (wcschr(from, '@') == nullptr) {
+ if (strchr(from, '@') == nullptr) {
UI_SAFE_NOTIFY(m_pDlgServiceDiscovery, WM_JABBER_TRANSPORT_REFRESH);
}
}
@@ -1869,44 +1788,44 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info)
}
}
-BOOL CJabberProto::OnProcessJingle(HXML node)
+BOOL CJabberProto::OnProcessJingle(const TiXmlElement *node)
{
- const wchar_t *type;
- HXML child = XmlGetChildByTag(node, L"jingle", L"xmlns", JABBER_FEAT_JINGLE);
+ const char *type;
+ auto *child = XmlGetChildByTag(node, "jingle", "xmlns", JABBER_FEAT_JINGLE);
if (child) {
- if ((type = XmlGetAttrValue(node, L"type")) == nullptr) return FALSE;
- if ((!mir_wstrcmp(type, L"get") || !mir_wstrcmp(type, L"set"))) {
- const wchar_t *szAction = XmlGetAttrValue(child, L"action");
- const wchar_t *idStr = XmlGetAttrValue(node, L"id");
- const wchar_t *from = XmlGetAttrValue(node, L"from");
- if (szAction && !mir_wstrcmp(szAction, L"session-initiate")) {
+ if ((type = node->Attribute("type")) == nullptr) return FALSE;
+ if ((!mir_strcmp(type, "get") || !mir_strcmp(type, "set"))) {
+ const char *szAction = child->Attribute("action");
+ const char *idStr = node->Attribute("id");
+ const char *from = node->Attribute("from");
+ if (szAction && !mir_strcmp(szAction, "session-initiate")) {
// if this is a Jingle 'session-initiate' and noone processed it yet, reply with "unsupported-applications"
- m_ThreadInfo->send(XmlNodeIq(L"result", idStr, from));
+ m_ThreadInfo->send(XmlNodeIq("result", idStr, from));
- XmlNodeIq iq(L"set", SerialNext(), from);
- HXML jingleNode = iq << XCHILDNS(L"jingle", JABBER_FEAT_JINGLE);
+ XmlNodeIq iq("set", SerialNext(), from);
+ TiXmlElement *jingleNode = iq << XCHILDNS("jingle", JABBER_FEAT_JINGLE);
- jingleNode << XATTR(L"action", L"session-terminate");
- const wchar_t *szInitiator = XmlGetAttrValue(child, L"initiator");
+ jingleNode << XATTR("action", "session-terminate");
+ const char *szInitiator = child->Attribute("initiator");
if (szInitiator)
- jingleNode << XATTR(L"initiator", szInitiator);
- const wchar_t *szSid = XmlGetAttrValue(child, L"sid");
+ jingleNode << XATTR("initiator", szInitiator);
+ const char *szSid = child->Attribute("sid");
if (szSid)
- jingleNode << XATTR(L"sid", szSid);
+ jingleNode << XATTR("sid", szSid);
- jingleNode << XCHILD(L"reason")
- << XCHILD(L"unsupported-applications");
+ jingleNode << XCHILD("reason")
+ << XCHILD("unsupported-applications");
m_ThreadInfo->send(iq);
return TRUE;
}
else {
// if it's something else than 'session-initiate' and noone processed it yet, reply with "unknown-session"
- XmlNodeIq iq(L"error", idStr, from);
- HXML errNode = iq << XCHILD(L"error");
- errNode << XATTR(L"type", L"cancel");
- errNode << XCHILDNS(L"item-not-found", L"urn:ietf:params:xml:ns:xmpp-stanzas");
- errNode << XCHILDNS(L"unknown-session", L"urn:xmpp:jingle:errors:1");
+ XmlNodeIq iq("error", idStr, from);
+ TiXmlElement *errNode = iq << XCHILD("error");
+ errNode << XATTR("type", "cancel");
+ errNode << XCHILDNS("item-not-found", "urn:ietf:params:xml:ns:xmpp-stanzas");
+ errNode << XCHILDNS("unknown-session", "urn:xmpp:jingle:errors:1");
m_ThreadInfo->send(iq);
return TRUE;
}
@@ -1915,19 +1834,15 @@ BOOL CJabberProto::OnProcessJingle(HXML node)
return FALSE;
}
-void CJabberProto::OnProcessIq(HXML node)
+void CJabberProto::OnProcessIq(const TiXmlElement *node)
{
- HXML queryNode;
- const wchar_t *type, *xmlns;
+ if (!node->Name() || mir_strcmp(node->Name(), "iq")) return;
- if (!XmlGetName(node) || mir_wstrcmp(XmlGetName(node), L"iq")) return;
- if ((type = XmlGetAttrValue(node, L"type")) == nullptr) return;
+ const char *type;
+ if ((type = node->Attribute("type")) == nullptr) return;
int id = JabberGetPacketID(node);
- queryNode = XmlGetChild(node, "query");
- xmlns = XmlGetAttrValue(queryNode, L"xmlns");
-
// new match by id
if (m_iqManager.HandleIq(id, node))
return;
@@ -1941,16 +1856,16 @@ void CJabberProto::OnProcessIq(HXML node)
return;
// RECVED: <iq type='error'> ...
- if (!mir_wstrcmp(type, L"error")) {
- wchar_t tszBuf[20];
- _itow(id, tszBuf, 10);
+ if (!mir_strcmp(type, "error")) {
+ char tszBuf[20];
+ _itoa(id, tszBuf, 10);
debugLogA("XXX on entry");
// Check for file transfer deny by comparing idStr with ft->iqId
LISTFOREACH(i, this, LIST_FILE)
{
JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i);
- if (item->ft != nullptr && item->ft->state == FT_CONNECTING && !mir_wstrcmp(tszBuf, item->ft->szId)) {
+ if (item->ft != nullptr && item->ft->state == FT_CONNECTING && !mir_strcmp(tszBuf, item->ft->szId)) {
debugLogA("Denying file sending request");
item->ft->state = FT_DENIED;
if (item->ft->hFileEvent != nullptr)
@@ -1958,67 +1873,68 @@ void CJabberProto::OnProcessIq(HXML node)
}
}
}
- else if ((!mir_wstrcmp(type, L"get") || !mir_wstrcmp(type, L"set"))) {
- XmlNodeIq iq(L"error", XmlGetAttrValue(node, L"id"), XmlGetAttrValue(node, L"from"));
+ else if ((!mir_strcmp(type, "get") || !mir_strcmp(type, "set"))) {
+ XmlNodeIq iq("error", node->Attribute("id"), node->Attribute("from"));
- HXML pFirstChild = XmlGetChild(node, 0);
+ auto *pFirstChild = node->FirstChildElement();
if (pFirstChild)
- XmlAddChild(iq, pFirstChild);
+ iq.InsertEndChild((TiXmlElement*)pFirstChild);
- iq << XCHILD(L"error") << XATTR(L"type", L"cancel")
- << XCHILDNS(L"service-unavailable", L"urn:ietf:params:xml:ns:xmpp-stanzas");
+ iq << XCHILD("error") << XATTR("type", "cancel")
+ << XCHILDNS("service-unavailable", "urn:ietf:params:xml:ns:xmpp-stanzas");
m_ThreadInfo->send(iq);
}
}
-void CJabberProto::SetRegConfig(HXML node, void *from)
+void CJabberProto::SetRegConfig(TiXmlElement *node, void *from)
{
if (g_pRegInfo) {
iqIdRegSetReg = SerialNext();
- wchar_t text[MAX_PATH];
- mir_snwprintf(text, L"%s@%S", g_pRegInfo->conn.username, g_pRegInfo->conn.server);
- XmlNodeIq iq(L"set", iqIdRegSetReg, (const wchar_t*)from);
- iq << XATTR(L"from", text);
- HXML query = iq << XQUERY(JABBER_FEAT_REGISTER);
- XmlAddChild(query, node);
+ char text[MAX_PATH];
+ mir_snprintf(text, "%s@%S", g_pRegInfo->conn.username, g_pRegInfo->conn.server);
+ XmlNodeIq iq("set", iqIdRegSetReg, (const char*)from);
+ iq << XATTR("from", text);
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_REGISTER);
+ query->InsertEndChild(node);
g_pRegInfo->send(iq);
}
}
-void CJabberProto::OnProcessRegIq(HXML node, ThreadData *info)
+void CJabberProto::OnProcessRegIq(const TiXmlElement *node, ThreadData *info)
{
- if (!XmlGetName(node) || mir_wstrcmp(XmlGetName(node), L"iq")) return;
- const wchar_t *type = XmlGetAttrValue(node, L"type");
+ if (!node->Name() || mir_strcmp(node->Name(), "iq")) return;
+ const char *type = node->Attribute("type");
if (type == nullptr)
return;
int id = JabberGetPacketID(node);
- if (!mir_wstrcmp(type, L"result")) {
- HXML queryNode = XmlGetChild(node, L"query");
+ if (!mir_strcmp(type, "result")) {
+ auto *queryNode = node->FirstChildElement("query");
if (queryNode != nullptr) {
- const wchar_t *str = XmlGetAttrValue(queryNode, L"xmlns");
- if (!mir_wstrcmp(str, JABBER_FEAT_REGISTER)) {
- HXML xNode = XmlGetChild(queryNode, L"x");
+ const char *str = queryNode->Attribute("xmlns");
+ if (!mir_strcmp(str, JABBER_FEAT_REGISTER)) {
+ auto *xNode = queryNode->FirstChildElement("x");
if (xNode != nullptr) {
- if (!mir_wstrcmp(XmlGetAttrValue(xNode, L"xmlns"), JABBER_FEAT_DATA_FORMS)) {
+ if (!mir_strcmp(xNode->Attribute("xmlns"), JABBER_FEAT_DATA_FORMS)) {
g_pRegInfo = info;
- FormCreateDialog(xNode, L"Jabber register new user", &CJabberProto::SetRegConfig, mir_wstrdup(XmlGetAttrValue(node, L"from")));
+ FormCreateDialog(xNode, "Jabber register new user", &CJabberProto::SetRegConfig, mir_strdup(node->Attribute("from")));
return;
}
}
}
}
+
// RECVED: result of the request for registration mechanism
// ACTION: send account registration information
if (id == iqIdRegGetReg) {
iqIdRegSetReg = SerialNext();
- XmlNodeIq iq(L"set", iqIdRegSetReg);
- HXML query = iq << XQUERY(JABBER_FEAT_REGISTER);
- query << XCHILD(L"password", info->conn.password);
- query << XCHILD(L"username", info->conn.username);
+ XmlNodeIq iq("set", iqIdRegSetReg);
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_REGISTER);
+ query << XCHILD("password", info->conn.password);
+ query << XCHILD("username", info->conn.username);
info->send(iq);
SendMessage(info->conn.reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 75, (LPARAM)TranslateT("Sending registration information..."));
@@ -2031,9 +1947,8 @@ void CJabberProto::OnProcessRegIq(HXML node, ThreadData *info)
info->reg_done = TRUE;
}
}
-
- else if (!mir_wstrcmp(type, L"error")) {
- wchar_t *str = JabberErrorMsg(XmlGetChild(node, "error"));
+ else if (!mir_strcmp(type, "error")) {
+ wchar_t *str = JabberErrorMsg(node->FirstChildElement("error"));
SendMessage(info->conn.reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 100, (LPARAM)str);
mir_free(str);
info->reg_done = TRUE;
@@ -2041,17 +1956,15 @@ void CJabberProto::OnProcessRegIq(HXML node, ThreadData *info)
}
}
-
/////////////////////////////////////////////////////////////////////////////////////////
// Carbons -- this might need to go into its own module
void CJabberProto::EnableCarbons(bool bEnable)
{
- m_ThreadInfo->send(XmlNodeIq(L"set", SerialNext())
- << XCHILDNS((bEnable) ? L"enable" : L"disable", JABBER_FEAT_CARBONS));
+ m_ThreadInfo->send(XmlNodeIq("set", SerialNext())
+ << XCHILDNS((bEnable) ? "enable" : "disable", JABBER_FEAT_CARBONS));
}
-
/////////////////////////////////////////////////////////////////////////////////////////
// ThreadData constructor & destructor
@@ -2139,40 +2052,36 @@ int ThreadData::send(char* buf, int bufsize)
}
// Caution: DO NOT use ->send() to send binary (non-string) data
-int ThreadData::send(HXML node)
+int ThreadData::send(TiXmlElement *node)
{
if (this == nullptr)
return 0;
- while (HXML parent = xmlGetParent(node))
+ while (auto *parent = node->Parent()->ToElement())
node = parent;
if (proto->m_bEnableStreamMgmt)
proto->m_StrmMgmt.HandleOutgoingNode(node); //TODO: is this a correct place ?, looks like some nodes does not goes here...
-
- int result = send_no_strm_mgmt(node);
-
-
- return result;
+ return send_no_strm_mgmt(node);
}
// this function required for send <r/>, <a/> and more important, for resend stuck nodes by strm_mgmt (xep-0198)
-int ThreadData::send_no_strm_mgmt(HXML node)
+int ThreadData::send_no_strm_mgmt(TiXmlElement *node)
{
-
if (proto->m_sendManager.HandleSendPermanent(node, this))
return 0;
proto->OnConsoleProcessXml(node, JCPF_OUT);
- wchar_t *str = xmlToString(node, nullptr);
+ tinyxml2::XMLPrinter printer(0, true);
+ node->GetDocument()->Print(&printer);
+ CMStringA buf(printer.CStr());
// strip forbidden control characters from outgoing XML stream
- wchar_t *q = str;
- for (wchar_t *p = str; *p; ++p) {
-
- WCHAR c = *p;
+ char *q = buf.GetBuffer();
+ for (char *p = buf.GetBuffer(); *p; ++p) {
+ int c = *p;
if (c < 32 && c != '\t' && c != '\n' && c != '\r')
continue;
@@ -2180,9 +2089,5 @@ int ThreadData::send_no_strm_mgmt(HXML node)
}
*q = 0;
- T2Utf utfStr(str);
- int result = send(utfStr, (int)mir_strlen(utfStr));
- xmlFree(str);
-
- return result;
+ return send(buf.GetBuffer(), int(q-buf.GetBuffer()));
}
diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp
index deff426e52..42c1751921 100755
--- a/protocols/JabberG/src/jabber_userinfo.cpp
+++ b/protocols/JabberG/src/jabber_userinfo.cpp
@@ -170,15 +170,17 @@ void sttCleanupInfo(HWND hwndTree, int stage)
}
}
-static HTREEITEM sttFillInfoLine(HWND hwndTree, HTREEITEM htiRoot, HICON hIcon, const wchar_t *title, const wchar_t *value, LPARAM id = INFOLINE_BAD_ID, bool expand = false)
+static HTREEITEM sttFillInfoLine(HWND hwndTree, HTREEITEM htiRoot, HICON hIcon, const wchar_t *title, const char *value, LPARAM id = INFOLINE_BAD_ID, bool expand = false)
{
HTREEITEM hti = sttFindInfoLine(hwndTree, htiRoot, id);
+ Utf2T wszValue(value);
+ const wchar_t *pwszValue = (value == nullptr) ? TranslateT("<not specified>") : wszValue;
wchar_t buf[256];
if (title)
- mir_snwprintf(buf, L"%s: %s", title, value);
+ mir_snwprintf(buf, L"%s: %s", title, pwszValue);
else
- mir_wstrncpy(buf, value, _countof(buf));
+ mir_wstrncpy(buf, pwszValue, _countof(buf));
TVINSERTSTRUCT tvis = {};
tvis.hParent = htiRoot;
@@ -212,17 +214,16 @@ static HTREEITEM sttFillInfoLine(HWND hwndTree, HTREEITEM htiRoot, HICON hIcon,
static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM htiRoot, JABBER_LIST_ITEM *item, int resource)
{
- wchar_t buf[256];
HTREEITEM htiResource = htiRoot;
pResourceStatus r = resource ? item->arResources[resource - 1] : item->getTemp();
- if (r->m_tszResourceName && *r->m_tszResourceName)
+ if (r->m_szResourceName && *r->m_szResourceName)
htiResource = sttFillInfoLine(hwndTree, htiRoot, Skin_LoadProtoIcon(ppro->m_szModuleName, r->m_iStatus),
- TranslateT("Resource"), r->m_tszResourceName, sttInfoLineId(resource, INFOLINE_NAME), true);
+ TranslateT("Resource"), r->m_szResourceName, sttInfoLineId(resource, INFOLINE_NAME), true);
// StatusMsg
sttFillInfoLine(hwndTree, htiResource, nullptr /*Skin_LoadIcon(SKINICON_EVENT_MESSAGE)*/,
- TranslateT("Message"), r->m_tszStatusMessage ? r->m_tszStatusMessage : TranslateT("<not specified>"),
+ TranslateT("Message"), r->m_szStatusMessage,
sttInfoLineId(resource, INFOLINE_MESSAGE));
// Software
@@ -231,81 +232,74 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti
if (ServiceExists(MS_FP_GETCLIENTICONT)) {
if (pCaps->GetSoft()) {
+ wchar_t buf[256];
mir_snwprintf(buf, L"%s %s", pCaps->GetSoft(), pCaps->GetSoftVer());
hIcon = Finger_GetClientIcon(buf, 0);
}
}
- sttFillInfoLine(hwndTree, htiResource, hIcon, TranslateT("Software"),
- pCaps->GetSoft() ? pCaps->GetSoft() : TranslateT("<not specified>"),
- sttInfoLineId(resource, INFOLINE_SOFTWARE));
+ sttFillInfoLine(hwndTree, htiResource, hIcon, TranslateT("Software"), pCaps->GetSoft(), sttInfoLineId(resource, INFOLINE_SOFTWARE));
// Version
- const wchar_t *wszVer = pCaps->GetSoftMir() ? pCaps->GetSoftMir() : pCaps->GetSoftVer();
- sttFillInfoLine(hwndTree, htiResource, nullptr, TranslateT("Version"),
- wszVer ? wszVer : TranslateT("<not specified>"),
- sttInfoLineId(resource, INFOLINE_VERSION));
+ sttFillInfoLine(hwndTree, htiResource, nullptr, TranslateT("Version"), pCaps->GetSoftMir() ? pCaps->GetSoftMir() : pCaps->GetSoftVer(), sttInfoLineId(resource, INFOLINE_VERSION));
// System
- wszVer = pCaps->GetOsVer() ? pCaps->GetOsVer() : pCaps->GetOs();
- sttFillInfoLine(hwndTree, htiResource, nullptr, TranslateT("System"),
- wszVer ? wszVer : TranslateT("<not specified>"),
- sttInfoLineId(resource, INFOLINE_SYSTEM));
+ sttFillInfoLine(hwndTree, htiResource, nullptr, TranslateT("System"), pCaps->GetOsVer() ? pCaps->GetOsVer() : pCaps->GetOs(), sttInfoLineId(resource, INFOLINE_SYSTEM));
if (hIcon)
DestroyIcon(hIcon);
}
// Resource priority
- wchar_t szPriority[128];
- mir_snwprintf(szPriority, L"%d", (int)r->m_iPriority);
- sttFillInfoLine(hwndTree, htiResource, nullptr, TranslateT("Resource priority"), szPriority, sttInfoLineId(resource, INFOLINE_PRIORITY));
+ char buf[256];
+ itoa(r->m_iPriority, buf, 10);
+ sttFillInfoLine(hwndTree, htiResource, nullptr, TranslateT("Resource priority"), buf, sttInfoLineId(resource, INFOLINE_PRIORITY));
// Idle
if (r->m_dwIdleStartTime > 0) {
- mir_wstrncpy(buf, _wctime(&r->m_dwIdleStartTime), _countof(buf));
- size_t len = mir_wstrlen(buf);
+ mir_strncpy(buf, ctime(&r->m_dwIdleStartTime), _countof(buf));
+ size_t len = mir_strlen(buf);
if (len > 0)
buf[len - 1] = 0;
}
else if (!r->m_dwIdleStartTime)
- mir_wstrncpy(buf, TranslateT("unknown"), _countof(buf));
+ mir_strncpy(buf, Translate("unknown"), _countof(buf));
else
- mir_wstrncpy(buf, TranslateT("<not specified>"), _countof(buf));
+ mir_strncpy(buf, Translate("<not specified>"), _countof(buf));
sttFillInfoLine(hwndTree, htiResource, nullptr, TranslateT("Idle since"), buf, sttInfoLineId(resource, INFOLINE_IDLE));
// caps
- mir_snwprintf(buf, L"%s/%s", item->jid, r->m_tszResourceName);
+ mir_snprintf(buf, "%s/%s", item->jid, r->m_szResourceName);
JabberCapsBits jcb = ppro->GetResourceCapabilities(buf, r);
if (!(jcb & JABBER_RESOURCE_CAPS_ERROR)) {
- HTREEITEM htiCaps = sttFillInfoLine(hwndTree, htiResource, ppro->LoadIconEx("main"), nullptr, TranslateT("Client capabilities"), sttInfoLineId(resource, INFOLINE_CAPS));
+ HTREEITEM htiCaps = sttFillInfoLine(hwndTree, htiResource, ppro->LoadIconEx("main"), nullptr, Translate("Client capabilities"), sttInfoLineId(resource, INFOLINE_CAPS));
int i;
for (i = 0; i < g_cJabberFeatCapPairs; i++)
if (jcb & g_JabberFeatCapPairs[i].jcbCap) {
- wchar_t szDescription[1024];
+ char szDescription[1024];
if (g_JabberFeatCapPairs[i].tszDescription)
- mir_snwprintf(szDescription, L"%s (%s)", TranslateW(g_JabberFeatCapPairs[i].tszDescription), g_JabberFeatCapPairs[i].szFeature);
+ mir_snprintf(szDescription, "%s (%s)", Translate(g_JabberFeatCapPairs[i].tszDescription), g_JabberFeatCapPairs[i].szFeature);
else
- wcsncpy_s(szDescription, g_JabberFeatCapPairs[i].szFeature, _TRUNCATE);
+ strncpy_s(szDescription, g_JabberFeatCapPairs[i].szFeature, _TRUNCATE);
sttFillInfoLine(hwndTree, htiCaps, nullptr, nullptr, szDescription, sttInfoLineId(resource, INFOLINE_CAPS, i));
}
for (auto &it : ppro->m_lstJabberFeatCapPairsDynamic) {
if (jcb & it->jcbCap) {
- wchar_t szDescription[1024];
+ char szDescription[1024];
if (it->szDescription)
- mir_snwprintf(szDescription, L"%s (%s)", TranslateW(it->szDescription), it->szFeature);
+ mir_snprintf(szDescription, "%s (%s)", Translate(it->szDescription), it->szFeature);
else
- wcsncpy_s(szDescription, it->szFeature, _TRUNCATE);
+ strncpy_s(szDescription, it->szFeature, _TRUNCATE);
sttFillInfoLine(hwndTree, htiCaps, nullptr, nullptr, szDescription, sttInfoLineId(resource, INFOLINE_CAPS, i++));
}
}
}
// Software info
- HTREEITEM htiSoftwareInfo = sttFillInfoLine(hwndTree, htiResource, ppro->LoadIconEx("main"), nullptr, TranslateT("Software information"), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION));
+ HTREEITEM htiSoftwareInfo = sttFillInfoLine(hwndTree, htiResource, ppro->LoadIconEx("main"), nullptr, Translate("Software information"), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION));
int nLineId = 0;
if (CJabberClientPartialCaps *pCaps = r->m_pCaps) {
if (pCaps->GetOs())
@@ -333,7 +327,7 @@ static void sttFillAdvStatusInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM ht
mir_snwprintf(szText, L"%s (%s)", TranslateW(szAdvStatusTitle), szAdvStatusText);
else
wcsncpy_s(szText, TranslateW(szAdvStatusTitle), _TRUNCATE);
- sttFillInfoLine(hwndTree, htiRoot, IcoLib_GetIcon(szAdvStatusIcon), szTitle, szText, dwInfoLine);
+ sttFillInfoLine(hwndTree, htiRoot, IcoLib_GetIcon(szAdvStatusIcon), szTitle, T2Utf(szText), dwInfoLine);
}
mir_free(szAdvStatusIcon);
@@ -348,7 +342,6 @@ static void sttFillUserInfo(CJabberProto *ppro, HWND hwndTree, JABBER_LIST_ITEM
sttCleanupInfo(hwndTree, 0);
HTREEITEM htiRoot = sttFillInfoLine(hwndTree, nullptr, ppro->LoadIconEx("main"), L"JID", item->jid, sttInfoLineId(0, INFOLINE_NAME), true);
- wchar_t buf[256];
if (MCONTACT hContact = ppro->HContactFromJID(item->jid)) {
sttFillAdvStatusInfo(ppro, hwndTree, htiRoot, sttInfoLineId(0, INFOLINE_MOOD), hContact, TranslateT("Mood"), ADVSTATUS_MOOD);
@@ -359,54 +352,52 @@ static void sttFillUserInfo(CJabberProto *ppro, HWND hwndTree, JABBER_LIST_ITEM
// subscription
switch (item->subscription) {
case SUB_BOTH:
- sttFillInfoLine(hwndTree, htiRoot, nullptr, TranslateT("Subscription"), TranslateT("both"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
+ sttFillInfoLine(hwndTree, htiRoot, nullptr, TranslateT("Subscription"), Translate("both"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
break;
case SUB_TO:
- sttFillInfoLine(hwndTree, htiRoot, nullptr, TranslateT("Subscription"), TranslateT("to"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
+ sttFillInfoLine(hwndTree, htiRoot, nullptr, TranslateT("Subscription"), Translate("to"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
break;
case SUB_FROM:
- sttFillInfoLine(hwndTree, htiRoot, nullptr, TranslateT("Subscription"), TranslateT("from"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
+ sttFillInfoLine(hwndTree, htiRoot, nullptr, TranslateT("Subscription"), Translate("from"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
break;
default:
- sttFillInfoLine(hwndTree, htiRoot, nullptr, TranslateT("Subscription"), TranslateT("none"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
+ sttFillInfoLine(hwndTree, htiRoot, nullptr, TranslateT("Subscription"), Translate("none"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
break;
}
// logoff
+ char buf[256];
JABBER_RESOURCE_STATUS *r = item->getTemp();
if (r->m_dwIdleStartTime > 0) {
- mir_wstrncpy(buf, _wctime(&r->m_dwIdleStartTime), _countof(buf));
- size_t len = mir_wstrlen(buf);
+ mir_strncpy(buf, ctime(&r->m_dwIdleStartTime), _countof(buf));
+ size_t len = mir_strlen(buf);
if (len > 0)
buf[len - 1] = 0;
}
else if (!r->m_dwIdleStartTime)
- mir_wstrncpy(buf, TranslateT("unknown"), _countof(buf));
+ mir_strncpy(buf, Translate("unknown"), _countof(buf));
else
- mir_wstrncpy(buf, TranslateT("<not specified>"), _countof(buf));
+ mir_strncpy(buf, Translate("<not specified>"), _countof(buf));
sttFillInfoLine(hwndTree, htiRoot, nullptr,
- (item->jid && wcschr(item->jid, '@')) ? TranslateT("Last logoff time") : TranslateT("Uptime"), buf,
+ (item->jid && strchr(item->jid, '@')) ? TranslateT("Last logoff time") : TranslateT("Uptime"), buf,
sttInfoLineId(0, INFOLINE_LOGOFF));
- sttFillInfoLine(hwndTree, htiRoot, nullptr, TranslateT("Logoff message"),
- r->m_tszStatusMessage ? r->m_tszStatusMessage : TranslateT("<not specified>"), sttInfoLineId(0, INFOLINE_LOGOFF_MSG));
+ sttFillInfoLine(hwndTree, htiRoot, nullptr, TranslateT("Logoff message"), r->m_szStatusMessage, sttInfoLineId(0, INFOLINE_LOGOFF_MSG));
// activity
if (item->m_pLastSeenResource)
- mir_wstrncpy(buf, item->m_pLastSeenResource->m_tszResourceName, _countof(buf));
+ mir_strncpy(buf, item->m_pLastSeenResource->m_szResourceName, _countof(buf));
else
- mir_wstrncpy(buf, TranslateT("<no information available>"), _countof(buf));
-
- sttFillInfoLine(hwndTree, htiRoot, nullptr, TranslateT("Last active resource"), buf,
- sttInfoLineId(0, INFOLINE_LASTACTIVE));
+ mir_strncpy(buf, Translate("<no information available>"), _countof(buf));
+ sttFillInfoLine(hwndTree, htiRoot, nullptr, TranslateT("Last active resource"), buf, sttInfoLineId(0, INFOLINE_LASTACTIVE));
// resources
if (item->arResources.getCount()) {
for (int i = 0; i < item->arResources.getCount(); i++)
sttFillResourceInfo(ppro, hwndTree, htiRoot, item, i + 1);
}
- else if (!wcschr(item->jid, '@') || (r->m_iStatus != ID_STATUS_OFFLINE))
+ else if (!strchr(item->jid, '@') || (r->m_iStatus != ID_STATUS_OFFLINE))
sttFillResourceInfo(ppro, hwndTree, htiRoot, item, 0);
sttCleanupInfo(hwndTree, 1);
@@ -480,7 +471,7 @@ static INT_PTR CALLBACK JabberUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa
if (dat == nullptr) break;
if (dat->item == nullptr) {
- ptrW jid(dat->ppro->getWStringA(dat->hContact, "jid"));
+ ptrA jid(dat->ppro->getUStringA(dat->hContact, "jid"));
if (jid == nullptr)
break;
@@ -492,8 +483,7 @@ static INT_PTR CALLBACK JabberUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa
HWND hwndTree = GetDlgItem(hwndDlg, IDC_TV_INFO);
TreeView_DeleteAllItems(hwndTree);
HTREEITEM htiRoot = sttFillInfoLine(hwndTree, nullptr, dat->ppro->LoadIconEx("main"), L"JID", jid, sttInfoLineId(0, INFOLINE_NAME), true);
- sttFillInfoLine(hwndTree, htiRoot, dat->ppro->LoadIconEx("vcard"), nullptr,
- TranslateT("Please switch online to see more details."));
+ sttFillInfoLine(hwndTree, htiRoot, dat->ppro->LoadIconEx("vcard"), nullptr, Translate("Please switch online to see more details."));
break;
}
}
@@ -570,7 +560,7 @@ static INT_PTR CALLBACK JabberUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa
case PSN_PARAMCHANGED:
dat->ppro = (CJabberProto*)((PSHNOTIFY*)lParam)->lParam;
if (dat->hContact != 0) {
- ptrW jid(dat->ppro->getWStringA(dat->hContact, "jid"));
+ ptrA jid(dat->ppro->getUStringA(dat->hContact, "jid"));
if (jid != nullptr)
if (!(dat->item = dat->ppro->ListGetItemPtr(LIST_VCARD_TEMP, jid)))
dat->item = dat->ppro->ListGetItemPtr(LIST_ROSTER, jid);
@@ -652,7 +642,7 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wP
}
ShowWindow(GetDlgItem(hwndDlg, IDC_SAVE), SW_HIDE);
{
- ptrW jid(photoInfo->ppro->getWStringA(photoInfo->hContact, "jid"));
+ ptrA jid(photoInfo->ppro->getUStringA(photoInfo->hContact, "jid"));
if (jid != nullptr) {
JABBER_LIST_ITEM *item = photoInfo->ppro->ListGetItemPtr(LIST_VCARD_TEMP, jid);
if (item == nullptr)
@@ -660,7 +650,7 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wP
if (item != nullptr) {
if (item->photoFileName) {
photoInfo->ppro->debugLogW(L"Showing picture from %s", item->photoFileName);
- photoInfo->hBitmap = Bitmap_Load(item->photoFileName);
+ photoInfo->hBitmap = Bitmap_Load(Utf2T(item->photoFileName));
FreeImage_Premultiply(photoInfo->hBitmap);
ShowWindow(GetDlgItem(hwndDlg, IDC_SAVE), SW_SHOW);
}
@@ -676,7 +666,7 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wP
case IDC_SAVE:
static wchar_t szFilter[512];
- ptrW jid(photoInfo->ppro->getWStringA(photoInfo->hContact, "jid"));
+ ptrA jid(photoInfo->ppro->getUStringA(photoInfo->hContact, "jid"));
if (jid == nullptr)
break;
@@ -685,7 +675,7 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wP
if ((item = photoInfo->ppro->ListGetItemPtr(LIST_ROSTER, jid)) == nullptr)
break;
- switch (ProtoGetAvatarFileFormat(item->photoFileName)) {
+ switch (ProtoGetAvatarFileFormat(Utf2T(item->photoFileName))) {
case PA_FORMAT_BMP:
mir_snwprintf(szFilter, L"BMP %s (*.bmp)%c*.BMP", TranslateT("format"), 0);
break;
@@ -712,7 +702,7 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wP
ofn.Flags = OFN_OVERWRITEPROMPT;
if (GetSaveFileName(&ofn)) {
photoInfo->ppro->debugLogW(L"File selected is %s", szFileName);
- CopyFile(item->photoFileName, szFileName, FALSE);
+ CopyFile(Utf2T(item->photoFileName), szFileName, FALSE);
}
}
break;
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index 91c477275f..fcd925f5d7 100755
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp
@@ -34,7 +34,7 @@ int CJabberProto::SerialNext(void)
///////////////////////////////////////////////////////////////////////////////
// JabberChatRoomHContactFromJID - looks for the char room MCONTACT with required JID
-MCONTACT CJabberProto::ChatRoomHContactFromJID(const wchar_t *jid)
+MCONTACT CJabberProto::ChatRoomHContactFromJID(const char *jid)
{
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, jid);
if (item != nullptr && item->hContact)
@@ -46,7 +46,7 @@ MCONTACT CJabberProto::ChatRoomHContactFromJID(const wchar_t *jid)
///////////////////////////////////////////////////////////////////////////////
// JabberHContactFromJID - looks for the MCONTACT with required JID
-MCONTACT CJabberProto::HContactFromJID(const wchar_t *jid, bool bStripResource)
+MCONTACT CJabberProto::HContactFromJID(const char *jid, bool bStripResource)
{
if (jid == nullptr)
return 0;
@@ -56,7 +56,7 @@ MCONTACT CJabberProto::HContactFromJID(const wchar_t *jid, bool bStripResource)
return item->hContact;
if (bStripResource) {
- wchar_t szJid[JABBER_MAX_JID_LEN];
+ char szJid[JABBER_MAX_JID_LEN];
JabberStripJid(jid, szJid, _countof(szJid));
item = ListGetItemPtr(LIST_ROSTER, szJid);
if (item != nullptr && item->hContact)
@@ -66,28 +66,28 @@ MCONTACT CJabberProto::HContactFromJID(const wchar_t *jid, bool bStripResource)
return 0;
}
-wchar_t* __stdcall JabberNickFromJID(const wchar_t *jid)
+char* JabberNickFromJID(const char *jid)
{
if (jid == nullptr)
- return mir_wstrdup(L"");
+ return mir_strdup("");
- const wchar_t *p = wcschr(jid, '@');
+ const char *p = strchr(jid, '@');
if (p == nullptr)
- p = wcschr(jid, '/');
+ p = strchr(jid, '/');
- return (p != nullptr) ? mir_wstrndup(jid, p - jid) : mir_wstrdup(jid);
+ return (p != nullptr) ? mir_strndup(jid, p - jid) : mir_strdup(jid);
}
-pResourceStatus CJabberProto::ResourceInfoFromJID(const wchar_t *jid)
+pResourceStatus CJabberProto::ResourceInfoFromJID(const char *jid)
{
if (jid == nullptr)
return nullptr;
- const wchar_t *p = wcschr(jid, '/');
+ const char *p = strchr(jid, '/');
JABBER_LIST_ITEM *item = nullptr;
if (p) {
- wchar_t szJid[JABBER_MAX_JID_LEN];
+ char szJid[JABBER_MAX_JID_LEN];
JabberStripJid(jid, szJid, _countof(szJid));
item = ListGetItemPtr(LIST_CHATROOM, szJid);
}
@@ -104,19 +104,25 @@ pResourceStatus CJabberProto::ResourceInfoFromJID(const wchar_t *jid)
return item->findResource(p + 1);
}
-wchar_t* JabberPrepareJid(const wchar_t *jid)
+char* JabberPrepareJid(const char *jid)
{
- if (jid == nullptr) return nullptr;
- wchar_t *szNewJid = mir_wstrdup(jid);
- if (!szNewJid) return nullptr;
- wchar_t *pDelimiter = wcschr(szNewJid, '/');
- if (pDelimiter) *pDelimiter = 0;
- CharLower(szNewJid);
- if (pDelimiter) *pDelimiter = '/';
+ if (jid == nullptr)
+ return nullptr;
+
+ char *szNewJid = mir_strdup(jid);
+ if (!szNewJid)
+ return nullptr;
+
+ char *pDelimiter = strchr(szNewJid, '/');
+ if (pDelimiter)
+ *pDelimiter = 0;
+ CharLowerA(szNewJid);
+ if (pDelimiter)
+ *pDelimiter = '/';
return szNewJid;
}
-char* __stdcall JabberSha1(const char *str, JabberShaStrBuf buf)
+char* JabberSha1(const char *str, JabberShaStrBuf buf)
{
BYTE digest[MIR_SHA1_HASH_SIZE];
mir_sha1_ctx sha;
@@ -128,7 +134,7 @@ char* __stdcall JabberSha1(const char *str, JabberShaStrBuf buf)
return buf;
}
-wchar_t* __stdcall JabberStrFixLines(const wchar_t *str)
+wchar_t* JabberStrFixLines(const wchar_t *str)
{
if (str == nullptr)
return nullptr;
@@ -159,7 +165,7 @@ wchar_t* __stdcall JabberStrFixLines(const wchar_t *str)
return buf;
}
-void __stdcall JabberHttpUrlDecode(wchar_t *str)
+void JabberHttpUrlDecode(wchar_t *str)
{
wchar_t *p, *q;
unsigned int code;
@@ -177,7 +183,7 @@ void __stdcall JabberHttpUrlDecode(wchar_t *str)
*q = '\0';
}
-int __stdcall JabberCombineStatus(int status1, int status2)
+int JabberCombineStatus(int status1, int status2)
{
// Combine according to the following priority (high to low)
// ID_STATUS_FREECHAT
@@ -230,7 +236,7 @@ static JabberErrorCodeToStrMapping[] = {
{ -1, LPGENW("Unknown error") }
};
-wchar_t* __stdcall JabberErrorStr(int errorCode)
+wchar_t* JabberErrorStr(int errorCode)
{
int i;
@@ -238,7 +244,7 @@ wchar_t* __stdcall JabberErrorStr(int errorCode)
return JabberErrorCodeToStrMapping[i].str;
}
-wchar_t* __stdcall JabberErrorMsg(HXML errorNode, int* pErrorCode)
+wchar_t* JabberErrorMsg(const TiXmlElement *errorNode, int* pErrorCode)
{
wchar_t *errorStr = (wchar_t*)mir_alloc(256 * sizeof(wchar_t));
if (errorNode == nullptr) {
@@ -248,28 +254,23 @@ wchar_t* __stdcall JabberErrorMsg(HXML errorNode, int* pErrorCode)
return errorStr;
}
- int errorCode = -1;
- const wchar_t *str = XmlGetAttrValue(errorNode, L"code");
- if (str != nullptr)
- errorCode = _wtoi(str);
+ int errorCode = errorNode->IntAttribute("code");
- str = XmlGetText(errorNode);
+ auto *str = errorNode->GetText();
if (str == nullptr)
- str = XmlGetText(XmlGetChild(errorNode, L"text"));
+ str = errorNode->FirstChildElement("text")->GetText();
if (str == nullptr) {
- for (int i = 0;; i++) {
- HXML c = XmlGetChild(errorNode, i);
- if (c == nullptr) break;
- const wchar_t *attr = XmlGetAttrValue(c, L"xmlns");
- if (attr && !mir_wstrcmp(attr, L"urn:ietf:params:xml:ns:xmpp-stanzas")) {
- str = XmlGetName(c);
+ for (auto *c : TiXmlEnum(errorNode)) {
+ const char *attr = c->Attribute("xmlns");
+ if (attr && !mir_strcmp(attr, "urn:ietf:params:xml:ns:xmpp-stanzas")) {
+ str = c->Name();
break;
}
}
}
if (str != nullptr)
- mir_snwprintf(errorStr, 256, L"%s %d: %s\r\n%s", TranslateT("Error"), errorCode, TranslateW(JabberErrorStr(errorCode)), str);
+ mir_snwprintf(errorStr, 256, 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)));
@@ -294,13 +295,13 @@ void CJabberProto::SendVisibleInvisiblePresence(bool invisible)
WORD apparentMode = getWord(hContact, "ApparentMode", 0);
if (invisible && apparentMode == ID_STATUS_OFFLINE)
- m_ThreadInfo->send(XmlNode(L"presence") << XATTR(L"to", item->jid) << XATTR(L"type", L"invisible"));
+ m_ThreadInfo->send(XmlNode("presence") << XATTR("to", item->jid) << XATTR("type", "invisible"));
else if (!invisible && apparentMode == ID_STATUS_ONLINE)
SendPresenceTo(m_iStatus, item->jid, nullptr);
}
}
-time_t __stdcall JabberIsoToUnixTime(const wchar_t *stamp)
+time_t JabberIsoToUnixTime(const char *stamp)
{
wchar_t date[9];
int i, y;
@@ -308,7 +309,7 @@ time_t __stdcall JabberIsoToUnixTime(const wchar_t *stamp)
if (stamp == nullptr)
return 0;
- const wchar_t *p = stamp;
+ auto *p = stamp;
// Get the date part
for (i = 0; *p != '\0' && i < 8 && isdigit(*p); p++, i++)
@@ -340,7 +341,7 @@ time_t __stdcall JabberIsoToUnixTime(const wchar_t *stamp)
for (; *p != '\0' && !isdigit(*p); p++);
// Parse time
- if (swscanf(p, L"%d:%d:%d", &timestamp.tm_hour, &timestamp.tm_min, &timestamp.tm_sec) != 3)
+ if (sscanf(p, "%d:%d:%d", &timestamp.tm_hour, &timestamp.tm_min, &timestamp.tm_sec) != 3)
return (time_t)0;
timestamp.tm_isdst = 0; // DST is already present in _timezone below
@@ -351,7 +352,7 @@ time_t __stdcall JabberIsoToUnixTime(const wchar_t *stamp)
return (t >= 0) ? t : 0;
}
-void CJabberProto::SendPresenceTo(int status, const wchar_t* to, HXML extra, const wchar_t *msg)
+void CJabberProto::SendPresenceTo(int status, const char *to, TiXmlElement *extra, const char *msg)
{
if (!m_bJabberOnline) return;
@@ -359,22 +360,22 @@ void CJabberProto::SendPresenceTo(int status, const wchar_t* to, HXML extra, con
int iPriority = getDword("Priority", 0);
UpdatePriorityMenu(iPriority);
- wchar_t szPriority[40];
- _itow(iPriority, szPriority, 10);
+ char szPriority[40];
+ itoa(iPriority, szPriority, 10);
- XmlNode p(L"presence"); p << XCHILD(L"priority", szPriority);
+ XmlNode p("presence"); p << XCHILD("priority", szPriority);
if (to != nullptr)
- p << XATTR(L"to", to);
+ p << XATTR("to", to);
if (extra)
- XmlAddChild(p, extra);
+ p.InsertEndChild(extra);
// XEP-0115:Entity Capabilities
if (m_bAllowVersionRequests) {
- HXML c = p << XCHILDNS(L"c", JABBER_FEAT_ENTITY_CAPS) << XATTR(L"hash", L"sha-1")
- << XATTR(L"node", JABBER_CAPS_MIRANDA_NODE) << XATTR(L"ver", m_clientCapsManager.GetFeaturesCrc());
+ TiXmlElement *c = p << XCHILDNS("c", JABBER_FEAT_ENTITY_CAPS) << XATTR("hash", "sha-1")
+ << XATTR("node", JABBER_CAPS_MIRANDA_NODE) << XATTR("ver", m_clientCapsManager.GetFeaturesCrc());
- LIST<wchar_t> arrExtCaps(5);
+ LIST<char> arrExtCaps(5);
if (bSecureIM)
arrExtCaps.insert(JABBER_EXT_SECUREIM);
@@ -420,25 +421,25 @@ void CJabberProto::SendPresenceTo(int status, const wchar_t* to, HXML extra, con
szExtCaps.AppendChar(' ');
szExtCaps += arrExtCaps[i];
}
- XmlAddAttr(c, L"ext", szExtCaps);
+ c->SetAttribute("ext", szExtCaps);
}
}
if (m_tmJabberIdleStartTime)
- p << XQUERY(JABBER_FEAT_LAST_ACTIVITY) << XATTRI(L"seconds", time(0) - m_tmJabberIdleStartTime);
+ p << XQUERY(JABBER_FEAT_LAST_ACTIVITY) << XATTRI("seconds", time(0) - m_tmJabberIdleStartTime);
if (m_bEnableAvatars) {
- HXML x = p << XCHILDNS(L"x", L"vcard-temp:x:update");
+ TiXmlElement *x = p << XCHILDNS("x", "vcard-temp:x:update");
- ptrW vcardHash(getWStringA("VCardHash"));
+ ptrA vcardHash(getUStringA("VCardHash"));
if (vcardHash != nullptr)
- x << XATTR(L"vcard", vcardHash);
+ x << XATTR("vcard", vcardHash);
- ptrW hashValue(getWStringA("AvatarHash"));
+ ptrA hashValue(getUStringA("AvatarHash"));
if (hashValue != nullptr) // XEP-0153: vCard-Based Avatars
- x << XCHILD(L"photo", hashValue);
+ x << XCHILD("photo", hashValue);
else
- x << XCHILD(L"photo");
+ x << XCHILD("photo");
}
{
mir_cslock lck(m_csModeMsgMutex);
@@ -447,25 +448,25 @@ void CJabberProto::SendPresenceTo(int status, const wchar_t* to, HXML extra, con
if (!msg) msg = m_modeMsgs.szOnline;
break;
case ID_STATUS_INVISIBLE:
- p << XATTR(L"type", L"invisible");
+ p << XATTR("type", "invisible");
break;
case ID_STATUS_AWAY:
case ID_STATUS_ONTHEPHONE:
case ID_STATUS_OUTTOLUNCH:
- p << XCHILD(L"show", L"away");
+ p << XCHILD("show", "away");
if (!msg) msg = m_modeMsgs.szAway;
break;
case ID_STATUS_NA:
- p << XCHILD(L"show", L"xa");
+ p << XCHILD("show", "xa");
if (!msg) msg = m_modeMsgs.szNa;
break;
case ID_STATUS_DND:
case ID_STATUS_OCCUPIED:
- p << XCHILD(L"show", L"dnd");
+ p << XCHILD("show", "dnd");
if (!msg) msg = m_modeMsgs.szDnd;
break;
case ID_STATUS_FREECHAT:
- p << XCHILD(L"show", L"chat");
+ p << XCHILD("show", "chat");
if (!msg) msg = m_modeMsgs.szFreechat;
break;
default: // Should not reach here
@@ -473,7 +474,7 @@ void CJabberProto::SendPresenceTo(int status, const wchar_t* to, HXML extra, con
}
if (msg)
- p << XCHILD(L"status", msg);
+ p << XCHILD("status", msg);
}
m_ThreadInfo->send(p);
@@ -490,8 +491,8 @@ void CJabberProto::SendPresence(int status, bool bSendToAll)
{
JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i);
if (item != nullptr && item->nick != nullptr) {
- wchar_t text[1024];
- mir_snwprintf(text, L"%s/%s", item->jid, item->nick);
+ char text[1024];
+ mir_snprintf(text, "%s/%s", item->jid, item->nick);
SendPresenceTo(status == ID_STATUS_INVISIBLE ? ID_STATUS_ONLINE : status, text, nullptr);
}
}
@@ -501,42 +502,42 @@ void CJabberProto::SendPresence(int status, bool bSendToAll)
///////////////////////////////////////////////////////////////////////////////
// JabberGetPacketID - converts the xml id attribute into an integer
-int __stdcall JabberGetPacketID(HXML n)
+int JabberGetPacketID(const TiXmlElement *n)
{
- const wchar_t *str = XmlGetAttrValue(n, L"id");
+ const char *str = n->Attribute("id");
if (str)
- if (!wcsncmp(str, _T(JABBER_IQID), _countof(JABBER_IQID) - 1))
- return _wtoi(str + _countof(JABBER_IQID) - 1);
+ if (!strncmp(str, JABBER_IQID, _countof(JABBER_IQID) - 1))
+ return atoi(str + _countof(JABBER_IQID) - 1);
return -1;
}
-wchar_t* __stdcall JabberId2string(int id)
+char* JabberId2string(int id)
{
- wchar_t text[100];
- mir_snwprintf(text, _T(JABBER_IQID) L"%d", id);
- return mir_wstrdup(text);
+ char text[100];
+ mir_snprintf(text, JABBER_IQID "%d", id);
+ return mir_strdup(text);
}
///////////////////////////////////////////////////////////////////////////////
// JabberGetClientJID - adds a resource postfix to a JID
-wchar_t* CJabberProto::GetClientJID(MCONTACT hContact, wchar_t *dest, size_t destLen)
+char* CJabberProto::GetClientJID(MCONTACT hContact, char *dest, size_t destLen)
{
if (hContact == 0)
return nullptr;
- ptrW jid(getWStringA(hContact, "jid"));
+ ptrA jid(getUStringA(hContact, "jid"));
return GetClientJID(jid, dest, destLen);
}
-wchar_t* CJabberProto::GetClientJID(const wchar_t *jid, wchar_t *dest, size_t destLen)
+char* CJabberProto::GetClientJID(const char *jid, char *dest, size_t destLen)
{
if (jid == nullptr)
return nullptr;
- wcsncpy_s(dest, destLen, jid, _TRUNCATE);
- wchar_t *p = wcschr(dest, '/');
+ strncpy_s(dest, destLen, jid, _TRUNCATE);
+ char *p = strchr(dest, '/');
mir_cslock lck(m_csLists);
JABBER_LIST_ITEM *LI = ListGetItemPtr(LIST_ROSTER, jid);
@@ -544,7 +545,7 @@ wchar_t* CJabberProto::GetClientJID(const wchar_t *jid, wchar_t *dest, size_t de
if (p == nullptr) {
pResourceStatus r(LI->getBestResource());
if (r != nullptr)
- mir_snwprintf(dest, destLen, L"%s/%s", jid, r->m_tszResourceName);
+ mir_snprintf(dest, destLen, "%s/%s", jid, r->m_szResourceName);
}
}
@@ -554,14 +555,14 @@ wchar_t* CJabberProto::GetClientJID(const wchar_t *jid, wchar_t *dest, size_t de
///////////////////////////////////////////////////////////////////////////////
// JabberStripJid - strips a resource postfix from a JID
-wchar_t* __stdcall JabberStripJid(const wchar_t *jid, wchar_t *dest, size_t destLen)
+char* JabberStripJid(const char *jid, char *dest, size_t destLen)
{
if (jid == nullptr)
*dest = 0;
else {
- wcsncpy_s(dest, destLen, jid, _TRUNCATE);
+ strncpy_s(dest, destLen, jid, _TRUNCATE);
- wchar_t *p = wcschr(dest, '/');
+ char *p = strchr(dest, '/');
if (p != nullptr)
*p = 0;
}
@@ -673,7 +674,7 @@ static VOID CALLBACK sttRebuildInfoFrameApcProc(void* param)
ppro->m_pInfoFrame->UpdateInfoItem("$/JID", Skin_GetIconHandle(SKINICON_OTHER_USERDETAILS), TranslateT("Offline"));
}
else {
- ppro->m_pInfoFrame->UpdateInfoItem("$/JID", Skin_GetIconHandle(SKINICON_OTHER_USERDETAILS), ppro->m_szJabberJID);
+ ppro->m_pInfoFrame->UpdateInfoItem("$/JID", Skin_GetIconHandle(SKINICON_OTHER_USERDETAILS), Utf2T(ppro->m_szJabberJID));
if (!ppro->m_bPepSupported)
ppro->m_pInfoFrame->RemoveInfoItem("$/PEP");
@@ -699,18 +700,16 @@ static VOID CALLBACK sttRebuildInfoFrameApcProc(void* param)
LISTFOREACH(i, ppro, LIST_ROSTER)
{
if ((item = ppro->ListGetItemPtrFromIndex(i)) != nullptr) {
- if (wcschr(item->jid, '@') == nullptr && wcschr(item->jid, '/') == nullptr && item->subscription != SUB_NONE) {
+ if (strchr(item->jid, '@') == nullptr && strchr(item->jid, '/') == nullptr && item->subscription != SUB_NONE) {
MCONTACT hContact = ppro->HContactFromJID(item->jid);
if (hContact == 0)
continue;
char name[128];
- char *jid_copy = mir_u2a(item->jid);
- mir_snprintf(name, "$/Transports/%s", jid_copy);
+ mir_snprintf(name, "$/Transports/%s", item->jid);
ppro->m_pInfoFrame->CreateInfoItem(name, true, hContact);
ppro->m_pInfoFrame->UpdateInfoItem(name, ppro->GetIconHandle(IDI_TRANSPORTL), (wchar_t *)item->jid);
ppro->m_pInfoFrame->SetInfoItemCallback(name, &CJabberProto::InfoFrame_OnTransport);
- mir_free(jid_copy);
}
}
}
@@ -727,20 +726,20 @@ void CJabberProto::RebuildInfoFrame()
////////////////////////////////////////////////////////////////////////
// time2str & str2time
-wchar_t* time2str(time_t _time, wchar_t *buf, size_t bufLen)
+char* time2str(time_t _time, char *buf, size_t bufLen)
{
- struct tm* T = gmtime(&_time);
- mir_snwprintf(buf, bufLen, L"%04d-%02d-%02dT%02d:%02d:%02dZ",
+ struct tm *T = gmtime(&_time);
+ mir_snprintf(buf, bufLen, "%04d-%02d-%02dT%02d:%02d:%02dZ",
T->tm_year + 1900, T->tm_mon + 1, T->tm_mday, T->tm_hour, T->tm_min, T->tm_sec);
return buf;
}
-time_t str2time(const wchar_t *buf)
+time_t str2time(const char *buf)
{
struct tm T = { 0 };
- if (swscanf(buf, L"%04d-%02d-%02dT%02d:%02d:%02dZ", &T.tm_year, &T.tm_mon, &T.tm_mday, &T.tm_hour, &T.tm_min, &T.tm_sec) != 6) {
+ if (sscanf(buf, "%04d-%02d-%02dT%02d:%02d:%02dZ", &T.tm_year, &T.tm_mon, &T.tm_mday, &T.tm_hour, &T.tm_min, &T.tm_sec) != 6) {
int boo;
- if (swscanf(buf, L"%04d-%02d-%02dT%02d:%02d:%02d.%dZ", &T.tm_year, &T.tm_mon, &T.tm_mday, &T.tm_hour, &T.tm_min, &T.tm_sec, &boo) != 7)
+ if (sscanf(buf, "%04d-%02d-%02dT%02d:%02d:%02d.%dZ", &T.tm_year, &T.tm_mon, &T.tm_mday, &T.tm_hour, &T.tm_min, &T.tm_sec, &boo) != 7)
return 0;
}
@@ -807,18 +806,18 @@ BOOL CJabberProto::EnterString(CMStringW &result, const wchar_t *caption, int ty
/////////////////////////////////////////////////////////////////////////////////////////
// XEP-0203 delay support
-bool JabberReadXep203delay(HXML node, time_t &msgTime)
+bool JabberReadXep203delay(const TiXmlElement *node, time_t &msgTime)
{
- HXML n = XmlGetChildByTag(node, "delay", "xmlns", L"urn:xmpp:delay");
+ auto *n = XmlGetChildByTag(node, "delay", "xmlns", "urn:xmpp:delay");
if (n == nullptr)
return false;
- const wchar_t *ptszTimeStamp = XmlGetAttrValue(n, L"stamp");
+ const char *ptszTimeStamp = n->Attribute("stamp");
if (ptszTimeStamp == nullptr)
return false;
// skip '-' chars
- wchar_t *szStamp = NEWWSTR_ALLOCA(ptszTimeStamp);
+ char *szStamp = NEWSTR_ALLOCA(ptszTimeStamp);
int si = 0, sj = 0;
while (true) {
if (szStamp[si] == '-')
@@ -830,28 +829,28 @@ bool JabberReadXep203delay(HXML node, time_t &msgTime)
return msgTime != 0;
}
-bool CJabberProto::IsMyOwnJID(const wchar_t *szJID)
+bool CJabberProto::IsMyOwnJID(const char *szJID)
{
if (m_ThreadInfo == nullptr)
return false;
- ptrW szFrom(JabberPrepareJid(szJID));
+ ptrA szFrom(JabberPrepareJid(szJID));
if (szFrom == nullptr)
return false;
- ptrW szTo(JabberPrepareJid(m_ThreadInfo->fullJID));
+ ptrA szTo(JabberPrepareJid(m_ThreadInfo->fullJID));
if (szTo == nullptr)
return false;
- wchar_t *pDelimiter = wcschr(szFrom, '/');
+ char *pDelimiter = strchr(szFrom, '/');
if (pDelimiter)
*pDelimiter = 0;
- pDelimiter = wcschr(szTo, '/');
+ pDelimiter = strchr(szTo, '/');
if (pDelimiter)
*pDelimiter = 0;
- return mir_wstrcmp(szFrom, szTo) == 0;
+ return mir_strcmp(szFrom, szTo) == 0;
}
void __cdecl CJabberProto::LoadHttpAvatars(void* param)
@@ -923,6 +922,12 @@ void __cdecl CJabberProto::LoadHttpAvatars(void* param)
/////////////////////////////////////////////////////////////////////////////////////////
// UI utilities
+void SetDlgItemTextUtf(HWND hwndDlg, int ctrlId, const char *szValue)
+{
+ if (szValue)
+ SetDlgItemTextW(hwndDlg, ctrlId, Utf2T(szValue));
+}
+
int UIEmulateBtnClick(HWND hwndDlg, UINT idcButton)
{
if (IsWindowEnabled(GetDlgItem(hwndDlg, idcButton)))
diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp
index 1c32eb663c..a8ba50067c 100644
--- a/protocols/JabberG/src/jabber_vcard.cpp
+++ b/protocols/JabberG/src/jabber_vcard.cpp
@@ -31,13 +31,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/////////////////////////////////////////////////////////////////////////////////////////
-int CJabberProto::SendGetVcard(const wchar_t *jid)
+int CJabberProto::SendGetVcard(const char *jid)
{
if (!m_bJabberOnline) return 0;
CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultGetVcard, JABBER_IQ_TYPE_GET, jid);
- m_ThreadInfo->send(XmlNodeIq(pInfo) << XCHILDNS(L"vCard", JABBER_FEAT_VCARD_TEMP)
- << XATTR(L"prodid", L"-//HandGen//NONSGML vGen v1.0//EN") << XATTR(L"version", L"2.0"));
+ m_ThreadInfo->send(XmlNodeIq(pInfo) << XCHILDNS("vCard", JABBER_FEAT_VCARD_TEMP)
+ << XATTR("prodid", "-//HandGen//NONSGML vGen v1.0//EN") << XATTR("version", "2.0"));
return pInfo->GetIqId();
}
@@ -1001,13 +1001,13 @@ void CJabberProto::SaveVcardToDB(HWND hwndPage, int iPage)
}
}
-void CJabberProto::AppendVcardFromDB(HXML n, char *tag, char *key)
+void CJabberProto::AppendVcardFromDB(TiXmlElement *n, char *tag, char *key)
{
if (n == nullptr || tag == nullptr || key == nullptr)
return;
- ptrW tszValue(getWStringA(key));
- n << XCHILD(_A2T(tag), tszValue);
+ ptrA tszValue(getUStringA(key));
+ n << XCHILD(tag, tszValue);
}
void CJabberProto::SetServerVcard(BOOL bPhotoChanged, wchar_t* szPhotoFileName)
@@ -1018,11 +1018,11 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, wchar_t* szPhotoFileName)
char idstr[33];
XmlNodeIq iq(AddIQ(&CJabberProto::OnIqResultSetVcard, JABBER_IQ_TYPE_SET));
- HXML v = iq << XCHILDNS(L"vCard", JABBER_FEAT_VCARD_TEMP);
+ TiXmlElement *v = iq << XCHILDNS("vCard", JABBER_FEAT_VCARD_TEMP);
AppendVcardFromDB(v, "FN", "FullName");
- HXML n = v << XCHILD(L"N");
+ TiXmlElement *n = v << XCHILD("N");
AppendVcardFromDB(n, "GIVEN", "FirstName");
AppendVcardFromDB(n, "MIDDLE", "MiddleName");
AppendVcardFromDB(n, "FAMILY", "LastName");
@@ -1033,23 +1033,23 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, wchar_t* szPhotoFileName)
for (i = 0;; i++) {
mir_snprintf(idstr, "e-mail%d", i);
- ptrW email(getWStringA(idstr));
+ ptrA email(getUStringA(idstr));
if (email == nullptr)
break;
- HXML e = v << XCHILD(L"EMAIL", email);
+ TiXmlElement *e = v << XCHILD("EMAIL", email);
AppendVcardFromDB(e, "USERID", idstr);
mir_snprintf(idstr, "e-mailFlag%d", i);
WORD nFlag = getWord(idstr, 0);
- if (nFlag & JABBER_VCEMAIL_HOME) e << XCHILD(L"HOME");
- if (nFlag & JABBER_VCEMAIL_WORK) e << XCHILD(L"WORK");
- if (nFlag & JABBER_VCEMAIL_INTERNET) e << XCHILD(L"INTERNET");
- if (nFlag & JABBER_VCEMAIL_X400) e << XCHILD(L"X400");
+ if (nFlag & JABBER_VCEMAIL_HOME) e << XCHILD("HOME");
+ if (nFlag & JABBER_VCEMAIL_WORK) e << XCHILD("WORK");
+ if (nFlag & JABBER_VCEMAIL_INTERNET) e << XCHILD("INTERNET");
+ if (nFlag & JABBER_VCEMAIL_X400) e << XCHILD("X400");
}
- n = v << XCHILD(L"ADR");
- n << XCHILD(L"HOME");
+ n = v << XCHILD("ADR");
+ n << XCHILD("HOME");
AppendVcardFromDB(n, "STREET", "Street");
AppendVcardFromDB(n, "EXTADR", "Street2");
AppendVcardFromDB(n, "EXTADD", "Street2"); // for compatibility with client using old vcard format
@@ -1059,8 +1059,8 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, wchar_t* szPhotoFileName)
AppendVcardFromDB(n, "CTRY", "Country");
AppendVcardFromDB(n, "COUNTRY", "Country"); // for compatibility with client using old vcard format
- n = v << XCHILD(L"ADR");
- n << XCHILD(L"WORK");
+ n = v << XCHILD("ADR");
+ n << XCHILD("WORK");
AppendVcardFromDB(n, "STREET", "CompanyStreet");
AppendVcardFromDB(n, "EXTADR", "CompanyStreet2");
AppendVcardFromDB(n, "EXTADD", "CompanyStreet2"); // for compatibility with client using old vcard format
@@ -1070,7 +1070,7 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, wchar_t* szPhotoFileName)
AppendVcardFromDB(n, "CTRY", "CompanyCountry");
AppendVcardFromDB(n, "COUNTRY", "CompanyCountry"); // for compatibility with client using old vcard format
- n = v << XCHILD(L"ORG");
+ n = v << XCHILD("ORG");
AppendVcardFromDB(n, "ORGNAME", "Company");
AppendVcardFromDB(n, "ORGUNIT", "CompanyDepartment");
@@ -1085,23 +1085,23 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, wchar_t* szPhotoFileName)
if (phone == nullptr)
break;
- n = v << XCHILD(L"TEL");
+ n = v << XCHILD("TEL");
AppendVcardFromDB(n, "NUMBER", idstr);
mir_snprintf(idstr, "PhoneFlag%d", i);
WORD nFlag = getWord(idstr, 0);
- if (nFlag & JABBER_VCTEL_HOME) n << XCHILD(L"HOME");
- if (nFlag & JABBER_VCTEL_WORK) n << XCHILD(L"WORK");
- if (nFlag & JABBER_VCTEL_VOICE) n << XCHILD(L"VOICE");
- if (nFlag & JABBER_VCTEL_FAX) n << XCHILD(L"FAX");
- if (nFlag & JABBER_VCTEL_PAGER) n << XCHILD(L"PAGER");
- if (nFlag & JABBER_VCTEL_MSG) n << XCHILD(L"MSG");
- if (nFlag & JABBER_VCTEL_CELL) n << XCHILD(L"CELL");
- if (nFlag & JABBER_VCTEL_VIDEO) n << XCHILD(L"VIDEO");
- if (nFlag & JABBER_VCTEL_BBS) n << XCHILD(L"BBS");
- if (nFlag & JABBER_VCTEL_MODEM) n << XCHILD(L"MODEM");
- if (nFlag & JABBER_VCTEL_ISDN) n << XCHILD(L"ISDN");
- if (nFlag & JABBER_VCTEL_PCS) n << XCHILD(L"PCS");
+ if (nFlag & JABBER_VCTEL_HOME) n << XCHILD("HOME");
+ if (nFlag & JABBER_VCTEL_WORK) n << XCHILD("WORK");
+ if (nFlag & JABBER_VCTEL_VOICE) n << XCHILD("VOICE");
+ if (nFlag & JABBER_VCTEL_FAX) n << XCHILD("FAX");
+ if (nFlag & JABBER_VCTEL_PAGER) n << XCHILD("PAGER");
+ if (nFlag & JABBER_VCTEL_MSG) n << XCHILD("MSG");
+ if (nFlag & JABBER_VCTEL_CELL) n << XCHILD("CELL");
+ if (nFlag & JABBER_VCTEL_VIDEO) n << XCHILD("VIDEO");
+ if (nFlag & JABBER_VCTEL_BBS) n << XCHILD("BBS");
+ if (nFlag & JABBER_VCTEL_MODEM) n << XCHILD("MODEM");
+ if (nFlag & JABBER_VCTEL_ISDN) n << XCHILD("ISDN");
+ if (nFlag & JABBER_VCTEL_PCS) n << XCHILD("PCS");
}
wchar_t szAvatarName[MAX_PATH], *szFileName;
@@ -1114,7 +1114,7 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, wchar_t* szPhotoFileName)
// Set photo element, also update the global jabberVcardPhotoFileName to reflect the update
debugLogW(L"Before update, file name = %s", szFileName);
if (szFileName == nullptr || szFileName[0] == 0) {
- v << XCHILD(L"PHOTO");
+ v << XCHILD("PHOTO");
DeleteFile(szAvatarName);
delSetting("AvatarSaved");
delSetting("AvatarHash");
@@ -1132,11 +1132,11 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, wchar_t* szPhotoFileName)
DWORD nRead;
if (ReadFile(hFile, buffer, st.st_size, &nRead, nullptr)) {
ptrA str(mir_base64_encode(buffer, nRead));
- const wchar_t *szFileType = ProtoGetAvatarMimeType(ProtoGetBufferFormat(buffer));
+ const char *szFileType = ProtoGetAvatarMimeType(ProtoGetBufferFormat(buffer));
if (str != nullptr && szFileType != nullptr) {
- n = v << XCHILD(L"PHOTO");
- n << XCHILD(L"TYPE", szFileType);
- n << XCHILD(L"BINVAL", _A2T(str));
+ n = v << XCHILD("PHOTO");
+ n << XCHILD("TYPE", szFileType);
+ n << XCHILD("BINVAL", str);
// NEED TO UPDATE OUR AVATAR HASH:
BYTE digest[MIR_SHA1_HASH_SIZE];
diff --git a/protocols/JabberG/src/jabber_xml.cpp b/protocols/JabberG/src/jabber_xml.cpp
index fe48d7b1af..66cb7a73bc 100644
--- a/protocols/JabberG/src/jabber_xml.cpp
+++ b/protocols/JabberG/src/jabber_xml.cpp
@@ -28,291 +28,187 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define TAG_MAX_LEN 128
#define ATTR_MAX_LEN 8192
-#define T2UTF(A) A
-
/////////////////////////////////////////////////////////////////////////////////////////
// XmlNodeIq class members
-XmlNodeIq::XmlNodeIq(const wchar_t *type, int id, const wchar_t *to) :
- XmlNode(L"iq")
+XmlNodeIq::XmlNodeIq(const char *type, int id, const char *to) :
+ XmlNode("iq")
{
- if (type != nullptr) *this << XATTR(L"type", type);
- if (to != nullptr) *this << XATTR(L"to", to);
+ if (type != nullptr) *this << XATTR("type", type);
+ if (to != nullptr) *this << XATTR("to", to);
if (id != -1 ) *this << XATTRID(id);
}
-XmlNodeIq::XmlNodeIq(const wchar_t *type, const wchar_t *idStr, const wchar_t *to) :
- XmlNode(L"iq")
+XmlNodeIq::XmlNodeIq(const char *type, const char *idStr, const char *to) :
+ XmlNode("iq")
{
- if (type != nullptr) *this << XATTR(L"type", type );
- if (to != nullptr) *this << XATTR(L"to", to );
- if (idStr != nullptr) *this << XATTR(L"id", idStr);
+ if (type != nullptr) *this << XATTR("type", type );
+ if (to != nullptr) *this << XATTR("to", to );
+ if (idStr != nullptr) *this << XATTR("id", idStr);
}
-XmlNodeIq::XmlNodeIq(const wchar_t *type, HXML node, const wchar_t *to) :
- XmlNode(L"iq")
+XmlNodeIq::XmlNodeIq(const char *type, TiXmlElement *node, const char *to) :
+ XmlNode("iq")
{
- if (type != nullptr) *this << XATTR(L"type", type );
- if (to != nullptr) *this << XATTR(L"to", to );
+ if (type != nullptr) *this << XATTR("type", type );
+ if (to != nullptr) *this << XATTR("to", to );
if (node != nullptr) {
- const wchar_t *iqId = XmlGetAttrValue(*this, L"id");
- if (iqId != nullptr) *this << XATTR(L"id", iqId);
+ const char *iqId = node->Attribute("id");
+ if (iqId != nullptr)
+ *this << XATTR("id", iqId);
}
}
XmlNodeIq::XmlNodeIq(CJabberIqInfo *pInfo) :
- XmlNode(L"iq")
+ XmlNode("iq")
{
if (pInfo) {
- if (pInfo->GetCharIqType() != nullptr) *this << XATTR(L"type", _A2T(pInfo->GetCharIqType()));
- if (pInfo->GetReceiver() != nullptr) *this << XATTR(L"to", pInfo->GetReceiver());
+ if (pInfo->GetCharIqType() != nullptr) *this << XATTR("type", pInfo->GetCharIqType());
+ if (pInfo->GetReceiver() != nullptr) *this << XATTR("to", pInfo->GetReceiver());
if (pInfo->GetIqId() != -1) *this << XATTRID(pInfo->GetIqId());
}
}
-XmlNodeIq::XmlNodeIq(const wchar_t *type, CJabberIqInfo *pInfo) :
- XmlNode(L"iq")
+XmlNodeIq::XmlNodeIq(const char *type, CJabberIqInfo *pInfo) :
+ XmlNode("iq")
{
- if (type != nullptr) *this << XATTR(L"type", type);
+ if (type != nullptr) *this << XATTR("type", type);
if (pInfo) {
- if (pInfo->GetFrom() != nullptr) *this << XATTR(L"to", pInfo->GetFrom());
- if (pInfo->GetIdStr() != nullptr) *this << XATTR(L"id", pInfo->GetIdStr());
+ if (pInfo->GetFrom() != nullptr) *this << XATTR("to", pInfo->GetFrom());
+ if (pInfo->GetIdStr() != nullptr) *this << XATTR("id", pInfo->GetIdStr());
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// XmlNode class members
-XmlNode::XmlNode(const wchar_t *pszName)
-{
- m_hXml = xmlCreateNode(T2UTF(pszName), nullptr, 0);
-}
-
-XmlNode::XmlNode(const wchar_t *pszName, const wchar_t *ptszText)
-{
- m_hXml = xmlCreateNode(T2UTF(pszName), ptszText, 0);
-}
-
-XmlNode::XmlNode(const XmlNode& n)
+XmlNode::XmlNode(const char *pszName)
{
- m_hXml = xmlCopyNode(n);
+ m_hXml = NewElement(pszName); InsertEndChild(m_hXml);
}
-XmlNode& XmlNode::operator =(const XmlNode& n)
+XmlNode::XmlNode(const char *pszName, const char *ptszText)
{
- if (m_hXml)
- xmlDestroyNode(m_hXml);
- m_hXml = xmlCopyNode(n);
- return *this;
+ m_hXml = NewElement(pszName); InsertEndChild(m_hXml);
+ m_hXml->SetText(ptszText);
}
-XmlNode::~XmlNode()
-{
- if (m_hXml) {
- xmlDestroyNode(m_hXml);
- m_hXml = nullptr;
-} }
-
/////////////////////////////////////////////////////////////////////////////////////////
-HXML __fastcall operator<<(HXML node, const XCHILDNS& child)
+TiXmlElement*operator<<(TiXmlElement *node, const XCHILDNS &child)
{
- HXML res = XmlAddChild(node, child.name);
- XmlAddAttr(res, L"xmlns", child.ns);
+ TiXmlElement *res = XmlAddChild(node, child.name);
+ res->SetAttribute("xmlns", child.ns);
return res;
}
-HXML __fastcall operator<<(HXML node, const XQUERY& child)
+TiXmlElement* operator<<(TiXmlElement *node, const XQUERY &child)
{
- HXML n = XmlAddChild(node, L"query");
+ TiXmlElement *n = node->GetDocument()->NewElement("query");
if (n)
- XmlAddAttr(n, L"xmlns", child.ns);
+ n->SetAttribute("xmlns", child.ns);
return n;
}
/////////////////////////////////////////////////////////////////////////////////////////
-void __fastcall XmlAddAttr(HXML hXml, const wchar_t *name, const wchar_t *value)
+void XmlAddAttr(TiXmlElement *hXml, const char *name, const char *value)
{
if (value)
- xmlAddAttr(hXml, name, T2UTF(value));
-}
-
-void __fastcall XmlAddAttr(HXML hXml, const wchar_t *pszName, int value)
-{
- xmlAddAttrInt(hXml, T2UTF(pszName), value);
-}
-
-void __fastcall XmlAddAttr(HXML hXml, const wchar_t *pszName, unsigned __int64 value)
-{
- wchar_t buf[60];
- _ui64tot(value, buf, 10);
-
- xmlAddAttr(hXml, T2UTF(pszName), T2UTF(buf));
+ hXml->SetAttribute(name, value);
}
-void __fastcall XmlAddAttrID(HXML hXml, int id)
+void XmlAddAttrID(TiXmlElement *hXml, int id)
{
- wchar_t text[100];
- mir_snwprintf(text, _T(JABBER_IQID) L"%d", id);
- XmlAddAttr(hXml, L"id", text);
+ char text[100];
+ mir_snprintf(text, JABBER_IQID "%d", id);
+ hXml->SetAttribute("id", text);
}
/////////////////////////////////////////////////////////////////////////////////////////
-const wchar_t *__fastcall XmlGetAttr(HXML hXml, int n)
+TiXmlElement* XmlAddChild(TiXmlElement *hXml, const char *name)
{
- return xmlGetAttr(hXml, n);
-}
-
-int __fastcall XmlGetAttrCount(HXML hXml)
-{
- return xmlGetAttrCount(hXml);
-}
+ if (hXml == nullptr)
+ return nullptr;
-const wchar_t *__fastcall XmlGetAttrName(HXML hXml, int n)
-{
- return xmlGetAttrName(hXml, n);
+ return hXml->GetDocument()->NewElement(name);
}
-/////////////////////////////////////////////////////////////////////////////////////////
-
-void __fastcall XmlAddChild(HXML hXml, HXML n)
+TiXmlElement* XmlAddChild(TiXmlElement *hXml, const char *name, const char *value)
{
- xmlAddChild2(n, hXml);
-}
+ if (hXml == nullptr)
+ return nullptr;
-HXML __fastcall XmlAddChild(HXML hXml, const wchar_t *name)
-{
- return xmlAddChild(hXml, T2UTF(name), nullptr);
+ auto *res = hXml->GetDocument()->NewElement(name);
+ res->SetText(value);
+ return res;
}
-HXML __fastcall XmlAddChild(HXML hXml, const wchar_t *name, const wchar_t *value)
+TiXmlElement* XmlAddChild(TiXmlElement *hXml, const char *name, int value)
{
- return xmlAddChild(hXml, T2UTF(name), T2UTF(value));
-}
+ if (hXml == nullptr)
+ return nullptr;
-HXML __fastcall XmlAddChild(HXML hXml, const wchar_t *name, int value)
-{
- wchar_t buf[40];
- _itow(value, buf, 10);
- return xmlAddChild(hXml, T2UTF(name), buf);
+ auto *res = hXml->GetDocument()->NewElement(name);
+ res->SetText(value);
+ return res;
}
/////////////////////////////////////////////////////////////////////////////////////////
-const wchar_t *__fastcall XmlGetAttrValue(HXML hXml, const wchar_t *key)
-{
- return xmlGetAttrValue(hXml, key);
-}
-
-HXML __fastcall XmlGetChild(HXML hXml, int n)
+const TiXmlElement* XmlGetChildByTag(const TiXmlElement *hXml, const char *key, const char *attrName, const char *attrValue)
{
- return xmlGetChild(hXml, n);
-}
-
-HXML __fastcall XmlGetChild(HXML hXml, const wchar_t *key)
-{
- return xmlGetNthChild(hXml, key, 0);
-}
-
-HXML __fastcall XmlGetChild(HXML hXml, LPCSTR key)
-{
- LPTSTR wszKey = mir_a2u(key);
- HXML result = xmlGetNthChild(hXml, wszKey, 0);
- mir_free(wszKey);
- return result;
-}
-
-HXML __fastcall XmlGetChildByTag(HXML hXml, const wchar_t *key, const wchar_t *attrName, const wchar_t *attrValue)
-{
- return xmlGetChildByAttrValue(hXml, key, attrName, attrValue);
-}
-
-HXML __fastcall XmlGetChildByTag(HXML hXml, LPCSTR key, LPCSTR attrName, const wchar_t *attrValue)
-{
- LPTSTR wszKey = mir_a2u(key), wszName = mir_a2u(attrName);
- HXML result = xmlGetChildByAttrValue(hXml, wszKey, wszName, attrValue);
- mir_free(wszKey), mir_free(wszName);
- return result;
-}
-
-int __fastcall XmlGetChildCount(HXML hXml)
-{
- return xmlGetChildCount(hXml);
-}
-
-HXML __fastcall XmlGetNthChild(HXML hXml, const wchar_t *tag, int nth)
-{
- int i, num;
-
- if (!hXml || tag == nullptr || mir_wstrlen(tag) <= 0 || nth < 1)
+ if (hXml == nullptr)
return nullptr;
- num = 1;
- for (i=0; ; i++) {
- HXML n = xmlGetChild(hXml, i);
- if (!n)
- break;
- if (!mir_wstrcmp(tag, XmlGetName(n))) {
- if (num == nth)
- return n;
-
- num++;
- } }
-
- return nullptr;
-}
+ auto *pChild = hXml->FirstChildElement(key);
+ if (pChild == nullptr)
+ return nullptr;
-const wchar_t *__fastcall XmlGetName(HXML xml)
-{
- return xmlGetName(xml);
+ return (pChild->Attribute(attrName, attrValue)) ? pChild : nullptr;
}
-const wchar_t *__fastcall XmlGetText(HXML xml)
+int XmlGetChildCount(const TiXmlElement *hXml)
{
- return (xml) ? xmlGetText(xml) : nullptr;
+ int iCount = 0;
+ for (auto *it : TiXmlEnum(hXml)) {
+ UNREFERENCED_PARAMETER(it);
+ iCount++;
+ }
+ return iCount;
}
/////////////////////////////////////////////////////////////////////////////////////////
-void XPath::ProcessPath(LookupInfo &info, bool bCreate)
+void XPath::ProcessPath(LookupInfo &info)
{
if (!info.nodeName) return;
- wchar_t *nodeName = (wchar_t *)alloca(sizeof(wchar_t) * (info.nodeName.length+1));
- mir_wstrncpy(nodeName, info.nodeName.p, info.nodeName.length+1);
+ char *nodeName = (char *)alloca(sizeof(char) * (info.nodeName.length+1));
+ mir_strncpy(nodeName, info.nodeName.p, info.nodeName.length+1);
if (info.attrName && info.attrValue) {
- wchar_t *attrName = (wchar_t *)alloca(sizeof(wchar_t)* (info.attrName.length + 1));
- mir_wstrncpy(attrName, info.attrName.p, info.attrName.length + 1);
- wchar_t *attrValue = (wchar_t *)alloca(sizeof(wchar_t)* (info.attrValue.length + 1));
- mir_wstrncpy(attrValue, info.attrValue.p, info.attrValue.length + 1);
- HXML hXml = XmlGetChildByTag(m_hXml, nodeName, attrName, attrValue);
-
- m_hXml = (hXml || !bCreate) ? hXml : (m_hXml << XCHILD(nodeName) << XATTR(attrName, attrValue));
- }
- else if (info.nodeIndex) {
- int idx = _wtoi(info.nodeIndex.p);
- m_hXml = mir_wstrcmp(nodeName, L"*") ? XmlGetNthChild(m_hXml, nodeName, idx) : XmlGetChild(m_hXml, idx - 1);
- }
- else {
- HXML hXml = XmlGetChild(m_hXml, nodeName);
- m_hXml = (hXml || !bCreate) ? hXml : (m_hXml << XCHILD(nodeName));
+ char *attrName = (char *)alloca(sizeof(char)* (info.attrName.length + 1));
+ mir_strncpy(attrName, info.attrName.p, info.attrName.length + 1);
+ char *attrValue = (char *)alloca(sizeof(char)* (info.attrValue.length + 1));
+ mir_strncpy(attrValue, info.attrValue.p, info.attrValue.length + 1);
+ m_hXml = XmlGetChildByTag(m_hXml, nodeName, attrName, attrValue);
}
+ else m_hXml = m_hXml->FirstChildElement(nodeName);
info.Reset();
}
-XPath::PathType XPath::LookupImpl(bool bCreate)
+XPath::PathType XPath::LookupImpl()
{
LookupState state = S_START;
LookupInfo info = {};
- for (const wchar_t *p = m_szPath; state < S_FINAL; ++p) {
+ for (const char *p = m_szPath; state < S_FINAL; ++p) {
switch (state) {
case S_START:
- ProcessPath(info, bCreate);
+ ProcessPath(info);
if (!m_hXml) {
state = S_FINAL_ERROR;
break;
@@ -374,29 +270,6 @@ XPath::PathType XPath::LookupImpl(bool bCreate)
info.attrName.Begin(p + 1);
state = S_NODE_ATTRNAME;
break;
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- info.nodeIndex.Begin(p);
- state = S_NODE_INDEX;
- break;
- default:
- state = S_FINAL_ERROR;
- break;
- };
- break;
-
- case S_NODE_INDEX:
- switch (*p) {
- case 0:
- state = S_FINAL_ERROR;
- break;
- case ']':
- info.nodeIndex.End(p);
- state = S_NODE_CLOSEBRACKET;
- break;
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- break;
default:
state = S_FINAL_ERROR;
break;
@@ -484,7 +357,7 @@ XPath::PathType XPath::LookupImpl(bool bCreate)
m_szParam = info.attrName.p;
return T_ATTRIBUTE;
case S_FINAL_NODE:
- ProcessPath(info, bCreate);
+ ProcessPath(info);
return T_NODE;
case S_FINAL_NODESET:
m_szParam = info.nodeName.p;
diff --git a/protocols/JabberG/src/jabber_xml.h b/protocols/JabberG/src/jabber_xml.h
index dced7ed334..b1ee52586f 100644
--- a/protocols/JabberG/src/jabber_xml.h
+++ b/protocols/JabberG/src/jabber_xml.h
@@ -26,88 +26,64 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef _JABBER_XML_H_
#define _JABBER_XML_H_
-#include <m_xml.h>
-
-void __fastcall XmlAddChild(HXML, HXML);
-HXML __fastcall XmlAddChild(HXML, const wchar_t *pszName);
-HXML __fastcall XmlAddChild(HXML, const wchar_t *pszName, const wchar_t *ptszValue);
-HXML __fastcall XmlAddChild(HXML, const wchar_t *pszName, int iValue);
-
-const wchar_t *__fastcall XmlGetAttrValue(HXML, const wchar_t *key);
-HXML __fastcall XmlGetChild(HXML, int n = 0);
-HXML __fastcall XmlGetChild(HXML, LPCSTR key);
-HXML __fastcall XmlGetChild(HXML, const wchar_t *key);
-int __fastcall XmlGetChildCount(HXML);
-HXML __fastcall XmlGetChildByTag(HXML, const wchar_t *key, const wchar_t *attrName, const wchar_t *attrValue);
-HXML __fastcall XmlGetChildByTag(HXML, LPCSTR key, LPCSTR attrName, const wchar_t *attrValue);
-HXML __fastcall XmlGetNthChild(HXML, const wchar_t *key, int n = 0);
-
-const wchar_t *__fastcall XmlGetName(HXML);
-const wchar_t *__fastcall XmlGetText(HXML);
-
-void __fastcall XmlAddAttr(HXML, const wchar_t *pszName, const wchar_t *ptszValue);
-void __fastcall XmlAddAttr(HXML, const wchar_t *pszName, int value);
-void __fastcall XmlAddAttr(HXML hXml, const wchar_t *pszName, unsigned __int64 value);
-void __fastcall XmlAddAttrID(HXML, int id);
-
-int __fastcall XmlGetAttrCount(HXML);
-const wchar_t *__fastcall XmlGetAttr(HXML, int n);
-const wchar_t *__fastcall XmlGetAttrName(HXML, int n);
-const wchar_t *__fastcall XmlGetAttrValue(HXML, const wchar_t *key);
-
-struct XmlNode
-{
- __forceinline XmlNode() { m_hXml = nullptr; }
+int XmlGetChildCount(const TiXmlElement*);
- __forceinline XmlNode(const wchar_t *pszString, int* numBytes, const wchar_t *ptszTag)
- {
- m_hXml = xmlParseString(pszString, numBytes, ptszTag);
- }
+TiXmlElement* XmlAddChild(TiXmlElement*, const char *pszName);
+TiXmlElement* XmlAddChild(TiXmlElement*, const char *pszName, const char *ptszValue);
+TiXmlElement* XmlAddChild(TiXmlElement*, const char *pszName, int iValue);
- XmlNode(const XmlNode& n);
- XmlNode(const wchar_t *name);
- XmlNode(const wchar_t *pszName, const wchar_t *ptszText);
- ~XmlNode();
+const TiXmlElement* XmlGetChildByTag(const TiXmlElement*, const char *key, const char *attrName, const char *attrValue);
- XmlNode& operator =(const XmlNode& n);
+void XmlAddAttr(TiXmlElement*, const char *pszName, const char *ptszValue);
+void XmlAddAttrID(TiXmlElement*, int id);
- __forceinline operator HXML() const
+int XmlGetAttrCount(TiXmlElement*);
+const char* XmlGetAttr(TiXmlElement*, int n);
+const char* XmlGetAttrName(TiXmlElement*, int n);
+
+class XmlNode : public TiXmlDocument, private MNonCopyable
+{
+ TiXmlElement *m_hXml;
+
+public:
+ XmlNode(const char *name);
+ XmlNode(const char *pszName, const char *ptszText);
+
+ __forceinline operator TiXmlElement*()
{ return m_hXml;
}
-
-private:
- HXML m_hXml;
};
class CJabberIqInfo;
struct XmlNodeIq : public XmlNode
{
- XmlNodeIq(const wchar_t *type, int id = -1, const wchar_t *to = nullptr);
- XmlNodeIq(const wchar_t *type, const wchar_t *idStr, const wchar_t *to);
- XmlNodeIq(const wchar_t *type, HXML node, const wchar_t *to);
+ XmlNodeIq(const char *type, int id = -1, const char *to = nullptr);
+ XmlNodeIq(const char *type, const char *idStr, const char *to);
+ XmlNodeIq(const char *type, TiXmlElement *node, const char *to);
// new request
XmlNodeIq(CJabberIqInfo *pInfo);
// answer to request
- XmlNodeIq(const wchar_t *type, CJabberIqInfo *pInfo);
+ XmlNodeIq(const char *type, CJabberIqInfo *pInfo);
};
-typedef void (*JABBER_XML_CALLBACK)(HXML, void*);
+typedef void (*JABBER_XML_CALLBACK)(TiXmlElement*, void*);
/////////////////////////////////////////////////////////////////////////////////////////
struct XATTR
{
- const wchar_t *name, *value;
+ const char *name, *value;
- __forceinline XATTR(const wchar_t *_name, const wchar_t *_value) :
+ __forceinline XATTR(const char *_name, const char *_value) :
name(_name),
value(_value)
{}
};
-HXML __forceinline operator<<(HXML node, const XATTR& attr)
-{ XmlAddAttr(node, attr.name, attr.value);
+__forceinline TiXmlElement *operator<<(TiXmlElement *node, const XATTR& attr)
+{
+ node->SetAttribute(attr.name, attr.value);
return node;
}
@@ -115,17 +91,18 @@ HXML __forceinline operator<<(HXML node, const XATTR& attr)
struct XATTRI
{
- const wchar_t *name;
+ const char *name;
int value;
- __forceinline XATTRI(const wchar_t *_name, int _value) :
+ __forceinline XATTRI(const char *_name, int _value) :
name(_name),
value(_value)
{}
};
-HXML __forceinline operator<<(HXML node, const XATTRI& attr)
-{ XmlAddAttr(node, attr.name, attr.value);
+__forceinline TiXmlElement *operator<<(TiXmlElement *node, const XATTRI& attr)
+{
+ node->SetAttribute(attr.name, attr.value);
return node;
}
@@ -133,17 +110,18 @@ HXML __forceinline operator<<(HXML node, const XATTRI& attr)
struct XATTRI64
{
- const wchar_t *name;
- unsigned __int64 value;
+ const char *name;
+ __int64 value;
- __forceinline XATTRI64(const wchar_t *_name, unsigned __int64 _value) :
+ __forceinline XATTRI64(const char *_name, __int64 _value) :
name(_name),
value(_value)
{}
};
-HXML __forceinline operator<<(HXML node, const XATTRI64& attr)
-{ XmlAddAttr(node, attr.name, attr.value);
+__forceinline TiXmlElement *operator<<(TiXmlElement *node, const XATTRI64& attr)
+{
+ node->SetAttribute(attr.name, attr.value);
return node;
}
@@ -158,8 +136,9 @@ struct XATTRID
{}
};
-HXML __forceinline operator<<(HXML node, const XATTRID& attr)
-{ XmlAddAttrID(node, attr.id);
+__forceinline TiXmlElement *operator<<(TiXmlElement *node, const XATTRID& attr)
+{
+ node->SetAttribute("id", attr.id);
return node;
}
@@ -167,44 +146,45 @@ HXML __forceinline operator<<(HXML node, const XATTRID& attr)
struct XCHILD
{
- const wchar_t *name, *value;
+ const char *name, *value;
- __forceinline XCHILD(const wchar_t *_name, const wchar_t *_value = nullptr) :
+ __forceinline XCHILD(const char *_name, const char *_value = nullptr) :
name(_name),
value(_value)
{}
};
-HXML __forceinline operator<<(HXML node, const XCHILD& child)
-{ return XmlAddChild(node, child.name, child.value);
+__forceinline TiXmlElement *operator<<(TiXmlElement *node, const XCHILD& child)
+{
+ return XmlAddChild(node, child.name, child.value);
}
/////////////////////////////////////////////////////////////////////////////////////////
struct XCHILDNS
{
- const wchar_t *name, *ns;
+ const char *name, *ns;
- __forceinline XCHILDNS(const wchar_t *_name, const wchar_t *_ns = nullptr) :
+ __forceinline XCHILDNS(const char *_name, const char *_ns = nullptr) :
name(_name),
ns(_ns)
{}
};
-HXML __fastcall operator<<(HXML node, const XCHILDNS& child);
+TiXmlElement *__fastcall operator<<(TiXmlElement *node, const XCHILDNS& child);
/////////////////////////////////////////////////////////////////////////////////////////
struct XQUERY
{
- const wchar_t *ns;
+ const char *ns;
- __forceinline XQUERY(const wchar_t *_ns) :
+ __forceinline XQUERY(const char *_ns) :
ns(_ns)
{}
};
-HXML __fastcall operator<<(HXML node, const XQUERY& child);
+TiXmlElement *__fastcall operator<<(TiXmlElement *node, const XQUERY& child);
/////////////////////////////////////////////////////////////////////////////////////////
// Limited XPath support
@@ -213,76 +193,53 @@ HXML __fastcall operator<<(HXML node, const XQUERY& child);
// result may be either "node-spec", or "@attr-name"
//
// Samples:
-// const wchar_t *s = XPathT(node, "child/subchild[@attr='value']"); // get node text
-// const wchar_t *s = XPathT(node, "child/subchild[2]/@attr"); // get attribute value
-// XPathT(node, "child/subchild[@name='test']/@attr") = L"Hello"; // create path if needed and set attribute value
+// const char *s = XPath(node, "child/subchild[@attr='value']"); // get node text
+// XPath(node, "child/subchild[@name='test']/@attr") = L"Hello"; // create path if needed and set attribute value
//
-// XPathT(node, "child/subchild[@name='test']") = L"Hello"; // TODO: create path if needed and set node text
-
-#define XPathT(a,b) XPath(a, _T(b))
+// XPath(node, "child/subchild[@name='test']") = L"Hello"; // TODO: create path if needed and set node text
class XPath
{
public:
- __forceinline XPath(HXML hXml, wchar_t *path):
+ __forceinline XPath(const TiXmlElement *hXml, char *path):
m_type(T_UNKNOWN),
- m_hXml(hXml),
m_szPath(path),
+ m_hXml(hXml),
m_szParam(nullptr)
- {}
+ {}
// Read data
- operator HXML()
+ operator const TiXmlElement*()
{
switch (Lookup())
{
- case T_NODE: return m_hXml;
- case T_NODESET: return XmlGetNthChild(m_hXml, m_szParam, 1);
+ case T_NODE: return m_hXml;
+ case T_NODESET: return m_hXml->FirstChildElement(m_szParam);
}
return nullptr;
}
- operator LPTSTR()
+ operator LPCSTR()
{
switch (Lookup())
{
- case T_ATTRIBUTE: return (wchar_t *)XmlGetAttrValue(m_hXml, m_szParam);
- case T_NODE: return (wchar_t *)XmlGetText(m_hXml);
- case T_NODESET: return (wchar_t *)XmlGetText(XmlGetNthChild(m_hXml, m_szParam, 1));
+ case T_ATTRIBUTE: return m_hXml->Attribute(m_szParam);
+ case T_NODE: return m_hXml->GetText();
+ case T_NODESET: return m_hXml->FirstChildElement()->GetText();
}
return nullptr;
}
operator int()
{
- if (wchar_t *s = *this) return _wtoi(s);
+ if (LPCSTR s = *this) return atoi(s);
return 0;
}
- __forceinline bool operator== (wchar_t *str)
- {
- return !mir_wstrcmp((const wchar_t *)*this, str);
- }
- __forceinline bool operator!= (wchar_t *str)
- {
- return mir_wstrcmp((const wchar_t *)*this, str) ? true : false;
- }
- HXML operator[] (int idx)
+ __forceinline bool operator== (char *str)
{
- return (Lookup() == T_NODESET) ? XmlGetNthChild(m_hXml, m_szParam, idx) : nullptr;
- }
-
- // Write data
- void operator= (const wchar_t *value)
- {
- switch (Lookup(true))
- {
- case T_ATTRIBUTE: XmlAddAttr(m_hXml, m_szParam, value); break;
- case T_NODE: break; // TODO: set node text
- }
+ return !mir_strcmp(*this, str);
}
- void operator= (int value)
+ __forceinline bool operator!= (char *str)
{
- wchar_t buf[16];
- _itow(value, buf, 10);
- *this = buf;
+ return mir_strcmp(*this, str) ? true : false;
}
private:
@@ -295,9 +252,9 @@ private:
T_NODESET
};
- __forceinline PathType Lookup(bool bCreate=false)
+ __forceinline PathType Lookup()
{
- return (m_type == T_UNKNOWN) ? LookupImpl(bCreate) : m_type;
+ return (m_type == T_UNKNOWN) ? LookupImpl() : m_type;
}
enum LookupState
@@ -306,7 +263,6 @@ private:
S_ATTR_STEP,
S_NODE_NAME,
S_NODE_OPENBRACKET,
- S_NODE_INDEX,
S_NODE_ATTRNAME,
S_NODE_ATTREQUALS,
S_NODE_ATTRVALUE,
@@ -322,11 +278,11 @@ private:
struct LookupString
{
- void Begin(const wchar_t *p_) { p = p_; }
- void End(const wchar_t *p_) { length = p_ - p; }
+ void Begin(const char *p_) { p = p_; }
+ void End(const char *p_) { length = p_ - p; }
operator bool() { return p ? true : false; }
- const wchar_t *p;
+ const char *p;
int length;
};
@@ -337,34 +293,22 @@ private:
LookupString nodeName;
LookupString attrName;
LookupString attrValue;
- LookupString nodeIndex;
};
- void ProcessPath(LookupInfo &info, bool bCreate);
- PathType LookupImpl(bool bCreate);
+ void ProcessPath(LookupInfo &info);
+ PathType LookupImpl();
PathType m_type;
- HXML m_hXml;
- const wchar_t *m_szPath;
- const wchar_t *m_szParam;
+ const TiXmlElement *m_hXml;
+ const char *m_szPath;
+ const char *m_szParam;
};
class XPathFmt: public XPath
{
public:
enum { BUFSIZE = 512 };
- XPathFmt(HXML hXml, wchar_t *path, ...): XPath(hXml, m_buf)
- {
- *m_buf = 0;
-
- va_list args;
- va_start(args, path);
- mir_vsnwprintf(m_buf, BUFSIZE, path, args);
- m_buf[BUFSIZE-1] = 0;
- va_end(args);
- }
-
- XPathFmt(HXML hXml, char *path, ...): XPath(hXml, m_buf)
+ XPathFmt(const TiXmlElement *hXml, char *path, ...): XPath(hXml, m_buf)
{
*m_buf = 0;
char buf[BUFSIZE];
@@ -373,12 +317,11 @@ public:
va_start(args, path);
mir_vsnprintf(buf, BUFSIZE, path, args);
buf[BUFSIZE-1] = 0;
- MultiByteToWideChar(CP_ACP, 0, buf, -1, m_buf, BUFSIZE);
va_end(args);
}
private:
- wchar_t m_buf[BUFSIZE];
+ char m_buf[BUFSIZE];
};
#endif
diff --git a/protocols/JabberG/src/jabber_xstatus.cpp b/protocols/JabberG/src/jabber_xstatus.cpp
index fd7472673a..76e9345491 100644
--- a/protocols/JabberG/src/jabber_xstatus.cpp
+++ b/protocols/JabberG/src/jabber_xstatus.cpp
@@ -376,7 +376,7 @@ BOOL CJabberDlgPepSimple::OnWmGetMinMaxInfo(UINT, WPARAM, LPARAM lParam)
///////////////////////////////////////////////////////////////////////////////
// CPepService base class
-CPepService::CPepService(CJabberProto *proto, char *name, wchar_t *node) :
+CPepService::CPepService(CJabberProto *proto, char *name, char *node) :
m_proto(proto),
m_name(name),
m_node(node),
@@ -391,11 +391,11 @@ CPepService::~CPepService()
void CPepService::Publish()
{
- XmlNodeIq iq(L"set", m_proto->SerialNext());
+ XmlNodeIq iq("set", m_proto->SerialNext());
CreateData(
- iq << XCHILDNS(L"pubsub", JABBER_FEAT_PUBSUB)
- << XCHILD(L"publish") << XATTR(L"node", m_node)
- << XCHILD(L"item") << XATTR(L"id", L"current"));
+ iq << XCHILDNS("pubsub", JABBER_FEAT_PUBSUB)
+ << XCHILD("publish") << XATTR("node", m_node)
+ << XCHILD("item") << XATTR("id", "current"));
m_proto->m_ThreadInfo->send(iq);
m_wasPublished = true;
@@ -403,17 +403,15 @@ void CPepService::Publish()
void CPepService::Retract()
{
- wchar_t *tempName = mir_a2u(m_name);
- wcslwr(tempName);
+ char *tempName = NEWSTR_ALLOCA(m_name);
+ strlwr(tempName);
m_proto->m_ThreadInfo->send(
- XmlNodeIq(L"set", m_proto->SerialNext())
- << XCHILDNS(L"pubsub", JABBER_FEAT_PUBSUB)
- << XCHILD(L"publish") << XATTR(L"node", m_node)
- << XCHILD(L"item")
+ XmlNodeIq("set", m_proto->SerialNext())
+ << XCHILDNS("pubsub", JABBER_FEAT_PUBSUB)
+ << XCHILD("publish") << XATTR("node", m_node)
+ << XCHILD("item")
<< XCHILDNS(tempName, m_node));
-
- mir_free(tempName);
}
void CPepService::ResetPublish()
@@ -430,7 +428,7 @@ void CPepService::ForceRepublishOnLogin()
///////////////////////////////////////////////////////////////////////////////
// CPepGuiService base class
-CPepGuiService::CPepGuiService(CJabberProto *proto, char *name, wchar_t *node) :
+CPepGuiService::CPepGuiService(CJabberProto *proto, char *name, char *node) :
CPepService(proto, name, node),
m_bGuiOpen(false),
m_hIcolibItem(nullptr),
@@ -616,7 +614,7 @@ CPepMood::~CPepMood()
mir_free(m_text);
}
-void CPepMood::ProcessItems(const wchar_t *from, HXML itemsNode)
+void CPepMood::ProcessItems(const char *from, const TiXmlElement *itemsNode)
{
MCONTACT hContact = 0, hSelfContact = 0;
if (!m_proto->IsMyOwnJID(from)) {
@@ -625,40 +623,41 @@ void CPepMood::ProcessItems(const wchar_t *from, HXML itemsNode)
}
else hSelfContact = m_proto->HContactFromJID(from);
- if (XmlGetChild(itemsNode, L"retract")) {
+ if (itemsNode->FirstChildElement("retract")) {
if (hSelfContact)
SetMood(hSelfContact, nullptr, nullptr);
SetMood(hContact, nullptr, nullptr);
return;
}
- HXML n, moodNode = XPath(itemsNode, L"item/mood[@xmlns='" JABBER_FEAT_USER_MOOD L"']");
- if (!moodNode) return;
+ auto *moodNode = XmlGetChildByTag(itemsNode->FirstChildElement("item"), "mood", "xmlns", JABBER_FEAT_USER_MOOD);
+ if (!moodNode)
+ return;
- const wchar_t *moodType = nullptr, *moodText = nullptr;
- for (int i = 0; n = XmlGetChild(moodNode, i); i++) {
- if (!mir_wstrcmp(XmlGetName(n), L"text"))
- moodText = XmlGetText(n);
+ const char *moodType = nullptr, *moodText = nullptr;
+ for (auto *n : TiXmlEnum(moodNode)) {
+ if (!mir_strcmp(n->Name(), "text"))
+ moodText = n->GetText();
else
- moodType = XmlGetName(n);
+ moodType = n->Name();
}
- wchar_t *fixedText = JabberStrFixLines(moodText);
+ wchar_t *fixedText = JabberStrFixLines(Utf2T(moodText));
if (hSelfContact)
- SetMood(hSelfContact, moodType, fixedText);
- SetMood(hContact, moodType, fixedText);
+ SetMood(hSelfContact, Utf2T(moodType), fixedText);
+ SetMood(hContact, Utf2T(moodType), fixedText);
mir_free(fixedText);
if (!hContact && m_mode >= 0)
ForceRepublishOnLogin();
}
-void CPepMood::CreateData(HXML n)
+void CPepMood::CreateData(TiXmlElement *n)
{
- HXML moodNode = n << XCHILDNS(L"mood", JABBER_FEAT_USER_MOOD);
- moodNode << XCHILD(_A2T(g_arrMoods[m_mode].szTag));
+ TiXmlElement *moodNode = n << XCHILDNS("mood", JABBER_FEAT_USER_MOOD);
+ moodNode << XCHILD(g_arrMoods[m_mode].szTag);
if (m_text)
- moodNode << XCHILD(L"text", m_text);
+ moodNode << XCHILD("text", T2Utf(m_text));
}
void CPepMood::ResetExtraIcon(MCONTACT hContact)
@@ -859,25 +858,23 @@ inline char *ActivityGetId(int id)
}
// -1 if not found, otherwise activity number
-static int ActivityCheck(const wchar_t *szFirstNode, const wchar_t *szSecondNode)
+static int ActivityCheck(const char *szFirstNode, const char *szSecondNode)
{
if (!szFirstNode) return 0;
- char *s1 = mir_u2a(szFirstNode), *s2 = mir_u2a(szSecondNode);
-
int i = 0, nFirst = -1, nSecond = -1;
while (g_arrActivities[i].szFirst || g_arrActivities[i].szSecond) {
// check first node
- if (g_arrActivities[i].szFirst && !mir_strcmp(s1, g_arrActivities[i].szFirst)) {
+ if (g_arrActivities[i].szFirst && !mir_strcmp(szFirstNode, g_arrActivities[i].szFirst)) {
// first part found
nFirst = i;
- if (!s2) {
+ if (!szSecondNode) {
nSecond = i;
break;
}
i++; // move to next
while (g_arrActivities[i].szSecond) {
- if (!mir_strcmp(g_arrActivities[i].szSecond, s2)) {
+ if (!mir_strcmp(g_arrActivities[i].szSecond, szSecondNode)) {
nSecond = i;
break;
}
@@ -888,9 +885,6 @@ static int ActivityCheck(const wchar_t *szFirstNode, const wchar_t *szSecondNode
i++;
}
- mir_free(s1);
- mir_free(s2);
-
if (nSecond != -1)
return nSecond;
@@ -989,7 +983,7 @@ CPepActivity::~CPepActivity()
mir_free(m_text);
}
-void CPepActivity::ProcessItems(const wchar_t *from, HXML itemsNode)
+void CPepActivity::ProcessItems(const char *from, const TiXmlElement *itemsNode)
{
MCONTACT hContact = 0, hSelfContact = 0;
if (!m_proto->IsMyOwnJID(from)) {
@@ -998,32 +992,31 @@ void CPepActivity::ProcessItems(const wchar_t *from, HXML itemsNode)
}
else hSelfContact = m_proto->HContactFromJID(from);
- if (XmlGetChild(itemsNode, "retract")) {
+ if (itemsNode->FirstChildElement("retract")) {
if (hSelfContact)
SetActivity(hSelfContact, nullptr, nullptr, nullptr);
SetActivity(hContact, nullptr, nullptr, nullptr);
return;
}
- HXML actNode = XPath(itemsNode, L"item/activity[@xmlns='" JABBER_FEAT_USER_ACTIVITY L"']");
+ auto *actNode = XmlGetChildByTag(itemsNode->FirstChildElement("item"), "activity", "xmlns", JABBER_FEAT_USER_ACTIVITY);
if (!actNode)
return;
- const wchar_t *szText = XPathT(actNode, "text");
- const wchar_t *szFirstNode = nullptr, *szSecondNode = nullptr;
+ const char *szText = XPath(actNode, "text");
+ const char *szFirstNode = nullptr, *szSecondNode = nullptr;
- HXML n;
- for (int i = 0; n = XmlGetChild(actNode, i); i++) {
- if (mir_wstrcmp(XmlGetName(n), L"text")) {
- szFirstNode = XmlGetName(n);
- HXML secondNode = XmlGetChild(n, 0);
- if (szFirstNode && secondNode && XmlGetName(secondNode))
- szSecondNode = XmlGetName(secondNode);
+ for (auto *n : TiXmlFilter(actNode, "text")) {
+ if (mir_strcmp(n->Name(), "text")) {
+ szFirstNode = n->Name();
+ auto *secondNode = n->FirstChildElement();
+ if (szFirstNode && secondNode && secondNode->Name())
+ szSecondNode = secondNode->Name();
break;
}
}
- wchar_t *fixedText = JabberStrFixLines(szText);
+ ptrW fixedText(JabberStrFixLines(Utf2T(szText)));
if (hSelfContact)
SetActivity(hSelfContact, szFirstNode, szSecondNode, fixedText);
SetActivity(hContact, szFirstNode, szSecondNode, fixedText);
@@ -1033,19 +1026,19 @@ void CPepActivity::ProcessItems(const wchar_t *from, HXML itemsNode)
ForceRepublishOnLogin();
}
-void CPepActivity::CreateData(HXML n)
+void CPepActivity::CreateData(TiXmlElement *n)
{
char *szFirstNode = ActivityGetFirst(m_mode);
char *szSecondNode = ActivityGetSecond(m_mode);
- HXML activityNode = n << XCHILDNS(L"activity", JABBER_FEAT_USER_ACTIVITY);
- HXML firstNode = activityNode << XCHILD(_A2T(szFirstNode));
+ TiXmlElement *activityNode = n << XCHILDNS("activity", JABBER_FEAT_USER_ACTIVITY);
+ TiXmlElement *firstNode = activityNode << XCHILD(szFirstNode);
if (firstNode && szSecondNode)
- firstNode << XCHILD(_A2T(szSecondNode));
+ firstNode << XCHILD(szSecondNode);
if (m_text)
- activityNode << XCHILD(L"text", m_text);
+ activityNode << XCHILD("text", T2Utf(m_text));
}
void CPepActivity::ResetExtraIcon(MCONTACT hContact)
@@ -1060,7 +1053,7 @@ void CPepActivity::SetExtraIcon(MCONTACT hContact, char *szActivity)
ExtraIcon_SetIcon(hExtraActivity, hContact, szActivity == nullptr ? nullptr : g_ActivityIcons.GetIcolibHandle(szActivity));
}
-void CPepActivity::SetActivity(MCONTACT hContact, const wchar_t *szFirst, const wchar_t *szSecond, const wchar_t *szText)
+void CPepActivity::SetActivity(MCONTACT hContact, const char *szFirst, const char *szSecond, const wchar_t *szText)
{
int activity = -1;
if (szFirst || szSecond) {
@@ -1169,18 +1162,18 @@ BOOL CJabberProto::SendPepTune(wchar_t* szArtist, wchar_t* szLength, wchar_t* sz
if (!m_bJabberOnline || !m_bPepSupported)
return FALSE;
- XmlNodeIq iq(L"set", SerialNext());
- HXML tuneNode = iq << XCHILDNS(L"pubsub", JABBER_FEAT_PUBSUB)
- << XCHILD(L"publish") << XATTR(L"node", JABBER_FEAT_USER_TUNE)
- << XCHILD(L"item") << XCHILDNS(L"tune", JABBER_FEAT_USER_TUNE);
+ XmlNodeIq iq("set", SerialNext());
+ TiXmlElement *tuneNode = iq << XCHILDNS("pubsub", JABBER_FEAT_PUBSUB)
+ << XCHILD("publish") << XATTR("node", JABBER_FEAT_USER_TUNE)
+ << XCHILD("item") << XCHILDNS("tune", JABBER_FEAT_USER_TUNE);
if (szArtist || szLength || szSource || szTitle || szUri) {
- if (szArtist) tuneNode << XCHILD(L"artist", szArtist);
- if (szLength) tuneNode << XCHILD(L"length", szLength);
- if (szSource) tuneNode << XCHILD(L"source", szSource);
- if (szTitle) tuneNode << XCHILD(L"title", szTitle);
- if (szTrack) tuneNode << XCHILD(L"track", szTrack);
- if (szUri) tuneNode << XCHILD(L"uri", szUri);
+ if (szArtist) tuneNode << XCHILD("artist", T2Utf(szArtist));
+ if (szLength) tuneNode << XCHILD("length", T2Utf(szLength));
+ if (szSource) tuneNode << XCHILD("source", T2Utf(szSource));
+ if (szTitle) tuneNode << XCHILD("title", T2Utf(szTitle));
+ if (szTrack) tuneNode << XCHILD("track", T2Utf(szTrack));
+ if (szUri) tuneNode << XCHILD("uri", T2Utf(szUri));
}
m_ThreadInfo->send(iq);
diff --git a/protocols/JabberG/src/jabber_xstatus.h b/protocols/JabberG/src/jabber_xstatus.h
index 784e3cc33e..012620cb97 100644
--- a/protocols/JabberG/src/jabber_xstatus.h
+++ b/protocols/JabberG/src/jabber_xstatus.h
@@ -32,12 +32,12 @@ struct CJabberProto;
class CPepService
{
public:
- CPepService(CJabberProto *proto, char *name, wchar_t *node);
+ CPepService(CJabberProto *proto, char *name, char *node);
virtual ~CPepService();
HGENMENU GetMenu() { return m_hMenuItem; }
- wchar_t *GetNode() { return m_node; }
- virtual void ProcessItems(const wchar_t *from, HXML items) = 0;
+ char* GetNode() { return m_node; }
+ virtual void ProcessItems(const char *from, const TiXmlElement *items) = 0;
void Publish();
void Retract();
@@ -53,10 +53,10 @@ protected:
CJabberProto *m_proto;
bool m_wasPublished;
char *m_name;
- wchar_t *m_node;
+ char *m_node;
HGENMENU m_hMenuItem;
- virtual void CreateData(HXML) = 0;
+ virtual void CreateData(TiXmlElement*) = 0;
void ForceRepublishOnLogin();
};
@@ -65,10 +65,10 @@ class CPepServiceList: public OBJLIST<CPepService>
public:
CPepServiceList(): OBJLIST<CPepService>(1) {}
- void ProcessEvent(const wchar_t *from, HXML eventNode)
+ void ProcessEvent(const char *from, const TiXmlElement *eventNode)
{
for (auto &it : *this) {
- HXML itemsNode = XmlGetChildByTag(eventNode, L"items", L"node", it->GetNode());
+ auto *itemsNode = XmlGetChildByTag(eventNode, "items", "node", it->GetNode());
if (itemsNode)
it->ProcessItems(from, itemsNode);
}
@@ -110,10 +110,10 @@ public:
it->ResetPublish();
}
- CPepService *Find(wchar_t *node)
+ CPepService* Find(const char *node)
{
for (auto &it : *this)
- if (!mir_wstrcmp(it->GetNode(), node))
+ if (!mir_strcmp(it->GetNode(), node))
return it;
return nullptr;
}
@@ -123,7 +123,7 @@ class CPepGuiService: public CPepService
{
typedef CPepService CSuper;
public:
- CPepGuiService(CJabberProto *proto, char *name, wchar_t *node);
+ CPepGuiService(CJabberProto *proto, char *name, char *node);
~CPepGuiService();
void InitGui();
void RebuildMenu();
@@ -149,7 +149,7 @@ class CPepMood: public CPepGuiService
public:
CPepMood(CJabberProto *proto);
~CPepMood();
- void ProcessItems(const wchar_t *from, HXML items);
+ void ProcessItems(const char *from, const TiXmlElement *items);
void ResetExtraIcon(MCONTACT hContact);
public:
@@ -160,8 +160,8 @@ protected:
void ShowSetDialog(BYTE bQuiet) override;
void UpdateMenuView(void) override;
- void CreateData(HXML);
void SetExtraIcon(MCONTACT hContact, char *szMood);
+ void CreateData(TiXmlElement*);
void SetMood(MCONTACT hContact, const wchar_t *szMood, const wchar_t *szText);
};
@@ -172,7 +172,7 @@ class CPepActivity: public CPepGuiService
public:
CPepActivity(CJabberProto *proto);
~CPepActivity();
- void ProcessItems(const wchar_t *from, HXML items);
+ void ProcessItems(const char *from, const TiXmlElement *items);
void ResetExtraIcon(MCONTACT hContact);
protected:
@@ -182,10 +182,10 @@ protected:
void ShowSetDialog(BYTE bQuiet) override;
void UpdateMenuView(void) override;
- void CreateData(HXML);
+ void CreateData(TiXmlElement*);
void SetExtraIcon(MCONTACT hContact, char *szActivity);
- void SetActivity(MCONTACT hContact, const wchar_t *szFirst, const wchar_t *szSecond, const wchar_t *szText);
+ void SetActivity(MCONTACT hContact, const char *szFirst, const char *szSecond, const wchar_t *szText);
};
#endif // _JABBER_XSTATUS_H_
diff --git a/protocols/JabberG/src/obsoleted/jabber_form2.cpp.obsoleted b/protocols/JabberG/src/obsoleted/jabber_form2.cpp.obsoleted
deleted file mode 100644
index e03c38bced..0000000000
--- a/protocols/JabberG/src/obsoleted/jabber_form2.cpp.obsoleted
+++ /dev/null
@@ -1,1200 +0,0 @@
-/*
-
-Jabber Protocol Plugin for Miranda NG
-
-Copyright (c) 2002-04 Santithorn Bunchua
-Copyright (c) 2005-12 George Hazan
-Copyright (c) 2007-09 Maxim Mluhov
-Copyright (c) 2007-09 Victor Pavlychko
-Copyright (C) 2012-19 Miranda NG team
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or ( at your option ) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-
-#include "stdafx.h"
-#include "jabber_caps.h"
-
-#include "jabber_form2.h"
-
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// FORM_TYPE Registry
-namespace NSJabberRegistry
-{
- // http://jabber.org/network/serverinfo
- static TJabberDataFormRegisry_Field form_type_serverinfo[] =
- {
- { _T("abuse-addresses"), JDFT_LIST_MULTI, LPGENT("One or more addresses for communication related to abusive traffic") },
- { _T("feedback-addresses"), JDFT_LIST_MULTI, LPGENT("One or more addresses for customer feedback") },
- { _T("sales-addresses"), JDFT_LIST_MULTI, LPGENT("One or more addresses for communication related to sales and marketing") },
- { _T("security-addresses"), JDFT_LIST_MULTI, LPGENT("One or more addresses for communication related to security concerns") },
- { _T("support-addresses"), JDFT_LIST_MULTI, LPGENT("One or more addresses for customer support") },
- };
-
- // http://jabber.org/protocol/admin
- static TJabberDataFormRegisry_Field form_type_admin[] =
- {
- { _T("accountjid"), JDFT_JID_SINGLE, LPGENT("The Jabber ID of a single entity to which an operation applies") },
- { _T("accountjids"), JDFT_JID_MULTI, LPGENT("The Jabber ID of one or more entities to which an operation applies") },
- { _T("activeuserjids"), JDFT_JID_MULTI, LPGENT("The Jabber IDs associated with active sessions") },
- { _T("activeusersnum"), JDFT_TEXT_SINGLE, LPGENT("The number of online entities that are active") },
- { _T("adminjids"), JDFT_JID_MULTI, LPGENT("A list of entities with administrative privileges") },
- { _T("announcement"), JDFT_TEXT_MULTI, LPGENT("The text of an announcement to be sent to active users or all users") },
- { _T("blacklistjids"), JDFT_JID_MULTI, LPGENT("A list of entities with whom communication is blocked") },
- { _T("delay"), JDFT_LIST_MULTI, LPGENT("The number of seconds to delay before applying a change") },
- { _T("disableduserjids"), JDFT_JID_MULTI, LPGENT("The Jabber IDs that have been disabled") },
- { _T("disabledusersnum"), JDFT_TEXT_SINGLE, LPGENT("The number of disabled entities") },
- { _T("email"), JDFT_TEXT_SINGLE, LPGENT("The email address for a user") },
- { _T("given_name"), JDFT_TEXT_SINGLE, LPGENT("The given (first) name of a user") },
- { _T("idleusersnum"), JDFT_TEXT_SINGLE, LPGENT("The number of online entities that are idle") },
- { _T("ipaddresses"), JDFT_LIST_MULTI, LPGENT("The IP addresses of an account's online sessions") },
- { _T("lastlogin"), JDFT_TEXT_SINGLE, LPGENT("The last login time (per XEP-0082) of a user") },
- { _T("loginsperminute"), JDFT_TEXT_SINGLE, LPGENT("The number of logins per minute for an account") },
- { _T("max_items"), JDFT_LIST_SINGLE, LPGENT("The maximum number of items associated with a search or list") },
- { _T("motd"), JDFT_TEXT_MULTI, LPGENT("The text of a message of the day") },
- { _T("onlineresources"), JDFT_TEXT_SINGLE, LPGENT("The names of an account's online sessions") },
- { _T("onlineuserjids"), JDFT_JID_MULTI, LPGENT("The Jabber IDs associated with online users") },
- { _T("onlineusersnum"), JDFT_TEXT_SINGLE, LPGENT("The number of online entities") },
- { _T("password"), JDFT_TEXT_PRIVATE, LPGENT("The password for an account") },
- { _T("password-verify"), JDFT_TEXT_PRIVATE, LPGENT("Password verification") },
- { _T("registereduserjids"), JDFT_JID_MULTI, LPGENT("A list of registered entities") },
- { _T("registeredusersnum"), JDFT_TEXT_SINGLE, LPGENT("The number of registered entities") },
- { _T("rostersize"), JDFT_TEXT_SINGLE, LPGENT("Number of roster items for an account") },
- { _T("stanzaspersecond"), JDFT_TEXT_SINGLE, LPGENT("The number of stanzas being sent per second by an account") },
- { _T("surname"), JDFT_TEXT_SINGLE, LPGENT("The family (last) name of a user") },
- { _T("welcome"), JDFT_TEXT_MULTI, LPGENT("The text of a welcome message") },
- { _T("whitelistjids"), JDFT_JID_MULTI, LPGENT("A list of entities with whom communication is allowed") },
- };
-
- // http://jabber.org/protocol/muc#register
- static TJabberDataFormRegisry_Field form_type_muc_register[] =
- {
- { _T("muc#register_first"), JDFT_TEXT_SINGLE, LPGENT("First Name") },
- { _T("muc#register_last"), JDFT_TEXT_SINGLE, LPGENT("Last Name") },
- { _T("muc#register_roomnick"), JDFT_TEXT_SINGLE, LPGENT("Desired Nickname") },
- { _T("muc#register_url"), JDFT_TEXT_SINGLE, LPGENT("Your URL") },
- { _T("muc#register_email"), JDFT_TEXT_SINGLE, LPGENT("Email Address") },
- { _T("muc#register_faqentry"), JDFT_TEXT_MULTI, LPGENT("FAQ Entry") },
- };
-
- // http://jabber.org/protocol/muc#roomconfig
- static TJabberDataFormRegisry_Field form_type_muc_roomconfig[] =
- {
- { _T("muc#roomconfig_allowinvites"), JDFT_BOOLEAN, LPGENT("Whether to allow occupants to invite others") },
- { _T("muc#roomconfig_changesubject"), JDFT_BOOLEAN, LPGENT("Whether to allow occupants to change subject") },
- { _T("muc#roomconfig_enablelogging"), JDFT_BOOLEAN, LPGENT("Whether to enable logging of room conversations") },
- { _T("muc#roomconfig_lang"), JDFT_TEXT_SINGLE, LPGENT("Natural language for room discussions") },
- { _T("muc#roomconfig_maxusers"), JDFT_LIST_SINGLE, LPGENT("Maximum number of room occupants") },
- { _T("muc#roomconfig_membersonly"), JDFT_BOOLEAN, LPGENT("Whether to make room members-only") },
- { _T("muc#roomconfig_moderatedroom"), JDFT_BOOLEAN, LPGENT("Whether to make room moderated") },
- { _T("muc#roomconfig_passwordprotectedroom"), JDFT_BOOLEAN, LPGENT("Whether a password is required to enter") },
- { _T("muc#roomconfig_persistentroom"), JDFT_BOOLEAN, LPGENT("Whether to make room persistent") },
- { _T("muc#roomconfig_presencebroadcast"), JDFT_LIST_MULTI, LPGENT("Roles for which presence is broadcast") },
- { _T("muc#roomconfig_publicroom"), JDFT_BOOLEAN, LPGENT("Whether to allow public searching for room") },
- { _T("muc#roomconfig_roomadmins"), JDFT_JID_MULTI, LPGENT("Full list of room admins") },
- { _T("muc#roomconfig_roomdesc"), JDFT_TEXT_SINGLE, LPGENT("Short description of room") },
- { _T("muc#roomconfig_roomname"), JDFT_TEXT_SINGLE, LPGENT("Natural-language room name") },
- { _T("muc#roomconfig_roomowners"), JDFT_JID_MULTI, LPGENT("Full list of room owners") },
- { _T("muc#roomconfig_roomsecret"), JDFT_TEXT_PRIVATE, LPGENT("The room password") },
- { _T("muc#roomconfig_whois"), JDFT_LIST_SINGLE, LPGENT("Affiliations that may discover real JIDs of occupants") },
- };
-
- // http://jabber.org/protocol/pubsub#publish-options
- static TJabberDataFormRegisry_Field form_type_publish_options[] =
- {
- { _T("pubsub#access_model"), JDFT_LIST_SINGLE, LPGENT("Precondition: node configuration with the specified access model") },
- };
-
- // http://jabber.org/protocol/pubsub#subscribe_authorization
- static TJabberDataFormRegisry_Field form_type_subscribe_auth[] =
- {
- { _T("pubsub#allow"), JDFT_BOOLEAN, LPGENT("Whether to allow the subscription") },
- { _T("pubsub#subid"), JDFT_TEXT_SINGLE, LPGENT("The SubID of the subscription") },
- { _T("pubsub#node"), JDFT_TEXT_SINGLE, LPGENT("The NodeID of the relevant node") },
- { _T("pubsub#subscriber_jid"), JDFT_JID_SINGLE, LPGENT("The address (JID) of the subscriber") },
- };
-
- // http://jabber.org/protocol/pubsub#subscribe_options
- static TJabberDataFormRegisry_Field form_type_subscribe_options[] =
- {
- { _T("pubsub#deliver"), JDFT_BOOLEAN, LPGENT("Whether an entity wants to receive or disable notifications") },
- { _T("pubsub#digest"), JDFT_BOOLEAN, LPGENT("Whether an entity wants to receive digests (aggregations) of notifications or all notifications individually") },
- { _T("pubsub#digest_frequency"), JDFT_TEXT_SINGLE, LPGENT("The minimum number of milliseconds between sending any two notification digests") },
- { _T("pubsub#expire"), JDFT_TEXT_SINGLE, LPGENT("The date and time at which a leased subscription will end or has ended") },
- { _T("pubsub#include_body"), JDFT_BOOLEAN, LPGENT("Whether an entity wants to receive an XMPP message body in addition to the payload format") },
- { _T("pubsub#show-values"), JDFT_LIST_MULTI, LPGENT("The presence states for which an entity wants to receive notifications") },
- { _T("pubsub#subscription_type"), JDFT_LIST_SINGLE, _T("") },
- { _T("pubsub#subscription_depth"), JDFT_LIST_SINGLE, _T("") },
- };
-
- // http://jabber.org/protocol/pubsub#node_config
- static TJabberDataFormRegisry_Field form_type_node_config[] =
- {
- { _T("pubsub#access_model"), JDFT_LIST_SINGLE, LPGENT("Who may subscribe and retrieve items") },
- { _T("pubsub#body_xslt"), JDFT_TEXT_SINGLE, LPGENT("The URL of an XSL transformation which can be applied to payloads in order to generate an appropriate message body element.") },
- { _T("pubsub#collection"), JDFT_TEXT_SINGLE, LPGENT("The collection with which a node is affiliated") },
- { _T("pubsub#dataform_xslt"), JDFT_TEXT_SINGLE, LPGENT("The URL of an XSL transformation which can be applied to the payload format in order to generate a valid Data Forms result that the client could display using a generic Data Forms rendering engine") },
- { _T("pubsub#deliver_payloads"), JDFT_BOOLEAN, LPGENT("Whether to deliver payloads with event notifications") },
- { _T("pubsub#itemreply"), JDFT_LIST_SINGLE, LPGENT("Whether owners or publisher should receive replies to items") },
- { _T("pubsub#children_association_policy"), JDFT_LIST_SINGLE, LPGENT("Who may associate leaf nodes with a collection") },
- { _T("pubsub#children_association_whitelist"), JDFT_JID_MULTI, LPGENT("The list of JIDs that may associated leaf nodes with a collection") },
- { _T("pubsub#children"), JDFT_TEXT_MULTI, LPGENT("The child nodes (leaf or collection) associated with a collection") },
- { _T("pubsub#children_max"), JDFT_TEXT_SINGLE, LPGENT("The maximum number of child nodes that can be associated with a collection") },
- { _T("pubsub#max_items"), JDFT_TEXT_SINGLE, LPGENT("The maximum number of items to persist") },
- { _T("pubsub#max_payload_size"), JDFT_TEXT_SINGLE, LPGENT("The maximum payload size in bytes") },
- { _T("pubsub#node_type"), JDFT_LIST_SINGLE, LPGENT("Whether the node is a leaf (default) or a collection") },
- { _T("pubsub#notify_config"), JDFT_BOOLEAN, LPGENT("Whether to notify subscribers when the node configuration changes") },
- { _T("pubsub#notify_delete"), JDFT_BOOLEAN, LPGENT("Whether to notify subscribers when the node is deleted") },
- { _T("pubsub#notify_retract"), JDFT_BOOLEAN, LPGENT("Whether to notify subscribers when items are removed from the node") },
- { _T("pubsub#persist_items"), JDFT_BOOLEAN, LPGENT("Whether to persist items to storage") },
- { _T("pubsub#presence_based_delivery"), JDFT_BOOLEAN, LPGENT("Whether to deliver notifications to available users only") },
- { _T("pubsub#publish_model"), JDFT_LIST_SINGLE, LPGENT("The publisher model") },
- { _T("pubsub#replyroom"), JDFT_JID_MULTI, LPGENT("The specific multi-user chat rooms to specify for replyroom") },
- { _T("pubsub#replyto"), JDFT_JID_MULTI, LPGENT("The specific JID(s) to specify for replyto") },
- { _T("pubsub#roster_groups_allowed"), JDFT_LIST_MULTI, LPGENT("The roster group(s) allowed to subscribe and retrieve items") },
- { _T("pubsub#send_item_subscribe"), JDFT_BOOLEAN, LPGENT("Whether to send items to new subscribers") },
- { _T("pubsub#subscribe"), JDFT_BOOLEAN, LPGENT("Whether to allow subscriptions") },
- { _T("pubsub#title"), JDFT_TEXT_SINGLE, LPGENT("A friendly name for the node") },
- { _T("pubsub#type"), JDFT_TEXT_SINGLE, LPGENT("The type of node data, usually specified by the namespace of the payload (if any); MAY be list-single rather than text-single") },
- };
-
- // http://jabber.org/protocol/pubsub#meta-data
- static TJabberDataFormRegisry_Field form_type_metadata[] =
- {
- { _T("pubsub#contact"), JDFT_JID_MULTI, LPGENT("The JIDs of those to contact with questions") },
- { _T("pubsub#creation_date"), JDFT_TEXT_SINGLE, LPGENT("The date and time when the node was created") },
- { _T("pubsub#creator"), JDFT_JID_SINGLE, LPGENT("The JID of the node creator") },
- { _T("pubsub#description"), JDFT_TEXT_SINGLE, LPGENT("A description of the node") },
- { _T("pubsub#language"), JDFT_TEXT_SINGLE, LPGENT("The default language of the node") },
- { _T("pubsub#num_subscribers"), JDFT_TEXT_SINGLE, LPGENT("The number of subscribers to the node") },
- { _T("pubsub#owner"), JDFT_JID_MULTI, LPGENT("The JIDs of those with an affiliation of owner") },
- { _T("pubsub#publisher"), JDFT_JID_MULTI, LPGENT("The JIDs of those with an affiliation of publisher") },
- { _T("pubsub#title"), JDFT_TEXT_SINGLE, LPGENT("The name of the node") },
- { _T("pubsub#type"), JDFT_TEXT_SINGLE, LPGENT("Payload type") },
- };
-
- // http://jabber.org/protocol/rc
- static TJabberDataFormRegisry_Field form_type_rc[] =
- {
- { _T("auto-auth"), JDFT_BOOLEAN, LPGENT("Whether to automatically authorize subscription requests") },
- { _T("auto-files"), JDFT_BOOLEAN, LPGENT("Whether to automatically accept file transfers") },
- { _T("auto-msg"), JDFT_BOOLEAN, LPGENT("Whether to automatically open new messages") },
- { _T("auto-offline"), JDFT_BOOLEAN, LPGENT("Whether to automatically go offline when idle") },
- { _T("sounds"), JDFT_BOOLEAN, LPGENT("Whether to play sounds") },
- { _T("files"), JDFT_LIST_MULTI, LPGENT("A list of pending file transfers") },
- { _T("groupchats"), JDFT_LIST_MULTI, LPGENT("A list of joined group chat rooms") },
- { _T("status"), JDFT_LIST_SINGLE, LPGENT("A presence or availability status") },
- { _T("status-message"), JDFT_TEXT_MULTI, LPGENT("The status message text") },
- { _T("status-priority"), JDFT_TEXT_SINGLE, LPGENT("The new priority for the client") },
- };
-
- // jabber:iq:register
- static TJabberDataFormRegisry_Field form_type_register[] =
- {
- { _T("username"), JDFT_TEXT_SINGLE, LPGENT("Account name associated with the user") },
- { _T("nick"), JDFT_TEXT_SINGLE, LPGENT("Familiar name of the user") },
- { _T("password"), JDFT_TEXT_PRIVATE, LPGENT("Password or secret for the user") },
- { _T("name"), JDFT_TEXT_SINGLE, LPGENT("Full name of the user") },
- { _T("first"), JDFT_TEXT_SINGLE, LPGENT("First name or given name of the user") },
- { _T("last"), JDFT_TEXT_SINGLE, LPGENT("Last name, surname, or family name of the user") },
- { _T("email"), JDFT_TEXT_SINGLE, LPGENT("Email address of the user") },
- { _T("address"), JDFT_TEXT_SINGLE, LPGENT("Street portion of a physical or mailing address") },
- { _T("city"), JDFT_TEXT_SINGLE, LPGENT("Locality portion of a physical or mailing address") },
- { _T("state"), JDFT_TEXT_SINGLE, LPGENT("Region portion of a physical or mailing address") },
- { _T("zip"), JDFT_TEXT_SINGLE, LPGENT("Postal code portion of a physical or mailing address") },
- };
-
- // jabber:iq:search
- static TJabberDataFormRegisry_Field form_type_search[] =
- {
- { _T("first"), JDFT_TEXT_SINGLE, LPGENT("First Name") },
- { _T("last"), JDFT_TEXT_SINGLE, LPGENT("Family Name") },
- { _T("nick"), JDFT_TEXT_SINGLE, LPGENT("Nickname") },
- { _T("email"), JDFT_TEXT_SINGLE, LPGENT("Email Address") },
- };
-
- // urn:xmpp:ssn
- static TJabberDataFormRegisry_Field form_type_ssn[] =
- {
- { _T("accept"), JDFT_BOOLEAN, LPGENT("Whether to accept the invitation") },
- { _T("continue"), JDFT_TEXT_SINGLE, LPGENT("Another resource with which to continue the session") },
- { _T("disclosure"), JDFT_LIST_SINGLE, LPGENT("Disclosure of content, decryption keys or identities") },
- { _T("http://jabber.org/protocol/chatstates"), JDFT_LIST_SINGLE, LPGENT("Whether may send Chat State Notifications per XEP-0085") },
- { _T("http://jabber.org/protocol/xhtml-im"), JDFT_LIST_SINGLE, LPGENT("Whether allowed to use XHTML-IM formatting per XEP-0071") },
- { _T("language"), JDFT_LIST_SINGLE, LPGENT("Primary written language of the chat (each value appears in order of preference and conforms to RFC 4646 and the IANA registry)") },
- { _T("logging"), JDFT_LIST_SINGLE, LPGENT("Whether allowed to log messages (i.e., whether Off-The-Record mode is required)") },
- { _T("renegotiate"), JDFT_BOOLEAN, LPGENT("Whether to renegotiate the session") },
- { _T("security"), JDFT_LIST_SINGLE, LPGENT("Minimum security level") },
- { _T("terminate"), JDFT_BOOLEAN, LPGENT("Whether to terminate the session") },
- { _T("urn:xmpp:receipts"), JDFT_BOOLEAN, LPGENT("Whether to enable Message Receipts per XEP-0184") },
- };
-
- TJabberDataFormRegisry_Form form_types[] =
- {
- /*0157*/ { _T("http://jabber.org/network/serverinfo"), form_type_serverinfo, SIZEOF(form_type_serverinfo) },
- /*0133*/ { _T("http://jabber.org/protocol/admin"), form_type_admin, SIZEOF(form_type_admin) },
- /*0045*/ { _T("http://jabber.org/protocol/muc#register"), form_type_muc_register, SIZEOF(form_type_muc_register) },
- /*0045*/ { _T("http://jabber.org/protocol/muc#roomconfig"), form_type_muc_roomconfig, SIZEOF(form_type_muc_roomconfig) },
- /*0060*/ { _T("http://jabber.org/protocol/pubsub#publish-options"), form_type_publish_options, SIZEOF(form_type_publish_options) },
- /*0060*/ { _T("http://jabber.org/protocol/pubsub#subscribe_authorization"), form_type_subscribe_auth, SIZEOF(form_type_subscribe_auth) },
- /*0060*/ { _T("http://jabber.org/protocol/pubsub#subscribe_options"), form_type_subscribe_options, SIZEOF(form_type_subscribe_options) },
- /*0060*/ { _T("http://jabber.org/protocol/pubsub#node_config"), form_type_node_config, SIZEOF(form_type_node_config) },
- /*0060*/ { _T("http://jabber.org/protocol/pubsub#meta-data"), form_type_metadata, SIZEOF(form_type_metadata) },
- /*0146*/ { _T("http://jabber.org/protocol/rc"), form_type_rc, SIZEOF(form_type_rc) },
- /*0077*/ { _T("jabber:iq:register"), form_type_register, SIZEOF(form_type_register) },
- /*0055*/ { _T("jabber:iq:search"), form_type_search, SIZEOF(form_type_search) },
- /*0155*/ { _T("urn:xmpp:ssn"), form_type_ssn, SIZEOF(form_type_ssn) },
- };
-};
-
-CJabberDataField::CJabberDataField(CJabberDataForm *form, XmlNode *node):
- m_node(node), m_options(5), m_values(1), m_descriptions(1)
-{
- m_typeName = JabberXmlGetAttrValue(m_node, "type");
- m_var = JabberXmlGetAttrValue(m_node, "var");
- m_label = JabberXmlGetAttrValue(m_node, "label");
- m_required = JabberXmlGetChild(m_node, "required") ? true : false;
-
- if (m_typeName)
- {
- if (!lstrcmp(m_typeName, _T("text-private")))
- m_type = JDFT_TEXT_PRIVATE;
- else if (!lstrcmp(m_typeName, _T("text-multi")) || !lstrcmp(m_typeName, _T("jid-multi")))
- m_type = JDFT_TEXT_MULTI;
- else if (!lstrcmp(m_typeName, _T("boolean")))
- m_type = JDFT_BOOLEAN;
- else if (!lstrcmp(m_typeName, _T("list-single")))
- m_type = JDFT_LIST_SINGLE;
- else if (!lstrcmp(m_typeName, _T("list-multi")))
- m_type = JDFT_LIST_MULTI;
- else if (!lstrcmp(m_typeName, _T("fixed")))
- m_type = JDFT_FIXED;
- else if (!lstrcmp(m_typeName, _T("hidden")))
- m_type = JDFT_HIDDEN;
- else
- m_type = JDFT_TEXT_SINGLE;
- } else
- {
- m_typeName = _T("text-single");
- m_type = JDFT_TEXT_SINGLE;
- }
-
- for (int i = 0; i < m_node->numChild; ++i)
- {
- if (!lstrcmpA(m_node->child[i]->name, "value"))
- {
- m_values.insert(m_node->child[i]->text, m_values.getCount());
- } else
- if (!lstrcmpA(m_node->child[i]->name, "option"))
- {
- TOption *opt = new TOption;
- opt->label = JabberXmlGetAttrValue(m_node->child[i], "label");
- opt->value = NULL;
- if (XmlNode *p = JabberXmlGetChild(m_node->child[i], "value"))
- opt->value = p->text;
- m_options.insert(opt, m_options.getCount());
- } else
- if (!lstrcmpA(m_node->child[i]->name, "desc"))
- {
- m_descriptions.insert(m_node->child[i]->text, m_descriptions.getCount());
- }
- }
-}
-
-CJabberDataField::~CJabberDataField()
-{
- m_values.destroy();
- m_descriptions.destroy();
-}
-
-CJabberDataFieldSet::CJabberDataFieldSet():
- m_fields(5)
-{
-}
-
-CJabberDataField *CJabberDataFieldSet::GetField(TCHAR *var)
-{
- for (int i = 0; i < m_fields.getCount(); ++i)
- if (!lstrcmp(m_fields[i].GetVar(), var))
- return &(m_fields[i]);
- return NULL;
-}
-
-CJabberDataForm::CJabberDataForm(XmlNode *node):
- m_node(node),
- m_form_type(0),
- m_form_type_info(0),
- m_title(0),
- m_instructions(1),
- m_items(1)
-{
- m_typename = JabberXmlGetAttrValue(m_node, "type");
-
- for (int i = 0; i < m_node->numChild; ++i)
- {
- XmlNode *child = m_node->child[i];
- if (!lstrcmpA(child->name, "field"))
- {
- CJabberDataField *field = new CJabberDataField(this, child);
- m_fields.AddField(field);
-
- if ((field->GetType() == JDFT_HIDDEN) && !lstrcmp(field->GetVar(), _T("FORM_TYPE")))
- {
- using NSJabberRegistry::form_types;
-
- m_form_type = field->GetValue();
- for (int j = 0; j < SIZEOF(form_types); ++j)
- if (!lstrcmp(m_form_type, form_types[j].form_type))
- {
- m_form_type_info = form_types + j;
- break;
- }
- }
- } else
- if (!lstrcmpA(child->name, "title"))
- {
- m_title = child->text;
- } else
- if (!lstrcmpA(child->name, "instructions"))
- {
- m_instructions.insert(child->text, m_instructions.getCount());
- } else
- if (!lstrcmpA(child->name, "reported"))
- {
- if (m_reported.GetCount())
- continue; // ignore second <reported/> -> error!!!!!!!!!!!
-
- for (int j = 0; j < child->numChild; ++j)
- {
- XmlNode *child2 = child->child[i];
- if (!lstrcmpA(child2->name, "field"))
- {
- CJabberDataField *field = new CJabberDataField(this, child2);
- m_reported.AddField(field);
- }
- }
- } else
- if (!lstrcmpA(child->name, "item"))
- {
- CJabberDataFieldSet *item = new CJabberDataFieldSet;
- m_items.insert(item);
-
- for (int j = 0; j < child->numChild; ++j)
- {
- XmlNode *child2 = child->child[i];
- if (!lstrcmpA(child2->name, "field"))
- {
- CJabberDataField *field = new CJabberDataField(this, child2);
- item->AddField(field);
- }
- }
- }
- }
-}
-
-CJabberDataForm::~CJabberDataForm()
-{
-}
-
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// UI classes
-
-#define FORM_CONTROL_MINWIDTH 100
-#define FORM_CONTROL_HEIGHT 20
-
-class CFormCtrlBase;
-
-class CJabberDlgDataPage
-{
-public:
- CJabberDlgDataPage(HWND hwndParent);
- ~CJabberDlgDataPage();
-
- void AddField(CJabberDataField *field);
- XmlNode *FetchData();
-
- HWND GetHwnd() { return m_hwnd; }
- void Layout();
-
- // internal usage
- int AddControl(CFormCtrlBase *ctrl)
- {
- m_controls.insert(ctrl, m_controls.getCount());
- return m_controls.getCount();
- }
-
-private:
- HWND m_hwnd;
- OBJLIST<CFormCtrlBase> m_controls;
- int m_scrollPos, m_height, m_dataHeight;
-
- BOOL DlgProc(UINT msg, WPARAM wParam, LPARAM lParam);
- static BOOL CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
-};
-
-class CFormCtrlBase
-{
-public:
- CFormCtrlBase(CJabberDlgDataPage *parent, CJabberDataField *field):
- m_field(field), m_parent(parent),
- m_hwnd(NULL), m_hwndLabel(NULL)
- {
- }
-
- HWND GetHwnd() { return m_hwnd; }
- void Init();
-
- int Layout(HDWP hdwp, int x, int y, int w);
- virtual XmlNode *FetchData() = 0;
-
-protected:
- int m_id;
- HWND m_hwnd, m_hwndLabel;
- CJabberDataField *m_field;
- CJabberDlgDataPage *m_parent;
-
- virtual void CreateControl() = 0;
- virtual int GetHeight(int width) = 0;
- SIZE GetControlTextSize(HWND hwnd, int w);
-
- void CreateLabel();
- void SetupFont();
- XmlNode *CreateNode();
-};
-
-void CFormCtrlBase::Init()
-{
- m_id = m_parent->AddControl(this);
- CreateControl();
- SetupFont();
-}
-
-SIZE CFormCtrlBase::GetControlTextSize(HWND hwnd, int w)
-{
- int length = GetWindowTextLength(hwnd) + 1;
- TCHAR *text = (TCHAR *)mir_alloc(sizeof(TCHAR) * length);
- GetWindowText(hwnd, text, length);
-
- RECT rc;
- SetRect(&rc, 0, 0, w, 0);
- HDC hdc = GetDC(hwnd);
- HFONT hfntSave = (HFONT)SelectObject(hdc, (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0));
- DrawText(hdc, text, -1, &rc, DT_CALCRECT|DT_WORDBREAK);
- SelectObject(hdc, hfntSave);
- ReleaseDC(hwnd, hdc);
-
- mir_free(text);
-
- SIZE res = { rc.right, rc.bottom };
- return res;
-}
-
-int CFormCtrlBase::Layout(HDWP hdwp, int x, int y, int w)
-{
- SIZE szLabel = {0}, szCtrl = {0};
- int h = 0;
-
- if (m_hwndLabel)
- {
- SIZE szLabel = GetControlTextSize(m_hwndLabel, w);
-
- szCtrl.cx = w - szLabel.cx - 5;
- szCtrl.cy = GetHeight(szCtrl.cx);
- if ((szCtrl.cx >= FORM_CONTROL_MINWIDTH) && (szCtrl.cy <= FORM_CONTROL_HEIGHT))
- {
- DeferWindowPos(hdwp, m_hwndLabel, NULL, x, y + (szCtrl.cy - szLabel.cy) / 2, szLabel.cx, szLabel.cy, SWP_NOZORDER|SWP_SHOWWINDOW);
- DeferWindowPos(hdwp, m_hwnd, NULL, x + szLabel.cx + 5, y, szCtrl.cx, szCtrl.cy, SWP_NOZORDER|SWP_SHOWWINDOW);
-
- h = szCtrl.cy;
- } else
- {
- szCtrl.cx = w - 10;
- szCtrl.cy = GetHeight(szCtrl.cx);
-
- DeferWindowPos(hdwp, m_hwndLabel, NULL, x, y, szLabel.cx, szLabel.cy, SWP_NOZORDER|SWP_SHOWWINDOW);
- DeferWindowPos(hdwp, m_hwnd, NULL, x + 10, y + szLabel.cy + 2, szCtrl.cx, szCtrl.cy, SWP_NOZORDER|SWP_SHOWWINDOW);
-
- h = szLabel.cy + 2 + szCtrl.cy;
- }
-
- } else
- {
- h = GetHeight(w);
- DeferWindowPos(hdwp, m_hwnd, NULL, x, y, w, h, SWP_NOZORDER|SWP_SHOWWINDOW);
- }
-
- return h;
-}
-
-void CFormCtrlBase::CreateLabel()
-{
- if (m_field->GetLabel())
- {
- m_hwndLabel = CreateWindow(_T("static"), m_field->GetLabel(),
- WS_CHILD|WS_VISIBLE/*|SS_CENTERIMAGE*/,
- 0, 0, 0, 0,
- m_parent->GetHwnd(), (HMENU)-1, hInst, NULL);
- }
-}
-
-void CFormCtrlBase::SetupFont()
-{
- if (m_hwnd)
- {
- HFONT hFont = (HFONT)SendMessage(GetParent(m_hwnd), WM_GETFONT, 0, 0);
- if (m_hwnd) SendMessage(m_hwnd, WM_SETFONT, (WPARAM)hFont, 0);
- if (m_hwndLabel) SendMessage(m_hwndLabel, WM_SETFONT, (WPARAM) hFont, 0);
- }
-}
-
-XmlNode *CFormCtrlBase::CreateNode()
-{
- XmlNode* field = new XmlNode("field");
- field->addAttr("var", m_field->GetVar());
- field->addAttr("type", m_field->GetTypeName());
- return field;
-}
-
-class CFormCtrlBoolean: public CFormCtrlBase
-{
-public:
- CFormCtrlBoolean(CJabberDlgDataPage *parent, CJabberDataField *field): CFormCtrlBase(parent, field) {}
-
- void CreateControl()
- {
- m_hwnd = CreateWindowEx(0, _T("button"), m_field->GetLabel(),
- WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX|BS_MULTILINE,
- 0, 0, 0, 0,
- m_parent->GetHwnd(), (HMENU)m_id, hInst, NULL);
- if (m_field->GetValue() && !mir_tstrcmp(m_field->GetValue(), _T("1")))
- SendMessage(m_hwnd, BM_SETCHECK, 1, 0);
- }
-
- int GetHeight(int width)
- {
- return GetControlTextSize(m_hwnd, width - 20).cy;
- }
-
- XmlNode *FetchData()
- {
- XmlNode *field = CreateNode();
- field->addChild("value", (SendMessage(m_hwnd, BM_GETCHECK, 0, 0) == BST_CHECKED) ? _T("1") : _T("0"));
- return field;
- }
-};
-
-class CFormCtrlFixed: public CFormCtrlBase
-{
-public:
- CFormCtrlFixed(CJabberDlgDataPage *parent, CJabberDataField *field): CFormCtrlBase(parent, field) {}
-
- void CreateControl()
- {
- CreateLabel();
- m_hwnd = CreateWindow(_T("edit"), m_field->GetValue(),
- WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_READONLY,
- 0, 0, 0, 0,
- m_parent->GetHwnd(), (HMENU)-1, hInst, NULL);
- }
-
- int GetHeight(int width)
- {
- return GetControlTextSize(m_hwnd, width - 2).cy;
- }
-
- XmlNode *FetchData()
- {
- XmlNode *field = CreateNode();
- for (int i = 0; i < m_field->GetValueCount(); ++i)
- field->addChild("value", m_field->GetValue(i));
- return field;
- }
-};
-
-class CFormCtrlHidden: public CFormCtrlBase
-{
-public:
- CFormCtrlHidden(CJabberDlgDataPage *parent, CJabberDataField *field): CFormCtrlBase(parent, field) {}
-
- void CreateControl()
- {
- }
-
- int GetHeight(int width)
- {
- return 0;
- }
-
- XmlNode *FetchData()
- {
- XmlNode *field = CreateNode();
- for (int i = 0; i < m_field->GetValueCount(); ++i)
- field->addChild("value", m_field->GetValue(i));
- return field;
- }
-};
-/*
-class CFormCtrlJidMulti: public CFormCtrlBase
-{
-public:
- CFormCtrlJidMulti(CJabberDlgDataPage *parent, CJabberDataField *field): CFormCtrlBase(parent, field) {}
-
- void CreateControl()
- {
- }
-
- int GetHeight(int width)
- {
- return 20;
- }
-
- XmlNode *FetchData()
- {
- return NULL;
- }
-};
-
-class CFormCtrlJidSingle: public CFormCtrlBase
-{
-public:
- CFormCtrlJidSingle(CJabberDlgDataPage *parent, CJabberDataField *field): CFormCtrlBase(parent, field) {}
-
- void CreateControl()
- {
- }
-
- int GetHeight(int width)
- {
- return 20;
- }
-
- XmlNode *FetchData()
- {
- return NULL;
- }
-};
-*/
-class CFormCtrlListMulti: public CFormCtrlBase
-{
-public:
- CFormCtrlListMulti(CJabberDlgDataPage *parent, CJabberDataField *field): CFormCtrlBase(parent, field) {}
-
- void CreateControl()
- {
- CreateLabel();
- m_hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, _T("listbox"),
- NULL, WS_CHILD|WS_VISIBLE|WS_TABSTOP|LBS_MULTIPLESEL,
- 0, 0, 0, 0,
- m_parent->GetHwnd(), (HMENU)m_id, hInst, NULL);
-
- for (int i = 0; i < m_field->GetOptionCount(); ++i)
- {
- DWORD dwIndex = SendMessage(m_hwnd, LB_ADDSTRING, 0, (LPARAM)m_field->GetOption(i)->label);
- SendMessage(m_hwnd, LB_SETITEMDATA, dwIndex, (LPARAM)m_field->GetOption(i)->value);
- for (int j = 0; j < m_field->GetValueCount(); ++j)
- if (!lstrcmp_null(m_field->GetValue(j), m_field->GetOption(i)->value))
- {
- SendMessage(m_hwnd, LB_SETSEL, TRUE, dwIndex);
- break;
- }
- }
- }
-
- int GetHeight(int width)
- {
- return 20 * 3;
- }
-
- XmlNode *FetchData()
- {
- XmlNode *field = CreateNode();
- int count = SendMessage(m_hwnd, LB_GETCOUNT, 0, 0);
- for (int i = 0; i < count; ++i)
- if (SendMessage(m_hwnd, LB_GETSEL, i, 0) > 0)
- field->addChild("value", (TCHAR *)SendMessage(m_hwnd, LB_GETITEMDATA, i, 0));
- return field;
- }
-};
-
-class CFormCtrlListSingle: public CFormCtrlBase
-{
-public:
- CFormCtrlListSingle(CJabberDlgDataPage *parent, CJabberDataField *field): CFormCtrlBase(parent, field) {}
-
- void CreateControl()
- {
- CreateLabel();
- m_hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, _T("combobox"), NULL,
- WS_CHILD|WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,
- 0, 0, 0, 0,
- m_parent->GetHwnd(), (HMENU)m_id, hInst, NULL);
-
- for (int i = 0; i < m_field->GetOptionCount(); ++i)
- {
- DWORD dwIndex = SendMessage(m_hwnd, CB_ADDSTRING, 0, (LPARAM)m_field->GetOption(i)->label);
- SendMessage(m_hwnd, CB_SETITEMDATA, dwIndex, (LPARAM)m_field->GetOption(i)->value);
- if (!lstrcmp_null(m_field->GetValue(), m_field->GetOption(i)->value))
- SendMessage(m_hwnd, CB_SETCURSEL, dwIndex, 0);
- }
- }
-
- int GetHeight(int width)
- {
- return 20;
- }
-
- XmlNode *FetchData()
- {
- XmlNode *field = CreateNode();
- int sel = SendMessage(m_hwnd, CB_GETCURSEL, 0, 0);
- if (sel != CB_ERR)
- field->addChild("value", (TCHAR *)SendMessage(m_hwnd, CB_GETITEMDATA, sel, 0));
- return field;
- }
-};
-
-class CFormCtrlTextMulti: public CFormCtrlBase
-{
-public:
- CFormCtrlTextMulti(CJabberDlgDataPage *parent, CJabberDataField *field): CFormCtrlBase(parent, field) {}
-
- void CreateControl()
- {
- CreateLabel();
- int i, length = 1;
- for (i = 0; i < m_field->GetValueCount(); ++i)
- length += mir_tstrlen(m_field->GetValue(i)) + 2;
-
- TCHAR *str = (TCHAR *)mir_alloc(sizeof(TCHAR) * length);
- *str = 0;
- for (i = 0; i < m_field->GetValueCount(); ++i)
- {
- if (i) lstrcat(str, _T("\r\n"));
- lstrcat(str, m_field->GetValue(i));
- }
-
- m_hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, _T("edit"), str,
- WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_VSCROLL|ES_LEFT|ES_MULTILINE|ES_AUTOVSCROLL|ES_WANTRETURN,
- 0, 0, 0, 0,
- m_parent->GetHwnd(), (HMENU)m_id, hInst, NULL);
- // WNDPROC oldWndProc = (WNDPROC)SetWindowLongPtr(item->hCtrl, GWL_WNDPROC, (LPARAM)JabberFormMultiLineWndProc);
- // SetWindowLongPtr(item->hCtrl, GWL_USERDATA, (LONG) oldWndProc);
-
- mir_free(str);
- }
-
- int GetHeight(int width)
- {
- return 20 * 3;
- }
-
- XmlNode *FetchData()
- {
- XmlNode *field = CreateNode();
- int len = GetWindowTextLength(m_hwnd);
- TCHAR *str = (TCHAR *)mir_alloc(sizeof(TCHAR) * (len+1));
- GetWindowText(m_hwnd, str, len+1);
- TCHAR *p = str;
- while (p != NULL)
- {
- TCHAR *q = _tcsstr( p, _T("\r\n"));
- if (q) *q = '\0';
- field->addChild("value", p);
- p = q ? q+2 : NULL;
- }
- mir_free(str);
- return field;
- }
-};
-
-class CFormCtrlTextSingle: public CFormCtrlBase
-{
-public:
- CFormCtrlTextSingle(CJabberDlgDataPage *parent, CJabberDataField *field): CFormCtrlBase(parent, field) {}
-
- void CreateControl()
- {
- CreateLabel();
- m_hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, _T("edit"), m_field->GetValue(),
- WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_LEFT|ES_AUTOHSCROLL,
- 0, 0, 0, 0,
- m_parent->GetHwnd(), (HMENU)m_id, hInst, NULL);
- }
-
- int GetHeight(int width)
- {
- return 20;
- }
-
- XmlNode *FetchData()
- {
- XmlNode *field = CreateNode();
- int len = GetWindowTextLength(m_hwnd);
- TCHAR *str = (TCHAR *)mir_alloc(sizeof(TCHAR) * (len+1));
- GetWindowText(m_hwnd, str, len+1);
- field->addChild("value", str);
- mir_free(str);
- return field;
- }
-};
-
-class CFormCtrlTextPrivate: public CFormCtrlBase
-{
-public:
- CFormCtrlTextPrivate(CJabberDlgDataPage *parent, CJabberDataField *field): CFormCtrlBase(parent, field) {}
-
- void CreateControl()
- {
- CreateLabel();
- m_hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, _T("edit"), m_field->GetValue(),
- WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_LEFT|ES_AUTOHSCROLL|ES_PASSWORD,
- 0, 0, 0, 0,
- m_parent->GetHwnd(), (HMENU)m_id, hInst, NULL);
- }
-
- int GetHeight(int width)
- {
- return 20;
- }
-
- XmlNode *FetchData()
- {
- XmlNode *field = CreateNode();
- int len = GetWindowTextLength(m_hwnd);
- TCHAR *str = (TCHAR *)mir_alloc(sizeof(TCHAR) * (len+1));
- GetWindowText(m_hwnd, str, len+1);
- field->addChild("value", str);
- mir_free(str);
- return field;
- }
-};
-
-CJabberDlgDataPage::CJabberDlgDataPage(HWND hwndParent):
- m_controls(5)
-{
- m_hwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DATAFORM_PAGE), hwndParent, DlgProc, (LPARAM)this);
- ShowWindow(m_hwnd, SW_SHOW);
-}
-
-CJabberDlgDataPage::~CJabberDlgDataPage()
-{
- DestroyWindow(m_hwnd);
-}
-
-void CJabberDlgDataPage::AddField(CJabberDataField *field)
-{
- CFormCtrlBase *ctrl = NULL;
-
- switch (field->GetType())
- {
- case JDFT_BOOLEAN: ctrl = new CFormCtrlBoolean(this, field); break;
- case JDFT_FIXED: ctrl = new CFormCtrlFixed(this, field); break;
- case JDFT_HIDDEN: ctrl = new CFormCtrlHidden(this, field); break;
- case JDFT_JID_MULTI: ctrl = new CFormCtrlTextMulti(this, field); break;
- case JDFT_JID_SINGLE: ctrl = new CFormCtrlTextSingle(this, field); break;
- case JDFT_LIST_MULTI: ctrl = new CFormCtrlListMulti(this, field); break;
- case JDFT_LIST_SINGLE: ctrl = new CFormCtrlListSingle(this, field); break;
- case JDFT_TEXT_MULTI: ctrl = new CFormCtrlTextMulti(this, field); break;
- case JDFT_TEXT_PRIVATE: ctrl = new CFormCtrlTextPrivate(this, field); break;
- case JDFT_TEXT_SINGLE: ctrl = new CFormCtrlTextSingle(this, field); break;
- }
-
- if (ctrl) ctrl->Init();
-}
-
-XmlNode *CJabberDlgDataPage::FetchData()
-{
- XmlNode *result = new XmlNode("x");
- result->addAttr("xmlns", JABBER_FEAT_DATA_FORMS);
- result->addAttr("type", "submit");
-
- for (int i = 0; i < m_controls.getCount(); ++i)
- if (XmlNode *field = m_controls[i].FetchData())
- result->addChild(field);
-
- return result;
-}
-
-void CJabberDlgDataPage::Layout()
-{
- RECT rc; GetClientRect(m_hwnd, &rc);
- int w = rc.right - 20;
- int x = 10;
- int y = 10;
-
- m_height = rc.bottom;
- m_scrollPos = GetScrollPos(m_hwnd, SB_VERT);
-
- HDWP hdwp = BeginDeferWindowPos(m_controls.getCount());
- for (int i = 0; i < m_controls.getCount(); ++i)
- if (int h = m_controls[i].Layout(hdwp, x, y - m_scrollPos, w))
- y += h + 5;
- EndDeferWindowPos(hdwp);
-
- m_dataHeight = y + 5;
-
- SCROLLINFO si = {0};
- si.cbSize = sizeof(si);
- si.fMask = SIF_DISABLENOSCROLL|SIF_PAGE|SIF_RANGE;
- si.nPage = m_height;
- si.nMin = 0;
- si.nMax = m_dataHeight;
- SetScrollInfo(m_hwnd, SB_VERT, &si, TRUE);
-}
-
-BOOL CJabberDlgDataPage::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- SCROLLINFO si = {0};
- si.cbSize = sizeof(si);
- si.fMask = SIF_DISABLENOSCROLL;
- SetScrollInfo(m_hwnd, SB_VERT, &si, TRUE);
- m_scrollPos = 0;
-
- break;
- }
-
- case WM_MOUSEWHEEL:
- {
- int zDelta = GET_WHEEL_DELTA_WPARAM(wParam);
- if (zDelta)
- {
- int i, nScrollLines = 0;
- SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, (void*)&nScrollLines, 0);
- for (i = 0; i < (nScrollLines + 1) / 2; i++ )
- SendMessage(m_hwnd, WM_VSCROLL, (zDelta < 0) ? SB_LINEDOWN : SB_LINEUP, 0);
- }
-
- SetWindowLongPtr(m_hwnd, DWL_MSGRESULT, 0);
- return TRUE;
- }
-
- case WM_VSCROLL:
- {
- int pos = m_scrollPos;
- switch (LOWORD(wParam))
- {
- case SB_LINEDOWN:
- pos += 15;
- break;
- case SB_LINEUP:
- pos -= 15;
- break;
- case SB_PAGEDOWN:
- pos += m_height - 10;
- break;
- case SB_PAGEUP:
- pos -= m_height - 10;
- break;
- case SB_THUMBTRACK:
- pos = HIWORD(wParam);
- break;
- }
-
- if (pos > m_dataHeight - m_height) pos = m_dataHeight - m_height;
- if (pos < 0) pos = 0;
-
- if (m_scrollPos != pos)
- {
- ScrollWindow(m_hwnd, 0, m_scrollPos - pos, NULL, NULL);
- SetScrollPos(m_hwnd, SB_VERT, pos, TRUE);
- m_scrollPos = pos;
- }
- break;
- }
-
- case WM_SIZE:
- Layout();
- break;
- }
-
- return FALSE;
-}
-
-BOOL CJabberDlgDataPage::DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- CJabberDlgDataPage *pThis = NULL;
-
- if (msg == WM_INITDIALOG)
- {
- if (pThis = (CJabberDlgDataPage *)lParam)
- pThis->m_hwnd = hwnd;
- SetWindowLongPtr(hwnd, GWL_USERDATA, lParam);
- } else
- {
- pThis = (CJabberDlgDataPage *)GetWindowLongPtr(hwnd, GWL_USERDATA);
- }
-
- if (pThis)
- {
- BOOL result = pThis->DlgProc(msg, wParam, lParam);
- if (msg == WM_DESTROY)
- {
- pThis->m_hwnd = NULL;
- SetWindowLongPtr(hwnd, GWL_USERDATA, 0);
- }
- return result;
- }
-
- return FALSE;
-}
-
-/////////////////////////////////////////////////////////////////////////////////
-// Data form control -- Window class support
-const TCHAR *CCtrlJabberForm::ClassName = _T("JabberDataFormControl");
-bool CCtrlJabberForm::ClassRegistered = false;
-
-bool CCtrlJabberForm::RegisterClass()
-{
- if (ClassRegistered) return true;
-
- WNDCLASSEX wcx = {0};
- wcx.cbSize = sizeof(wcx);
- wcx.lpszClassName = ClassName;
- wcx.lpfnWndProc = DefWindowProc;
- wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
- wcx.hbrBackground = 0;
- wcx.style = CS_GLOBALCLASS;
-
- if (::RegisterClassEx(&wcx))
- ClassRegistered = true;
-
- return ClassRegistered;
-}
-
-bool CCtrlJabberForm::UnregisterClass()
-{
- if (!ClassRegistered) return true;
-
- if (::UnregisterClass(ClassName, hInst) == 0)
- ClassRegistered = false;
-
- return !ClassRegistered;
-}
-
-/////////////////////////////////////////////////////////////////////////////////
-// Data form control
-CCtrlJabberForm::CCtrlJabberForm(CDlgBase* dlg, int ctrlId):
- CCtrlBase(dlg, ctrlId), m_pForm(NULL), m_pDlgPage(NULL)
-{
-}
-
-CCtrlJabberForm::~CCtrlJabberForm()
-{
- if (m_pDlgPage) delete m_pDlgPage;
-}
-
-void CCtrlJabberForm::OnInit()
-{
- CSuper::OnInit();
- Subclass();
- SetupForm();
-}
-
-void CCtrlJabberForm::SetDataForm(CJabberDataForm *pForm)
-{
- if (m_pDlgPage)
- {
- delete m_pDlgPage;
- m_pDlgPage = NULL;
- }
-
- m_pForm = pForm;
- SetupForm();
-}
-
-XmlNode *CCtrlJabberForm::FetchData()
-{
- return m_pDlgPage ? m_pDlgPage->FetchData() : NULL;
-}
-
-void CCtrlJabberForm::SetupForm()
-{
- if (!m_pForm || !m_hwnd) return;
-
- m_pDlgPage = new CJabberDlgDataPage(m_hwnd);
- for (int i = 0; i < m_pForm->GetFields()->GetCount(); ++i)
- m_pDlgPage->AddField(m_pForm->GetFields()->GetField(i));
-
- Layout();
-}
-
-void CCtrlJabberForm::Layout()
-{
- if (!m_pDlgPage) return;
-
- RECT rc;
- GetClientRect(m_hwnd, &rc);
- SetWindowPos(m_pDlgPage->GetHwnd(), NULL, 0, 0, rc.right, rc.bottom, SWP_NOZORDER);
-}
-
-LRESULT CCtrlJabberForm::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg)
- {
- case WM_SIZE:
- {
- Layout();
- break;
- }
- }
-
- return CSuper::CustomWndProc(msg, wParam, lParam);
-}
-
-/////////////////////////////////////////////////////////////////////////////////
-// testing
-class CJabberDlgFormTest: public CDlgBase
-{
-public:
- CJabberDlgFormTest(CJabberDataForm *pForm):
- CDlgBase(IDD_DATAFORM_TEST, NULL),
- m_frm(this, IDC_DATAFORM)
- {
- m_frm.SetDataForm(pForm);
- }
-
- int Resizer(UTILRESIZECONTROL *urc)
- {
- return RD_ANCHORX_WIDTH|RD_ANCHORY_HEIGHT;
- }
-
-private:
- CCtrlJabberForm m_frm;
-};
-
-static VOID CALLBACK CreateDialogApcProc(void* param)
-{
- XmlNode *node = (XmlNode *)param;
-
- CJabberDataForm form(node);
-
- CCtrlJabberForm::RegisterClass();
- CJabberDlgFormTest dlg(&form);
- dlg.DoModal();
-
- delete node;
-}
-
-void LaunchForm(XmlNode *node)
-{
- node = JabberXmlCopyNode(node);
- CallFunctionAsync(CreateDialogApcProc, node);
-}
diff --git a/protocols/JabberG/src/obsoleted/jabber_form2.h.obsoleted b/protocols/JabberG/src/obsoleted/jabber_form2.h.obsoleted
deleted file mode 100644
index 61bc9d8a14..0000000000
--- a/protocols/JabberG/src/obsoleted/jabber_form2.h.obsoleted
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
-
-Jabber Protocol Plugin for Miranda NG
-
-Copyright (c) 2002-04 Santithorn Bunchua
-Copyright (c) 2005-12 George Hazan
-Copyright (c) 2007-09 Maxim Mluhov
-Copyright (c) 2007-09 Victor Pavlychko
-Copyright (C) 2012-19 Miranda NG team
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or ( at your option ) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-
-enum TJabberDataFormType
-{
- JDFT_BOOLEAN,
- JDFT_FIXED,
- JDFT_HIDDEN,
- JDFT_JID_MULTI,
- JDFT_JID_SINGLE,
- JDFT_LIST_MULTI,
- JDFT_LIST_SINGLE,
- JDFT_TEXT_MULTI,
- JDFT_TEXT_PRIVATE,
- JDFT_TEXT_SINGLE,
-};
-
-struct TJabberDataFormRegisry_Field
-{
- TCHAR *field;
- TJabberDataFormType type;
- TCHAR *description_en;
- TCHAR *description_tr;
-};
-
-struct TJabberDataFormRegisry_Form
-{
- TCHAR *form_type;
- TJabberDataFormRegisry_Field *fields;
- int count;
-};
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Forwards
-class CJabberDlgDataForm;
-class CJabberDataField;
-class CJabberDataFieldSet;
-class CJabberDataForm;
-class CJabberDlgDataPage;
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Data form classes
-class CJabberDataField
-{
-public:
- struct TOption
- {
- TCHAR *label;
- TCHAR *value;
- };
-
- CJabberDataField(CJabberDataForm *form, XmlNode *node);
- ~CJabberDataField();
-
- XmlNode *GetNode() { return m_node; }
-
- TCHAR *GetTypeName() { return m_typeName; }
- TJabberDataFormType GetType() { return m_type; }
-
- TCHAR *GetVar() { return m_var; }
-
- bool IsRequired() { return m_required; }
- TCHAR *GetDescription(int i) { return m_descriptions[i]; }
- TCHAR *GetLabel() { return m_label; }
-
- int GetValueCount() { return m_values.getCount(); }
- TCHAR *GetValue(int i = 0) { return m_values[i]; }
-
- int GetOptionCount() { return m_options.getCount(); }
- TOption *GetOption(int i) { return &(m_options[i]); }
-
-private:
- XmlNode *m_node;
- CJabberDataFieldSet *m_fieldset;
-
- bool m_required;
- TCHAR *m_var;
- TCHAR *m_label;
- TCHAR *m_typeName;
- TJabberDataFormType m_type;
-
- OBJLIST<TOption> m_options;
- LIST<TCHAR> m_values;
- LIST<TCHAR> m_descriptions;
-};
-
-class CJabberDataFieldSet
-{
-public:
- CJabberDataFieldSet();
-
- int GetCount() { return m_fields.getCount(); }
- CJabberDataField *GetField(int i) { return &(m_fields[i]); }
- CJabberDataField *GetField(TCHAR *var);
-
- void AddField(CJabberDataField *field) { m_fields.insert(field, m_fields.getCount()); }
-
-private:
- OBJLIST<CJabberDataField> m_fields;
-};
-
-class CJabberDataForm
-{
-public:
- enum TFormType { TYPE_NONE, TYPE_FORM, TYPE_SUBMIT, TYPE_CANCEL, TYPE_RESULT };
-
- CJabberDataForm(XmlNode *node);
- ~CJabberDataForm();
-
- TCHAR *GetTypeName() const { return m_typename; }
- TFormType GetType() const { return m_type; }
- TCHAR *GetFormType() const { return m_form_type; }
- TCHAR *GetTitle() const { return m_title; }
- int GetInstructionsCount() const { return m_instructions.getCount(); }
- TCHAR *GetInstructions(int idx=0) const { return m_instructions[idx]; }
-
- CJabberDataFieldSet *GetFields() { return &m_fields; }
-
- CJabberDataFieldSet *GetReported() { return &m_reported; }
- int GetItemCount() { return m_items.getCount(); }
- CJabberDataFieldSet *GetItem(int i) { return &(m_items[i]); }
-
-private:
- XmlNode *m_node;
-
- TCHAR *m_typename;
- TFormType m_type;
-
- TCHAR *m_form_type;
- TJabberDataFormRegisry_Form *m_form_type_info;
-
- TCHAR *m_title;
- LIST<TCHAR> m_instructions;
-
- CJabberDataFieldSet m_fields;
- CJabberDataFieldSet m_reported;
- OBJLIST<CJabberDataFieldSet> m_items;
-};
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// UI Control
-class CCtrlJabberForm: public CCtrlBase
-{
- typedef CCtrlBase CSuper;
-
-public:
- static const TCHAR *ClassName;
- static bool RegisterClass();
- static bool UnregisterClass();
-
- CCtrlJabberForm(CDlgBase* dlg, int ctrlId);
- ~CCtrlJabberForm();
-
- void OnInit();
- void SetDataForm(CJabberDataForm *pForm);
- XmlNode *FetchData();
-
-protected:
- virtual LRESULT CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam);
-
-private:
- static bool ClassRegistered;
-
- CJabberDataForm *m_pForm;
- CJabberDlgDataPage *m_pDlgPage;
-
- void SetupForm();
- void Layout();
-};
diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h
index a6afbd23ea..dc50a93f52 100755
--- a/protocols/JabberG/src/stdafx.h
+++ b/protocols/JabberG/src/stdafx.h
@@ -86,6 +86,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <win2k.h>
#include <m_imgsrvc.h>
#include <m_clc.h>
+#include <m_xml.h>
#include <m_folders.h>
#include <m_fingerprint.h>
@@ -179,8 +180,8 @@ protected:
#define JABBER_IQID "mir_"
#define JABBER_MAX_JID_LEN 1024
-#define JABBER_GC_MSG_QUIT LPGENW("I'm happy Miranda NG user. Get it at https://miranda-ng.org/.")
-#define JABBER_GC_MSG_SLAP LPGENW("/me slaps %s around a bit with a large trout")
+#define JABBER_GC_MSG_QUIT LPGEN("I'm happy Miranda NG user. Get it at https://miranda-ng.org/.")
+#define JABBER_GC_MSG_SLAP LPGEN("/me slaps %s around a bit with a large trout")
#define JABBER_SERVER_URL "https://xmpp.net/services.php"
// registered db event types
@@ -309,12 +310,12 @@ enum {
struct CJabberHttpAuthParams
{
enum {IQ = 1, MSG = 2} m_nType;
- wchar_t *m_szFrom;
- wchar_t *m_szIqId;
- wchar_t *m_szThreadId;
- wchar_t *m_szId;
- wchar_t *m_szMethod;
- wchar_t *m_szUrl;
+ char *m_szFrom;
+ char *m_szIqId;
+ char *m_szThreadId;
+ char *m_szId;
+ char *m_szMethod;
+ char *m_szUrl;
CJabberHttpAuthParams()
{
memset(this, 0, sizeof(CJabberHttpAuthParams));
@@ -353,14 +354,14 @@ struct CJabberHttpAuthParams
struct JABBER_CONN_DATA : public MZeroedObject
{
- wchar_t username[512];
- wchar_t password[512];
- char server[128];
- char manualHost[128];
- int port;
- BOOL useSSL;
-
- HWND reg_hwndDlg;
+ char username[512];
+ char password[512];
+ char server[128];
+ char manualHost[128];
+ int port;
+ BOOL useSSL;
+
+ HWND reg_hwndDlg;
};
struct ThreadData
@@ -402,9 +403,9 @@ struct ThreadData
// connection & login data
JABBER_CONN_DATA conn;
- wchar_t resource[128];
- wchar_t fullJID[JABBER_MAX_JID_LEN];
- ptrW tszNewPassword;
+ char resource[128];
+ char fullJID[JABBER_MAX_JID_LEN];
+ ptrA tszNewPassword;
class TJabberAuth *auth;
JabberCapsBits jabberServerCaps;
@@ -413,8 +414,8 @@ struct ThreadData
void shutdown(void);
int recv(char* buf, size_t len);
int send(char* buffer, int bufsize = -1);
- int send(HXML node);
- int send_no_strm_mgmt(HXML node);
+ int send(TiXmlElement *node);
+ int send_no_strm_mgmt(TiXmlElement *node);
int recvws(char* buffer, size_t bufsize, int flags);
int sendws(char* buffer, size_t bufsize, int flags);
@@ -422,11 +423,11 @@ struct ThreadData
struct JABBER_MODEMSGS
{
- wchar_t *szOnline;
- wchar_t *szAway;
- wchar_t *szNa;
- wchar_t *szDnd;
- wchar_t *szFreechat;
+ char *szOnline;
+ char *szAway;
+ char *szNa;
+ char *szDnd;
+ char *szFreechat;
};
typedef enum { FT_SI, FT_OOB, FT_BYTESTREAM, FT_IBB } JABBER_FT_TYPE;
@@ -446,10 +447,10 @@ struct filetransfer
JABBER_FT_TYPE type;
HNETLIBCONN s;
JABBER_FILE_STATE state;
- wchar_t *jid;
+ char* jid;
int fileId;
- wchar_t* szId;
- wchar_t *sid;
+ char* szId;
+ char* sid;
int bCompleted;
HANDLE hWaitEvent;
@@ -497,19 +498,20 @@ enum JABBER_MUC_JIDLIST_TYPE
MUC_OWNERLIST
};
-struct JABBER_MUC_JIDLIST_INFO
+struct JABBER_MUC_JIDLIST_INFO : public MZeroedObject
{
~JABBER_MUC_JIDLIST_INFO();
JABBER_MUC_JIDLIST_TYPE type;
- wchar_t *roomJid; // filled-in by the WM_JABBER_REFRESH code
- HXML iqNode;
+ char *roomJid; // filled-in by the WM_JABBER_REFRESH code
+ TiXmlDocument doc;
+ TiXmlElement *iqNode;
CJabberProto *ppro;
- wchar_t *type2str(void) const;
+ wchar_t* type2str(void) const;
};
-typedef void (CJabberProto::*JABBER_FORM_SUBMIT_FUNC)(HXML values, void *userdata);
+typedef void (CJabberProto::*JABBER_FORM_SUBMIT_FUNC)(TiXmlElement *values, void *userdata);
//---- jabber_treelist.c ------------------------------------------------
@@ -590,7 +592,7 @@ private:
extern HANDLE hExtraMood;
extern HANDLE hExtraActivity;
-extern wchar_t szCoreVersion[];
+extern char szCoreVersion[];
extern unsigned int g_nTempFileId;
extern int g_cbCountries;
@@ -637,14 +639,14 @@ enum TJabberFormControlType
typedef struct TJabberFormControlInfo *HJFORMCTRL;
typedef struct TJabberFormLayoutInfo *HJFORMLAYOUT;
-void JabberFormCreateUI(HWND hwndStatic, HXML xNode, int *formHeight, BOOL bCompact = FALSE);
+void JabberFormCreateUI(HWND hwndStatic, TiXmlElement *xNode, int *formHeight, BOOL bCompact = FALSE);
void JabberFormDestroyUI(HWND hwndStatic);
-void JabberFormSetInstruction(HWND hwndForm, const wchar_t *text);
+void JabberFormSetInstruction(HWND hwndForm, const char *text);
HJFORMLAYOUT JabberFormCreateLayout(HWND hwndStatic); // use mir_free to destroy
-HJFORMCTRL JabberFormAppendControl(HWND hwndStatic, HJFORMLAYOUT layout_info, TJabberFormControlType type, const wchar_t *labelStr, const wchar_t *valueStr);
+HJFORMCTRL JabberFormAppendControl(HWND hwndStatic, HJFORMLAYOUT layout_info, TJabberFormControlType type, const char *labelStr, const char *valueStr);
void JabberFormLayoutControls(HWND hwndStatic, HJFORMLAYOUT layout_info, int *formHeight);
-HXML JabberFormGetData(HWND hwndStatic, HXML xNode);
+TiXmlElement* JabberFormGetData(HWND hwndStatic, TiXmlDocument *doc, TiXmlElement *xNode);
//---- jabber_icolib.c ----------------------------------------------
@@ -670,15 +672,15 @@ int g_OnToolbarInit(WPARAM, LPARAM);
struct CJabberAdhocStartupParams
{
- wchar_t *m_szJid;
- wchar_t *m_szNode;
+ char *m_szJid;
+ char *m_szNode;
CJabberProto *m_pProto;
- CJabberAdhocStartupParams(CJabberProto *proto, wchar_t* szJid, wchar_t* szNode = nullptr)
+ CJabberAdhocStartupParams(CJabberProto *proto, const char *szJid, const char *szNode = nullptr)
{
m_pProto = proto;
- m_szJid = mir_wstrdup(szJid);
- m_szNode = szNode ? mir_wstrdup(szNode) : nullptr;
+ m_szJid = mir_strdup(szJid);
+ m_szNode = szNode ? mir_strdup(szNode) : nullptr;
}
~CJabberAdhocStartupParams()
{
@@ -687,16 +689,18 @@ struct CJabberAdhocStartupParams
}
};
-struct JabberAdHocData
+struct JabberAdHocData : public MZeroedObject
{
CJabberProto *proto;
- int CurrentHeight;
- int curPos;
- int frameHeight;
- RECT frameRect;
- HXML AdHocNode;
- HXML CommandsNode;
- wchar_t *ResponderJID;
+
+ int CurrentHeight;
+ int curPos;
+ int frameHeight;
+ RECT frameRect;
+ TiXmlDocument doc;
+ TiXmlElement *AdHocNode;
+ TiXmlElement *CommandsNode;
+ char* ResponderJID;
};
//---- jabber_util.cpp ------------------------------------------------------------------
@@ -719,27 +723,31 @@ struct TStringPairs
typedef char JabberShaStrBuf[2*MIR_SHA1_HASH_SIZE + 1];
-wchar_t* __stdcall JabberNickFromJID(const wchar_t *jid);
-wchar_t* JabberPrepareJid(const wchar_t *jid);
-char* __stdcall JabberSha1(const char *str, JabberShaStrBuf buf);
-wchar_t* __stdcall JabberStrFixLines(const wchar_t *str);
-void __stdcall JabberHttpUrlDecode(wchar_t *str);
-int __stdcall JabberCombineStatus(int status1, int status2);
-wchar_t* __stdcall JabberErrorStr(int errorCode);
-wchar_t* __stdcall JabberErrorMsg(HXML errorNode, int *errorCode = nullptr);
-time_t __stdcall JabberIsoToUnixTime(const wchar_t *stamp);
-wchar_t* __stdcall JabberStripJid(const wchar_t *jid, wchar_t *dest, size_t destLen);
-int __stdcall JabberGetPacketID(HXML n);
-wchar_t* __stdcall JabberId2string(int id);
-
-wchar_t* time2str(time_t _time, wchar_t *buf, size_t bufLen);
-time_t str2time(const wchar_t*);
-
-const wchar_t* JabberStrIStr(const wchar_t *str, const wchar_t *substr);
-void JabberCopyText(HWND hwnd, const wchar_t *text);
-CJabberProto* JabberChooseInstance(bool bIsLink=false);
-
-bool JabberReadXep203delay(HXML node, time_t &msgTime);
+char* JabberNickFromJID(const char *jid);
+char* JabberPrepareJid(const char *jid);
+char* JabberSha1(const char *str, JabberShaStrBuf buf);
+void JabberHttpUrlDecode(wchar_t *str);
+int JabberCombineStatus(int status1, int status2);
+time_t JabberIsoToUnixTime(const char *stamp);
+char* JabberStripJid(const char *jid, char *dest, size_t destLen);
+int JabberGetPacketID(const TiXmlElement *n);
+char* JabberId2string(int id);
+
+char* time2str(time_t _time, char *buf, size_t bufLen);
+time_t str2time(const char*);
+
+wchar_t* JabberStrFixLines(const wchar_t *str);
+
+wchar_t* JabberErrorStr(int errorCode);
+wchar_t* JabberErrorMsg(const TiXmlElement *errorNode, int *errorCode = nullptr);
+
+const wchar_t *JabberStrIStr(const wchar_t *str, const wchar_t *substr);
+void JabberCopyText(HWND hwnd, const wchar_t *text);
+CJabberProto* JabberChooseInstance(bool bIsLink=false);
+
+bool JabberReadXep203delay(const TiXmlElement *node, time_t &msgTime);
+
+void SetDlgItemTextUtf(HWND hwndDlg, int ctrlId, const char *szValue);
int UIEmulateBtnClick(HWND hwndDlg, UINT idcButton);
void UIShowControls(HWND hwndDlg, int *idList, int nCmdShow);
diff --git a/src/mir_app/src/netlibsecurity.cpp b/src/mir_app/src/netlibsecurity.cpp
index dd41941ea8..c48becd6c9 100644
--- a/src/mir_app/src/netlibsecurity.cpp
+++ b/src/mir_app/src/netlibsecurity.cpp
@@ -357,7 +357,7 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge,
return szResult.Detach();
}
-MIR_APP_DLL(char*) Netlib_NtlmCreateResponse(HANDLE hProvider, char *szChallenge, wchar_t *pwszLogin, wchar_t *pwszPassword, unsigned &complete)
+MIR_APP_DLL(char*) Netlib_NtlmCreateResponse(HANDLE hProvider, const char *szChallenge, wchar_t *pwszLogin, wchar_t *pwszPassword, unsigned &complete)
{
return NtlmCreateResponseFromChallenge(hProvider, szChallenge, pwszLogin, pwszPassword, false, complete);
}