diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-05-27 23:05:29 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-05-27 23:05:46 +0100 |
| commit | 2115fca942897260bb338c8093ada5186d9b775d (patch) | |
| tree | 2dfbfdc6e6749fa6125e31feb95158cf1723d5f2 | |
| parent | 1158dd504d0838b0c359b2cf1d63615c4ecb0a53 (diff) | |
Add missing icons and make emailing work.
| -rw-r--r-- | graphics/osx/preferences/notifications.png | bin | 0 -> 1809 bytes | |||
| -rw-r--r-- | graphics/src/notifications.svg | 138 | ||||
| -rw-r--r-- | src/lib/send_notification_email_job.cc | 79 | ||||
| -rw-r--r-- | src/lib/send_notification_email_job.h | 34 | ||||
| -rw-r--r-- | src/lib/wscript | 1 | ||||
| -rw-r--r-- | src/wx/job_view.cc | 11 |
6 files changed, 261 insertions, 2 deletions
diff --git a/graphics/osx/preferences/notifications.png b/graphics/osx/preferences/notifications.png Binary files differnew file mode 100644 index 000000000..564f82b18 --- /dev/null +++ b/graphics/osx/preferences/notifications.png diff --git a/graphics/src/notifications.svg b/graphics/src/notifications.svg new file mode 100644 index 000000000..e88a0ae20 --- /dev/null +++ b/graphics/src/notifications.svg @@ -0,0 +1,138 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + id="svg5816" + viewBox="0 0 48 48" + sodipodi:version="0.32" + inkscape:output_extension="org.inkscape.output.svg.inkscape" + inkscape:version="0.92.3 (2405546, 2018-03-11)" + sodipodi:docname="notifications.svg" + version="1.1"> + <defs + id="defs3"> + <linearGradient + id="linearGradient2152"> + <stop + id="stop2154" + style="stop-color:#9aa29a" + offset="0" /> + <stop + id="stop2156" + style="stop-color:#b5beb5" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3601" + y2="613.94" + gradientUnits="userSpaceOnUse" + x2="385.04001" + gradientTransform="matrix(0.04860254,-0.04951283,0.04860254,0.04951283,-9.7664634,27.282)" + y1="63.870998" + x1="386.39001"> + <stop + id="stop3797" + stop-color="#ffe800" + offset="0" /> + <stop + id="stop3799" + stop-color="#dfb300" + offset="1" /> + </linearGradient> + </defs> + <sodipodi:namedview + id="base" + bordercolor="#666666" + inkscape:window-x="0" + inkscape:window-y="27" + pagecolor="#ffffff" + inkscape:grid-bbox="true" + inkscape:zoom="5.6568542" + inkscape:pageshadow="2" + showgrid="false" + borderopacity="1.0" + inkscape:current-layer="layer1" + inkscape:cx="14.465598" + inkscape:cy="3.1824916" + inkscape:window-width="1366" + inkscape:pageopacity="0.0" + inkscape:window-height="704" + inkscape:document-units="px" + inkscape:snap-global="false" + inkscape:window-maximized="1" /> + <g + id="layer1" + inkscape:label="Layer 1" + inkscape:groupmode="layer"> + <circle + style="fill:#cccccc;stroke:#808080;stroke-width:1.72725451;stroke-miterlimit:4;stroke-dasharray:none" + id="path11817" + cx="24" + cy="24" + r="21.526354" /> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;font-size:47.65264893px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:#808080;stroke-width:1.19131637;" + x="14.448529" + y="41.369484" + id="text11793"><tspan + sodipodi:role="line" + id="tspan11791" + x="14.448529" + y="41.369484" + style="fill:#ffffff;stroke:#808080;stroke-width:1.19131637;">!</tspan></text> + </g> + <metadata + id="metadata53"> + <rdf:RDF> + <cc:Work> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <cc:license + rdf:resource="http://creativecommons.org/licenses/publicdomain/" /> + <dc:publisher> + <cc:Agent + rdf:about="http://openclipart.org/"> + <dc:title>Openclipart</dc:title> + </cc:Agent> + </dc:publisher> + <dc:title></dc:title> + <dc:date>2010-03-29T08:04:16</dc:date> + <dc:description>"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></dc:description> + <dc:source>https://openclipart.org/detail/35215/tango-internet-mail-by-warszawianka</dc:source> + <dc:creator> + <cc:Agent> + <dc:title>warszawianka</dc:title> + </cc:Agent> + </dc:creator> + <dc:subject> + <rdf:Bag> + <rdf:li>email</rdf:li> + <rdf:li>envelope</rdf:li> + <rdf:li>externalsource</rdf:li> + <rdf:li>icon</rdf:li> + <rdf:li>letter</rdf:li> + <rdf:li>tango</rdf:li> + </rdf:Bag> + </dc:subject> + </cc:Work> + <cc:License + rdf:about="http://creativecommons.org/licenses/publicdomain/"> + <cc:permits + rdf:resource="http://creativecommons.org/ns#Reproduction" /> + <cc:permits + rdf:resource="http://creativecommons.org/ns#Distribution" /> + <cc:permits + rdf:resource="http://creativecommons.org/ns#DerivativeWorks" /> + </cc:License> + </rdf:RDF> + </metadata> +</svg> 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 <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_notification_email_job.h" +#include "exceptions.h" +#include "config.h" +#include "emailer.h" +#include "compose.hpp" +#include <boost/foreach.hpp> +#include <list> + +#include "i18n.h" + +using std::string; +using std::list; +using boost::shared_ptr; + +/** @param body Email body */ +SendNotificationEmailJob::SendNotificationEmailJob (string body) + : Job (shared_ptr<Film>()) + , _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<string> 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 <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 "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 <wx/wx.h> using std::string; using std::min; using boost::shared_ptr; using boost::bind; +using boost::dynamic_pointer_cast; JobView::JobView (shared_ptr<Job> 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<TranscodeJob>(_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<Job> (new SendNotificationEmailJob (body))); } } } |
