From 2115fca942897260bb338c8093ada5186d9b775d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 27 May 2018 23:05:29 +0100 Subject: [PATCH] Add missing icons and make emailing work. --- graphics/osx/preferences/notifications.png | Bin 0 -> 1809 bytes graphics/src/notifications.svg | 138 +++++++++++++++++++++ src/lib/send_notification_email_job.cc | 79 ++++++++++++ src/lib/send_notification_email_job.h | 34 +++++ src/lib/wscript | 1 + src/wx/job_view.cc | 11 +- 6 files changed, 261 insertions(+), 2 deletions(-) create mode 100644 graphics/osx/preferences/notifications.png create mode 100644 graphics/src/notifications.svg create mode 100644 src/lib/send_notification_email_job.cc create mode 100644 src/lib/send_notification_email_job.h diff --git a/graphics/osx/preferences/notifications.png b/graphics/osx/preferences/notifications.png new file mode 100644 index 0000000000000000000000000000000000000000..564f82b18b2b83bfa4e0962847bce90dfa20eebf GIT binary patch literal 1809 zcma)+d0Z1`8pnr#kb=Mp)>NeI5Lo3f2Uu(fK>@=RZcHn9lqSOjhLB7$Ga*f6g;k*- zQe0740gshpmc;<|pv42EC{S3zZWk1=9L5TsxCK#8JBj^ckAFI!&ol45&phuu-{<$d z^A^U(hTB>@SpxuI8yUe*BuCI_R7>)XYqitlV1b833aR9kO-(Hz=kF*Yl5ujlYc#Wt z(@lEPxta(~BDSIuLM_5zK&@6Y5xEqHL<*RRVrdo6c}`@IqcJF0MWmw`K*r%(ks1-n zrK07{QDp#N=4O1&hj9o)6a<3G0eUDyCPFglAOfLsP=cW{kS7AuF<25vPbUZkm&GDP z@-&nw!C*KQ#-#+RFs5S(jouXUQ$|lpJcee#5JBGrn*89ebCAapZ33-#%6VdJlhMe> zt%w|g!7LcV$^0Oj$zl4l|7Vqv1qaD0!FZK86M;ZJN`3Q%Z8^ZpNH!L{8#QfYMK}V|TYLsgW28)cVK_Mc80bjNc zo59||@bwq6Ib8M!T%U~ydLxGnj(gi56$Zh8Q97K|4pqQ%C=*eLFv6r-Dol`Svo`qo z`uM#SmVw9#7?Z<u=V! zy7s0o5r<0dUUzJ;Q(k`9<12NViW z_DSof8W-z4iX<(qTTt@{`sLK28B}J@`2s&)Pl_M$3>i7c?pM0GlvIRJldVV^sh}p^-NFCjgP{XqRp1$>Cw#{8^d*;u^|eo@ zX6@d;&R$Lsgz!Dc+z)7Df3i92Y0`_^7q+SH-zWsf7oIr*D^yndta{`4ve|84zkcKd zYDFN0F9m*vx{xF(6FxB0yc4zYP zmPN$d2mfR@@Sc#S}+J z$4yi>%R-z^F~SX}&3!NiWC#uoX-4+De4!ozd8IZF$r)z#H%&iJ{iDrg&=JvkhB z@7ivf!C*+*v7@bKtM2hrfhWmYURf#RPZ!FDVlV8BW3)JTXi9xH()UjY+#SgO;ryik z*k$Iiva+w&l;&kXzKvx$wff`(_{on2*X|7rB-?%7)*A02+^5_{d-CK-QgZS@_Vh$T zF5Vo(KU~l}(llyk(XchK%L2+gy*;|p@`bo>dcV)HDc + + + + + + + + + + + + + + + + + ! + + + + + image/svg+xml + + + + + Openclipart + + + + 2010-03-29T08:04:16 + "E-mail" icon from <a href="http://tango.freedesktop.org/Tango_Desktop_Project"> Tango Project </a> \n<br><br> \nSince version 0.8.90 Tango Project icons are Public Domain: <a href="http://tango.freedesktop.org/Frequently_Asked_Questions#Terms_of_Use.3F"> Tango Project FAQ </a> + https://openclipart.org/detail/35215/tango-internet-mail-by-warszawianka + + + warszawianka + + + + + email + envelope + externalsource + icon + letter + tango + + + + + + + + + + + diff --git a/src/lib/send_notification_email_job.cc b/src/lib/send_notification_email_job.cc new file mode 100644 index 000000000..6d7882e71 --- /dev/null +++ b/src/lib/send_notification_email_job.cc @@ -0,0 +1,79 @@ +/* + Copyright (C) 2018 Carl Hetherington + + 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 . + +*/ + +#include "send_notification_email_job.h" +#include "exceptions.h" +#include "config.h" +#include "emailer.h" +#include "compose.hpp" +#include +#include + +#include "i18n.h" + +using std::string; +using std::list; +using boost::shared_ptr; + +/** @param body Email body */ +SendNotificationEmailJob::SendNotificationEmailJob (string body) + : Job (shared_ptr()) + , _body (body) +{ + +} + +string +SendNotificationEmailJob::name () const +{ + return _("Email notification"); +} + +string +SendNotificationEmailJob::json_name () const +{ + return N_("send_notification_email"); +} + +void +SendNotificationEmailJob::run () +{ + Config* config = Config::instance (); + + if (config->mail_server().empty()) { + throw NetworkError (_("No mail server configured in preferences")); + } + + set_progress_unknown (); + list to; + to.push_back (config->notification_to ()); + Emailer email (config->notification_from(), to, config->notification_subject(), _body); + BOOST_FOREACH (string i, config->notification_cc()) { + email.add_cc (i); + } + if (!config->notification_bcc().empty()) { + email.add_bcc (config->notification_bcc ()); + } + + email.send (config->mail_server(), config->mail_port(), config->mail_user(), config->mail_password()); + + set_progress (1); + set_state (FINISHED_OK); +} diff --git a/src/lib/send_notification_email_job.h b/src/lib/send_notification_email_job.h new file mode 100644 index 000000000..f6ca3fbd6 --- /dev/null +++ b/src/lib/send_notification_email_job.h @@ -0,0 +1,34 @@ +/* + Copyright (C) 2018 Carl Hetherington + + 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 . + +*/ + +#include "job.h" + +class SendNotificationEmailJob : public Job +{ +public: + SendNotificationEmailJob (std::string body); + + std::string name () const; + std::string json_name () const; + void run (); + +private: + std::string _body; +}; diff --git a/src/lib/wscript b/src/lib/wscript index 9e7d83903..b6784dbaa 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -127,6 +127,7 @@ sources = """ screen.cc screen_kdm.cc send_kdm_email_job.cc + send_notification_email_job.cc send_problem_report_job.cc server.cc shuffler.cc diff --git a/src/wx/job_view.cc b/src/wx/job_view.cc index acf42bc8b..9a1a12ca7 100644 --- a/src/wx/job_view.cc +++ b/src/wx/job_view.cc @@ -21,14 +21,18 @@ #include "job_view.h" #include "wx_util.h" #include "lib/job.h" +#include "lib/job_manager.h" #include "lib/compose.hpp" #include "lib/config.h" +#include "lib/send_notification_email_job.h" +#include "lib/transcode_job.h" #include using std::string; using std::min; using boost::shared_ptr; using boost::bind; +using boost::dynamic_pointer_cast; JobView::JobView (shared_ptr job, wxWindow* parent, wxWindow* container, wxFlexGridSizer* table) : _job (job) @@ -129,12 +133,15 @@ JobView::finished () _details->Enable (true); } - if (_notify->GetValue()) { + if (dynamic_pointer_cast(_job) && _notify->GetValue()) { if (Config::instance()->notification(Config::MESSAGE_BOX)) { wxMessageBox (std_to_wx(_job->name() + ": " + _job->status()), _("DCP-o-matic"), wxICON_INFORMATION); } if (Config::instance()->notification(Config::EMAIL)) { - + string body = Config::instance()->notification_email(); + boost::algorithm::replace_all (body, "$JOB_NAME", _job->name()); + boost::algorithm::replace_all (body, "$JOB_STATUS", _job->status()); + JobManager::instance()->add (shared_ptr (new SendNotificationEmailJob (body))); } } } -- 2.30.2