1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

FlashCookieManager: Operate on PepperFlash cookies

This commit is contained in:
David Rosca 2016-12-24 00:23:44 +01:00
parent 6117f468f4
commit 5d2ffc30d1
5 changed files with 8 additions and 114 deletions

View File

@ -65,13 +65,11 @@ FCM_Dialog::FCM_Dialog(FCM_Plugin* manager, QWidget* parent)
connect(ui->autoMode, SIGNAL(toggled(bool)), ui->notification, SLOT(setEnabled(bool))); connect(ui->autoMode, SIGNAL(toggled(bool)), ui->notification, SLOT(setEnabled(bool)));
connect(ui->autoMode, SIGNAL(toggled(bool)), ui->labelNotification, SLOT(setEnabled(bool))); connect(ui->autoMode, SIGNAL(toggled(bool)), ui->labelNotification, SLOT(setEnabled(bool)));
connect(ui->browseFlashDataPath, SIGNAL(clicked()), this, SLOT(selectFlashDataPath()));
ui->autoMode->setChecked(m_manager->readSettings().value(QL1S("autoMode")).toBool()); ui->autoMode->setChecked(m_manager->readSettings().value(QL1S("autoMode")).toBool());
ui->notification->setEnabled(m_manager->readSettings().value(QL1S("autoMode")).toBool()); ui->notification->setEnabled(m_manager->readSettings().value(QL1S("autoMode")).toBool());
ui->notification->setChecked(m_manager->readSettings().value(QL1S("notification")).toBool()); ui->notification->setChecked(m_manager->readSettings().value(QL1S("notification")).toBool());
ui->deleteAllOnStartExit->setChecked(m_manager->readSettings().value(QL1S("deleteAllOnStartExit")).toBool()); ui->deleteAllOnStartExit->setChecked(m_manager->readSettings().value(QL1S("deleteAllOnStartExit")).toBool());
ui->flashDataPath->setText(m_manager->flashPlayerDataPath());
ui->labelNotification->setEnabled(ui->autoMode->isChecked()); ui->labelNotification->setEnabled(ui->autoMode->isChecked());
@ -370,14 +368,6 @@ void FCM_Dialog::reloadFromDisk()
refreshView(true); refreshView(true);
} }
void FCM_Dialog::selectFlashDataPath()
{
QString path = QzTools::getExistingDirectory(QL1S("FCM_Plugin_FlashDataPath"), this, tr("Select Flash Data Path"), ui->flashDataPath->text());
if (!path.isEmpty()) {
ui->flashDataPath->setText(path);
}
}
void FCM_Dialog::cookieTreeContextMenuRequested(const QPoint &pos) void FCM_Dialog::cookieTreeContextMenuRequested(const QPoint &pos)
{ {
QMenu menu; QMenu menu;
@ -426,12 +416,6 @@ void FCM_Dialog::closeEvent(QCloseEvent* e)
settingsHash.insert(QL1S("notification"), QVariant(ui->notification->isChecked())); settingsHash.insert(QL1S("notification"), QVariant(ui->notification->isChecked()));
settingsHash.insert(QL1S("flashCookiesWhitelist"), flashWhitelist); settingsHash.insert(QL1S("flashCookiesWhitelist"), flashWhitelist);
settingsHash.insert(QL1S("flashCookiesBlacklist"), flashBlacklist); settingsHash.insert(QL1S("flashCookiesBlacklist"), flashBlacklist);
QString path = ui->flashDataPath->text();
path.replace(QL1C('\\'), QL1C('/'));
settingsHash.insert(QL1S("flashDataPath"), path);
m_manager->writeSettings(settingsHash); m_manager->writeSettings(settingsHash);
e->accept(); e->accept();

View File

@ -66,7 +66,6 @@ private slots:
void filterString(const QString &string); void filterString(const QString &string);
void reloadFromDisk(); void reloadFromDisk();
void selectFlashDataPath();
void cookieTreeContextMenuRequested(const QPoint &pos); void cookieTreeContextMenuRequested(const QPoint &pos);
private: private:

View File

@ -454,7 +454,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0"> <item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QCheckBox" name="autoMode"> <widget class="QCheckBox" name="autoMode">
@ -484,14 +484,14 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="19" column="0"> <item row="16" column="0">
<widget class="QDialogButtonBox" name="close3"> <widget class="QDialogButtonBox" name="close3">
<property name="standardButtons"> <property name="standardButtons">
<set>QDialogButtonBox::Close</set> <set>QDialogButtonBox::Close</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="17" column="0"> <item row="14" column="0">
<spacer name="verticalSpacer_3"> <spacer name="verticalSpacer_3">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -504,7 +504,7 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="18" column="0"> <item row="15" column="0">
<widget class="QLabel" name="label_19"> <widget class="QLabel" name="label_19">
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Note:&lt;/span&gt; This settings are just applied to flash cookies, to manage HTTP cookies use &lt;span style=&quot; font-weight:600;&quot;&gt;Cookies Manager&lt;/span&gt;. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Note:&lt;/span&gt; This settings are just applied to flash cookies, to manage HTTP cookies use &lt;span style=&quot; font-weight:600;&quot;&gt;Cookies Manager&lt;/span&gt;. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@ -517,7 +517,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="0"> <item row="6" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<widget class="QCheckBox" name="notification"> <widget class="QCheckBox" name="notification">
@ -544,7 +544,7 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="16" column="0"> <item row="13" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
<widget class="QCheckBox" name="deleteAllOnStartExit"> <widget class="QCheckBox" name="deleteAllOnStartExit">
@ -571,56 +571,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Flash data path*:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="flashDataPath"/>
</item>
<item>
<widget class="QPushButton" name="browseFlashDataPath">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="7" column="0">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>*: You should select directory that contains #SharedObject as a subfolder.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>

View File

@ -23,6 +23,7 @@
#include "clickablelabel.h" #include "clickablelabel.h"
#include "tabbedwebview.h" #include "tabbedwebview.h"
#include "fcm_notification.h" #include "fcm_notification.h"
#include "datapaths.h"
#include <QStatusBar> #include <QStatusBar>
#include <QTimer> #include <QTimer>
@ -157,43 +158,6 @@ void FCM_Plugin::clearCache()
m_flashCookies.clear(); m_flashCookies.clear();
} }
QString FCM_Plugin::flashDataPathForOS() const
{
/* On Microsoft Windows NT 5.x and 6.x, they are stored in:
* %APPDATA%\Macromedia\Flash Player\#SharedObjects\
* %APPDATA%\Macromedia\Flash Player\macromedia.com\support\flashplayer\sys\
* On Mac OS X, they are stored in:
* ~/Library/Preferences/Macromedia/Flash Player/#SharedObjects/
* ~/Library/Preferences/Macromedia/Flash Player/macromedia.com/support/flashplayer/sys/
* On Linux or Unix, they are stored in:
* ~/.macromedia/Flash_Player/#SharedObjects/
* ~/.macromedia/Flash_Player/macromedia.com/support/flashplayer/sys/
* For Linux and Unix systems, if the open-source Gnash plugin is being used
* instead of the official Adobe Flash, they will instead be found at:
* ~/.gnash/SharedObjects/
*/
if (m_flashDataPathForOS.isEmpty()) {
#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
QString appData = QProcessEnvironment::systemEnvironment().value(QL1S("APPDATA"));
appData.replace(QL1C('\\'), QL1C('/'));
m_flashDataPathForOS = (appData + QL1S("/Macromedia/Flash Player"));
#elif defined(Q_OS_MAC)
m_flashDataPathForOS = QDir::homePath() + QL1S("/Library/Preferences/Macromedia/Flash Player");
#else
if (QDir::home().cd(QL1S(".macromedia"))) {
m_flashDataPathForOS = QDir::homePath() + QL1S("/.macromedia/Flash_Player");
}
else {
m_flashDataPathForOS = QDir::homePath() + QL1S("/.gnash");
}
#endif
}
return m_flashDataPathForOS;
}
bool FCM_Plugin::isBlacklisted(const FlashCookie &flashCookie) bool FCM_Plugin::isBlacklisted(const FlashCookie &flashCookie)
{ {
return readSettings().value(QL1S("flashCookiesBlacklist")).toStringList().contains(flashCookie.origin); return readSettings().value(QL1S("flashCookiesBlacklist")).toStringList().contains(flashCookie.origin);
@ -228,7 +192,7 @@ QString FCM_Plugin::sharedObjectDirName() const
QString FCM_Plugin::flashPlayerDataPath() const QString FCM_Plugin::flashPlayerDataPath() const
{ {
return readSettings().value(QL1S("flashDataPath")).toString(); return DataPaths::currentProfilePath() + QSL("/Pepper Data/Shockwave Flash/WritableRoot/");
} }
QVariantHash FCM_Plugin::readSettings() const QVariantHash FCM_Plugin::readSettings() const
@ -239,7 +203,6 @@ QVariantHash FCM_Plugin::readSettings() const
m_settingsHash.insert(QL1S("notification"), QVariant(false)); m_settingsHash.insert(QL1S("notification"), QVariant(false));
m_settingsHash.insert(QL1S("flashCookiesWhitelist"), QVariant()); m_settingsHash.insert(QL1S("flashCookiesWhitelist"), QVariant());
m_settingsHash.insert(QL1S("flashCookiesBlacklist"), QVariant()); m_settingsHash.insert(QL1S("flashCookiesBlacklist"), QVariant());
m_settingsHash.insert(QL1S("flashDataPath"), flashDataPathForOS());
QSettings settings(m_settingsPath + QL1S("/extensions.ini"), QSettings::IniFormat); QSettings settings(m_settingsPath + QL1S("/extensions.ini"), QSettings::IniFormat);
settings.beginGroup(QL1S("FlashCookieManager")); settings.beginGroup(QL1S("FlashCookieManager"));

View File

@ -84,7 +84,6 @@ private:
void loadFlashCookies(QString path); void loadFlashCookies(QString path);
void insertFlashCookie(QString path); void insertFlashCookie(QString path);
QString extractOriginFrom(const QString &path); QString extractOriginFrom(const QString &path);
QString flashDataPathForOS() const;
bool isBlacklisted(const FlashCookie &flashCookie); bool isBlacklisted(const FlashCookie &flashCookie);
bool isWhitelisted(const FlashCookie &flashCookie); bool isWhitelisted(const FlashCookie &flashCookie);
void removeAllButWhitelisted(); void removeAllButWhitelisted();
@ -104,7 +103,6 @@ private:
QStringList m_blaklist; QStringList m_blaklist;
QStringList m_whitelist; QStringList m_whitelist;
QStringList m_newCookiesList; QStringList m_newCookiesList;
mutable QString m_flashDataPathForOS;
}; };
Q_DECLARE_METATYPE(FlashCookie); Q_DECLARE_METATYPE(FlashCookie);