mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-10-22 10:46:04 +03:00
Add button for sending test email
This allows for easily testing whether the provided email configuration is correct. PR #20488.
This commit is contained in:
parent
1702b6c891
commit
c06817f4eb
9 changed files with 67 additions and 1 deletions
|
@ -680,6 +680,24 @@ void Application::sendNotificationEmail(const BitTorrent::Torrent *torrent)
|
||||||
content);
|
content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::sendTestEmail() const
|
||||||
|
{
|
||||||
|
const Preferences *pref = Preferences::instance();
|
||||||
|
if (pref->isMailNotificationEnabled())
|
||||||
|
{
|
||||||
|
// Prepare mail content
|
||||||
|
const QString content = tr("This is a test email.") + u'\n'
|
||||||
|
+ tr("Thank you for using qBittorrent.") + u'\n';
|
||||||
|
|
||||||
|
// Send the notification email
|
||||||
|
auto *smtp = new Net::Smtp();
|
||||||
|
smtp->sendMail(pref->getMailNotificationSender(),
|
||||||
|
pref->getMailNotificationEmail(),
|
||||||
|
tr("Test email"),
|
||||||
|
content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Application::torrentAdded(const BitTorrent::Torrent *torrent) const
|
void Application::torrentAdded(const BitTorrent::Torrent *torrent) const
|
||||||
{
|
{
|
||||||
const Preferences *pref = Preferences::instance();
|
const Preferences *pref = Preferences::instance();
|
||||||
|
|
|
@ -127,6 +127,8 @@ public:
|
||||||
int memoryWorkingSetLimit() const override;
|
int memoryWorkingSetLimit() const override;
|
||||||
void setMemoryWorkingSetLimit(int size) override;
|
void setMemoryWorkingSetLimit(int size) override;
|
||||||
|
|
||||||
|
void sendTestEmail() const override;
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
MemoryPriority processMemoryPriority() const override;
|
MemoryPriority processMemoryPriority() const override;
|
||||||
void setProcessMemoryPriority(MemoryPriority priority) override;
|
void setProcessMemoryPriority(MemoryPriority priority) override;
|
||||||
|
|
|
@ -83,6 +83,8 @@ public:
|
||||||
virtual int memoryWorkingSetLimit() const = 0;
|
virtual int memoryWorkingSetLimit() const = 0;
|
||||||
virtual void setMemoryWorkingSetLimit(int size) = 0;
|
virtual void setMemoryWorkingSetLimit(int size) = 0;
|
||||||
|
|
||||||
|
virtual void sendTestEmail() const = 0;
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
virtual MemoryPriority processMemoryPriority() const = 0;
|
virtual MemoryPriority processMemoryPriority() const = 0;
|
||||||
virtual void setProcessMemoryPriority(MemoryPriority priority) = 0;
|
virtual void setProcessMemoryPriority(MemoryPriority priority) = 0;
|
||||||
|
|
|
@ -707,6 +707,11 @@ void OptionsDialog::loadDownloadsTabOptions()
|
||||||
connect(m_ui->groupMailNotifAuth, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
connect(m_ui->groupMailNotifAuth, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||||||
connect(m_ui->mailNotifUsername, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
connect(m_ui->mailNotifUsername, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||||||
connect(m_ui->mailNotifPassword, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
connect(m_ui->mailNotifPassword, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||||||
|
connect(m_ui->sendTestEmail, &QPushButton::clicked, this, [this]
|
||||||
|
{
|
||||||
|
app()->sendTestEmail();
|
||||||
|
QMessageBox::information(this, tr("Test email"), tr("Attempted to send email. Check your inbox to confirm success"));
|
||||||
|
});
|
||||||
|
|
||||||
connect(m_ui->groupBoxRunOnAdded, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
connect(m_ui->groupBoxRunOnAdded, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||||||
connect(m_ui->lineEditRunOnAdded, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
connect(m_ui->lineEditRunOnAdded, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||||||
|
|
|
@ -1566,6 +1566,19 @@ readme[0-9].txt: filter 'readme1.txt', 'readme2.txt' but not 'readme10.txt'.</st
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="sendTestEmail">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Send test email</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -3935,6 +3948,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string>
|
||||||
<tabstop>groupMailNotifAuth</tabstop>
|
<tabstop>groupMailNotifAuth</tabstop>
|
||||||
<tabstop>mailNotifUsername</tabstop>
|
<tabstop>mailNotifUsername</tabstop>
|
||||||
<tabstop>mailNotifPassword</tabstop>
|
<tabstop>mailNotifPassword</tabstop>
|
||||||
|
<tabstop>sendTestEmail</tabstop>
|
||||||
<tabstop>checkSmtpSSL</tabstop>
|
<tabstop>checkSmtpSSL</tabstop>
|
||||||
<tabstop>lineEditRunOnAdded</tabstop>
|
<tabstop>lineEditRunOnAdded</tabstop>
|
||||||
<tabstop>lineEditRunOnFinished</tabstop>
|
<tabstop>lineEditRunOnFinished</tabstop>
|
||||||
|
|
|
@ -1107,6 +1107,11 @@ void AppController::defaultSavePathAction()
|
||||||
setResult(BitTorrent::Session::instance()->savePath().toString());
|
setResult(BitTorrent::Session::instance()->savePath().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppController::sendTestEmailAction()
|
||||||
|
{
|
||||||
|
app()->sendTestEmail();
|
||||||
|
}
|
||||||
|
|
||||||
void AppController::networkInterfaceListAction()
|
void AppController::networkInterfaceListAction()
|
||||||
{
|
{
|
||||||
QJsonArray ifaceList;
|
QJsonArray ifaceList;
|
||||||
|
|
|
@ -48,6 +48,7 @@ private slots:
|
||||||
void preferencesAction();
|
void preferencesAction();
|
||||||
void setPreferencesAction();
|
void setPreferencesAction();
|
||||||
void defaultSavePathAction();
|
void defaultSavePathAction();
|
||||||
|
void sendTestEmailAction();
|
||||||
|
|
||||||
void networkInterfaceListAction();
|
void networkInterfaceListAction();
|
||||||
void networkInterfaceAddressListAction();
|
void networkInterfaceAddressListAction();
|
||||||
|
|
|
@ -149,12 +149,12 @@ private:
|
||||||
const QHash<std::pair<QString, QString>, QString> m_allowedMethod =
|
const QHash<std::pair<QString, QString>, QString> m_allowedMethod =
|
||||||
{
|
{
|
||||||
// <<controller name, action name>, HTTP method>
|
// <<controller name, action name>, HTTP method>
|
||||||
|
{{u"app"_s, u"sendTestEmail"_s}, Http::METHOD_POST},
|
||||||
{{u"app"_s, u"setPreferences"_s}, Http::METHOD_POST},
|
{{u"app"_s, u"setPreferences"_s}, Http::METHOD_POST},
|
||||||
{{u"app"_s, u"shutdown"_s}, Http::METHOD_POST},
|
{{u"app"_s, u"shutdown"_s}, Http::METHOD_POST},
|
||||||
{{u"auth"_s, u"login"_s}, Http::METHOD_POST},
|
{{u"auth"_s, u"login"_s}, Http::METHOD_POST},
|
||||||
{{u"auth"_s, u"logout"_s}, Http::METHOD_POST},
|
{{u"auth"_s, u"logout"_s}, Http::METHOD_POST},
|
||||||
{{u"rss"_s, u"addFeed"_s}, Http::METHOD_POST},
|
{{u"rss"_s, u"addFeed"_s}, Http::METHOD_POST},
|
||||||
{{u"rss"_s, u"setFeedURL"_s}, Http::METHOD_POST},
|
|
||||||
{{u"rss"_s, u"addFolder"_s}, Http::METHOD_POST},
|
{{u"rss"_s, u"addFolder"_s}, Http::METHOD_POST},
|
||||||
{{u"rss"_s, u"markAsRead"_s}, Http::METHOD_POST},
|
{{u"rss"_s, u"markAsRead"_s}, Http::METHOD_POST},
|
||||||
{{u"rss"_s, u"moveItem"_s}, Http::METHOD_POST},
|
{{u"rss"_s, u"moveItem"_s}, Http::METHOD_POST},
|
||||||
|
@ -162,6 +162,7 @@ private:
|
||||||
{{u"rss"_s, u"removeItem"_s}, Http::METHOD_POST},
|
{{u"rss"_s, u"removeItem"_s}, Http::METHOD_POST},
|
||||||
{{u"rss"_s, u"removeRule"_s}, Http::METHOD_POST},
|
{{u"rss"_s, u"removeRule"_s}, Http::METHOD_POST},
|
||||||
{{u"rss"_s, u"renameRule"_s}, Http::METHOD_POST},
|
{{u"rss"_s, u"renameRule"_s}, Http::METHOD_POST},
|
||||||
|
{{u"rss"_s, u"setFeedURL"_s}, Http::METHOD_POST},
|
||||||
{{u"rss"_s, u"setRule"_s}, Http::METHOD_POST},
|
{{u"rss"_s, u"setRule"_s}, Http::METHOD_POST},
|
||||||
{{u"search"_s, u"delete"_s}, Http::METHOD_POST},
|
{{u"search"_s, u"delete"_s}, Http::METHOD_POST},
|
||||||
{{u"search"_s, u"enablePlugin"_s}, Http::METHOD_POST},
|
{{u"search"_s, u"enablePlugin"_s}, Http::METHOD_POST},
|
||||||
|
|
|
@ -263,6 +263,9 @@
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<div class="formRow">
|
||||||
|
<input type="button" id="mail_test_button" value="QBT_TR(Send test email)QBT_TR[CONTEXT=OptionsDialog]" onclick="qBittorrent.Preferences.sendTestEmail();" />
|
||||||
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset class="settings">
|
<fieldset class="settings">
|
||||||
|
@ -1553,6 +1556,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
||||||
changeWatchFolderSelect: changeWatchFolderSelect,
|
changeWatchFolderSelect: changeWatchFolderSelect,
|
||||||
updateMailNotification: updateMailNotification,
|
updateMailNotification: updateMailNotification,
|
||||||
updateMailAuthSettings: updateMailAuthSettings,
|
updateMailAuthSettings: updateMailAuthSettings,
|
||||||
|
sendTestEmail: sendTestEmail,
|
||||||
updateAutoRun: updateAutoRun,
|
updateAutoRun: updateAutoRun,
|
||||||
updateAutoRunOnTorrentAdded: updateAutoRunOnTorrentAdded,
|
updateAutoRunOnTorrentAdded: updateAutoRunOnTorrentAdded,
|
||||||
generateRandomPort: generateRandomPort,
|
generateRandomPort: generateRandomPort,
|
||||||
|
@ -1705,6 +1709,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
||||||
$('smtp_server_txt').setProperty('disabled', !isMailNotificationEnabled);
|
$('smtp_server_txt').setProperty('disabled', !isMailNotificationEnabled);
|
||||||
$('mail_ssl_checkbox').setProperty('disabled', !isMailNotificationEnabled);
|
$('mail_ssl_checkbox').setProperty('disabled', !isMailNotificationEnabled);
|
||||||
$('mail_auth_checkbox').setProperty('disabled', !isMailNotificationEnabled);
|
$('mail_auth_checkbox').setProperty('disabled', !isMailNotificationEnabled);
|
||||||
|
$('mail_test_button').setProperty('disabled', !isMailNotificationEnabled);
|
||||||
|
|
||||||
if (!isMailNotificationEnabled) {
|
if (!isMailNotificationEnabled) {
|
||||||
$('mail_auth_checkbox').setProperty('checked', !isMailNotificationEnabled);
|
$('mail_auth_checkbox').setProperty('checked', !isMailNotificationEnabled);
|
||||||
|
@ -1718,6 +1723,19 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
||||||
$('mail_password_text').setProperty('disabled', !isMailAuthEnabled);
|
$('mail_password_text').setProperty('disabled', !isMailAuthEnabled);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const sendTestEmail = function() {
|
||||||
|
new Request({
|
||||||
|
url: 'api/v2/app/sendTestEmail',
|
||||||
|
method: 'post',
|
||||||
|
onFailure: function() {
|
||||||
|
alert("QBT_TR(Could not contact qBittorrent)QBT_TR[CONTEXT=HttpServer]");
|
||||||
|
},
|
||||||
|
onSuccess: function() {
|
||||||
|
alert("QBT_TR(Attempted to send email. Check your inbox to confirm success)QBT_TR[CONTEXT=OptionsDialog]");
|
||||||
|
}
|
||||||
|
}).send();
|
||||||
|
};
|
||||||
|
|
||||||
const updateAutoRunOnTorrentAdded = function() {
|
const updateAutoRunOnTorrentAdded = function() {
|
||||||
const isAutoRunOnTorrentAddedEnabled = $('autorunOnTorrentAddedCheckbox').getProperty('checked');
|
const isAutoRunOnTorrentAddedEnabled = $('autorunOnTorrentAddedCheckbox').getProperty('checked');
|
||||||
$('autorunOnTorrentAddedProgram').setProperty('disabled', !isAutoRunOnTorrentAddedEnabled);
|
$('autorunOnTorrentAddedProgram').setProperty('disabled', !isAutoRunOnTorrentAddedEnabled);
|
||||||
|
|
Loading…
Reference in a new issue