Added cookie support for RSS feeds (Needs testing)

This commit is contained in:
Christophe Dumez
2010-05-17 14:57:45 +00:00
parent 119bda1595
commit 994c798264
10 changed files with 243 additions and 11 deletions

View File

@@ -951,6 +951,28 @@ public:
}
#endif
static QList<QByteArray> getHostNameCookies(QString host_name) {
QSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QList<QByteArray> ret;
QMap<QString, QVariant> hosts_table = qBTRSS.value("hosts_cookies", QMap<QString, QVariant>()).toMap();
if(!hosts_table.contains(host_name)) return ret;
QByteArray raw_cookies = hosts_table.value(host_name).toByteArray();
return raw_cookies.split(':');
}
static void setHostNameCookies(QString host_name, const QList<QByteArray> &cookies) {
QSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QMap<QString, QVariant> hosts_table = qBTRSS.value("hosts_cookies", QMap<QString, QVariant>()).toMap();
QByteArray raw_cookies = "";
foreach(const QByteArray& cookie, cookies) {
raw_cookies += cookie + ":";
}
if(raw_cookies.endsWith(":"))
raw_cookies.chop(1);
hosts_table.insert(host_name, raw_cookies);
qBTRSS.setValue("hosts_cookies", hosts_table);
}
};
#endif // PREFERENCES_H