diff options
Diffstat (limited to 'protocols/JabberG/src/jabber_iq.cpp')
-rw-r--r-- | protocols/JabberG/src/jabber_iq.cpp | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/protocols/JabberG/src/jabber_iq.cpp b/protocols/JabberG/src/jabber_iq.cpp index 916e2963cb..162d60e7a6 100644 --- a/protocols/JabberG/src/jabber_iq.cpp +++ b/protocols/JabberG/src/jabber_iq.cpp @@ -85,52 +85,52 @@ void CJabberIqManager::Shutdown() void CJabberIqManager::FillPermanentHandlers()
{
// version requests (XEP-0092)
- AddPermanentHandler(&CJabberProto::OnIqRequestVersion, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_VERSION, FALSE, L"query");
+ AddPermanentHandler(&CJabberProto::OnIqRequestVersion, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_VERSION, FALSE, "query");
// last activity (XEP-0012)
- AddPermanentHandler(&CJabberProto::OnIqRequestLastActivity, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_LAST_ACTIVITY, FALSE, L"query");
+ AddPermanentHandler(&CJabberProto::OnIqRequestLastActivity, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_LAST_ACTIVITY, FALSE, "query");
// ping requests (XEP-0199)
- AddPermanentHandler(&CJabberProto::OnIqRequestPing, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_PING, FALSE, L"ping");
+ AddPermanentHandler(&CJabberProto::OnIqRequestPing, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_PING, FALSE, "ping");
// entity time (XEP-0202)
- AddPermanentHandler(&CJabberProto::OnIqRequestTime, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_ENTITY_TIME, FALSE, L"time");
+ AddPermanentHandler(&CJabberProto::OnIqRequestTime, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_ENTITY_TIME, FALSE, "time");
// entity time (XEP-0090)
- AddPermanentHandler(&CJabberProto::OnIqProcessIqOldTime, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_ENTITY_TIME_OLD, FALSE, L"query");
+ AddPermanentHandler(&CJabberProto::OnIqProcessIqOldTime, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_ENTITY_TIME_OLD, FALSE, "query");
// old avatars support (deprecated XEP-0008)
- AddPermanentHandler(&CJabberProto::OnIqRequestAvatar, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_AVATAR, FALSE, L"query");
+ AddPermanentHandler(&CJabberProto::OnIqRequestAvatar, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_AVATAR, FALSE, "query");
// privacy lists (XEP-0016)
- AddPermanentHandler(&CJabberProto::OnIqRequestPrivacyLists, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_PRIVACY_LISTS, FALSE, L"query");
+ AddPermanentHandler(&CJabberProto::OnIqRequestPrivacyLists, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_PRIVACY_LISTS, FALSE, "query");
// in band bytestreams (XEP-0047)
AddPermanentHandler(&CJabberProto::OnFtHandleIbbIq, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE | JABBER_IQ_PARSE_CHILD_TAG_NAME | JABBER_IQ_PARSE_CHILD_TAG_XMLNS, JABBER_FEAT_IBB, FALSE, nullptr);
// socks5-bytestreams (XEP-0065)
- AddPermanentHandler(&CJabberProto::FtHandleBytestreamRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_BYTESTREAMS, FALSE, L"query");
+ AddPermanentHandler(&CJabberProto::FtHandleBytestreamRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_BYTESTREAMS, FALSE, "query");
// session initiation (XEP-0095)
- AddPermanentHandler(&CJabberProto::OnSiRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_SI, FALSE, L"si");
+ AddPermanentHandler(&CJabberProto::OnSiRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_SI, FALSE, "si");
// roster push requests
- AddPermanentHandler(&CJabberProto::OnRosterPushRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_IQ_ROSTER, FALSE, L"query");
+ AddPermanentHandler(&CJabberProto::OnRosterPushRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_IQ_ROSTER, FALSE, "query");
// OOB file transfers
- AddPermanentHandler(&CJabberProto::OnIqRequestOOB, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_OOB, FALSE, L"query");
+ AddPermanentHandler(&CJabberProto::OnIqRequestOOB, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_OOB, FALSE, "query");
// disco#items requests (XEP-0030, XEP-0050)
- AddPermanentHandler(&CJabberProto::OnHandleDiscoItemsRequest, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_DISCO_ITEMS, FALSE, L"query");
+ AddPermanentHandler(&CJabberProto::OnHandleDiscoItemsRequest, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_DISCO_ITEMS, FALSE, "query");
// disco#info requests (XEP-0030, XEP-0050, XEP-0115)
- AddPermanentHandler(&CJabberProto::OnHandleDiscoInfoRequest, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_DISCO_INFO, FALSE, L"query");
+ AddPermanentHandler(&CJabberProto::OnHandleDiscoInfoRequest, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_DISCO_INFO, FALSE, "query");
// ad-hoc commands (XEP-0050) for remote controlling (XEP-0146)
- AddPermanentHandler(&CJabberProto::HandleAdhocCommandRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_COMMANDS, FALSE, L"command");
+ AddPermanentHandler(&CJabberProto::HandleAdhocCommandRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_COMMANDS, FALSE, "command");
// http auth (XEP-0070)
- AddPermanentHandler(&CJabberProto::OnIqHttpAuth, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_HTTP_AUTH, FALSE, L"confirm");
+ AddPermanentHandler(&CJabberProto::OnIqHttpAuth, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, JABBER_FEAT_HTTP_AUTH, FALSE, "confirm");
}
void __cdecl CJabberProto::ExpirerThread(void* pParam)
@@ -171,7 +171,7 @@ void CJabberIqManager::ExpireInfo(CJabberIqInfo *pInfo) if ((pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_HCONTACT) && (pInfo->m_szFrom))
pInfo->m_hContact = ppro->HContactFromJID(pInfo->m_szFrom);
- ppro->debugLogW(L"Expiring iq id %d, sent to %s", pInfo->m_nIqId, pInfo->m_szReceiver ? pInfo->m_szReceiver : L"server");
+ ppro->debugLogW(L"Expiring iq id %d, sent to %s", pInfo->m_nIqId, pInfo->m_szReceiver ? pInfo->m_szReceiver : "server");
pInfo->m_nIqType = JABBER_IQ_TYPE_FAIL;
(ppro->*(pInfo->m_pHandler))(nullptr, pInfo);
@@ -201,7 +201,7 @@ void CJabberIqManager::ExpireAll() ExpireInfo(pInfo);
}
-CJabberIqInfo* CJabberIqManager::AddHandler(JABBER_IQ_HANDLER pHandler, int nIqType, const wchar_t *szReceiver, DWORD dwParamsToParse, int nIqId, void *pUserData, int iPriority)
+CJabberIqInfo* CJabberIqManager::AddHandler(JABBER_IQ_HANDLER pHandler, int nIqType, const char *szReceiver, DWORD dwParamsToParse, int nIqId, void *pUserData, int iPriority)
{
CJabberIqInfo *pInfo = new CJabberIqInfo();
pInfo->m_pHandler = pHandler;
@@ -238,19 +238,19 @@ bool CJabberIqManager::DeleteHandler(CJabberIqInfo *pInfo) return false;
}
-bool CJabberIqManager::HandleIq(int nIqId, HXML pNode)
+bool CJabberIqManager::HandleIq(int nIqId, const TiXmlElement *pNode)
{
if (nIqId == -1 || pNode == nullptr)
return false;
- const wchar_t *szType = XmlGetAttrValue(pNode, L"type");
+ const char *szType = pNode->Attribute("type");
if (!szType)
return false;
int nIqType = JABBER_IQ_TYPE_FAIL;
- if (!mir_wstrcmpi(szType, L"result"))
+ if (!mir_strcmpi(szType, "result"))
nIqType = JABBER_IQ_TYPE_RESULT;
- else if (!mir_wstrcmpi(szType, L"error"))
+ else if (!mir_strcmpi(szType, "error"))
nIqType = JABBER_IQ_TYPE_ERROR;
else
return false;
@@ -263,24 +263,24 @@ bool CJabberIqManager::HandleIq(int nIqId, HXML pNode) pInfo->m_nIqType = nIqType;
if (nIqType == JABBER_IQ_TYPE_RESULT) {
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_CHILD_TAG_NODE)
- pInfo->m_pChildNode = XmlGetChild(pNode, 0);
+ pInfo->m_pChildNode = pNode->FirstChildElement();
if (pInfo->m_pChildNode && (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_CHILD_TAG_NAME))
- pInfo->m_szChildTagName = (wchar_t*)XmlGetName(pInfo->m_pChildNode);
+ pInfo->m_szChildTagName = pInfo->m_pChildNode->Name();
if (pInfo->m_pChildNode && (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_CHILD_TAG_XMLNS))
- pInfo->m_szChildTagXmlns = (wchar_t*)XmlGetAttrValue(pNode, L"xmlns");
+ pInfo->m_szChildTagXmlns = pNode->Attribute("xmlns");
}
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_TO)
- pInfo->m_szTo = (wchar_t*)XmlGetAttrValue(pNode, L"to");
+ pInfo->m_szTo = pNode->Attribute("to");
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_FROM)
- pInfo->m_szFrom = (wchar_t*)XmlGetAttrValue(pNode, L"from");
+ pInfo->m_szFrom = pNode->Attribute("from");
if (pInfo->m_szFrom && (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_HCONTACT))
pInfo->m_hContact = ppro->HContactFromJID(pInfo->m_szFrom);
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_ID_STR)
- pInfo->m_szId = (wchar_t*)XmlGetAttrValue(pNode, L"id");
+ pInfo->m_szId = pNode->Attribute("id");
(ppro->*(pInfo->m_pHandler))(pNode, pInfo);
delete pInfo;
@@ -289,19 +289,19 @@ bool CJabberIqManager::HandleIq(int nIqId, HXML pNode) return true;
}
-bool CJabberIqManager::HandleIqPermanent(HXML pNode)
+bool CJabberIqManager::HandleIqPermanent(const TiXmlElement *pNode)
{
for (auto &pInfo : m_arHandlers) {
// have to get all data here, in the loop, because there's always possibility that previous handler modified it
- const wchar_t *szType = XmlGetAttrValue(pNode, L"type");
+ const char *szType = pNode->Attribute("type");
if (!szType)
return FALSE;
CJabberIqInfo iqInfo;
iqInfo.m_nIqType = JABBER_IQ_TYPE_FAIL;
- if (!mir_wstrcmpi(szType, L"get"))
+ if (!mir_strcmpi(szType, "get"))
iqInfo.m_nIqType = JABBER_IQ_TYPE_GET;
- else if (!mir_wstrcmpi(szType, L"set"))
+ else if (!mir_strcmpi(szType, "set"))
iqInfo.m_nIqType = JABBER_IQ_TYPE_SET;
else
return FALSE;
@@ -309,27 +309,27 @@ bool CJabberIqManager::HandleIqPermanent(HXML pNode) if (!(pInfo->m_nIqTypes & iqInfo.m_nIqType))
continue;
- HXML pFirstChild = XmlGetChild(pNode, 0);
- if (!pFirstChild || !XmlGetName(pFirstChild))
+ auto *pFirstChild = pNode->FirstChildElement();
+ if (!pFirstChild || !pFirstChild->Name())
return FALSE;
- const wchar_t *szTagName = XmlGetName(pFirstChild);
- const wchar_t *szXmlns = XmlGetAttrValue(pFirstChild, L"xmlns");
+ const char *szTagName = pFirstChild->Name();
+ const char *szXmlns = pFirstChild->Attribute("xmlns");
- if ((!pInfo->m_szXmlns || (szXmlns && !mir_wstrcmp(pInfo->m_szXmlns, szXmlns))) &&
- (!pInfo->m_szTag || !mir_wstrcmp(pInfo->m_szTag, szTagName))) {
+ if ((!pInfo->m_szXmlns || (szXmlns && !mir_strcmp(pInfo->m_szXmlns, szXmlns))) &&
+ (!pInfo->m_szTag || !mir_strcmp(pInfo->m_szTag, szTagName))) {
// node suits handler criteria, call the handler
iqInfo.m_pChildNode = pFirstChild;
- iqInfo.m_szChildTagName = (wchar_t*)szTagName;
- iqInfo.m_szChildTagXmlns = (wchar_t*)szXmlns;
- iqInfo.m_szId = (wchar_t*)XmlGetAttrValue(pNode, L"id");
+ iqInfo.m_szChildTagName = szTagName;
+ iqInfo.m_szChildTagXmlns = szXmlns;
+ iqInfo.m_szId = pNode->Attribute("id");
iqInfo.m_pUserData = pInfo->m_pUserData;
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_TO)
- iqInfo.m_szTo = (wchar_t*)XmlGetAttrValue(pNode, L"to");
+ iqInfo.m_szTo = pNode->Attribute("to");
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_FROM)
- iqInfo.m_szFrom = (wchar_t*)XmlGetAttrValue(pNode, L"from");
+ iqInfo.m_szFrom = pNode->Attribute("from");
if ((pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_HCONTACT) && (iqInfo.m_szFrom))
iqInfo.m_hContact = ppro->HContactFromJID(iqInfo.m_szFrom);
@@ -394,9 +394,9 @@ CJabberIqPermanentInfo* CJabberIqManager::AddPermanentHandler( JABBER_PERMANENT_IQ_HANDLER pHandler,
int nIqTypes,
DWORD dwParamsToParse,
- const wchar_t *szXmlns,
+ const char *szXmlns,
BOOL bAllowPartialNs,
- const wchar_t *szTag,
+ const char *szTag,
void *pUserData,
IQ_USER_DATA_FREE_FUNC pUserDataFree,
int iPriority)
@@ -404,9 +404,9 @@ CJabberIqPermanentInfo* CJabberIqManager::AddPermanentHandler( CJabberIqPermanentInfo *pInfo = new CJabberIqPermanentInfo();
pInfo->m_pHandler = pHandler;
pInfo->m_nIqTypes = nIqTypes ? nIqTypes : JABBER_IQ_TYPE_ANY;
- pInfo->m_szXmlns = mir_wstrdup(szXmlns);
+ pInfo->m_szXmlns = mir_strdup(szXmlns);
pInfo->m_bAllowPartialNs = bAllowPartialNs;
- pInfo->m_szTag = mir_wstrdup(szTag);
+ pInfo->m_szTag = mir_strdup(szTag);
pInfo->m_dwParamsToParse = dwParamsToParse;
pInfo->m_pUserData = pUserData;
pInfo->m_pUserDataFree = pUserDataFree;
|