summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_gui.h16
-rw-r--r--plugins/CrashDumper/src/ui.cpp13
-rw-r--r--plugins/Dbx_mdbx/src/dbcrypt.cpp64
-rw-r--r--plugins/Import/src/ui.cpp9
-rw-r--r--plugins/MyDetails/src/services.cpp36
-rwxr-xr-xplugins/New_GPG/src/ui.cpp25
-rwxr-xr-xplugins/New_GPG/src/ui.h6
-rw-r--r--plugins/PluginUpdater/src/DlgListNew.cpp17
-rw-r--r--plugins/Scriver/src/msgtimedout.cpp9
-rw-r--r--plugins/StopSpamPlus/src/options.cpp2
-rw-r--r--protocols/CloudFile/src/oauth.cpp12
-rw-r--r--protocols/CloudFile/src/oauth.h4
-rw-r--r--protocols/IRCG/src/irc_dlg.h27
-rw-r--r--protocols/IRCG/src/options.cpp34
-rw-r--r--protocols/IRCG/src/windows.cpp39
-rw-r--r--protocols/JabberG/res/jabber.rc4
-rw-r--r--protocols/JabberG/src/jabber_adhoc.cpp30
-rw-r--r--protocols/JabberG/src/jabber_agent.cpp122
-rw-r--r--protocols/JabberG/src/jabber_captcha.cpp2
-rw-r--r--protocols/JabberG/src/jabber_form.cpp28
-rw-r--r--protocols/JabberG/src/jabber_groupchat.cpp31
-rw-r--r--protocols/JabberG/src/jabber_notes.cpp32
-rwxr-xr-xprotocols/JabberG/src/jabber_opt.cpp39
-rw-r--r--protocols/JabberG/src/jabber_privacy.cpp138
-rw-r--r--protocols/JabberG/src/jabber_svc.cpp34
-rw-r--r--protocols/JabberG/src/jabber_xstatus.cpp458
-rw-r--r--protocols/JabberG/src/resource.h1
-rwxr-xr-xprotocols/JabberG/src/stdafx.h5
-rw-r--r--protocols/NewsAggregator/Src/Authentication.cpp16
-rw-r--r--protocols/NewsAggregator/Src/Options.cpp38
-rw-r--r--protocols/NewsAggregator/Src/Options.h25
-rw-r--r--protocols/SkypeWeb/src/skype_chatrooms.cpp29
-rw-r--r--protocols/SkypeWeb/src/skype_dialogs.cpp51
-rw-r--r--protocols/SkypeWeb/src/skype_dialogs.h37
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h7
-rw-r--r--protocols/Steam/src/steam_dialogs.cpp14
-rw-r--r--protocols/Steam/src/steam_dialogs.h6
-rw-r--r--protocols/Tox/src/stdafx.h1
-rw-r--r--protocols/Tox/src/tox_options.cpp151
-rw-r--r--protocols/Tox/src/tox_options.h28
-rw-r--r--protocols/Tox/src/tox_profile.cpp307
-rw-r--r--protocols/Tox/src/tox_profile.h69
-rw-r--r--protocols/Tox/src/tox_proto.h10
-rw-r--r--protocols/VKontakte/src/vk_dialogs.cpp53
-rw-r--r--protocols/VKontakte/src/vk_dialogs.h21
-rw-r--r--protocols/VKontakte/src/vk_struct.cpp2
-rw-r--r--src/mir_app/src/addcontact.cpp48
-rw-r--r--src/mir_app/src/auth.cpp53
-rw-r--r--src/mir_app/src/db_ini.cpp14
-rw-r--r--src/mir_app/src/menu_options.cpp4
-rw-r--r--src/mir_app/src/profilemanager.cpp6
-rw-r--r--src/mir_core/src/CDlgBase.cpp21
52 files changed, 980 insertions, 1268 deletions
diff --git a/include/m_gui.h b/include/m_gui.h
index 6b13667a83..5b92502f0b 100644
--- a/include/m_gui.h
+++ b/include/m_gui.h
@@ -399,7 +399,7 @@ public:
__forceinline HINSTANCE GetInst() const { return m_pPlugin.getInst(); }
__forceinline HWND GetHwnd() const { return m_hwnd; }
__forceinline void Hide() { Show(SW_HIDE); }
- __forceinline bool IsInitialized() const { return m_initialized; }
+ __forceinline bool IsInitialized() const { return m_bInitialized; }
__forceinline void SetMinSize(int x, int y) { m_iMinWidth = x, m_iMinHeight = y; }
__forceinline void SetParent(HWND hwnd) { m_hwndParent = hwnd; }
@@ -411,16 +411,18 @@ protected:
HWND m_hwnd = nullptr; // must be the first data item
HWND m_hwndParent = nullptr;
int m_idDialog;
+
bool m_isModal = false;
- bool m_initialized = false;
+ bool m_bInitialized = false;
bool m_forceResizable = false;
+ bool m_bSucceeded = false; // was IDOK pressed or not
bool m_bExiting = false; // window received WM_CLOSE and gonna die soon
- CMPluginBase &m_pPlugin;
-
enum { CLOSE_ON_OK = 0x1, CLOSE_ON_CANCEL = 0x2 };
BYTE m_autoClose; // automatically close dialog on IDOK/CANCEL commands. default: CLOSE_ON_OK|CLOSE_ON_CANCEL
+ CMPluginBase &m_pPlugin;
+
// override this handlers to provide custom functionality
// general messages
virtual bool OnInitDialog();
@@ -1464,11 +1466,11 @@ class MIR_APP_EXPORT CProtoIntDlgBase : public CDlgBase
public:
CProtoIntDlgBase(PROTO_INTERFACE *proto, int idDialog);
- void CreateLink(CCtrlData& ctrl, const char *szSetting, BYTE type, DWORD iValue);
- void CreateLink(CCtrlData& ctrl, const char *szSetting, wchar_t *szValue);
+ void CreateLink(CCtrlData &ctrl, const char *szSetting, BYTE type, DWORD iValue);
+ void CreateLink(CCtrlData &ctrl, const char *szSetting, wchar_t *szValue);
template<class T>
- __inline void CreateLink(CCtrlData& ctrl, CMOption<T> &option)
+ __inline void CreateLink(CCtrlData &ctrl, CMOption<T> &option)
{
ctrl.CreateDbLink(new CMOptionLink<T>(option));
}
diff --git a/plugins/CrashDumper/src/ui.cpp b/plugins/CrashDumper/src/ui.cpp
index ff3a18e49f..7018e90521 100644
--- a/plugins/CrashDumper/src/ui.cpp
+++ b/plugins/CrashDumper/src/ui.cpp
@@ -22,13 +22,12 @@ class CViewVersionInfo : public CDlgBase
{
DWORD m_flags;
- CCtrlButton m_btnCancel, m_btnCopyClip, m_btnCopyFile;
+ CCtrlButton m_btnCopyClip, m_btnCopyFile;
CCtrlRichEdit m_redtViewVersionInfo;
public:
CViewVersionInfo(DWORD flags) :
CDlgBase(g_plugin, IDD_VIEWVERSION),
- m_btnCancel(this, IDCANCEL),
m_btnCopyClip(this, IDC_CLIPVER),
m_btnCopyFile(this, IDC_FILEVER),
m_redtViewVersionInfo(this, IDC_VIEWVERSIONINFO)
@@ -38,7 +37,6 @@ public:
m_flags = flags;
m_forceResizable = true;
- m_btnCancel.OnClick = Callback(this, &CViewVersionInfo::OnCancelClick);
m_btnCopyClip.OnClick = Callback(this, &CViewVersionInfo::OnCopyClipClick);
m_btnCopyFile.OnClick = Callback(this, &CViewVersionInfo::OnCopyFileClick);
m_redtViewVersionInfo.OnBuildMenu = Callback(this, &CViewVersionInfo::OnViewVersionInfoBuildMenu);
@@ -78,7 +76,7 @@ public:
return true;
}
- int Resizer(UTILRESIZECONTROL * urc) override
+ int Resizer(UTILRESIZECONTROL *urc) override
{
switch (urc->wId) {
case IDC_VIEWVERSIONINFO:
@@ -97,11 +95,6 @@ public:
return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
}
- void OnCancelClick(CCtrlBase*)
- {
- Close();
- }
-
void OnCopyClipClick(CCtrlBase*)
{
CallService(MS_CRASHDUMPER_STORETOCLIP, 0, m_flags);
@@ -286,7 +279,7 @@ LRESULT CALLBACK DlgProcPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
void ShowMessage(int type, const wchar_t *format, ...)
{
- switch(type) {
+ switch (type) {
case 1:
case 3:
if (!g_plugin.bSuccessPopups)
diff --git a/plugins/Dbx_mdbx/src/dbcrypt.cpp b/plugins/Dbx_mdbx/src/dbcrypt.cpp
index 75a630aa72..117c5e0af6 100644
--- a/plugins/Dbx_mdbx/src/dbcrypt.cpp
+++ b/plugins/Dbx_mdbx/src/dbcrypt.cpp
@@ -122,28 +122,29 @@ CRYPTO_PROVIDER* CDbxMDBX::SelectProvider()
class CEnterPasswordDialog : public CDlgBase
{
+ CTimer m_timer;
CCtrlData m_header;
CCtrlData m_language;
CCtrlEdit m_passwordEdit;
- CCtrlButton m_buttonOK;
friend class CDbxMDBX;
CDbxMDBX *m_db;
TCHAR m_newPass[100];
unsigned short m_wrongPass = 0;
+ void OnTimer(CTimer*)
+ {
+ UINT_PTR LangID = (UINT_PTR)GetKeyboardLayout(0);
+ char Lang[3] = { 0 };
+ GetLocaleInfoA(MAKELCID((LangID & 0xffffffff), SORT_DEFAULT), LOCALE_SABBREVLANGNAME, Lang, 2);
+ Lang[0] = toupper(Lang[0]);
+ Lang[1] = tolower(Lang[1]);
+ m_language.SetTextA(Lang);
+ }
+
INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override
{
- if (msg == WM_TIMER) {
- UINT_PTR LangID = (UINT_PTR)GetKeyboardLayout(0);
- char Lang[3] = { 0 };
- GetLocaleInfoA(MAKELCID((LangID & 0xffffffff), SORT_DEFAULT), LOCALE_SABBREVLANGNAME, Lang, 2);
- Lang[0] = toupper(Lang[0]);
- Lang[1] = tolower(Lang[1]);
- m_language.SetTextA(Lang);
- return FALSE;
- }
- else if (msg == WM_CTLCOLORSTATIC) {
+ if (msg == WM_CTLCOLORSTATIC) {
if ((HWND)lParam == m_language.GetHwnd()) {
SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
SetBkMode((HDC)wParam, TRANSPARENT);
@@ -153,6 +154,19 @@ class CEnterPasswordDialog : public CDlgBase
return CDlgBase::DlgProc(msg, wParam, lParam);
}
+public:
+ CEnterPasswordDialog(CDbxMDBX *db) :
+ CDlgBase(g_plugin, IDD_LOGIN),
+ m_timer(this, 1),
+ m_header(this, IDC_HEADERBAR),
+ m_language(this, IDC_LANG),
+ m_passwordEdit(this, IDC_USERPASS),
+ m_db(db)
+ {
+ m_newPass[0] = 0;
+ m_timer.OnEvent = Callback(this, &CEnterPasswordDialog::OnTimer);
+ }
+
bool OnInitDialog() override
{
m_header.SendMsg(WM_SETICON, ICON_SMALL, (LPARAM)g_plugin.getIcon(IDI_LOGO, true));
@@ -160,40 +174,26 @@ class CEnterPasswordDialog : public CDlgBase
if (m_wrongPass) {
if (m_wrongPass > 2) {
m_passwordEdit.Disable();
- m_buttonOK.Disable();
+ EnableWindow(GetDlgItem(m_hwnd, IDOK), false);
m_header.SetText(TranslateT("Too many errors!"));
}
else m_header.SetText(TranslateT("Password is not correct!"));
}
else m_header.SetText(TranslateT("Please type in your password"));
- SetTimer(m_hwnd, 1, 200, nullptr);
+ m_timer.Start(200);
return true;
}
- void OnDestroy() override
- {
- KillTimer(m_hwnd, 1);
- Window_FreeIcon_IcoLib(m_header.GetHwnd());
- }
-
- void OnOK(CCtrlButton*)
+ bool OnApply() override
{
m_passwordEdit.GetText(m_newPass, _countof(m_newPass));
- EndDialog(m_hwnd, -128);
+ return true;
}
-public:
- CEnterPasswordDialog(CDbxMDBX *db) :
- CDlgBase(g_plugin, IDD_LOGIN),
- m_header(this, IDC_HEADERBAR),
- m_language(this, IDC_LANG),
- m_passwordEdit(this, IDC_USERPASS),
- m_buttonOK(this, IDOK),
- m_db(db)
+ void OnDestroy() override
{
- m_newPass[0] = 0;
- m_buttonOK.OnClick = Callback(this, &CEnterPasswordDialog::OnOK);
+ Window_FreeIcon_IcoLib(m_header.GetHwnd());
}
};
@@ -233,7 +233,7 @@ int CDbxMDBX::InitCrypt()
if (!m_crypto->setKey((const BYTE*)value.iov_base, value.iov_len)) {
CEnterPasswordDialog dlg(this);
while (true) {
- if (-128 != dlg.DoModal())
+ if (!dlg.DoModal())
return 4;
m_crypto->setPassword(pass_ptrA(mir_utf8encodeW(dlg.m_newPass)));
if (m_crypto->setKey((const BYTE*)value.iov_base, value.iov_len)) {
diff --git a/plugins/Import/src/ui.cpp b/plugins/Import/src/ui.cpp
index 14e7122a20..c181adc415 100644
--- a/plugins/Import/src/ui.cpp
+++ b/plugins/Import/src/ui.cpp
@@ -31,7 +31,7 @@ class CContactImportDlg : public CDlgBase
CImportPattern *m_pPattern = 0;
wchar_t m_wszFileName[MAX_PATH];
- CCtrlButton m_btnOpenFile, m_btnOk;
+ CCtrlButton m_btnOpenFile;
CCtrlCombo m_cmbFileType;
CCtrlEdit edtFileName;
@@ -41,12 +41,10 @@ public:
m_hContact(hContact),
edtFileName(this, IDC_FILENAME),
m_cmbFileType(this, IDC_FILETYPE),
- m_btnOk(this, IDOK),
m_btnOpenFile(this, IDC_OPEN_FILE)
{
m_wszFileName[0] = 0;
- m_btnOk.OnClick = Callback(this, &CContactImportDlg::onClick_Ok);
m_btnOpenFile.OnClick = Callback(this, &CContactImportDlg::onClick_OpenFile);
}
@@ -76,11 +74,6 @@ public:
return true;
}
- void onClick_Ok(CCtrlButton*)
- {
- EndModal(1);
- }
-
void onClick_OpenFile(CCtrlButton*)
{
int iCur = m_cmbFileType.GetCurSel();
diff --git a/plugins/MyDetails/src/services.cpp b/plugins/MyDetails/src/services.cpp
index 04f3e795c2..1043d70898 100644
--- a/plugins/MyDetails/src/services.cpp
+++ b/plugins/MyDetails/src/services.cpp
@@ -28,17 +28,13 @@ class CSetNickDialog : public CDlgBase
int m_protonum;
CCtrlEdit m_edtNickname;
- CCtrlButton m_btnOk, m_btnCancel;
+
public:
CSetNickDialog(int protoparam) :
CDlgBase(g_plugin, IDD_SETNICKNAME),
- m_edtNickname(this, IDC_NICKNAME),
- m_btnOk(this, IDOK),
- m_btnCancel(this, IDCANCEL)
+ m_edtNickname(this, IDC_NICKNAME)
{
m_protonum = protoparam;
- m_btnOk.OnClick = Callback(this, &CSetNickDialog::OnOkClick);
- m_btnCancel.OnClick = Callback(this, &CSetNickDialog::OnCancelClick);
}
bool OnInitDialog() override
@@ -88,7 +84,7 @@ public:
return true;
}
- void OnOkClick(CCtrlBase*)
+ bool OnApply() override
{
wchar_t tmp[MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE];
m_edtNickname.GetText(tmp, _countof(tmp));
@@ -97,11 +93,7 @@ public:
protocols->SetNicks(tmp);
else
protocols->Get(m_protonum)->SetNick(tmp);
- }
-
- void OnCancelClick(CCtrlBase*)
- {
- Close();
+ return true;
}
bool OnClose() override
@@ -298,20 +290,15 @@ class CSetStatusMessageDialog : public CDlgBase
SetStatusMessageData *m_data;
CCtrlEdit m_edtStatusMessage;
- CCtrlButton m_btnOk, m_btnCancel;
+
public:
CSetStatusMessageDialog(int protoparam, int statusparam) :
CDlgBase(g_plugin, IDD_SETSTATUSMESSAGE),
- m_edtStatusMessage(this, IDC_STATUSMESSAGE),
- m_btnOk(this, IDOK),
- m_btnCancel(this, IDCANCEL)
+ m_edtStatusMessage(this, IDC_STATUSMESSAGE)
{
m_data = (SetStatusMessageData *)mir_alloc(sizeof(SetStatusMessageData));
m_data->proto_num = protoparam;
m_data->status = statusparam;
-
- m_btnOk.OnClick = Callback(this, &CSetStatusMessageDialog::OnOkClick);
- m_btnCancel.OnClick = Callback(this, &CSetStatusMessageDialog::OnCancelClick);
}
bool OnInitDialog() override
@@ -351,7 +338,7 @@ public:
return true;
}
- void OnOkClick(CCtrlBase*)
+ bool OnApply() override
{
wchar_t tmp[MS_MYDETAILS_GETMYSTATUSMESSAGE_BUFFER_SIZE];
m_edtStatusMessage.GetText(tmp, _countof(tmp));
@@ -362,20 +349,15 @@ public:
protocols->SetStatusMsgs(tmp);
else
protocols->SetStatusMsgs(m_data->status, tmp);
+ return true;
}
- void OnCancelClick(CCtrlBase*)
- {
- Close();
- }
-
- bool OnClose() override
+ void OnDestroy() override
{
mir_free(m_data);
Window_FreeIcon_IcoLib(m_hwnd);
if (pSetStatusMessageDialog == this)
pSetStatusMessageDialog = nullptr;
- return true;
}
};
diff --git a/plugins/New_GPG/src/ui.cpp b/plugins/New_GPG/src/ui.cpp
index ebc2fa8fd6..3742d43b24 100755
--- a/plugins/New_GPG/src/ui.cpp
+++ b/plugins/New_GPG/src/ui.cpp
@@ -1192,13 +1192,9 @@ CDlgKeyPasswordMsgBox::CDlgKeyPasswordMsgBox(MCONTACT _hContact) :
lbl_KEYID(this, IDC_KEYID),
edit_KEY_PASSWORD(this, IDC_KEY_PASSWORD),
chk_DEFAULT_PASSWORD(this, IDC_DEFAULT_PASSWORD),
- chk_SAVE_PASSWORD(this, IDC_SAVE_PASSWORD),
- btn_OK(this, IDOK),
- btn_CANCEL(this, IDCANCEL)
+ chk_SAVE_PASSWORD(this, IDC_SAVE_PASSWORD)
{
hContact = _hContact;
- btn_OK.OnClick = Callback(this, &CDlgKeyPasswordMsgBox::onClick_OK);
- btn_CANCEL.OnClick = Callback(this, &CDlgKeyPasswordMsgBox::onClick_CANCEL);
}
bool CDlgKeyPasswordMsgBox::OnInitDialog()
@@ -1213,13 +1209,7 @@ bool CDlgKeyPasswordMsgBox::OnInitDialog()
return true;
}
-void CDlgKeyPasswordMsgBox::OnDestroy()
-{
- mir_free(inkeyid);
- Utils_SaveWindowPosition(m_hwnd, 0, MODULENAME, "PasswordWindow");
-}
-
-void CDlgKeyPasswordMsgBox::onClick_OK(CCtrlButton*)
+bool CDlgKeyPasswordMsgBox::OnApply()
{
ptrW tmp(edit_KEY_PASSWORD.GetText());
if (tmp && tmp[0]) {
@@ -1236,11 +1226,14 @@ void CDlgKeyPasswordMsgBox::onClick_OK(CCtrlButton*)
globals.wszPassword = tmp;
}
mir_free(inkeyid);
- DestroyWindow(m_hwnd);
+ return true;
}
-void CDlgKeyPasswordMsgBox::onClick_CANCEL(CCtrlButton*)
+void CDlgKeyPasswordMsgBox::OnDestroy()
{
- globals._terminate = true;
- DestroyWindow(m_hwnd);
+ if (!m_bSucceeded)
+ globals._terminate = true;
+
+ mir_free(inkeyid);
+ Utils_SaveWindowPosition(m_hwnd, 0, MODULENAME, "PasswordWindow");
}
diff --git a/plugins/New_GPG/src/ui.h b/plugins/New_GPG/src/ui.h
index 6ab8c7111c..e5c0c2c5ad 100755
--- a/plugins/New_GPG/src/ui.h
+++ b/plugins/New_GPG/src/ui.h
@@ -164,15 +164,13 @@ class CDlgKeyPasswordMsgBox : public CDlgBase //always modal
CCtrlData lbl_KEYID;
CCtrlEdit edit_KEY_PASSWORD;
CCtrlCheck chk_DEFAULT_PASSWORD, chk_SAVE_PASSWORD;
- CCtrlButton btn_OK, btn_CANCEL;
public:
CDlgKeyPasswordMsgBox(MCONTACT _hContact);
+
bool OnInitDialog() override;
+ bool OnApply() override;
void OnDestroy() override;
-
- void onClick_OK(CCtrlButton*);
- void onClick_CANCEL(CCtrlButton*);
};
#endif // UI_H \ No newline at end of file
diff --git a/plugins/PluginUpdater/src/DlgListNew.cpp b/plugins/PluginUpdater/src/DlgListNew.cpp
index b264635d05..53cf844391 100644
--- a/plugins/PluginUpdater/src/DlgListNew.cpp
+++ b/plugins/PluginUpdater/src/DlgListNew.cpp
@@ -128,11 +128,9 @@ public:
m_list(this, IDC_LIST_UPDATES),
m_filter(this, IDC_SEARCH)
{
- m_autoClose = CLOSE_ON_CANCEL;
SetParent(GetDesktopWindow());
SetMinSize(370, 300);
- btnOk.OnClick = Callback(this, &CMissingPLuginsDlg::onClick_Ok);
btnNone.OnClick = Callback(this, &CMissingPLuginsDlg::onClick_None);
m_filter.OnChange = Callback(this, &CMissingPLuginsDlg::onChange_Filter);
@@ -211,6 +209,14 @@ public:
return true;
}
+ bool OnApply() override
+ {
+ btnOk.Disable();
+ btnNone.Disable();
+ mir_forkthread(ApplyDownloads, this);
+ return false; // do not allow a dialog to close
+ }
+
void OnDestroy() override
{
Utils_SaveWindowPosition(m_hwnd, NULL, MODULENAME, "ListWindow");
@@ -260,13 +266,6 @@ public:
}
}
- void onClick_Ok(CCtrlButton *)
- {
- btnOk.Disable();
- btnNone.Disable();
- mir_forkthread(ApplyDownloads, this);
- }
-
void onClick_None(CCtrlButton *)
{
SelectAll(false);
diff --git a/plugins/Scriver/src/msgtimedout.cpp b/plugins/Scriver/src/msgtimedout.cpp
index ba621e4434..5595b5aaf6 100644
--- a/plugins/Scriver/src/msgtimedout.cpp
+++ b/plugins/Scriver/src/msgtimedout.cpp
@@ -25,7 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
class CErrorDlg : public CDlgBase
{
- bool m_bRetry = false;
ptrW m_wszText;
CMStringW m_wszName, m_wszDescr;
CMsgDialog *m_pOwner;
@@ -71,16 +70,10 @@ public:
return true;
}
- bool OnApply() override
- {
- m_bRetry = true;
- return true;
- }
-
void OnDestroy() override
{
m_queueItem->hwndErrorDlg = nullptr;
- m_pOwner->HandleError(m_bRetry, m_queueItem);
+ m_pOwner->HandleError(m_bSucceeded, m_queueItem);
}
};
diff --git a/plugins/StopSpamPlus/src/options.cpp b/plugins/StopSpamPlus/src/options.cpp
index 15a05898fb..e2d18e72df 100644
--- a/plugins/StopSpamPlus/src/options.cpp
+++ b/plugins/StopSpamPlus/src/options.cpp
@@ -159,7 +159,7 @@ public:
void list_OnItemChanged(CCtrlListView::TEventInfo*)
{
- if (m_initialized)
+ if (m_bInitialized)
NotifyChange();
}
};
diff --git a/protocols/CloudFile/src/oauth.cpp b/protocols/CloudFile/src/oauth.cpp
index e62629fcd8..aeeba741c4 100644
--- a/protocols/CloudFile/src/oauth.cpp
+++ b/protocols/CloudFile/src/oauth.cpp
@@ -8,7 +8,6 @@ COAuthDlg::COAuthDlg(CCloudService *service, const char *authUrl, CCloudService:
{
m_autoClose = CLOSE_ON_CANCEL;
m_code.OnChange = Callback(this, &COAuthDlg::Code_OnChange);
- m_ok.OnClick = Callback(this, &COAuthDlg::Ok_OnClick);
}
bool COAuthDlg::OnInitDialog()
@@ -21,13 +20,14 @@ bool COAuthDlg::OnInitDialog()
return true;
}
+bool COAuthDlg::OnApply()
+{
+ m_service->ForkThread(m_requestAccessTokenThread, m_hwnd);
+ return true;
+}
+
void COAuthDlg::Code_OnChange(CCtrlBase*)
{
ptrA requestToken(m_code.GetTextA());
m_ok.Enable(mir_strlen(requestToken) != 0);
}
-
-void COAuthDlg::Ok_OnClick(CCtrlButton*)
-{
- m_service->ForkThread(m_requestAccessTokenThread, m_hwnd);
-} \ No newline at end of file
diff --git a/protocols/CloudFile/src/oauth.h b/protocols/CloudFile/src/oauth.h
index 2b32ecbd9b..24f755fc79 100644
--- a/protocols/CloudFile/src/oauth.h
+++ b/protocols/CloudFile/src/oauth.h
@@ -6,15 +6,15 @@ class COAuthDlg : public CDlgBase
CCloudService *m_service;
CCloudService::MyThreadFunc m_requestAccessTokenThread;
+ CCtrlButton m_ok;
CCtrlHyperlink m_authorize;
CCtrlEdit m_code;
- CCtrlButton m_ok;
protected:
bool OnInitDialog() override;
+ bool OnApply() override;
void Code_OnChange(CCtrlBase*);
- void Ok_OnClick(CCtrlButton*);
public:
COAuthDlg(CCloudService *service, const char *authUrl, CCloudService::MyThreadFunc requestAccessTokenThread);
diff --git a/protocols/IRCG/src/irc_dlg.h b/protocols/IRCG/src/irc_dlg.h
index f4d7d1363b..6da582a634 100644
--- a/protocols/IRCG/src/irc_dlg.h
+++ b/protocols/IRCG/src/irc_dlg.h
@@ -30,8 +30,7 @@ struct CMessageBoxDlg : public CProtoDlgBase < CIrcProto >
CMessageBoxDlg(CIrcProto* _pro, DCCINFO* _dci);
- CCtrlButton m_Ok;
- void OnOk(CCtrlButton*);
+ bool OnApply() override;
};
struct CCoolIrcDlg : public CProtoDlgBase < CIrcProto >
@@ -74,13 +73,11 @@ struct CNickDlg : public CCoolIrcDlg
{
CNickDlg(CIrcProto* _pro);
- CCtrlCombo m_Enick;
- CCtrlButton m_Ok;
+ CCtrlCombo m_Enick;
bool OnInitDialog() override;
+ bool OnApply() override;
void OnDestroy() override;
-
- void OnOk(CCtrlButton*);
};
struct CListDlg : public CProtoDlgBase < CIrcProto >
@@ -111,10 +108,8 @@ struct CJoinDlg : public CCoolIrcDlg
CJoinDlg(CIrcProto* _pro);
bool OnInitDialog() override;
+ bool OnApply() override;
void OnDestroy() override;
-
- CCtrlButton m_Ok;
- void OnOk(CCtrlButton*);
};
struct CQuickDlg : public CCoolIrcDlg
@@ -122,14 +117,12 @@ struct CQuickDlg : public CCoolIrcDlg
CQuickDlg(CIrcProto* _pro);
bool OnInitDialog() override;
+ bool OnApply() override;
void OnDestroy() override;
CCtrlCombo m_serverCombo;
void OnServerCombo(CCtrlData*);
- CCtrlButton m_Ok;
- void OnOk(CCtrlButton*);
-
private:
struct SERVER_INFO* m_si;
};
@@ -176,11 +169,9 @@ struct CQuestionDlg : public CCoolIrcDlg
CQuestionDlg(CIrcProto* _pro, CManagerDlg* owner = nullptr);
bool OnInitDialog() override;
+ bool OnApply() override;
bool OnClose() override;
- CCtrlButton m_Ok;
- void OnOk(CCtrlButton*);
-
void Activate();
private:
@@ -282,8 +273,8 @@ struct CIgnorePrefsDlg : public CProtoDlgBase < CIrcProto >
CIgnorePrefsDlg(CIrcProto* _pro);
bool OnInitDialog() override;
- void OnDestroy() override;
bool OnApply() override;
+ void OnDestroy() override;
INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
@@ -301,7 +292,6 @@ struct CIgnorePrefsDlg : public CProtoDlgBase < CIrcProto >
struct CAddIgnoreDlg : public CProtoDlgBase < CIrcProto >
{
- CCtrlButton m_Ok;
CIgnorePrefsDlg* m_owner;
wchar_t szOldMask[500];
@@ -309,7 +299,6 @@ struct CAddIgnoreDlg : public CProtoDlgBase < CIrcProto >
CAddIgnoreDlg(CIrcProto* _pro, const wchar_t* mask, CIgnorePrefsDlg* parent);
bool OnInitDialog() override;
+ bool OnApply() override;
bool OnClose() override;
-
- void OnOk(CCtrlButton*);
};
diff --git a/protocols/IRCG/src/options.cpp b/protocols/IRCG/src/options.cpp
index e289ccaeb6..22bbde0610 100644
--- a/protocols/IRCG/src/options.cpp
+++ b/protocols/IRCG/src/options.cpp
@@ -267,7 +267,6 @@ struct CServerDlg : public CProtoDlgBase<CIrcProto>
CConnectPrefsDlg *m_owner;
int m_action;
- CCtrlButton m_OK;
CCtrlEdit m_server, m_address, m_port, m_port2;
CCtrlCombo m_groupCombo;
@@ -275,7 +274,6 @@ struct CServerDlg : public CProtoDlgBase<CIrcProto>
: CProtoDlgBase<CIrcProto>(_pro, IDD_ADDSERVER),
m_owner(_owner),
m_action(_action),
- m_OK(this, IDOK),
m_groupCombo(this, IDC_ADD_COMBO),
m_address(this, IDC_ADD_ADDRESS),
m_server(this, IDC_ADD_SERVER),
@@ -283,8 +281,6 @@ struct CServerDlg : public CProtoDlgBase<CIrcProto>
m_port2(this, IDC_ADD_PORT2)
{
m_hwndParent = _owner->GetHwnd();
- m_OK.OnClick = Callback(this, &CServerDlg::OnOk);
- m_autoClose = CLOSE_ON_CANCEL;
}
bool OnInitDialog() override
@@ -330,21 +326,12 @@ struct CServerDlg : public CProtoDlgBase<CIrcProto>
return true;
}
- bool OnClose() override
- {
- m_owner->m_serverCombo.Enable();
- m_owner->m_add.Enable();
- m_owner->m_edit.Enable();
- m_owner->m_del.Enable();
- return true;
- }
-
- void OnOk(CCtrlButton*)
+ bool OnApply() override
{
for (auto &it : sttRequiredFields)
if (!GetWindowTextLength(GetDlgItem(m_hwnd, it))) {
MessageBox(m_hwnd, TranslateT("Please complete all fields"), TranslateT("IRC error"), MB_OK | MB_ICONERROR);
- return;
+ return false;
}
if (m_action == 2) {
@@ -375,7 +362,16 @@ struct CServerDlg : public CProtoDlgBase<CIrcProto>
m_owner->OnServerCombo(nullptr);
m_owner->m_serverlistModified = true;
- ::PostMessage(m_hwnd, WM_CLOSE, 0, 0);
+ return true;
+ }
+
+ bool OnClose() override
+ {
+ m_owner->m_serverCombo.Enable();
+ m_owner->m_add.Enable();
+ m_owner->m_edit.Enable();
+ m_owner->m_del.Enable();
+ return true;
}
};
@@ -1171,7 +1167,6 @@ void COtherPrefsDlg::addPerformComboValue(int idx, const char* szValueName)
CAddIgnoreDlg::CAddIgnoreDlg(CIrcProto* _pro, const wchar_t* mask, CIgnorePrefsDlg* _owner)
: CProtoDlgBase<CIrcProto>(_pro, IDD_ADDIGNORE),
- m_Ok(this, IDOK),
m_owner(_owner)
{
m_hwndParent = _owner->GetHwnd();
@@ -1180,8 +1175,6 @@ CAddIgnoreDlg::CAddIgnoreDlg(CIrcProto* _pro, const wchar_t* mask, CIgnorePrefsD
szOldMask[0] = 0;
else
wcsncpy(szOldMask, mask, _countof(szOldMask));
-
- m_Ok.OnClick = Callback(this, &CAddIgnoreDlg::OnOk);
}
bool CAddIgnoreDlg::OnInitDialog()
@@ -1198,7 +1191,7 @@ bool CAddIgnoreDlg::OnInitDialog()
return true;
}
-void CAddIgnoreDlg::OnOk(CCtrlButton*)
+bool CAddIgnoreDlg::OnApply()
{
wchar_t szMask[500];
wchar_t szNetwork[500];
@@ -1224,6 +1217,7 @@ void CAddIgnoreDlg::OnOk(CCtrlButton*)
m_proto->AddIgnore(Mask.c_str(), flags.c_str(), szNetwork);
}
}
+ return true;
}
bool CAddIgnoreDlg::OnClose()
diff --git a/protocols/IRCG/src/windows.cpp b/protocols/IRCG/src/windows.cpp
index c1f4aa254b..b952e936f3 100644
--- a/protocols/IRCG/src/windows.cpp
+++ b/protocols/IRCG/src/windows.cpp
@@ -26,13 +26,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
CMessageBoxDlg::CMessageBoxDlg(CIrcProto *_pro, DCCINFO *_dci)
: CProtoDlgBase<CIrcProto>(_pro, IDD_MESSAGEBOX),
- pdci(_dci),
- m_Ok(this, IDOK)
+ pdci(_dci)
{
- m_Ok.OnClick = Callback(this, &CMessageBoxDlg::OnOk);
}
-void CMessageBoxDlg::OnOk(CCtrlButton*)
+bool CMessageBoxDlg::OnApply()
{
CDccSession *dcc = new CDccSession(m_proto, pdci);
@@ -42,6 +40,7 @@ void CMessageBoxDlg::OnOk(CCtrlButton*)
m_proto->AddDCCSession(pdci->hContact, dcc);
dcc->Connect();
+ return true;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -199,12 +198,10 @@ void CWhoisDlg::ShowMessageNoUser(const CIrcMessage *pmsg)
/////////////////////////////////////////////////////////////////////////////////////////
// 'Change nickname' dialog
-CNickDlg::CNickDlg(CIrcProto *_pro)
- : CCoolIrcDlg(_pro, IDD_NICK),
- m_Ok(this, IDOK),
+CNickDlg::CNickDlg(CIrcProto *_pro) :
+ CCoolIrcDlg(_pro, IDD_NICK),
m_Enick(this, IDC_ENICK)
{
- m_Ok.OnClick = Callback(this, &CNickDlg::OnOk);
}
bool CNickDlg::OnInitDialog()
@@ -229,7 +226,7 @@ void CNickDlg::OnDestroy()
m_proto->m_nickDlg = nullptr;
}
-void CNickDlg::OnOk(CCtrlButton*)
+bool CNickDlg::OnApply()
{
wchar_t szTemp[255];
m_Enick.GetText(szTemp, _countof(szTemp));
@@ -246,6 +243,7 @@ void CNickDlg::OnOk(CCtrlButton*)
db_free(&dbv);
}
m_proto->setWString("RecentNicks", S.c_str());
+ return true;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -499,11 +497,9 @@ void CListDlg::UpdateList()
/////////////////////////////////////////////////////////////////////////////////////////
// 'Join' dialog
-CJoinDlg::CJoinDlg(CIrcProto *_pro)
- : CCoolIrcDlg(_pro, IDD_NICK),
- m_Ok(this, IDOK)
+CJoinDlg::CJoinDlg(CIrcProto *_pro) :
+ CCoolIrcDlg(_pro, IDD_NICK)
{
- m_Ok.OnClick = Callback(this, &CJoinDlg::OnOk);
}
bool CJoinDlg::OnInitDialog()
@@ -530,7 +526,7 @@ void CJoinDlg::OnDestroy()
m_proto->m_joinDlg = nullptr;
}
-void CJoinDlg::OnOk(CCtrlButton*)
+bool CJoinDlg::OnApply()
{
wchar_t szTemp[255];
GetDlgItemText(m_hwnd, IDC_ENICK, szTemp, _countof(szTemp));
@@ -553,6 +549,7 @@ void CJoinDlg::OnOk(CCtrlButton*)
db_free(&dbv);
}
m_proto->setWString("RecentChannels", S.c_str());
+ return true;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -560,10 +557,8 @@ void CJoinDlg::OnOk(CCtrlButton*)
CQuickDlg::CQuickDlg(CIrcProto *_pro)
: CCoolIrcDlg(_pro, IDD_QUICKCONN),
- m_Ok(this, IDOK),
m_serverCombo(this, IDC_SERVERCOMBO)
{
- m_Ok.OnClick = Callback(this, &CQuickDlg::OnOk);
m_serverCombo.OnChange = Callback(this, &CQuickDlg::OnServerCombo);
}
@@ -621,7 +616,7 @@ void CQuickDlg::OnDestroy()
m_proto->m_quickDlg = nullptr;
}
-void CQuickDlg::OnOk(CCtrlButton*)
+bool CQuickDlg::OnApply()
{
GetDlgItemTextA(m_hwnd, IDC_SERVER, m_proto->m_serverName, _countof(m_proto->m_serverName));
GetDlgItemTextA(m_hwnd, IDC_PORT, m_proto->m_portStart, _countof(m_proto->m_portStart));
@@ -656,6 +651,7 @@ void CQuickDlg::OnOk(CCtrlButton*)
m_proto->setDword("QuickComboSelection", m_proto->m_quickComboSelection);
m_proto->DisconnectFromServer();
m_proto->ConnectToServer();
+ return true;
}
void CQuickDlg::OnServerCombo(CCtrlData*)
@@ -710,14 +706,12 @@ void CQuickDlg::OnServerCombo(CCtrlData*)
/////////////////////////////////////////////////////////////////////////////////////////
// 'Question' dialog
-CQuestionDlg::CQuestionDlg(CIrcProto *_pro, CManagerDlg *owner)
- : CCoolIrcDlg(_pro, IDD_QUESTION),
- m_Ok(this, IDOK),
+CQuestionDlg::CQuestionDlg(CIrcProto *_pro, CManagerDlg *owner) :
+ CCoolIrcDlg(_pro, IDD_QUESTION),
m_owner(owner)
{
if (owner != nullptr)
m_hwndParent = owner->GetHwnd();
- m_Ok.OnClick = Callback(this, &CQuestionDlg::OnOk);
}
bool CQuestionDlg::OnInitDialog()
@@ -735,7 +729,7 @@ bool CQuestionDlg::OnClose()
return true;
}
-void CQuestionDlg::OnOk(CCtrlButton*)
+bool CQuestionDlg::OnApply()
{
int i = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_EDIT));
if (i > 0) {
@@ -779,6 +773,7 @@ void CQuestionDlg::OnOk(CCtrlButton*)
if (m_owner)
m_owner->ApplyQuestion();
}
+ return true;
}
void CQuestionDlg::Activate()
diff --git a/protocols/JabberG/res/jabber.rc b/protocols/JabberG/res/jabber.rc
index 3c0930ad1a..6280d2c403 100644
--- a/protocols/JabberG/res/jabber.rc
+++ b/protocols/JabberG/res/jabber.rc
@@ -182,7 +182,7 @@ BEGIN
CONTROL "",IDC_FRAME2,"Static",SS_ETCHEDHORZ,0,197,258,1
LTEXT "",IDC_FRAME,0,28,250,168,WS_TABSTOP
SCROLLBAR IDC_VSCROLL,246,28,11,167,SBS_VERT
- DEFPUSHBUTTON "Submit",IDC_SUBMIT,146,203,50,14,WS_DISABLED
+ DEFPUSHBUTTON "Submit",IDOK,146,203,50,14,WS_DISABLED
PUSHBUTTON "Cancel",IDCANCEL,200,203,50,14
DEFPUSHBUTTON "Next",IDC_NEXT,50,203,40,14,NOT WS_VISIBLE | WS_DISABLED
DEFPUSHBUTTON "Back",IDC_PREV,6,203,42,14,NOT WS_VISIBLE | WS_DISABLED
@@ -657,7 +657,7 @@ BEGIN
EDITTEXT IDC_INSTRUCTION,17,16,233,8,ES_MULTILINE | ES_READONLY | NOT WS_BORDER
CONTROL "",IDC_FRAME1,"Static",SS_ETCHEDHORZ,0,26,258,1
CONTROL "",IDC_FRAME2,"Static",SS_ETCHEDHORZ,0,197,258,1
- DEFPUSHBUTTON "Submit",IDC_SUBMIT,146,203,50,14
+ DEFPUSHBUTTON "Submit",IDOK,146,203,50,14
PUSHBUTTON "Cancel",IDCANCEL,200,203,50,14
END
diff --git a/protocols/JabberG/src/jabber_adhoc.cpp b/protocols/JabberG/src/jabber_adhoc.cpp
index 7148fdc748..b4e5bac799 100644
--- a/protocols/JabberG/src/jabber_adhoc.cpp
+++ b/protocols/JabberG/src/jabber_adhoc.cpp
@@ -121,8 +121,8 @@ void CJabberProto::AdHoc_ExecuteCommand(HWND hwndDlg, char*, JabberAdHocData *da
XmlNodeIq(AddIQ(&CJabberProto::OnIqResult_CommandExecution, JABBER_IQ_TYPE_SET, jid2, hwndDlg))
<< XCHILDNS("command", JABBER_FEAT_COMMANDS) << XATTR("node", node) << XATTR("action", "execute"));
- EnableDlgItem(hwndDlg, IDC_SUBMIT, FALSE);
- SetDlgItemText(hwndDlg, IDC_SUBMIT, TranslateT("OK"));
+ EnableDlgItem(hwndDlg, IDOK, FALSE);
+ SetDlgItemText(hwndDlg, IDOK, TranslateT("OK"));
}
}
}
@@ -174,7 +174,7 @@ void CJabberProto::AdHoc_OnJAHMCommandListResult(HWND hwndDlg, TiXmlElement *iqN
JabberFormSetInstruction(hwndDlg, TranslateU("Select Command"));
ShowDlgItem(hwndDlg, IDC_FRAME, SW_SHOW);
ShowDlgItem(hwndDlg, IDC_VSCROLL, SW_SHOW);
- EnableDlgItem(hwndDlg, IDC_SUBMIT, TRUE);
+ EnableDlgItem(hwndDlg, IDOK, TRUE);
}
else JabberFormSetInstruction(hwndDlg, TranslateU("Not supported"));
}
@@ -235,7 +235,7 @@ void CJabberProto::AdHoc_OnJAHMProcessResult(HWND hwndDlg, TiXmlElement *workNod
ShowDlgItem(hwndDlg, IDC_PREV, (XmlFirstChild(actionsNode, "prev") != nullptr) ? SW_SHOW : SW_HIDE);
ShowDlgItem(hwndDlg, IDC_NEXT, (XmlFirstChild(actionsNode, "next") != nullptr) ? SW_SHOW : SW_HIDE);
ShowDlgItem(hwndDlg, IDC_COMPLETE, (XmlFirstChild(actionsNode, "complete") != nullptr) ? SW_SHOW : SW_HIDE);
- ShowDlgItem(hwndDlg, IDC_SUBMIT, SW_HIDE);
+ ShowDlgItem(hwndDlg, IDOK, SW_HIDE);
int toEnable[] = { IDC_PREV, IDC_NEXT, IDC_COMPLETE, 0 };
sttEnableControls(hwndDlg, TRUE, toEnable);
@@ -244,18 +244,18 @@ void CJabberProto::AdHoc_OnJAHMProcessResult(HWND hwndDlg, TiXmlElement *workNod
int toHide[] = { IDC_PREV, IDC_NEXT, IDC_COMPLETE, 0 };
sttShowControls(hwndDlg, FALSE, toHide);
- ShowDlgItem(hwndDlg, IDC_SUBMIT, SW_SHOW);
- EnableDlgItem(hwndDlg, IDC_SUBMIT, TRUE);
+ ShowDlgItem(hwndDlg, IDOK, SW_SHOW);
+ EnableDlgItem(hwndDlg, IDOK, TRUE);
}
if (!status || mir_strcmp(status, "executing")) {
- ShowDlgItem(hwndDlg, IDC_SUBMIT, SW_HIDE);
+ ShowDlgItem(hwndDlg, IDOK, SW_HIDE);
SetDlgItemText(hwndDlg, IDCANCEL, TranslateT("Done"));
}
}
else if (!mir_strcmp(type, "error")) {
// error occurred here
- int toHide[] = { IDC_FRAME, IDC_VSCROLL, IDC_PREV, IDC_NEXT, IDC_COMPLETE, IDC_SUBMIT, 0 };
+ int toHide[] = { IDC_FRAME, IDC_VSCROLL, IDC_PREV, IDC_NEXT, IDC_COMPLETE, IDOK, 0 };
sttShowControls(hwndDlg, FALSE, toHide);
const char *code = "";
@@ -296,7 +296,7 @@ void CJabberProto::AdHoc_SubmitCommandForm(HWND hwndDlg, JabberAdHocData *dat, c
JabberFormSetInstruction(hwndDlg, TranslateU("In progress. Please Wait..."));
- static const int toDisable[] = { IDC_SUBMIT, IDC_PREV, IDC_NEXT, IDC_COMPLETE, 0 };
+ static const int toDisable[] = { IDOK, IDC_PREV, IDC_NEXT, IDC_COMPLETE, 0 };
sttEnableControls(hwndDlg, FALSE, toDisable);
}
@@ -350,14 +350,14 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA
int toHide[] = { IDC_FRAME, IDC_VSCROLL, IDC_PREV, IDC_NEXT, IDC_COMPLETE, 0 };
sttShowControls(hwndDlg, FALSE, toHide);
- int toShow[] = { IDC_INSTRUCTION, IDC_SUBMIT, IDCANCEL, 0 };
+ int toShow[] = { IDC_INSTRUCTION, IDOK, IDCANCEL, 0 };
sttShowControls(hwndDlg, TRUE, toShow);
EnableDlgItem(hwndDlg, IDC_VSCROLL, TRUE);
SetWindowPos(GetDlgItem(hwndDlg, IDC_VSCROLL), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
- SetDlgItemText(hwndDlg, IDC_SUBMIT, TranslateT("Execute"));
+ SetDlgItemText(hwndDlg, IDOK, TranslateT("Execute"));
JabberFormSetInstruction(hwndDlg, TranslateU("Requesting command list. Please wait..."));
char Caption[512];
@@ -372,8 +372,8 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA
<< XCHILDNS("command", JABBER_FEAT_COMMANDS)
<< XATTR("node", pStartupParams->m_szNode) << XATTR("action", "execute"));
- EnableDlgItem(hwndDlg, IDC_SUBMIT, FALSE);
- SetDlgItemText(hwndDlg, IDC_SUBMIT, TranslateT("OK"));
+ EnableDlgItem(hwndDlg, IDOK, FALSE);
+ SetDlgItemText(hwndDlg, IDOK, TranslateT("OK"));
mir_snprintf(Caption, TranslateU("Sending Ad-Hoc command to %s"), dat->ResponderJID);
}
@@ -401,8 +401,8 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA
case IDC_COMPLETE:
dat->proto->AdHoc_SubmitCommandForm(hwndDlg, dat, "complete");
return TRUE;
- case IDC_SUBMIT:
- if (!dat->AdHocNode && dat->CommandsNode && LOWORD(wParam) == IDC_SUBMIT)
+ case IDOK:
+ if (!dat->AdHocNode && dat->CommandsNode && LOWORD(wParam) == IDOK)
dat->proto->AdHoc_ExecuteCommand(hwndDlg, dat->ResponderJID, dat);
else
dat->proto->AdHoc_SubmitCommandForm(hwndDlg, dat, nullptr);
diff --git a/protocols/JabberG/src/jabber_agent.cpp b/protocols/JabberG/src/jabber_agent.cpp
index 55e5532bb6..de17dc3bab 100644
--- a/protocols/JabberG/src/jabber_agent.cpp
+++ b/protocols/JabberG/src/jabber_agent.cpp
@@ -39,7 +39,6 @@ public:
m_ok(this, IDOK)
{
SetParent(_owner);
- m_ok.OnClick = Callback(this, &CAgentRegProgressDlg::OnOk);
}
bool OnInitDialog() override
@@ -50,6 +49,11 @@ public:
return true;
}
+ void OnDestroy() override
+ {
+ m_proto->m_hwndRegProgress = nullptr;
+ }
+
INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override
{
if (msg == WM_JABBER_REGDLG_UPDATE) {
@@ -66,12 +70,6 @@ public:
return CJabberDlgBase::DlgProc(msg, wParam, lParam);
}
-
- void OnOk(CCtrlButton*)
- {
- m_proto->m_hwndRegProgress = nullptr;
- EndDialog(m_hwnd, 0);
- }
};
/////////////////////////////////////////////////////////////////////////////////////////
@@ -86,17 +84,14 @@ class CAgentRegDlg : public CJabberDlgBase
TiXmlElement *m_agentRegIqNode;
char *m_jid;
- CCtrlButton m_submit;
HWND m_statusBar;
public:
CAgentRegDlg(CJabberProto *_ppro, char *_jid) :
CJabberDlgBase(_ppro, IDD_FORM),
- m_submit(this, IDC_SUBMIT),
m_jid(_jid),
m_agentRegIqNode(nullptr)
{
- m_submit.OnClick = Callback(this, &CAgentRegDlg::OnSubmit);
}
bool OnInitDialog() override
@@ -104,7 +99,7 @@ public:
EnableWindow(GetParent(m_hwnd), FALSE);
m_proto->m_hwndAgentRegInput = m_hwnd;
SetWindowText(m_hwnd, TranslateT("Jabber Agent Registration"));
- SetDlgItemText(m_hwnd, IDC_SUBMIT, TranslateT("Register"));
+ SetDlgItemText(m_hwnd, IDOK, TranslateT("Register"));
m_statusBar = CreateWindowExW(0, STATUSCLASSNAME, nullptr, WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0, m_hwnd, nullptr, g_plugin.getInst(), nullptr);
SendMessage(m_statusBar, WM_SIZE, 0, 0);
@@ -121,6 +116,57 @@ public:
return true;
}
+ bool OnApply() override
+ {
+ if (m_agentRegIqNode == nullptr)
+ return true;
+
+ auto *queryNode = XmlFirstChild(m_agentRegIqNode, "query");
+ const char *from = XmlGetAttr(m_agentRegIqNode, "from");
+ if (from == nullptr || queryNode == nullptr)
+ return true;
+
+ HWND hwndFrame = GetDlgItem(m_hwnd, IDC_FRAME);
+ wchar_t *str2 = (wchar_t *)alloca(sizeof(wchar_t) * 128);
+ int id = 0;
+
+ XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultSetRegister, JABBER_IQ_TYPE_SET, from));
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_REGISTER);
+
+ if (auto *xNode = XmlFirstChild(queryNode, "x")) {
+ // use new jabber:x:data form
+ JabberFormGetData(hwndFrame, query, xNode);
+ }
+ else {
+ // use old registration information form
+ for (auto *n : TiXmlEnum(queryNode)) {
+ const char *pszName = n->Name();
+ if (pszName) {
+ if (!mir_strcmp(pszName, "key")) {
+ // field that must be passed along with the registration
+ if (n->GetText())
+ XmlAddChildA(query, pszName, n->GetText());
+ else
+ XmlAddChild(query, pszName);
+ }
+ else if (!mir_strcmp(pszName, "registered") || !mir_strcmp(pszName, "instructions")) {
+ // do nothing, we will skip these
+ }
+ else {
+ GetDlgItemText(hwndFrame, id, str2, 128);
+ XmlAddChildA(query, pszName, T2Utf(str2).get());
+ id++;
+ }
+ }
+ }
+ }
+
+ m_proto->m_ThreadInfo->send(iq);
+
+ CAgentRegProgressDlg(m_proto, m_hwnd).DoModal();
+ return true;
+ }
+
void OnDestroy() override
{
JabberFormDestroyUI(GetDlgItem(m_hwnd, IDC_FRAME));
@@ -200,7 +246,7 @@ public:
m_curPos = 0;
}
- EnableWindow(GetDlgItem(m_hwnd, IDC_SUBMIT), TRUE);
+ EnableWindow(GetDlgItem(m_hwnd, IDOK), TRUE);
}
else if (wParam == 0) {
// lParam = error message
@@ -230,58 +276,6 @@ public:
return CJabberDlgBase::DlgProc(msg, wParam, lParam);
}
-
- void OnSubmit(CCtrlButton*)
- {
- if (m_agentRegIqNode == nullptr)
- return;
-
- auto *queryNode = XmlFirstChild(m_agentRegIqNode, "query");
- const char *from = XmlGetAttr(m_agentRegIqNode, "from");
- if (from == nullptr || queryNode == nullptr)
- return;
-
- HWND hwndFrame = GetDlgItem(m_hwnd, IDC_FRAME);
- wchar_t *str2 = (wchar_t*)alloca(sizeof(wchar_t) * 128);
- int id = 0;
-
- XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultSetRegister, JABBER_IQ_TYPE_SET, from));
- TiXmlElement *query = iq << XQUERY(JABBER_FEAT_REGISTER);
-
- if (auto *xNode = XmlFirstChild(queryNode, "x")) {
- // use new jabber:x:data form
- JabberFormGetData(hwndFrame, query, xNode);
- }
- else {
- // use old registration information form
- for (auto *n : TiXmlEnum(queryNode)) {
- const char *pszName = n->Name();
- if (pszName) {
- if (!mir_strcmp(pszName, "key")) {
- // field that must be passed along with the registration
- if (n->GetText())
- XmlAddChildA(query, pszName, n->GetText());
- else
- XmlAddChild(query, pszName);
- }
- else if (!mir_strcmp(pszName, "registered") || !mir_strcmp(pszName, "instructions")) {
- // do nothing, we will skip these
- }
- else {
- GetDlgItemText(hwndFrame, id, str2, 128);
- XmlAddChildA(query, pszName, T2Utf(str2).get());
- id++;
- }
- }
- }
- }
-
- m_proto->m_ThreadInfo->send(iq);
-
- CAgentRegProgressDlg(m_proto, m_hwnd).DoModal();
-
- Close();
- }
};
void CJabberProto::RegisterAgent(HWND, char *jid)
diff --git a/protocols/JabberG/src/jabber_captcha.cpp b/protocols/JabberG/src/jabber_captcha.cpp
index 89f8c118b9..9f77ba6456 100644
--- a/protocols/JabberG/src/jabber_captcha.cpp
+++ b/protocols/JabberG/src/jabber_captcha.cpp
@@ -92,7 +92,7 @@ INT_PTR CALLBACK JabberCaptchaFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
EndDialog(hwndDlg, 0);
return TRUE;
- case IDC_SUBMIT:
+ case IDOK:
GetDlgItemText(hwndDlg, IDC_VALUE, params->Result, _countof(params->Result));
EndDialog(hwndDlg, 1);
return TRUE;
diff --git a/protocols/JabberG/src/jabber_form.cpp b/protocols/JabberG/src/jabber_form.cpp
index 3f49a7312b..eb6c147b88 100644
--- a/protocols/JabberG/src/jabber_form.cpp
+++ b/protocols/JabberG/src/jabber_form.cpp
@@ -569,16 +569,11 @@ void JabberFormGetData(HWND hwndStatic, TiXmlElement *xRoot, const TiXmlElement
CJabberFormDlg::CJabberFormDlg(CJabberProto *ppro, const TiXmlElement *xNode, char *defTitle, JABBER_FORM_SUBMIT_FUNC pfnSubmit, void *userdata) :
CSuper(ppro, IDD_FORM),
- btnSubmit(this, IDC_SUBMIT),
- btnCancel(this, IDCANCEL),
m_pfnSubmit(pfnSubmit),
m_pUserdata(userdata),
m_defTitle(mir_strdup(defTitle))
{
m_xNode = xNode->DeepClone(&m_doc)->ToElement();
-
- btnSubmit.OnClick = Callback(this, &CJabberFormDlg::onClick_Submit);
- btnCancel.OnClick = Callback(this, &CJabberFormDlg::onClick_Cancel);
}
bool CJabberFormDlg::OnInitDialog()
@@ -625,12 +620,21 @@ bool CJabberFormDlg::OnInitDialog()
SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_FRAME), GWL_EXSTYLE, frameExStyle);
if (m_pfnSubmit != nullptr)
- EnableWindow(GetDlgItem(m_hwnd, IDC_SUBMIT), TRUE);
+ EnableWindow(GetDlgItem(m_hwnd, IDOK), TRUE);
+ return true;
+}
+
+bool CJabberFormDlg::OnApply()
+{
+ (m_proto->*(m_pfnSubmit))(this, m_pUserdata);
return true;
}
void CJabberFormDlg::OnDestroy()
{
+ if (!m_bSucceeded && m_pfnCancel)
+ (m_proto->*(m_pfnCancel))(this, m_pUserdata);
+
JabberFormDestroyUI(GetDlgItem(m_hwnd, IDC_FRAME));
mir_free(m_pUserdata);
}
@@ -691,18 +695,6 @@ INT_PTR CJabberFormDlg::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
return CSuper::DlgProc(msg, wParam, lParam);
}
-void CJabberFormDlg::onClick_Submit(CCtrlButton*)
-{
- (m_proto->*(m_pfnSubmit))(this, m_pUserdata);
- Close();
-}
-
-void CJabberFormDlg::onClick_Cancel(CCtrlButton*)
-{
- if (m_pfnCancel)
- (m_proto->*(m_pfnCancel))(this, m_pUserdata);
-}
-
static void CALLBACK JabberFormCreateDialogApcProc(void *param)
{
((CJabberFormDlg*)param)->Show();
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp
index 7b5cd15de6..aff88618b9 100644
--- a/protocols/JabberG/src/jabber_groupchat.cpp
+++ b/protocols/JabberG/src/jabber_groupchat.cpp
@@ -382,15 +382,11 @@ class CJabberDlgGcJoin : public CJabberDlgBase
char *m_jid;
- CCtrlButton btnOk;
-
public:
CJabberDlgGcJoin(CJabberProto *proto, char *jid) :
CSuper(proto, IDD_GROUPCHAT_JOIN),
- btnOk(this, IDOK),
m_jid(mir_strdup(jid))
{
- btnOk.OnClick = Callback(this, &CJabberDlgGcJoin::OnBtnOk);
}
~CJabberDlgGcJoin()
@@ -463,18 +459,7 @@ public:
return true;
}
- void OnDestroy() override
- {
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BM_SETIMAGE, IMAGE_ICON, 0));
- m_proto->m_pDlgJabberJoinGroupchat = nullptr;
- DeleteObject((HFONT)SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_GETFONT, 0, 0));
-
- CSuper::OnDestroy();
-
- mir_free(m_jid); m_jid = nullptr;
- }
-
- void OnBtnOk(CCtrlButton*)
+ bool OnApply() override
{
wchar_t text[128];
GetDlgItemText(m_hwnd, IDC_SERVER, text, _countof(text));
@@ -491,6 +476,18 @@ public:
GetDlgItemText(m_hwnd, IDC_PASSWORD, text, _countof(text));
T2Utf password(text);
m_proto->GroupchatJoinRoom(server, room, nick, password);
+ return true;
+ }
+
+ void OnDestroy() override
+ {
+ IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BM_SETIMAGE, IMAGE_ICON, 0));
+ m_proto->m_pDlgJabberJoinGroupchat = nullptr;
+ DeleteObject((HFONT)SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_GETFONT, 0, 0));
+
+ CSuper::OnDestroy();
+
+ mir_free(m_jid); m_jid = nullptr;
}
INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override
@@ -683,7 +680,7 @@ public:
if (GetAsyncKeyState(VK_CONTROL))
break;
- OnBtnOk(nullptr);
+ UIEmulateBtnClick(m_hwnd, IDOK);
Close();
}
break;
diff --git a/protocols/JabberG/src/jabber_notes.cpp b/protocols/JabberG/src/jabber_notes.cpp
index 8f1a4eef1e..c7065598cb 100644
--- a/protocols/JabberG/src/jabber_notes.cpp
+++ b/protocols/JabberG/src/jabber_notes.cpp
@@ -147,7 +147,6 @@ class CJabberDlgNoteItem : public CJabberDlgBase
CCtrlEdit m_txtTitle;
CCtrlEdit m_txtText;
CCtrlEdit m_txtTags;
- CCtrlButton m_btnOk;
public:
CJabberDlgNoteItem(CJabberDlgBase *parent, CNoteItem *pNote) :
@@ -156,11 +155,9 @@ public:
m_fnProcess(nullptr),
m_txtTitle(this, IDC_TXT_TITLE),
m_txtText(this, IDC_TXT_TEXT),
- m_txtTags(this, IDC_TXT_TAGS),
- m_btnOk(this, IDOK)
+ m_txtTags(this, IDC_TXT_TAGS)
{
SetParent(parent->GetHwnd());
- m_btnOk.OnClick = Callback(this, &CJabberDlgNoteItem::btnOk_OnClick);
}
CJabberDlgNoteItem(CJabberProto *proto, CNoteItem *pNote, TFnProcessNote fnProcess) :
@@ -169,10 +166,8 @@ public:
m_fnProcess(fnProcess),
m_txtTitle(this, IDC_TXT_TITLE),
m_txtText(this, IDC_TXT_TEXT),
- m_txtTags(this, IDC_TXT_TAGS),
- m_btnOk(this, IDOK)
+ m_txtTags(this, IDC_TXT_TAGS)
{
- m_btnOk.OnClick = Callback(this, &CJabberDlgNoteItem::btnOk_OnClick);
}
bool OnInitDialog() override
@@ -196,6 +191,18 @@ public:
return true;
}
+ bool OnApply() override
+ {
+ T2Utf szTitle(ptrW(m_txtTitle.GetText()));
+ T2Utf szTags(ptrW(m_txtTags.GetText()));
+ m_pNote->SetData(szTitle, m_pNote->GetFrom(), ptrW(m_txtText.GetText()), szTags);
+
+ m_autoClose = false;
+ if (m_fnProcess)
+ (m_proto->*m_fnProcess)(m_pNote, true);
+ return true;
+ }
+
int Resizer(UTILRESIZECONTROL *urc) override
{
switch (urc->wId) {
@@ -215,17 +222,6 @@ public:
return CSuper::Resizer(urc);
}
- void btnOk_OnClick(CCtrlButton*)
- {
- T2Utf szTitle(ptrW(m_txtTitle.GetText()));
- T2Utf szTags(ptrW(m_txtTags.GetText()));
- m_pNote->SetData(szTitle, m_pNote->GetFrom(), ptrW(m_txtText.GetText()), szTags);
-
- m_autoClose = false;
- if (m_fnProcess) (m_proto->*m_fnProcess)(m_pNote, true);
- EndDialog(m_hwnd, TRUE);
- }
-
bool OnClose() override
{
if (m_fnProcess)
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp
index fda71360fd..e6a44883e1 100755
--- a/protocols/JabberG/src/jabber_opt.cpp
+++ b/protocols/JabberG/src/jabber_opt.cpp
@@ -239,8 +239,6 @@ public:
m_btnOk(this, IDOK)
{
SetParent(hwndParent);
- m_autoClose = CLOSE_ON_CANCEL;
- m_btnOk.OnClick = Callback(this, &CJabberDlgRegister::btnOk_OnClick);
}
bool OnInitDialog() override
@@ -250,6 +248,23 @@ public:
return true;
}
+ bool OnApply() override
+ {
+ if (m_bProcessStarted) {
+ Close();
+ return true;
+ }
+
+ ShowWindow(GetDlgItem(m_hwnd, IDC_PROGRESS_REG), SW_SHOW);
+
+ m_regInfo->reg_hwndDlg = m_hwnd;
+ m_proto->ForkThread((CJabberProto::MyThreadFunc) & CJabberProto::ServerThread, m_regInfo);
+
+ m_btnOk.SetText(TranslateT("Cancel"));
+ m_bProcessStarted = true;
+ return false;
+ }
+
INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override
{
switch (msg) {
@@ -270,22 +285,6 @@ public:
return CSuper::DlgProc(msg, wParam, lParam);
}
-
- void btnOk_OnClick(CCtrlButton*)
- {
- if (m_bProcessStarted) {
- Close();
- return;
- }
-
- ShowWindow(GetDlgItem(m_hwnd, IDC_PROGRESS_REG), SW_SHOW);
-
- m_regInfo->reg_hwndDlg = m_hwnd;
- m_proto->ForkThread((CJabberProto::MyThreadFunc)&CJabberProto::ServerThread, m_regInfo);
-
- m_btnOk.SetText(TranslateT("Cancel"));
- m_bProcessStarted = true;
- }
};
/////////////////////////////////////////////////////////////////////////////////////////
@@ -507,7 +506,7 @@ protected:
void OnChange(CCtrlBase*)
{
- if (m_initialized)
+ if (m_bInitialized)
CheckRegistration();
}
@@ -1213,7 +1212,7 @@ protected:
void OnChange(CCtrlBase*)
{
- if (m_initialized)
+ if (m_bInitialized)
CheckRegistration();
}
diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp
index f789dd0a82..ce16d1ae0c 100644
--- a/protocols/JabberG/src/jabber_privacy.cpp
+++ b/protocols/JabberG/src/jabber_privacy.cpp
@@ -287,40 +287,32 @@ void CJabberProto::OnIqResultPrivacyLists(const TiXmlElement *iqNode, CJabberIqI
/////////////////////////////////////////////////////////////////////////////////////////
// Add privacy list box
+
class CJabberDlgPrivacyAddList : public CJabberDlgBase
{
- typedef CJabberDlgBase CSuper;
+ CCtrlEdit m_txtName;
public:
char szLine[512];
CJabberDlgPrivacyAddList(CJabberProto *proto, HWND hwndParent) :
CJabberDlgBase(proto, IDD_PRIVACY_ADD_LIST),
- m_txtName(this, IDC_EDIT_NAME),
- m_btnOk(this, IDOK),
- m_btnCancel(this, IDCANCEL)
+ m_txtName(this, IDC_EDIT_NAME)
{
SetParent(hwndParent);
-
- m_btnOk.OnClick = Callback(this, &CJabberDlgPrivacyAddList::btnOk_OnClick);
- m_btnCancel.OnClick = Callback(this, &CJabberDlgPrivacyAddList::btnCancel_OnClick);
}
- void btnOk_OnClick(CCtrlButton*)
+ bool OnApply() override
{
m_txtName.GetTextU(szLine, _countof(szLine));
- EndDialog(m_hwnd, 1);
+ return true;
}
- void btnCancel_OnClick(CCtrlButton*)
+
+ bool OnClose() override
{
- szLine[0] = 0;
- EndDialog(m_hwnd, 0);
+ EndModal(m_bSucceeded);
+ return true;
}
-
-private:
- CCtrlEdit m_txtName;
- CCtrlButton m_btnOk;
- CCtrlButton m_btnCancel;
};
/////////////////////////////////////////////////////////////////////////////////////////
@@ -329,8 +321,6 @@ class CJabberDlgPrivacyRule : public CJabberDlgBase
{
typedef CJabberDlgBase CSuper;
- CCtrlButton m_btnOk;
- CCtrlButton m_btnCancel;
CCtrlCombo m_cbType;
public:
@@ -338,16 +328,12 @@ public:
CJabberDlgPrivacyRule(CJabberProto *proto, HWND hwndParent, CPrivacyListRule *pRule) :
CJabberDlgBase(proto, IDD_PRIVACY_RULE),
- m_btnOk(this, IDOK),
- m_btnCancel(this, IDCANCEL),
m_cbType(this, IDC_COMBO_TYPE)
{
SetParent(hwndParent);
m_pRule = pRule;
m_cbType.OnChange = Callback(this, &CJabberDlgPrivacyRule::cbType_OnChange);
- m_btnOk.OnClick = Callback(this, &CJabberDlgPrivacyRule::btnOk_OnClick);
- m_btnCancel.OnClick = Callback(this, &CJabberDlgPrivacyRule::btnCancel_OnClick);
}
bool OnInitDialog() override
@@ -401,6 +387,56 @@ public:
return true;
}
+ bool OnApply() override
+ {
+ LRESULT nItemData = -1;
+ LRESULT nCurSel = SendDlgItemMessage(m_hwnd, IDC_COMBO_TYPE, CB_GETCURSEL, 0, 0);
+ if (nCurSel != CB_ERR)
+ nItemData = SendDlgItemMessage(m_hwnd, IDC_COMBO_TYPE, CB_GETITEMDATA, nCurSel, 0);
+
+ switch (nItemData) {
+ case Jid:
+ case Group:
+ wchar_t szText[512];
+ GetDlgItemText(m_hwnd, IDC_COMBO_VALUES, szText, _countof(szText));
+ m_pRule->SetValue(T2Utf(szText));
+ break;
+
+ case Subscription:
+ nCurSel = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_GETCURSEL, 0, 0);
+ if (nCurSel != CB_ERR)
+ m_pRule->SetValue((char *)SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_GETITEMDATA, nCurSel, 0));
+ else
+ m_pRule->SetValue("none");
+ break;
+
+ default:
+ m_pRule->SetValue(nullptr);
+ break;
+ }
+
+ m_pRule->SetType((PrivacyListRuleType)nItemData);
+ nCurSel = SendDlgItemMessage(m_hwnd, IDC_COMBO_ACTION, CB_GETCURSEL, 0, 0);
+ if (nCurSel == CB_ERR)
+ nCurSel = 1;
+ m_pRule->SetAction(nCurSel ? TRUE : FALSE);
+
+ DWORD dwPackets = 0;
+ if (BST_CHECKED == IsDlgButtonChecked(m_hwnd, IDC_CHECK_MESSAGES))
+ dwPackets |= JABBER_PL_RULE_TYPE_MESSAGE;
+ if (BST_CHECKED == IsDlgButtonChecked(m_hwnd, IDC_CHECK_PRESENCE_IN))
+ dwPackets |= JABBER_PL_RULE_TYPE_PRESENCE_IN;
+ if (BST_CHECKED == IsDlgButtonChecked(m_hwnd, IDC_CHECK_PRESENCE_OUT))
+ dwPackets |= JABBER_PL_RULE_TYPE_PRESENCE_OUT;
+ if (BST_CHECKED == IsDlgButtonChecked(m_hwnd, IDC_CHECK_QUERIES))
+ dwPackets |= JABBER_PL_RULE_TYPE_IQ;
+ if (!dwPackets)
+ dwPackets = JABBER_PL_RULE_TYPE_ALL;
+
+ m_pRule->SetPackets(dwPackets);
+ return true;
+ }
+
void OnDestroy() override
{
IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_MESSAGE, STM_SETICON, 0, 0));
@@ -488,62 +524,6 @@ public:
break;
}
}
-
- void btnOk_OnClick(CCtrlButton*)
- {
- LRESULT nItemData = -1;
- LRESULT nCurSel = SendDlgItemMessage(m_hwnd, IDC_COMBO_TYPE, CB_GETCURSEL, 0, 0);
- if (nCurSel != CB_ERR)
- nItemData = SendDlgItemMessage(m_hwnd, IDC_COMBO_TYPE, CB_GETITEMDATA, nCurSel, 0);
-
- switch (nItemData) {
- case Jid:
- case Group:
- wchar_t szText[512];
- GetDlgItemText(m_hwnd, IDC_COMBO_VALUES, szText, _countof(szText));
- m_pRule->SetValue(T2Utf(szText));
- break;
-
- case Subscription:
- nCurSel = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_GETCURSEL, 0, 0);
- if (nCurSel != CB_ERR)
- m_pRule->SetValue((char*)SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_GETITEMDATA, nCurSel, 0));
- else
- m_pRule->SetValue("none");
- break;
-
- default:
- m_pRule->SetValue(nullptr);
- break;
- }
-
- m_pRule->SetType((PrivacyListRuleType)nItemData);
- nCurSel = SendDlgItemMessage(m_hwnd, IDC_COMBO_ACTION, CB_GETCURSEL, 0, 0);
- if (nCurSel == CB_ERR)
- nCurSel = 1;
- m_pRule->SetAction(nCurSel ? TRUE : FALSE);
-
- DWORD dwPackets = 0;
- if (BST_CHECKED == IsDlgButtonChecked(m_hwnd, IDC_CHECK_MESSAGES))
- dwPackets |= JABBER_PL_RULE_TYPE_MESSAGE;
- if (BST_CHECKED == IsDlgButtonChecked(m_hwnd, IDC_CHECK_PRESENCE_IN))
- dwPackets |= JABBER_PL_RULE_TYPE_PRESENCE_IN;
- if (BST_CHECKED == IsDlgButtonChecked(m_hwnd, IDC_CHECK_PRESENCE_OUT))
- dwPackets |= JABBER_PL_RULE_TYPE_PRESENCE_OUT;
- if (BST_CHECKED == IsDlgButtonChecked(m_hwnd, IDC_CHECK_QUERIES))
- dwPackets |= JABBER_PL_RULE_TYPE_IQ;
- if (!dwPackets)
- dwPackets = JABBER_PL_RULE_TYPE_ALL;
-
- m_pRule->SetPackets(dwPackets);
-
- EndDialog(m_hwnd, 1);
- }
-
- void btnCancel_OnClick(CCtrlButton*)
- {
- EndDialog(m_hwnd, 0);
- }
};
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp
index 0b4848614a..fd41daf761 100644
--- a/protocols/JabberG/src/jabber_svc.cpp
+++ b/protocols/JabberG/src/jabber_svc.cpp
@@ -553,18 +553,17 @@ class CJabberDlgHttpAuth : public CJabberDlgBase
{
typedef CJabberDlgBase CSuper;
+ CCtrlEdit m_txtInfo;
+
+ CJabberHttpAuthParams *m_pParams;
+
public:
CJabberDlgHttpAuth(CJabberProto *proto, HWND hwndParent, CJabberHttpAuthParams *pParams) :
CSuper(proto, IDD_HTTP_AUTH),
m_txtInfo(this, IDC_EDIT_HTTP_AUTH_INFO),
- m_btnAuth(this, IDOK),
- m_btnDeny(this, IDCANCEL),
m_pParams(pParams)
{
SetParent(hwndParent);
-
- m_btnAuth.OnClick = Callback(this, &CJabberDlgHttpAuth::btnAuth_OnClick);
- m_btnDeny.OnClick = Callback(this, &CJabberDlgHttpAuth::btnDeny_OnClick);
}
bool OnInitDialog() override
@@ -580,24 +579,12 @@ public:
return true;
}
- BOOL SendReply(BOOL bAuthorized)
+ bool OnClose() override
{
- BOOL bRetVal = m_proto->SendHttpAuthReply(m_pParams, bAuthorized);
+ m_proto->SendHttpAuthReply(m_pParams, m_bSucceeded);
m_pParams->Free();
mir_free(m_pParams);
- m_pParams = nullptr;
- return bRetVal;
- }
-
- void btnAuth_OnClick(CCtrlButton*)
- {
- SendReply(TRUE);
- Close();
- }
- void btnDeny_OnClick(CCtrlButton*)
- {
- SendReply(FALSE);
- Close();
+ return true;
}
UI_MESSAGE_MAP(CJabberDlgHttpAuth, CSuper);
@@ -608,13 +595,6 @@ public:
{
return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
}
-
-private:
- CCtrlEdit m_txtInfo;
- CCtrlButton m_btnAuth;
- CCtrlButton m_btnDeny;
-
- CJabberHttpAuthParams *m_pParams;
};
// XEP-0070 support (http auth)
diff --git a/protocols/JabberG/src/jabber_xstatus.cpp b/protocols/JabberG/src/jabber_xstatus.cpp
index a9955b335d..826c1e733a 100644
--- a/protocols/JabberG/src/jabber_xstatus.cpp
+++ b/protocols/JabberG/src/jabber_xstatus.cpp
@@ -34,84 +34,65 @@ static CIconPool g_MoodIcons, g_ActivityIcons;
class CJabberDlgPepBase : public CJabberDlgBase
{
typedef CJabberDlgBase CSuper;
-public:
- CJabberDlgPepBase(CJabberProto *proto, int id);
+
+ int m_time = 5;
+ CTimer timer;
protected:
CPepService *m_pepService;
- CCtrlButton m_btnOk;
- CCtrlButton m_btnCancel;
-
- bool OnInitDialog() override;
- int Resizer(UTILRESIZECONTROL *urc) override;
- INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
-
- void StopTimer();
-
-private:
- int m_time;
-};
-
-CJabberDlgPepBase::CJabberDlgPepBase(CJabberProto *proto, int id) :
- CJabberDlgBase(proto, id),
- m_btnOk(this, IDOK),
- m_btnCancel(this, IDCANCEL),
- m_time(5)
-{
-}
+ CCtrlButton btnOk;
-bool CJabberDlgPepBase::OnInitDialog()
-{
- CSuper::OnInitDialog();
+public:
+ CJabberDlgPepBase(CJabberProto *proto, int id) :
+ CJabberDlgBase(proto, id),
+ timer(this, 1),
+ btnOk(this, IDOK)
+ {
+ timer.OnEvent = Callback(this, &CJabberDlgPepBase::OnTimer);
+ }
- SetTimer(m_hwnd, 1, 1000, nullptr);
+ bool OnInitDialog() override
+ {
+ CSuper::OnInitDialog();
- wchar_t buf[128];
- mir_snwprintf(buf, TranslateT("OK (%d)"), m_time);
- m_btnOk.SetText(buf);
- return true;
-}
+ timer.Start(1000);
-int CJabberDlgPepBase::Resizer(UTILRESIZECONTROL *urc)
-{
- switch (urc->wId) {
- case IDOK:
- case IDCANCEL:
- return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
+ wchar_t buf[128];
+ mir_snwprintf(buf, TranslateT("OK (%d)"), m_time);
+ btnOk.SetText(buf);
+ return true;
}
- return CSuper::Resizer(urc);
-}
+ int Resizer(UTILRESIZECONTROL *urc) override
+ {
+ switch (urc->wId) {
+ case IDOK:
+ case IDCANCEL:
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
+ }
-INT_PTR CJabberDlgPepBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg) {
- case WM_TIMER:
- if (wParam == 1) {
- wchar_t buf[128];
- mir_snwprintf(buf, TranslateT("OK (%d)"), --m_time);
- m_btnOk.SetText(buf);
+ return CSuper::Resizer(urc);
+ }
- if (m_time < 0) {
- KillTimer(m_hwnd, 1);
- UIEmulateBtnClick(m_hwnd, IDOK);
- }
+ void OnTimer(CTimer *)
+ {
+ wchar_t buf[128];
+ mir_snwprintf(buf, TranslateT("OK (%d)"), --m_time);
+ btnOk.SetText(buf);
- return TRUE;
+ if (m_time < 0) {
+ timer.Stop();
+ UIEmulateBtnClick(m_hwnd, IDOK);
}
-
- break;
}
- return CSuper::DlgProc(msg, wParam, lParam);
-}
-
-void CJabberDlgPepBase::StopTimer()
-{
- KillTimer(m_hwnd, 1);
- m_btnOk.SetText(TranslateT("OK"));
-}
+ void StopTimer()
+ {
+ timer.Stop();
+ btnOk.SetText(TranslateT("OK"));
+ }
+};
///////////////////////////////////////////////////////////////////////////////
// Simple PEP status
@@ -119,32 +100,7 @@ void CJabberDlgPepBase::StopTimer()
class CJabberDlgPepSimple : public CJabberDlgPepBase
{
typedef CJabberDlgPepBase CSuper;
-public:
- CJabberDlgPepSimple(CJabberProto *proto, wchar_t *title);
- ~CJabberDlgPepSimple();
-
- bool OkClicked() { return m_bOkClicked; }
- void AddStatusMode(LPARAM id, char *name, HICON hIcon, wchar_t *title, bool subitem = false);
- void SetActiveStatus(LPARAM id, wchar_t *text);
- LPARAM GetStatusMode();
- wchar_t *GetStatusText();
-protected:
- CCtrlCombo m_cbModes;
- CCtrlEdit m_txtDescription;
-
- bool OnInitDialog() override;
- int Resizer(UTILRESIZECONTROL *urc);
-
- UI_MESSAGE_MAP(CJabberDlgPepSimple, CSuper);
- UI_MESSAGE(WM_MEASUREITEM, OnWmMeasureItem);
- UI_MESSAGE(WM_DRAWITEM, OnWmDrawItem);
- UI_MESSAGE_MAP_END();
-
- BOOL OnWmMeasureItem(UINT msg, WPARAM wParam, LPARAM lParam);
- BOOL OnWmDrawItem(UINT msg, WPARAM wParam, LPARAM lParam);
-
-private:
struct CStatusMode
{
LPARAM m_id;
@@ -163,207 +119,209 @@ private:
int m_time;
int m_prevSelected;
int m_selected;
- bool m_bOkClicked;
LPARAM m_active;
wchar_t *m_activeText;
- void btnOk_OnClick(CCtrlButton*btn);
- void global_OnChange(CCtrlData *);
- void cbModes_OnChange(CCtrlData *);
-};
+ void global_OnChange(CCtrlData *)
+ {
+ StopTimer();
+ }
-CJabberDlgPepSimple::CJabberDlgPepSimple(CJabberProto *proto, wchar_t *title) :
- CJabberDlgPepBase(proto, IDD_PEP_SIMPLE),
- m_cbModes(this, IDC_CB_MODES),
- m_txtDescription(this, IDC_TXT_DESCRIPTION),
- m_modes(10),
- m_text(nullptr),
- m_selected(0),
- m_prevSelected(-1),
- m_active(-1),
- m_bOkClicked(false),
- m_title(title)
-{
- SetMinSize(200, 200);
+ void cbModes_OnChange(CCtrlData *)
+ {
+ StopTimer();
- m_btnOk.OnClick = Callback(this, &CJabberDlgPepSimple::btnOk_OnClick);
- m_cbModes.OnChange = Callback(this, &CJabberDlgPepSimple::cbModes_OnChange);
- m_cbModes.OnDropdown =
- m_txtDescription.OnChange = Callback(this, &CJabberDlgPepSimple::global_OnChange);
+ if (m_prevSelected == m_cbModes.GetCurSel())
+ return;
- m_modes.insert(new CStatusMode(-1, "<none>", Skin_LoadIcon(SKINICON_OTHER_SMALLDOT), TranslateT("None"), false));
-}
+ char szSetting[128];
-CJabberDlgPepSimple::~CJabberDlgPepSimple()
-{
- mir_free(m_text);
-}
+ CStatusMode *pMode = (CStatusMode *)m_cbModes.GetItemData(m_prevSelected);
+ if (m_prevSelected >= 0 && pMode->m_id >= 0) {
+ wchar_t *txt = m_txtDescription.GetText();
+ mir_snprintf(szSetting, "PepMsg_%s", pMode->m_name);
+ m_proto->setWString(szSetting, txt);
+ mir_free(txt);
+ }
-void CJabberDlgPepSimple::AddStatusMode(LPARAM id, char *name, HICON hIcon, wchar_t *title, bool subitem)
-{
- m_modes.insert(new CStatusMode(id, name, hIcon, title, subitem));
-}
+ m_prevSelected = m_cbModes.GetCurSel();
+ pMode = (CStatusMode *)m_cbModes.GetItemData(m_prevSelected);
+ if (m_prevSelected >= 0 && pMode->m_id >= 0) {
+ mir_snprintf(szSetting, "PepMsg_%s", pMode->m_name);
-void CJabberDlgPepSimple::SetActiveStatus(LPARAM id, wchar_t *text)
-{
- m_active = id;
- m_activeText = text;
-}
+ ptrW szDescr(m_proto->getWStringA(szSetting));
+ m_txtDescription.SetText((szDescr != nullptr) ? szDescr : L"");
+ m_txtDescription.Enable(true);
+ }
+ else {
+ m_txtDescription.SetTextA("");
+ m_txtDescription.Enable(false);
+ }
+ }
-LPARAM CJabberDlgPepSimple::GetStatusMode()
-{
- return m_modes[m_selected].m_id;
-}
+ CCtrlCombo m_cbModes;
+ CCtrlEdit m_txtDescription;
-wchar_t* CJabberDlgPepSimple::GetStatusText()
-{
- return m_text;
-}
+ UI_MESSAGE_MAP(CJabberDlgPepSimple, CSuper);
+ UI_MESSAGE(WM_MEASUREITEM, OnWmMeasureItem);
+ UI_MESSAGE(WM_DRAWITEM, OnWmDrawItem);
+ UI_MESSAGE_MAP_END();
-bool CJabberDlgPepSimple::OnInitDialog()
-{
- CSuper::OnInitDialog();
+public:
+ CJabberDlgPepSimple(CJabberProto *proto, wchar_t *title) :
+ CJabberDlgPepBase(proto, IDD_PEP_SIMPLE),
+ m_cbModes(this, IDC_CB_MODES),
+ m_txtDescription(this, IDC_TXT_DESCRIPTION),
+ m_modes(10),
+ m_text(nullptr),
+ m_selected(0),
+ m_prevSelected(-1),
+ m_active(-1),
+ m_title(title)
+ {
+ SetMinSize(200, 200);
- Window_SetIcon_IcoLib(m_hwnd, m_proto->m_hProtoIcon);
- SetWindowText(m_hwnd, m_title);
+ m_cbModes.OnChange = Callback(this, &CJabberDlgPepSimple::cbModes_OnChange);
+ m_cbModes.OnDropdown =
+ m_txtDescription.OnChange = Callback(this, &CJabberDlgPepSimple::global_OnChange);
- m_txtDescription.Enable(false);
- for (auto &it : m_modes) {
- int idx = m_cbModes.AddString(it->m_title, (LPARAM)it);
- if (it->m_id == m_active || !idx) {
- m_prevSelected = idx;
- m_cbModes.SetCurSel(idx);
- if (idx)
- m_txtDescription.Enable();
- }
+ m_modes.insert(new CStatusMode(-1, "<none>", Skin_LoadIcon(SKINICON_OTHER_SMALLDOT), TranslateT("None"), false));
}
- if (m_activeText)
- m_txtDescription.SetText(m_activeText);
- return true;
-}
-
-int CJabberDlgPepSimple::Resizer(UTILRESIZECONTROL *urc)
-{
- switch (urc->wId) {
- case IDC_CB_MODES:
- return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP;
- case IDC_TXT_DESCRIPTION:
- return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
+ ~CJabberDlgPepSimple()
+ {
+ mir_free(m_text);
}
- return CSuper::Resizer(urc);
-}
+ bool OnInitDialog() override
+ {
+ CSuper::OnInitDialog();
-void CJabberDlgPepSimple::btnOk_OnClick(CCtrlButton*)
-{
- m_text = m_txtDescription.GetText();
- m_selected = m_cbModes.GetCurSel();
- m_bOkClicked = true;
-}
+ Window_SetIcon_IcoLib(m_hwnd, m_proto->m_hProtoIcon);
+ SetWindowText(m_hwnd, m_title);
-void CJabberDlgPepSimple::global_OnChange(CCtrlData *)
-{
- StopTimer();
-}
+ m_txtDescription.Enable(false);
+ for (auto &it : m_modes) {
+ int idx = m_cbModes.AddString(it->m_title, (LPARAM)it);
+ if (it->m_id == m_active || !idx) {
+ m_prevSelected = idx;
+ m_cbModes.SetCurSel(idx);
+ if (idx)
+ m_txtDescription.Enable();
+ }
+ }
-void CJabberDlgPepSimple::cbModes_OnChange(CCtrlData *)
-{
- StopTimer();
+ if (m_activeText)
+ m_txtDescription.SetText(m_activeText);
+ return true;
+ }
- if (m_prevSelected == m_cbModes.GetCurSel())
- return;
+ bool OnApply() override
+ {
+ m_text = m_txtDescription.GetText();
+ m_selected = m_cbModes.GetCurSel();
+ return true;
+ }
- char szSetting[128];
+ int Resizer(UTILRESIZECONTROL *urc) override
+ {
+ switch (urc->wId) {
+ case IDC_CB_MODES:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP;
+ case IDC_TXT_DESCRIPTION:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
+ }
- CStatusMode *pMode = (CStatusMode*)m_cbModes.GetItemData(m_prevSelected);
- if (m_prevSelected >= 0 && pMode->m_id >= 0) {
- wchar_t *txt = m_txtDescription.GetText();
- mir_snprintf(szSetting, "PepMsg_%s", pMode->m_name);
- m_proto->setWString(szSetting, txt);
- mir_free(txt);
+ return CSuper::Resizer(urc);
}
- m_prevSelected = m_cbModes.GetCurSel();
- pMode = (CStatusMode*)m_cbModes.GetItemData(m_prevSelected);
- if (m_prevSelected >= 0 && pMode->m_id >= 0) {
- mir_snprintf(szSetting, "PepMsg_%s", pMode->m_name);
+ void AddStatusMode(LPARAM id, char *name, HICON hIcon, wchar_t *title, bool subitem = false)
+ {
+ m_modes.insert(new CStatusMode(id, name, hIcon, title, subitem));
+ }
- ptrW szDescr(m_proto->getWStringA(szSetting));
- m_txtDescription.SetText((szDescr != nullptr) ? szDescr : L"");
- m_txtDescription.Enable(true);
+ void SetActiveStatus(LPARAM id, wchar_t *text)
+ {
+ m_active = id;
+ m_activeText = text;
}
- else {
- m_txtDescription.SetTextA("");
- m_txtDescription.Enable(false);
+
+ LPARAM GetStatusMode()
+ {
+ return m_modes[m_selected].m_id;
}
-}
-BOOL CJabberDlgPepSimple::OnWmMeasureItem(UINT, WPARAM, LPARAM lParam)
-{
- LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam;
- if (lpmis->CtlID != IDC_CB_MODES)
- return FALSE;
+ wchar_t *GetStatusText()
+ {
+ return m_text;
+ }
- HDC hdc = GetDC(m_cbModes.GetHwnd());
- TEXTMETRIC tm = {};
- GetTextMetrics(hdc, &tm);
- ReleaseDC(m_cbModes.GetHwnd(), hdc);
+ BOOL OnWmMeasureItem(UINT, WPARAM, LPARAM lParam)
+ {
+ LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam;
+ if (lpmis->CtlID != IDC_CB_MODES)
+ return FALSE;
+
+ HDC hdc = GetDC(m_cbModes.GetHwnd());
+ TEXTMETRIC tm = {};
+ GetTextMetrics(hdc, &tm);
+ ReleaseDC(m_cbModes.GetHwnd(), hdc);
+
+ lpmis->itemHeight = max(tm.tmHeight, 18);
+ if (lpmis->itemHeight < 18)
+ lpmis->itemHeight = 18;
+ return TRUE;
+ }
- lpmis->itemHeight = max(tm.tmHeight, 18);
- if (lpmis->itemHeight < 18)
- lpmis->itemHeight = 18;
- return TRUE;
-}
+ BOOL OnWmDrawItem(UINT, WPARAM, LPARAM lParam)
+ {
+ LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
+ if (lpdis->CtlID != IDC_CB_MODES)
+ return FALSE;
-BOOL CJabberDlgPepSimple::OnWmDrawItem(UINT, WPARAM, LPARAM lParam)
-{
- LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
- if (lpdis->CtlID != IDC_CB_MODES)
- return FALSE;
+ if (lpdis->itemData == -1)
+ return FALSE;
- if (lpdis->itemData == -1)
- return FALSE;
+ CStatusMode *mode = (CStatusMode *)lpdis->itemData;
- CStatusMode *mode = (CStatusMode *)lpdis->itemData;
+ TEXTMETRIC tm = { 0 };
+ GetTextMetrics(lpdis->hDC, &tm);
- TEXTMETRIC tm = { 0 };
- GetTextMetrics(lpdis->hDC, &tm);
+ SetBkMode(lpdis->hDC, TRANSPARENT);
+ if (lpdis->itemState & ODS_SELECTED) {
+ SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
+ FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
+ }
+ else {
+ SetTextColor(lpdis->hDC, GetSysColor(COLOR_WINDOWTEXT));
+ FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_WINDOW));
+ }
- SetBkMode(lpdis->hDC, TRANSPARENT);
- if (lpdis->itemState & ODS_SELECTED) {
- SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
- FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
- }
- else {
- SetTextColor(lpdis->hDC, GetSysColor(COLOR_WINDOWTEXT));
- FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_WINDOW));
- }
+ if (!mode->m_subitem || (lpdis->itemState & ODS_COMBOBOXEDIT)) {
+ wchar_t text[128];
+ if (mode->m_subitem) {
+ for (int i = mode->m_id; i >= 0; --i)
+ if (!m_modes[i].m_subitem) {
+ mir_snwprintf(text, L"%s [%s]", m_modes[i].m_title, mode->m_title);
+ break;
+ }
+ }
+ else mir_wstrncpy(text, mode->m_title, _countof(text));
- if (!mode->m_subitem || (lpdis->itemState & ODS_COMBOBOXEDIT)) {
- wchar_t text[128];
- if (mode->m_subitem) {
- for (int i = mode->m_id; i >= 0; --i)
- if (!m_modes[i].m_subitem) {
- mir_snwprintf(text, L"%s [%s]", m_modes[i].m_title, mode->m_title);
- break;
- }
+ DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 2, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2, mode->m_hIcon, 16, 16, 0, nullptr, DI_NORMAL);
+ TextOut(lpdis->hDC, lpdis->rcItem.left + 23, (lpdis->rcItem.top + lpdis->rcItem.bottom - tm.tmHeight) / 2, text, (int)mir_wstrlen(text));
+ }
+ else {
+ wchar_t text[128];
+ mir_snwprintf(text, L"...%s", mode->m_title);
+ DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 23, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2, mode->m_hIcon, 16, 16, 0, nullptr, DI_NORMAL);
+ TextOut(lpdis->hDC, lpdis->rcItem.left + 44, (lpdis->rcItem.top + lpdis->rcItem.bottom - tm.tmHeight) / 2, text, (int)mir_wstrlen(text));
}
- else mir_wstrncpy(text, mode->m_title, _countof(text));
- DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 2, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2, mode->m_hIcon, 16, 16, 0, nullptr, DI_NORMAL);
- TextOut(lpdis->hDC, lpdis->rcItem.left + 23, (lpdis->rcItem.top + lpdis->rcItem.bottom - tm.tmHeight) / 2, text, (int)mir_wstrlen(text));
- }
- else {
- wchar_t text[128];
- mir_snwprintf(text, L"...%s", mode->m_title);
- DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 23, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2, mode->m_hIcon, 16, 16, 0, nullptr, DI_NORMAL);
- TextOut(lpdis->hDC, lpdis->rcItem.left + 44, (lpdis->rcItem.top + lpdis->rcItem.bottom - tm.tmHeight) / 2, text, (int)mir_wstrlen(text));
+ return TRUE;
}
-
- return TRUE;
-}
+};
///////////////////////////////////////////////////////////////////////////////
// CPepService base class
@@ -719,8 +677,7 @@ void CPepMood::ShowSetDialog(BYTE bQuiet)
dlg.AddStatusMode(i, g_arrMoods[i].szTag, g_MoodIcons.GetIcon(g_arrMoods[i].szTag), TranslateW(g_arrMoods[i].szName));
dlg.SetActiveStatus(m_mode, m_text);
- dlg.DoModal();
- if (!dlg.OkClicked())
+ if (!dlg.DoModal())
return;
m_mode = dlg.GetStatusMode();
@@ -1078,9 +1035,8 @@ void CPepActivity::ShowSetDialog(BYTE)
dlg.AddStatusMode(i, ActivityGetId(i), g_ActivityIcons.GetIcon(returnActivity(i)), TranslateW(g_arrActivities[i].szTitle), (g_arrActivities[i].szSecond != nullptr));
dlg.SetActiveStatus(m_mode, m_text);
- dlg.DoModal();
-
- if (!dlg.OkClicked()) return;
+ if (!dlg.DoModal())
+ return;
m_mode = dlg.GetStatusMode();
if (m_mode >= 0) {
diff --git a/protocols/JabberG/src/resource.h b/protocols/JabberG/src/resource.h
index c9a3df960e..a3e3f5987f 100644
--- a/protocols/JabberG/src/resource.h
+++ b/protocols/JabberG/src/resource.h
@@ -97,7 +97,6 @@
#define IDC_LINK_PUBLIC_SERVER 1009
#define IDC_NAME 1009
#define IDC_PROGRESS_REG 1011
-#define IDC_SUBMIT 1023
#define IDC_NEXT 1025
#define IDC_PREV 1026
#define IDC_COMPLETE 1027
diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h
index 2082acca92..e744ff7075 100755
--- a/protocols/JabberG/src/stdafx.h
+++ b/protocols/JabberG/src/stdafx.h
@@ -653,10 +653,6 @@ class CJabberFormDlg : public CJabberDlgBase
int m_formHeight; // Actual height of the form
int m_curPos; // Current scroll position
- CCtrlButton btnSubmit, btnCancel;
- void onClick_Submit(CCtrlButton*);
- void onClick_Cancel(CCtrlButton*);
-
public:
CJabberFormDlg(CJabberProto *ppro, const TiXmlElement *xNode, char *defTitle, JABBER_FORM_SUBMIT_FUNC pfnSubmit, void *userdata);
@@ -668,6 +664,7 @@ public:
}
bool OnInitDialog() override;
+ bool OnApply() override;
void OnDestroy() override;
INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
};
diff --git a/protocols/NewsAggregator/Src/Authentication.cpp b/protocols/NewsAggregator/Src/Authentication.cpp
index 33b080bb6c..0797dfde22 100644
--- a/protocols/NewsAggregator/Src/Authentication.cpp
+++ b/protocols/NewsAggregator/Src/Authentication.cpp
@@ -43,13 +43,13 @@ void CreateAuthString(char *auth, MCONTACT hContact, CFeedEditor *pDlg)
}
CAuthRequest::CAuthRequest(CFeedEditor *pDlg, MCONTACT hContact) :
- CSuper(g_plugin, IDD_AUTHENTICATION),
- m_feedname(this, IDC_FEEDNAME), m_username(this, IDC_FEEDUSERNAME),
- m_password(this, IDC_FEEDPASSWORD), m_ok(this, IDOK)
+ CDlgBase(g_plugin, IDD_AUTHENTICATION),
+ m_feedname(this, IDC_FEEDNAME),
+ m_username(this, IDC_FEEDUSERNAME),
+ m_password(this, IDC_FEEDPASSWORD)
{
m_pDlg = pDlg;
m_hContact = hContact;
- m_ok.OnClick = Callback(this, &CAuthRequest::OnOk);
}
bool CAuthRequest::OnInitDialog()
@@ -74,18 +74,19 @@ bool CAuthRequest::OnInitDialog()
return true;
}
-void CAuthRequest::OnOk(CCtrlBase*)
+bool CAuthRequest::OnApply()
{
ptrW strfeedusername(m_username.GetText());
if (!strfeedusername || mir_wstrcmp(strfeedusername, L"") == 0) {
MessageBox(m_hwnd, TranslateT("Enter your username"), TranslateT("Error"), MB_OK | MB_ICONERROR);
- return;
+ return false;
}
ptrA strfeedpassword(m_password.GetTextA());
if (!strfeedpassword || mir_strcmp(strfeedpassword, "") == 0) {
MessageBox(m_hwnd, TranslateT("Enter your password"), TranslateT("Error"), MB_OK | MB_ICONERROR);
- return;
+ return false;
}
+
if (m_pDlg) {
m_pDlg->m_useauth.SetState(1);
m_pDlg->m_login.Enable(1);
@@ -98,4 +99,5 @@ void CAuthRequest::OnOk(CCtrlBase*)
g_plugin.setWString(m_hContact, "Login", strfeedusername);
g_plugin.setString(m_hContact, "Password", strfeedpassword);
}
+ return true;
}
diff --git a/protocols/NewsAggregator/Src/Options.cpp b/protocols/NewsAggregator/Src/Options.cpp
index cae87cf248..2dfcadf7da 100644
--- a/protocols/NewsAggregator/Src/Options.cpp
+++ b/protocols/NewsAggregator/Src/Options.cpp
@@ -30,7 +30,6 @@ CExportFeed::CExportFeed()
m_removefeed.OnClick = Callback(this, &CExportFeed::OnRemoveFeed);
m_addallfeeds.OnClick = Callback(this, &CExportFeed::OnAddAllFeeds);
m_removeallfeeds.OnClick = Callback(this, &CExportFeed::OnRemoveAllFeeds);
- m_ok.OnClick = Callback(this, &CExportFeed::OnOk);
m_feedslist.OnDblClick = Callback(this, &CExportFeed::OnFeedsList);
m_feedsexportlist.OnDblClick = Callback(this, &CExportFeed::OnFeedsExportList);
@@ -190,7 +189,7 @@ static const TiXmlElement* AdviceNode(const TiXmlElement *node)
return nullptr;
}
-void CExportFeed::OnOk(CCtrlBase*)
+bool CExportFeed::OnApply()
{
wchar_t FileName[MAX_PATH];
VARSW tszMirDir(L"%miranda_path%");
@@ -209,7 +208,7 @@ void CExportFeed::OnOk(CCtrlBase*)
*FileName = '\0';
ofn.lpstrDefExt = L"";
if (!GetSaveFileName(&ofn))
- return;
+ return false;
TiXmlDocument doc;
auto *hXml = doc.NewElement("opml"); doc.InsertEndChild(hXml);
@@ -274,14 +273,14 @@ void CExportFeed::OnOk(CCtrlBase*)
doc.Print(&printer);
fclose(out);
}
+ return true;
}
-bool CExportFeed::OnClose()
+void CExportFeed::OnDestroy()
{
Utils_SaveWindowPosition(m_hwnd, NULL, MODULENAME, "ExportDlg");
if (pExportDialog)
pExportDialog = nullptr;
- return true;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -300,7 +299,6 @@ CImportFeed::CImportFeed(CCtrlListView *m_feeds)
m_removefeed.OnClick = Callback(this, &CImportFeed::OnRemoveFeed);
m_addallfeeds.OnClick = Callback(this, &CImportFeed::OnAddAllFeeds);
m_removeallfeeds.OnClick = Callback(this, &CImportFeed::OnRemoveAllFeeds);
- m_ok.OnClick = Callback(this, &CImportFeed::OnOk);
m_feedslist.OnDblClick = Callback(this, &CImportFeed::OnFeedsList);
m_feedsimportlist.OnDblClick = Callback(this, &CImportFeed::OnFeedsImportList);
@@ -492,26 +490,26 @@ void CImportFeed::OnFeedsImportList(CCtrlBase*)
}
}
-void CImportFeed::OnOk(CCtrlBase*)
+bool CImportFeed::OnApply()
{
wchar_t FileName[MAX_PATH];
m_importfile.GetText(FileName, _countof(FileName));
FILE *in = _wfopen(FileName, L"rb");
if (in == nullptr)
- return;
+ return false;
TiXmlDocument doc;
int res = doc.LoadFile(in);
fclose(in);
if (res != 0)
- return;
+ return false;
auto *node = TiXmlConst(&doc)["opml"]["body"]["outline"].ToElement();
if (!node)
node = TiXmlConst(&doc)["body"]["outline"].ToElement();
if (node == nullptr)
- return;
+ return false;
int count = m_feedsimportlist.GetCount();
int DUPES = 0;
@@ -598,14 +596,14 @@ void CImportFeed::OnOk(CCtrlBase*)
else
mir_snwprintf(mes, TranslateT("Imported %d feed(s)."), count);
MessageBox(m_hwnd, mes, TranslateT("News Aggregator"), MB_OK | MB_ICONINFORMATION);
+ return true;
}
-bool CImportFeed::OnClose()
+void CImportFeed::OnDestroy()
{
Utils_SaveWindowPosition(m_hwnd, NULL, MODULENAME, "ImportDlg");
if (pImportDialog)
pImportDialog = nullptr;
- return true;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -617,7 +615,8 @@ CFeedEditor::CFeedEditor(int iItem, CCtrlListView *m_feeds, MCONTACT Contact)
m_checkfeed(this, IDC_DISCOVERY), m_useauth(this, IDC_USEAUTH),
m_login(this, IDC_LOGIN), m_password(this, IDC_PASSWORD),
m_tagedit(this, IDC_TAGSEDIT), m_reset(this, IDC_RESET),
- m_help(this, IDC_TAGHELP), m_ok(this, IDOK), m_iItem(iItem)
+ m_help(this, IDC_TAGHELP),
+ m_iItem(iItem)
{
m_list = m_feeds;
m_hContact = Contact;
@@ -625,7 +624,6 @@ CFeedEditor::CFeedEditor(int iItem, CCtrlListView *m_feeds, MCONTACT Contact)
m_useauth.OnChange = Callback(this, &CFeedEditor::OnUseAuth);
m_reset.OnClick = Callback(this, &CFeedEditor::OnReset);
m_help.OnClick = Callback(this, &CFeedEditor::OnHelp);
- m_ok.OnClick = Callback(this, &CFeedEditor::OnOk);
}
bool CFeedEditor::OnInitDialog()
@@ -748,24 +746,24 @@ void CFeedEditor::OnHelp(CCtrlBase*)
MessageBox(m_hwnd, wszTagHelp, TranslateT("Feed Tag Help"), MB_OK);
}
-void CFeedEditor::OnOk(CCtrlBase*)
+bool CFeedEditor::OnApply()
{
ptrW strfeedtitle(m_feedtitle.GetText());
if (!strfeedtitle || mir_wstrcmp(strfeedtitle, L"") == 0) {
MessageBox(m_hwnd, TranslateT("Enter Feed name"), TranslateT("Error"), MB_OK);
- return;
+ return false;
}
ptrW strfeedurl(m_feedurl.GetText());
if (!strfeedurl || mir_wstrcmp(strfeedurl, L"http://") == 0 || mir_wstrcmp(strfeedurl, L"") == 0) {
MessageBox(m_hwnd, TranslateT("Enter Feed URL"), TranslateT("Error"), MB_OK);
- return;
+ return false;
}
ptrW strtagedit(m_tagedit.GetText());
if (!strtagedit || mir_wstrcmp(strtagedit, L"") == 0) {
MessageBox(m_hwnd, TranslateT("Enter message format"), TranslateT("Error"), MB_OK);
- return;
+ return false;
}
MCONTACT hContact;
@@ -801,15 +799,15 @@ void CFeedEditor::OnOk(CCtrlBase*)
m_list->SetItem(m_iItem, 0, strfeedtitle);
m_list->SetItem(m_iItem, 1, strfeedurl);
}
+ return true;
}
-bool CFeedEditor::OnClose()
+void CFeedEditor::OnDestroy()
{
g_arFeeds.remove(this);
Utils_SaveWindowPosition(m_hwnd, NULL, MODULENAME, m_iItem == -1 ? "AddDlg" : "ChangeDlg");
if (pAddFeedDialog == this)
pAddFeedDialog = nullptr;
- return true;
}
void CFeedEditor::OnUseAuth(CCtrlBase*)
diff --git a/protocols/NewsAggregator/Src/Options.h b/protocols/NewsAggregator/Src/Options.h
index 2389eb9bb9..c92c886da8 100644
--- a/protocols/NewsAggregator/Src/Options.h
+++ b/protocols/NewsAggregator/Src/Options.h
@@ -50,16 +50,15 @@ private:
CCtrlEdit m_tagedit;
CCtrlButton m_reset;
CCtrlButton m_help;
- CCtrlButton m_ok;
protected:
bool OnInitDialog() override;
- bool OnClose() override;
+ bool OnApply() override;
+ void OnDestroy() override;
void OnCheckFeed(CCtrlBase*);
void OnReset(CCtrlBase*);
void OnHelp(CCtrlBase*);
- void OnOk(CCtrlBase*);
void OnUseAuth(CCtrlBase*);
public:
@@ -91,14 +90,14 @@ private:
protected:
bool OnInitDialog() override;
- bool OnClose() override;
+ bool OnApply() override;
+ void OnDestroy() override;
void OnBrowseFile(CCtrlBase*);
void OnAddFeed(CCtrlBase*);
void OnRemoveFeed(CCtrlBase*);
void OnAddAllFeeds(CCtrlBase*);
void OnRemoveAllFeeds(CCtrlBase*);
- void OnOk(CCtrlBase*);
void OnFeedsList(CCtrlBase*);
void OnFeedsImportList(CCtrlBase*);
@@ -122,13 +121,13 @@ private:
protected:
bool OnInitDialog() override;
- bool OnClose() override;
+ bool OnApply() override;
+ void OnDestroy() override;
void OnAddFeed(CCtrlBase*);
void OnRemoveFeed(CCtrlBase*);
void OnAddAllFeeds(CCtrlBase*);
void OnRemoveAllFeeds(CCtrlBase*);
- void OnOk(CCtrlBase*);
void OnFeedsList(CCtrlBase*);
void OnFeedsExportList(CCtrlBase*);
@@ -139,24 +138,18 @@ public:
class CAuthRequest : public CDlgBase
{
-private:
- typedef CDlgBase CSuper;
-
CFeedEditor *m_pDlg;
MCONTACT m_hContact;
CCtrlBase m_feedname;
CCtrlEdit m_username;
CCtrlEdit m_password;
- CCtrlButton m_ok;
-
-protected:
- bool OnInitDialog() override;
-
- void OnOk(CCtrlBase*);
public:
CAuthRequest(CFeedEditor *pDlg, MCONTACT hContact);
+
+ bool OnInitDialog() override;
+ bool OnApply() override;
};
#endif //_OPTIONS_H_ \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp
index 6aeea2bab4..137d6b8475 100644
--- a/protocols/SkypeWeb/src/skype_chatrooms.cpp
+++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp
@@ -117,20 +117,10 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
case 10:
{
CSkypeInviteDlg dlg(this);
- {
- mir_cslock lck(m_InviteDialogsLock);
- m_InviteDialogs.insert(&dlg);
+ if (dlg.DoModal()) {
+ if (dlg.m_hContact != NULL)
+ SendRequest(new InviteUserToChatRequest(chat_id, getId(dlg.m_hContact), "User"));
}
-
- if (!dlg.DoModal())
- break;
-
- MCONTACT hContact = dlg.m_hContact;
- if (hContact != NULL)
- SendRequest(new InviteUserToChatRequest(chat_id, getId(hContact), "User"));
-
- mir_cslock lck(m_InviteDialogsLock);
- m_InviteDialogs.remove(&dlg);
}
break;
@@ -475,15 +465,10 @@ INT_PTR CSkypeProto::SvcCreateChat(WPARAM, LPARAM)
{
if (IsOnline()) {
CSkypeGCCreateDlg dlg(this);
-
- { mir_cslock lck(m_GCCreateDialogsLock); m_GCCreateDialogs.insert(&dlg); }
-
- if (!dlg.DoModal()) { return 1; }
-
- SendRequest(new CreateChatroomRequest(dlg.m_ContactsList, this));
-
- { mir_cslock lck(m_GCCreateDialogsLock); m_GCCreateDialogs.remove(&dlg); }
- return 0;
+ if (dlg.DoModal()) {
+ SendRequest(new CreateChatroomRequest(dlg.m_ContactsList, this));
+ return 0;
+ }
}
return 1;
}
diff --git a/protocols/SkypeWeb/src/skype_dialogs.cpp b/protocols/SkypeWeb/src/skype_dialogs.cpp
index d0f3ba18a9..d64e20c81f 100644
--- a/protocols/SkypeWeb/src/skype_dialogs.cpp
+++ b/protocols/SkypeWeb/src/skype_dialogs.cpp
@@ -19,43 +19,51 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
void CSkypeProto::CloseDialogs()
{
- { mir_cslock lck(m_GCCreateDialogsLock);
- for (auto &it : m_GCCreateDialogs)
- it->Close();
- }
+ for (auto &it : m_GCCreateDialogs)
+ it->Close();
- { mir_cslock lck(m_InviteDialogsLock);
- for (auto &it : m_InviteDialogs)
- it->Close();
- }
+ for (auto &it : m_InviteDialogs)
+ it->Close();
}
-//CSkypeInvideDlg
+/////////////////////////////////////////////////////////////////////////////////////////
+// CSkypeInvideDlg
+
CSkypeInviteDlg::CSkypeInviteDlg(CSkypeProto *proto) :
- CSkypeDlgBase(proto, IDD_GC_INVITE), m_ok(this, IDOK), m_cancel(this, IDCANCEL), m_combo(this, IDC_CONTACT), m_hContact(NULL)
+ CSkypeDlgBase(proto, IDD_GC_INVITE),
+ m_combo(this, IDC_CONTACT)
{
- m_ok.OnClick = Callback(this, &CSkypeInviteDlg::btnOk_OnOk);
}
bool CSkypeInviteDlg::OnInitDialog()
{
+ m_proto->m_InviteDialogs.insert(this);
+
for (auto &hContact : m_proto->AccContacts())
if (!m_proto->isChatRoom(hContact))
m_combo.AddString(Clist_GetContactDisplayName(hContact), hContact);
return true;
}
-void CSkypeInviteDlg::btnOk_OnOk(CCtrlButton*)
+bool CSkypeInviteDlg::OnApply()
{
m_hContact = m_combo.GetItemData(m_combo.GetCurSel());
- EndDialog(m_hwnd, 1);
+ return true;
+}
+
+void CSkypeInviteDlg::OnDestroy()
+{
+ m_proto->m_InviteDialogs.remove(this);
}
-//CSkypeGCCreateDlg
+/////////////////////////////////////////////////////////////////////////////////////////
+// CSkypeGCCreateDlg
+
CSkypeGCCreateDlg::CSkypeGCCreateDlg(CSkypeProto *proto) :
- CSkypeDlgBase(proto, IDD_GC_CREATE), m_ok(this, IDOK), m_cancel(this, IDCANCEL), m_clc(this, IDC_CLIST), m_ContactsList(1)
+ CSkypeDlgBase(proto, IDD_GC_CREATE),
+ m_clc(this, IDC_CLIST),
+ m_ContactsList(1)
{
- m_ok.OnClick = Callback(this, &CSkypeGCCreateDlg::btnOk_OnOk);
m_clc.OnListRebuilt = Callback(this, &CSkypeGCCreateDlg::FilterList);
}
@@ -67,6 +75,8 @@ CSkypeGCCreateDlg::~CSkypeGCCreateDlg()
bool CSkypeGCCreateDlg::OnInitDialog()
{
+ m_proto->m_GCCreateDialogs.insert(this);
+
SetWindowLongPtr(m_clc.GetHwnd(), GWL_STYLE,
GetWindowLongPtr(m_clc.GetHwnd(), GWL_STYLE) | CLS_CHECKBOXES | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE);
m_clc.SendMsg(CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP | CLS_EX_TRACKSELECT, 0);
@@ -75,7 +85,7 @@ bool CSkypeGCCreateDlg::OnInitDialog()
return true;
}
-void CSkypeGCCreateDlg::btnOk_OnOk(CCtrlButton*)
+bool CSkypeGCCreateDlg::OnApply()
{
for (auto &hContact : m_proto->AccContacts()) {
if (!m_proto->isChatRoom(hContact))
@@ -85,7 +95,12 @@ void CSkypeGCCreateDlg::btnOk_OnOk(CCtrlButton*)
}
m_ContactsList.insert(m_proto->m_szSkypename.GetBuffer());
- EndDialog(m_hwnd, m_ContactsList.getCount());
+ return true;
+}
+
+void CSkypeGCCreateDlg::OnDestroy()
+{
+ m_proto->m_GCCreateDialogs.remove(this);
}
void CSkypeGCCreateDlg::FilterList(CCtrlClc *)
diff --git a/protocols/SkypeWeb/src/skype_dialogs.h b/protocols/SkypeWeb/src/skype_dialogs.h
index 6c653d9fd5..942128d692 100644
--- a/protocols/SkypeWeb/src/skype_dialogs.h
+++ b/protocols/SkypeWeb/src/skype_dialogs.h
@@ -22,43 +22,34 @@ typedef CProtoDlgBase<CSkypeProto> CSkypeDlgBase;
class CSkypeInviteDlg : public CSkypeDlgBase
{
-private:
- typedef CSkypeDlgBase CSuper;
- CCtrlButton m_ok;
- CCtrlButton m_cancel;
- CCtrlCombo m_combo;
-
-protected:
- bool OnInitDialog() override;
-
- void btnOk_OnOk(CCtrlButton*);
+ CCtrlCombo m_combo;
public:
- MCONTACT m_hContact;
-
CSkypeInviteDlg(CSkypeProto *proto);
+
+ bool OnInitDialog() override;
+ bool OnApply() override;
+ void OnDestroy() override;
+
+ MCONTACT m_hContact = 0;
};
class CSkypeGCCreateDlg : public CSkypeDlgBase
{
-private:
- typedef CSkypeDlgBase CSuper;
- CCtrlButton m_ok;
- CCtrlButton m_cancel;
- CCtrlClc m_clc;
+ CCtrlClc m_clc;
+
+public:
+ CSkypeGCCreateDlg(CSkypeProto *proto);
+ ~CSkypeGCCreateDlg();
-protected:
bool OnInitDialog() override;
+ bool OnApply() override;
+ void OnDestroy() override;
- void btnOk_OnOk(CCtrlButton*);
void FilterList(CCtrlClc*);
void ResetListOptions(CCtrlClc*);
-public:
LIST<char> m_ContactsList;
-
- CSkypeGCCreateDlg(CSkypeProto *proto);
- ~CSkypeGCCreateDlg();
};
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index 5279bc6c4d..99392ad332 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -20,8 +20,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
struct CSkypeProto : public PROTO <CSkypeProto>
{
- friend CSkypeOptionsMain;
- friend CSkypeGCCreateDlg;
+ friend class CSkypeOptionsMain;
+ friend class CSkypeGCCreateDlg;
+ friend class CSkypeInviteDlg;
class CSkypeProtoImpl
{
@@ -158,8 +159,6 @@ private:
// locks
mir_cs m_lckOutMessagesList;
- mir_cs m_InviteDialogsLock;
- mir_cs m_GCCreateDialogsLock;
mir_cs messageSyncLock;
mir_cs m_StatusLock;
mir_cs m_AppendMessageLock;
diff --git a/protocols/Steam/src/steam_dialogs.cpp b/protocols/Steam/src/steam_dialogs.cpp
index 3e3fe3b912..690e04d1e6 100644
--- a/protocols/Steam/src/steam_dialogs.cpp
+++ b/protocols/Steam/src/steam_dialogs.cpp
@@ -110,16 +110,15 @@ bool CSteamTwoFactorDialog::OnClose()
/////////////////////////////////////////////////////////////////////////////////
-CSteamCaptchaDialog::CSteamCaptchaDialog(CSteamProto *proto, const uint8_t *captchaImage, size_t captchaImageSize)
- : CSteamDlgBase(proto, IDD_CAPTCHA),
- m_ok(this, IDOK), m_text(this, IDC_TEXT),
+CSteamCaptchaDialog::CSteamCaptchaDialog(CSteamProto *proto, const uint8_t *captchaImage, size_t captchaImageSize) :
+ CSteamDlgBase(proto, IDD_CAPTCHA),
+ m_text(this, IDC_TEXT),
m_captchaImage(nullptr)
{
memset(m_captchaText, 0, sizeof(m_captchaText));
m_captchaImageSize = captchaImageSize;
m_captchaImage = (uint8_t*)mir_alloc(captchaImageSize);
memcpy(m_captchaImage, captchaImage, captchaImageSize);
- m_ok.OnClick = Callback(this, &CSteamCaptchaDialog::OnOk);
}
CSteamCaptchaDialog::~CSteamCaptchaDialog()
@@ -140,16 +139,15 @@ bool CSteamCaptchaDialog::OnInitDialog()
return true;
}
-void CSteamCaptchaDialog::OnOk(CCtrlButton*)
+bool CSteamCaptchaDialog::OnApply()
{
mir_strncpy(m_captchaText, ptrA(m_text.GetTextA()), _countof(m_captchaText));
- EndModal(DIALOG_RESULT_OK);
+ return true;
}
-bool CSteamCaptchaDialog::OnClose()
+void CSteamCaptchaDialog::OnDestroy()
{
Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "CaptchaWindow");
- return true;
}
INT_PTR CSteamCaptchaDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
diff --git a/protocols/Steam/src/steam_dialogs.h b/protocols/Steam/src/steam_dialogs.h
index 190c2504c5..8389e0bfd3 100644
--- a/protocols/Steam/src/steam_dialogs.h
+++ b/protocols/Steam/src/steam_dialogs.h
@@ -75,15 +75,13 @@ class CSteamCaptchaDialog : public CSteamDlgBase
size_t m_captchaImageSize;
CCtrlEdit m_text;
- CCtrlButton m_ok;
protected:
bool OnInitDialog() override;
- bool OnClose() override;
+ bool OnApply() override;
+ void OnDestroy() override;
INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
- void OnOk(CCtrlButton*);
-
public:
CSteamCaptchaDialog(CSteamProto *proto, const uint8_t *captchaImage, size_t captchaImageSize);
~CSteamCaptchaDialog();
diff --git a/protocols/Tox/src/stdafx.h b/protocols/Tox/src/stdafx.h
index 9dbf24a568..8e7afcb0be 100644
--- a/protocols/Tox/src/stdafx.h
+++ b/protocols/Tox/src/stdafx.h
@@ -83,7 +83,6 @@ struct CToxProto;
#include "tox_menus.h"
#include "tox_address.h"
#include "tox_dialogs.h"
-#include "tox_profile.h"
#include "tox_options.h"
#include "tox_transfer.h"
#include "tox_proto.h"
diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp
index 3f7777e56a..781c279d7e 100644
--- a/protocols/Tox/src/tox_options.cpp
+++ b/protocols/Tox/src/tox_options.cpp
@@ -253,91 +253,102 @@ bool CToxOptionsMain::OnApply()
/////////////////////////////////////////////////////////////////////////////////
-CToxNodeEditor::CToxNodeEditor(int iItem, CCtrlListView *m_nodes)
- : CSuper(g_plugin, IDD_NODE_EDITOR),
- m_ipv4(this, IDC_IPV4), m_ipv6(this, IDC_IPV6),
- m_port(this, IDC_PORT), m_pkey(this, IDC_PKEY),
- m_ok(this, IDOK), m_iItem(iItem)
+class CToxNodeEditor : public CDlgBase
{
- m_autoClose = CLOSE_ON_CANCEL;
- m_list = m_nodes;
- m_ok.OnClick = Callback(this, &CToxNodeEditor::OnOk);
-}
+ typedef CDlgBase CSuper;
+
+ int m_iItem;
+ CCtrlListView *m_list;
+
+ CCtrlEdit m_ipv4;
+ CCtrlEdit m_ipv6;
+ CCtrlEdit m_port;
+ CCtrlEdit m_pkey;
+
+public:
+ CToxNodeEditor(int iItem, CCtrlListView *m_nodes) :
+ CSuper(g_plugin, IDD_NODE_EDITOR),
+ m_ipv4(this, IDC_IPV4), m_ipv6(this, IDC_IPV6),
+ m_port(this, IDC_PORT), m_pkey(this, IDC_PKEY),
+ m_iItem(iItem)
+ {
+ m_autoClose = CLOSE_ON_CANCEL;
+ m_list = m_nodes;
+ }
-bool CToxNodeEditor::OnInitDialog()
-{
- SetWindowText(m_hwnd, m_iItem == -1 ? TranslateT("Add node") : TranslateT("Change node"));
+ bool OnInitDialog() override
+ {
+ SetWindowText(m_hwnd, m_iItem == -1 ? TranslateT("Add node") : TranslateT("Change node"));
- if (m_iItem > -1) {
- LVITEM lvi = { 0 };
- lvi.mask = LVIF_TEXT;
- lvi.iItem = m_iItem;
- lvi.cchTextMax = MAX_PATH;
- lvi.pszText = (wchar_t*)alloca(MAX_PATH * sizeof(wchar_t));
+ if (m_iItem > -1) {
+ LVITEM lvi = { 0 };
+ lvi.mask = LVIF_TEXT;
+ lvi.iItem = m_iItem;
+ lvi.cchTextMax = MAX_PATH;
+ lvi.pszText = (wchar_t *)alloca(MAX_PATH * sizeof(wchar_t));
- lvi.iSubItem = 0;
- m_list->GetItem(&lvi);
- m_ipv4.SetText(lvi.pszText);
+ lvi.iSubItem = 0;
+ m_list->GetItem(&lvi);
+ m_ipv4.SetText(lvi.pszText);
- lvi.iSubItem = 1;
- m_list->GetItem(&lvi);
- m_ipv6.SetText(lvi.pszText);
+ lvi.iSubItem = 1;
+ m_list->GetItem(&lvi);
+ m_ipv6.SetText(lvi.pszText);
- lvi.iSubItem = 2;
- m_list->GetItem(&lvi);
- m_port.SetText(lvi.pszText);
+ lvi.iSubItem = 2;
+ m_list->GetItem(&lvi);
+ m_port.SetText(lvi.pszText);
- lvi.iSubItem = 3;
- m_list->GetItem(&lvi);
- m_pkey.SetText(lvi.pszText);
+ lvi.iSubItem = 3;
+ m_list->GetItem(&lvi);
+ m_pkey.SetText(lvi.pszText);
+ }
+
+ Utils_RestoreWindowPositionNoSize(m_hwnd, NULL, MODULE, "EditNodeDlg");
+ return true;
}
- Utils_RestoreWindowPositionNoSize(m_hwnd, NULL, MODULE, "EditNodeDlg");
- return true;
-}
+ bool OnApply() override
+ {
+ ptrW ipv4(m_ipv4.GetText());
+ if (!ipv4) {
+ MessageBox(m_hwnd, TranslateT("Enter IPv4"), TranslateT("Error"), MB_OK);
+ return false;
+ }
-void CToxNodeEditor::OnOk(CCtrlBase*)
-{
- ptrW ipv4(m_ipv4.GetText());
- if (!ipv4) {
- MessageBox(m_hwnd, TranslateT("Enter IPv4"), TranslateT("Error"), MB_OK);
- return;
- }
+ ptrW port(m_port.GetText());
+ if (!port) {
+ MessageBox(m_hwnd, TranslateT("Enter port"), TranslateT("Error"), MB_OK);
+ return false;
+ }
- ptrW port(m_port.GetText());
- if (!port) {
- MessageBox(m_hwnd, TranslateT("Enter port"), TranslateT("Error"), MB_OK);
- return;
- }
+ ptrW pubKey(m_pkey.GetText());
+ if (!pubKey) {
+ MessageBox(m_hwnd, TranslateT("Enter public key"), TranslateT("Error"), MB_OK);
+ return false;
+ }
- ptrW pubKey(m_pkey.GetText());
- if (!pubKey) {
- MessageBox(m_hwnd, TranslateT("Enter public key"), TranslateT("Error"), MB_OK);
- return;
+ if (m_iItem == -1) {
+ m_iItem = m_list->AddItem(ipv4, -1, NULL, 1);
+ m_list->SetItemState(m_iItem, LVIS_FOCUSED | LVIS_SELECTED, 0x000F);
+ m_list->EnsureVisible(m_iItem, TRUE);
+ }
+ else
+ m_list->SetItem(m_iItem, 0, ipv4);
+ m_list->SetItem(m_iItem, 2, port);
+ m_list->SetItem(m_iItem, 3, pubKey);
+ m_list->SetItem(m_iItem, 4, L"", 0);
+ m_list->SetItem(m_iItem, 5, L"", 1);
+
+ SendMessage(GetParent(GetParent(m_list->GetHwnd())), PSM_CHANGED, 0, 0);
+ return true;
}
- if (m_iItem == -1) {
- m_iItem = m_list->AddItem(ipv4, -1, NULL, 1);
- m_list->SetItemState(m_iItem, LVIS_FOCUSED | LVIS_SELECTED, 0x000F);
- m_list->EnsureVisible(m_iItem, TRUE);
+ void OnDestroy() override
+ {
+ Utils_SaveWindowPosition(m_hwnd, NULL, MODULE, "EditNodeDlg");
}
- else
- m_list->SetItem(m_iItem, 0, ipv4);
- m_list->SetItem(m_iItem, 2, port);
- m_list->SetItem(m_iItem, 3, pubKey);
- m_list->SetItem(m_iItem, 4, L"", 0);
- m_list->SetItem(m_iItem, 5, L"", 1);
-
- SendMessage(GetParent(GetParent(m_list->GetHwnd())), PSM_CHANGED, 0, 0);
-
- EndDialog(m_hwnd, 1);
-}
-
-bool CToxNodeEditor::OnClose()
-{
- Utils_SaveWindowPosition(m_hwnd, NULL, MODULE, "EditNodeDlg");
- return true;
-}
+};
/****************************************/
diff --git a/protocols/Tox/src/tox_options.h b/protocols/Tox/src/tox_options.h
index 374bfbb5af..fdc8ea7402 100644
--- a/protocols/Tox/src/tox_options.h
+++ b/protocols/Tox/src/tox_options.h
@@ -57,34 +57,6 @@ public:
static CDlgBase *CreateOptionsPage(void *param) { return new CToxOptionsMain((CToxProto*)param, IDD_OPTIONS_MAIN); }
};
-/////////////////////////////////////////////////////////////////////////////////
-
-class CToxNodeEditor : public CDlgBase
-{
-private:
- typedef CDlgBase CSuper;
-
- int m_iItem;
- CCtrlListView *m_list;
-
- CCtrlEdit m_ipv4;
- CCtrlEdit m_ipv6;
- CCtrlEdit m_port;
- CCtrlEdit m_pkey;
-
- CCtrlButton m_ok;
-
-protected:
- bool OnInitDialog() override;
- bool OnClose() override;
-
- void OnOk(CCtrlBase*);
-
-public:
- CToxNodeEditor(int iItem, CCtrlListView *m_list);
-};
-
-
/****************************************/
class CToxOptionsNodeList : public CToxDlgBase
diff --git a/protocols/Tox/src/tox_profile.cpp b/protocols/Tox/src/tox_profile.cpp
index 2b8ef857c5..d414f75a8d 100644
--- a/protocols/Tox/src/tox_profile.cpp
+++ b/protocols/Tox/src/tox_profile.cpp
@@ -16,6 +16,42 @@ wchar_t* CToxProto::GetToxProfilePath(const wchar_t *accountName)
return profilePath;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// ENTER PASSWORD
+
+class CToxEnterPasswordDlg : public CToxDlgBase
+{
+ CCtrlEdit m_password;
+
+ CCtrlButton m_ok;
+
+public:
+ CToxEnterPasswordDlg(CToxProto *proto) :
+ CToxDlgBase(proto, IDD_PASSWORD_ENTER),
+ m_password(this, IDC_PASSWORD),
+ m_ok(this, IDOK)
+ {
+ m_password.OnChange = Callback(this, &CToxEnterPasswordDlg::Password_OnChange);
+ }
+
+ bool OnInitDialog() override
+ {
+ m_ok.Disable();
+ return true;
+ }
+
+ bool OnApply() override
+ {
+ m_proto->setWString(TOX_SETTINGS_PASSWORD, pass_ptrW(m_password.GetText()));
+ return true;
+ }
+
+ void Password_OnChange(CCtrlBase *)
+ {
+ m_ok.Enable(GetWindowTextLength(m_password.GetHwnd()) != 0);
+ }
+};
+
static INT_PTR CALLBACK EnterPassword(void *param)
{
CToxProto *proto = (CToxProto*)param;
@@ -163,172 +199,167 @@ INT_PTR CToxProto::OnCopyToxID(WPARAM, LPARAM)
return 0;
}
-INT_PTR CToxProto::OnCreatePassword(WPARAM, LPARAM)
-{
- pass_ptrW password(getWStringA(TOX_SETTINGS_PASSWORD));
- CToxCreatePasswordDlg passwordDlg(this);
- passwordDlg.DoModal();
- return 0;
-}
+/////////////////////////////////////////////////////////////////////////////////////////
+// CREATE PASSWORD
-INT_PTR CToxProto::OnChangePassword(WPARAM, LPARAM)
+class CToxCreatePasswordDlg : public CToxDlgBase
{
- CToxChangePasswordDlg passwordDlg(this);
- passwordDlg.DoModal();
- return 0;
-}
+ CCtrlEdit m_newPassword;
+ CCtrlEdit m_confirmPassword;
+ CCtrlBase m_passwordValidation;
+ CCtrlButton m_ok;
+
+public:
+ CToxCreatePasswordDlg(CToxProto *proto) :
+ CToxDlgBase(proto, IDD_PASSWORD_CREATE),
+ m_ok(this, IDOK),
+ m_newPassword(this, IDC_PASSWORD_NEW),
+ m_confirmPassword(this, IDC_PASSWORD_CONFIRM),
+ m_passwordValidation(this, IDC_PASSWORD_VALIDATION)
+ {
+ m_newPassword.OnChange = Callback(this, &CToxCreatePasswordDlg::Password_OnChange);
+ m_confirmPassword.OnChange = Callback(this, &CToxCreatePasswordDlg::Password_OnChange);
+ }
-INT_PTR CToxProto::OnRemovePassword(WPARAM, LPARAM)
-{
- const wchar_t *message = TranslateT("Removing the password will lead to decryption of the profile.\r\nAre you sure to remove password?");
- int result = MessageBox(nullptr, message, TranslateT("Remove password"), MB_YESNO | MB_ICONQUESTION);
- if (result == IDYES) {
- delSetting(TOX_SETTINGS_PASSWORD);
- SaveToxProfile(m_tox);
+ bool OnInitDialog() override
+ {
+ LOGFONT lf;
+ HFONT hFont = (HFONT)m_passwordValidation.SendMsg(WM_GETFONT, 0, 0);
+ GetObject(hFont, sizeof(lf), &lf);
+ lf.lfWeight = FW_BOLD;
+ m_passwordValidation.SendMsg(WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), 0);
+
+ m_ok.Disable();
+ return true;
}
- return 0;
-}
-/* ENTER PASSWORD */
+ bool OnApply() override
+ {
+ m_proto->setWString(TOX_SETTINGS_PASSWORD, pass_ptrW(m_newPassword.GetText()));
+ m_proto->SaveToxProfile(m_proto->m_tox);
+ return true;
+ }
-CToxEnterPasswordDlg::CToxEnterPasswordDlg(CToxProto *proto)
- : CToxDlgBase(proto, IDD_PASSWORD_ENTER),
- m_password(this, IDC_PASSWORD),
- m_ok(this, IDOK)
-{
- m_password.OnChange = Callback(this, &CToxEnterPasswordDlg::Password_OnChange);
- m_ok.OnClick = Callback(this, &CToxEnterPasswordDlg::OnOk);
-}
+ void Password_OnChange(CCtrlBase *)
+ {
+ pass_ptrW newPassword(m_newPassword.GetText());
+ if (mir_wstrlen(newPassword) == 0) {
+ m_ok.Disable();
+ m_passwordValidation.SetText(TranslateT("New password is empty"));
+ return;
+ }
-bool CToxEnterPasswordDlg::OnInitDialog()
-{
- m_ok.Disable();
- return true;
-}
+ pass_ptrW confirmPassword(m_confirmPassword.GetText());
+ if (mir_wstrcmp(newPassword, confirmPassword) != 0) {
+ m_ok.Disable();
+ m_passwordValidation.SetText(TranslateT("New password is not equal to confirmation"));
+ return;
+ }
-void CToxEnterPasswordDlg::Password_OnChange(CCtrlBase*)
-{
- m_ok.Enable(GetWindowTextLength(m_password.GetHwnd()) != 0);
-}
+ m_passwordValidation.SetText(L"");
+ m_ok.Enable();
+ }
+};
-void CToxEnterPasswordDlg::OnOk(CCtrlButton*)
+INT_PTR CToxProto::OnCreatePassword(WPARAM, LPARAM)
{
- m_proto->setWString(TOX_SETTINGS_PASSWORD, pass_ptrW(m_password.GetText()));
- EndDialog(m_hwnd, 1);
+ pass_ptrW password(getWStringA(TOX_SETTINGS_PASSWORD));
+ CToxCreatePasswordDlg(this).DoModal();
+ return 0;
}
-/* CREATE PASSWORD */
+/////////////////////////////////////////////////////////////////////////////////////////
+// CHANGE PASSWORD
-CToxCreatePasswordDlg::CToxCreatePasswordDlg(CToxProto *proto)
- : CToxDlgBase(proto, IDD_PASSWORD_CREATE),
- m_newPassword(this, IDC_PASSWORD_NEW),
- m_confirmPassword(this, IDC_PASSWORD_CONFIRM),
- m_passwordValidation(this, IDC_PASSWORD_VALIDATION),
- m_ok(this, IDOK)
+class CToxChangePasswordDlg : public CToxDlgBase
{
- m_newPassword.OnChange = Callback(this, &CToxCreatePasswordDlg::Password_OnChange);
- m_confirmPassword.OnChange = Callback(this, &CToxCreatePasswordDlg::Password_OnChange);
- m_ok.OnClick = Callback(this, &CToxCreatePasswordDlg::OnOk);
-}
+ CCtrlEdit m_oldPassword;
+
+ CCtrlEdit m_newPassword;
+ CCtrlEdit m_confirmPassword;
+
+ CCtrlBase m_passwordValidation;
+
+ CCtrlButton m_ok;
+
+public:
+ CToxChangePasswordDlg(CToxProto *proto) :
+ CToxDlgBase(proto, IDD_PASSWORD_CHANGE),
+ m_oldPassword(this, IDC_PASSWORD),
+ m_newPassword(this, IDC_PASSWORD_NEW),
+ m_confirmPassword(this, IDC_PASSWORD_CONFIRM),
+ m_passwordValidation(this, IDC_PASSWORD_VALIDATION),
+ m_ok(this, IDOK)
+ {
+ m_oldPassword.OnChange = Callback(this, &CToxChangePasswordDlg::Password_OnChange);
+ m_newPassword.OnChange = Callback(this, &CToxChangePasswordDlg::Password_OnChange);
+ m_confirmPassword.OnChange = Callback(this, &CToxChangePasswordDlg::Password_OnChange);
+ }
-bool CToxCreatePasswordDlg::OnInitDialog()
-{
- LOGFONT lf;
- HFONT hFont = (HFONT)m_passwordValidation.SendMsg(WM_GETFONT, 0, 0);
- GetObject(hFont, sizeof(lf), &lf);
- lf.lfWeight = FW_BOLD;
- m_passwordValidation.SendMsg(WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), 0);
-
- m_ok.Disable();
- return true;
-}
+ bool OnInitDialog() override
+ {
+ LOGFONT lf;
+ HFONT hFont = (HFONT)m_passwordValidation.SendMsg(WM_GETFONT, 0, 0);
+ GetObject(hFont, sizeof(lf), &lf);
+ lf.lfWeight = FW_BOLD;
+ m_passwordValidation.SendMsg(WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), 0);
-void CToxCreatePasswordDlg::Password_OnChange(CCtrlBase*)
-{
- pass_ptrW newPassword(m_newPassword.GetText());
- if (mir_wstrlen(newPassword) == 0) {
m_ok.Disable();
- m_passwordValidation.SetText(TranslateT("New password is empty"));
- return;
+ return true;
}
- pass_ptrW confirmPassword(m_confirmPassword.GetText());
- if (mir_wstrcmp(newPassword, confirmPassword) != 0) {
- m_ok.Disable();
- m_passwordValidation.SetText(TranslateT("New password is not equal to confirmation"));
- return;
+ bool OnApply() override
+ {
+ m_proto->setWString(TOX_SETTINGS_PASSWORD, pass_ptrW(m_newPassword.GetText()));
+ m_proto->SaveToxProfile(m_proto->m_tox);
+ return true;
}
- m_passwordValidation.SetText(L"");
- m_ok.Enable();
-}
+ void Password_OnChange(CCtrlBase *)
+ {
+ pass_ptrW dbPassword(m_proto->getWStringA(TOX_SETTINGS_PASSWORD));
+ pass_ptrW oldPassword(m_oldPassword.GetText());
+ if (mir_wstrlen(dbPassword) > 0 && mir_wstrcmp(dbPassword, oldPassword) != 0) {
+ m_ok.Disable();
+ m_passwordValidation.SetText(TranslateT("Old password is not valid"));
+ return;
+ }
-void CToxCreatePasswordDlg::OnOk(CCtrlButton*)
-{
- m_proto->setWString(TOX_SETTINGS_PASSWORD, pass_ptrW(m_newPassword.GetText()));
- m_proto->SaveToxProfile(m_proto->m_tox);
- EndDialog(m_hwnd, 1);
-}
+ pass_ptrW newPassword(m_newPassword.GetText());
+ if (mir_wstrlen(newPassword) == 0) {
+ m_ok.Disable();
+ m_passwordValidation.SetText(TranslateT("New password is empty"));
+ return;
+ }
-/* CHANGE PASSWORD */
+ pass_ptrW confirmPassword(m_confirmPassword.GetText());
+ if (mir_wstrcmp(newPassword, confirmPassword) != 0) {
+ m_ok.Disable();
+ m_passwordValidation.SetText(TranslateT("New password is not equal to confirmation"));
+ return;
+ }
-CToxChangePasswordDlg::CToxChangePasswordDlg(CToxProto *proto)
- : CToxDlgBase(proto, IDD_PASSWORD_CHANGE),
- m_oldPassword(this, IDC_PASSWORD),
- m_newPassword(this, IDC_PASSWORD_NEW),
- m_confirmPassword(this, IDC_PASSWORD_CONFIRM),
- m_passwordValidation(this, IDC_PASSWORD_VALIDATION),
- m_ok(this, IDOK)
-{
- m_oldPassword.OnChange = Callback(this, &CToxChangePasswordDlg::Password_OnChange);
- m_newPassword.OnChange = Callback(this, &CToxChangePasswordDlg::Password_OnChange);
- m_confirmPassword.OnChange = Callback(this, &CToxChangePasswordDlg::Password_OnChange);
- m_ok.OnClick = Callback(this, &CToxChangePasswordDlg::OnOk);
-}
+ m_passwordValidation.SetText(L"");
+ m_ok.Enable();
+ }
+};
-bool CToxChangePasswordDlg::OnInitDialog()
+INT_PTR CToxProto::OnChangePassword(WPARAM, LPARAM)
{
- LOGFONT lf;
- HFONT hFont = (HFONT)m_passwordValidation.SendMsg(WM_GETFONT, 0, 0);
- GetObject(hFont, sizeof(lf), &lf);
- lf.lfWeight = FW_BOLD;
- m_passwordValidation.SendMsg(WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), 0);
-
- m_ok.Disable();
- return true;
+ CToxChangePasswordDlg passwordDlg(this);
+ passwordDlg.DoModal();
+ return 0;
}
-void CToxChangePasswordDlg::Password_OnChange(CCtrlBase*)
-{
- pass_ptrW dbPassword(m_proto->getWStringA(TOX_SETTINGS_PASSWORD));
- pass_ptrW oldPassword(m_oldPassword.GetText());
- if (mir_wstrlen(dbPassword) > 0 && mir_wstrcmp(dbPassword, oldPassword) != 0) {
- m_ok.Disable();
- m_passwordValidation.SetText(TranslateT("Old password is not valid"));
- return;
- }
+/////////////////////////////////////////////////////////////////////////////////////////
- pass_ptrW newPassword(m_newPassword.GetText());
- if (mir_wstrlen(newPassword) == 0) {
- m_ok.Disable();
- m_passwordValidation.SetText(TranslateT("New password is empty"));
- return;
- }
-
- pass_ptrW confirmPassword(m_confirmPassword.GetText());
- if (mir_wstrcmp(newPassword, confirmPassword) != 0) {
- m_ok.Disable();
- m_passwordValidation.SetText(TranslateT("New password is not equal to confirmation"));
- return;
- }
-
- m_passwordValidation.SetText(L"");
- m_ok.Enable();
-}
-
-void CToxChangePasswordDlg::OnOk(CCtrlButton*)
+INT_PTR CToxProto::OnRemovePassword(WPARAM, LPARAM)
{
- m_proto->setWString(TOX_SETTINGS_PASSWORD, pass_ptrW(m_newPassword.GetText()));
- m_proto->SaveToxProfile(m_proto->m_tox);
- EndDialog(m_hwnd, 1);
+ const wchar_t *message = TranslateT("Removing the password will lead to decryption of the profile.\r\nAre you sure to remove password?");
+ int result = MessageBox(nullptr, message, TranslateT("Remove password"), MB_YESNO | MB_ICONQUESTION);
+ if (result == IDYES) {
+ delSetting(TOX_SETTINGS_PASSWORD);
+ SaveToxProfile(m_tox);
+ }
+ return 0;
}
diff --git a/protocols/Tox/src/tox_profile.h b/protocols/Tox/src/tox_profile.h
deleted file mode 100644
index fd23665c90..0000000000
--- a/protocols/Tox/src/tox_profile.h
+++ /dev/null
@@ -1,69 +0,0 @@
-#ifndef _TOX_PROFILE_H_
-#define _TOX_PROFILE_H_
-
-/* ENTER PASSWORD */
-
-class CToxEnterPasswordDlg : public CToxDlgBase
-{
-private:
- CCtrlEdit m_password;
-
- CCtrlButton m_ok;
-
-protected:
- bool OnInitDialog() override;
-
- void Password_OnChange(CCtrlBase*);
- void OnOk(CCtrlButton*);
-
-public:
- CToxEnterPasswordDlg(CToxProto *proto);
-};
-
-/* CREATE PASSWORD */
-
-class CToxCreatePasswordDlg : public CToxDlgBase
-{
-private:
- CCtrlEdit m_newPassword;
- CCtrlEdit m_confirmPassword;
-
- CCtrlBase m_passwordValidation;
-
- CCtrlButton m_ok;
-
-protected:
- bool OnInitDialog() override;
-
- void Password_OnChange(CCtrlBase*);
- void OnOk(CCtrlButton*);
-
-public:
- CToxCreatePasswordDlg(CToxProto *proto);
-};
-
-/* CHANGE PASSWORD */
-
-class CToxChangePasswordDlg : public CToxDlgBase
-{
-private:
- CCtrlEdit m_oldPassword;
-
- CCtrlEdit m_newPassword;
- CCtrlEdit m_confirmPassword;
-
- CCtrlBase m_passwordValidation;
-
- CCtrlButton m_ok;
-
-protected:
- bool OnInitDialog() override;
-
- void Password_OnChange(CCtrlBase*);
- void OnOk(CCtrlButton*);
-
-public:
- CToxChangePasswordDlg(CToxProto *proto);
-};
-
-#endif //_TOX_PROFILE_H_ \ No newline at end of file
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h
index f78985f42b..681df6dcab 100644
--- a/protocols/Tox/src/tox_proto.h
+++ b/protocols/Tox/src/tox_proto.h
@@ -3,11 +3,11 @@
struct CToxProto : public PROTO<CToxProto>
{
- friend CToxEnterPasswordDlg;
- friend CToxCreatePasswordDlg;
- friend CToxChangePasswordDlg;
- friend CToxOptionsMain;
- friend CToxOptionsNodeList;
+ friend class CToxEnterPasswordDlg;
+ friend class CToxCreatePasswordDlg;
+ friend class CToxChangePasswordDlg;
+ friend class CToxOptionsMain;
+ friend class CToxOptionsNodeList;
public:
//////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/VKontakte/src/vk_dialogs.cpp b/protocols/VKontakte/src/vk_dialogs.cpp
index bfd4dab273..9bdead7c7f 100644
--- a/protocols/VKontakte/src/vk_dialogs.cpp
+++ b/protocols/VKontakte/src/vk_dialogs.cpp
@@ -28,7 +28,6 @@ CVkCaptchaForm::CVkCaptchaForm(CVkProto *proto, CAPTCHA_FORM_PARAMS *param) :
m_param(param)
{
m_btnOpenInBrowser.OnClick = Callback(this, &CVkCaptchaForm::On_btnOpenInBrowser_Click);
- m_btnOk.OnClick = Callback(this, &CVkCaptchaForm::On_btnOk_Click);
m_edtValue.OnChange = Callback(this, &CVkCaptchaForm::On_edtValue_Change);
}
@@ -42,6 +41,12 @@ bool CVkCaptchaForm::OnInitDialog()
return true;
}
+bool CVkCaptchaForm::OnApply()
+{
+ m_edtValue.GetTextA(m_param->Result, _countof(m_param->Result));
+ return true;
+}
+
INT_PTR CVkCaptchaForm::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
@@ -90,12 +95,6 @@ void CVkCaptchaForm::On_btnOpenInBrowser_Click(CCtrlButton*)
m_proto->ShowCaptchaInBrowser(m_param->bmp);
}
-void CVkCaptchaForm::On_btnOk_Click(CCtrlButton*)
-{
- m_edtValue.GetTextA(m_param->Result, _countof(m_param->Result));
- EndDialog(m_hwnd, 1);
-}
-
void CVkCaptchaForm::On_edtValue_Change(CCtrlEdit*)
{
m_btnOk.Enable(!IsEmpty(ptrA(m_edtValue.GetTextA())));
@@ -111,7 +110,6 @@ CVkWallPostForm::CVkWallPostForm(CVkProto *proto, WALLPOST_FORM_PARAMS *param) :
m_btnShare(this, IDOK),
m_param(param)
{
- m_btnShare.OnClick = Callback(this, &CVkWallPostForm::On_btnShare_Click);
m_edtMsg.OnChange = Callback(this, &CVkWallPostForm::On_edtValue_Change);
m_edtUrl.OnChange = Callback(this, &CVkWallPostForm::On_edtValue_Change);
}
@@ -127,18 +125,17 @@ bool CVkWallPostForm::OnInitDialog()
return true;
}
-void CVkWallPostForm::OnDestroy()
-{
- Window_FreeIcon_IcoLib(m_hwnd);
-}
-
-void CVkWallPostForm::On_btnShare_Click(CCtrlButton*)
+bool CVkWallPostForm::OnApply()
{
m_param->pwszUrl = m_edtUrl.GetText();
m_param->pwszMsg = m_edtMsg.GetText();
m_param->bFriendsOnly = m_cbOnlyForFriends.GetState() != 0;
+ return true;
+}
- EndDialog(m_hwnd, 1);
+void CVkWallPostForm::OnDestroy()
+{
+ Window_FreeIcon_IcoLib(m_hwnd);
}
void CVkWallPostForm::On_edtValue_Change(CCtrlEdit*)
@@ -150,11 +147,9 @@ void CVkWallPostForm::On_edtValue_Change(CCtrlEdit*)
CVkInviteChatForm::CVkInviteChatForm(CVkProto *proto) :
CVkDlgBase(proto, IDD_INVITE),
- m_btnOk(this, IDOK),
m_cbxCombo(this, IDC_CONTACT),
m_hContact(0)
{
- m_btnOk.OnClick = Callback(this, &CVkInviteChatForm::btnOk_OnOk);
}
bool CVkInviteChatForm::OnInitDialog()
@@ -165,21 +160,19 @@ bool CVkInviteChatForm::OnInitDialog()
return true;
}
-void CVkInviteChatForm::btnOk_OnOk(CCtrlButton*)
+bool CVkInviteChatForm::OnApply()
{
m_hContact = m_cbxCombo.GetItemData(m_cbxCombo.GetCurSel());
- EndDialog(m_hwnd, 1);
+ return true;
}
////////////////////////////////// IDD_GC_CREATE //////////////////////////////////////////
CVkGCCreateForm::CVkGCCreateForm(CVkProto *proto) :
CVkDlgBase(proto, IDD_GC_CREATE),
- m_btnOk(this, IDOK),
m_clc(this, IDC_CLIST),
m_edtTitle(this, IDC_TITLE)
{
- m_btnOk.OnClick = Callback(this, &CVkGCCreateForm::btnOk_OnOk);
m_clc.OnListRebuilt = Callback(this, &CVkGCCreateForm::FilterList);
}
@@ -193,7 +186,7 @@ bool CVkGCCreateForm::OnInitDialog()
return true;
}
-void CVkGCCreateForm::btnOk_OnOk(CCtrlButton*)
+bool CVkGCCreateForm::OnApply()
{
CMStringA szUIds;
for (auto &hContact : m_proto->AccContacts()) {
@@ -214,8 +207,7 @@ void CVkGCCreateForm::btnOk_OnOk(CCtrlButton*)
bool bRes = !szUIds.IsEmpty();
if (bRes)
m_proto->CreateNewChat(szUIds, ptrW(m_edtTitle.GetText()));
-
- EndDialog(m_hwnd, bRes);
+ return true;
}
void CVkGCCreateForm::FilterList(CCtrlClc*)
@@ -239,13 +231,11 @@ void CVkGCCreateForm::ResetListOptions()
CVkContactDeleteForm::CVkContactDeleteForm(CVkProto *proto, CONTACTDELETE_FORM_PARAMS *param) :
CVkDlgBase(proto, IDD_CONTACTDELETE),
- m_btnOk(this, IDOK),
m_stText(this, IDC_STATIC_TXT),
m_cbDeleteFromFriendlist(this, IDC_CH_REMOVE_FROM_FRIEND),
m_cbDeleteDialog(this, IDC_CH_CLEARHISTORY),
m_param(param)
{
- m_btnOk.OnClick = Callback(this, &CVkContactDeleteForm::btnOk_OnOk);
}
bool CVkContactDeleteForm::OnInitDialog()
@@ -269,12 +259,9 @@ bool CVkContactDeleteForm::OnInitDialog()
return true;
}
-void CVkContactDeleteForm::btnOk_OnOk(CCtrlButton*)
+bool CVkContactDeleteForm::OnApply()
{
-
m_param->bDeleteDialog = m_cbDeleteDialog.GetState() != 0;
- m_param->bDeleteFromFriendlist = m_param->bEnableDeleteFromFriendlist
- && (m_cbDeleteFromFriendlist.GetState() != 0);
-
- EndDialog(m_hwnd, 1);
-} \ No newline at end of file
+ m_param->bDeleteFromFriendlist = m_param->bEnableDeleteFromFriendlist && (m_cbDeleteFromFriendlist.GetState() != 0);
+ return true;
+}
diff --git a/protocols/VKontakte/src/vk_dialogs.h b/protocols/VKontakte/src/vk_dialogs.h
index 903e26679a..bf62571015 100644
--- a/protocols/VKontakte/src/vk_dialogs.h
+++ b/protocols/VKontakte/src/vk_dialogs.h
@@ -41,12 +41,12 @@ public:
CVkCaptchaForm(CVkProto *proto, CAPTCHA_FORM_PARAMS *param);
bool OnInitDialog() override;
+ bool OnApply() override;
void OnDestroy() override;
INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
void On_btnOpenInBrowser_Click(CCtrlButton*);
- void On_btnOk_Click(CCtrlButton*);
void On_edtValue_Change(CCtrlEdit*);
};
@@ -88,9 +88,9 @@ public:
CVkWallPostForm(CVkProto *proto, WALLPOST_FORM_PARAMS *param);
bool OnInitDialog() override;
- void OnDestroy();
+ bool OnApply() override;
+ void OnDestroy() override;
- void On_btnShare_Click(CCtrlButton*);
void On_edtValue_Change(CCtrlEdit*);
};
@@ -98,7 +98,6 @@ public:
class CVkInviteChatForm : public CVkDlgBase
{
- CCtrlButton m_btnOk;
CCtrlCombo m_cbxCombo;
public:
@@ -107,23 +106,21 @@ public:
CVkInviteChatForm(CVkProto *proto);
bool OnInitDialog() override;
-
- void btnOk_OnOk(CCtrlButton*);
+ bool OnApply() override;
};
////////////////////////////////// IDD_GC_CREATE //////////////////////////////////////////
class CVkGCCreateForm : public CVkDlgBase
{
- CCtrlButton m_btnOk;
CCtrlClc m_clc;
CCtrlEdit m_edtTitle;
public:
CVkGCCreateForm(CVkProto *proto);
bool OnInitDialog() override;
-
- void btnOk_OnOk(CCtrlButton*);
+ bool OnApply() override;
+
void FilterList(CCtrlClc*);
void ResetListOptions();
};
@@ -152,13 +149,11 @@ class CVkContactDeleteForm : public CVkDlgBase
CCtrlBase m_stText;
CCtrlCheck m_cbDeleteFromFriendlist;
CCtrlCheck m_cbDeleteDialog;
- CCtrlButton m_btnOk;
CONTACTDELETE_FORM_PARAMS *m_param;
public:
CVkContactDeleteForm(CVkProto *proto, CONTACTDELETE_FORM_PARAMS *param);
bool OnInitDialog() override;
-
- void btnOk_OnOk(CCtrlButton*);
-}; \ No newline at end of file
+ bool OnApply() override;
+};
diff --git a/protocols/VKontakte/src/vk_struct.cpp b/protocols/VKontakte/src/vk_struct.cpp
index 90f3e7cba5..efec941c19 100644
--- a/protocols/VKontakte/src/vk_struct.cpp
+++ b/protocols/VKontakte/src/vk_struct.cpp
@@ -353,7 +353,7 @@ void CVkUserItem::LoadFromGroup(const JSONNode & jnNode)
Set(m_wszDomain, jnNode["screen_name"].as_mstring());
}
-MCONTACT CVkUserItem::WriteToDB(bool bForce, VKContactType vkContactType)
+MCONTACT CVkUserItem::WriteToDB(bool bForce, VKContactType /*vkContactType*/)
{
if (!bForce && !m_bIsUpdated)
return m_hContact;
diff --git a/src/mir_app/src/addcontact.cpp b/src/mir_app/src/addcontact.cpp
index aa76957656..f9128bdcb6 100644
--- a/src/mir_app/src/addcontact.cpp
+++ b/src/mir_app/src/addcontact.cpp
@@ -39,7 +39,6 @@ class CAddContactDlg : public CDlgBase
{
CCtrlEdit m_authReq, m_myHandle;
CCtrlCheck m_chkAuth, m_chkOpen;
- CCtrlButton m_btnOk;
CCtrlCombo m_group;
protected:
@@ -54,14 +53,12 @@ public:
CDlgBase(g_plugin, IDD_ADDCONTACT),
m_chkAuth(this, IDC_AUTH),
m_chkOpen(this, IDC_OPEN_WINDOW),
- m_btnOk(this, IDOK),
m_group(this, IDC_GROUP),
m_authReq(this, IDC_AUTHREQ),
m_myHandle(this, IDC_MYHANDLE)
{
m_chkAuth.OnChange = Callback(this, &CAddContactDlg::OnAuthClicked);
m_chkOpen.OnChange = Callback(this, &CAddContactDlg::OnOpenClicked);
- m_btnOk.OnClick = Callback(this, &CAddContactDlg::OnOk);
}
bool OnInitDialog() override
@@ -105,27 +102,7 @@ public:
return true;
}
- void OnDestroy()
- {
- Window_FreeIcon_IcoLib(m_hwnd);
- }
-
- void OnAuthClicked(CCtrlButton*)
- {
- DWORD flags = CallProtoServiceInt(0, m_szProto, PS_GETCAPS, PFLAGNUM_4, 0);
- if (flags & PF4_NOCUSTOMAUTH)
- m_authReq.Enable(false);
- else
- m_authReq.Enable(m_chkAuth.Enabled());
- }
-
- void OnOpenClicked(CCtrlButton*)
- {
- // Remember this choice
- db_set_b(0, "Miranda", "AuthOpenWindow", m_chkOpen.Enabled());
- }
-
- void OnOk(CCtrlButton*)
+ bool OnApply() override
{
MCONTACT hContact = 0;
if (m_hDbEvent)
@@ -136,7 +113,7 @@ public:
hContact = m_hContact;
if (hContact == 0) // something went wrong
- return;
+ return false;
ptrW szHandle(m_myHandle.GetText());
if (mir_wstrlen(szHandle))
@@ -158,6 +135,27 @@ public:
if (m_chkOpen.GetState())
Clist_ContactDoubleClicked(hContact);
+ return true;
+ }
+
+ void OnDestroy()
+ {
+ Window_FreeIcon_IcoLib(m_hwnd);
+ }
+
+ void OnAuthClicked(CCtrlButton*)
+ {
+ DWORD flags = CallProtoServiceInt(0, m_szProto, PS_GETCAPS, PFLAGNUM_4, 0);
+ if (flags & PF4_NOCUSTOMAUTH)
+ m_authReq.Enable(false);
+ else
+ m_authReq.Enable(m_chkAuth.Enabled());
+ }
+
+ void OnOpenClicked(CCtrlButton*)
+ {
+ // Remember this choice
+ db_set_b(0, "Miranda", "AuthOpenWindow", m_chkOpen.Enabled());
}
};
diff --git a/src/mir_app/src/auth.cpp b/src/mir_app/src/auth.cpp
index ce3daa9cbc..10b11f783a 100644
--- a/src/mir_app/src/auth.cpp
+++ b/src/mir_app/src/auth.cpp
@@ -34,20 +34,16 @@ class CAuthReqDlg : public CDlgBase
const char *m_szProto;
CCtrlCheck chkAdd;
- CCtrlButton btnDetails, btnLater, btnOk, btnCancel;
+ CCtrlButton btnDetails, btnLater;
public:
CAuthReqDlg(MEVENT hEvent) :
CDlgBase(g_plugin, IDD_AUTHREQ),
m_hDbEvent(hEvent),
- btnOk(this, IDOK),
- btnCancel(this, IDCANCEL),
btnLater(this, IDC_DECIDELATER),
btnDetails(this, IDC_DETAILS),
chkAdd(this, IDC_ADDCHECK)
{
- btnOk.OnClick = Callback(this, &CAuthReqDlg::onClick_OK);
- btnCancel.OnClick = Callback(this, &CAuthReqDlg::onClick_Cancel);
btnLater.OnClick = Callback(this, &CAuthReqDlg::onClick_Later);
btnDetails.OnClick = Callback(this, &CAuthReqDlg::onClick_Details);
}
@@ -134,30 +130,30 @@ public:
return true;
}
- void OnDestroy() override
- {
- Button_FreeIcon_IcoLib(m_hwnd, IDC_ADD);
- Button_FreeIcon_IcoLib(m_hwnd, IDC_DETAILS);
- DestroyIcon((HICON)SendMessage(m_hwnd, WM_SETICON, ICON_BIG, 0));
- DestroyIcon((HICON)SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, 0));
- }
-
- void onClick_OK(CCtrlButton*)
+ bool OnApply() override
{
CallProtoService(m_szProto, PS_AUTHALLOW, m_hDbEvent, 0);
if (chkAdd.GetState())
Contact_AddByEvent(m_hDbEvent, m_hwnd);
+ return true;
}
- void onClick_Cancel(CCtrlButton*)
+ void OnDestroy() override
{
- if (IsWindowEnabled(GetDlgItem(m_hwnd, IDC_DENYREASON))) {
- wchar_t tszReason[256];
- GetDlgItemText(m_hwnd, IDC_DENYREASON, tszReason, _countof(tszReason));
- CallProtoService(m_szProto, PS_AUTHDENY, m_hDbEvent, (LPARAM)tszReason);
+ if (!m_bSucceeded) {
+ if (IsWindowEnabled(GetDlgItem(m_hwnd, IDC_DENYREASON))) {
+ wchar_t tszReason[256];
+ GetDlgItemText(m_hwnd, IDC_DENYREASON, tszReason, _countof(tszReason));
+ CallProtoService(m_szProto, PS_AUTHDENY, m_hDbEvent, (LPARAM)tszReason);
+ }
+ else CallProtoService(m_szProto, PS_AUTHDENY, m_hDbEvent, 0);
}
- else CallProtoService(m_szProto, PS_AUTHDENY, m_hDbEvent, 0);
+
+ Button_FreeIcon_IcoLib(m_hwnd, IDC_ADD);
+ Button_FreeIcon_IcoLib(m_hwnd, IDC_DETAILS);
+ DestroyIcon((HICON)SendMessage(m_hwnd, WM_SETICON, ICON_BIG, 0));
+ DestroyIcon((HICON)SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, 0));
}
void onClick_Later(CCtrlButton*)
@@ -184,17 +180,15 @@ class CAddedDlg : public CDlgBase
MEVENT m_hDbEvent;
MCONTACT m_hContact;
- CCtrlButton btnDetails, btnAdd, btnOk;
+ CCtrlButton btnDetails, btnAdd;
public:
CAddedDlg(MEVENT hEvent) :
CDlgBase(g_plugin, IDD_ADDED),
m_hDbEvent(hEvent),
- btnOk(this, IDOK),
btnAdd(this, IDC_ADD),
btnDetails(this, IDC_DETAILS)
{
- btnOk.OnClick = Callback(this, &CAddedDlg::onClick_OK);
btnAdd.OnClick = Callback(this, &CAddedDlg::onClick_Add);
btnDetails.OnClick = Callback(this, &CAddedDlg::onClick_Details);
}
@@ -258,7 +252,13 @@ public:
ShowWindow(GetDlgItem(m_hwnd, IDC_ADD), FALSE);
return true;
}
-
+
+ bool OnApply()
+ {
+ Contact_AddByEvent(m_hDbEvent, m_hwnd);
+ return true;
+ }
+
void OnDestroy() override
{
Button_FreeIcon_IcoLib(m_hwnd, IDC_ADD);
@@ -267,11 +267,6 @@ public:
DestroyIcon((HICON)SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, 0));
}
- void onClick_OK(CCtrlButton*)
- {
- Contact_AddByEvent(m_hDbEvent, m_hwnd);
- }
-
void onClick_Add(CCtrlButton*)
{
Contact_AddByEvent(m_hDbEvent, m_hwnd);
diff --git a/src/mir_app/src/db_ini.cpp b/src/mir_app/src/db_ini.cpp
index f558f1fb83..f2702e1928 100644
--- a/src/mir_app/src/db_ini.cpp
+++ b/src/mir_app/src/db_ini.cpp
@@ -123,7 +123,6 @@ class CWarnIniChangeDlg : public CDlgBase
CCtrlButton m_yes;
CCtrlButton m_no;
- CCtrlButton m_cancel;
CCtrlCheck m_noWarn;
@@ -153,23 +152,23 @@ protected:
return true;
}
- void YesNo_OnClick(CCtrlBase*)
+ bool OnClose() override
{
+ m_warnInfo->cancel = !m_bSucceeded;
m_warnInfo->warnNoMore = m_noWarn.GetState();
- Close();
+ return true;
}
- void Cancel_OnClick(CCtrlBase*)
+ void YesNo_OnClick(CCtrlBase*)
{
- m_warnInfo->cancel = 1;
- m_warnInfo->warnNoMore = m_noWarn.GetState();
+ Close();
}
public:
CWarnIniChangeDlg(warnSettingChangeInfo_t *warnInfo) :
CDlgBase(g_plugin, IDD_WARNINICHANGE),
m_yes(this, IDYES), m_no(this, IDNO),
- m_cancel(this, IDCANCEL), m_noWarn(this, IDC_WARNNOMORE),
+ m_noWarn(this, IDC_WARNNOMORE),
m_iniName(this, IDC_ININAME), m_settingName(this, IDC_SETTINGNAME),
m_newValue(this, IDC_NEWVALUE), m_securityInfo(this, IDC_SECURITYINFO)
{
@@ -177,7 +176,6 @@ public:
m_yes.OnClick = Callback(this, &CWarnIniChangeDlg::YesNo_OnClick);
m_no.OnClick = Callback(this, &CWarnIniChangeDlg::YesNo_OnClick);
- m_cancel.OnClick = Callback(this, &CWarnIniChangeDlg::Cancel_OnClick);
}
};
diff --git a/src/mir_app/src/menu_options.cpp b/src/mir_app/src/menu_options.cpp
index 61ea371933..fa8330a13e 100644
--- a/src/mir_app/src/menu_options.cpp
+++ b/src/mir_app/src/menu_options.cpp
@@ -485,9 +485,9 @@ public:
void onMenuObjectChanged(void*)
{
- m_initialized = false;
+ m_bInitialized = false;
RebuildCurrent();
- m_initialized = true;
+ m_bInitialized = true;
}
void onMenuItemChanged(void*)
diff --git a/src/mir_app/src/profilemanager.cpp b/src/mir_app/src/profilemanager.cpp
index 6491bc4578..93c4130c8a 100644
--- a/src/mir_app/src/profilemanager.cpp
+++ b/src/mir_app/src/profilemanager.cpp
@@ -588,7 +588,6 @@ public:
m_servicePlugs(this, IDC_SM_COMBO),
m_chkSmEnabled(this, IDC_SM_ENABLED)
{
- m_btnOk.OnClick = Callback(this, &CProfileManager::onOk);
m_chkSmEnabled.OnChange = Callback(this, &CProfileManager::onChanged);
m_tab.AddPage(LPGENW("My profiles"), nullptr, new CChooseProfileDlg(m_btnOk, m_pd));
@@ -637,11 +636,6 @@ public:
DestroyIcon((HICON)SendMessage(m_hwnd, WM_SETICON, ICON_BIG, 0));
}
- void onOk(CCtrlButton*)
- {
- EndDialog(m_hwnd, 1);
- }
-
void onChanged(CCtrlCheck*)
{
m_servicePlugs.Enable(m_chkSmEnabled.GetState());
diff --git a/src/mir_core/src/CDlgBase.cpp b/src/mir_core/src/CDlgBase.cpp
index 4ac2d5751d..f89f68139c 100644
--- a/src/mir_core/src/CDlgBase.cpp
+++ b/src/mir_core/src/CDlgBase.cpp
@@ -56,7 +56,7 @@ CDlgBase::CDlgBase(CMPluginBase &pPlug, int idDialog)
CDlgBase::~CDlgBase()
{
- m_initialized = false; // prevent double call of destructor
+ m_bInitialized = false; // prevent double call of destructor
if (m_hwnd)
DestroyWindow(m_hwnd);
}
@@ -117,7 +117,7 @@ void CDlgBase::EndModal(INT_PTR nResult)
void CDlgBase::NotifyChange(void)
{
- if (!m_initialized)
+ if (!m_bInitialized)
return;
OnChange();
@@ -202,7 +202,7 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_INITDIALOG:
- m_initialized = false;
+ m_bInitialized = false;
TranslateDialog_LP(m_hwnd, &m_pPlugin);
::EnumChildWindows(m_hwnd, &GlobalFieldEnum, LPARAM(this));
@@ -211,7 +211,7 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
if (!OnInitDialog())
return FALSE;
- m_initialized = true;
+ m_bInitialized = true;
return TRUE;
case WM_CTLCOLOREDIT:
@@ -285,10 +285,11 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
m_bExiting = true;
// everything ok? good, let's close it
- if (OnApply())
+ if (OnApply()) {
+ m_bSucceeded = true;
PostMessage(m_hwnd, WM_CLOSE, 0, 0);
- else
- m_bExiting = false;
+ }
+ else m_bExiting = false;
}
}
}
@@ -328,7 +329,7 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
return FALSE;
case PSM_CHANGED:
- if (m_initialized)
+ if (m_bInitialized)
OnChange();
break;
@@ -351,7 +352,7 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
if (OnClose()) {
m_bExiting = true;
if (m_isModal)
- EndModal(0);
+ EndModal(m_bSucceeded ? IDOK : IDCANCEL);
else
DestroyWindow(m_hwnd);
}
@@ -368,7 +369,7 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
arDialogs.remove(idx);
}
m_hwnd = nullptr;
- if (m_initialized) {
+ if (m_bInitialized) {
if (m_isModal)
m_isModal = false;
else // modeless dialogs MUST be allocated with 'new'