diff options
author | George Hazan <george.hazan@gmail.com> | 2013-12-28 10:41:49 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-12-28 10:41:49 +0000 |
commit | a99d11e809f81a74ae186750d65ff77f7aa2e376 (patch) | |
tree | 21ab0589f3cea5bc4dd704b1afd122403c3d005f /protocols/JabberG | |
parent | d2d076e523b7a5a10507fba40f58543a386dbec0 (diff) |
correct XEP-0249 support (missing caps for jabber:x:conference)
git-svn-id: http://svn.miranda-ng.org/main/trunk@7405 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG')
-rw-r--r-- | protocols/JabberG/src/jabber_caps.cpp | 1 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_caps.h | 15 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_chat.cpp | 4 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_thread.cpp | 75 |
4 files changed, 52 insertions, 43 deletions
diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp index f38a6f9dd7..ac71cdd416 100644 --- a/protocols/JabberG/src/jabber_caps.cpp +++ b/protocols/JabberG/src/jabber_caps.cpp @@ -74,6 +74,7 @@ const JabberFeatCapPair g_JabberFeatCapPairs[] = { { JABBER_FEAT_MIRANDA_NOTES, JABBER_CAPS_MIRANDA_NOTES, LPGENT("Supports Miranda NG notes extension") },
{ JABBER_FEAT_JINGLE, JABBER_CAPS_JINGLE, LPGENT("Supports Jingle") },
{ JABBER_FEAT_ROSTER_EXCHANGE, JABBER_CAPS_ROSTER_EXCHANGE, LPGENT("Supports Roster Exchange") },
+ { JABBER_FEAT_DIRECT_MUC_INVITE, JABBER_CAPS_DIRECT_MUC_INVITE, LPGENT("Supports direct chat invitations (XEP-0249)") },
{ NULL, 0, NULL }
};
diff --git a/protocols/JabberG/src/jabber_caps.h b/protocols/JabberG/src/jabber_caps.h index e5e8c4e6da..20a04452c1 100644 --- a/protocols/JabberG/src/jabber_caps.h +++ b/protocols/JabberG/src/jabber_caps.h @@ -146,16 +146,25 @@ typedef unsigned __int64 JabberCapsBits; #define JABBER_FEAT_ROSTER_EXCHANGE _T("http://jabber.org/protocol/rosterx")
#define JABBER_CAPS_ROSTER_EXCHANGE ((JabberCapsBits)1<<40)
+#define JABBER_FEAT_DIRECT_MUC_INVITE _T("jabber:x:conference")
+#define JABBER_CAPS_DIRECT_MUC_INVITE ((JabberCapsBits)1<<41)
+
#define JABBER_FEAT_PUBSUB_EVENT _T("http://jabber.org/protocol/pubsub#event")
#define JABBER_FEAT_PUBSUB_NODE_CONFIG _T("http://jabber.org/protocol/pubsub#node_config")
#define JABBER_CAPS_MESSAGE_EVENTS_NO_DELIVERY ((JabberCapsBits)1<<62)
#define JABBER_CAPS_OTHER_SPECIAL (JABBER_CAPS_MESSAGE_EVENTS_NO_DELIVERY|JABBER_RESOURCE_CAPS_ERROR) // must contain all the caps not listed in g_JabberFeatCapPairs, to prevent using these bits for features registered through IJabberNetInterface::RegisterFeature()
-#define JABBER_CAPS_MIRANDA_NODE _T("http://miranda-ng.org/caps")
-#define JABBER_CAPS_MIRANDA_ALL (JABBER_CAPS_DISCO_INFO|JABBER_CAPS_DISCO_ITEMS|JABBER_CAPS_MUC|JABBER_CAPS_ENTITY_CAPS|JABBER_CAPS_SI|JABBER_CAPS_SI_FT|JABBER_CAPS_BYTESTREAMS|JABBER_CAPS_IBB|JABBER_CAPS_OOB|JABBER_CAPS_CHATSTATES|JABBER_CAPS_AGENTS|JABBER_CAPS_BROWSE|JABBER_CAPS_VERSION|JABBER_CAPS_LAST_ACTIVITY|JABBER_CAPS_DATA_FORMS|JABBER_CAPS_MESSAGE_EVENTS|JABBER_CAPS_VCARD_TEMP|JABBER_CAPS_ENTITY_TIME|JABBER_CAPS_PING|JABBER_CAPS_PRIVACY_LISTS|JABBER_CAPS_MESSAGE_RECEIPTS|JABBER_CAPS_PRIVATE_STORAGE|JABBER_CAPS_ATTENTION_0|JABBER_CAPS_JINGLE|JABBER_CAPS_ROSTER_EXCHANGE|JABBER_CAPS_SECUREIM|JABBER_CAPS_MIROTR|JABBER_CAPS_NEWGPG|JABBER_CAPS_COMMANDS|JABBER_CAPS_USER_MOOD_NOTIFY|JABBER_CAPS_USER_TUNE_NOTIFY|JABBER_CAPS_USER_ACTIVITY_NOTIFY|JABBER_CAPS_PLATFORMX86|JABBER_CAPS_PLATFORMX64)
+#define JABBER_CAPS_MIRANDA_NODE _T("http://miranda-ng.org/caps")
+#define JABBER_CAPS_MIRANDA_PARTIAL (JABBER_CAPS_DISCO_INFO | JABBER_CAPS_DISCO_ITEMS | JABBER_CAPS_MUC | JABBER_CAPS_ENTITY_CAPS | JABBER_CAPS_SI | JABBER_CAPS_SI_FT | \
+ JABBER_CAPS_BYTESTREAMS | JABBER_CAPS_IBB | JABBER_CAPS_OOB | JABBER_CAPS_CHATSTATES | JABBER_CAPS_AGENTS | JABBER_CAPS_BROWSE | \
+ JABBER_CAPS_VERSION | JABBER_CAPS_LAST_ACTIVITY | JABBER_CAPS_DATA_FORMS | JABBER_CAPS_MESSAGE_EVENTS | JABBER_CAPS_VCARD_TEMP | \
+ JABBER_CAPS_ENTITY_TIME | JABBER_CAPS_PING | JABBER_CAPS_PRIVACY_LISTS | JABBER_CAPS_MESSAGE_RECEIPTS | JABBER_CAPS_PRIVATE_STORAGE | \
+ JABBER_CAPS_ATTENTION_0 | JABBER_CAPS_JINGLE | JABBER_CAPS_ROSTER_EXCHANGE | JABBER_CAPS_DIRECT_MUC_INVITE)
+
+#define JABBER_CAPS_MIRANDA_ALL (JABBER_CAPS_MIRANDA_PARTIAL | JABBER_CAPS_SECUREIM | JABBER_CAPS_MIROTR | JABBER_CAPS_NEWGPG | JABBER_CAPS_COMMANDS | \
+ JABBER_CAPS_USER_MOOD_NOTIFY | JABBER_CAPS_USER_TUNE_NOTIFY | JABBER_CAPS_USER_ACTIVITY_NOTIFY | JABBER_CAPS_PLATFORMX86 | JABBER_CAPS_PLATFORMX64)
-#define JABBER_CAPS_MIRANDA_PARTIAL (JABBER_CAPS_DISCO_INFO|JABBER_CAPS_DISCO_ITEMS|JABBER_CAPS_MUC|JABBER_CAPS_ENTITY_CAPS|JABBER_CAPS_SI|JABBER_CAPS_SI_FT|JABBER_CAPS_BYTESTREAMS|JABBER_CAPS_IBB|JABBER_CAPS_OOB|JABBER_CAPS_CHATSTATES|JABBER_CAPS_AGENTS|JABBER_CAPS_BROWSE|JABBER_CAPS_VERSION|JABBER_CAPS_LAST_ACTIVITY|JABBER_CAPS_DATA_FORMS|JABBER_CAPS_MESSAGE_EVENTS|JABBER_CAPS_VCARD_TEMP|JABBER_CAPS_ENTITY_TIME|JABBER_CAPS_PING|JABBER_CAPS_PRIVACY_LISTS|JABBER_CAPS_MESSAGE_RECEIPTS|JABBER_CAPS_PRIVATE_STORAGE|JABBER_CAPS_ATTENTION_0|JABBER_CAPS_JINGLE|JABBER_CAPS_ROSTER_EXCHANGE)
#define JABBER_EXT_SECUREIM "secureim"
#define JABBER_EXT_MIROTR "mirotr"
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index a4aa2d292d..a0041a3cec 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -1201,7 +1201,7 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* }
}
- if ( !szInviteTo) break;
+ if (!szInviteTo) break;
mir_sntprintf(szTitle, SIZEOF(szTitle), TranslateT("Invite %s to %s"), him->m_tszResourceName, szInviteTo);
*szBuffer = 0;
@@ -1213,7 +1213,7 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* XmlNode msg(_T("message"));
HXML invite = msg << XATTR(_T("to"), szTitle) << XATTRID(ppro->SerialNext())
<< XCHILD(_T("x"), szBuffer)
- << XATTR(_T("xmlns"), _T("jabber:x:conference"))
+ << XATTR(_T("xmlns"), JABBER_FEAT_DIRECT_MUC_INVITE)
<< XATTR(_T("jid"), szInviteTo)
<< XCHILD(_T("invite")) << XATTR(_T("from"), item->nick);
ppro->m_ThreadInfo->send(msg);
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 1e4d068847..957ab6cb00 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -1161,12 +1161,12 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData* info) item = ListGetItemPtr(LIST_VCARD_TEMP, from);
time_t msgTime = 0;
- BOOL isChatRoomInvitation = FALSE;
+ bool isChatRoomInvitation = false;
const TCHAR *inviteRoomJid = NULL;
const TCHAR *inviteFromJid = NULL;
const TCHAR *inviteReason = NULL;
const TCHAR *invitePassword = NULL;
- BOOL delivered = FALSE;
+ bool isDelivered = false;
// check chatstates availability
if (pFromResource && xmlGetChildByTag(node, "active", "xmlns", JABBER_FEAT_CHATSTATES))
@@ -1286,29 +1286,29 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData* info) // pFromResource->m_jcbManualDiscoveredCaps |= (JABBER_CAPS_MESSAGE_EVENTS | JABBER_CAPS_MESSAGE_EVENTS_NO_DELIVERY);
if (bodyNode == NULL) {
- HXML idNode = xmlGetChild(xNode , "id");
- if (xmlGetChild(xNode , "delivered") != NULL || xmlGetChild(xNode , "offline") != NULL) {
+ HXML idNode = xmlGetChild(xNode, "id");
+ if (xmlGetChild(xNode, "delivered") != NULL || xmlGetChild(xNode, "offline") != NULL) {
int id = -1;
if (idNode != NULL && xmlGetText(idNode) != NULL)
- if ( !_tcsncmp(xmlGetText(idNode), _T(JABBER_IQID), strlen(JABBER_IQID)))
- id = _ttoi((xmlGetText(idNode))+strlen(JABBER_IQID));
+ if (!_tcsncmp(xmlGetText(idNode), _T(JABBER_IQID), strlen(JABBER_IQID)))
+ id = _ttoi((xmlGetText(idNode)) + strlen(JABBER_IQID));
if (id != -1)
ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)id, 0);
}
- if (hContact && xmlGetChild(xNode , "composing") != NULL)
+ if (hContact && xmlGetChild(xNode, "composing") != NULL)
CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact, 60);
// Maybe a cancel to the previous composing
- HXML child = xmlGetChild(xNode ,0);
+ HXML child = xmlGetChild(xNode, 0);
if (hContact && (!child || (child && idNode != NULL)))
CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact, PROTOTYPE_CONTACTTYPING_OFF);
}
else {
// Check whether any event is requested
- if ( !delivered && (n = xmlGetChild(xNode , "delivered")) != NULL) {
- delivered = TRUE;
+ if (!isDelivered && (n = xmlGetChild(xNode, "delivered")) != NULL) {
+ isDelivered = true;
XmlNode m(_T("message")); m << XATTR(_T("to"), from);
HXML x = m << XCHILDNS(_T("x"), JABBER_FEAT_MESSAGE_EVENTS);
@@ -1316,17 +1316,18 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData* info) x << XCHILD(_T("id"), idStr);
info->send(m);
}
- if (item != NULL && xmlGetChild(xNode , "composing") != NULL) {
+ if (item != NULL && xmlGetChild(xNode, "composing") != NULL) {
if (item->messageEventIdStr)
mir_free(item->messageEventIdStr);
- item->messageEventIdStr = (idStr == NULL)?NULL:mir_tstrdup(idStr);
- } }
+ item->messageEventIdStr = (idStr == NULL) ? NULL : mir_tstrdup(idStr);
+ }
+ }
}
- else if ( !_tcscmp(ptszXmlns, JABBER_FEAT_OOB2)) {
- LPCTSTR ptszUrl = xmlGetText( xmlGetChild(xNode , "url"));
+ else if (!_tcscmp(ptszXmlns, JABBER_FEAT_OOB2)) {
+ LPCTSTR ptszUrl = xmlGetText(xmlGetChild(xNode, "url"));
if (ptszUrl != NULL && *ptszUrl) {
size_t cbLen = (szMessage ? _tcslen(szMessage) : 0) + _tcslen(ptszUrl) + 32;
- TCHAR *szTmp = (TCHAR *)alloca(sizeof(TCHAR) * cbLen);
+ TCHAR *szTmp = (TCHAR *)alloca(sizeof(TCHAR)* cbLen);
_tcscpy(szTmp, ptszUrl);
if (szMessage) {
_tcscat(szTmp, _T("\r\n"));
@@ -1335,36 +1336,36 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData* info) szMessage = szTmp;
}
}
- else if ( !_tcscmp(ptszXmlns, JABBER_FEAT_MUC_USER)) {
- HXML inviteNode = xmlGetChild(xNode , _T("invite"));
+ else if (!_tcscmp(ptszXmlns, JABBER_FEAT_MUC_USER)) {
+ HXML inviteNode = xmlGetChild(xNode, _T("invite"));
if (inviteNode != NULL) {
inviteFromJid = xmlGetAttrValue(inviteNode, _T("from"));
- inviteReason = xmlGetText( xmlGetChild(inviteNode , _T("reason")));
+ inviteReason = xmlGetText(xmlGetChild(inviteNode, _T("reason")));
}
inviteRoomJid = from;
if (inviteReason == NULL)
inviteReason = szMessage;
- isChatRoomInvitation = TRUE;
- invitePassword = xmlGetText( xmlGetChild(xNode, "password"));
+ isChatRoomInvitation = true;
+ invitePassword = xmlGetText(xmlGetChild(xNode, "password"));
}
- else if ( !_tcscmp(ptszXmlns, JABBER_FEAT_ROSTER_EXCHANGE) &&
+ else if (!_tcscmp(ptszXmlns, JABBER_FEAT_ROSTER_EXCHANGE) &&
item != NULL && (item->subscription == SUB_BOTH || item->subscription == SUB_TO)) {
TCHAR chkJID[JABBER_MAX_JID_LEN] = _T("@");
JabberStripJid(from, chkJID + 1, SIZEOF(chkJID) - 1);
- for (int i = 1; ; i++) {
- HXML iNode = xmlGetNthChild(xNode , _T("item"), i);
+ for (int i = 1;; i++) {
+ HXML iNode = xmlGetNthChild(xNode, _T("item"), i);
if (iNode == NULL) break;
const TCHAR *action = xmlGetAttrValue(iNode, _T("action"));
const TCHAR *jid = xmlGetAttrValue(iNode, _T("jid"));
const TCHAR *nick = xmlGetAttrValue(iNode, _T("name"));
const TCHAR *group = xmlGetText(xmlGetChild(iNode, _T("group")));
if (action && jid && _tcsstr(jid, chkJID)) {
- if ( !_tcscmp(action, _T("add"))) {
+ if (!_tcscmp(action, _T("add"))) {
HANDLE hContact = DBCreateContact(jid, nick, FALSE, FALSE);
if (group)
db_set_ts(hContact, "CList", "Group", group);
}
- else if ( !_tcscmp(action, _T("delete"))) {
+ else if (!_tcscmp(action, _T("delete"))) {
HANDLE hContact = HContactFromJID(jid);
if (hContact)
CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
@@ -1372,14 +1373,14 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData* info) }
}
}
- else if ( !isChatRoomInvitation && !_tcscmp(ptszXmlns, _T("jabber:x:conference"))) {
+ else if (!isChatRoomInvitation && !_tcscmp(ptszXmlns, JABBER_FEAT_DIRECT_MUC_INVITE)) {
inviteRoomJid = xmlGetAttrValue(xNode, _T("jid"));
inviteFromJid = from;
if (inviteReason == NULL)
inviteReason = xmlGetText(xNode);
- if ( !inviteReason)
+ if (!inviteReason)
inviteReason = szMessage;
- isChatRoomInvitation = TRUE;
+ isChatRoomInvitation = true;
}
}
@@ -1397,8 +1398,7 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData* info) info->send(m);
*/
}
- else
- GroupchatProcessInvite(inviteRoomJid, inviteFromJid, inviteReason, invitePassword);
+ else GroupchatProcessInvite(inviteRoomJid, inviteFromJid, inviteReason, invitePassword);
}
return;
}
@@ -1410,7 +1410,7 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData* info) if ((szMessage = JabberUnixToDosT(szMessage)) == NULL)
szMessage = mir_tstrdup(_T(""));
- char* buf = mir_utf8encodeW(szMessage);
+ char *buf = mir_utf8encodeW(szMessage);
if (item != NULL) {
if (pFromResource) {
@@ -1429,7 +1429,7 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData* info) CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact, PROTOTYPE_CONTACTTYPING_OFF);
time_t now = time(NULL);
- if ( !msgTime)
+ if (!msgTime)
msgTime = now;
if (m_options.FixIncorrectTimestamps && (msgTime > now || (msgTime < (time_t)JabberGetLastContactMessageTime(hContact))))
@@ -1449,19 +1449,18 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData* info) // XEP-0115: Entity Capabilities
void CJabberProto::OnProcessPresenceCapabilites(HXML node)
{
- const TCHAR *from;
- if ((from = xmlGetAttrValue(node, _T("from"))) == NULL)
+ const TCHAR *from = xmlGetAttrValue(node, _T("from"));
+ if (from == NULL)
return;
debugLogA("presence: for jid %S", from);
- pResourceStatus r( ResourceInfoFromJID(from));
+ pResourceStatus r(ResourceInfoFromJID(from));
if (r == NULL)
return;
- HXML n;
-
// check XEP-0115 support, and old style:
+ HXML n;
if ((n = xmlGetChildByTag(node, "c", "xmlns", JABBER_FEAT_ENTITY_CAPS)) != NULL ||
(n = xmlGetChild(node, "c")) != NULL) {
const TCHAR *szNode = xmlGetAttrValue(n, _T("node"));
|