mirror of
https://github.com/arcan1s/queued.git
synced 2025-07-12 21:35:48 +00:00
use 100 symbols (2)
This commit is contained in:
@ -29,8 +29,7 @@ void QueuedEmailNotify::init(const QVariantHash &_settings)
|
||||
m_helper->setInsecureCurl(_settings.value("InsecureCurl", false).toBool());
|
||||
m_helper->setPassword(_settings.value("Password", "").toString());
|
||||
m_helper->setPort(_settings.value("Port", 465).toInt());
|
||||
m_helper->setServer(
|
||||
_settings.value("Server", "smtp://smtp.example.com").toString());
|
||||
m_helper->setServer(_settings.value("Server", "smtp://smtp.example.com").toString());
|
||||
m_helper->setSslEnabled(_settings.value("UseSSL", false).toBool());
|
||||
m_helper->setUsername(_settings.value("Username", "").toString());
|
||||
}
|
||||
@ -50,14 +49,12 @@ void QueuedEmailNotify::setup(const QueuedPluginManagerInterface *_manager)
|
||||
}
|
||||
|
||||
|
||||
void QueuedEmailNotify::updateSettings(const QString &_key,
|
||||
const QVariant &_value)
|
||||
void QueuedEmailNotify::updateSettings(const QString &_key, const QVariant &_value)
|
||||
{
|
||||
qCDebug(LOG_PL) << "Update settings for" << _key;
|
||||
|
||||
if (!m_helper) {
|
||||
qCWarning(LOG_PL)
|
||||
<< "Helper is not initialized. Did you forget to call ::init()?";
|
||||
qCWarning(LOG_PL) << "Helper is not initialized. Did you forget to call ::init()?";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -44,8 +44,8 @@ char *QueuedEmailNotifyHelper::curlString(const QString &_source)
|
||||
}
|
||||
|
||||
|
||||
size_t QueuedEmailNotifyHelper::curlReadCallback(char *buffer, size_t size,
|
||||
size_t nitems, void *instream)
|
||||
size_t QueuedEmailNotifyHelper::curlReadCallback(char *buffer, size_t size, size_t nitems,
|
||||
void *instream)
|
||||
{
|
||||
// FIXME not really best choice to use here
|
||||
auto text = reinterpret_cast<MailBody *>(instream);
|
||||
@ -206,16 +206,14 @@ void QueuedEmailNotifyHelper::sendEmail(const long long _id)
|
||||
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
|
||||
|
||||
// mail body
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION,
|
||||
&QueuedEmailNotifyHelper::curlReadCallback);
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, &QueuedEmailNotifyHelper::curlReadCallback);
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, &text);
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
|
||||
// send
|
||||
auto res = curl_easy_perform(curl);
|
||||
if (res != CURLE_OK)
|
||||
qCWarning(LOG_PL) << "Could not perform curl action"
|
||||
<< curl_easy_strerror(res);
|
||||
qCWarning(LOG_PL) << "Could not perform curl action" << curl_easy_strerror(res);
|
||||
|
||||
// cleanup
|
||||
curl_slist_free_all(recipients);
|
||||
@ -244,16 +242,13 @@ QString QueuedEmailNotifyHelper::getEmail(const long long _id) const
|
||||
}
|
||||
|
||||
|
||||
QStringList QueuedEmailNotifyHelper::getEmailText(const long long _id,
|
||||
const QString &_to) const
|
||||
QStringList QueuedEmailNotifyHelper::getEmailText(const long long _id, const QString &_to) const
|
||||
{
|
||||
qCDebug(LOG_PL) << "Get email text for user" << _to << "for task" << _id;
|
||||
|
||||
auto now
|
||||
= QDateTime::currentDateTimeUtc().toString(Qt::DateFormat::RFC2822Date);
|
||||
auto now = QDateTime::currentDateTimeUtc().toString(Qt::DateFormat::RFC2822Date);
|
||||
|
||||
return {QString("Date: %1\r\n").arg(now),
|
||||
QString("To: %1\r\n").arg(curlEmail(_to)),
|
||||
return {QString("Date: %1\r\n").arg(now), QString("To: %1\r\n").arg(curlEmail(_to)),
|
||||
QString("From: %1\r\n").arg(curlEmail(from())),
|
||||
// message-id?
|
||||
QString("Subject: %1\r\n").arg("Job %1 done").arg(_id), "\r\n",
|
||||
|
@ -42,8 +42,7 @@ public:
|
||||
virtual ~QueuedEmailNotifyHelper() = default;
|
||||
static QString curlEmail(const QString &_from);
|
||||
static char *curlString(const QString &_source);
|
||||
static size_t curlReadCallback(char *buffer, size_t size, size_t nitems,
|
||||
void *instream);
|
||||
static size_t curlReadCallback(char *buffer, size_t size, size_t nitems, void *instream);
|
||||
// properties
|
||||
QString from() const;
|
||||
bool isInsecureCurl() const;
|
||||
|
Reference in New Issue
Block a user