1 // For license of this file, see <project-root-folder>/LICENSE.md. 2 3 #ifndef WEBFACTORY_H 4 #define WEBFACTORY_H 5 6 #include <QObject> 7 8 #include "core/messagesmodel.h" 9 10 #include <QMap> 11 12 #if defined(USE_WEBENGINE) 13 #include <QWebEngineSettings> 14 #endif 15 16 #if defined(USE_WEBENGINE) 17 class QMenu; 18 class AdBlockManager; 19 class NetworkUrlInterceptor; 20 #endif 21 22 class CookieJar; 23 24 class WebFactory : public QObject { 25 Q_OBJECT 26 27 public: 28 explicit WebFactory(QObject* parent = nullptr); 29 virtual ~WebFactory(); 30 31 // Strips "<....>" (HTML, XML) tags from given text. 32 QString stripTags(QString text); 33 34 // HTML entity unescaping. This method 35 // converts both HTML entity names and numbers to UTF-8 string. 36 // Example of entities are: 37 // ∀ = ∀ (entity name), ∀ (base-10 entity), ∀ (base-16 entity) 38 QString unescapeHtml(const QString& html); 39 40 QString processFeedUriScheme(const QString& url); 41 42 #if defined(USE_WEBENGINE) 43 QAction* engineSettingsAction(); 44 AdBlockManager* adBlock() const; 45 NetworkUrlInterceptor* urlIinterceptor() const; 46 #endif 47 48 CookieJar* cookieJar() const; 49 50 void updateProxy(); 51 bool openUrlInExternalBrowser(const QString& url) const; 52 bool sendMessageViaEmail(const Message& message); 53 54 #if defined(USE_WEBENGINE) 55 private slots: 56 void createMenu(QMenu* menu = nullptr); 57 void webEngineSettingChanged(bool enabled); 58 59 private: 60 QAction* createEngineSettingsAction(const QString& title, QWebEngineSettings::WebAttribute attribute); 61 #endif 62 63 private: 64 void generateUnescapes(); 65 66 private: 67 #if defined(USE_WEBENGINE) 68 AdBlockManager * m_adBlock; 69 NetworkUrlInterceptor* m_urlInterceptor; 70 QAction* m_engineSettings; 71 #endif 72 73 CookieJar* m_cookieJar; 74 QMap<QString, char16_t> m_htmlNamedEntities; 75 }; 76 77 #endif // WEBFACTORY_H 78