summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-04-02 00:03:12 +0200
committerCarl Hetherington <cth@carlh.net>2022-04-02 00:03:12 +0200
commit8c39f950ec8f8b3cf4d258279ab499d7e71dafc8 (patch)
treec75cd9ee31eb3af1df7b48f66e28a9749fc81fa9
parentbd5c164496bcb86c41ae8ac42241a652ee3a1b14 (diff)
Add button to send test emails in the mail server prefs (#2216).
-rw-r--r--src/wx/full_config_dialog.cc37
-rw-r--r--src/wx/send_test_email_dialog.cc36
-rw-r--r--src/wx/send_test_email_dialog.h45
-rw-r--r--src/wx/wscript1
4 files changed, 119 insertions, 0 deletions
diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc
index 127ca4129..1c14ad35c 100644
--- a/src/wx/full_config_dialog.cc
+++ b/src/wx/full_config_dialog.cc
@@ -39,12 +39,14 @@
#include "nag_dialog.h"
#include "name_format_editor.h"
#include "password_entry.h"
+#include "send_test_email_dialog.h"
#include "server_dialog.h"
#include "static_text.h"
#include "wx_util.h"
#include "lib/config.h"
#include "lib/cross.h"
#include "lib/dcp_content_type.h"
+#include "lib/emailer.h"
#include "lib/exceptions.h"
#include "lib/filter.h"
#include "lib/log.h"
@@ -762,11 +764,16 @@ private:
_password = new PasswordEntry (_panel);
table->Add (_password->get_panel(), 1, wxEXPAND | wxALL);
+ table->AddSpacer (0);
+ _send_test_email = new Button (_panel, _("Send test email..."));
+ table->Add (_send_test_email);
+
_server->Bind (wxEVT_TEXT, boost::bind(&EmailPage::server_changed, this));
_port->Bind (wxEVT_SPINCTRL, boost::bind(&EmailPage::port_changed, this));
_protocol->Bind (wxEVT_CHOICE, boost::bind(&EmailPage::protocol_changed, this));
_user->Bind (wxEVT_TEXT, boost::bind(&EmailPage::user_changed, this));
_password->Changed.connect (boost::bind(&EmailPage::password_changed, this));
+ _send_test_email->Bind (wxEVT_BUTTON, boost::bind(&EmailPage::send_test_email_clicked, this));
}
void config_changed ()
@@ -831,11 +838,41 @@ private:
Config::instance()->set_mail_password(_password->get());
}
+ void send_test_email_clicked ()
+ {
+ auto dialog = new SendTestEmailDialog(_panel);
+ auto result = dialog->ShowModal();
+ dialog->Destroy();
+ if (result == wxID_OK) {
+ Emailer emailer(
+ wx_to_std(dialog->from()),
+ { wx_to_std(dialog->to()) },
+ wx_to_std(_("DCP-o-matic test email")),
+ wx_to_std(_("This is a test email from DCP-o-matic."))
+ );
+ auto config = Config::instance();
+ try {
+ emailer.send (config->mail_server(), config->mail_port(), config->mail_protocol(), config->mail_user(), config->mail_password());
+ } catch (NetworkError& e) {
+ error_dialog (_panel, std_to_wx(e.summary()), std_to_wx(e.detail().get_value_or("")));
+ return;
+ } catch (std::exception& e) {
+ error_dialog (_panel, _("Test email sending failed."), std_to_wx(e.what()));
+ return;
+ } catch (...) {
+ error_dialog (_panel, _("Test email sending failed."));
+ return;
+ }
+ message_dialog (_panel, _("Test email sent."));
+ }
+ }
+
wxTextCtrl* _server;
wxSpinCtrl* _port;
wxChoice* _protocol;
wxTextCtrl* _user;
PasswordEntry* _password;
+ Button* _send_test_email;
};
diff --git a/src/wx/send_test_email_dialog.cc b/src/wx/send_test_email_dialog.cc
new file mode 100644
index 000000000..f9acb382e
--- /dev/null
+++ b/src/wx/send_test_email_dialog.cc
@@ -0,0 +1,36 @@
+/*
+ Copyright (C) 2022 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic 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 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "send_test_email_dialog.h"
+
+
+SendTestEmailDialog::SendTestEmailDialog (wxWindow* parent)
+ : TableDialog (parent, _("Send test email"), 2, 1, true)
+{
+ add (_("From address"), true);
+ _from = add (new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(300, -1)));
+ add (_("To address"), true);
+ _to = add (new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(300, -1)));
+
+ layout ();
+}
+
+
diff --git a/src/wx/send_test_email_dialog.h b/src/wx/send_test_email_dialog.h
new file mode 100644
index 000000000..fa47160e9
--- /dev/null
+++ b/src/wx/send_test_email_dialog.h
@@ -0,0 +1,45 @@
+/*
+ Copyright (C) 2022 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic 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 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "table_dialog.h"
+
+
+class wxTextCtrl;
+
+
+class SendTestEmailDialog : public TableDialog
+{
+public:
+ SendTestEmailDialog (wxWindow* parent);
+
+ wxString from () const {
+ return _from->GetValue();
+ }
+
+ wxString to () const {
+ return _to->GetValue();
+ }
+
+private:
+ wxTextCtrl* _from;
+ wxTextCtrl* _to;
+};
+
diff --git a/src/wx/wscript b/src/wx/wscript
index d2e16c2fe..e000a9ed8 100644
--- a/src/wx/wscript
+++ b/src/wx/wscript
@@ -129,6 +129,7 @@ sources = """
screens_panel.cc
self_dkdm_dialog.cc
send_i18n_dialog.cc
+ send_test_email_dialog.cc
server_dialog.cc
servers_list_dialog.cc
simple_video_view.cc