summaryrefslogtreecommitdiff
path: root/protocols/NewsAggregator/Src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-06-04 17:03:28 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-06-04 17:03:28 +0300
commitf531ff887729783a7fe7a3e12ad12f658eefc7b0 (patch)
tree9e1844429448b6527ef7ca87163e44eafce250d8 /protocols/NewsAggregator/Src
parent1c2e5d128a7176ae827dda1e2a8fcc64e772a148 (diff)
UI classes:
- CDlgBase::m_bSucceeded variable introduced to check whether IDOK was pressed or not; - unused/useless buttons with id=IDOK or IDCANCEL removed; - brnOk.OnClick replaced with OnApply calls; - unused/useless calls of EndDialog/EndModal removed; - minor code cleaning
Diffstat (limited to 'protocols/NewsAggregator/Src')
-rw-r--r--protocols/NewsAggregator/Src/Authentication.cpp16
-rw-r--r--protocols/NewsAggregator/Src/Options.cpp38
-rw-r--r--protocols/NewsAggregator/Src/Options.h25
3 files changed, 36 insertions, 43 deletions
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