diff options
author | Robert Pösel <robyer@seznam.cz> | 2013-10-29 22:15:21 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2013-10-29 22:15:21 +0000 |
commit | 345930435561acd026c9356f01065e7ee0e92101 (patch) | |
tree | c4f3f67bbd0bba4181ca9e09d02a8d2304110b3e /plugins/SmartAutoReplier/GUI | |
parent | a88eaa5da5d02cd33b6725fb47c5f0dbb6a7d090 (diff) |
Adopted SmartAutoReplier plugin
First compilable version.
git-svn-id: http://svn.miranda-ng.org/main/trunk@6693 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SmartAutoReplier/GUI')
-rw-r--r-- | plugins/SmartAutoReplier/GUI/AddRuleDlg.cpp | 219 | ||||
-rw-r--r-- | plugins/SmartAutoReplier/GUI/AddRuleDlg.h | 67 | ||||
-rw-r--r-- | plugins/SmartAutoReplier/GUI/EditReplyDlg.cpp | 88 | ||||
-rw-r--r-- | plugins/SmartAutoReplier/GUI/EditReplyDlg.h | 55 | ||||
-rw-r--r-- | plugins/SmartAutoReplier/GUI/OptionsDlg.cpp | 528 | ||||
-rw-r--r-- | plugins/SmartAutoReplier/GUI/OptionsDlg.h | 119 | ||||
-rw-r--r-- | plugins/SmartAutoReplier/GUI/SelectUserDlg.cpp | 109 | ||||
-rw-r--r-- | plugins/SmartAutoReplier/GUI/SelectUserDlg.h | 58 | ||||
-rw-r--r-- | plugins/SmartAutoReplier/GUI/SettingsDlgHolder.cpp | 207 | ||||
-rw-r--r-- | plugins/SmartAutoReplier/GUI/SettingsDlgHolder.h | 69 |
10 files changed, 1519 insertions, 0 deletions
diff --git a/plugins/SmartAutoReplier/GUI/AddRuleDlg.cpp b/plugins/SmartAutoReplier/GUI/AddRuleDlg.cpp new file mode 100644 index 0000000000..0d76db3210 --- /dev/null +++ b/plugins/SmartAutoReplier/GUI/AddRuleDlg.cpp @@ -0,0 +1,219 @@ +/*
+ * Smart Auto Replier (SAR) - auto replier plugin for Miranda IM
+ *
+ * Copyright (C) 2004 - 2012 by Volodymyr M. Shcherbyna <volodymyr@shcherbyna.com>
+ *
+ * This file is part of SAR.
+ *
+ * SAR is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SAR is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with SAR. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "stdafx.h"
+#include "../resource.h"
+#include "addruledlg.h"
+#include "addruledlg.h"
+#include "selectuserdlg.h"
+
+extern LPTSTR g_strPluginName;
+extern CMessagesHandler *g_pMessHandler;
+extern CCrushLog CRUSHLOGOBJ;
+
+CAddRuleDlg::CAddRuleDlg(void) : m_dwCRC32(NULL), m_baur2thisMode(false), m_bEditing(false)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ ZeroMemory(&m_item, sizeof(m_item));
+END_PROTECT_AND_LOG_CODE
+}
+
+CAddRuleDlg::~CAddRuleDlg(void)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+END_PROTECT_AND_LOG_CODE
+}
+
+LRESULT CAddRuleDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ TranslateDialogDefault(m_hWnd);
+ m_editRuleName = GetDlgItem(IDC_ED_RULENAME);
+ m_editContactName = GetDlgItem(IDC_ED_RULECNAME);
+ m_editReplyText = GetDlgItem(IDC_ED_RULEREPLY);
+ //m_editReplyAction = GetDlgItem(IDC_ED_RULEACTION);
+ m_btnSelUser = GetDlgItem(IDC_BTN_SELUSER);
+
+ CenterWindow();
+
+ if (m_dwCRC32)
+ {
+ SetWindowText(TranslateTS(TEXT("Edit rule")));
+ m_editRuleName.SetWindowText(m_item.RuleName);
+ m_editContactName.SetWindowText(m_item.ContactName);
+ m_editReplyText.SetWindowText(m_item.ReplyText);
+ //m_editReplyAction.SetWindowText(m_item.ReplyAction);
+ m_bEditing = true;
+ }
+ else if (m_baur2thisMode)
+ {
+ m_editRuleName.SetWindowText(m_item.RuleName);
+ m_editContactName.SetWindowText(m_item.ContactName);
+ m_editReplyText.SetWindowText(m_item.ReplyText);
+ //m_editReplyAction.SetWindowText(m_item.ReplyAction);
+
+ m_btnSelUser.EnableWindow(FALSE);
+ m_editContactName.EnableWindow(FALSE);
+ m_editReplyText.SetSel(0, _tcslen(m_item.ReplyText), FALSE);
+ m_editReplyText.SetFocus();
+ }
+ else
+ {
+ m_editRuleName.SetWindowText(SETTINGS_DEF_RULE_NAME);
+ m_editReplyText.SetWindowText(SETTINGS_DEF_MESSAGE_RULE);
+ }
+
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+LRESULT CAddRuleDlg::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ return FALSE;
+END_PROTECT_AND_LOG_CODE
+}
+
+BOOL CAddRuleDlg::PreTranslateMessage(MSG* pMsg)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ return FALSE;
+END_PROTECT_AND_LOG_CODE
+}
+
+LRESULT CAddRuleDlg::OnBtnOKClicked(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+#define ON_ERROR_1BYTE(x) if (x == 1) { \
+ MessageBox(TranslateTS(TEXT("Please, specify longer contact name")), g_strPluginName, MB_OK); \
+ return FALSE; }
+
+#define ON_ERROR(x) MessageBox(TranslateTS(x), g_strPluginName, MB_OK); \
+ return FALSE;
+
+ int nLength = m_editRuleName.GetWindowTextLength();
+ if (nLength)
+ {
+ nLength++;
+ m_item.RuleName = new TCHAR[nLength];
+
+ if (m_item.RuleName != NULL)
+ {
+ memset(m_item.RuleName, 0, nLength * sizeof(TCHAR));
+ m_editRuleName.GetWindowText(m_item.RuleName, nLength);
+ }
+ }
+ else
+ {
+ ON_ERROR(TEXT("Please, specify Rule Name"))
+ }
+
+ nLength = m_editContactName.GetWindowTextLength();
+ if (nLength)
+ {
+ ON_ERROR_1BYTE(nLength)
+ nLength++;
+ m_item.ContactName = new TCHAR[nLength];
+
+ if (m_item.ContactName != NULL)
+ {
+ memset(m_item.ContactName, 0, nLength * sizeof(TCHAR));
+ m_editContactName.GetWindowText(m_item.ContactName, nLength);
+ }
+ }
+ else
+ {
+ ON_ERROR(TEXT("Please, specify Contact Name"))
+ }
+
+ nLength = m_editReplyText.GetWindowTextLength();
+ if (nLength)
+ {
+ if (nLength > SETTINGS_MESSAGE_MAXVALENGTH)
+ {
+ MessageBox(TranslateTS(TEXT("header is too big")), g_strPluginName, MB_OK);
+ return FALSE;
+ }
+
+ nLength++;
+ m_item.ReplyText = new TCHAR[nLength];
+
+ if (m_item.ContactName != NULL)
+ {
+ memset(m_item.ReplyText, 0, nLength * sizeof(TCHAR));
+ m_editReplyText.GetWindowText(m_item.ReplyText, nLength);
+ }
+ }
+ else
+ {
+ ON_ERROR(TEXT("Please, specify Reply Text"))
+ }
+
+ {
+ if (m_bEditing)
+ {/// delete prev item from storage...
+ g_pMessHandler->getSettings().getStorage().RemReplyAction(m_dwCRC32);
+ }
+
+ bool b;
+ DWORD dwCrc = g_pMessHandler->getSettings().AddReplyAction(m_item, b);
+ if (b)
+ {
+ MessageBox(TranslateTS(TEXT("Rule with the same contact name already exists")), g_strPluginName, MB_OK);
+ return FALSE;
+ }
+
+ m_bAddedOk = ((b == false) && dwCrc);
+ m_dwCRC32 = dwCrc;
+ }
+
+ EndDialog(0);
+#undef ON_ERROR
+#undef ON_ERROR_1BYTE
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+LRESULT CAddRuleDlg::OnBtnCancelClicked(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ m_bAddedOk = false;
+ EndDialog(0);
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+LRESULT CAddRuleDlg::OnBnClickedBtnSeluser(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ CSelectUserDlg dlg;
+ dlg.DoModal(m_hWnd);
+ if (dlg.m_bAllOk == true)
+ {
+ m_editContactName.SetWindowText(dlg.m_szRetVal);
+ m_editReplyText.SetFocus();
+ }
+ else
+ {
+ m_editContactName.SetFocus();
+ }
+END_PROTECT_AND_LOG_CODE
+ return 0;
+}
diff --git a/plugins/SmartAutoReplier/GUI/AddRuleDlg.h b/plugins/SmartAutoReplier/GUI/AddRuleDlg.h new file mode 100644 index 0000000000..d02fde733c --- /dev/null +++ b/plugins/SmartAutoReplier/GUI/AddRuleDlg.h @@ -0,0 +1,67 @@ +/*
+ * Smart Auto Replier (SAR) - auto replier plugin for Miranda IM
+ *
+ * Copyright (C) 2004 - 2012 by Volodymyr M. Shcherbyna <volodymyr@shcherbyna.com>
+ *
+ * This file is part of SAR.
+ *
+ * SAR is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SAR is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with SAR. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+
+#include <commctrl.h>
+#include <atlbase.h>
+#include <atlapp.h>
+#include <atlwin.h>
+
+#include "../RuleItem.h"
+
+class CAddRuleDlg : public CDialogImpl<CAddRuleDlg>, public CMessageFilter
+{
+public:
+ CAddRuleDlg(void);
+ virtual ~CAddRuleDlg(void);
+public:
+ enum {IDD = IDD_ADDRULE_DLG};
+ BEGIN_MSG_MAP(COptionsDlg)
+ MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
+ MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
+
+ COMMAND_ID_HANDLER(IDOK, OnBtnOKClicked)
+ COMMAND_ID_HANDLER(IDCANCEL, OnBtnCancelClicked)
+ COMMAND_HANDLER(IDC_BTN_SELUSER, BN_CLICKED, OnBnClickedBtnSeluser)
+ END_MSG_MAP()
+protected:
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
+ LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
+ LRESULT OnBtnOKClicked(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+ LRESULT OnBtnCancelClicked(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+ LRESULT OnBnClickedBtnSeluser(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+protected:
+ CEdit m_editRuleName;
+ CEdit m_editContactName;
+ CEdit m_editReplyText;
+ //CEdit m_editReplyAction;
+ CButton m_btnSelUser;
+public:
+ RULE_ITEM m_item;
+ bool m_bAddedOk;
+ DWORD m_dwCRC32;
+private:
+ bool m_bEditing;
+public:
+ bool m_baur2thisMode;
+};
diff --git a/plugins/SmartAutoReplier/GUI/EditReplyDlg.cpp b/plugins/SmartAutoReplier/GUI/EditReplyDlg.cpp new file mode 100644 index 0000000000..5dbc6989bc --- /dev/null +++ b/plugins/SmartAutoReplier/GUI/EditReplyDlg.cpp @@ -0,0 +1,88 @@ +/*
+ * Smart Auto Replier (SAR) - auto replier plugin for Miranda IM
+ *
+ * Copyright (C) 2004 - 2012 by Volodymyr M. Shcherbyna <volodymyr@shcherbyna.com>
+ *
+ * This file is part of SAR.
+ *
+ * SAR is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SAR is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with SAR. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "stdafx.h"
+#include "editreplydlg.h"
+
+extern LPTSTR g_strPluginName;
+
+CEditReplyDlg::CEditReplyDlg(void)
+{
+}
+
+CEditReplyDlg::~CEditReplyDlg(void)
+{
+}
+
+BOOL CEditReplyDlg::PreTranslateMessage(MSG* pMsg)
+{
+ return IsDialogMessage(pMsg);
+}
+
+LRESULT CEditReplyDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
+{
+ TranslateDialogDefault(m_hWnd);
+ m_editReplyText = GetDlgItem(IDC_ED_TEXT);
+
+ if (m_commRule.Message)
+ {
+ m_editReplyText.SetWindowText(m_commRule.Message);
+ }
+
+ CenterWindow(GetDesktopWindow());
+
+ return FALSE;
+}
+
+LRESULT CEditReplyDlg::OnBtnOKClicked(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+ int nLength = 0;
+
+ delete m_commRule.Message;
+
+ nLength = m_editReplyText.GetWindowTextLength();
+
+ if (nLength > SETTINGS_MESSAGE_MAXVALENGTH)
+ {
+ MessageBox(TranslateTS(TEXT("message is too big")), g_strPluginName, MB_OK);
+
+ return FALSE;
+ }
+ nLength++;
+ m_commRule.Message = new TCHAR[nLength];
+
+ if (!m_commRule.Message)
+ return FALSE;
+
+ memset(m_commRule.Message, 0, nLength * sizeof(TCHAR));
+ m_editReplyText.GetWindowText((LPTSTR)m_commRule.Message, nLength);
+
+ m_bAllOk = true;
+ EndDialog(1);
+ return FALSE;
+}
+
+LRESULT CEditReplyDlg::OnBtnCancelClicked(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+ m_bAllOk = false;
+ EndDialog(0);
+ return FALSE;
+}
\ No newline at end of file diff --git a/plugins/SmartAutoReplier/GUI/EditReplyDlg.h b/plugins/SmartAutoReplier/GUI/EditReplyDlg.h new file mode 100644 index 0000000000..0b4a5fb94a --- /dev/null +++ b/plugins/SmartAutoReplier/GUI/EditReplyDlg.h @@ -0,0 +1,55 @@ +/*
+ * Smart Auto Replier (SAR) - auto replier plugin for Miranda IM
+ *
+ * Copyright (C) 2004 - 2012 by Volodymyr M. Shcherbyna <volodymyr@shcherbyna.com>
+ *
+ * This file is part of SAR.
+ *
+ * SAR is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SAR is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with SAR. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+
+#include "..\resource.h"
+
+#include <commctrl.h>
+#include <atlbase.h>
+#include <atlapp.h>
+#include <atlwin.h>
+
+class CEditReplyDlg : public CDialogImpl<CEditReplyDlg>, public CMessageFilter
+{
+public:
+ CEditReplyDlg(void);
+ ~CEditReplyDlg(void);
+public:
+ enum {IDD = IDD_SET_AURMESSAGEDLG};
+ BEGIN_MSG_MAP(CEditReplyDlg)
+ MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
+ COMMAND_ID_HANDLER(IDOK, OnBtnOKClicked)
+ COMMAND_ID_HANDLER(IDCANCEL, OnBtnCancelClicked)
+ END_MSG_MAP()
+protected:
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
+ LRESULT OnBtnOKClicked(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+ LRESULT OnBtnCancelClicked(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+public:
+ REPLYER_SETTINGS m_settings;
+ COMMON_RULE_ITEM m_commRule;
+ bool m_bAllOk;
+protected:
+ CEdit m_editReplyText;
+ CEdit m_editReplyHeader;
+};
diff --git a/plugins/SmartAutoReplier/GUI/OptionsDlg.cpp b/plugins/SmartAutoReplier/GUI/OptionsDlg.cpp new file mode 100644 index 0000000000..29916f0f5f --- /dev/null +++ b/plugins/SmartAutoReplier/GUI/OptionsDlg.cpp @@ -0,0 +1,528 @@ +/*
+ * Smart Auto Replier (SAR) - auto replier plugin for Miranda IM
+ *
+ * Copyright (C) 2004 - 2012 by Volodymyr M. Shcherbyna <volodymyr@shcherbyna.com>
+ *
+ * This file is part of SAR.
+ *
+ * SAR is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SAR is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with SAR. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "stdafx.h"
+#include "optionsdlg.h"
+#include "addruledlg.h"
+
+/// need ptr to get/set info
+extern CMessagesHandler *g_pMessHandler;
+extern CCrushLog CRUSHLOGOBJ;
+extern LPTSTR g_strPluginName;
+
+//COptionsDlg g_optionsDlg;
+
+BOOL CALLBACK COptionsDlg::DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+
+ /*if (g_optionsDlg.m_bDestroying)
+ return FALSE;
+
+ if (g_optionsDlg.m_hWnd == NULL)
+ g_optionsDlg.Attach(hwndDlg);
+
+ LRESULT lre = {0};
+ DWORD dwId = {0};
+ return g_optionsDlg.ProcessWindowMessage(hwndDlg, msg, wParam, lParam, lre, dwId);*/
+
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+COptionsDlg::COptionsDlg(void) : m_bShown(false), m_szMessage(NULL)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+///g_optionsDlg.m_bDestroying = false;
+m_bDestroying = false;
+END_PROTECT_AND_LOG_CODE
+}
+
+COptionsDlg::~COptionsDlg(void)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+END_PROTECT_AND_LOG_CODE
+}
+
+BOOL COptionsDlg::PreTranslateMessage(MSG* pMsg)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ return ::IsDialogMessage(m_hWnd, pMsg);
+END_PROTECT_AND_LOG_CODE
+}
+
+/// process OnInitDialog
+LRESULT COptionsDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ TranslateDialogDefault(m_hWnd);
+
+ if (!g_pMessHandler)
+ return FALSE;
+
+ m_listRules = GetDlgItem(IDC_LIST_RULES);
+ m_editReplayDelay = GetDlgItem(IDC_EDIT_REPLAYDELAY);
+// m_editHeaderMessage = GetDlgItem(IDC_EDIT_HEADER);
+ m_editMessageText = GetDlgItem(IDC_EDIT_MESSAGE);
+ m_btnAdd = GetDlgItem(IDC_BTN_ADDRULE);
+ m_btnDel = GetDlgItem(IDC_BTN_DELRULE);
+ m_btnChange = GetDlgItem(IDC_BTN_EDITRULE);
+ m_wndCheckDOnSOn = GetDlgItem(IDC_CHECK_DISABLEWMON);
+ m_wndCheckModeTypes = GetDlgItem(IDC_CH_ENABLE_WSCH);
+ m_cbModeTypes = GetDlgItem(IDC_CB_ENWSC);
+ m_chbShowAurWhmc = GetDlgItem(IDC_CH_SHOWCG);
+ m_cbDisWMBTypes = GetDlgItem(IDC_CB_DWSB);
+ m_chDisWMB = GetDlgItem(IDC_CH_DISWHSB);
+ m_chSaveAURSToHist = GetDlgItem(IDC_CH_SAVE_AURS);
+
+ m_cbModeTypes.AddString(TranslateTS(TEXT("DND/NA/Away/Occupied modes")));
+ m_cbModeTypes.AddString(TranslateTS(TEXT("DND mode")));
+ m_cbModeTypes.AddString(TranslateTS(TEXT("NA mode")));
+ m_cbModeTypes.AddString(TranslateTS(TEXT("Away mode")));
+ m_cbModeTypes.AddString(TranslateTS(TEXT("Occupied mode")));
+
+ m_cbDisWMBTypes.AddString(TranslateTS(TEXT("Online/Free for chat modes")));
+ m_cbDisWMBTypes.AddString(TranslateTS(TEXT("Online mode")));
+ m_cbDisWMBTypes.AddString(TranslateTS(TEXT("Free for chat mode")));
+
+ COMMON_RULE_ITEM & commRules = g_pMessHandler->getSettings().getStorage().getCommonRule();
+ REPLYER_SETTINGS & settings = g_pMessHandler->getSettings().getSettings();
+
+ if (settings.ModeValue > m_cbModeTypes.GetCount())
+ m_cbModeTypes.SetCurSel(0);
+ else
+ m_cbModeTypes.SetCurSel(settings.ModeValue);
+ if (settings.ModeDisValue > m_cbDisWMBTypes.GetCount())
+ m_cbDisWMBTypes.SetCurSel(0);
+ else
+ m_cbDisWMBTypes.SetCurSel(settings.ModeDisValue);
+
+ m_cbDisWMBTypes.EnableWindow(settings.bDisableWhenModeIsSet);
+
+ if (settings.bDisableWhenModeIsSet)
+ {
+ m_chDisWMB.SendMessage(BM_SETCHECK, BST_CHECKED, 0);
+ }
+ else
+ {
+ m_chDisWMB.SendMessage(BM_SETCHECK, BST_UNCHECKED, 0);
+ }
+
+ if (settings.bShowAURDlgWhenModeChanges)
+ {
+ m_chbShowAurWhmc.SendMessage(BM_SETCHECK, BST_CHECKED, 0);
+ }
+ else
+ {
+ m_chbShowAurWhmc.SendMessage(BST_UNCHECKED, BST_CHECKED, 0);
+ }
+
+ if (settings.bEnableWhenModeIsSet)
+ {
+ m_wndCheckModeTypes.SendMessage(BM_SETCHECK, BST_CHECKED, 0);
+ }
+ else
+ {
+ m_wndCheckModeTypes.SendMessage(BST_UNCHECKED, BST_CHECKED, 0);
+ }
+
+ if (settings.bSaveToHistory)
+ {
+ m_chSaveAURSToHist.SendMessage(BM_SETCHECK, BST_CHECKED, 0);
+ }
+ else
+ {
+ m_chSaveAURSToHist.SendMessage(BST_UNCHECKED, BST_CHECKED, 0);
+ }
+
+ m_cbModeTypes.EnableWindow(settings.bEnableWhenModeIsSet);
+
+ int nLength = settings.ReplayDelay;
+ if (nLength == 0)
+ nLength = SETTINGS_DEF_COMMON_VALREPDELAY;
+
+ if (settings.bDisableWhenMirandaIsOn)
+ m_wndCheckDOnSOn.SendMessage(BM_SETCHECK, BST_CHECKED, 0);
+ else
+ m_wndCheckDOnSOn.SendMessage(BM_SETCHECK, BST_UNCHECKED, 0);
+
+ TCHAR strNumber[MAX_PATH] = {0};
+ m_editReplayDelay.SetWindowText(_itot(nLength, strNumber, 10));
+ m_nReplayDelay = nLength;
+
+ TCHAR* str = commRules.Message;
+ m_editMessageText.SetWindowText(str);
+
+ if (m_szMessage)
+ {
+ delete m_szMessage;
+ m_szMessage = NULL;
+ }
+
+ m_szMessage = new TCHAR[SETTINGS_MESSAGE_MAXVALENGTH];
+
+ if (!m_szMessage)
+ return FALSE;
+
+ memset(m_szMessage, 0, SETTINGS_MESSAGE_MAXVALENGTH * sizeof(TCHAR));
+
+ m_editMessageText.GetWindowText(m_szMessage, SETTINGS_MESSAGE_MAXVALENGTH);
+
+ { /// filling listbox with rule names...
+ RulesHash::iterator it;
+ RulesHash & hash = g_pMessHandler->getSettings().getStorage().getHashTable();
+ int nPos = 0;
+
+ bool bAdded = false;
+ for (it = hash.begin(); it != hash.end(); it++)
+ {
+ nPos = m_listRules.AddString(it->second.RuleName);
+ if (nPos != -1)
+ {
+ m_listRules.SetItemData(nPos, it->first);
+ if (!bAdded)
+ bAdded = true;
+ }
+ }
+ if (bAdded)
+ {
+ OnSetSelInRulesList(0);
+ }
+ }
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+/// process WM_DESTROY
+LRESULT COptionsDlg::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ m_bDestroying = true;
+ ///g_optionsDlg.m_bDestroying = true;
+ ///::DestroyWindow(m_hWnd);
+ ///g_optionsDlg.m_hWnd = NULL;
+ //m_hWnd = NULL;
+ m_szMessage = NULL;
+ // m_bDestroying = false;
+ ///g_optionsDlg.m_bDestroying = false;
+ return FALSE;
+END_PROTECT_AND_LOG_CODE
+}
+
+void COptionsDlg::OnNotifyAboutChanges(void)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ SendMessage(m_hwndHolder, PSM_CHANGED, 0, 0);
+END_PROTECT_AND_LOG_CODE
+}
+
+/// handler of typing in replay delay edit box
+LRESULT COptionsDlg::OnEditReply(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ if (m_bShown)
+ {
+ m_bShown = false;
+ return FALSE;
+ }
+ TCHAR tch[MAX_PATH] = {0};
+ GetDlgItemText (IDC_EDIT_REPLAYDELAY, tch, sizeof(tch));
+ int nValue = _tstoi(tch);
+
+ if (nValue != m_nReplayDelay)
+ {
+ m_nReplayDelay = nValue;
+ OnNotifyAboutChanges();
+ }
+
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+LRESULT COptionsDlg::OnNotify(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ { /// apply our changes...
+ REPLYER_SETTINGS sett;
+ COMMON_RULE_ITEM commrule;
+
+ commrule.Message = m_szMessage;
+
+ sett.bEnabled = g_pMessHandler->getSettings().getSettings().bEnabled;
+ sett.ReplayDelay = m_nReplayDelay;
+
+ LRESULT lres = m_wndCheckDOnSOn.SendMessage(BM_GETCHECK, 0, 0);
+ sett.bDisableWhenMirandaIsOn = (lres == BST_CHECKED);
+ lres = m_wndCheckModeTypes.SendMessage(BM_GETCHECK, 0, 0);
+ sett.bEnableWhenModeIsSet = (lres == BST_CHECKED);
+ lres = m_chbShowAurWhmc.SendMessage(BM_GETCHECK, 0, 0);
+ sett.bShowAURDlgWhenModeChanges = (lres == BST_CHECKED);
+ lres = m_chSaveAURSToHist.SendMessage(BM_GETCHECK, 0, 0);
+ sett.bSaveToHistory = (lres == BST_CHECKED);
+ sett.ModeValue = m_cbModeTypes.GetCurSel();
+ lres = m_chDisWMB.SendMessage(BM_GETCHECK, 0, 0);
+ sett.bDisableWhenModeIsSet = (lres == BST_CHECKED);
+ sett.ModeDisValue = m_cbDisWMBTypes.GetCurSel();
+
+ CSettingsHandler & handler = g_pMessHandler->getSettings();
+ handler.setSettings(sett, &commrule);
+ //handler.getStorage().Flush(); /// flush all unflushed rules into hdd
+ }
+ }
+
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+LRESULT COptionsDlg::OnEditHeader(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+LRESULT COptionsDlg::OnEditMessage(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ if (!m_szMessage)
+ return FALSE;
+
+ int nLength = m_editMessageText.GetWindowTextLength();
+
+ if (nLength > SETTINGS_MESSAGE_MAXVALENGTH)
+ {
+ MessageBox(TranslateTS(TEXT("too big size")), g_strPluginName, MB_OK);
+ m_editMessageText.SetWindowText(m_szMessage);
+
+ return FALSE;
+ }
+ nLength++;
+ LPTSTR str2 = new TCHAR[nLength];
+
+ if (!str2)
+ return FALSE;
+
+ memset(str2, 0, nLength * sizeof(TCHAR));
+ m_editMessageText.GetWindowText(str2, nLength);
+
+ if (_tcscmp(m_szMessage, str2) != 0)
+ {
+ _tcscpy(m_szMessage, str2);
+ OnNotifyAboutChanges();
+ }
+
+ delete str2;
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+void COptionsDlg::OnSetSelInRulesList(int nIndex)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ m_listRules.SetCurSel(nIndex);
+ BOOL b;
+ OnListBoxSelChanged(0, 0, 0, b);
+END_PROTECT_AND_LOG_CODE
+}
+
+LRESULT COptionsDlg::OnBtnAddRuleClick(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ CAddRuleDlg dlg;
+ dlg.DoModal(m_hWnd, 0);
+ if (dlg.m_bAddedOk)
+ {
+ int npos = m_listRules.AddString(dlg.m_item.RuleName);
+ if (npos != -1)
+ {
+ m_listRules.SetItemData(npos, dlg.m_dwCRC32);
+ OnSetSelInRulesList(npos);
+ OnNotifyAboutChanges();
+ }
+ }
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+LRESULT COptionsDlg::OnBtnEditRuleClick(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ int nIndex = m_listRules.GetCurSel();
+ if (nIndex >= 0)
+ {
+ DWORD dwCrc32 = static_cast<DWORD>(m_listRules.GetItemData(nIndex));
+ if (dwCrc32)
+ {
+ CAddRuleDlg dlgEdit;
+ RulesHash::iterator it;
+ RulesHash & hash = g_pMessHandler->getSettings().getStorage().getHashTable();
+ it = hash.find(dwCrc32);
+ if (it != hash.end())
+ {
+ dlgEdit.m_item = it->second;
+ dlgEdit.m_dwCRC32 = dwCrc32;
+ dlgEdit.DoModal();
+ if (dlgEdit.m_bAddedOk)
+ {/// the rule is edited...
+ m_listRules.DeleteString(nIndex);
+ nIndex = m_listRules.AddString(dlgEdit.m_item.RuleName);
+ m_listRules.SetItemData(nIndex, dlgEdit.m_dwCRC32);
+ OnSetSelInRulesList(nIndex);
+ OnNotifyAboutChanges();
+ }
+ }
+ }
+ }
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+LRESULT COptionsDlg::OnBtnDeleteRuleClick(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ int nIndex = m_listRules.GetCurSel();
+ if (nIndex >= 0)
+ {
+ DWORD dwptr = static_cast<DWORD>(m_listRules.GetItemData(nIndex));
+ if (dwptr)/// we have ptr
+ {
+ if (MessageBox(TranslateTS(TEXT("Do you really want delete selected rule?")), g_strPluginName, MB_YESNO) == IDNO)
+ return FALSE;
+
+ CRulesStorage & hash = g_pMessHandler->getSettings().getStorage();
+
+ if (hash.RemReplyAction(dwptr))
+ {/// we found item in storage list...
+ int nCount = m_listRules.DeleteString(nIndex);
+ if (nCount != LB_ERR)
+ { /// set sel to prev one
+ if (nIndex == 0 && nCount)
+ OnSetSelInRulesList(0);
+ else
+ if ( (nIndex - 1) <= nCount)
+ {
+ OnSetSelInRulesList(nIndex - 1);
+ }
+ }
+
+ OnNotifyAboutChanges();
+ }
+ }
+ }
+
+ BOOL b;
+ OnListBoxSelChanged(0, 0, 0, b);
+
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+LRESULT COptionsDlg::OnListBoxSelChanged(WORD wParam, WORD w2Param, HWND hwnd, BOOL & bHandled)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ int nCount = m_listRules.GetCurSel();
+ //m_btnChange.EnableWindow((nCount >= 0));
+ BOOL bEnable = (nCount >= 0);
+ m_btnDel.EnableWindow(bEnable);
+ m_btnChange.EnableWindow(bEnable);
+
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+LRESULT COptionsDlg::OnBnClickedCheck(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ OnNotifyAboutChanges();
+
+ return FALSE;
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+LRESULT COptionsDlg::OnBnCheckEnableWhenModeIsOn(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ LRESULT lres = m_wndCheckModeTypes.SendMessage(BM_GETCHECK, 0, 0);
+ m_cbModeTypes.EnableWindow(lres == BST_CHECKED);
+ OnNotifyAboutChanges();
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+LRESULT COptionsDlg::OnCbnSelchangeCbEnwsc(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ OnNotifyAboutChanges();
+
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+LRESULT COptionsDlg::OnCheckSaveToHistory(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ OnNotifyAboutChanges();
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+LRESULT COptionsDlg::OnBnCheckDisableWhenModeIsOn(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ LRESULT lres = m_chDisWMB.SendMessage(BM_GETCHECK, 0, 0);
+ m_cbDisWMBTypes.EnableWindow(lres == BST_CHECKED);
+ OnNotifyAboutChanges();
+
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+LRESULT COptionsDlg::OnCbnSelchangeCbDisnwsc(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ OnNotifyAboutChanges();
+
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+/// options are changed in another place...
+/// so just update them all...
+LRESULT COptionsDlg::OnRefreshOptions(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ MessageBox (TranslateTS(TEXT("Options are changed in another dialog")), g_strPluginName, MB_OK);
+ ///OnNotifyAboutChanges();
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+LRESULT COptionsDlg::OnLbnDblclkListRules(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ return OnBtnEditRuleClick(wNotifyCode, wID, hWndCtl, bHandled);
+END_PROTECT_AND_LOG_CODE
+}
\ No newline at end of file diff --git a/plugins/SmartAutoReplier/GUI/OptionsDlg.h b/plugins/SmartAutoReplier/GUI/OptionsDlg.h new file mode 100644 index 0000000000..0e2e91f191 --- /dev/null +++ b/plugins/SmartAutoReplier/GUI/OptionsDlg.h @@ -0,0 +1,119 @@ +/*
+ * Smart Auto Replier (SAR) - auto replier plugin for Miranda IM
+ *
+ * Copyright (C) 2004 - 2012 by Volodymyr M. Shcherbyna <volodymyr@shcherbyna.com>
+ *
+ * This file is part of SAR.
+ *
+ * SAR is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SAR is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with SAR. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+
+/// #warning: redeclaring....quick programming ;)
+/// look at stdafx.h
+#ifndef REFRESH_OPTS_MSG
+ #define REFRESH_OPTS_MSG WM_USER + 666
+#endif
+
+#include <commctrl.h>
+#include <atlbase.h>
+#include <atlapp.h>
+#include <atlwin.h>
+#include <atlctrls.h>
+
+/// here is a wrapper on options dlg
+class COptionsDlg : public CDialogImpl<COptionsDlg>, public CMessageFilter
+{
+public:
+ COptionsDlg(void);
+ virtual ~COptionsDlg(void);
+public:
+ enum {IDD = IDD_OPTIONS};
+ BEGIN_MSG_MAP(COptionsDlg)
+ MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
+ MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
+ MESSAGE_HANDLER(WM_NOTIFY, OnNotify)
+ MESSAGE_HANDLER(REFRESH_OPTS_MSG, OnRefreshOptions)
+ COMMAND_ID_HANDLER(IDC_BTN_ADDRULE, OnBtnAddRuleClick)
+ COMMAND_ID_HANDLER(IDC_BTN_DELRULE, OnBtnDeleteRuleClick)
+ COMMAND_ID_HANDLER(IDC_BTN_EDITRULE, OnBtnEditRuleClick)
+ COMMAND_ID_HANDLER(IDC_EDIT_REPLAYDELAY, OnEditReply)
+ COMMAND_ID_HANDLER(IDC_EDIT_HEADER, OnEditHeader)
+ COMMAND_ID_HANDLER(IDC_EDIT_MESSAGE, OnEditMessage)
+ COMMAND_CODE_HANDLER(LBN_SELCHANGE, OnListBoxSelChanged)
+ COMMAND_HANDLER(IDC_LIST_RULES, LBN_DBLCLK, OnLbnDblclkListRules)
+ COMMAND_HANDLER(IDC_CHECK_DISABLEWMON, BN_CLICKED, OnBnClickedCheck)
+ COMMAND_HANDLER(IDC_CH_ENABLE_WSCH, BN_CLICKED, OnBnCheckEnableWhenModeIsOn)
+ COMMAND_HANDLER(IDC_CH_SHOWCG, BN_CLICKED, OnBnCheckEnableWhenModeIsOn)
+ COMMAND_HANDLER(IDC_CH_SAVE_AURS, BN_CLICKED, OnCheckSaveToHistory)
+ COMMAND_HANDLER(IDC_CB_ENWSC, CBN_SELENDOK, OnCbnSelchangeCbEnwsc)
+ COMMAND_HANDLER(IDC_CH_DISWHSB, BN_CLICKED, OnBnCheckDisableWhenModeIsOn)
+ COMMAND_HANDLER(IDC_CB_DWSB, CBN_SELENDOK, OnCbnSelchangeCbDisnwsc)
+ END_MSG_MAP()
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+protected:
+ /// messages handlers prototypes
+ LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
+ LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
+ LRESULT OnNotify(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
+ LRESULT OnRefreshOptions(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
+
+ /// commands handlers prototypes
+ LRESULT OnBtnAddRuleClick(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+ LRESULT OnBtnDeleteRuleClick(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+ LRESULT OnBtnEditRuleClick(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+ LRESULT OnEditReply(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+ LRESULT OnEditHeader(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+ LRESULT OnEditMessage(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+ LRESULT OnListBoxSelChanged(WORD wParam, WORD wParam2, HWND hwnd, BOOL & bHandled);
+ LRESULT OnBnClickedCheck(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+ LRESULT OnBnCheckEnableWhenModeIsOn(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+ LRESULT OnCbnSelchangeCbEnwsc(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+ LRESULT OnBnCheckDisableWhenModeIsOn(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+ LRESULT OnCheckSaveToHistory(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+ LRESULT OnCbnSelchangeCbDisnwsc(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+ LRESULT OnLbnDblclkListRules(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+public:
+ static BOOL CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+private:
+ void OnNotifyAboutChanges(void);
+ void OnSetSelInRulesList(int nIndex);
+protected:
+ CEdit m_editReplayDelay; /// edit box where reply delay is specifyed
+ CEdit m_editMessageText; /// edit box where message text is specifyed
+ CListBox m_listRules; /// list box where all rules are specifyed
+ CButton m_btnAdd; /// button add rule
+ CButton m_btnDel; /// button delete rule
+ CButton m_btnChange; /// button change rule
+ CWindow m_wndCheckDOnSOn; /// checkbox that specifyes dis of plug. when mir is on
+ CComboBox m_cbModeTypes; /// cb mode types
+ CWindow m_wndCheckModeTypes; /// ch mode types
+ CWindow m_chbShowAurWhmc; /// ch show edit reply message
+ CWindow m_chDisWMB; /// ch disable when mode becomes...
+ CWindow m_chSaveAURSToHist; /// save aurs to history
+ CComboBox m_cbDisWMBTypes; /// cb disable when mode becomes...
+private:
+ LPTSTR m_szMessage;
+ int m_nReplayDelay;
+ bool m_bDestroying;
+protected:
+ bool m_bShown;
+public:
+ HWND m_hwndHolder;
+};
+
+/// here is static dlg proc for options dialog..
+/// very bad but mirand can accept only this function
+BOOL CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
\ No newline at end of file diff --git a/plugins/SmartAutoReplier/GUI/SelectUserDlg.cpp b/plugins/SmartAutoReplier/GUI/SelectUserDlg.cpp new file mode 100644 index 0000000000..daf249ebec --- /dev/null +++ b/plugins/SmartAutoReplier/GUI/SelectUserDlg.cpp @@ -0,0 +1,109 @@ +/*
+ * Smart Auto Replier (SAR) - auto replier plugin for Miranda IM
+ *
+ * Copyright (C) 2004 - 2012 by Volodymyr M. Shcherbyna <volodymyr@shcherbyna.com>
+ *
+ * This file is part of SAR.
+ *
+ * SAR is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SAR is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with SAR. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "stdafx.h"
+#include "selectuserdlg.h"
+#include "selectuserdlg.h"
+
+extern LPTSTR g_strPluginName;
+extern CMessagesHandler * g_pMessHandler;
+
+
+CSelectUserDlg::CSelectUserDlg(void) : m_bAllOk(false)
+{
+}
+
+CSelectUserDlg::~CSelectUserDlg(void)
+{
+}
+
+BOOL CSelectUserDlg::PreTranslateMessage(MSG* pMsg)
+{
+ return IsDialogMessage(pMsg);
+}
+
+LRESULT CSelectUserDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ TranslateDialogDefault(m_hWnd);
+ m_listUsers = GetDlgItem(IDC_LIST_USERS);
+ RebuildCL();
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+void CSelectUserDlg::RebuildCL()
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ HANDLE hContact= db_find_first();
+ TCHAR* szContactName = NULL;
+ TCHAR* szProto = NULL;
+ DWORD wId = 0;
+ while (hContact != NULL)
+ {
+ szContactName = g_pMessHandler->GetContactName(hContact);
+ szProto = (TCHAR*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (szProto)
+ {
+ size_t nPos = -1;
+ if (szContactName)
+ {
+ nPos = m_listUsers.AddString(szContactName);
+ }
+
+ /*DBVARIANT db = {0};
+ db_get(hContact, szProto, "uin", &db);
+ db_get(hContact, szProto, "UIN", &db);*/
+ //m_listUsers.SetItemData(nPos, )
+ }
+
+ hContact = db_find_next(hContact);
+ }
+END_PROTECT_AND_LOG_CODE
+}
+
+LRESULT CSelectUserDlg::OnBtnOKClicked(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ INT nsel = m_listUsers.GetCurSel();
+ m_bAllOk = (nsel != -1);
+ if (m_bAllOk == true)
+ {
+ m_listUsers.GetText(nsel, m_szRetVal);
+ EndDialog(0);
+ }
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+LRESULT CSelectUserDlg::OnBtnCancelClicked(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ m_bAllOk = false;
+ EndDialog(0);
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+LRESULT CSelectUserDlg::OnLbnDblclkListUsers(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+ return OnBtnOKClicked(wNotifyCode, wID, hWndCtl, bHandled);
+}
diff --git a/plugins/SmartAutoReplier/GUI/SelectUserDlg.h b/plugins/SmartAutoReplier/GUI/SelectUserDlg.h new file mode 100644 index 0000000000..1756e7a4b8 --- /dev/null +++ b/plugins/SmartAutoReplier/GUI/SelectUserDlg.h @@ -0,0 +1,58 @@ +/*
+ * Smart Auto Replier (SAR) - auto replier plugin for Miranda IM
+ *
+ * Copyright (C) 2004 - 2012 by Volodymyr M. Shcherbyna <volodymyr@shcherbyna.com>
+ *
+ * This file is part of SAR.
+ *
+ * SAR is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SAR is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with SAR. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+
+#include "..\resource.h"
+
+#include <commctrl.h>
+#include <atlbase.h>
+#include <atlapp.h>
+#include <atlwin.h>
+
+class CSelectUserDlg : public CDialogImpl<CSelectUserDlg>, public CMessageFilter
+{
+public:
+ CSelectUserDlg(void);
+ ~CSelectUserDlg(void);
+public:
+ enum {IDD = IDD_SEL_USER};
+ BEGIN_MSG_MAP(CSelectUserDlg)
+ MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
+ COMMAND_ID_HANDLER(IDOK, OnBtnOKClicked)
+ COMMAND_ID_HANDLER(IDCANCEL, OnBtnCancelClicked)
+ COMMAND_HANDLER(IDC_LIST_USERS, LBN_DBLCLK, OnLbnDblclkListUsers)
+ END_MSG_MAP()
+protected:
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
+ LRESULT OnBtnOKClicked(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+ LRESULT OnBtnCancelClicked(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+private:
+ void RebuildCL();
+public:
+ bool m_bAllOk;
+ TCHAR m_szRetVal[MAX_PATH];
+protected:
+ CListBox m_listUsers;
+public:
+ LRESULT OnLbnDblclkListUsers(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+};
diff --git a/plugins/SmartAutoReplier/GUI/SettingsDlgHolder.cpp b/plugins/SmartAutoReplier/GUI/SettingsDlgHolder.cpp new file mode 100644 index 0000000000..4a9eae542a --- /dev/null +++ b/plugins/SmartAutoReplier/GUI/SettingsDlgHolder.cpp @@ -0,0 +1,207 @@ +/*
+ * Smart Auto Replier (SAR) - auto replier plugin for Miranda IM
+ *
+ * Copyright (C) 2004 - 2012 by Volodymyr M. Shcherbyna <volodymyr@shcherbyna.com>
+ *
+ * This file is part of SAR.
+ *
+ * SAR is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SAR is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with SAR. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "stdafx.h"
+#include "settingsdlgholder.h"
+
+/// #warning
+/// dont make Translate each time
+/// instead once fill list of translated strings
+/// and use them
+
+extern LPTSTR g_strPluginName;
+extern CMessagesHandler * g_pMessHandler;
+CSettingsDlgHolder * CSettingsDlgHolder::m_pThis = NULL;
+
+CSettingsDlgHolder::CSettingsDlgHolder(void) :
+IMSingeltone<CSettingsDlgHolder>(this),
+m_bTabSelected(false),
+m_bDestroying(false)
+{
+}
+
+CSettingsDlgHolder::~CSettingsDlgHolder(void)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ BOOL b;
+ OnDestroy(NULL, NULL, NULL, b);
+END_PROTECT_AND_LOG_CODE
+}
+
+BOOL CSettingsDlgHolder::PreTranslateMessage(MSG* pMsg)
+{
+ return IsDialogMessage(pMsg);
+}
+
+LRESULT CSettingsDlgHolder::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ TranslateDialogDefault(m_hWnd);
+
+ m_tabCtrl = GetDlgItem(IDC_TABSHOLDER);
+ m_statusMsg = GetDlgItem(IDC_STATUSMSG);
+
+ TCITEM ti = {0};
+ ti.mask = TCIF_TEXT;
+ ti.pszText = TranslateTS(TEXT("General"));
+ ti.cchTextMax = _tcslen(ti.pszText);
+ m_tabCtrl.InsertItem(0, &ti);
+ /*ti.pszText = Translate("About");
+ ti.cchTextMax = _tcslen(ti.pszText);
+ m_tabCtrl.InsertItem(1, &ti);*/
+
+ m_generalOpt.Create(m_tabCtrl, NULL);
+ m_generalOpt.m_hwndHolder = this->m_hWnd;
+ m_tabCtrl.SetCurSel(0);
+
+ /// #warning
+ /// copy paste from OnNotify(), fix later
+ /*m_statusMsg.SetWindowText(Translate("General options, provides basic functionality."));*/
+ m_statusMsg.SetWindowText(TranslateTS(TEXT("")));
+ m_generalOpt.SetWindowPos(NULL, 7, 23, NULL, NULL, SWP_NOSIZE);
+ m_generalOpt.ShowWindow(SW_SHOW);
+
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+void CSettingsDlgHolder::OnNotifyParents(LPNMHDR lpnmhdr, int nCode)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ lpnmhdr->code = nCode;
+ m_generalOpt.SendMessage(WM_NOTIFY, 0, reinterpret_cast<LPARAM>(lpnmhdr));
+END_PROTECT_AND_LOG_CODE
+}
+
+LRESULT CSettingsDlgHolder::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ LPNMHDR lpnmhdr = NULL;
+ lpnmhdr = (LPNMHDR)lParam;
+ if (lpnmhdr == NULL)
+ {
+ return FALSE;
+ }
+
+ if (m_bTabSelected == false)
+ {
+ m_bTabSelected = true;
+ return FALSE;
+ }
+
+ switch (lpnmhdr->code)
+ {
+ case PSN_APPLY:
+ OnNotifyParents(lpnmhdr, PSN_APPLY);
+ break;
+ }
+
+ int nSel = -1;
+ if (lpnmhdr->hwndFrom == m_tabCtrl)
+ {
+ nSel = m_tabCtrl.GetCurSel();
+ /// let's make a switch by dialogs...
+ if (nSel == 0)
+ {
+ m_statusMsg.SetWindowText(TranslateTS(TEXT("General options, provides basic functionality.")));
+ m_generalOpt.ShowWindow(SW_SHOW);
+ m_generalOpt.SetWindowPos(NULL, 7, 23, NULL, NULL, SWP_NOSIZE);
+ }
+ else
+ m_generalOpt.ShowWindow(SW_HIDE);
+ }
+
+ m_bTabSelected = false;
+
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+BOOL CALLBACK CSettingsDlgHolder::FakeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ CSettingsDlgHolder *pHandler = CSettingsDlgHolder::GetObject();
+
+ if (pHandler == NULL)
+ return FALSE;
+
+ if (pHandler->m_bDestroying == true)
+ return FALSE;
+
+ if (pHandler->m_hWnd == NULL)
+ pHandler->Attach(hwndDlg);
+
+ LRESULT lr = 0;
+ DWORD dwid = 0;
+ BOOL bRetVal = pHandler->ProcessWindowMessage(hwndDlg, msg, wParam, lParam, lr, dwid);
+ return bRetVal;
+ END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+LRESULT CSettingsDlgHolder::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ m_bDestroying = true;
+
+ if (m_tabCtrl.IsWindow())
+ {
+ m_tabCtrl.DeleteAllItems();
+ m_tabCtrl.DestroyWindow();
+ }
+ if (m_statusMsg.IsWindow())
+ m_statusMsg.DestroyWindow();
+
+ if (m_generalOpt.IsWindow())
+ {
+ /*try
+ {*/
+ //OSVERSIONINFO ver = {0};
+ //ver.dwOSVersionInfoSize = sizeof(ver);
+
+ //if (GetVersionEx(&ver) == TRUE)
+ //{
+ // if (ver.dwMajorVersion > 4)
+ // {
+ NMHDR h = {0};
+ h.code = PSN_APPLY;
+ OnNotifyParents(&h, PSN_APPLY);
+ // }
+ //}
+ m_generalOpt.DestroyWindow();
+ //}
+ //catch (...)
+ //{/// win9x will die here
+ //}
+ }
+ m_hWnd = NULL;
+
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
+
+LRESULT CSettingsDlgHolder::OnSettingsChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
+{
+BEGIN_PROTECT_AND_LOG_CODE
+ return SendMessage(GetParent(), PSM_CHANGED, 0, 0);
+END_PROTECT_AND_LOG_CODE
+ return FALSE;
+}
\ No newline at end of file diff --git a/plugins/SmartAutoReplier/GUI/SettingsDlgHolder.h b/plugins/SmartAutoReplier/GUI/SettingsDlgHolder.h new file mode 100644 index 0000000000..61fb460e5b --- /dev/null +++ b/plugins/SmartAutoReplier/GUI/SettingsDlgHolder.h @@ -0,0 +1,69 @@ +/*
+ * Smart Auto Replier (SAR) - auto replier plugin for Miranda IM
+ *
+ * Copyright (C) 2004 - 2012 by Volodymyr M. Shcherbyna <volodymyr@shcherbyna.com>
+ *
+ * This file is part of SAR.
+ *
+ * SAR is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SAR is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with SAR. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+
+#include "..\resource.h"
+
+#include <commctrl.h>
+#include <atlbase.h>
+#include <atlapp.h>
+#include <atlwin.h>
+
+#include "optionsdlg.h"
+
+/// dialog that holds all
+/// gui dialogs..
+class CSettingsDlgHolder : public CDialogImpl<CSettingsDlgHolder>,
+ public CMessageFilter,
+ public IMSingeltone<CSettingsDlgHolder>
+{
+public: /// ctors
+ CSettingsDlgHolder(void);
+ /// dctors
+ ~CSettingsDlgHolder(void);
+public:
+ enum {IDD = IDD_SDLGHOLDER};
+ BEGIN_MSG_MAP(CSettingsDlgHolder)
+ MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
+ MESSAGE_HANDLER(WM_NOTIFY, OnNotify)
+ MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
+ MESSAGE_HANDLER(PSM_CHANGED, OnSettingsChanged)
+ END_MSG_MAP()
+protected:
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
+ LRESULT OnNotify(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
+ LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
+ LRESULT OnSettingsChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
+private:
+ void OnNotifyParents(LPNMHDR lpnmhdr, int nCode);
+private:
+ bool m_bTabSelected;
+public:
+ static BOOL CALLBACK FakeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+protected:
+ CTabCtrl m_tabCtrl; /// holder of all settings dlg
+ CStatic m_statusMsg;
+ COptionsDlg m_generalOpt; /// general options dlg
+public:
+ bool m_bDestroying;
+};
|