summaryrefslogtreecommitdiff
path: root/protocols/JabberG
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-06-26 19:38:43 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-06-26 19:38:43 +0300
commitb58a27002bb24772dcfbc7d44387c29e84127374 (patch)
tree16f4b09cb42affadd2aa66e3f6f4f3d8f28c05e8 /protocols/JabberG
parent0fc0c03f8176b13f0596e90bb3832040cf46c9af (diff)
two more obsolete messages removed
Diffstat (limited to 'protocols/JabberG')
-rw-r--r--protocols/JabberG/src/jabber_agent.cpp179
-rwxr-xr-xprotocols/JabberG/src/jabber_iqid.cpp21
-rwxr-xr-xprotocols/JabberG/src/jabber_proto.cpp1
-rwxr-xr-xprotocols/JabberG/src/jabber_proto.h6
-rwxr-xr-xprotocols/JabberG/src/stdafx.h2
5 files changed, 103 insertions, 106 deletions
diff --git a/protocols/JabberG/src/jabber_agent.cpp b/protocols/JabberG/src/jabber_agent.cpp
index 7d7badaeec..7db3ebcc3a 100644
--- a/protocols/JabberG/src/jabber_agent.cpp
+++ b/protocols/JabberG/src/jabber_agent.cpp
@@ -67,12 +67,7 @@ public:
}
};
-void CJabberProto::AgentShutdown()
-{
- UI_SAFE_CLOSE(m_pDlgReg);
-}
-
-void CJabberProto::OnIqAgentRegister(const TiXmlElement *iqNode, CJabberIqInfo *)
+void CJabberProto::OnIqAgentSetRegister(const TiXmlElement *iqNode, CJabberIqInfo *)
{
// RECVED: result of registration process
// ACTION: notify of successful agent registration
@@ -118,8 +113,9 @@ public:
bool OnInitDialog() override
{
+ m_proto->m_pDlgAgentReg = this;
+
EnableWindow(GetParent(m_hwnd), FALSE);
- m_proto->m_hwndAgentRegInput = m_hwnd;
SetWindowText(m_hwnd, TranslateT("Jabber Agent Registration"));
SetDlgItemText(m_hwnd, IDOK, TranslateT("Register"));
@@ -128,8 +124,7 @@ public:
SetWindowTextW(m_statusBar, TranslateT("Please wait..."));
m_proto->m_ThreadInfo->send(
- XmlNodeIq(m_proto->AddIQ(&CJabberProto::OnIqResultGetRegister, JABBER_IQ_TYPE_GET, m_jid))
- << XQUERY(JABBER_FEAT_REGISTER));
+ XmlNodeIq(m_proto->AddIQ(&CJabberProto::OnIqAgentGetRegister, 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_PTR frameExStyle = GetWindowLongPtr(GetDlgItem(m_hwnd, IDC_FRAME), GWL_EXSTYLE);
@@ -151,7 +146,7 @@ public:
HWND hwndFrame = GetDlgItem(m_hwnd, IDC_FRAME);
int id = 0;
- XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqAgentRegister, JABBER_IQ_TYPE_SET, from));
+ XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqAgentSetRegister, JABBER_IQ_TYPE_SET, from));
TiXmlElement *query = iq << XQUERY(JABBER_FEAT_REGISTER);
if (auto *xNode = XmlFirstChild(queryNode, "x")) {
@@ -192,11 +187,78 @@ public:
void OnDestroy() override
{
JabberFormDestroyUI(GetDlgItem(m_hwnd, IDC_FRAME));
- m_proto->m_hwndAgentRegInput = nullptr;
+ m_proto->m_pDlgAgentReg = nullptr;
EnableWindow(GetParent(m_hwnd), TRUE);
SetActiveWindow(GetParent(m_hwnd));
}
+ void Success(const TiXmlElement *pNode)
+ {
+ HWND hwndFrame = GetDlgItem(m_hwnd, IDC_FRAME);
+ SetWindowTextW(m_statusBar, L"");
+
+ if (pNode == nullptr)
+ return;
+
+ m_agentRegIqNode = pNode->DeepClone(&m_doc)->ToElement();
+ auto *queryNode = XmlFirstChild(m_agentRegIqNode, "query");
+ if (queryNode == nullptr)
+ return;
+
+ m_curPos = 0;
+ GetClientRect(GetDlgItem(m_hwnd, IDC_FRAME), &m_frameRect);
+
+ RECT rect;
+ GetClientRect(GetDlgItem(m_hwnd, IDC_VSCROLL), &rect);
+ m_frameRect.right -= (rect.right - rect.left);
+ GetClientRect(GetDlgItem(m_hwnd, IDC_FRAME), &rect);
+ m_frameHeight = rect.bottom - rect.top;
+
+ if (auto *xNode = XmlFirstChild(queryNode, "x")) {
+ // use new jabber:x:data form
+ if (const char *pszText = XmlGetChildText(xNode, "instructions"))
+ JabberFormSetInstruction(m_hwnd, pszText);
+
+ JabberFormCreateUI(hwndFrame, xNode, &m_formHeight);
+ }
+ else {
+ // use old registration information form
+ TJabberFormLayoutInfo layout_info(hwndFrame, false);
+ for (auto *n : TiXmlEnum(queryNode)) {
+ const char *pszName = n->Name();
+ if (pszName) {
+ if (!mir_strcmp(pszName, "instructions")) {
+ JabberFormSetInstruction(m_hwnd, n->GetText());
+ }
+ else if (!mir_strcmp(pszName, "key") || !mir_strcmp(pszName, "registered")) {
+ // do nothing
+ }
+ else if (!mir_strcmp(pszName, "password"))
+ layout_info.AppendControl(JFORM_CTYPE_TEXT_PRIVATE, pszName, n->GetText());
+ else // everything else is a normal text field
+ layout_info.AppendControl(JFORM_CTYPE_TEXT_SINGLE, pszName, n->GetText());
+ }
+ }
+ layout_info.OrderControls(&m_formHeight);
+ }
+
+ if (m_formHeight > m_frameHeight) {
+ HWND hwndScroll;
+
+ hwndScroll = GetDlgItem(m_hwnd, IDC_VSCROLL);
+ EnableWindow(hwndScroll, TRUE);
+ SetScrollRange(hwndScroll, SB_CTL, 0, m_formHeight - m_frameHeight, FALSE);
+ m_curPos = 0;
+ }
+
+ EnableWindow(GetDlgItem(m_hwnd, IDOK), TRUE);
+ }
+
+ void Fail(const CMStringW &wszErrMsg)
+ {
+ SetWindowText(m_statusBar, wszErrMsg);
+ }
+
INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override
{
switch (msg) {
@@ -208,74 +270,6 @@ public:
return 0;
}
- case WM_JABBER_REGINPUT_ACTIVATE:
- if (wParam == 1) { // success
- // lParam = <iq/> node from agent JID as a result of "get jabber:iq:register"
- HWND hwndFrame = GetDlgItem(m_hwnd, IDC_FRAME);
- SetWindowTextW(m_statusBar, L"");
-
- if ((m_agentRegIqNode = (TiXmlElement*)lParam) == nullptr)
- return TRUE;
-
- m_agentRegIqNode = m_agentRegIqNode->DeepClone(&m_doc)->ToElement();
- auto *queryNode = XmlFirstChild(m_agentRegIqNode, "query");
- if (queryNode == nullptr)
- return TRUE;
-
- m_curPos = 0;
- GetClientRect(GetDlgItem(m_hwnd, IDC_FRAME), &m_frameRect);
-
- RECT rect;
- GetClientRect(GetDlgItem(m_hwnd, IDC_VSCROLL), &rect);
- m_frameRect.right -= (rect.right - rect.left);
- GetClientRect(GetDlgItem(m_hwnd, IDC_FRAME), &rect);
- m_frameHeight = rect.bottom - rect.top;
-
- if (auto *xNode = XmlFirstChild(queryNode, "x")) {
- // use new jabber:x:data form
- if (const char *pszText = XmlGetChildText(xNode, "instructions"))
- JabberFormSetInstruction(m_hwnd, pszText);
-
- JabberFormCreateUI(hwndFrame, xNode, &m_formHeight);
- }
- else {
- // use old registration information form
- TJabberFormLayoutInfo layout_info(hwndFrame, false);
- for (auto *n : TiXmlEnum(queryNode)) {
- const char *pszName = n->Name();
- if (pszName) {
- if (!mir_strcmp(pszName, "instructions")) {
- JabberFormSetInstruction(m_hwnd, n->GetText());
- }
- else if (!mir_strcmp(pszName, "key") || !mir_strcmp(pszName, "registered")) {
- // do nothing
- }
- else if (!mir_strcmp(pszName, "password"))
- layout_info.AppendControl(JFORM_CTYPE_TEXT_PRIVATE, pszName, n->GetText());
- else // everything else is a normal text field
- layout_info.AppendControl(JFORM_CTYPE_TEXT_SINGLE, pszName, n->GetText());
- }
- }
- layout_info.OrderControls(&m_formHeight);
- }
-
- if (m_formHeight > m_frameHeight) {
- HWND hwndScroll;
-
- hwndScroll = GetDlgItem(m_hwnd, IDC_VSCROLL);
- EnableWindow(hwndScroll, TRUE);
- SetScrollRange(hwndScroll, SB_CTL, 0, m_formHeight - m_frameHeight, FALSE);
- m_curPos = 0;
- }
-
- EnableWindow(GetDlgItem(m_hwnd, IDOK), TRUE);
- }
- else if (wParam == 0) {
- // lParam = error message
- SetWindowText(m_statusBar, (const wchar_t *)lParam);
- }
- return TRUE;
-
case WM_VSCROLL:
int pos = m_curPos;
switch (LOWORD(wParam)) {
@@ -304,3 +298,30 @@ void CJabberProto::RegisterAgent(HWND, char *jid)
{
(new CAgentRegDlg(this, jid))->Show();
}
+
+void CJabberProto::OnIqAgentGetRegister(const TiXmlElement *iqNode, CJabberIqInfo *)
+{
+ // RECVED: result of the request for (agent) registration mechanism
+ // ACTION: activate (agent) registration input dialog
+ debugLogA("<iq/> iqIdGetRegister");
+
+ const TiXmlElement *queryNode;
+ const char *type;
+ if ((type = XmlGetAttr(iqNode, "type")) == nullptr) return;
+ if ((queryNode = XmlFirstChild(iqNode, "query")) == nullptr) return;
+
+ if (!mir_strcmp(type, "result")) {
+ if (m_pDlgAgentReg)
+ m_pDlgAgentReg->Success(iqNode);
+ }
+ else if (!mir_strcmp(type, "error")) {
+ if (m_pDlgAgentReg)
+ m_pDlgAgentReg->Fail(JabberErrorMsg(iqNode));
+ }
+}
+
+void CJabberProto::AgentShutdown()
+{
+ UI_SAFE_CLOSE(m_pDlgReg);
+ UI_SAFE_CLOSE(m_pDlgAgentReg);
+}
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp
index 39c695f69d..c34cc8cb50 100755
--- a/protocols/JabberG/src/jabber_iqid.cpp
+++ b/protocols/JabberG/src/jabber_iqid.cpp
@@ -469,27 +469,6 @@ void CJabberProto::OnIqResultGetRoster(const TiXmlElement *iqNode, CJabberIqInfo
RebuildInfoFrame();
}
-void CJabberProto::OnIqResultGetRegister(const TiXmlElement *iqNode, CJabberIqInfo*)
-{
- // RECVED: result of the request for (agent) registration mechanism
- // ACTION: activate (agent) registration input dialog
- debugLogA("<iq/> iqIdGetRegister");
-
- const TiXmlElement *queryNode;
- const char *type;
- if ((type = XmlGetAttr(iqNode, "type")) == nullptr) return;
- if ((queryNode = XmlFirstChild(iqNode, "query")) == nullptr) return;
-
- if (!mir_strcmp(type, "result")) {
- if (m_hwndAgentRegInput)
- SendMessage(m_hwndAgentRegInput, WM_JABBER_REGINPUT_ACTIVATE, 1 /*success*/, (LPARAM)iqNode);
- }
- else if (!mir_strcmp(type, "error")) {
- if (m_hwndAgentRegInput)
- SendMessage(m_hwndAgentRegInput, WM_JABBER_REGINPUT_ACTIVATE, 0 /*error*/, (LPARAM)JabberErrorMsg(iqNode).c_str());
- }
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
// JabberIqResultGetVcard - processes the server-side v-card
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index b249df7ed9..a28fcc7b87 100755
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -331,7 +331,6 @@ void CJabberProto::OnShutdown()
{
m_bShutdown = true;
- UI_SAFE_CLOSE_HWND(m_hwndAgentRegInput);
UI_SAFE_CLOSE_HWND(m_hwndJabberChangePassword);
UI_SAFE_CLOSE_HWND(m_hwndJabberAddBookmark);
UI_SAFE_CLOSE_HWND(m_hwndPrivacyRule);
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index bd0c06d54e..a7a65ff709 100755
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -251,7 +251,6 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
bool m_bStreamSent;
bool m_bMamPrefsAvailable;
- HWND m_hwndAgentRegInput;
HWND m_hwndJabberChangePassword;
HWND m_hwndPrivacyRule;
HWND m_hwndJabberAddBookmark;
@@ -362,9 +361,11 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
//---- jabber_agent.c ----------------------------------------------------------------
class CAgentRegProgressDlg *m_pDlgReg;
+ class CAgentRegDlg *m_pDlgAgentReg;
void AgentShutdown();
- void OnIqAgentRegister(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqAgentGetRegister(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
+ void OnIqAgentSetRegister(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
//---- jabber_archive.c --------------------------------------------------------------
@@ -540,7 +541,6 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void OnIqResultGetServerAvatar(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
void OnIqResultGotAvatar(MCONTACT hContact, const char *pszText, const char *mimeType);
void OnIqResultGetMuc(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
- void OnIqResultGetRegister(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
void OnIqResultGetRoster(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
void OnIqResultGetVcard(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
void OnIqResultLastActivity(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h
index f5f73f96ae..ae23167963 100755
--- a/protocols/JabberG/src/stdafx.h
+++ b/protocols/JabberG/src/stdafx.h
@@ -179,9 +179,7 @@ protected:
#define JABBER_DB_EVENT_PRESENCE_ERROR 5
// User-defined message
-#define WM_JABBER_AGENT_REFRESH (WM_PROTO_LAST + 101)
#define WM_JABBER_TRANSPORT_REFRESH (WM_PROTO_LAST + 102)
-#define WM_JABBER_REGINPUT_ACTIVATE (WM_PROTO_LAST + 103)
#define WM_JABBER_CHANGED (WM_PROTO_LAST + 106)
#define WM_JABBER_SET_FONT (WM_PROTO_LAST + 108)
#define WM_JABBER_FLASHWND (WM_PROTO_LAST + 109)