diff options
author | George Hazan <ghazan@miranda.im> | 2020-06-04 12:55:23 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-06-04 12:55:29 +0300 |
commit | 1c2e5d128a7176ae827dda1e2a8fcc64e772a148 (patch) | |
tree | e8fa55c910cd479b8aa3ca0294a9f564f98753ea | |
parent | 624ebde8a9f3278c2af39f009e004786c98dbc35 (diff) |
fixes #2420 (empty error window in StdMsg/Scriver)
-rw-r--r-- | plugins/Scriver/src/globals.cpp | 2 | ||||
-rw-r--r-- | plugins/Scriver/src/msgdialog.cpp | 17 | ||||
-rw-r--r-- | plugins/Scriver/src/msgs.h | 22 | ||||
-rw-r--r-- | plugins/Scriver/src/msgtimedout.cpp | 108 | ||||
-rw-r--r-- | plugins/Scriver/src/sendqueue.cpp | 2 | ||||
-rw-r--r-- | plugins/Scriver/src/version.h | 2 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgtimedout.cpp | 11 |
7 files changed, 82 insertions, 82 deletions
diff --git a/plugins/Scriver/src/globals.cpp b/plugins/Scriver/src/globals.cpp index 025cca09b6..ac1d9be163 100644 --- a/plugins/Scriver/src/globals.cpp +++ b/plugins/Scriver/src/globals.cpp @@ -133,7 +133,7 @@ static int ackevent(WPARAM, LPARAM lParam) if (item != nullptr && item->hwndErrorDlg == nullptr) {
if (pSender != nullptr) {
pSender->StopMessageSending();
- (new CErrorDlg((wchar_t *)pAck->lParam, pSender, item))->Create();
+ pSender->ShowError((wchar_t *)pAck->lParam, item);
}
else RemoveSendQueueItem(item);
}
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 84972181c8..18534fce4a 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -1320,23 +1320,6 @@ INT_PTR CMsgDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) }
break;
- case DM_ERRORDECIDED:
- {
- MessageSendQueueItem *item = (MessageSendQueueItem *)lParam;
- item->hwndErrorDlg = nullptr;
- switch (wParam) {
- case MSGERROR_CANCEL:
- RemoveSendQueueItem(item);
- SetFocus(m_message.GetHwnd());
- break;
- case MSGERROR_RETRY:
- StartMessageSending();
- SendSendQueueItem(item);
- break;
- }
- }
- break;
-
case WM_MEASUREITEM:
if (!MeasureMenuItem(wParam, lParam)) {
MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *)lParam;
diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h index e25128b5ac..79b18c4504 100644 --- a/plugins/Scriver/src/msgs.h +++ b/plugins/Scriver/src/msgs.h @@ -181,6 +181,9 @@ public: void UpdateStatusBar() override;
void UpdateTitle() override;
+ void HandleError(bool bRetry, MessageSendQueueItem *pItem);
+ void ShowError(const wchar_t *pwszMsg, MessageSendQueueItem *pItem);
+
void FixTabIcons();
void GetAvatar();
void SwitchTyping(void);
@@ -220,7 +223,6 @@ public: #define DM_REMAKELOG (WM_USER+12)
#define DM_CASCADENEWWINDOW (WM_USER+13)
#define DM_OPTIONSAPPLIED (WM_USER+14)
-#define DM_ERRORDECIDED (WM_USER+18)
#define DM_CHANGEICONS (WM_USER+24)
#define DM_STATUSICONCHANGE (WM_USER+56)
@@ -233,24 +235,6 @@ public: #define EVENTTYPE_JABBER_CHATSTATES 2000
#define EVENTTYPE_JABBER_PRESENCE 2001
-class CErrorDlg : public CDlgBase
-{
- ptrW m_wszText;
- CMStringW m_wszName, m_wszDescr;
- MessageSendQueueItem *m_queueItem;
-
- CCtrlButton m_btnOk, m_btnCancel;
-
-protected:
- bool OnInitDialog() override;
-
-public:
- CErrorDlg(const wchar_t *pwszDescr, CMsgDialog *pDlg, MessageSendQueueItem*);
-
- void onOk(CCtrlButton*);
- void onCancel(CCtrlButton*);
-};
-
int DbEventIsShown(DBEVENTINFO &dbei);
int DbEventIsCustomForMsgWindow(DBEVENTINFO *dbei);
int DbEventIsMessageOrCustom(DBEVENTINFO *dbei);
diff --git a/plugins/Scriver/src/msgtimedout.cpp b/plugins/Scriver/src/msgtimedout.cpp index 6f8e1adae8..ba621e4434 100644 --- a/plugins/Scriver/src/msgtimedout.cpp +++ b/plugins/Scriver/src/msgtimedout.cpp @@ -23,52 +23,82 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-CErrorDlg::CErrorDlg(const wchar_t *pwszDescr, CMsgDialog *pDlg, MessageSendQueueItem *pItem) :
- CDlgBase(g_plugin, IDD_MSGSENDERROR),
- m_wszText(mir_utf8decodeW(pItem->sendBuffer)),
- m_wszDescr(pwszDescr != nullptr ? pwszDescr : TranslateT("An unknown error has occurred.")),
- m_queueItem(pItem),
-
- m_btnOk(this, IDOK),
- m_btnCancel(this, IDCANCEL)
+class CErrorDlg : public CDlgBase
{
- SetParent(pDlg->GetHwnd());
+ bool m_bRetry = false;
+ ptrW m_wszText;
+ CMStringW m_wszName, m_wszDescr;
+ CMsgDialog *m_pOwner;
+ MessageSendQueueItem *m_queueItem;
- const wchar_t *pwszName = Clist_GetContactDisplayName(pItem->hContact);
- if (pwszName)
- m_wszName.Format(L"%s - %s", TranslateT("Send error"), pwszName);
- else
- m_wszName = TranslateT("Send error");
+ CCtrlBase m_errorText, m_msgText;
- m_btnOk.OnClick = Callback(this, &CErrorDlg::onOk);
- m_btnCancel.OnClick = Callback(this, &CErrorDlg::onCancel);
-}
+public:
+ CErrorDlg(CMsgDialog *pOwner, const wchar_t *pwszDescr, MessageSendQueueItem *pItem) :
+ CDlgBase(g_plugin, IDD_MSGSENDERROR),
+ m_pOwner(pOwner),
+ m_wszText(mir_utf8decodeW(pItem->sendBuffer)),
+ m_wszDescr(pwszDescr != nullptr ? pwszDescr : TranslateT("An unknown error has occurred.")),
+ m_queueItem(pItem),
-bool CErrorDlg::OnInitDialog()
-{
- ShowWindow(GetParent(m_hwndParent), SW_RESTORE);
-
- SetDlgItemText(m_hwnd, IDC_ERRORTEXT, m_wszDescr);
- SetWindowText(m_hwnd, m_wszName);
-
- SETTEXTEX st = { 0 };
- st.flags = ST_DEFAULT;
- st.codepage = 1200;
- SendDlgItemMessage(m_hwnd, IDC_MSGTEXT, EM_SETTEXTEX, (WPARAM)&st, (LPARAM)m_wszText.get());
-
- RECT rc, rcParent;
- GetWindowRect(m_hwnd, &rc);
- GetWindowRect(GetParent(m_hwndParent), &rcParent);
- SetWindowPos(m_hwnd, HWND_TOP, rcParent.left + (rcParent.right - rcParent.left - rc.right + rc.left) / 2, rcParent.top + (rcParent.bottom - rcParent.top - rc.bottom + rc.top) / 2, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
- return true;
-}
+ m_msgText(this, IDC_MSGTEXT),
+ m_errorText(this, IDC_ERRORTEXT)
+ {
+ const wchar_t *pwszName = Clist_GetContactDisplayName(pItem->hContact);
+ if (pwszName)
+ m_wszName.Format(L"%s - %s", TranslateT("Send error"), pwszName);
+ else
+ m_wszName = TranslateT("Send error");
+ }
+
+ bool OnInitDialog() override
+ {
+ m_queueItem->hwndErrorDlg = m_hwnd;
+ ShowWindow(GetParent(m_hwndParent), SW_RESTORE);
+
+ m_errorText.SetText(m_wszDescr);
+ SetWindowText(m_hwnd, m_wszName);
+
+ SETTEXTEX st = { 0 };
+ st.flags = ST_DEFAULT;
+ st.codepage = 1200;
+ m_msgText.SendMsg(EM_SETTEXTEX, (WPARAM)&st, (LPARAM)m_wszText.get());
+
+ RECT rc, rcParent;
+ GetWindowRect(m_hwnd, &rc);
+ GetWindowRect(GetParent(m_hwndParent), &rcParent);
+ SetWindowPos(m_hwnd, HWND_TOP, rcParent.left + (rcParent.right - rcParent.left - rc.right + rc.left) / 2, rcParent.top + (rcParent.bottom - rcParent.top - rc.bottom + rc.top) / 2, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
+ return true;
+ }
+
+ bool OnApply() override
+ {
+ m_bRetry = true;
+ return true;
+ }
+
+ void OnDestroy() override
+ {
+ m_queueItem->hwndErrorDlg = nullptr;
+ m_pOwner->HandleError(m_bRetry, m_queueItem);
+ }
+};
-void CErrorDlg::onOk(CCtrlButton*)
+void CMsgDialog::ShowError(const wchar_t *pwszMsg, MessageSendQueueItem *pItem)
{
- SendMessage(m_hwndParent, DM_ERRORDECIDED, MSGERROR_RETRY, (LPARAM)m_queueItem);
+ auto *pDlg = new CErrorDlg(this, pwszMsg, pItem);
+ pDlg->SetParent(m_hwnd);
+ pDlg->Show();
}
-void CErrorDlg::onCancel(CCtrlButton*)
+void CMsgDialog::HandleError(bool bRetry, MessageSendQueueItem *pItem)
{
- SendMessage(m_hwndParent, DM_ERRORDECIDED, MSGERROR_CANCEL, (LPARAM)m_queueItem);
+ if (bRetry) {
+ StartMessageSending();
+ SendSendQueueItem(pItem);
+ }
+ else {
+ RemoveSendQueueItem(pItem);
+ SetFocus(m_message.GetHwnd());
+ }
}
diff --git a/plugins/Scriver/src/sendqueue.cpp b/plugins/Scriver/src/sendqueue.cpp index bfd39e3ce5..2447759f57 100644 --- a/plugins/Scriver/src/sendqueue.cpp +++ b/plugins/Scriver/src/sendqueue.cpp @@ -87,7 +87,7 @@ void ReportSendQueueTimeouts(CMsgDialog *pDlg) if (pDlg != nullptr) {
pDlg->StopMessageSending();
- (new CErrorDlg(TranslateT("The message send timed out."), pDlg, it))->Create();
+ pDlg->ShowError(TranslateT("The message send timed out."), it);
}
else arQueue.removeItem(&it);
}
diff --git a/plugins/Scriver/src/version.h b/plugins/Scriver/src/version.h index f4087f605e..3430e2cd0c 100644 --- a/plugins/Scriver/src/version.h +++ b/plugins/Scriver/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 3 #define __MINOR_VERSION 0 #define __RELEASE_NUM 2 -#define __BUILD_NUM 1 +#define __BUILD_NUM 2 #include <stdver.h> diff --git a/src/core/stdmsg/src/msgtimedout.cpp b/src/core/stdmsg/src/msgtimedout.cpp index f0351042b3..25df4af3c4 100644 --- a/src/core/stdmsg/src/msgtimedout.cpp +++ b/src/core/stdmsg/src/msgtimedout.cpp @@ -26,11 +26,14 @@ class CErrorDlg : public CDlgBase {
TMsgQueue *m_item;
CMStringW m_wszErr;
+ CCtrlBase m_errorText, m_msgText;
public:
CErrorDlg(TMsgQueue *item, const wchar_t *err, HWND hwndParent) :
CDlgBase(g_plugin, IDD_MSGSENDERROR),
- m_item(item)
+ m_item(item),
+ m_msgText(this, IDC_MSGTEXT),
+ m_errorText(this, IDC_ERRORTEXT)
{
if (err)
m_wszErr = err;
@@ -41,11 +44,11 @@ public: bool OnInitDialog() override
{
if (m_wszErr.IsEmpty())
- SetCaption(TranslateT("An unknown error has occurred."));
+ m_errorText.SetText(TranslateT("An unknown error has occurred."));
else
- SetCaption(m_wszErr);
+ m_errorText.SetText(m_wszErr);
- SetDlgItemText(m_hwnd, IDC_MSGTEXT, ptrW(mir_utf8decodeW(m_item->szMsg)));
+ m_msgText.SetText(ptrW(mir_utf8decodeW(m_item->szMsg)));
if (m_hwndParent != nullptr) {
RECT rc, rcParent;
|