mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-29 16:49:34 +01:00
Loading/saving of acc-specific proxy settings now works for all account types.
This commit is contained in:
parent
20e16152aa
commit
15eadf188e
@ -518,7 +518,7 @@ void FeedsModel::loadActivatedServiceAccounts() {
|
||||
// Iterate all globally available feed "service plugins".
|
||||
for (const ServiceEntryPoint* entry_point : qApp->feedReader()->feedServices()) {
|
||||
// Load all stored root nodes from the entry point and add those to the model.
|
||||
QList<ServiceRoot*>roots = entry_point->initializeSubtree();
|
||||
QList<ServiceRoot*> roots = entry_point->initializeSubtree();
|
||||
|
||||
for (ServiceRoot* root : roots) {
|
||||
addServiceAccount(root, false);
|
||||
|
@ -20,6 +20,32 @@ NetworkProxyDetails::NetworkProxyDetails(QWidget* parent) : QWidget(parent) {
|
||||
m_ui.m_cmbProxyType->addItem(tr("Http"), QNetworkProxy::ProxyType::HttpProxy);
|
||||
|
||||
displayProxyPassword(Qt::CheckState::Unchecked);
|
||||
|
||||
connect(m_ui.m_cmbProxyType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&NetworkProxyDetails::changed);
|
||||
connect(m_ui.m_txtProxyHost, &QLineEdit::textChanged, this, &NetworkProxyDetails::changed);
|
||||
connect(m_ui.m_txtProxyPassword, &QLineEdit::textChanged, this, &NetworkProxyDetails::changed);
|
||||
connect(m_ui.m_txtProxyUsername, &QLineEdit::textChanged, this, &NetworkProxyDetails::changed);
|
||||
connect(m_ui.m_spinProxyPort, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
|
||||
&NetworkProxyDetails::changed);
|
||||
}
|
||||
|
||||
QNetworkProxy NetworkProxyDetails::proxy() const {
|
||||
QNetworkProxy proxy(static_cast<QNetworkProxy::ProxyType>(m_ui.m_cmbProxyType->currentData().toInt()),
|
||||
m_ui.m_txtProxyHost->text(),
|
||||
m_ui.m_spinProxyPort->value(),
|
||||
m_ui.m_txtProxyUsername->text(),
|
||||
m_ui.m_txtProxyPassword->text());
|
||||
|
||||
return proxy;
|
||||
}
|
||||
|
||||
void NetworkProxyDetails::setProxy(const QNetworkProxy& proxy) {
|
||||
m_ui.m_cmbProxyType->setCurrentIndex(m_ui.m_cmbProxyType->findData(proxy.type()));
|
||||
m_ui.m_txtProxyHost->setText(proxy.hostName());
|
||||
m_ui.m_spinProxyPort->setValue(proxy.port());
|
||||
m_ui.m_txtProxyUsername->setText(proxy.user());
|
||||
m_ui.m_txtProxyPassword->setText(proxy.password());
|
||||
}
|
||||
|
||||
void NetworkProxyDetails::displayProxyPassword(int state) {
|
||||
@ -27,13 +53,14 @@ void NetworkProxyDetails::displayProxyPassword(int state) {
|
||||
m_ui.m_txtProxyPassword->setEchoMode(QLineEdit::EchoMode::Normal);
|
||||
}
|
||||
else {
|
||||
m_ui.m_txtProxyPassword->setEchoMode(QLineEdit::EchoMode::PasswordEchoOnEdit);
|
||||
m_ui.m_txtProxyPassword->setEchoMode(QLineEdit::EchoMode::Password);
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkProxyDetails::onProxyTypeChanged(int index) {
|
||||
const QNetworkProxy::ProxyType selected_type = static_cast<QNetworkProxy::ProxyType>(m_ui.m_cmbProxyType->itemData(index).toInt());
|
||||
const bool is_proxy_selected = selected_type != QNetworkProxy::NoProxy && selected_type != QNetworkProxy::DefaultProxy;
|
||||
const bool is_proxy_selected = selected_type != QNetworkProxy::ProxyType::NoProxy &&
|
||||
selected_type != QNetworkProxy::ProxyType::DefaultProxy;
|
||||
|
||||
m_ui.m_proxyDetails->setEnabled(is_proxy_selected);
|
||||
}
|
||||
|
@ -7,17 +7,25 @@
|
||||
|
||||
#include "ui_networkproxydetails.h"
|
||||
|
||||
#include <QNetworkProxy>
|
||||
|
||||
class NetworkProxyDetails : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NetworkProxyDetails(QWidget* parent = nullptr);
|
||||
|
||||
QNetworkProxy proxy() const;
|
||||
void setProxy(const QNetworkProxy& proxy);
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
|
||||
private slots:
|
||||
void displayProxyPassword(int state);
|
||||
void onProxyTypeChanged(int index);
|
||||
|
||||
public:
|
||||
private:
|
||||
Ui::NetworkProxyDetails m_ui;
|
||||
};
|
||||
|
||||
|
@ -32,13 +32,7 @@ SettingsBrowserMail::SettingsBrowserMail(Settings* settings, QWidget* parent)
|
||||
m_ui->m_listTools->setHeaderLabels(QStringList() << tr("Executable") << tr("Parameters"));
|
||||
m_ui->m_listTools->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
||||
|
||||
connect(m_proxyDetails->m_ui.m_cmbProxyType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&SettingsBrowserMail::dirtifySettings);
|
||||
connect(m_proxyDetails->m_ui.m_txtProxyHost, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings);
|
||||
connect(m_proxyDetails->m_ui.m_txtProxyPassword, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings);
|
||||
connect(m_proxyDetails->m_ui.m_txtProxyUsername, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings);
|
||||
connect(m_proxyDetails->m_ui.m_spinProxyPort, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
|
||||
&SettingsBrowserMail::dirtifySettings);
|
||||
connect(m_proxyDetails, &NetworkProxyDetails::changed, this, &SettingsBrowserMail::dirtifySettings);
|
||||
connect(m_ui->m_grpCustomExternalBrowser, &QGroupBox::toggled, this, &SettingsBrowserMail::dirtifySettings);
|
||||
connect(m_ui->m_grpCustomExternalEmail, &QGroupBox::toggled, this, &SettingsBrowserMail::dirtifySettings);
|
||||
connect(m_ui->m_txtExternalBrowserArguments, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings);
|
||||
@ -159,11 +153,12 @@ void SettingsBrowserMail::loadSettings() {
|
||||
// Load the settings.
|
||||
QNetworkProxy::ProxyType selected_proxy_type = static_cast<QNetworkProxy::ProxyType>(settings()->value(GROUP(Proxy),
|
||||
SETTING(Proxy::Type)).toInt());
|
||||
m_proxyDetails->m_ui.m_cmbProxyType->setCurrentIndex(m_proxyDetails->m_ui.m_cmbProxyType->findData(selected_proxy_type));
|
||||
m_proxyDetails->m_ui.m_txtProxyHost->setText(settings()->value(GROUP(Proxy), SETTING(Proxy::Host)).toString());
|
||||
m_proxyDetails->m_ui.m_txtProxyUsername->setText(settings()->value(GROUP(Proxy), SETTING(Proxy::Username)).toString());
|
||||
m_proxyDetails->m_ui.m_txtProxyPassword->setText(settings()->password(GROUP(Proxy), SETTING(Proxy::Password)).toString());
|
||||
m_proxyDetails->m_ui.m_spinProxyPort->setValue(settings()->value(GROUP(Proxy), SETTING(Proxy::Port)).toInt());
|
||||
|
||||
m_proxyDetails->setProxy(QNetworkProxy(selected_proxy_type,
|
||||
settings()->value(GROUP(Proxy), SETTING(Proxy::Host)).toString(),
|
||||
settings()->value(GROUP(Proxy), SETTING(Proxy::Port)).toInt(),
|
||||
settings()->value(GROUP(Proxy), SETTING(Proxy::Username)).toString(),
|
||||
settings()->password(GROUP(Proxy), SETTING(Proxy::Password)).toString()));
|
||||
|
||||
setExternalTools(ExternalTool::toolsFromSettings());
|
||||
onEndLoadSettings();
|
||||
@ -185,11 +180,14 @@ void SettingsBrowserMail::saveSettings() {
|
||||
settings()->setValue(GROUP(Browser), Browser::CustomExternalEmailExecutable, m_ui->m_txtExternalEmailExecutable->text());
|
||||
settings()->setValue(GROUP(Browser), Browser::CustomExternalEmailArguments, m_ui->m_txtExternalEmailArguments->text());
|
||||
settings()->setValue(GROUP(Browser), Browser::CustomExternalEmailEnabled, m_ui->m_grpCustomExternalEmail->isChecked());
|
||||
settings()->setValue(GROUP(Proxy), Proxy::Type, m_proxyDetails->m_ui.m_cmbProxyType->itemData(m_proxyDetails->m_ui.m_cmbProxyType->currentIndex()));
|
||||
settings()->setValue(GROUP(Proxy), Proxy::Host, m_proxyDetails->m_ui.m_txtProxyHost->text());
|
||||
settings()->setValue(GROUP(Proxy), Proxy::Username, m_proxyDetails->m_ui.m_txtProxyUsername->text());
|
||||
settings()->setPassword(GROUP(Proxy), Proxy::Password, m_proxyDetails->m_ui.m_txtProxyPassword->text());
|
||||
settings()->setValue(GROUP(Proxy), Proxy::Port, m_proxyDetails->m_ui.m_spinProxyPort->value());
|
||||
|
||||
auto proxy = m_proxyDetails->proxy();
|
||||
|
||||
settings()->setValue(GROUP(Proxy), Proxy::Type, int(proxy.type()));
|
||||
settings()->setValue(GROUP(Proxy), Proxy::Host, proxy.hostName());
|
||||
settings()->setValue(GROUP(Proxy), Proxy::Username, proxy.user());
|
||||
settings()->setPassword(GROUP(Proxy), Proxy::Password, proxy.password());
|
||||
settings()->setValue(GROUP(Proxy), Proxy::Port, proxy.port());
|
||||
|
||||
auto tools = externalTools();
|
||||
|
||||
|
@ -1652,6 +1652,29 @@ QStringList DatabaseQueries::customIdsOfMessagesFromFeed(const QSqlDatabase& db,
|
||||
return ids;
|
||||
}
|
||||
|
||||
void DatabaseQueries::fillBaseAccountData(const QSqlDatabase& db, ServiceRoot* account, bool* ok) {
|
||||
QSqlQuery query(db);
|
||||
|
||||
query.prepare(QSL("SELECT * FROM Accounts WHERE id = :id;"));
|
||||
query.bindValue(QSL(":id"), account->accountId());
|
||||
|
||||
bool res = query.exec() && query.next();
|
||||
|
||||
if (res) {
|
||||
QNetworkProxy proxy(QNetworkProxy::ProxyType(query.value(QSL("proxy_type")).toInt()),
|
||||
query.value(QSL("proxy_host")).toString(),
|
||||
query.value(QSL("proxy_port")).toInt(),
|
||||
query.value(QSL("proxy_username")).toString(),
|
||||
TextFactory::decrypt(query.value(QSL("proxy_password")).toString()));
|
||||
|
||||
account->setNetworkProxy(proxy);
|
||||
}
|
||||
|
||||
if (ok != nullptr) {
|
||||
*ok = res;
|
||||
}
|
||||
}
|
||||
|
||||
QList<ServiceRoot*> DatabaseQueries::getOwnCloudAccounts(const QSqlDatabase& db, bool* ok) {
|
||||
QSqlQuery query(db);
|
||||
QList<ServiceRoot*> roots;
|
||||
@ -1668,8 +1691,10 @@ QList<ServiceRoot*> DatabaseQueries::getOwnCloudAccounts(const QSqlDatabase& db,
|
||||
root->network()->setForceServerSideUpdate(query.value(4).toBool());
|
||||
root->network()->setBatchSize(query.value(5).toInt());
|
||||
root->network()->setDownloadOnlyUnreadMessages(query.value(6).toBool());
|
||||
|
||||
root->updateTitle();
|
||||
|
||||
fillBaseAccountData(db, root);
|
||||
|
||||
roots.append(root);
|
||||
}
|
||||
|
||||
@ -1709,8 +1734,10 @@ QList<ServiceRoot*> DatabaseQueries::getTtRssAccounts(const QSqlDatabase& db, bo
|
||||
root->network()->setUrl(query.value(6).toString());
|
||||
root->network()->setForceServerSideUpdate(query.value(7).toBool());
|
||||
root->network()->setDownloadOnlyUnreadMessages(query.value(8).toBool());
|
||||
|
||||
root->updateTitle();
|
||||
|
||||
fillBaseAccountData(db, root);
|
||||
|
||||
roots.append(root);
|
||||
}
|
||||
|
||||
@ -1839,11 +1866,27 @@ int DatabaseQueries::createBaseAccount(const QSqlDatabase& db, const QString& co
|
||||
}
|
||||
|
||||
void DatabaseQueries::editBaseAccount(const QSqlDatabase& db, ServiceRoot* account, bool* ok) {
|
||||
Q_UNUSED(account)
|
||||
Q_UNUSED(ok)
|
||||
Q_UNUSED(db)
|
||||
auto proxy = account->networkProxy();
|
||||
QSqlQuery q(db);
|
||||
|
||||
// TODO: edit proxy etc
|
||||
q.setForwardOnly(true);
|
||||
|
||||
q.prepare(QSL("UPDATE Accounts "
|
||||
"SET proxy_type = :proxy_type, proxy_host = :proxy_host, proxy_port = :proxy_port, "
|
||||
" proxy_username = :proxy_username, proxy_password = :proxy_password "
|
||||
"WHERE id = :id"));
|
||||
q.bindValue(QSL(":proxy_type"), proxy.type());
|
||||
q.bindValue(QSL(":proxy_host"), proxy.hostName());
|
||||
q.bindValue(QSL(":proxy_port"), proxy.port());
|
||||
q.bindValue(QSL(":proxy_username"), proxy.user());
|
||||
q.bindValue(QSL(":proxy_password"), TextFactory::encrypt(proxy.password()));
|
||||
q.bindValue(QSL(":id"), account->accountId());
|
||||
|
||||
bool res = q.exec();
|
||||
|
||||
if (ok != nullptr) {
|
||||
*ok = res;
|
||||
}
|
||||
}
|
||||
|
||||
bool DatabaseQueries::deleteFeed(const QSqlDatabase& db, int feed_custom_id, int account_id) {
|
||||
@ -2289,6 +2332,9 @@ QList<ServiceRoot*> DatabaseQueries::getStandardAccounts(const QSqlDatabase& db,
|
||||
auto* root = new StandardServiceRoot();
|
||||
|
||||
root->setAccountId(q.value(0).toInt());
|
||||
|
||||
fillBaseAccountData(db, root);
|
||||
|
||||
roots.append(root);
|
||||
}
|
||||
|
||||
@ -2418,6 +2464,9 @@ QList<ServiceRoot*> DatabaseQueries::getGmailAccounts(const QSqlDatabase& db, bo
|
||||
root->network()->oauth()->setRedirectUrl(query.value(4).toString());
|
||||
root->network()->setBatchSize(query.value(6).toInt());
|
||||
root->updateTitle();
|
||||
|
||||
fillBaseAccountData(db, root);
|
||||
|
||||
roots.append(root);
|
||||
}
|
||||
|
||||
@ -2516,6 +2565,9 @@ QList<ServiceRoot*> DatabaseQueries::getInoreaderAccounts(const QSqlDatabase& db
|
||||
root->network()->oauth()->setRedirectUrl(query.value(4).toString());
|
||||
root->network()->setBatchSize(query.value(6).toInt());
|
||||
root->updateTitle();
|
||||
|
||||
fillBaseAccountData(db, root);
|
||||
|
||||
roots.append(root);
|
||||
}
|
||||
|
||||
|
@ -88,6 +88,7 @@ class DatabaseQueries {
|
||||
bool* ok = nullptr);
|
||||
|
||||
// Common account methods.
|
||||
static void fillBaseAccountData(const QSqlDatabase& db, ServiceRoot* account, bool* ok = nullptr);
|
||||
static int createBaseAccount(const QSqlDatabase& db, const QString& code, bool* ok = nullptr);
|
||||
static void editBaseAccount(const QSqlDatabase& db, ServiceRoot* account, bool* ok = nullptr);
|
||||
static int updateMessages(QSqlDatabase db, const QList<Message>& messages, const QString& feed_custom_id,
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include "services/abstract/gui/formaccountdetails.h"
|
||||
|
||||
#include "gui/guiutilities.h"
|
||||
#include "gui/networkproxydetails.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "services/abstract/serviceroot.h"
|
||||
@ -34,6 +33,10 @@ void FormAccountDetails::clearTabs() {
|
||||
void FormAccountDetails::setEditableAccount(ServiceRoot* editable_account) {
|
||||
setWindowTitle(tr("Edit account '%1'").arg(editable_account->title()));
|
||||
m_account = editable_account;
|
||||
|
||||
if (m_account != nullptr) {
|
||||
m_proxyDetails->setProxy(m_account->networkProxy());
|
||||
}
|
||||
}
|
||||
|
||||
void FormAccountDetails::createConnections() {
|
||||
|
@ -7,12 +7,12 @@
|
||||
|
||||
#include "ui_formaccountdetails.h"
|
||||
|
||||
#include "gui/networkproxydetails.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "miscellaneous/databasefactory.h"
|
||||
#include "miscellaneous/databasequeries.h"
|
||||
|
||||
class ServiceRoot;
|
||||
class NetworkProxyDetails;
|
||||
|
||||
class FormAccountDetails : public QDialog {
|
||||
Q_OBJECT
|
||||
@ -80,6 +80,8 @@ inline bool FormAccountDetails::applyInternal() {
|
||||
//m_account->setId(m_account->accountId());
|
||||
}
|
||||
|
||||
m_account->setNetworkProxy(m_proxyDetails->proxy());
|
||||
|
||||
// NOTE: We edit account common attributes here directly.
|
||||
DatabaseQueries::editBaseAccount(database, m_account);
|
||||
return creating;
|
||||
|
@ -308,6 +308,14 @@ void ServiceRoot::restoreCustomFeedsData(const QMap<QString, QVariantMap>& data,
|
||||
}
|
||||
}
|
||||
|
||||
QNetworkProxy ServiceRoot::networkProxy() const {
|
||||
return m_networkProxy;
|
||||
}
|
||||
|
||||
void ServiceRoot::setNetworkProxy(const QNetworkProxy& network_proxy) {
|
||||
m_networkProxy = network_proxy;
|
||||
}
|
||||
|
||||
ImportantNode* ServiceRoot::importantNode() const {
|
||||
return m_importantNode;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "core/message.h"
|
||||
|
||||
#include <QNetworkProxy>
|
||||
#include <QPair>
|
||||
|
||||
class FeedsModel;
|
||||
@ -161,6 +162,9 @@ class ServiceRoot : public RootItem {
|
||||
int accountId() const;
|
||||
void setAccountId(int account_id);
|
||||
|
||||
QNetworkProxy networkProxy() const;
|
||||
void setNetworkProxy(const QNetworkProxy& network_proxy);
|
||||
|
||||
// Removes all data associated with this account from DB
|
||||
// and from model.
|
||||
void completelyRemoveAllData();
|
||||
@ -245,6 +249,7 @@ class ServiceRoot : public RootItem {
|
||||
LabelsNode* m_labelsNode;
|
||||
int m_accountId;
|
||||
QList<QAction*> m_serviceMenu;
|
||||
QNetworkProxy m_networkProxy;
|
||||
};
|
||||
|
||||
ServiceRoot::LabelOperation operator|(ServiceRoot::LabelOperation lhs, ServiceRoot::LabelOperation rhs);
|
||||
|
Loading…
x
Reference in New Issue
Block a user