diff --git a/src/librssguard/miscellaneous/databasequeries.cpp b/src/librssguard/miscellaneous/databasequeries.cpp index 69078b6c5..d44beb68a 100755 --- a/src/librssguard/miscellaneous/databasequeries.cpp +++ b/src/librssguard/miscellaneous/databasequeries.cpp @@ -1954,16 +1954,27 @@ bool DatabaseQueries::editStandardFeed(const QSqlDatabase& db, int parent_id, in } bool DatabaseQueries::editBaseFeed(const QSqlDatabase& db, int feed_id, Feed::AutoUpdateType auto_update_type, - int auto_update_interval) { + int auto_update_interval, bool is_protected, const QString& username, + const QString& password) { QSqlQuery q(db); q.setForwardOnly(true); q.prepare("UPDATE Feeds " - "SET update_type = :update_type, update_interval = :update_interval " + "SET update_type = :update_type, update_interval = :update_interval, protected = :protected, username = :username, password = :password " "WHERE id = :id;"); q.bindValue(QSL(":update_type"), (int) auto_update_type); q.bindValue(QSL(":update_interval"), auto_update_interval); q.bindValue(QSL(":id"), feed_id); + q.bindValue(QSL(":protected"), is_protected ? 1 : 0); + q.bindValue(QSL(":username"), username); + + if (password.isEmpty()) { + q.bindValue(QSL(":password"), password); + } + else { + q.bindValue(QSL(":password"), TextFactory::encrypt(password)); + } + return q.exec(); } diff --git a/src/librssguard/miscellaneous/databasequeries.h b/src/librssguard/miscellaneous/databasequeries.h index 17bb69da2..3a7b4220c 100644 --- a/src/librssguard/miscellaneous/databasequeries.h +++ b/src/librssguard/miscellaneous/databasequeries.h @@ -96,7 +96,9 @@ class DatabaseQueries { static bool cleanFeeds(const QSqlDatabase& db, const QStringList& ids, bool clean_read_only, int account_id); static bool storeAccountTree(const QSqlDatabase& db, RootItem* tree_root, int account_id); static bool editBaseFeed(const QSqlDatabase& db, int feed_id, - Feed::AutoUpdateType auto_update_type, int auto_update_interval); + Feed::AutoUpdateType auto_update_type, int auto_update_interval, + bool is_protected, const QString& username, + const QString& password); template static Assignment getCategories(const QSqlDatabase& db, int account_id, bool* ok = nullptr); @@ -200,18 +202,8 @@ void DatabaseQueries::fillFeedData(T* feed, const QSqlRecord& sql_record) { template<> inline void DatabaseQueries::fillFeedData(StandardFeed* feed, const QSqlRecord& sql_record) { - StandardFeed::Type type = static_cast(sql_record.value(FDS_DB_TYPE_INDEX).toInt()); - - switch (type) { - case StandardFeed::Type::Atom10: - case StandardFeed::Type::Rdf: - case StandardFeed::Type::Rss0X: - case StandardFeed::Type::Rss2X: - case StandardFeed::Type::Json: { - feed->setType(type); - break; - } - } + Q_UNUSED(feed) + Q_UNUSED(sql_record) } template diff --git a/src/librssguard/services/abstract/feed.cpp b/src/librssguard/services/abstract/feed.cpp index 25d793b0b..304a6511c 100755 --- a/src/librssguard/services/abstract/feed.cpp +++ b/src/librssguard/services/abstract/feed.cpp @@ -46,6 +46,16 @@ Feed::Feed(const QSqlRecord& record) : Feed(nullptr) { setAutoUpdateType(static_cast(record.value(FDS_DB_UPDATE_TYPE_INDEX).toInt())); setAutoUpdateInitialInterval(record.value(FDS_DB_UPDATE_INTERVAL_INDEX).toInt()); + setPasswordProtected(record.value(FDS_DB_PROTECTED_INDEX).toBool()); + setUsername(record.value(FDS_DB_USERNAME_INDEX).toString()); + + if (record.value(FDS_DB_PASSWORD_INDEX).toString().isEmpty()) { + setPassword(record.value(FDS_DB_PASSWORD_INDEX).toString()); + } + else { + setPassword(TextFactory::decrypt(record.value(FDS_DB_PASSWORD_INDEX).toString())); + } + qDebugNN << LOGSEC_CORE << "Custom ID of feed when loading from DB is" << QUOTE_W_SPACE_DOT(customId()); @@ -160,9 +170,14 @@ bool Feed::editViaGui() { bool Feed::editItself(Feed* new_feed_data) { QSqlDatabase database = qApp->database()->connection(metaObject()->className()); - // TODO: aby editbasefeed editoval i http/basic autentizační data. if (DatabaseQueries::editBaseFeed(database, id(), new_feed_data->autoUpdateType(), - new_feed_data->autoUpdateInitialInterval())) { + new_feed_data->autoUpdateInitialInterval(), + new_feed_data->passwordProtected(), + new_feed_data->username(), + new_feed_data->password())) { + setPasswordProtected(new_feed_data->passwordProtected()); + setUsername(new_feed_data->username()); + setPassword(new_feed_data->password()); setAutoUpdateType(new_feed_data->autoUpdateType()); setAutoUpdateInitialInterval(new_feed_data->autoUpdateInitialInterval()); return true; @@ -234,6 +249,8 @@ bool Feed::cleanMessages(bool clean_read_only) { } QList Feed::obtainNewMessages(bool* error_during_obtaining) { + Q_UNUSED(error_during_obtaining) + return {}; } diff --git a/src/librssguard/services/abstract/gui/formfeeddetails.cpp b/src/librssguard/services/abstract/gui/formfeeddetails.cpp index d197d2f05..b313778fd 100644 --- a/src/librssguard/services/abstract/gui/formfeeddetails.cpp +++ b/src/librssguard/services/abstract/gui/formfeeddetails.cpp @@ -40,6 +40,10 @@ int FormFeedDetails::editBaseFeed(Feed* input_feed) { return QDialog::exec(); } +void FormFeedDetails::activateTab(int index) { + m_ui->m_tabWidget->setCurrentIndex(index); +} + void FormFeedDetails::insertCustomTab(QWidget* custom_tab, const QString& title, int index) { m_ui->m_tabWidget->insertTab(index, custom_tab, title); } diff --git a/src/librssguard/services/abstract/gui/formfeeddetails.h b/src/librssguard/services/abstract/gui/formfeeddetails.h index 2429de385..15345b832 100644 --- a/src/librssguard/services/abstract/gui/formfeeddetails.h +++ b/src/librssguard/services/abstract/gui/formfeeddetails.h @@ -27,6 +27,7 @@ class FormFeedDetails : public QDialog { int editBaseFeed(Feed* input_feed); protected slots: + void activateTab(int index); void insertCustomTab(QWidget* custom_tab, const QString& title, int index); // Applies changes. diff --git a/src/librssguard/services/standard/gui/formstandardfeeddetails.cpp b/src/librssguard/services/standard/gui/formstandardfeeddetails.cpp index 2b767be6f..acc8319db 100644 --- a/src/librssguard/services/standard/gui/formstandardfeeddetails.cpp +++ b/src/librssguard/services/standard/gui/formstandardfeeddetails.cpp @@ -18,6 +18,7 @@ FormStandardFeedDetails::FormStandardFeedDetails(ServiceRoot* service_root, QWidget* parent) : FormFeedDetails(service_root, parent), m_standardFeedDetails(new StandardFeedDetails(this)) { insertCustomTab(m_standardFeedDetails, tr("General"), 0); + activateTab(0); m_standardFeedDetails->ui->m_txtTitle->lineEdit()->setPlaceholderText(tr("Feed title")); m_standardFeedDetails->ui->m_txtTitle->lineEdit()->setToolTip(tr("Set title for your feed.")); diff --git a/src/librssguard/services/standard/standardfeed.cpp b/src/librssguard/services/standard/standardfeed.cpp index ede0b9edb..44af3ba9d 100644 --- a/src/librssguard/services/standard/standardfeed.cpp +++ b/src/librssguard/services/standard/standardfeed.cpp @@ -474,17 +474,19 @@ QNetworkReply::NetworkError StandardFeed::networkError() const { StandardFeed::StandardFeed(const QSqlRecord& record) : Feed(record) { setEncoding(record.value(FDS_DB_ENCODING_INDEX).toString()); - setPasswordProtected(record.value(FDS_DB_PROTECTED_INDEX).toBool()); - setUsername(record.value(FDS_DB_USERNAME_INDEX).toString()); - if (record.value(FDS_DB_PASSWORD_INDEX).toString().isEmpty()) { - setPassword(record.value(FDS_DB_PASSWORD_INDEX).toString()); - } - else { - setPassword(TextFactory::decrypt(record.value(FDS_DB_PASSWORD_INDEX).toString())); + StandardFeed::Type type = static_cast(record.value(FDS_DB_TYPE_INDEX).toInt()); + + switch (type) { + case StandardFeed::Type::Atom10: + case StandardFeed::Type::Rdf: + case StandardFeed::Type::Rss0X: + case StandardFeed::Type::Rss2X: + case StandardFeed::Type::Json: { + setType(type); + break; + } } - setAutoUpdateType(static_cast(record.value(FDS_DB_UPDATE_TYPE_INDEX).toInt())); - setAutoUpdateInitialInterval(record.value(FDS_DB_UPDATE_INTERVAL_INDEX).toInt()); m_networkError = QNetworkReply::NoError; }