Browse Source

Delete old RSS cookies dialog

adaptive-webui-19844
Vladimir Golovnev (Glassez) 9 years ago
parent
commit
c193d448d8
  1. 110
      src/gui/rss/cookiesdlg.cpp
  2. 62
      src/gui/rss/cookiesdlg.h
  3. 172
      src/gui/rss/cookiesdlg.ui
  4. 5
      src/gui/rss/rss.pri
  5. 5
      src/gui/rss/rss.ui
  6. 23
      src/gui/rss/rss_imp.cpp
  7. 1
      src/gui/rss/rss_imp.h

110
src/gui/rss/cookiesdlg.cpp

@ -1,110 +0,0 @@ @@ -1,110 +0,0 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2010 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org arnaud@qbittorrent.org
*/
#include "cookiesdlg.h"
#include "ui_cookiesdlg.h"
#include "guiiconprovider.h"
#include "base/net/downloadmanager.h"
#include <QNetworkCookie>
#include <QDateTime>
enum CookiesCols { COOKIE_KEY, COOKIE_VALUE};
CookiesDlg::CookiesDlg(const QUrl &url, QWidget *parent) :
QDialog(parent),
ui(new Ui::CookiesDlg)
{
ui->setupUi(this);
// Icons
ui->add_btn->setIcon(GuiIconProvider::instance()->getIcon("list-add"));
ui->del_btn->setIcon(GuiIconProvider::instance()->getIcon("list-remove"));
ui->infos_lbl->setText(tr("Common keys for cookies are: '%1', '%2'.\nYou should get this information from your Web browser preferences.").arg("uid").arg("pass"));
QList<QNetworkCookie> cookies = Net::DownloadManager::instance()->cookiesForUrl(url);
foreach (const QNetworkCookie &cookie, cookies) {
const int i = ui->cookiesTable->rowCount();
ui->cookiesTable->setRowCount(i+1);
ui->cookiesTable->setItem(i, COOKIE_KEY, new QTableWidgetItem(QString(cookie.name())));
ui->cookiesTable->setItem(i, COOKIE_VALUE, new QTableWidgetItem(QString(cookie.value())));
}
}
CookiesDlg::~CookiesDlg()
{
delete ui;
}
void CookiesDlg::on_add_btn_clicked() {
ui->cookiesTable->setRowCount(ui->cookiesTable->rowCount()+1);
// Edit first column
ui->cookiesTable->editItem(ui->cookiesTable->item(ui->cookiesTable->rowCount()-1, COOKIE_KEY));
}
void CookiesDlg::on_del_btn_clicked() {
// Get selected cookie
QList<QTableWidgetItem*> selection = ui->cookiesTable->selectedItems();
if (!selection.isEmpty()) {
ui->cookiesTable->removeRow(selection.first()->row());
}
}
QList<QNetworkCookie> CookiesDlg::getCookies() const {
QList<QNetworkCookie> ret;
auto now = QDateTime::currentDateTime();
for (int i=0; i<ui->cookiesTable->rowCount(); ++i) {
QString key;
if (ui->cookiesTable->item(i, COOKIE_KEY))
key = ui->cookiesTable->item(i, COOKIE_KEY)->text().trimmed();
QString value;
if (ui->cookiesTable->item(i, COOKIE_VALUE))
value = ui->cookiesTable->item(i, COOKIE_VALUE)->text().trimmed();
if (!key.isEmpty() && !value.isEmpty()) {
QNetworkCookie cookie(key.toUtf8(), value.toUtf8());
// TODO: Delete this hack when advanced Cookie dialog will be implemented.
cookie.setExpirationDate(now.addYears(10));
qDebug("Cookie: %s", cookie.toRawForm().data());
ret << cookie;
}
}
return ret;
}
bool CookiesDlg::askForCookies(QWidget *parent, const QUrl &url, QList<QNetworkCookie> &out)
{
CookiesDlg dlg(url, parent);
if (dlg.exec()) {
out = dlg.getCookies();
return true;
}
return false;
}

62
src/gui/rss/cookiesdlg.h

@ -1,62 +0,0 @@ @@ -1,62 +0,0 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2010 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org arnaud@qbittorrent.org
*/
#ifndef COOKIESDLG_H
#define COOKIESDLG_H
#include <QDialog>
#include <QList>
class QNetworkCookie;
class QUrl;
namespace Ui {
class CookiesDlg;
}
class CookiesDlg : public QDialog
{
Q_OBJECT
public:
explicit CookiesDlg(const QUrl &url, QWidget *parent = 0);
~CookiesDlg();
QList<QNetworkCookie> getCookies() const;
static bool askForCookies(QWidget *parent, const QUrl &url, QList<QNetworkCookie> &out);
protected slots:
void on_add_btn_clicked();
void on_del_btn_clicked();
private:
Ui::CookiesDlg *ui;
};
#endif // COOKIESDLG_H

172
src/gui/rss/cookiesdlg.ui

@ -1,172 +0,0 @@ @@ -1,172 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CookiesDlg</class>
<widget class="QDialog" name="CookiesDlg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Cookies management</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTableWidget" name="cookiesTable">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string extracomment="As in Key/Value pair">Key</string>
</property>
</column>
<column>
<property name="text">
<string extracomment="As in Key/Value pair">Value</string>
</property>
</column>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="add_btn">
<property name="text">
<string notr="true"/>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="del_btn">
<property name="text">
<string notr="true"/>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="infos_lbl">
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>CookiesDlg</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>CookiesDlg</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

5
src/gui/rss/rss.pri

@ -4,17 +4,14 @@ HEADERS += $$PWD/rss_imp.h \ @@ -4,17 +4,14 @@ HEADERS += $$PWD/rss_imp.h \
$$PWD/rsssettingsdlg.h \
$$PWD/feedlistwidget.h \
$$PWD/automatedrssdownloader.h \
$$PWD/cookiesdlg.h \
$$PWD/htmlbrowser.h
SOURCES += $$PWD/rss_imp.cpp \
$$PWD/rsssettingsdlg.cpp \
$$PWD/feedlistwidget.cpp \
$$PWD/automatedrssdownloader.cpp \
$$PWD/cookiesdlg.cpp \
$$PWD/htmlbrowser.cpp
FORMS += $$PWD/rss.ui \
$$PWD/rsssettingsdlg.ui \
$$PWD/automatedrssdownloader.ui \
$$PWD/cookiesdlg.ui
$$PWD/automatedrssdownloader.ui

5
src/gui/rss/rss.ui

@ -197,11 +197,6 @@ @@ -197,11 +197,6 @@
<string>New folder...</string>
</property>
</action>
<action name="actionManage_cookies">
<property name="text">
<string>Manage cookies...</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

23
src/gui/rss/rss_imp.cpp

@ -41,7 +41,6 @@ @@ -41,7 +41,6 @@
#include "feedlistwidget.h"
#include "base/bittorrent/session.h"
#include "base/net/downloadmanager.h"
#include "cookiesdlg.h"
#include "base/preferences.h"
#include "rsssettingsdlg.h"
#include "base/rss/rssmanager.h"
@ -84,8 +83,6 @@ void RSSImp::displayRSSListMenu(const QPoint& pos) @@ -84,8 +83,6 @@ void RSSImp::displayRSSListMenu(const QPoint& pos)
myRSSListMenu.addSeparator();
if (m_feedList->isFolder(selectedItems.first()))
myRSSListMenu.addAction(actionNew_folder);
else
myRSSListMenu.addAction(actionManage_cookies);
}
}
else {
@ -138,25 +135,6 @@ void RSSImp::displayItemsListMenu(const QPoint&) @@ -138,25 +135,6 @@ void RSSImp::displayItemsListMenu(const QPoint&)
myItemListMenu.exec(QCursor::pos());
}
void RSSImp::on_actionManage_cookies_triggered()
{
Q_ASSERT(!m_feedList->selectedItems().empty());
// TODO: Create advanced application wide Cookie dialog and use it everywhere.
QUrl feedUrl = QUrl::fromEncoded(m_feedList->getItemID(m_feedList->selectedItems().first()).toUtf8());
QList<QNetworkCookie> cookies;
if (CookiesDlg::askForCookies(this, feedUrl, cookies)) {
auto downloadManager = Net::DownloadManager::instance();
QList<QNetworkCookie> oldCookies = downloadManager->cookiesForUrl(feedUrl);
foreach (const QNetworkCookie &oldCookie, oldCookies) {
if (!cookies.contains(oldCookie))
downloadManager->deleteCookie(oldCookie);
}
downloadManager->setCookiesFromUrl(cookies, feedUrl);
}
}
void RSSImp::askNewFolder()
{
QTreeWidgetItem* parent_item = 0;
@ -713,7 +691,6 @@ RSSImp::RSSImp(QWidget *parent): @@ -713,7 +691,6 @@ RSSImp::RSSImp(QWidget *parent):
actionCopy_feed_URL->setIcon(GuiIconProvider::instance()->getIcon("edit-copy"));
actionDelete->setIcon(GuiIconProvider::instance()->getIcon("edit-delete"));
actionDownload_torrent->setIcon(GuiIconProvider::instance()->getIcon("download"));
actionManage_cookies->setIcon(GuiIconProvider::instance()->getIcon("preferences-web-browser-cookies"));
actionMark_items_read->setIcon(GuiIconProvider::instance()->getIcon("mail-mark-read"));
actionNew_folder->setIcon(GuiIconProvider::instance()->getIcon("folder-new"));
actionNew_subscription->setIcon(GuiIconProvider::instance()->getIcon("list-add"));

1
src/gui/rss/rss_imp.h

@ -84,7 +84,6 @@ private slots: @@ -84,7 +84,6 @@ private slots:
void askNewFolder();
void saveFoldersOpenState();
void loadFoldersOpenState();
void on_actionManage_cookies_triggered();
void on_settingsButton_clicked();
void on_rssDownloaderBtn_clicked();

Loading…
Cancel
Save