summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-10-02 19:38:44 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-10-02 19:38:44 +0000
commit8fecb411c56387ef6db40abe96b8c935fddc6083 (patch)
tree3aee9abef3610ab248bba34af1bd4878038d130f /protocols/JabberG/src
parentf7e58cf1bf50928ae22ffbdd9de99844407d5780 (diff)
atavism extincted: old nasty IQ handler mechanism
git-svn-id: http://svn.miranda-ng.org/main/trunk@6312 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/src')
-rw-r--r--protocols/JabberG/src/jabber_adhoc.cpp45
-rw-r--r--protocols/JabberG/src/jabber_agent.cpp11
-rw-r--r--protocols/JabberG/src/jabber_api.cpp2
-rw-r--r--protocols/JabberG/src/jabber_archive.cpp13
-rw-r--r--protocols/JabberG/src/jabber_bookmarks.cpp22
-rw-r--r--protocols/JabberG/src/jabber_byte.cpp11
-rw-r--r--protocols/JabberG/src/jabber_caps.cpp10
-rw-r--r--protocols/JabberG/src/jabber_chat.cpp28
-rw-r--r--protocols/JabberG/src/jabber_disco.cpp12
-rw-r--r--protocols/JabberG/src/jabber_ft.cpp2
-rw-r--r--protocols/JabberG/src/jabber_groupchat.cpp11
-rw-r--r--protocols/JabberG/src/jabber_ibb.cpp4
-rw-r--r--protocols/JabberG/src/jabber_iq.cpp80
-rw-r--r--protocols/JabberG/src/jabber_iq.h27
-rw-r--r--protocols/JabberG/src/jabber_iqid.cpp87
-rw-r--r--protocols/JabberG/src/jabber_iqid_muc.cpp14
-rw-r--r--protocols/JabberG/src/jabber_opt.cpp23
-rw-r--r--protocols/JabberG/src/jabber_password.cpp5
-rw-r--r--protocols/JabberG/src/jabber_privacy.cpp22
-rw-r--r--protocols/JabberG/src/jabber_proto.cpp36
-rw-r--r--protocols/JabberG/src/jabber_proto.h90
-rw-r--r--protocols/JabberG/src/jabber_search.cpp20
-rw-r--r--protocols/JabberG/src/jabber_svc.cpp10
-rw-r--r--protocols/JabberG/src/jabber_thread.cpp18
-rw-r--r--protocols/JabberG/src/jabber_vcard.cpp22
25 files changed, 209 insertions, 416 deletions
diff --git a/protocols/JabberG/src/jabber_adhoc.cpp b/protocols/JabberG/src/jabber_adhoc.cpp
index a7e1d5378d..704c6b663f 100644
--- a/protocols/JabberG/src/jabber_adhoc.cpp
+++ b/protocols/JabberG/src/jabber_adhoc.cpp
@@ -60,18 +60,16 @@ static BOOL CALLBACK sttDeleteChildWindowsProc(HWND hwnd, LPARAM)
return TRUE;
}
-static void sttEnableControls(HWND hwndDlg, BOOL bEnable, const int * controlsID)
+static void sttEnableControls(HWND hwndDlg, BOOL bEnable, const int *controlsID)
{
- int i=0;
- while (controlsID[i] != 0)
- EnableDlgItem(hwndDlg, controlsID[i++], bEnable);
+ for (int i=0; controlsID[i] != 0; i++)
+ EnableDlgItem(hwndDlg, controlsID[i], bEnable);
}
-static void sttShowControls(HWND hwndDlg, BOOL bShow, int * controlsID)
+static void sttShowControls(HWND hwndDlg, BOOL bShow, int *controlsID)
{
- int i=0;
- while (controlsID[i] != 0)
- ShowDlgItem(hwndDlg, controlsID[i++], (bShow) ? SW_SHOW : SW_HIDE);
+ for (int i=0; controlsID[i] != 0; i++)
+ ShowDlgItem(hwndDlg, controlsID[i], (bShow) ? SW_SHOW : SW_HIDE);
}
static void JabberAdHoc_RefreshFrameScroll(HWND hwndDlg, JabberAdHocData * dat)
@@ -92,30 +90,26 @@ static void JabberAdHoc_RefreshFrameScroll(HWND hwndDlg, JabberAdHocData * dat)
else ShowWindow(hwndScroll, SW_HIDE);
SetScrollRange(hwndScroll, SB_CTL, 0, dat->CurrentHeight-dat->frameHeight, FALSE);
-
}
//////////////////////////////////////////////////////////////////////////
// Iq handlers
// Forwards to dialog window procedure
-void CJabberProto::OnIqResult_ListOfCommands(HXML iqNode)
+void CJabberProto::OnIqResult_ListOfCommands(HXML iqNode, CJabberIqInfo*)
{
SendMessage(GetWindowFromIq(iqNode), JAHM_COMMANDLISTRESULT, 0, (LPARAM)xi.copyNode(iqNode));
}
-void CJabberProto::OnIqResult_CommandExecution(HXML iqNode)
+void CJabberProto::OnIqResult_CommandExecution(HXML iqNode, CJabberIqInfo*)
{
SendMessage(GetWindowFromIq(iqNode), JAHM_PROCESSRESULT, (WPARAM)xi.copyNode(iqNode), 0);
}
-int CJabberProto::AdHoc_RequestListOfCommands(TCHAR * szResponder, HWND hwndDlg)
+void CJabberProto::AdHoc_RequestListOfCommands(TCHAR * szResponder, HWND hwndDlg)
{
- int iqId = (int)hwndDlg;
- IqAdd(iqId, IQ_PROC_DISCOCOMMANDS, &CJabberProto::OnIqResult_ListOfCommands);
- m_ThreadInfo->send( XmlNodeIq(_T("get"), iqId, szResponder) << XQUERY(JABBER_FEAT_DISCO_ITEMS)
- << XATTR(_T("node"), JABBER_FEAT_COMMANDS));
- return iqId;
+ m_ThreadInfo->send( XmlNodeIq( AddIQ(&CJabberProto::OnIqResultGetCollectionList, JABBER_IQ_TYPE_GET, szResponder, 0, (int)hwndDlg))
+ << XQUERY(JABBER_FEAT_DISCO_ITEMS) << XATTR(_T("node"), JABBER_FEAT_COMMANDS));
}
int CJabberProto::AdHoc_ExecuteCommand(HWND hwndDlg, TCHAR*, JabberAdHocData* dat)
@@ -129,16 +123,14 @@ int CJabberProto::AdHoc_ExecuteCommand(HWND hwndDlg, TCHAR*, JabberAdHocData* da
const TCHAR *node = xmlGetAttrValue(itemNode, _T("node"));
if (node) {
const TCHAR *jid2 = xmlGetAttrValue(itemNode, _T("jid"));
-
- int iqId = (int)hwndDlg;
- IqAdd(iqId, IQ_PROC_EXECCOMMANDS, &CJabberProto::OnIqResult_CommandExecution);
m_ThreadInfo->send(
- XmlNodeIq(_T("set"), iqId, jid2)
+ XmlNodeIq( AddIQ(&CJabberProto::OnIqResult_CommandExecution, JABBER_IQ_TYPE_SET, jid2, 0, (int)hwndDlg))
<< XCHILDNS(_T("command"), JABBER_FEAT_COMMANDS) << XATTR(_T("node"), node) << XATTR(_T("action"), _T("execute")));
EnableDlgItem(hwndDlg, IDC_SUBMIT, FALSE);
SetDlgItemText(hwndDlg, IDC_SUBMIT, TranslateT("OK"));
- } }
+ }
+ }
xi.destroyNode(dat->CommandsNode); dat->CommandsNode = NULL;
return TRUE;
@@ -301,8 +293,8 @@ int CJabberProto::AdHoc_SubmitCommandForm(HWND hwndDlg, JabberAdHocData* dat, TC
HXML xNode = xmlGetChild(commandNode , "x");
HXML dataNode = JabberFormGetData(GetDlgItem(hwndDlg, IDC_FRAME), xNode);
- int iqId = (int)hwndDlg;
- XmlNodeIq iq(_T("set"), iqId, xmlGetAttrValue(dat->AdHocNode, _T("from")));
+ LPCTSTR jid2 = xmlGetAttrValue(dat->AdHocNode, _T("from"));
+ XmlNodeIq iq( AddIQ(&CJabberProto::OnIqResult_CommandExecution, JABBER_IQ_TYPE_SET, jid2, 0, (int)hwndDlg));
HXML command = iq << XCHILDNS(_T("command"), JABBER_FEAT_COMMANDS);
const TCHAR *sessionId = xmlGetAttrValue(commandNode, _T("sessionid"));
@@ -317,7 +309,6 @@ int CJabberProto::AdHoc_SubmitCommandForm(HWND hwndDlg, JabberAdHocData* dat, TC
command << XATTR(_T("action"), action);
xmlAddChild(command, dataNode);
- IqAdd(iqId, IQ_PROC_EXECCOMMANDS, &CJabberProto::OnIqResult_CommandExecution);
m_ThreadInfo->send(iq);
xi.destroyNode(dataNode);
@@ -403,10 +394,8 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA
}
else
{
- int iqId = (int)hwndDlg;
- dat->proto->IqAdd(iqId, IQ_PROC_EXECCOMMANDS, &CJabberProto::OnIqResult_CommandExecution);
dat->proto->m_ThreadInfo->send(
- XmlNodeIq(_T("set"), iqId, pStartupParams->m_szJid)
+ XmlNodeIq( dat->proto->AddIQ(&CJabberProto::OnIqResult_CommandExecution, JABBER_IQ_TYPE_SET, pStartupParams->m_szJid, 0, (int)hwndDlg))
<< XCHILDNS(_T("command"), JABBER_FEAT_COMMANDS)
<< XATTR(_T("node"), pStartupParams->m_szNode) << XATTR(_T("action"), _T("execute")));
diff --git a/protocols/JabberG/src/jabber_agent.cpp b/protocols/JabberG/src/jabber_agent.cpp
index c448cee0c7..bc0a3d7e3a 100644
--- a/protocols/JabberG/src/jabber_agent.cpp
+++ b/protocols/JabberG/src/jabber_agent.cpp
@@ -101,9 +101,9 @@ public:
SetDlgItemText(m_hwnd, IDC_SUBMIT, TranslateT("Register"));
SetDlgItemText(m_hwnd, IDC_FRAME_TEXT, TranslateT("Please wait..."));
- int iqId = m_proto->SerialNext();
- m_proto->IqAdd(iqId, IQ_PROC_GETREGISTER, &CJabberProto::OnIqResultGetRegister);
- m_proto->m_ThreadInfo->send( XmlNodeIq(_T("get"), iqId, m_jid) << XQUERY(JABBER_FEAT_REGISTER));
+ m_proto->m_ThreadInfo->send(
+ XmlNodeIq( m_proto->AddIQ(&CJabberProto::OnIqResultGetRegister, JABBER_IQ_TYPE_GET, m_jid))
+ << XQUERY(JABBER_FEAT_REGISTER));
// Enable WS_EX_CONTROLPARENT on IDC_FRAME (so tab stop goes through all its children)
LONG frameExStyle = GetWindowLongPtr(GetDlgItem(m_hwnd, IDC_FRAME), GWL_EXSTYLE);
@@ -233,10 +233,7 @@ public:
TCHAR *str2 = (TCHAR*)alloca(sizeof(TCHAR) * 128);
int id = 0;
- int iqId = m_proto->SerialNext();
- m_proto->IqAdd(iqId, IQ_PROC_SETREGISTER, &CJabberProto::OnIqResultSetRegister);
-
- XmlNodeIq iq(_T("set"), iqId, from);
+ XmlNodeIq iq( m_proto->AddIQ(&CJabberProto::OnIqResultSetRegister, JABBER_IQ_TYPE_SET, from));
HXML query = iq << XQUERY(JABBER_FEAT_REGISTER);
if ((xNode = xmlGetChild(queryNode , "x")) != NULL) {
diff --git a/protocols/JabberG/src/jabber_api.cpp b/protocols/JabberG/src/jabber_api.cpp
index 015c76fb58..7838260aec 100644
--- a/protocols/JabberG/src/jabber_api.cpp
+++ b/protocols/JabberG/src/jabber_api.cpp
@@ -179,7 +179,7 @@ HJHANDLER CJabberProto::AddTemporaryIqHandler(JABBER_HANDLER_FUNC Func, int iIqT
sHandlerData *d = (sHandlerData*)malloc(sizeof(sHandlerData));
d->Func = Func;
d->pUserData = pUserData;
- CJabberIqInfo *pInfo = m_iqManager.AddHandler(&CJabberProto::ExternalTempIqHandler, iIqTypes, NULL, 0, iIqId, d, iPriority);
+ CJabberIqInfo *pInfo = AddIQ(&CJabberProto::ExternalTempIqHandler, iIqTypes, NULL, 0, iIqId, d, iPriority);
if (pInfo && dwTimeout > 0)
pInfo->SetTimeout(dwTimeout);
return (HJHANDLER)pInfo;
diff --git a/protocols/JabberG/src/jabber_archive.cpp b/protocols/JabberG/src/jabber_archive.cpp
index 5359f67e51..57700a86a5 100644
--- a/protocols/JabberG/src/jabber_archive.cpp
+++ b/protocols/JabberG/src/jabber_archive.cpp
@@ -38,8 +38,7 @@ void CJabberProto::RetrieveMessageArchive(HANDLE hContact, JABBER_LIST_ITEM *pIt
pItem->bHistoryRead = TRUE;
- int iqId = SerialNext();
- XmlNodeIq iq(_T("get"), iqId);
+ XmlNodeIq iq( AddIQ(&CJabberProto::OnIqResultGetCollectionList, JABBER_IQ_TYPE_GET));
HXML list = iq << XCHILDNS( _T("list"), JABBER_FEAT_ARCHIVE) << XATTR(_T("with"), pItem->jid);
time_t tmLast = getDword(hContact, "LastCollection", 0);
@@ -47,12 +46,10 @@ void CJabberProto::RetrieveMessageArchive(HANDLE hContact, JABBER_LIST_ITEM *pIt
TCHAR buf[40];
list << XATTR(_T("start"), time2str(tmLast, buf, SIZEOF(buf)));
}
-
- IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetCollectionList);
m_ThreadInfo->send(iq);
}
-void CJabberProto::OnIqResultGetCollectionList(HXML iqNode)
+void CJabberProto::OnIqResultGetCollectionList(HXML iqNode, CJabberIqInfo*)
{
const TCHAR *to = xmlGetAttrValue(iqNode, _T("to"));
if (to == NULL || lstrcmp( xmlGetAttrValue(iqNode, _T("type")), _T("result")))
@@ -82,10 +79,8 @@ void CJabberProto::OnIqResultGetCollectionList(HXML iqNode)
tmLast = getDword(hContact, "LastCollection", 0);
}
- int iqId = SerialNext();
- IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetCollection);
m_ThreadInfo->send(
- XmlNodeIq(_T("get"), iqId)
+ XmlNodeIq( AddIQ(&CJabberProto::OnIqResultGetCollection, JABBER_IQ_TYPE_GET))
<< XCHILDNS( _T("retrieve"), JABBER_FEAT_ARCHIVE) << XATTR(_T("with"), with) << XATTR(_T("start"), start));
time_t tmThis = str2time(start);
@@ -248,7 +243,7 @@ BOOL IsDuplicateEvent(HANDLE hContact, DBEVENTINFO& dbei)
return FALSE;
}
-void CJabberProto::OnIqResultGetCollection(HXML iqNode)
+void CJabberProto::OnIqResultGetCollection(HXML iqNode, CJabberIqInfo*)
{
if ( lstrcmp( xmlGetAttrValue(iqNode, _T("type")), _T("result")))
return;
diff --git a/protocols/JabberG/src/jabber_bookmarks.cpp b/protocols/JabberG/src/jabber_bookmarks.cpp
index e025dbc5d0..e47575cf42 100644
--- a/protocols/JabberG/src/jabber_bookmarks.cpp
+++ b/protocols/JabberG/src/jabber_bookmarks.cpp
@@ -131,14 +131,10 @@ static INT_PTR CALLBACK JabberAddBookmarkDlgProc(HWND hwndDlg, UINT msg, WPARAM
replaceStrT(item->name, (text[0] == 0) ? roomJID : text);
item->bAutoJoin = (SendDlgItemMessage(hwndDlg, IDC_CHECK_BM_AUTOJOIN, BM_GETCHECK,0, 0) == BST_CHECKED);
- {
- int iqId = param->ppro->SerialNext();
- param->ppro->IqAdd(iqId, IQ_PROC_SETBOOKMARKS, &CJabberProto::OnIqResultSetBookmarks);
- XmlNodeIq iq(_T("set"), iqId);
- param->ppro->SetBookmarkRequest(iq);
- param->ppro->m_ThreadInfo->send(iq);
- }
+ XmlNodeIq iq( param->ppro->AddIQ(&CJabberProto::OnIqResultSetBookmarks, JABBER_IQ_TYPE_SET));
+ param->ppro->SetBookmarkRequest(iq);
+ param->ppro->m_ThreadInfo->send(iq);
}
// fall through
case IDCANCEL:
@@ -243,10 +239,7 @@ private:
m_lvBookmarks.SetItemState(iItem, 0, LVIS_SELECTED); // Unselect the item
- int iqId = m_proto->SerialNext();
- m_proto->IqAdd(iqId, IQ_PROC_SETBOOKMARKS, &CJabberProto::OnIqResultSetBookmarks);
-
- XmlNodeIq iq(_T("set"), iqId);
+ XmlNodeIq iq( m_proto->AddIQ(&CJabberProto::OnIqResultSetBookmarks, JABBER_IQ_TYPE_SET));
m_proto->SetBookmarkRequest(iq);
m_proto->m_ThreadInfo->send(iq);
}
@@ -269,10 +262,9 @@ void CJabberDlgBookmarks::UpdateData()
{
if ( !m_proto->m_bJabberOnline) return;
- int iqId = m_proto->SerialNext();
- m_proto->IqAdd(iqId, IQ_PROC_DISCOBOOKMARKS, &CJabberProto::OnIqResultDiscoBookmarks);
- m_proto->m_ThreadInfo->send( XmlNodeIq(_T("get"), iqId) << XQUERY(JABBER_FEAT_PRIVATE_STORAGE)
- << XCHILDNS(_T("storage"), _T("storage:bookmarks")));
+ m_proto->m_ThreadInfo->send(
+ XmlNodeIq( m_proto->AddIQ(&CJabberProto::OnIqResultDiscoBookmarks, JABBER_IQ_TYPE_GET))
+ << XQUERY(JABBER_FEAT_PRIVATE_STORAGE) << XCHILDNS(_T("storage"), _T("storage:bookmarks")));
}
void CJabberDlgBookmarks::OnInitDialog()
diff --git a/protocols/JabberG/src/jabber_byte.cpp b/protocols/JabberG/src/jabber_byte.cpp
index 4bcec43ab7..d2d5fcf0d5 100644
--- a/protocols/JabberG/src/jabber_byte.cpp
+++ b/protocols/JabberG/src/jabber_byte.cpp
@@ -167,7 +167,7 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt)
jbt->szProxyJid = NULL;
jbt->hProxyEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- pInfo = m_iqManager.AddHandler(&CJabberProto::IqResultProxyDiscovery, JABBER_IQ_TYPE_GET, proxyJid, 0, -1, jbt);
+ pInfo = AddIQ(&CJabberProto::IqResultProxyDiscovery, JABBER_IQ_TYPE_GET, proxyJid, 0, -1, jbt);
nIqId = pInfo->GetIqId();
XmlNodeIq iq(pInfo);
iq << XQUERY(JABBER_FEAT_BYTESTREAMS);
@@ -191,7 +191,7 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt)
}
} }
- pInfo = m_iqManager.AddHandler(&CJabberProto::ByteInitiateResult, JABBER_IQ_TYPE_SET, jbt->dstJID, 0, -1, jbt);
+ pInfo = AddIQ(&CJabberProto::ByteInitiateResult, JABBER_IQ_TYPE_SET, jbt->dstJID, 0, -1, jbt);
nIqId = pInfo->GetIqId();
{
XmlNodeIq iq(pInfo);
@@ -414,7 +414,7 @@ int CJabberProto::ByteSendParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* b
///////////////// Bytestream receiving /////////////////////////
-void CJabberProto::IqResultStreamActivate(HXML iqNode)
+void CJabberProto::IqResultStreamActivate(HXML iqNode, CJabberIqInfo*)
{
int id = JabberGetPacketID(iqNode);
@@ -573,10 +573,9 @@ int CJabberProto::ByteSendProxyParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, ch
JABBER_LIST_ITEM *item = ListAdd(LIST_FTIQID, listJid);
item->jbt = jbt;
- IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::IqResultStreamActivate);
m_ThreadInfo->send(
- XmlNodeIq(_T("set"), iqId, jbt->streamhostJID) << XQUERY(JABBER_FEAT_BYTESTREAMS)
- << XATTR(_T("sid"), jbt->sid) << XCHILD(_T("activate"), jbt->dstJID));
+ XmlNodeIq( AddIQ(&CJabberProto::IqResultStreamActivate, JABBER_IQ_TYPE_SET, jbt->streamhostJID))
+ << XQUERY(JABBER_FEAT_BYTESTREAMS) << XATTR(_T("sid"), jbt->sid) << XCHILD(_T("activate"), jbt->dstJID));
WaitForSingleObject(jbt->hProxyEvent, INFINITE);
diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp
index 0ffffb207b..ce01ed053a 100644
--- a/protocols/JabberG/src/jabber_caps.cpp
+++ b/protocols/JabberG/src/jabber_caps.cpp
@@ -232,7 +232,7 @@ JabberCapsBits CJabberProto::GetResourceCapabilites(const TCHAR *jid, BOOL appen
if (jcbMainCaps == JABBER_RESOURCE_CAPS_UNINIT) {
// send disco#info query
- CJabberIqInfo *pInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE);
+ 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);
m_clientCapsManager.SetClientCaps(r->m_tszCapsNode, r->m_tszCapsVer, JABBER_RESOURCE_CAPS_IN_PROGRESS, pInfo->GetIqId());
r->m_dwDiscoInfoRequestTime = pInfo->GetRequestTime();
@@ -261,7 +261,7 @@ JabberCapsBits CJabberProto::GetResourceCapabilites(const TCHAR *jid, BOOL appen
{
// send disco#info query
- CJabberIqInfo *pInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE);
+ 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);
m_clientCapsManager.SetClientCaps(r->m_tszCapsNode, token, JABBER_RESOURCE_CAPS_IN_PROGRESS, pInfo->GetIqId());
@@ -301,7 +301,7 @@ JabberCapsBits CJabberProto::GetResourceCapabilites(const TCHAR *jid, BOOL appen
if ( !r->m_dwVersionRequestTime) {
// send version query
- CJabberIqInfo *pInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE);
+ CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE);
pInfo->SetTimeout(JABBER_RESOURCE_CAPS_QUERY_TIMEOUT);
r->m_dwVersionRequestTime = pInfo->GetRequestTime();
@@ -323,7 +323,7 @@ JabberCapsBits CJabberProto::GetResourceCapabilites(const TCHAR *jid, BOOL appen
if ( !r->m_dwDiscoInfoRequestTime) {
// send disco#info query
- CJabberIqInfo *pInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE);
+ 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);
r->m_dwDiscoInfoRequestTime = pInfo->GetRequestTime();
@@ -366,7 +366,7 @@ JabberCapsBits CJabberProto::GetResourceCapabilites(const TCHAR *jid, BOOL appen
else if (jcbMainCaps == JABBER_RESOURCE_CAPS_UNINIT) {
// send disco#info query
- CJabberIqInfo *pInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE);
+ 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);
m_clientCapsManager.SetClientCaps(r->m_tszSoftware, r->m_tszSoftwareVersion, JABBER_RESOURCE_CAPS_IN_PROGRESS, pInfo->GetIqId());
r->m_dwDiscoInfoRequestTime = pInfo->GetRequestTime();
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp
index b21c0ddfa7..ec73143d6f 100644
--- a/protocols/JabberG/src/jabber_chat.cpp
+++ b/protocols/JabberG/src/jabber_chat.cpp
@@ -843,11 +843,10 @@ void CJabberProto::AdminSetReason(const TCHAR *to, const TCHAR *ns, const TCHAR
{ m_ThreadInfo->send( XmlNodeIq(_T("set"), SerialNext(), to) << XQUERY(ns) << XCHILD(_T("item")) << XATTR(szItem, itemVal) << XATTR(var, varVal) << XCHILD(_T("reason"), rsn));
}
-void CJabberProto::AdminGet(const TCHAR *to, const TCHAR *ns, const TCHAR *var, const TCHAR *varVal, JABBER_IQ_PFUNC foo)
+void CJabberProto::AdminGet(const TCHAR *to, const TCHAR *ns, const TCHAR *var, const TCHAR *varVal, JABBER_IQ_HANDLER foo)
{
- int id = SerialNext();
- IqAdd(id, IQ_PROC_NONE, foo);
- m_ThreadInfo->send( XmlNodeIq(_T("get"), id, to) << XQUERY(ns) << XCHILD(_T("item")) << XATTR(var, varVal));
+ m_ThreadInfo->send( XmlNodeIq( AddIQ(foo, JABBER_IQ_TYPE_GET, to))
+ << XQUERY(ns) << XCHILD(_T("item")) << XATTR(var, varVal));
}
// Member info dialog
@@ -1356,15 +1355,11 @@ static void sttLogListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* g
break;
case IDM_CONFIG:
- {
- int iqId = ppro->SerialNext();
- ppro->IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetMuc);
-
- XmlNodeIq iq(_T("get"), iqId, gch->pDest->ptszID);
- iq << XQUERY(JABBER_FEAT_MUC_OWNER);
- ppro->m_ThreadInfo->send(iq);
+ ppro->m_ThreadInfo->send(
+ XmlNodeIq( ppro->AddIQ(&CJabberProto::OnIqResultGetMuc, JABBER_IQ_TYPE_GET, gch->pDest->ptszID))
+ << XQUERY(JABBER_FEAT_MUC_OWNER));
break;
- }
+
case IDM_BOOKMARKS:
{
JABBER_LIST_ITEM *item = ppro->ListGetItemPtr(LIST_BOOKMARK, gch->pDest->ptszID);
@@ -1492,9 +1487,9 @@ int CJabberProto::JabberGcEventHook(WPARAM, LPARAM lParam)
break;
case GC_USER_CHANMGR:
- int iqId = SerialNext();
- IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetMuc);
- m_ThreadInfo->send( XmlNodeIq(_T("get"), iqId, item->jid) << XQUERY(JABBER_FEAT_MUC_OWNER));
+ m_ThreadInfo->send(
+ XmlNodeIq( AddIQ(&CJabberProto::OnIqResultGetMuc, JABBER_IQ_TYPE_GET, item->jid))
+ << XQUERY(JABBER_FEAT_MUC_OWNER));
break;
}
@@ -1509,7 +1504,8 @@ void CJabberProto::AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, TCHAR* s
if (jidListInfo->type == MUC_BANLIST) {
AdminSetReason(roomJid, JABBER_FEAT_MUC_ADMIN, field, str, _T("affiliation"), _T("outcast"), rsn);
AdminGet(roomJid, JABBER_FEAT_MUC_ADMIN, _T("affiliation"), _T("outcast"), &CJabberProto::OnIqResultMucGetBanList);
-} }
+ }
+}
void CJabberProto::AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, TCHAR* str)
{
diff --git a/protocols/JabberG/src/jabber_disco.cpp b/protocols/JabberG/src/jabber_disco.cpp
index efca9cac98..6d3e12de4d 100644
--- a/protocols/JabberG/src/jabber_disco.cpp
+++ b/protocols/JabberG/src/jabber_disco.cpp
@@ -289,7 +289,7 @@ void CJabberProto::OnIqResultServiceDiscoveryRootItems(HXML iqNode, CJabberIqInf
for (int i = 1; (item = xmlGetNthChild(query, _T("item"), i)) != NULL; i++) {
const TCHAR *szJid = xmlGetAttrValue(item, _T("jid"));
const TCHAR *szNode = xmlGetAttrValue(item, _T("node"));
- CJabberIqInfo *pNewInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultServiceDiscoveryRootInfo, JABBER_IQ_TYPE_GET, szJid);
+ CJabberIqInfo *pNewInfo = AddIQ(&CJabberProto::OnIqResultServiceDiscoveryRootInfo, JABBER_IQ_TYPE_GET, szJid);
pNewInfo->m_pUserData = pInfo->m_pUserData;
pNewInfo->SetTimeout(30000);
@@ -310,7 +310,7 @@ BOOL CJabberProto::SendInfoRequest(CJabberSDNode *pNode, HXML parent)
// disco#info
if ( !pNode->GetInfoRequestId()) {
- CJabberIqInfo *pInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultServiceDiscoveryInfo, JABBER_IQ_TYPE_GET, pNode->GetJid());
+ CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultServiceDiscoveryInfo, JABBER_IQ_TYPE_GET, pNode->GetJid());
pInfo->SetTimeout(30000);
pNode->SetInfoRequestId(pInfo->GetIqId());
@@ -340,7 +340,7 @@ BOOL CJabberProto::SendBothRequests(CJabberSDNode *pNode, HXML parent)
// disco#info
if ( !pNode->GetInfoRequestId()) {
- CJabberIqInfo *pInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultServiceDiscoveryInfo, JABBER_IQ_TYPE_GET, pNode->GetJid());
+ CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultServiceDiscoveryInfo, JABBER_IQ_TYPE_GET, pNode->GetJid());
pInfo->SetTimeout(30000);
pNode->SetInfoRequestId(pInfo->GetIqId());
@@ -357,7 +357,7 @@ BOOL CJabberProto::SendBothRequests(CJabberSDNode *pNode, HXML parent)
// disco#items
if ( !pNode->GetItemsRequestId()) {
- CJabberIqInfo *pInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultServiceDiscoveryItems, JABBER_IQ_TYPE_GET, pNode->GetJid());
+ CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultServiceDiscoveryItems, JABBER_IQ_TYPE_GET, pNode->GetJid());
pInfo->SetTimeout(30000);
pNode->SetItemsRequestId(pInfo->GetIqId());
@@ -419,7 +419,7 @@ void CJabberProto::PerformBrowse(HWND hwndDlg)
else if ( !lstrcmp(szJid, _T(SD_FAKEJID_CONFERENCES))) {
sttBrowseMode = SD_BROWSE_CONFERENCES;
TCHAR *szServerJid = mir_a2t(m_ThreadInfo->server);
- CJabberIqInfo *pInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultServiceDiscoveryRootItems, JABBER_IQ_TYPE_GET, szServerJid);
+ CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultServiceDiscoveryRootItems, JABBER_IQ_TYPE_GET, szServerJid);
pInfo->m_pUserData = (void*)JABBER_FEAT_MUC;
pInfo->SetTimeout(30000);
XmlNodeIq iq(pInfo);
@@ -430,7 +430,7 @@ void CJabberProto::PerformBrowse(HWND hwndDlg)
else if ( !lstrcmp(szJid, _T(SD_FAKEJID_AGENTS))) {
sttBrowseMode = SD_BROWSE_AGENTS;
TCHAR *szServerJid = mir_a2t(m_ThreadInfo->server);
- CJabberIqInfo *pInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultServiceDiscoveryRootItems, JABBER_IQ_TYPE_GET, szServerJid);
+ CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultServiceDiscoveryRootItems, JABBER_IQ_TYPE_GET, szServerJid);
pInfo->m_pUserData = (void*)_T("jabber:iq:gateway");
pInfo->SetTimeout(30000);
XmlNodeIq iq(pInfo);
diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp
index ae863c6b5d..99cbc79b70 100644
--- a/protocols/JabberG/src/jabber_ft.cpp
+++ b/protocols/JabberG/src/jabber_ft.cpp
@@ -101,7 +101,7 @@ void CJabberProto::FtInitiate(TCHAR* jid, filetransfer *ft)
TCHAR tszJid[ 512 ];
mir_sntprintf(tszJid, SIZEOF(tszJid), _T("%s/%s"), jid, rs);
- XmlNodeIq iq(m_iqManager.AddHandler(&CJabberProto::OnFtSiResult, JABBER_IQ_TYPE_SET, tszJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO, -1, ft));
+ XmlNodeIq iq( AddIQ(&CJabberProto::OnFtSiResult, JABBER_IQ_TYPE_SET, tszJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO, -1, ft));
HXML si = iq << XCHILDNS(_T("si"), JABBER_FEAT_SI) << XATTR(_T("id"), sid)
<< XATTR(_T("mime-type"), _T("binary/octet-stream")) << XATTR(_T("profile"), JABBER_FEAT_SI_FT);
si << XCHILDNS(_T("file"), JABBER_FEAT_SI_FT) << XATTR(_T("name"), filename)
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp
index bb5921e1c3..62a64bd4b6 100644
--- a/protocols/JabberG/src/jabber_groupchat.cpp
+++ b/protocols/JabberG/src/jabber_groupchat.cpp
@@ -676,7 +676,7 @@ INT_PTR CJabberDlgGcJoin::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
sttRoomListAppend(GetDlgItem(m_hwnd, IDC_ROOM), RoomInfo::ROOM_WAIT, TranslateT("Loading..."), TranslateT("Please wait for room list to download."), _T(""));
- CJabberIqInfo *pInfo = m_proto->m_iqManager.AddHandler(&CJabberProto::OnIqResultDiscovery, JABBER_IQ_TYPE_GET, server, 0, -1, (void*)GetDlgItem(m_hwnd, IDC_ROOM));
+ CJabberIqInfo *pInfo = m_proto->AddIQ(&CJabberProto::OnIqResultDiscovery, JABBER_IQ_TYPE_GET, server, 0, -1, (void*)GetDlgItem(m_hwnd, IDC_ROOM));
pInfo->SetTimeout(30000);
XmlNodeIq iq(pInfo);
iq << XQUERY(JABBER_FEAT_DISCO_ITEMS);
@@ -1023,13 +1023,12 @@ void CJabberProto::GroupchatProcessPresence(HXML node)
// Check <created/>
if (bRoomCreated) {
HXML n = xmlGetChild(node , "created");
- if (n != NULL && (str = xmlGetAttrValue(n, _T("xmlns"))) != NULL && !_tcscmp(str, JABBER_FEAT_MUC_OWNER)) {
+ if (n != NULL && (str = xmlGetAttrValue(n, _T("xmlns"))) != NULL && !_tcscmp(str, JABBER_FEAT_MUC_OWNER))
// A new room just created by me
// Request room config
- int iqId = SerialNext();
- IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetMuc);
- m_ThreadInfo->send( XmlNodeIq(_T("get"), iqId, item->jid) << XQUERY(JABBER_FEAT_MUC_OWNER));
- }
+ m_ThreadInfo->send(
+ XmlNodeIq( AddIQ(&CJabberProto::OnIqResultGetMuc, JABBER_IQ_TYPE_GET, item->jid))
+ << XQUERY(JABBER_FEAT_MUC_OWNER));
}
mir_free(room);
diff --git a/protocols/JabberG/src/jabber_ibb.cpp b/protocols/JabberG/src/jabber_ibb.cpp
index 24f54a21c3..f696e98b5e 100644
--- a/protocols/JabberG/src/jabber_ibb.cpp
+++ b/protocols/JabberG/src/jabber_ibb.cpp
@@ -95,7 +95,7 @@ void CJabberProto::IbbSendThread(JABBER_IBB_TRANSFER *jibb)
jibb->state = JIBB_SENDING;
m_ThreadInfo->send(
- XmlNodeIq(m_iqManager.AddHandler(&CJabberProto::OnIbbInitiateResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb))
+ XmlNodeIq( AddIQ(&CJabberProto::OnIbbInitiateResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb))
<< XCHILDNS(_T("open"), JABBER_FEAT_IBB) << XATTR(_T("sid"), jibb->sid) << XATTRI(_T("block-size"), JABBER_IBB_BLOCK_SIZE)
<< XATTR(_T("stanza"), _T("message")));
@@ -114,7 +114,7 @@ void CJabberProto::IbbSendThread(JABBER_IBB_TRANSFER *jibb)
jibb->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
m_ThreadInfo->send(
- XmlNodeIq(m_iqManager.AddHandler(&CJabberProto::OnIbbCloseResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb))
+ XmlNodeIq( AddIQ(&CJabberProto::OnIbbCloseResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb))
<< XCHILDNS(_T("close"), JABBER_FEAT_IBB) << XATTR(_T("sid"), jibb->sid));
WaitForSingleObject(jibb->hEvent, INFINITE);
diff --git a/protocols/JabberG/src/jabber_iq.cpp b/protocols/JabberG/src/jabber_iq.cpp
index 64cfafb85c..6af37f07a3 100644
--- a/protocols/JabberG/src/jabber_iq.cpp
+++ b/protocols/JabberG/src/jabber_iq.cpp
@@ -29,86 +29,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "jabber_ibb.h"
#include "jabber_rc.h"
-void CJabberProto::IqInit()
-{
- InitializeCriticalSection(&m_csIqList);
- m_ppIqList = NULL;
- m_nIqCount = 0;
- m_nIqAlloced = 0;
-}
-
-void CJabberProto::IqUninit()
-{
- if (m_ppIqList) mir_free(m_ppIqList);
- m_ppIqList = NULL;
- m_nIqCount = 0;
- m_nIqAlloced = 0;
- DeleteCriticalSection(&m_csIqList);
-}
-
-void CJabberProto::IqAdd(unsigned int iqId, JABBER_IQ_PROCID procId, JABBER_IQ_PFUNC func)
-{
- int i;
-
- mir_cslock lck(m_csIqList);
- Log("IqAdd id=%d, proc=%d, func=0x%x", iqId, procId, func);
- if (procId == IQ_PROC_NONE)
- i = m_nIqCount;
- else
- for (i=0; i<m_nIqCount && m_ppIqList[i].procId != procId; i++);
-
- if (i >= m_nIqCount && m_nIqCount >= m_nIqAlloced) {
- m_nIqAlloced = m_nIqCount + 8;
- m_ppIqList = (JABBER_IQ_FUNC*)mir_realloc(m_ppIqList, sizeof(JABBER_IQ_FUNC)*m_nIqAlloced);
- }
-
- if (m_ppIqList != NULL) {
- m_ppIqList[i].iqId = iqId;
- m_ppIqList[i].procId = procId;
- m_ppIqList[i].func = func;
- m_ppIqList[i].requestTime = time(NULL);
- if (i == m_nIqCount)
- m_nIqCount++;
- }
-}
-
-void CJabberProto::IqRemove(int index)
-{
- mir_cslock lck(m_csIqList);
- if (index >= 0 && index < m_nIqCount) {
- memmove(m_ppIqList+index, m_ppIqList+index+1, sizeof(JABBER_IQ_FUNC)*(m_nIqCount-index-1));
- m_nIqCount--;
- }
-}
-
-void CJabberProto::IqExpire()
-{
- time_t expire = time(NULL) - 120; // 2 minute
-
- mir_cslock lck(m_csIqList);
- for (int i=0; i < m_nIqCount; ) {
- if (m_ppIqList[i].requestTime < expire)
- IqRemove(i);
- else
- i++;
- }
-}
-
-JABBER_IQ_PFUNC CJabberProto::JabberIqFetchFunc(int iqId)
-{
- mir_cslock lck(m_csIqList);
- IqExpire();
-
- int i;
- for (i=0; i < m_nIqCount && m_ppIqList[i].iqId != iqId; i++);
- if (i < m_nIqCount) {
- JABBER_IQ_PFUNC res = m_ppIqList[i].func;
- IqRemove(i);
- return res;
- }
- return NULL;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
// CJabberIqManager class
diff --git a/protocols/JabberG/src/jabber_iq.h b/protocols/JabberG/src/jabber_iq.h
index 02d4fdf38e..57afea900b 100644
--- a/protocols/JabberG/src/jabber_iq.h
+++ b/protocols/JabberG/src/jabber_iq.h
@@ -29,34 +29,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
class CJabberIqInfo;
-typedef enum {
- IQ_PROC_NONE,
- IQ_PROC_GETAGENTS,
- IQ_PROC_GETREGISTER,
- IQ_PROC_SETREGISTER,
- IQ_PROC_GETVCARD,
- IQ_PROC_SETVCARD,
- IQ_PROC_GETSEARCH,
- IQ_PROC_GETSEARCHFIELDS,
- IQ_PROC_BROWSEROOMS,
- IQ_PROC_DISCOROOMSERVER,
- IQ_PROC_DISCOAGENTS,
- IQ_PROC_DISCOBOOKMARKS,
- IQ_PROC_SETBOOKMARKS,
- IQ_PROC_DISCOCOMMANDS,
- IQ_PROC_EXECCOMMANDS,
-} JABBER_IQ_PROCID;
-
struct CJabberProto;
-typedef void (CJabberProto::*JABBER_IQ_PFUNC)(HXML iqNode);
typedef void (*IQ_USER_DATA_FREE_FUNC)(void *pUserData);
-typedef struct {
- TCHAR *xmlns;
- JABBER_IQ_PFUNC func;
- BOOL allowSubNs; // e.g. #info in disco#info
-} JABBER_IQ_XMLNS_FUNC;
-
// 2 minutes, milliseconds
#define JABBER_DEFAULT_IQ_REQUEST_TIMEOUT 120000
@@ -209,7 +184,7 @@ public:
BOOL Shutdown();
// fucking params, maybe just return CJabberIqRequestInfo pointer ?
- CJabberIqInfo* AddHandler(JABBER_IQ_HANDLER pHandler, int nIqType = JABBER_IQ_TYPE_GET, const TCHAR *szReceiver = NULL, DWORD dwParamsToParse = 0, int nIqId = -1, void *pUserData = NULL, int iPriority = JH_PRIORITY_DEFAULT);
+ CJabberIqInfo* AddHandler(JABBER_IQ_HANDLER pHandler, int nIqType, const TCHAR *szReceiver, DWORD dwParamsToParse, int nIqId, void *pUserData, int iPriority);
CJabberIqPermanentInfo* AddPermanentHandler(JABBER_PERMANENT_IQ_HANDLER pHandler, int nIqTypes, DWORD dwParamsToParse, const TCHAR *szXmlns, BOOL bAllowPartialNs, const TCHAR *szTag, void *pUserData = NULL, IQ_USER_DATA_FREE_FUNC pUserDataFree = NULL, int iPriority = JH_PRIORITY_DEFAULT);
// returns TRUE when pInfo found, or FALSE otherwise
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp
index 54f83a0ed7..ec36891932 100644
--- a/protocols/JabberG/src/jabber_iqid.cpp
+++ b/protocols/JabberG/src/jabber_iqid.cpp
@@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "jabber_caps.h"
#include "jabber_privacy.h"
-void CJabberProto::OnIqResultServerDiscoInfo(HXML iqNode)
+void CJabberProto::OnIqResultServerDiscoInfo(HXML iqNode, CJabberIqInfo*)
{
if ( !iqNode)
return;
@@ -103,7 +103,7 @@ void CJabberProto::OnIqResultNestedRosterGroups(HXML iqNode, CJabberIqInfo *pInf
// roster request
TCHAR *szUserData = mir_tstrdup(szGroupDelimeter ? szGroupDelimeter : _T("\\"));
m_ThreadInfo->send(
- XmlNodeIq(m_iqManager.AddHandler(&CJabberProto::OnIqResultGetRoster, JABBER_IQ_TYPE_GET, NULL, 0, -1, (void*)szUserData))
+ XmlNodeIq( AddIQ(&CJabberProto::OnIqResultGetRoster, JABBER_IQ_TYPE_GET, NULL, 0, -1, (void*)szUserData))
<< XCHILDNS(_T("query"), JABBER_FEAT_IQ_ROSTER));
}
@@ -170,7 +170,7 @@ void CJabberProto::OnLoggedIn()
// XEP-0083 support
{
- CJabberIqInfo *pIqInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultNestedRosterGroups, JABBER_IQ_TYPE_GET);
+ CJabberIqInfo *pIqInfo = AddIQ(&CJabberProto::OnIqResultNestedRosterGroups, JABBER_IQ_TYPE_GET);
// ugly hack to prevent hangup during login process
pIqInfo->SetTimeout(30000);
m_ThreadInfo->send(
@@ -179,24 +179,21 @@ void CJabberProto::OnLoggedIn()
}
// Server-side notes
- {
- m_ThreadInfo->send(
- XmlNodeIq(m_iqManager.AddHandler(&CJabberProto::OnIqResultNotes, JABBER_IQ_TYPE_GET))
- << XQUERY(JABBER_FEAT_PRIVATE_STORAGE)
- << XCHILDNS(_T("storage"), JABBER_FEAT_MIRANDA_NOTES));
- }
-
- int iqId = SerialNext();
- IqAdd(iqId, IQ_PROC_DISCOBOOKMARKS, &CJabberProto::OnIqResultDiscoBookmarks);
m_ThreadInfo->send(
- XmlNodeIq(_T("get"), iqId) << XQUERY(JABBER_FEAT_PRIVATE_STORAGE)
- << XCHILDNS(_T("storage"), _T("storage:bookmarks")));
+ XmlNodeIq( AddIQ(&CJabberProto::OnIqResultNotes, JABBER_IQ_TYPE_GET))
+ << XQUERY(JABBER_FEAT_PRIVATE_STORAGE)
+ << XCHILDNS(_T("storage"), JABBER_FEAT_MIRANDA_NOTES));
+
+ m_ThreadInfo->send(
+ XmlNodeIq( AddIQ(&CJabberProto::OnIqResultDiscoBookmarks, JABBER_IQ_TYPE_GET))
+ << XQUERY(JABBER_FEAT_PRIVATE_STORAGE) << XCHILDNS(_T("storage"), _T("storage:bookmarks")));
m_bPepSupported = FALSE;
m_ThreadInfo->jabberServerCaps = JABBER_RESOURCE_CAPS_NONE;
- iqId = SerialNext();
- IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultServerDiscoInfo);
- m_ThreadInfo->send( XmlNodeIq(_T("get"), iqId, _A2T(m_ThreadInfo->server)) << XQUERY(JABBER_FEAT_DISCO_INFO));
+
+ m_ThreadInfo->send(
+ XmlNodeIq( AddIQ(&CJabberProto::OnIqResultServerDiscoInfo, JABBER_IQ_TYPE_GET, _A2T(m_ThreadInfo->server)))
+ << XQUERY(JABBER_FEAT_DISCO_INFO));
QueryPrivacyLists(m_ThreadInfo);
@@ -208,7 +205,7 @@ void CJabberProto::OnLoggedIn()
m_pepServices.ResetPublishAll();
}
-void CJabberProto::OnIqResultGetAuth(HXML iqNode)
+void CJabberProto::OnIqResultGetAuth(HXML iqNode, CJabberIqInfo *pInfo)
{
// RECVED: result of the request for authentication method
// ACTION: send account authentication information to log in
@@ -220,10 +217,7 @@ void CJabberProto::OnIqResultGetAuth(HXML iqNode)
if ((queryNode=xmlGetChild(iqNode , "query")) == NULL) return;
if ( !lstrcmp(type, _T("result"))) {
- int iqId = SerialNext();
- IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultSetAuth);
-
- XmlNodeIq iq(_T("set"), iqId);
+ XmlNodeIq iq( AddIQ(&CJabberProto::OnIqResultSetAuth, JABBER_IQ_TYPE_SET));
HXML query = iq << XQUERY(_T("jabber:iq:auth"));
query << XCHILD(_T("username"), m_ThreadInfo->username);
if (xmlGetChild(queryNode, "digest") != NULL && m_szStreamId) {
@@ -240,7 +234,6 @@ void CJabberProto::OnIqResultGetAuth(HXML iqNode)
query << XCHILD(_T("password"), m_ThreadInfo->password);
else {
Log("No known authentication mechanism accepted by the server.");
-
m_ThreadInfo->send("</stream:stream>");
return;
}
@@ -260,7 +253,7 @@ void CJabberProto::OnIqResultGetAuth(HXML iqNode)
m_ThreadInfo = NULL; // To disallow auto reconnect
} }
-void CJabberProto::OnIqResultSetAuth(HXML iqNode)
+void CJabberProto::OnIqResultSetAuth(HXML iqNode, CJabberIqInfo *pInfo)
{
const TCHAR *type;
@@ -305,7 +298,7 @@ void CJabberProto::OnIqResultBind(HXML iqNode, CJabberIqInfo *pInfo)
}
if (m_ThreadInfo->bIsSessionAvailable)
m_ThreadInfo->send(
- XmlNodeIq(m_iqManager.AddHandler(&CJabberProto::OnIqResultSession, JABBER_IQ_TYPE_SET))
+ XmlNodeIq( AddIQ(&CJabberProto::OnIqResultSession, JABBER_IQ_TYPE_SET))
<< XCHILDNS(_T("session"), _T("urn:ietf:params:xml:ns:xmpp-session")));
else
OnLoggedIn();
@@ -548,7 +541,7 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo)
RebuildInfoFrame();
}
-void CJabberProto::OnIqResultGetRegister(HXML iqNode)
+void CJabberProto::OnIqResultGetRegister(HXML iqNode, CJabberIqInfo*)
{
// RECVED: result of the request for (agent) registration mechanism
// ACTION: activate (agent) registration input dialog
@@ -571,7 +564,7 @@ void CJabberProto::OnIqResultGetRegister(HXML iqNode)
mir_free(str);
} } }
-void CJabberProto::OnIqResultSetRegister(HXML iqNode)
+void CJabberProto::OnIqResultSetRegister(HXML iqNode, CJabberIqInfo*)
{
// RECVED: result of registration process
// ACTION: notify of successful agent registration
@@ -675,7 +668,7 @@ static TCHAR* sttGetText(HXML node, char* tag)
return (TCHAR*)xmlGetText(n);
}
-void CJabberProto::OnIqResultGetVcard(HXML iqNode)
+void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo *pInfo)
{
HXML vCardNode, m, n, o;
const TCHAR *type, *jid;
@@ -1149,7 +1142,7 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode)
}
}
-void CJabberProto::OnIqResultSetVcard(HXML iqNode)
+void CJabberProto::OnIqResultSetVcard(HXML iqNode, CJabberIqInfo *pInfo)
{
Log("<iq/> iqIdSetVcard");
if ( !xmlGetAttrValue(iqNode, _T("type")))
@@ -1158,7 +1151,7 @@ void CJabberProto::OnIqResultSetVcard(HXML iqNode)
WindowNotify(WM_JABBER_REFRESH_VCARD);
}
-void CJabberProto::OnIqResultSetSearch(HXML iqNode)
+void CJabberProto::OnIqResultSetSearch(HXML iqNode, CJabberIqInfo *pInfo)
{
HXML queryNode, n;
const TCHAR *type, *jid;
@@ -1209,7 +1202,7 @@ void CJabberProto::OnIqResultSetSearch(HXML iqNode)
ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
}
-void CJabberProto::OnIqResultExtSearch(HXML iqNode)
+void CJabberProto::OnIqResultExtSearch(HXML iqNode, CJabberIqInfo *pInfo)
{
HXML queryNode;
const TCHAR *type;
@@ -1276,7 +1269,7 @@ void CJabberProto::OnIqResultExtSearch(HXML iqNode)
ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
}
-void CJabberProto::OnIqResultSetPassword(HXML iqNode)
+void CJabberProto::OnIqResultSetPassword(HXML iqNode, CJabberIqInfo *pInfo)
{
Log("<iq/> iqIdSetPassword");
@@ -1298,19 +1291,19 @@ void CJabberProto::OnIqResultDiscoAgentItems(HXML iqNode, void *userdata)
return;
}
*/
-void CJabberProto::OnIqResultGetVCardAvatar(HXML iqNode)
+void CJabberProto::OnIqResultGetVCardAvatar(HXML iqNode, CJabberIqInfo *pInfo)
{
- const TCHAR *type;
-
Log("<iq/> OnIqResultGetVCardAvatar");
const TCHAR *from = xmlGetAttrValue(iqNode, _T("from"));
if (from == NULL)
return;
+
HANDLE hContact = HContactFromJID(from);
if (hContact == NULL)
return;
+ const TCHAR *type;
if ((type = xmlGetAttrValue(iqNode, _T("type"))) == NULL) return;
if (_tcscmp(type, _T("result"))) return;
@@ -1327,7 +1320,6 @@ void CJabberProto::OnIqResultGetVCardAvatar(HXML iqNode)
delSetting(hContact, "AvatarSaved");
ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, NULL, NULL);
}
-
return;
}
@@ -1340,7 +1332,7 @@ void CJabberProto::OnIqResultGetVCardAvatar(HXML iqNode)
OnIqResultGotAvatar(hContact, n, mimeType);
}
-void CJabberProto::OnIqResultGetClientAvatar(HXML iqNode)
+void CJabberProto::OnIqResultGetClientAvatar(HXML iqNode, CJabberIqInfo *pInfo)
{
const TCHAR *type;
@@ -1371,10 +1363,7 @@ void CJabberProto::OnIqResultGetClientAvatar(HXML iqNode)
*res = 0;
// Try server stored avatar
- int iqId = SerialNext();
- IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetServerAvatar);
-
- XmlNodeIq iq(_T("get"), iqId, szJid);
+ XmlNodeIq iq( AddIQ(&CJabberProto::OnIqResultGetServerAvatar, JABBER_IQ_TYPE_GET, szJid));
iq << XQUERY(JABBER_FEAT_SERVER_AVATAR);
m_ThreadInfo->send(iq);
@@ -1387,7 +1376,7 @@ void CJabberProto::OnIqResultGetClientAvatar(HXML iqNode)
}
-void CJabberProto::OnIqResultGetServerAvatar(HXML iqNode)
+void CJabberProto::OnIqResultGetServerAvatar(HXML iqNode, CJabberIqInfo *pInfo)
{
const TCHAR *type;
@@ -1418,13 +1407,9 @@ void CJabberProto::OnIqResultGetServerAvatar(HXML iqNode)
*res = 0;
// Try VCard photo
- int iqId = SerialNext();
- IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetVCardAvatar);
-
- XmlNodeIq iq(_T("get"), iqId, szJid);
- iq << XCHILDNS(_T("vCard"), JABBER_FEAT_VCARD_TEMP);
- m_ThreadInfo->send(iq);
-
+ m_ThreadInfo->send(
+ XmlNodeIq( AddIQ(&CJabberProto::OnIqResultGetVCardAvatar, JABBER_IQ_TYPE_GET, szJid))
+ << XCHILDNS(_T("vCard"), JABBER_FEAT_VCARD_TEMP));
return;
}
@@ -1492,7 +1477,7 @@ LBL_ErrFormat:
/////////////////////////////////////////////////////////////////////////////////////////
// Bookmarks
-void CJabberProto::OnIqResultDiscoBookmarks(HXML iqNode)
+void CJabberProto::OnIqResultDiscoBookmarks(HXML iqNode, CJabberIqInfo *pInfo)
{
HXML storageNode;//, nickNode, passNode;
const TCHAR *type, *jid, *name;
@@ -1581,7 +1566,7 @@ void CJabberProto::SetBookmarkRequest (XmlNodeIq& iq)
}
}
-void CJabberProto::OnIqResultSetBookmarks(HXML iqNode)
+void CJabberProto::OnIqResultSetBookmarks(HXML iqNode, CJabberIqInfo *pInfo)
{
// RECVED: server's response
// ACTION: refresh bookmarks list dialog
diff --git a/protocols/JabberG/src/jabber_iqid_muc.cpp b/protocols/JabberG/src/jabber_iqid_muc.cpp
index d5d458c2c5..bd9d9251af 100644
--- a/protocols/JabberG/src/jabber_iqid_muc.cpp
+++ b/protocols/JabberG/src/jabber_iqid_muc.cpp
@@ -36,7 +36,7 @@ void CJabberProto::SetMucConfig(HXML node, void *from)
}
}
-void CJabberProto::OnIqResultGetMuc(HXML iqNode)
+void CJabberProto::OnIqResultGetMuc(HXML iqNode, CJabberIqInfo *pInfo)
{
HXML queryNode, xNode;
const TCHAR *type, *from, *str;
@@ -505,37 +505,37 @@ void CJabberProto::OnIqResultMucGetJidList(HXML iqNode, JABBER_MUC_JIDLIST_TYPE
mir_free(jidListInfo);
} } }
-void CJabberProto::OnIqResultMucGetVoiceList(HXML iqNode)
+void CJabberProto::OnIqResultMucGetVoiceList(HXML iqNode, CJabberIqInfo *pInfo)
{
Log("<iq/> iqResultMucGetVoiceList");
OnIqResultMucGetJidList(iqNode, MUC_VOICELIST);
}
-void CJabberProto::OnIqResultMucGetMemberList(HXML iqNode)
+void CJabberProto::OnIqResultMucGetMemberList(HXML iqNode, CJabberIqInfo *pInfo)
{
Log("<iq/> iqResultMucGetMemberList");
OnIqResultMucGetJidList(iqNode, MUC_MEMBERLIST);
}
-void CJabberProto::OnIqResultMucGetModeratorList(HXML iqNode)
+void CJabberProto::OnIqResultMucGetModeratorList(HXML iqNode, CJabberIqInfo *pInfo)
{
Log("<iq/> iqResultMucGetModeratorList");
OnIqResultMucGetJidList(iqNode, MUC_MODERATORLIST);
}
-void CJabberProto::OnIqResultMucGetBanList(HXML iqNode)
+void CJabberProto::OnIqResultMucGetBanList(HXML iqNode, CJabberIqInfo *pInfo)
{
Log("<iq/> iqResultMucGetBanList");
OnIqResultMucGetJidList(iqNode, MUC_BANLIST);
}
-void CJabberProto::OnIqResultMucGetAdminList(HXML iqNode)
+void CJabberProto::OnIqResultMucGetAdminList(HXML iqNode, CJabberIqInfo *pInfo)
{
Log("<iq/> iqResultMucGetAdminList");
OnIqResultMucGetJidList(iqNode, MUC_ADMINLIST);
}
-void CJabberProto::OnIqResultMucGetOwnerList(HXML iqNode)
+void CJabberProto::OnIqResultMucGetOwnerList(HXML iqNode, CJabberIqInfo *pInfo)
{
Log("<iq/> iqResultMucGetOwnerList");
OnIqResultMucGetJidList(iqNode, MUC_OWNERLIST);
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp
index e4b36f2c73..8e3abd8694 100644
--- a/protocols/JabberG/src/jabber_opt.cpp
+++ b/protocols/JabberG/src/jabber_opt.cpp
@@ -1030,7 +1030,7 @@ static void _RosterListClear(HWND hwndDlg)
ListView_SetColumnWidth(hList,3,width*10/100);
}
-void CJabberProto::_RosterHandleGetRequest(HXML node)
+void CJabberProto::_RosterHandleGetRequest(HXML node, CJabberIqInfo*)
{
HWND hList=GetDlgItem(rrud.hwndDlg, IDC_ROSTER);
if (rrud.bRRAction==RRA_FILLLIST)
@@ -1101,18 +1101,13 @@ void CJabberProto::_RosterHandleGetRequest(HXML node)
if ( !queryRoster)
return;
- int iqId = SerialNext();
- IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::_RosterHandleGetRequest);
-
- XmlNode iq(_T("iq"));
- xmlAddAttr(iq, _T("type"), _T("set"));
- iq << XATTRID(iqId);
+ XmlNodeIq iq( AddIQ(&CJabberProto::_RosterHandleGetRequest, JABBER_IQ_TYPE_SET));
HXML query = iq << XCHILDNS(_T("query"), JABBER_FEAT_IQ_ROSTER);
int itemCount=0;
int ListItemCount=ListView_GetItemCount(hList);
- for (int index=0; index<ListItemCount; index++)
+ for (int index=0; index < ListItemCount; index++)
{
TCHAR jid[JABBER_MAX_JID_LEN]=_T("");
TCHAR name[260]=_T("");
@@ -1179,12 +1174,12 @@ void CJabberProto::_RosterHandleGetRequest(HXML node)
void CJabberProto::_RosterSendRequest(HWND hwndDlg, BYTE rrAction)
{
- rrud.bRRAction=rrAction;
- rrud.hwndDlg=hwndDlg;
-
- int iqId = SerialNext();
- IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::_RosterHandleGetRequest);
- m_ThreadInfo->send(XmlNode(_T("iq")) << XATTR(_T("type"), _T("get")) << XATTRID(iqId) << XCHILDNS(_T("query"), JABBER_FEAT_IQ_ROSTER));
+ rrud.bRRAction = rrAction;
+ rrud.hwndDlg = hwndDlg;
+
+ m_ThreadInfo->send(
+ XmlNodeIq( AddIQ(&CJabberProto::_RosterHandleGetRequest, JABBER_IQ_TYPE_GET))
+ << XCHILDNS(_T("query"), JABBER_FEAT_IQ_ROSTER));
}
static void _RosterItemEditEnd(HWND hEditor, ROSTEREDITDAT * edat, BOOL bCancel)
diff --git a/protocols/JabberG/src/jabber_password.cpp b/protocols/JabberG/src/jabber_password.cpp
index cda5158227..3a5c7d65f0 100644
--- a/protocols/JabberG/src/jabber_password.cpp
+++ b/protocols/JabberG/src/jabber_password.cpp
@@ -71,10 +71,7 @@ static INT_PTR CALLBACK JabberChangePasswordDlgProc(HWND hwndDlg, UINT msg, WPAR
}
_tcsncpy(ppro->m_ThreadInfo->newPassword, newPasswd, SIZEOF(ppro->m_ThreadInfo->newPassword));
- int iqId = ppro->SerialNext();
- ppro->IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultSetPassword);
-
- XmlNodeIq iq(_T("set"), iqId, _A2T(ppro->m_ThreadInfo->server));
+ XmlNodeIq iq( ppro->AddIQ(&CJabberProto::OnIqResultSetPassword, JABBER_IQ_TYPE_SET, _A2T(ppro->m_ThreadInfo->server)));
HXML q = iq << XQUERY(JABBER_FEAT_REGISTER);
q << XCHILD(_T("username"), ppro->m_ThreadInfo->username);
q << XCHILD(_T("password"), newPasswd);
diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp
index eef6276e4f..9fcb7046c9 100644
--- a/protocols/JabberG/src/jabber_privacy.cpp
+++ b/protocols/JabberG/src/jabber_privacy.cpp
@@ -69,7 +69,7 @@ void CJabberProto::OnIqResultPrivacyListModify(HXML, CJabberIqInfo *pInfo)
}
}
-void CJabberProto::OnIqResultPrivacyList(HXML iqNode)
+void CJabberProto::OnIqResultPrivacyList(HXML iqNode, CJabberIqInfo*)
{
if ( !iqNode)
return;
@@ -273,11 +273,11 @@ void CJabberProto::OnIqResultPrivacyLists(HXML iqNode, CJabberIqInfo *pInfo)
m_privacyListManager.AddList((TCHAR*)listName);
// Query contents only if list editior is visible!
- if (m_pDlgPrivacyLists) {
- int iqId = SerialNext();
- IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultPrivacyList);
- m_ThreadInfo->send( XmlNodeIq(_T("get"), iqId) << XQUERY(JABBER_FEAT_PRIVACY_LISTS) << XCHILD(_T("list")) << XATTR(_T("name"), listName));
- } } }
+ if (m_pDlgPrivacyLists)
+ m_ThreadInfo->send(
+ XmlNodeIq( AddIQ(&CJabberProto::OnIqResultPrivacyList, JABBER_IQ_TYPE_GET))
+ << XQUERY(JABBER_FEAT_PRIVACY_LISTS) << XCHILD(_T("list")) << XATTR(_T("name"), listName));
+ } }
const TCHAR *szName = NULL;
HXML node = xmlGetChild(query , "active");
@@ -1711,7 +1711,7 @@ void CJabberDlgPrivacyLists::btnActivate_OnClick(CCtrlButton *)
}
EnableWindow(GetDlgItem(m_hwnd, IDC_ACTIVATE), FALSE);
SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ACTIVATE), GWLP_USERDATA, (LONG_PTR)pList);
- XmlNodeIq iq(m_proto->m_iqManager.AddHandler(&CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, NULL, 0, -1, pList));
+ XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, NULL, 0, -1, pList));
HXML query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
HXML active = query << XCHILD(_T("active"));
if (pList)
@@ -1738,7 +1738,7 @@ void CJabberDlgPrivacyLists::btnSetDefault_OnClick(CCtrlButton *)
EnableWindow(GetDlgItem(m_hwnd, IDC_SET_DEFAULT), FALSE);
SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_SET_DEFAULT), GWLP_USERDATA, (LONG_PTR)pList);
- XmlNodeIq iq(m_proto->m_iqManager.AddHandler(&CJabberProto::OnIqResultPrivacyListDefault, JABBER_IQ_TYPE_SET, NULL, 0, -1, pList));
+ XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListDefault, JABBER_IQ_TYPE_SET, NULL, 0, -1, pList));
HXML query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
HXML defaultTag = query << XCHILD(_T("default"));
if (pList)
@@ -1981,7 +1981,7 @@ void CJabberDlgPrivacyLists::btnApply_OnClick(CCtrlButton *)
pUserData->m_dwCount++;
- XmlNodeIq iq(m_proto->m_iqManager.AddHandler(&CJabberProto::OnIqResultPrivacyListModify, JABBER_IQ_TYPE_SET, NULL, 0, -1, pUserData));
+ XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListModify, JABBER_IQ_TYPE_SET, NULL, 0, -1, pUserData));
HXML query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
HXML listTag = query << XCHILD(_T("list")) << XATTR(_T("name"), pList->GetListName());
@@ -2120,7 +2120,7 @@ INT_PTR __cdecl CJabberProto::OnMenuHandlePrivacyLists(WPARAM, LPARAM)
void CJabberProto::QueryPrivacyLists(ThreadData *pThreadInfo)
{
- XmlNodeIq iq(m_iqManager.AddHandler(&CJabberProto::OnIqResultPrivacyLists));
+ XmlNodeIq iq( AddIQ(&CJabberProto::OnIqResultPrivacyLists));
iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
if (pThreadInfo)
pThreadInfo->send(iq);
@@ -2143,7 +2143,7 @@ INT_PTR __cdecl CJabberProto::menuSetPrivacyList(WPARAM, LPARAM, LPARAM iList)
pList = pList->GetNext();
}
- XmlNodeIq iq(m_iqManager.AddHandler(&CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, NULL, 0, -1, pList));
+ XmlNodeIq iq( AddIQ(&CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, NULL, 0, -1, pList));
HXML query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
HXML active = query << XCHILD(_T("active"));
if (pList)
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index 15a640f50a..bb70bc2ecd 100644
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -139,7 +139,6 @@ CJabberProto::CJabberProto(const char *aProtoName, const TCHAR *aUserName) :
InitPopups();
GlobalMenuInit();
WsInit();
- IqInit();
ConsoleInit();
InitCustomFolders();
@@ -176,7 +175,6 @@ CJabberProto::CJabberProto(const char *aProtoName, const TCHAR *aUserName) :
CJabberProto::~CJabberProto()
{
WsUninit();
- IqUninit();
ConsoleUninit();
GlobalMenuUninit();
@@ -686,11 +684,11 @@ int __cdecl CJabberProto::GetInfo(HANDLE hContact, int /*infoType*/)
if (m_ThreadInfo) {
m_ThreadInfo->send(
- XmlNodeIq(m_iqManager.AddHandler(&CJabberProto::OnIqResultEntityTime, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_HCONTACT))
+ XmlNodeIq( AddIQ(&CJabberProto::OnIqResultEntityTime, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_HCONTACT))
<< XCHILDNS(_T("time"), JABBER_FEAT_ENTITY_TIME));
// XEP-0012, last logoff time
- XmlNodeIq iq2(m_iqManager.AddHandler(&CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_FROM));
+ XmlNodeIq iq2( AddIQ(&CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_FROM));
iq2 << XQUERY(JABBER_FEAT_LAST_ACTIVITY);
m_ThreadInfo->send(iq2);
@@ -728,25 +726,25 @@ int __cdecl CJabberProto::GetInfo(HANDLE hContact, int /*infoType*/)
JabberStripJid(jid, szp1, SIZEOF(szp1));
mir_sntprintf(tmp, SIZEOF(tmp), _T("%s/%s"), szp1, r->m_tszResourceName);
- XmlNodeIq iq3(m_iqManager.AddHandler(&CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM));
+ XmlNodeIq iq3( AddIQ(&CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM));
iq3 << XQUERY(JABBER_FEAT_LAST_ACTIVITY);
m_ThreadInfo->send(iq3);
if (r->m_jcbCachedCaps & JABBER_CAPS_DISCO_INFO) {
- XmlNodeIq iq5(m_iqManager.AddHandler(&CJabberProto::OnIqResultCapsDiscoInfoSI, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE | JABBER_IQ_PARSE_HCONTACT));
+ XmlNodeIq iq5( AddIQ(&CJabberProto::OnIqResultCapsDiscoInfoSI, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE | JABBER_IQ_PARSE_HCONTACT));
iq5 << XQUERY(JABBER_FEAT_DISCO_INFO);
m_ThreadInfo->send(iq5);
}
if (r->m_dwVersionRequestTime == 0) {
- XmlNodeIq iq4(m_iqManager.AddHandler(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE));
+ XmlNodeIq iq4( AddIQ(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE));
iq4 << XQUERY(JABBER_FEAT_VERSION);
m_ThreadInfo->send(iq4);
}
}
}
else if (item->getTemp()->m_dwVersionRequestTime == 0) {
- XmlNodeIq iq4(m_iqManager.AddHandler(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, item->jid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE));
+ XmlNodeIq iq4( AddIQ(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, item->jid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE));
iq4 << XQUERY(JABBER_FEAT_VERSION);
m_ThreadInfo->send(iq4);
}
@@ -833,11 +831,10 @@ HANDLE __cdecl CJabberProto::SearchByEmail(const TCHAR *email)
ptrA szServerName( getStringA("Jud"));
- int iqId = SerialNext();
- IqAdd(iqId, IQ_PROC_GETSEARCH, &CJabberProto::OnIqResultSetSearch);
- m_ThreadInfo->send( XmlNodeIq(_T("set"), iqId, _A2T(szServerName == 0 ? "users.jabber.org" : szServerName)) << XQUERY(_T("jabber:iq:search"))
- << XCHILD(_T("email"), email));
- return (HANDLE)iqId;
+ LPCSTR jid = szServerName == 0 ? "users.jabber.org" : szServerName;
+ CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultSetSearch, JABBER_IQ_TYPE_SET, _A2T(jid));
+ m_ThreadInfo->send( XmlNodeIq(pInfo) << XQUERY(_T("jabber:iq:search")) << XCHILD(_T("email"), email));
+ return (HANDLE)pInfo->GetIqId();
}
////////////////////////////////////////////////////////////////////////////////////////
@@ -852,13 +849,13 @@ HANDLE __cdecl CJabberProto::SearchByName(const TCHAR *nick, const TCHAR *firstN
ptrA szServerName( getStringA("Jud"));
- int iqId = SerialNext();
- XmlNodeIq iq(_T("set"), iqId, _A2T(szServerName == 0 ? "users.jabber.org" : szServerName));
- HXML query = iq << XQUERY(_T("jabber:iq:search"));
+ CJabberIqInfo *pInfo = AddIQ(
+ (bIsExtFormat) ? &CJabberProto::OnIqResultExtSearch : &CJabberProto::OnIqResultSetSearch,
+ JABBER_IQ_TYPE_SET, _A2T(szServerName == 0 ? "users.jabber.org" : szServerName));
+ XmlNodeIq iq(pInfo);
+ HXML query = iq << XQUERY( _T("jabber:iq:search"));
if (bIsExtFormat) {
- IqAdd(iqId, IQ_PROC_GETSEARCH, &CJabberProto::OnIqResultExtSearch);
-
if (m_tszSelectedLang)
iq << XATTR(_T("xml:lang"), m_tszSelectedLang);
@@ -873,7 +870,6 @@ HANDLE __cdecl CJabberProto::SearchByName(const TCHAR *nick, const TCHAR *firstN
x << XCHILD(_T("field")) << XATTR(_T("var"), _T("given")) << XATTR(_T("value"), lastName);
}
else {
- IqAdd(iqId, IQ_PROC_GETSEARCH, &CJabberProto::OnIqResultSetSearch);
if (nick[0] != '\0')
query << XCHILD(_T("nick"), nick);
@@ -885,7 +881,7 @@ HANDLE __cdecl CJabberProto::SearchByName(const TCHAR *nick, const TCHAR *firstN
}
m_ThreadInfo->send(iq);
- return (HANDLE)iqId;
+ return (HANDLE)pInfo->GetIqId();
}
////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index 2a5dea1b34..148ca94695 100644
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -48,14 +48,6 @@ typedef UNIQUE_MAP<TCHAR,TCharKeyCmp> U_TCHAR_MAP;
#define JABBER_DEFAULT_RECENT_COUNT 10
-struct JABBER_IQ_FUNC
-{
- int iqId; // id to match IQ get/set with IQ result
- JABBER_IQ_PROCID procId; // must be unique in the list, except for IQ_PROC_NONE which can have multiple entries
- JABBER_IQ_PFUNC func; // callback function
- time_t requestTime; // time the request was sent, used to remove relinquent entries
-};
-
struct JABBER_GROUPCHAT_INVITE_INFO
{
TCHAR *roomJid;
@@ -241,11 +233,6 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
LIST<JabberFeatCapPairDynamic> m_lstJabberFeatCapPairsDynamic; // list of features registered through IJabberNetInterface::RegisterFeature()
JabberCapsBits m_uEnabledFeatCapsDynamic;
- CRITICAL_SECTION m_csIqList;
- JABBER_IQ_FUNC *m_ppIqList;
- int m_nIqCount;
- int m_nIqAlloced;
-
HGENMENU m_hMenuRoot;
HGENMENU m_hMenuChangePassword;
HGENMENU m_hMenuGroupchat;
@@ -296,9 +283,9 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
int AdhocQuitMirandaHandler(HXML iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession* pSession);
int AdhocLeaveGroupchatsHandler(HXML iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession* pSession);
- void OnIqResult_ListOfCommands(HXML iqNode);
- void OnIqResult_CommandExecution(HXML iqNode);
- int AdHoc_RequestListOfCommands(TCHAR * szResponder, HWND hwndDlg);
+ void OnIqResult_ListOfCommands(HXML iqNode, CJabberIqInfo*);
+ void OnIqResult_CommandExecution(HXML iqNode, CJabberIqInfo*);
+ void AdHoc_RequestListOfCommands(TCHAR * szResponder, HWND hwndDlg);
int AdHoc_ExecuteCommand(HWND hwndDlg, TCHAR * jid, struct JabberAdHocData* dat);
int AdHoc_SubmitCommandForm(HWND hwndDlg, JabberAdHocData * dat, TCHAR* action);
int AdHoc_AddCommandRadio(HWND hFrame, TCHAR * labelStr, int id, int ypos, int value);
@@ -312,8 +299,8 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void EnableArchive(bool bEnable);
void RetrieveMessageArchive(HANDLE hContact, JABBER_LIST_ITEM *pItem);
- void OnIqResultGetCollection(HXML iqNode);
- void OnIqResultGetCollectionList(HXML iqNode);
+ void OnIqResultGetCollection(HXML iqNode, CJabberIqInfo*);
+ void OnIqResultGetCollectionList(HXML iqNode, CJabberIqInfo*);
//---- jabber_bookmarks.c ------------------------------------------------------------
@@ -341,7 +328,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void ByteInitiateResult(HXML iqNode, CJabberIqInfo *pInfo);
void ByteSendViaProxy(JABBER_BYTE_TRANSFER *jbt);
int ByteSendParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen);
- void IqResultStreamActivate(HXML iqNode);
+ void IqResultStreamActivate(HXML iqNode, CJabberIqInfo *pInfo);
int ByteReceiveParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen);
int ByteSendProxyParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen);
@@ -368,7 +355,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void InviteUser(TCHAR *room, TCHAR *pUser, TCHAR *text);
void AdminSet(const TCHAR *to, const TCHAR *ns, const TCHAR *szItem, const TCHAR *itemVal, const TCHAR *var, const TCHAR *varVal);
- void AdminGet(const TCHAR *to, const TCHAR *ns, const TCHAR *var, const TCHAR *varVal, JABBER_IQ_PFUNC foo);
+ void AdminGet(const TCHAR *to, const TCHAR *ns, const TCHAR *var, const TCHAR *varVal, JABBER_IQ_HANDLER foo);
void AdminSetReason(const TCHAR *to, const TCHAR *ns, const TCHAR *szItem, const TCHAR *itemVal, const TCHAR *var, const TCHAR *varVal, const TCHAR *rsn);
void AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, TCHAR* str);
void AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, TCHAR* str , TCHAR* rsn);
@@ -473,45 +460,42 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
//---- jabber_iq.c -------------------------------------------------------------------
- JABBER_IQ_PFUNC JabberIqFetchFunc(int iqId);
+ __forceinline CJabberIqInfo* AddIQ(JABBER_IQ_HANDLER pHandler, int nIqType = JABBER_IQ_TYPE_GET, const TCHAR *szReceiver = NULL, DWORD dwParamsToParse = 0, int nIqId = -1, void *pUserData = NULL, int iPriority = JH_PRIORITY_DEFAULT)
+ {
+ return m_iqManager.AddHandler(pHandler, nIqType, szReceiver, dwParamsToParse, nIqId, pUserData, iPriority);
+ }
void __cdecl ExpirerThread(void*);
- void IqInit();
- void IqUninit();
- void IqAdd(unsigned int iqId, JABBER_IQ_PROCID procId, JABBER_IQ_PFUNC func);
- void IqRemove(int index);
- void IqExpire();
-
void OnIqResultBind(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultDiscoBookmarks(HXML iqNode);
+ void OnIqResultDiscoBookmarks(HXML iqNode, CJabberIqInfo *pInfo);
void OnIqResultEntityTime(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultExtSearch(HXML iqNode);
- void OnIqResultGetAuth(HXML iqNode);
- void OnIqResultGetVCardAvatar(HXML iqNode);
- void OnIqResultGetClientAvatar(HXML iqNode);
- void OnIqResultGetServerAvatar(HXML iqNode);
+ void OnIqResultExtSearch(HXML iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultGetAuth(HXML iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultGetVCardAvatar(HXML iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultGetClientAvatar(HXML iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultGetServerAvatar(HXML iqNode, CJabberIqInfo *pInfo);
void OnIqResultGotAvatar(HANDLE hContact, HXML n, const TCHAR *mimeType);
- void OnIqResultGetMuc(HXML iqNode);
- void OnIqResultGetRegister(HXML iqNode);
+ void OnIqResultGetMuc(HXML iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultGetRegister(HXML iqNode, CJabberIqInfo *pInfo);
void OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultGetVcard(HXML iqNode);
+ void OnIqResultGetVcard(HXML iqNode, CJabberIqInfo *pInfo);
void OnIqResultLastActivity(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultMucGetAdminList(HXML iqNode);
- void OnIqResultMucGetBanList(HXML iqNode);
- void OnIqResultMucGetMemberList(HXML iqNode);
- void OnIqResultMucGetModeratorList(HXML iqNode);
- void OnIqResultMucGetOwnerList(HXML iqNode);
- void OnIqResultMucGetVoiceList(HXML iqNode);
+ void OnIqResultMucGetAdminList(HXML iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultMucGetBanList(HXML iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultMucGetMemberList(HXML iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultMucGetModeratorList(HXML iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultMucGetOwnerList(HXML iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultMucGetVoiceList(HXML iqNode, CJabberIqInfo *pInfo);
void OnIqResultNestedRosterGroups(HXML iqNode, CJabberIqInfo *pInfo);
void OnIqResultNotes(HXML iqNode, CJabberIqInfo *pInfo);
void OnIqResultSession(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultSetAuth(HXML iqNode);
- void OnIqResultSetBookmarks(HXML iqNode);
- void OnIqResultSetPassword(HXML iqNode);
- void OnIqResultSetRegister(HXML iqNode);
- void OnIqResultSetSearch(HXML iqNode);
- void OnIqResultSetVcard(HXML iqNode);
+ void OnIqResultSetAuth(HXML iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultSetBookmarks(HXML iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultSetPassword(HXML iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultSetRegister(HXML iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultSetSearch(HXML iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultSetVcard(HXML iqNode, CJabberIqInfo *pInfo);
void OnIqResultVersion(HXML node, CJabberIqInfo *pInfo);
void OnProcessLoginRq(ThreadData* info, DWORD rq);
void OnLoggedIn(void);
@@ -578,7 +562,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void SetMucConfig(HXML node, void *from);
void OnIqResultMucGetJidList(HXML iqNode, JABBER_MUC_JIDLIST_TYPE listType);
- void OnIqResultServerDiscoInfo(HXML iqNode);
+ void OnIqResultServerDiscoInfo(HXML iqNode, CJabberIqInfo *pInfo);
void OnIqResultGetVcardPhoto(const TCHAR *jid, HXML n, HANDLE hContact, BOOL& hasPhoto);
void SetBookmarkRequest (XmlNodeIq& iqId);
@@ -643,7 +627,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void _RosterExportToFile(HWND hwndDlg);
void _RosterImportFromFile(HWND hwndDlg);
void _RosterSendRequest(HWND hwndDlg, BYTE rrAction);
- void _RosterHandleGetRequest(HXML node);
+ void _RosterHandleGetRequest(HXML node, CJabberIqInfo*);
//---- jabber_password.cpp --------------------------------------------------------------
@@ -661,7 +645,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void QueryPrivacyLists(ThreadData *pThreadInfo = NULL);
BOOL OnIqRequestPrivacyLists(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultPrivacyList(HXML iqNode);
+ void OnIqResultPrivacyList(HXML iqNode, CJabberIqInfo *pInfo);
void OnIqResultPrivacyLists(HXML iqNode, CJabberIqInfo *pInfo);
void OnIqResultPrivacyListActive(HXML iqNode, CJabberIqInfo *pInfo);
void OnIqResultPrivacyListDefault(HXML iqNode, CJabberIqInfo *pInfo);
@@ -688,8 +672,8 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
//---- jabber_search.cpp -------------------------------------------------------------
void SearchReturnResults(HANDLE id, void* pvUsersInfo, U_TCHAR_MAP* pmAllFields);
- void OnIqResultAdvancedSearch(HXML iqNode);
- void OnIqResultGetSearchFields(HXML iqNode);
+ void OnIqResultAdvancedSearch(HXML iqNode, CJabberIqInfo *pInfo);
+ void OnIqResultGetSearchFields(HXML iqNode, CJabberIqInfo *pInfo);
int SearchRenewFields(HWND hwndDlg, JabberSearchData * dat);
void SearchDeleteFromRecent(const TCHAR *szAddr, BOOL deleteLastFromDB = TRUE);
void SearchAddToRecent(const TCHAR *szAddr, HWND hwndDialog = NULL);
diff --git a/protocols/JabberG/src/jabber_search.cpp b/protocols/JabberG/src/jabber_search.cpp
index 21819e80d4..e024ee28d6 100644
--- a/protocols/JabberG/src/jabber_search.cpp
+++ b/protocols/JabberG/src/jabber_search.cpp
@@ -131,7 +131,7 @@ static int JabberSearchAddField(HWND hwndDlg, Data* FieldDat)
////////////////////////////////////////////////////////////////////////////////
// Available search field request result handler (XEP-0055. Examples 2, 7)
-void CJabberProto::OnIqResultGetSearchFields(HXML iqNode)
+void CJabberProto::OnIqResultGetSearchFields(HXML iqNode, CJabberIqInfo *pInfo)
{
if ( !searchHandleDlg)
return;
@@ -295,7 +295,7 @@ TCHAR* CopyKey(TCHAR* key)
////////////////////////////////////////////////////////////////////////////////
// Search field request result handler (XEP-0055. Examples 3, 8)
-void CJabberProto::OnIqResultAdvancedSearch(HXML iqNode)
+void CJabberProto::OnIqResultAdvancedSearch(HXML iqNode, CJabberIqInfo *pInfo)
{
const TCHAR *type;
int id;
@@ -467,10 +467,9 @@ int CJabberProto::SearchRenewFields(HWND hwndDlg, JabberSearchData * dat)
searchHandleDlg = hwndDlg;
- int iqId = SerialNext();
- IqAdd(iqId, IQ_PROC_GETSEARCHFIELDS, &CJabberProto::OnIqResultGetSearchFields);
- m_ThreadInfo->send( XmlNodeIq(_T("get"), iqId, szServerName) << XQUERY(_T("jabber:iq:search")));
- return iqId;
+ CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultGetSearchFields, JABBER_IQ_TYPE_GET, szServerName);
+ m_ThreadInfo->send( XmlNodeIq(pInfo) << XQUERY(_T("jabber:iq:search")));
+ return pInfo->GetIqId();
}
static void JabberSearchAddUrlToRecentCombo(HWND hwndDlg, const TCHAR *szAddr)
@@ -734,8 +733,8 @@ HWND __cdecl CJabberProto::SearchAdvanced(HWND hwndDlg)
GetDlgItemText(hwndDlg, IDC_SERVER, szServerName, SIZEOF(szServerName));
// formating query
- int iqId = SerialNext();
- XmlNodeIq iq(_T("set"), iqId, szServerName);
+ CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultAdvancedSearch, JABBER_IQ_TYPE_SET, szServerName);
+ XmlNodeIq iq(pInfo);
HXML query = iq << XQUERY(_T("jabber:iq:search"));
if (m_tszSelectedLang)
@@ -759,11 +758,8 @@ HWND __cdecl CJabberProto::SearchAdvanced(HWND hwndDlg)
} } }
if (fRequestNotEmpty) {
- // register search request result handler
- IqAdd(iqId, IQ_PROC_GETSEARCH, &CJabberProto::OnIqResultAdvancedSearch);
- // send request
m_ThreadInfo->send(iq);
- return (HWND)iqId;
+ return (HWND)pInfo->GetIqId();
}
return 0;
}
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp
index 34ee8b4480..6fe92b789f 100644
--- a/protocols/JabberG/src/jabber_svc.cpp
+++ b/protocols/JabberG/src/jabber_svc.cpp
@@ -159,13 +159,9 @@ INT_PTR __cdecl CJabberProto::JabberGetAvatarInfo(WPARAM wParam, LPARAM lParam)
Log("Rereading %s for %S", isXVcard ? JABBER_FEAT_VCARD_TEMP : JABBER_FEAT_AVATAR, szJid);
- int iqId = SerialNext();
- if (isXVcard)
- IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetVCardAvatar);
- else
- IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetClientAvatar);
-
- XmlNodeIq iq(_T("get"), iqId, szJid);
+ XmlNodeIq iq(
+ AddIQ((isXVcard) ? &CJabberProto::OnIqResultGetVCardAvatar : &CJabberProto::OnIqResultGetClientAvatar,
+ JABBER_IQ_TYPE_GET, szJid));
if (isXVcard)
iq << XCHILDNS(_T("vCard"), JABBER_FEAT_VCARD_TEMP);
else
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp
index 03b2b81669..0aaca01f15 100644
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -470,7 +470,7 @@ LBL_FatalError:
break;
else if (nSelRes == 0 && m_bSendKeepAlive) {
if (m_ThreadInfo->jabberServerCaps & JABBER_CAPS_PING) {
- CJabberIqInfo *pInfo = m_iqManager.AddHandler(&CJabberProto::OnPingReply, JABBER_IQ_TYPE_GET, NULL, 0, -1, this);
+ CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnPingReply, JABBER_IQ_TYPE_GET, NULL, 0, -1, this);
pInfo->SetTimeout(m_options.ConnectionKeepAliveTimeout);
info->send( XmlNodeIq(pInfo) << XATTR(_T("from"), m_ThreadInfo->fullJID) << XCHILDNS(_T("ping"), JABBER_FEAT_PING));
}
@@ -620,9 +620,8 @@ void CJabberProto::PerformRegistration(ThreadData* info)
void CJabberProto::PerformIqAuth(ThreadData* info)
{
if (info->type == JABBER_SESSION_NORMAL) {
- int iqId = SerialNext();
- IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetAuth);
- info->send( XmlNodeIq(_T("get"), iqId) << XQUERY(_T("jabber:iq:auth")) << XCHILD(_T("username"), info->username));
+ info->send( XmlNodeIq( AddIQ(&CJabberProto::OnIqResultGetAuth, JABBER_IQ_TYPE_GET))
+ << XQUERY(_T("jabber:iq:auth")) << XCHILD(_T("username"), info->username));
}
else if (info->type == JABBER_SESSION_REGISTER)
PerformRegistration(info);
@@ -820,7 +819,7 @@ void CJabberProto::OnProcessFeatures(HXML node, ThreadData* info)
// mechanisms are not defined.
if (info->auth) { //We are already logged-in
info->send(
- XmlNodeIq(m_iqManager.AddHandler(&CJabberProto::OnIqResultBind, JABBER_IQ_TYPE_SET))
+ XmlNodeIq( AddIQ(&CJabberProto::OnIqResultBind, JABBER_IQ_TYPE_SET))
<< XCHILDNS(_T("bind"), _T("urn:ietf:params:xml:ns:xmpp-bind"))
<< XCHILD(_T("resource"), info->resource));
@@ -1859,7 +1858,6 @@ void CJabberProto::OnProcessIq(HXML node)
{
HXML queryNode;
const TCHAR *type, *xmlns;
- JABBER_IQ_PFUNC pfunc;
if ( !xmlGetName(node) || _tcscmp(xmlGetName(node), _T("iq"))) return;
if ((type=xmlGetAttrValue(node, _T("type"))) == NULL) return;
@@ -1882,14 +1880,6 @@ void CJabberProto::OnProcessIq(HXML node)
if (OnProcessJingle(node))
return;
- /////////////////////////////////////////////////////////////////////////
- // OLD MATCH BY ID
- /////////////////////////////////////////////////////////////////////////
- if ((!_tcscmp(type, _T("result")) || !_tcscmp(type, _T("error"))) && ((pfunc=JabberIqFetchFunc(id)) != NULL)) {
- Log("Handling iq request for id=%d", id);
- (this->*pfunc)(node);
- return;
- }
// RECVED: <iq type='error'> ...
if ( !_tcscmp(type, _T("error"))) {
Log("XXX on entry");
diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp
index d479960324..c8b875165b 100644
--- a/protocols/JabberG/src/jabber_vcard.cpp
+++ b/protocols/JabberG/src/jabber_vcard.cpp
@@ -34,15 +34,11 @@ int CJabberProto::SendGetVcard(const TCHAR *jid)
{
if ( !m_bJabberOnline) return 0;
- int iqId = SerialNext();
- JABBER_IQ_PROCID procId = !lstrcmp(jid, m_szJabberJID) ? IQ_PROC_GETVCARD : IQ_PROC_NONE;
+ CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultGetVcard, JABBER_IQ_TYPE_GET, jid);
+ m_ThreadInfo->send( XmlNodeIq(pInfo) << XCHILDNS(_T("vCard"), JABBER_FEAT_VCARD_TEMP)
+ << XATTR(_T("prodid"), _T("-//HandGen//NONSGML vGen v1.0//EN")) << XATTR(_T("version"), _T("2.0")));
- IqAdd(iqId, procId, &CJabberProto::OnIqResultGetVcard);
- m_ThreadInfo->send(
- XmlNodeIq(_T("get"), iqId, jid) << XCHILDNS(_T("vCard"), JABBER_FEAT_VCARD_TEMP)
- << XATTR(_T("prodid"), _T("-//HandGen//NONSGML vGen v1.0//EN")) << XATTR(_T("version"), _T("2.0")));
-
- return iqId;
+ return pInfo->GetIqId();
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -1033,16 +1029,12 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName)
if ( !m_bJabberOnline) return;
DBVARIANT dbv;
- int iqId;
TCHAR *szFileName;
int i;
char idstr[33];
WORD nFlag;
- iqId = SerialNext();
- IqAdd(iqId, IQ_PROC_SETVCARD, &CJabberProto::OnIqResultSetVcard);
-
- XmlNodeIq iq(_T("set"), iqId);
+ XmlNodeIq iq( AddIQ(&CJabberProto::OnIqResultSetVcard, JABBER_IQ_TYPE_SET));
HXML v = iq << XCHILDNS(_T("vCard"), JABBER_FEAT_VCARD_TEMP);
AppendVcardFromDB(v, "FN", "FullName");
@@ -1056,7 +1048,7 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName)
AppendVcardFromDB(v, "BDAY", "BirthDate");
AppendVcardFromDB(v, "GENDER", "GenderString");
- for (i=0;;i++) {
+ for (i=0; ; i++) {
mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", i);
if ( getTString(idstr, &dbv))
break;
@@ -1104,7 +1096,7 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName)
AppendVcardFromDB(v, "URL", "Homepage");
AppendVcardFromDB(v, "DESC", "About");
- for (i=0;;i++) {
+ for (i=0; ; i++) {
mir_snprintf(idstr, SIZEOF(idstr), "Phone%d", i);
if ( getTString(idstr, &dbv)) break;
db_free(&dbv);