File indexing completed on 2024-05-19 04:59:15
0001 /* ============================================================ 0002 * FlashCookieManager plugin for Falkon 0003 * Copyright (C) 2014 S. Razi Alavizadeh <s.r.alavizadeh@gmail.com> 0004 * Copyright (C) 2018 David Rosca <nowrep@gmail.com> 0005 * 0006 * This program is free software: you can redistribute it and/or modify 0007 * it under the terms of the GNU General Public License as published by 0008 * the Free Software Foundation, either version 3 of the License, or 0009 * (at your option) any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public License 0017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0018 * ============================================================ */ 0019 #ifndef FLASHCOOKIEMANAGER_H 0020 #define FLASHCOOKIEMANAGER_H 0021 0022 #include "plugininterface.h" 0023 0024 #include <QPointer> 0025 #include <QDateTime> 0026 0027 class BrowserWindow; 0028 class FCM_Dialog; 0029 class QTimer; 0030 class AbstractButtonInterface; 0031 0032 struct FlashCookie { 0033 QString name; 0034 QString origin; 0035 int size; 0036 QString path; 0037 QString contents; 0038 QDateTime lastModification; 0039 0040 bool operator ==(const FlashCookie &other) const { 0041 return (this->name == other.name && this->path == other.path); 0042 } 0043 }; 0044 0045 class FCM_Plugin : public QObject, public PluginInterface 0046 { 0047 Q_OBJECT 0048 Q_INTERFACES(PluginInterface) 0049 Q_PLUGIN_METADATA(IID "Falkon.Browser.plugin.FlashCookieManager" FILE "flashcookiemanager.json") 0050 0051 public: 0052 explicit FCM_Plugin(); 0053 0054 void init(InitState state, const QString &settingsPath) override; 0055 void unload() override; 0056 bool testPlugin() override; 0057 void showSettings(QWidget *parent) override; 0058 0059 void populateExtensionsMenu(QMenu *menu) override; 0060 0061 void setFlashCookies(const QList<FlashCookie> &flashCookies); 0062 QList<FlashCookie> flashCookies(); 0063 QStringList newCookiesList(); 0064 void clearNewOrigins(); 0065 void clearCache(); 0066 QString flashPlayerDataPath() const; 0067 QVariantHash readSettings() const; 0068 void writeSettings(const QVariantHash &hashSettings); 0069 0070 void removeCookie(const FlashCookie &flashCookie); 0071 0072 private Q_SLOTS: 0073 void autoRefresh(); 0074 void showFlashCookieManager(); 0075 void mainWindowCreated(BrowserWindow* window); 0076 void mainWindowDeleted(BrowserWindow* window); 0077 void startStopTimer(); 0078 0079 private: 0080 AbstractButtonInterface* createStatusBarIcon(BrowserWindow* mainWindow); 0081 void loadFlashCookies(); 0082 void loadFlashCookies(QString path); 0083 void insertFlashCookie(const QString &path); 0084 QString extractOriginFrom(const QString &path); 0085 bool isBlacklisted(const FlashCookie &flashCookie); 0086 bool isWhitelisted(const FlashCookie &flashCookie); 0087 void removeAllButWhitelisted(); 0088 QString sharedObjectDirName() const; 0089 0090 QHash<BrowserWindow*, AbstractButtonInterface*> m_statusBarIcons; 0091 QPointer<FCM_Dialog> m_fcmDialog; 0092 0093 QString m_settingsPath; 0094 QList<FlashCookie> m_flashCookies; 0095 QTimer* m_timer; 0096 0097 mutable QVariantHash m_settingsHash; 0098 bool m_autoMode; 0099 bool m_deleteOnClose; 0100 bool m_enableNotification; 0101 QStringList m_blacklist; 0102 QStringList m_whitelist; 0103 QStringList m_newCookiesList; 0104 }; 0105 0106 Q_DECLARE_METATYPE(FlashCookie); 0107 #endif // FLASHCOOKIEMANAGER_H