Send alarm notifications via e-mail. More...
#include <emailsender.h>
Public Member Functions | |
~EMailSender () | |
Destructor. | |
EMailSender (const EMailSender &other) | |
Copy constructor (deleted). | |
EMailSender (EMailSender &&other) | |
Move constructor (C++11, deleted). | |
EMailSender & | operator= (const EMailSender &other) |
Copy assignment (deleted). | |
EMailSender & | operator= (EMailSender &&other) |
Move assignment (C++11, deleted). | |
Static Public Member Functions | |
static EMailSender & | instance () noexcept |
Get singleton instance. | |
static void | sendAlarmNotification (const std::vector< AlarmStatusEntry > alarms) noexcept |
Send an alarm notification via e-mail. | |
Private Member Functions | |
EMailSender () | |
Constructor. | |
void | sendAlarmNotification_internal (const std::vector< AlarmStatusEntry > alarms) |
Compose and send the e-mail notification. | |
QString | composeMessageText (const std::vector< AlarmStatusEntry > &alarms) |
Compose message text. |
Send alarm notifications via e-mail.
This class encapsulates the code that produces an e-mail notification that can be sent to a mailing list to inform the staff about an alarm that occured while nobody was in the laboratory.
The actual SMTP client work is done by the classes of the SmtpClient-for-Qt project, The code has been written by "bluetiger9" on GitHub and is available here: https://www.github.com/bluetiger9/SmtpClient-for-Qt. It is licensed unter the GNU Lesser General Public License, version 2.1.
The task of this class is to compose the message text and instruct the SmtpClient properly to have the e-mail sent. The parameters for the connection to the SMTP server are read from the AlarmConfiguration class.
Definition at line 57 of file emailsender.h.
EMailSender::EMailSender | ( | ) | [private] |
EMailSender::~EMailSender | ( | ) |
AlarmNotifications::EMailSender::EMailSender | ( | const EMailSender & | other | ) |
Copy constructor (deleted).
This class cannot be copied.
other | Another instance of EMailSender |
AlarmNotifications::EMailSender::EMailSender | ( | EMailSender && | other | ) |
Move constructor (C++11, deleted).
This class cannot be moved.
other | Another instance of EMailSender |
QString EMailSender::composeMessageText | ( | const std::vector< AlarmStatusEntry > & | alarms | ) | [private] |
Compose message text.
This method creates the text to be put into the body of the alarm notification e-mail.
alarms | Alarm to be listed in the e-mail |
Definition at line 123 of file emailsender.cpp.
EMailSender & EMailSender::instance | ( | ) | [static] |
Get singleton instance.
Returns a reference (not a pointer) to the single global instance of this class.
Definition at line 47 of file emailsender.cpp.
EMailSender& AlarmNotifications::EMailSender::operator= | ( | EMailSender && | other | ) |
Move assignment (C++11, deleted).
This class cannot be moved.
other | Another instance of EMailSender |
EMailSender& AlarmNotifications::EMailSender::operator= | ( | const EMailSender & | other | ) |
Copy assignment (deleted).
This class cannot be copied.
other | Another instance of EMailSender |
void EMailSender::sendAlarmNotification | ( | const std::vector< AlarmStatusEntry > | alarms | ) | [static] |
Send an alarm notification via e-mail.
This static method gets a reference to the global instance of EMailSender and invokes sendAlarmNotification_internal() to send an e-mail to tell the staff about the alarms.
alarms | Alarms to be listed in the e-mail |
Definition at line 53 of file emailsender.cpp.
void EMailSender::sendAlarmNotification_internal | ( | const std::vector< AlarmStatusEntry > | alarms | ) | [private] |
Compose and send the e-mail notification.
This method is invoked by sendAlarmNotification() and does the actual work. It reads the necessary configuration parameters, creates a connection to the SMTP server, assembles the e-mail message and sends it.
alarms | Alarms to be listed in the e-mail |
Definition at line 78 of file emailsender.cpp.