aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/browserinterface.h24
-rw-r--r--include/plugininterface.h35
-rw-r--r--include/profileinterface.h84
3 files changed, 143 insertions, 0 deletions
diff --git a/include/browserinterface.h b/include/browserinterface.h
new file mode 100644
index 0000000..25de65c
--- /dev/null
+++ b/include/browserinterface.h
@@ -0,0 +1,24 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#pragma once
+
+class Profile;
+class BrowserInterface
+{
+public:
+ // configuration access
+ virtual const QStringList configurationOptions() const = 0;
+ virtual const QString configuration(const QString &key) const = 0;
+ virtual void setConfiguration(const QString &key, const QString &value) = 0;
+
+ // profile access
+ virtual const QList<QPair<QString, Profile *>> profileList() const = 0;
+ virtual QPair<QString, Profile *> loadProfile(const QString &id, bool isOffTheRecord = true) = 0;
+ virtual void removeProfile(const QString &id) = 0;
+};
diff --git a/include/plugininterface.h b/include/plugininterface.h
new file mode 100644
index 0000000..103ee62
--- /dev/null
+++ b/include/plugininterface.h
@@ -0,0 +1,35 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#pragma once
+
+#include <QtPlugin>
+#include <QHash>
+#include <memory>
+#include <functional>
+#include "browserinterface.h"
+#include <QApplication>
+
+typedef QHash<QString, std::function<int()>> CommandHash_t;
+
+class QDialog;
+class PluginInterface
+{
+public:
+ virtual ~PluginInterface() = default;
+ virtual CommandHash_t commands() = 0;
+ virtual QDialog *createWidget(QWidget *parent = nullptr) const = 0;
+
+protected:
+ BrowserInterface *browser() const {
+ return dynamic_cast<BrowserInterface *>(qApp);
+ }
+};
+
+#define PluginInterfaceIid "net.iserlohn-fortress.smolbote.PluginInterface"
+Q_DECLARE_INTERFACE(PluginInterface, PluginInterfaceIid)
diff --git a/include/profileinterface.h b/include/profileinterface.h
new file mode 100644
index 0000000..c24a4ae
--- /dev/null
+++ b/include/profileinterface.h
@@ -0,0 +1,84 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#pragma once
+
+#include <QString>
+#include <QUrl>
+#include <QWebEngineProfile>
+#include <QWebEngineSettings>
+#include <QNetworkCookie>
+
+class Profile : public QWebEngineProfile
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+ Q_PROPERTY(QString search READ search WRITE setSearch NOTIFY searchChanged)
+ Q_PROPERTY(QUrl homepage READ homepage WRITE setHomepage NOTIFY homepageChanged)
+ Q_PROPERTY(QUrl newtab READ newtab WRITE setNewtab NOTIFY newtabChanged)
+
+ // QWebEngineProfile should-be properties
+ Q_PROPERTY(QString cachePath READ cachePath WRITE setCachePath NOTIFY propertyChanged)
+ Q_PROPERTY(QString persistentStoragePath READ persistentStoragePath WRITE setPersistentStoragePath NOTIFY propertyChanged)
+ Q_PROPERTY(int persistentCookiesPolicy READ persistentCookiesPolicy WRITE setPersistentCookiesPolicy NOTIFY propertyChanged)
+
+ Q_PROPERTY(QString httpAcceptLanguage READ httpAcceptLanguage WRITE setHttpAcceptLanguage NOTIFY propertyChanged)
+ Q_PROPERTY(int httpCacheMaximumSize READ httpCacheMaximumSize WRITE setHttpCacheMaximumSize NOTIFY propertyChanged)
+ Q_PROPERTY(int httpCacheType READ httpCacheType WRITE setHttpCacheType NOTIFY propertyChanged)
+ Q_PROPERTY(QString httpUserAgent READ httpUserAgent WRITE setHttpUserAgent NOTIFY propertyChanged)
+
+ Q_PROPERTY(bool spellCheckEnabled READ isSpellCheckEnabled WRITE setSpellCheckEnabled NOTIFY propertyChanged)
+
+protected:
+ explicit Profile(QObject *parent = nullptr) : QWebEngineProfile(parent) {};
+ explicit Profile(const QString &storageName, QObject *parent = nullptr) : QWebEngineProfile(storageName, parent) {};
+
+public:
+ virtual const QString name() const = 0;
+ virtual void setName(const QString &name) = 0;
+
+ virtual const QVector<QNetworkCookie> cookies() const = 0;
+ virtual const QMap<QByteArray, QByteArray> headers() const = 0;
+
+ // search url
+ virtual QString search() const = 0;
+ virtual void setSearch(const QString &url) = 0;
+
+ // homepage url
+ virtual QUrl homepage() const = 0;
+ virtual void setHomepage(const QUrl &url) = 0;
+
+ // new tab url
+ virtual QUrl newtab() const = 0;
+ virtual void setNewtab(const QUrl &url) = 0;
+
+ virtual void setCachePath(const QString &path) = 0;
+ virtual void setPersistentStoragePath(const QString &path) = 0;
+ virtual void setPersistentCookiesPolicy(int policy) = 0;
+
+ virtual void setHttpAcceptLanguage(const QString &httpAcceptLanguage) = 0;
+ virtual void setHttpCacheMaximumSize(int maxSize) = 0;
+ virtual void setHttpCacheType(int type) = 0;
+ virtual void setHttpUserAgent(const QString &userAgent) = 0;
+ virtual void setHttpHeader(const QString &name, const QString &value) = 0;
+ virtual void removeHttpHeader(const QString &name) = 0;
+
+ virtual void setSpellCheckEnabled(bool enable) = 0;
+
+signals:
+ void nameChanged(const QString &name);
+ void searchChanged(const QString &url);
+ void homepageChanged(const QUrl &url);
+ void newtabChanged(const QUrl &url);
+
+ void propertyChanged(const QString &name, const QVariant &value);
+ void attributeChanged(const QWebEngineSettings::WebAttribute attribute, const bool value);
+ void headerChanged(const QString &name, const QString &value);
+ void headerRemoved(const QString &name);
+};