summaryrefslogtreecommitdiff
path: root/protocols/JabberG
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-10-02 20:37:58 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-10-02 20:37:58 +0000
commit681126055acd747349453a57bbed6624420e0c6e (patch)
tree853d5ae4e303cfe9951c10de9e9a8cb9fbcfe314 /protocols/JabberG
parentbed8dcfa17b2f9de35a145826c2a4201e6daff13 (diff)
Jabber IQ handlers: ability to handle the same packet by two or more handlers
git-svn-id: http://svn.miranda-ng.org/main/trunk@6314 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG')
-rw-r--r--protocols/JabberG/src/jabber_ft.cpp14
-rw-r--r--protocols/JabberG/src/jabber_iq.cpp16
-rw-r--r--protocols/JabberG/src/jabber_svc.cpp105
3 files changed, 64 insertions, 71 deletions
diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp
index 99cbc79b70..2bf763e775 100644
--- a/protocols/JabberG/src/jabber_ft.cpp
+++ b/protocols/JabberG/src/jabber_ft.cpp
@@ -30,19 +30,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void CJabberProto::FtCancel(filetransfer *ft)
{
- JABBER_LIST_ITEM *item;
- JABBER_BYTE_TRANSFER *jbt;
- JABBER_IBB_TRANSFER *jibb;
-
Log("Invoking JabberFtCancel()");
// For file sending session that is still in si negotiation phase
if (m_iqManager.ExpireByUserData(ft))
return;
+
// For file receiving session that is still in si negotiation phase
LISTFOREACH(i, this, LIST_FTRECV)
{
- item = ListGetItemPtrFromIndex(i);
+ JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i);
if (item->ft == ft) {
Log("Canceling file receiving session while in si negotiation");
ListRemoveByIndex(i);
@@ -52,7 +49,8 @@ void CJabberProto::FtCancel(filetransfer *ft)
}
}
// For file transfer through bytestream
- if ((jbt=ft->jbt) != NULL) {
+ JABBER_BYTE_TRANSFER *jbt = ft->jbt;
+ if (jbt != NULL) {
Log("Canceling bytestream session");
jbt->state = JBT_ERROR;
if (jbt->hConn) {
@@ -64,8 +62,10 @@ void CJabberProto::FtCancel(filetransfer *ft)
if (jbt->hEvent) SetEvent(jbt->hEvent);
if (jbt->hProxyEvent) SetEvent(jbt->hProxyEvent);
}
+
// For file transfer through IBB
- if ((jibb=ft->jibb) != NULL) {
+ JABBER_IBB_TRANSFER *jibb = ft->jibb;
+ if (jibb != NULL) {
Log("Canceling IBB session");
jibb->state = JIBB_ERROR;
m_iqManager.ExpireByUserData(jibb);
diff --git a/protocols/JabberG/src/jabber_iq.cpp b/protocols/JabberG/src/jabber_iq.cpp
index 6af37f07a3..e5dbecfe31 100644
--- a/protocols/JabberG/src/jabber_iq.cpp
+++ b/protocols/JabberG/src/jabber_iq.cpp
@@ -185,8 +185,11 @@ BOOL CJabberIqManager::ExpireIq(int nIqId)
{
CJabberIqInfo *pInfo = DetachInfo(nIqId);
if (pInfo) {
- ExpireInfo(pInfo);
- delete pInfo;
+ do {
+ ExpireInfo(pInfo);
+ delete pInfo;
+ }
+ while ((pInfo = DetachInfo(nIqId)) != NULL);
return TRUE;
}
return FALSE;
@@ -263,7 +266,10 @@ BOOL CJabberIqManager::HandleIq(int nIqId, HXML pNode)
return FALSE;
CJabberIqInfo *pInfo = DetachInfo(nIqId);
- if (pInfo) {
+ if (pInfo == NULL)
+ return FALSE;
+
+ do {
pInfo->m_nIqType = nIqType;
if (nIqType == JABBER_IQ_TYPE_RESULT) {
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_CHILD_TAG_NODE)
@@ -288,9 +294,9 @@ BOOL CJabberIqManager::HandleIq(int nIqId, HXML pNode)
(ppro->*(pInfo->m_pHandler))(pNode, pInfo);
delete pInfo;
- return TRUE;
}
- return FALSE;
+ while ((pInfo = DetachInfo(nIqId)) != NULL);
+ return TRUE;
}
BOOL CJabberIqManager::HandleIqPermanent(HXML pNode)
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp
index 6fe92b789f..cbbc811759 100644
--- a/protocols/JabberG/src/jabber_svc.cpp
+++ b/protocols/JabberG/src/jabber_svc.cpp
@@ -129,7 +129,7 @@ INT_PTR __cdecl CJabberProto::JabberGetAvatarInfo(WPARAM wParam, LPARAM lParam)
return GAIR_NOAVATAR;
}
- TCHAR tszFileName[ MAX_PATH ];
+ TCHAR tszFileName[MAX_PATH];
GetAvatarFileName(AI->hContact, tszFileName, SIZEOF(tszFileName));
_tcsncpy(AI->filename, tszFileName, SIZEOF(AI->filename));
@@ -159,13 +159,11 @@ INT_PTR __cdecl CJabberProto::JabberGetAvatarInfo(WPARAM wParam, LPARAM lParam)
Log("Rereading %s for %S", isXVcard ? JABBER_FEAT_VCARD_TEMP : JABBER_FEAT_AVATAR, szJid);
- XmlNodeIq iq(
- AddIQ((isXVcard) ? &CJabberProto::OnIqResultGetVCardAvatar : &CJabberProto::OnIqResultGetClientAvatar,
- JABBER_IQ_TYPE_GET, szJid));
+ HXML iq;
if (isXVcard)
- iq << XCHILDNS(_T("vCard"), JABBER_FEAT_VCARD_TEMP);
+ iq = XmlNodeIq( AddIQ(&CJabberProto::OnIqResultGetVCardAvatar, JABBER_IQ_TYPE_GET, szJid)) << XCHILDNS(_T("vCard"), JABBER_FEAT_VCARD_TEMP);
else
- iq << XQUERY(isXVcard ? _T("") : JABBER_FEAT_AVATAR);
+ iq = XmlNodeIq( AddIQ(&CJabberProto::OnIqResultGetClientAvatar, JABBER_IQ_TYPE_GET, szJid)) << XQUERY(JABBER_FEAT_AVATAR);
m_ThreadInfo->send(iq);
db_free(&dbv);
@@ -210,56 +208,48 @@ INT_PTR __cdecl CJabberProto::OnGetEventTextPresence(WPARAM, LPARAM lParam)
INT_PTR nRetVal = 0;
if (pdbEvent->dbei->cbBlob > 0) {
- switch (pdbEvent->dbei->pBlob[0])
- {
+ switch (pdbEvent->dbei->pBlob[0]) {
case JABBER_DB_EVENT_PRESENCE_SUBSCRIBE:
- {
- if (pdbEvent->datatype == DBVT_WCHAR)
- nRetVal = (INT_PTR)mir_tstrdup(TranslateTS(_T("sent subscription request")));
- else if (pdbEvent->datatype == DBVT_ASCIIZ)
- nRetVal = (INT_PTR)mir_strdup(Translate("sent subscription request"));
- break;
- }
+ if (pdbEvent->datatype == DBVT_WCHAR)
+ nRetVal = (INT_PTR)mir_tstrdup(TranslateTS(_T("sent subscription request")));
+ else if (pdbEvent->datatype == DBVT_ASCIIZ)
+ nRetVal = (INT_PTR)mir_strdup(Translate("sent subscription request"));
+ break;
+
case JABBER_DB_EVENT_PRESENCE_SUBSCRIBED:
- {
- if (pdbEvent->datatype == DBVT_WCHAR)
- nRetVal = (INT_PTR)mir_tstrdup(TranslateTS(_T("approved subscription request")));
- else if (pdbEvent->datatype == DBVT_ASCIIZ)
- nRetVal = (INT_PTR)mir_strdup(Translate("approved subscription request"));
- break;
- }
+ if (pdbEvent->datatype == DBVT_WCHAR)
+ nRetVal = (INT_PTR)mir_tstrdup(TranslateTS(_T("approved subscription request")));
+ else if (pdbEvent->datatype == DBVT_ASCIIZ)
+ nRetVal = (INT_PTR)mir_strdup(Translate("approved subscription request"));
+ break;
+
case JABBER_DB_EVENT_PRESENCE_UNSUBSCRIBE:
- {
- if (pdbEvent->datatype == DBVT_WCHAR)
- nRetVal = (INT_PTR)mir_tstrdup(TranslateTS(_T("declined subscription")));
- else if (pdbEvent->datatype == DBVT_ASCIIZ)
- nRetVal = (INT_PTR)mir_strdup(Translate("declined subscription"));
- break;
- }
+ if (pdbEvent->datatype == DBVT_WCHAR)
+ nRetVal = (INT_PTR)mir_tstrdup(TranslateTS(_T("declined subscription")));
+ else if (pdbEvent->datatype == DBVT_ASCIIZ)
+ nRetVal = (INT_PTR)mir_strdup(Translate("declined subscription"));
+ break;
+
case JABBER_DB_EVENT_PRESENCE_UNSUBSCRIBED:
- {
- if (pdbEvent->datatype == DBVT_WCHAR)
- nRetVal = (INT_PTR)mir_tstrdup(TranslateTS(_T("declined subscription")));
- else if (pdbEvent->datatype == DBVT_ASCIIZ)
- nRetVal = (INT_PTR)mir_strdup(Translate("declined subscription"));
- break;
- }
+ if (pdbEvent->datatype == DBVT_WCHAR)
+ nRetVal = (INT_PTR)mir_tstrdup(TranslateTS(_T("declined subscription")));
+ else if (pdbEvent->datatype == DBVT_ASCIIZ)
+ nRetVal = (INT_PTR)mir_strdup(Translate("declined subscription"));
+ break;
+
case JABBER_DB_EVENT_PRESENCE_ERROR:
- {
- if (pdbEvent->datatype == DBVT_WCHAR)
- nRetVal = (INT_PTR)mir_tstrdup(TranslateTS(_T("sent error presence")));
- else if (pdbEvent->datatype == DBVT_ASCIIZ)
- nRetVal = (INT_PTR)mir_strdup(Translate("sent error presence"));
- break;
- }
+ if (pdbEvent->datatype == DBVT_WCHAR)
+ nRetVal = (INT_PTR)mir_tstrdup(TranslateTS(_T("sent error presence")));
+ else if (pdbEvent->datatype == DBVT_ASCIIZ)
+ nRetVal = (INT_PTR)mir_strdup(Translate("sent error presence"));
+ break;
+
default:
- {
- if (pdbEvent->datatype == DBVT_WCHAR)
- nRetVal = (INT_PTR)mir_tstrdup(TranslateTS(_T("sent unknown presence type")));
- else if (pdbEvent->datatype == DBVT_ASCIIZ)
- nRetVal = (INT_PTR)mir_strdup(Translate("sent unknown presence type"));
- break;
- }
+ if (pdbEvent->datatype == DBVT_WCHAR)
+ nRetVal = (INT_PTR)mir_tstrdup(TranslateTS(_T("sent unknown presence type")));
+ else if (pdbEvent->datatype == DBVT_ASCIIZ)
+ nRetVal = (INT_PTR)mir_strdup(Translate("sent unknown presence type"));
+ break;
}
}
@@ -338,7 +328,7 @@ INT_PTR __cdecl CJabberProto::JabberSetAvatar(WPARAM, LPARAM lParam)
INT_PTR __cdecl CJabberProto::JabberSetNickname(WPARAM wParam, LPARAM lParam)
{
- TCHAR *nickname = (wParam & SMNN_UNICODE) ? mir_u2t((WCHAR *) lParam) : mir_a2t((char *) lParam);
+ TCHAR *nickname = (wParam & SMNN_UNICODE) ? mir_u2t((WCHAR*)lParam) : mir_a2t((char*)lParam);
setTString("Nick", nickname);
SetServerVcard(FALSE, _T(""));
@@ -356,8 +346,8 @@ INT_PTR __cdecl CJabberProto::ServiceSendXML(WPARAM, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////
// "/GCGetToolTipText" - gets tooltip text
-static const TCHAR * JabberEnum2AffilationStr[]={ _T("None"), _T("Outcast"), _T("Member"), _T("Admin"), _T("Owner") };
-static const TCHAR * JabberEnum2RoleStr[]={ _T("None"), _T("Visitor"), _T("Participant"), _T("Moderator") };
+static const TCHAR *JabberEnum2AffilationStr[] = { _T("None"), _T("Outcast"), _T("Member"), _T("Admin"), _T("Owner") };
+static const TCHAR *JabberEnum2RoleStr[] = { _T("None"), _T("Visitor"), _T("Participant"), _T("Moderator") };
static void appendString(bool bIsTipper, const TCHAR *tszTitle, const TCHAR *tszValue, TCHAR* buf, size_t bufSize)
{
@@ -440,13 +430,10 @@ INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI(WPARAM wParam, LPARAM lP
if (arg == NULL)
return 1;
- TCHAR szUri[ 1024 ];
- mir_sntprintf(szUri, SIZEOF(szUri), _T("%s"), arg);
-
- TCHAR *szJid = szUri;
-
// skip leading prefix
- szJid = _tcschr(szJid, _T(':'));
+ TCHAR szUri[ 1024 ];
+ _tcsncpy_s(szUri, SIZEOF(szUri), arg, _TRUNCATE);
+ TCHAR *szJid = _tcschr(szUri, _T(':'));
if (szJid == NULL)
return 1;