summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src/jabber_iqid.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/JabberG/src/jabber_iqid.cpp')
-rwxr-xr-xprotocols/JabberG/src/jabber_iqid.cpp936
1 files changed, 446 insertions, 490 deletions
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;