summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src/jabber_events.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-02-18 22:32:52 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-02-19 19:24:16 +0300
commit6e9ba17bef418a058e84ff5e248ea479d4836669 (patch)
treed49f0c620d3c06092900ff7374b22ccfa646a0b7 /protocols/JabberG/src/jabber_events.cpp
parentd05f7096cd384679e9dcab92a6efc81c68977628 (diff)
Jabber -> TinyXml2
Diffstat (limited to 'protocols/JabberG/src/jabber_events.cpp')
-rw-r--r--protocols/JabberG/src/jabber_events.cpp58
1 files changed, 29 insertions, 29 deletions
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);