summaryrefslogtreecommitdiff
path: root/protocols/JabberG
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-07-08 19:38:08 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-07-08 19:38:08 +0300
commit48708565d05d099b5ea1d4bd0e0c80d047888b8f (patch)
tree123f0b247887e9628423cfbf0c11e58d0e2accd2 /protocols/JabberG
parent415ac2910116ee6e4716568ecf30514c91b6e1ff (diff)
Jabber: fix for CAgentRegDlg to launch commands from the main thread
Diffstat (limited to 'protocols/JabberG')
-rw-r--r--protocols/JabberG/src/jabber_agent.cpp39
1 files changed, 30 insertions, 9 deletions
diff --git a/protocols/JabberG/src/jabber_agent.cpp b/protocols/JabberG/src/jabber_agent.cpp
index 7db3ebcc3a..035368d278 100644
--- a/protocols/JabberG/src/jabber_agent.cpp
+++ b/protocols/JabberG/src/jabber_agent.cpp
@@ -243,9 +243,7 @@ public:
}
if (m_formHeight > m_frameHeight) {
- HWND hwndScroll;
-
- hwndScroll = GetDlgItem(m_hwnd, IDC_VSCROLL);
+ HWND hwndScroll = GetDlgItem(m_hwnd, IDC_VSCROLL);
EnableWindow(hwndScroll, TRUE);
SetScrollRange(hwndScroll, SB_CTL, 0, m_formHeight - m_frameHeight, FALSE);
m_curPos = 0;
@@ -294,9 +292,32 @@ public:
}
};
-void CJabberProto::RegisterAgent(HWND, char *jid)
+void CJabberProto::RegisterAgent(HWND hwndParent, char *jid)
+{
+ auto *pDlg = new CAgentRegDlg(this, jid);
+ pDlg->SetParent(hwndParent);
+ pDlg->Show();
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+struct TAgentParam
+{
+ CAgentRegDlg *pDlg;
+ bool bSuccess;
+ const TiXmlElement *iqNode;
+};
+
+static INT_PTR CALLBACK sttFinish(void *param)
{
- (new CAgentRegDlg(this, jid))->Show();
+ auto *p = (TAgentParam *)param;
+ if (p->pDlg) {
+ if (p->bSuccess)
+ p->pDlg->Success(p->iqNode);
+ else
+ p->pDlg->Fail(JabberErrorMsg(p->iqNode));
+ }
+ return 0;
}
void CJabberProto::OnIqAgentGetRegister(const TiXmlElement *iqNode, CJabberIqInfo *)
@@ -311,12 +332,12 @@ void CJabberProto::OnIqAgentGetRegister(const TiXmlElement *iqNode, CJabberIqInf
if ((queryNode = XmlFirstChild(iqNode, "query")) == nullptr) return;
if (!mir_strcmp(type, "result")) {
- if (m_pDlgAgentReg)
- m_pDlgAgentReg->Success(iqNode);
+ TAgentParam param = { m_pDlgAgentReg, true, iqNode };
+ CallFunctionSync(sttFinish, &param);
}
else if (!mir_strcmp(type, "error")) {
- if (m_pDlgAgentReg)
- m_pDlgAgentReg->Fail(JabberErrorMsg(iqNode));
+ TAgentParam param = { m_pDlgAgentReg, false, iqNode };
+ CallFunctionSync(sttFinish, &param);
}
}