diff options
author | George Hazan <ghazan@miranda.im> | 2019-02-18 22:32:52 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-02-19 19:24:16 +0300 |
commit | 6e9ba17bef418a058e84ff5e248ea479d4836669 (patch) | |
tree | d49f0c620d3c06092900ff7374b22ccfa646a0b7 /protocols/JabberG/src/jabber_caps.cpp | |
parent | d05f7096cd384679e9dcab92a6efc81c68977628 (diff) |
Jabber -> TinyXml2
Diffstat (limited to 'protocols/JabberG/src/jabber_caps.cpp')
-rwxr-xr-x | protocols/JabberG/src/jabber_caps.cpp | 285 |
1 files changed, 141 insertions, 144 deletions
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());
}
}
|