Falkon Develop
Cross-platform Qt-based web browser
fcm_plugin.h
Go to the documentation of this file.
1/* ============================================================
2* FlashCookieManager plugin for Falkon
3* Copyright (C) 2014 S. Razi Alavizadeh <s.r.alavizadeh@gmail.com>
4* Copyright (C) 2018 David Rosca <nowrep@gmail.com>
5*
6* This program is free software: you can redistribute it and/or modify
7* it under the terms of the GNU General Public License as published by
8* the Free Software Foundation, either version 3 of the License, or
9* (at your option) any later version.
10*
11* This program is distributed in the hope that it will be useful,
12* but WITHOUT ANY WARRANTY; without even the implied warranty of
13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14* GNU General Public License for more details.
15*
16* You should have received a copy of the GNU General Public License
17* along with this program. If not, see <http://www.gnu.org/licenses/>.
18* ============================================================ */
19#ifndef FLASHCOOKIEMANAGER_H
20#define FLASHCOOKIEMANAGER_H
21
22#include "plugininterface.h"
23
24#include <QPointer>
25#include <QDateTime>
26
27class BrowserWindow;
28class FCM_Dialog;
29class QTimer;
31
33 QString name;
34 QString origin;
35 int size;
36 QString path;
37 QString contents;
39
40 bool operator ==(const FlashCookie &other) const {
41 return (this->name == other.name && this->path == other.path);
42 }
43};
44
45class FCM_Plugin : public QObject, public PluginInterface
46{
47 Q_OBJECT
48 Q_INTERFACES(PluginInterface)
49 Q_PLUGIN_METADATA(IID "Falkon.Browser.plugin.FlashCookieManager" FILE "flashcookiemanager.json")
50
51public:
52 explicit FCM_Plugin();
53
54 void init(InitState state, const QString &settingsPath) override;
55 void unload() override;
56 bool testPlugin() override;
57 void showSettings(QWidget *parent) override;
58
59 void populateExtensionsMenu(QMenu *menu) override;
60
61 void setFlashCookies(const QList<FlashCookie> &flashCookies);
62 QList<FlashCookie> flashCookies();
63 QStringList newCookiesList();
64 void clearNewOrigins();
65 void clearCache();
66 QString flashPlayerDataPath() const;
67 QVariantHash readSettings() const;
68 void writeSettings(const QVariantHash &hashSettings);
69
70 void removeCookie(const FlashCookie &flashCookie);
71
72private Q_SLOTS:
73 void autoRefresh();
74 void showFlashCookieManager();
75 void mainWindowCreated(BrowserWindow* window);
76 void mainWindowDeleted(BrowserWindow* window);
77 void startStopTimer();
78
79private:
80 AbstractButtonInterface* createStatusBarIcon(BrowserWindow* mainWindow);
81 void loadFlashCookies();
82 void loadFlashCookies(QString path);
83 void insertFlashCookie(const QString &path);
84 QString extractOriginFrom(const QString &path);
85 bool isBlacklisted(const FlashCookie &flashCookie);
86 bool isWhitelisted(const FlashCookie &flashCookie);
87 void removeAllButWhitelisted();
88 QString sharedObjectDirName() const;
89
90 QHash<BrowserWindow*, AbstractButtonInterface*> m_statusBarIcons;
91 QPointer<FCM_Dialog> m_fcmDialog;
92
93 QString m_settingsPath;
94 QList<FlashCookie> m_flashCookies;
95 QTimer* m_timer;
96
97 mutable QVariantHash m_settingsHash;
98 bool m_autoMode;
99 bool m_deleteOnClose;
100 bool m_enableNotification;
101 QStringList m_blacklist;
102 QStringList m_whitelist;
103 QStringList m_newCookiesList;
104};
105
107#endif // FLASHCOOKIEMANAGER_H
void unload() override
Definition: fcm_plugin.cpp:96
bool testPlugin() override
Definition: fcm_plugin.cpp:114
void clearCache()
Definition: fcm_plugin.cpp:157
void init(InitState state, const QString &settingsPath) override
Definition: fcm_plugin.cpp:68
QStringList newCookiesList()
Definition: fcm_plugin.cpp:147
QVariantHash readSettings() const
Definition: fcm_plugin.cpp:199
void clearNewOrigins()
Definition: fcm_plugin.cpp:152
void showSettings(QWidget *parent) override
Definition: fcm_plugin.cpp:119
void populateExtensionsMenu(QMenu *menu) override
Definition: fcm_plugin.cpp:127
void removeCookie(const FlashCookie &flashCookie)
Definition: fcm_plugin.cpp:239
QString flashPlayerDataPath() const
Definition: fcm_plugin.cpp:194
QList< FlashCookie > flashCookies()
Definition: fcm_plugin.cpp:139
void setFlashCookies(const QList< FlashCookie > &flashCookies)
Definition: fcm_plugin.cpp:134
void writeSettings(const QVariantHash &hashSettings)
Definition: fcm_plugin.cpp:222
Q_DECLARE_METATYPE(FlashCookie)
State state