|
|
@ -33,80 +33,68 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "qinisettings.h" |
|
|
|
#include "qinisettings.h" |
|
|
|
|
|
|
|
|
|
|
|
class RssSettings { |
|
|
|
class RssSettings: public QIniSettings{ |
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
public: |
|
|
|
|
|
|
|
RssSettings() : QIniSettings("qBittorrent", "qBittorrent") {} |
|
|
|
|
|
|
|
|
|
|
|
static bool isRSSEnabled() { |
|
|
|
bool isRSSEnabled() const { |
|
|
|
QIniSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
return value(QString::fromUtf8("Preferences/RSS/RSSEnabled"), false).toBool(); |
|
|
|
return settings.value(QString::fromUtf8("Preferences/RSS/RSSEnabled"), false).toBool(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void setRSSEnabled(bool enabled) { |
|
|
|
void setRSSEnabled(bool enabled) { |
|
|
|
QIniSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
setValue(QString::fromUtf8("Preferences/RSS/RSSEnabled"), enabled); |
|
|
|
settings.setValue(QString::fromUtf8("Preferences/RSS/RSSEnabled"), enabled); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static unsigned int getRSSRefreshInterval() { |
|
|
|
unsigned int getRSSRefreshInterval() const { |
|
|
|
QIniSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
return value(QString::fromUtf8("Preferences/RSS/RSSRefresh"), 5).toUInt(); |
|
|
|
return settings.value(QString::fromUtf8("Preferences/RSS/RSSRefresh"), 5).toUInt(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void setRSSRefreshInterval(uint interval) { |
|
|
|
void setRSSRefreshInterval(uint interval) { |
|
|
|
QIniSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
setValue(QString::fromUtf8("Preferences/RSS/RSSRefresh"), interval); |
|
|
|
settings.setValue(QString::fromUtf8("Preferences/RSS/RSSRefresh"), interval); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int getRSSMaxArticlesPerFeed() { |
|
|
|
int getRSSMaxArticlesPerFeed() const { |
|
|
|
QIniSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
return value(QString::fromUtf8("Preferences/RSS/RSSMaxArticlesPerFeed"), 50).toInt(); |
|
|
|
return settings.value(QString::fromUtf8("Preferences/RSS/RSSMaxArticlesPerFeed"), 50).toInt(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void setRSSMaxArticlesPerFeed(int nb) { |
|
|
|
void setRSSMaxArticlesPerFeed(int nb) { |
|
|
|
QIniSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
setValue(QString::fromUtf8("Preferences/RSS/RSSMaxArticlesPerFeed"), nb); |
|
|
|
settings.setValue(QString::fromUtf8("Preferences/RSS/RSSMaxArticlesPerFeed"), nb); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static bool isRssDownloadingEnabled() { |
|
|
|
bool isRssDownloadingEnabled() const { |
|
|
|
QIniSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
return value("Preferences/RSS/RssDownloading", true).toBool(); |
|
|
|
return settings.value("Preferences/RSS/RssDownloading", true).toBool(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void setRssDownloadingEnabled(bool b) { |
|
|
|
void setRssDownloadingEnabled(bool b) { |
|
|
|
QIniSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
setValue("Preferences/RSS/RssDownloading", b); |
|
|
|
settings.setValue("Preferences/RSS/RssDownloading", b); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static QStringList getRssFeedsUrls() { |
|
|
|
QStringList getRssFeedsUrls() const { |
|
|
|
QIniSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
return value("Rss/streamList").toStringList(); |
|
|
|
return settings.value("Rss/streamList").toStringList(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void setRssFeedsUrls(const QStringList &rssFeeds) { |
|
|
|
void setRssFeedsUrls(const QStringList &rssFeeds) { |
|
|
|
QIniSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
setValue("Rss/streamList", rssFeeds); |
|
|
|
settings.setValue("Rss/streamList", rssFeeds); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static QStringList getRssFeedsAliases() { |
|
|
|
QStringList getRssFeedsAliases() const { |
|
|
|
QIniSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
return value("Rss/streamAlias").toStringList(); |
|
|
|
return settings.value("Rss/streamAlias").toStringList(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void setRssFeedsAliases(const QStringList &rssAliases) { |
|
|
|
void setRssFeedsAliases(const QStringList &rssAliases) { |
|
|
|
QIniSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
setValue("Rss/streamAlias", rssAliases); |
|
|
|
settings.setValue("Rss/streamAlias", rssAliases); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static QList<QByteArray> getHostNameCookies(const QString &host_name) { |
|
|
|
QList<QByteArray> getHostNameCookies(const QString &host_name) const { |
|
|
|
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss"); |
|
|
|
QMap<QString, QVariant> hosts_table = value("Rss/hosts_cookies").toMap(); |
|
|
|
QMap<QString, QVariant> hosts_table = qBTRSS.value("hosts_cookies", QMap<QString, QVariant>()).toMap(); |
|
|
|
|
|
|
|
if(!hosts_table.contains(host_name)) return QList<QByteArray>(); |
|
|
|
if(!hosts_table.contains(host_name)) return QList<QByteArray>(); |
|
|
|
QByteArray raw_cookies = hosts_table.value(host_name).toByteArray(); |
|
|
|
QByteArray raw_cookies = hosts_table.value(host_name).toByteArray(); |
|
|
|
return raw_cookies.split(':'); |
|
|
|
return raw_cookies.split(':'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void setHostNameCookies(QString host_name, const QList<QByteArray> &cookies) { |
|
|
|
void setHostNameCookies(const QString &host_name, const QList<QByteArray> &cookies) { |
|
|
|
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss"); |
|
|
|
QMap<QString, QVariant> hosts_table = value("Rss/hosts_cookies").toMap(); |
|
|
|
QMap<QString, QVariant> hosts_table = qBTRSS.value("hosts_cookies", QMap<QString, QVariant>()).toMap(); |
|
|
|
|
|
|
|
QByteArray raw_cookies = ""; |
|
|
|
QByteArray raw_cookies = ""; |
|
|
|
foreach(const QByteArray& cookie, cookies) { |
|
|
|
foreach(const QByteArray& cookie, cookies) { |
|
|
|
raw_cookies += cookie + ":"; |
|
|
|
raw_cookies += cookie + ":"; |
|
|
@ -114,7 +102,7 @@ public: |
|
|
|
if(raw_cookies.endsWith(":")) |
|
|
|
if(raw_cookies.endsWith(":")) |
|
|
|
raw_cookies.chop(1); |
|
|
|
raw_cookies.chop(1); |
|
|
|
hosts_table.insert(host_name, raw_cookies); |
|
|
|
hosts_table.insert(host_name, raw_cookies); |
|
|
|
qBTRSS.setValue("hosts_cookies", hosts_table); |
|
|
|
setValue("Rss/hosts_cookies", hosts_table); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|