diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index ba3208b4..8ce35371 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -1,338 +1,340 @@ add_definitions(-DFALKON_SHAREDLIBRARY) set(CMAKE_CXX_STANDARD 14) # Enable C++14, with cmake >= 3.1 set(CMAKE_CXX_EXTENSIONS OFF) # Don't enable gcc-specific extensions set(SRCS 3rdparty/qtsingleapplication/qtsingleapplication.cpp 3rdparty/qtsingleapplication/qtlocalpeer.cpp ) if(CMAKE_BUILD_TYPE STREQUAL "Debug") set(SRCS ${SRCS} ${CMAKE_SOURCE_DIR}/tests/modeltest/modeltest.cpp) include_directories(${CMAKE_SOURCE_DIR}/tests/modeltest) endif() include_directories( 3rdparty adblock app autofill bookmarks cookies downloads history navigation network notifications opensearch other plugins popupwindow preferences session sidebar tabwidget tools webengine webtab ) include_directories(${OPENSSL_INCLUDE_DIR}) set(SRCS ${SRCS} 3rdparty/fancytabwidget.cpp 3rdparty/lineedit.cpp 3rdparty/processinfo.cpp 3rdparty/squeezelabelv1.cpp 3rdparty/squeezelabelv2.cpp 3rdparty/stylehelper.cpp adblock/adblockaddsubscriptiondialog.cpp adblock/adblockurlinterceptor.cpp adblock/adblockdialog.cpp adblock/adblockicon.cpp adblock/adblockmanager.cpp adblock/adblockmatcher.cpp adblock/adblockrule.cpp adblock/adblocksearchtree.cpp adblock/adblocksubscription.cpp adblock/adblocktreewidget.cpp adblock/adblockplugin.cpp app/autosaver.cpp app/browserwindow.cpp app/commandlineoptions.cpp app/datapaths.cpp app/mainapplication.cpp app/mainmenu.cpp app/profilemanager.cpp app/proxystyle.cpp app/qzcommon.cpp app/settings.cpp autofill/autofill.cpp autofill/autofillicon.cpp autofill/autofillnotification.cpp autofill/autofillwidget.cpp autofill/passwordbackends/databaseencryptedpasswordbackend.cpp autofill/passwordbackends/databasepasswordbackend.cpp autofill/passwordbackends/passwordbackend.cpp autofill/passwordmanager.cpp bookmarks/bookmarkitem.cpp bookmarks/bookmarks.cpp bookmarks/bookmarksexport/bookmarksexportdialog.cpp bookmarks/bookmarksexport/bookmarksexporter.cpp bookmarks/bookmarksexport/htmlexporter.cpp bookmarks/bookmarksicon.cpp bookmarks/bookmarksimport/bookmarksimportdialog.cpp bookmarks/bookmarksimport/bookmarksimporter.cpp bookmarks/bookmarksimport/firefoximporter.cpp bookmarks/bookmarksimport/htmlimporter.cpp bookmarks/bookmarksimport/chromeimporter.cpp bookmarks/bookmarksimport/ieimporter.cpp bookmarks/bookmarksimport/operaimporter.cpp bookmarks/bookmarksitemdelegate.cpp bookmarks/bookmarksmanager.cpp bookmarks/bookmarksmenu.cpp bookmarks/bookmarksmodel.cpp bookmarks/bookmarkstoolbarbutton.cpp bookmarks/bookmarkstoolbar.cpp bookmarks/bookmarkstools.cpp bookmarks/bookmarkstreeview.cpp bookmarks/bookmarkswidget.cpp cookies/cookiejar.cpp cookies/cookiemanager.cpp downloads/downloaditem.cpp downloads/downloadmanager.cpp downloads/downloadoptionsdialog.cpp downloads/downloadsbutton.cpp history/history.cpp history/historyitem.cpp history/historymanager.cpp history/historymenu.cpp history/historymodel.cpp history/historytreeview.cpp navigation/completer/locationcompleter.cpp navigation/completer/locationcompleterdelegate.cpp navigation/completer/locationcompletermodel.cpp navigation/completer/locationcompleterrefreshjob.cpp navigation/completer/locationcompleterview.cpp navigation/downicon.cpp navigation/goicon.cpp navigation/locationbar.cpp navigation/locationbarpopup.cpp navigation/navigationbar.cpp navigation/navigationbartoolbutton.cpp navigation/navigationbarconfigdialog.cpp navigation/navigationcontainer.cpp navigation/reloadstopbutton.cpp navigation/siteicon.cpp navigation/websearchbar.cpp network/networkmanager.cpp network/networkurlinterceptor.cpp network/schemehandlers/extensionschemehandler.cpp network/schemehandlers/falkonschemehandler.cpp network/sslerrordialog.cpp notifications/desktopnotification.cpp notifications/desktopnotificationsfactory.cpp opensearch/editsearchengine.cpp opensearch/opensearchengine.cpp opensearch/opensearchenginedelegate.cpp opensearch/opensearchreader.cpp opensearch/searchenginesdialog.cpp opensearch/searchenginesmanager.cpp other/aboutdialog.cpp other/browsinglibrary.cpp other/clearprivatedata.cpp other/checkboxdialog.cpp other/iconchooser.cpp other/licenseviewer.cpp other/qzsettings.cpp other/siteinfo.cpp other/siteinfowidget.cpp other/statusbar.cpp other/updater.cpp other/useragentmanager.cpp plugins/pluginproxy.cpp plugins/plugins.cpp plugins/speeddial.cpp plugins/qml/qmlpluginloader.cpp plugins/qml/qmlplugins.cpp plugins/qml/qmlplugininterface.cpp plugins/qml/api/bookmarks/qmlbookmarktreenode.cpp plugins/qml/api/bookmarks/qmlbookmarks.cpp plugins/qml/api/topsites/qmlmostvisitedurl.cpp plugins/qml/api/topsites/qmltopsites.cpp plugins/qml/api/history/qmlhistoryitem.cpp plugins/qml/api/history/qmlhistory.cpp + plugins/qml/api/cookies/qmlcookie.cpp + plugins/qml/api/cookies/qmlcookies.cpp popupwindow/popuplocationbar.cpp popupwindow/popupstatusbarmessage.cpp popupwindow/popupwebview.cpp popupwindow/popupwindow.cpp preferences/acceptlanguage.cpp preferences/autofillmanager.cpp preferences/jsoptions.cpp preferences/pluginlistdelegate.cpp preferences/pluginsmanager.cpp preferences/preferences.cpp preferences/thememanager.cpp preferences/useragentdialog.cpp session/recoveryjsobject.cpp session/restoremanager.cpp session/sessionmanager.cpp session/sessionmanagerdialog.cpp sidebar/bookmarkssidebar.cpp sidebar/historysidebar.cpp sidebar/sidebar.cpp tabwidget/combotabbar.cpp tabwidget/tabbar.cpp tabwidget/tabicon.cpp tabwidget/tabmodel.cpp tabwidget/tabmrumodel.cpp tabwidget/tabtreemodel.cpp tabwidget/tabstackedwidget.cpp tabwidget/tabwidget.cpp tabwidget/tabcontextmenu.cpp tools/abstractbuttoninterface.cpp tools/aesinterface.cpp tools/animatedwidget.cpp tools/buttonwithmenu.cpp tools/certificateinfowidget.cpp tools/clickablelabel.cpp tools/closedtabsmanager.cpp tools/closedwindowsmanager.cpp tools/colors.cpp tools/delayedfilewatcher.cpp tools/desktopfile.cpp tools/docktitlebarwidget.cpp tools/enhancedmenu.cpp tools/focusselectlineedit.cpp tools/headerview.cpp tools/horizontallistwidget.cpp tools/html5permissions/html5permissionsdialog.cpp tools/html5permissions/html5permissionsmanager.cpp tools/html5permissions/html5permissionsnotification.cpp tools/iconprovider.cpp tools/listitemdelegate.cpp tools/mactoolbutton.cpp tools/menubar.cpp tools/pagethumbnailer.cpp tools/progressbar.cpp tools/qztools.cpp tools/removeitemfocusdelegate.cpp tools/scripts.cpp tools/sqldatabase.cpp tools/toolbutton.cpp tools/treewidget.cpp tools/wheelhelper.cpp webengine/javascript/autofilljsobject.cpp webengine/javascript/externaljsobject.cpp webengine/loadrequest.cpp webengine/webhittestresult.cpp webengine/webinspector.cpp webengine/webpage.cpp webengine/webview.cpp webengine/webscrollbar.cpp webengine/webscrollbarmanager.cpp webtab/searchtoolbar.cpp webtab/tabbedwebview.cpp webtab/webtab.cpp ) if (WIN32) set(SRCS ${SRCS} other/registerqappassociation.cpp) endif() if (APPLE) set(SRCS ${SRCS} tools/disablewindowtabbbing.mm) endif() # TODO: use ki18n_wrap_ui? qt5_wrap_ui(SRCS adblock/adblockaddsubscriptiondialog.ui adblock/adblockdialog.ui autofill/autofillnotification.ui autofill/autofillwidget.ui autofill/passwordbackends/masterpassworddialog.ui bookmarks/bookmarksexport/bookmarksexportdialog.ui bookmarks/bookmarksimport/bookmarksimportdialog.ui bookmarks/bookmarksmanager.ui bookmarks/bookmarkswidget.ui cookies/cookiemanager.ui downloads/downloaditem.ui downloads/downloadmanager.ui downloads/downloadoptionsdialog.ui history/historymanager.ui navigation/navigationbarconfigdialog.ui network/sslerrordialog.ui notifications/desktopnotification.ui opensearch/editsearchengine.ui opensearch/searchenginesdialog.ui other/aboutdialog.ui other/browsinglibrary.ui other/clearprivatedata.ui other/iconchooser.ui other/siteinfo.ui other/siteinfowidget.ui preferences/acceptlanguage.ui preferences/addacceptlanguage.ui preferences/autofillmanager.ui preferences/jsoptions.ui preferences/pluginslist.ui preferences/preferences.ui preferences/thememanager.ui preferences/useragentdialog.ui session/sessionmanagerdialog.ui sidebar/bookmarkssidebar.ui sidebar/historysidebar.ui tools/certificateinfowidget.ui tools/docktitlebarwidget.ui tools/html5permissions/html5permissionsdialog.ui tools/html5permissions/html5permissionsnotification.ui webengine/jsalert.ui webengine/jsconfirm.ui webengine/jsprompt.ui webtab/searchtoolbar.ui ) qt5_add_resources(SRCS data/data.qrc data/html.qrc data/icons.qrc data/breeze-fallback.qrc adblock/adblock.qrc ) add_library(FalkonPrivate SHARED ${SRCS}) get_property(QT_WEBENGINE_INCLUDE_DIRS TARGET Qt5::WebEngine PROPERTY INTERFACE_INCLUDE_DIRECTORIES) target_include_directories(FalkonPrivate SYSTEM PUBLIC ${QT_WEBENGINE_INCLUDE_DIRS}) target_link_libraries(FalkonPrivate Qt5::Widgets Qt5::WebEngineWidgets Qt5::Network Qt5::Sql Qt5::PrintSupport Qt5::QuickWidgets Qt5::WebChannel ${OPENSSL_CRYPTO_LIBRARY} ) if (UNIX AND NOT APPLE) if (NOT NO_X11) target_link_libraries(FalkonPrivate XCB::XCB Qt5::X11Extras) endif() set_target_properties(FalkonPrivate PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION "3") install(TARGETS FalkonPrivate ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP) endif() if (WIN32) target_link_libraries(FalkonPrivate Qt5::WinExtras) endif() if (APPLE) target_link_libraries(FalkonPrivate "-framework CoreServices -framework AppKit") endif() if (NOT DISABLE_DBUS) target_link_libraries(FalkonPrivate Qt5::DBus) endif() diff --git a/src/lib/plugins/qml/api/cookies/qmlcookie.cpp b/src/lib/plugins/qml/api/cookies/qmlcookie.cpp new file mode 100644 index 00000000..09ef70e2 --- /dev/null +++ b/src/lib/plugins/qml/api/cookies/qmlcookie.cpp @@ -0,0 +1,81 @@ +/* ============================================================ +* Falkon - Qt web browser +* Copyright (C) 2018 Anmol Gautam +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#include "qmlcookie.h" +#include + +QmlCookie::QmlCookie(QNetworkCookie *cookie, QObject *parent) : + QObject(parent) + , m_cookie(cookie) +{ +} + +QString QmlCookie::domain() const +{ + if (!m_cookie) { + return QString(); + } + return m_cookie->domain(); +} + +QDateTime QmlCookie::expirationDate() const +{ + if (!m_cookie) { + return QDateTime(); + } + return m_cookie->expirationDate(); +} + +QString QmlCookie::name() const +{ + if (!m_cookie) { + return QString(); + } + return QString(m_cookie->name()); +} + +QString QmlCookie::path() const +{ + if (!m_cookie) { + return QString(); + } + return m_cookie->path(); +} + +bool QmlCookie::secure() const +{ + if (!m_cookie) { + return false; + } + return m_cookie->isSecure(); +} + +bool QmlCookie::session() const +{ + if (!m_cookie) { + return false; + } + return m_cookie->isSessionCookie(); +} + +QString QmlCookie::value() const +{ + if (!m_cookie) { + return QString(); + } + return QString(m_cookie->value()); +} diff --git a/src/lib/plugins/qml/qmlplugins.h b/src/lib/plugins/qml/api/cookies/qmlcookie.h similarity index 50% copy from src/lib/plugins/qml/qmlplugins.h copy to src/lib/plugins/qml/api/cookies/qmlcookie.h index f8c3b8f0..92ab77dd 100644 --- a/src/lib/plugins/qml/qmlplugins.h +++ b/src/lib/plugins/qml/api/cookies/qmlcookie.h @@ -1,37 +1,48 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2018 Anmol Gautam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * ============================================================ */ -#ifndef QMLPLUGINS_H -#define QMLPLUGINS_H +#ifndef QMLCOOKIE_H +#define QMLCOOKIE_H -class QmlPlugins -{ - static void registerQmlPluginInterface(); - - static void registerQmlBookmarkTreeNode(); - static void registerQmlBookmarks(); +#include +#include +#include - static void registerQmlMostVisitedUrl(); - static void registerQmlTopSites(); - - static void registerQmlHistoryItem(); - static void registerQmlHistory(); +class QmlCookie : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString domain READ domain CONSTANT) + Q_PROPERTY(QDateTime expirationDate READ expirationDate CONSTANT) + Q_PROPERTY(QString name READ name CONSTANT) + Q_PROPERTY(QString path READ path CONSTANT) + Q_PROPERTY(bool secure READ secure CONSTANT) + Q_PROPERTY(bool session READ session CONSTANT) + Q_PROPERTY(QString value READ value CONSTANT) public: - static void registerQmlTypes(); + explicit QmlCookie(QNetworkCookie *cookie = 0, QObject *parent = 0); + QString domain() const; + QDateTime expirationDate() const; + QString name() const; + QString path() const; + bool secure() const; + bool session() const; + QString value() const; +private: + QNetworkCookie *m_cookie; }; -#endif // QMLPLUGINS_H +#endif // QMLCOOKIE_H diff --git a/src/lib/plugins/qml/api/cookies/qmlcookies.cpp b/src/lib/plugins/qml/api/cookies/qmlcookies.cpp new file mode 100644 index 00000000..34262760 --- /dev/null +++ b/src/lib/plugins/qml/api/cookies/qmlcookies.cpp @@ -0,0 +1,115 @@ +/* ============================================================ +* Falkon - Qt web browser +* Copyright (C) 2018 Anmol Gautam +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#include "qmlcookies.h" +#include "mainapplication.h" +#include "cookiejar.h" +#include "qwebengineprofile.h" + +QmlCookies::QmlCookies(QObject *parent) : + QObject(parent) +{ + connect(mApp->cookieJar(), &CookieJar::cookieAdded, this, [=](QNetworkCookie network_cookie){ + QmlCookie *cookie = new QmlCookie(&network_cookie); + emit changed(cookie, false); + }); + + connect(mApp->cookieJar(), &CookieJar::cookieRemoved, this, [=](QNetworkCookie network_cookie){ + QmlCookie *cookie = new QmlCookie(&network_cookie); + emit changed(cookie, true); + }); +} + +QNetworkCookie *QmlCookies::getNetworkCookie(const QVariantMap &map) +{ + if (!map["name"].isValid() || !map["url"].isValid()) { + qWarning() << "Error:" << "Wrong arguments passed to" << __FUNCTION__; + return nullptr; + } + QString name = map["name"].toString(); + QString url = map["url"].toString(); + QVector cookies = mApp->cookieJar()->getAllCookies(); + for (QNetworkCookie cookie : cookies) { + if (cookie.name() == name && cookie.domain() == url) { + QNetworkCookie *netCookie = new QNetworkCookie(cookie); + return netCookie; + } + } + return nullptr; +} + +QmlCookie *QmlCookies::get(const QVariantMap &map) +{ + QNetworkCookie *netCookie = getNetworkCookie(map); + if (!netCookie) { + return nullptr; + } + return new QmlCookie(netCookie); +} + +QList QmlCookies::getAll(const QVariantMap &map) +{ + QList qmlCookies; + QString name = map["name"].toString(); + QString url = map["url"].toString(); + QString path = map["path"].toString(); + bool secure = map["secure"].toBool(); + bool session = map["session"].toBool(); + QVector cookies = mApp->cookieJar()->getAllCookies(); + for (QNetworkCookie cookie : cookies) { + if ((!map["name"].isValid() || cookie.name() == name) + && (!map["url"].isValid() || cookie.domain() == url) + && (!map["path"].isValid() || cookie.path() == path) + && (!map["secure"].isValid() || cookie.isSecure() == secure) + && (!map["session"].isValid() || cookie.isSessionCookie() == session)) { + QNetworkCookie *netCookie = new QNetworkCookie(cookie); + QmlCookie *qmlCookie = new QmlCookie(netCookie); + qmlCookies.append(qmlCookie); + } + } + return qmlCookies; +} + +void QmlCookies::set(const QVariantMap &map) +{ + QString name = map["name"].toString(); + QString url = map["url"].toString(); + QString path = map["path"].toString(); + bool secure = map["secure"].toBool(); + QDateTime expirationDate = QDateTime::fromMSecsSinceEpoch(map["expirationDate"].toDouble()); + bool httpOnly = map["httpOnly"].toBool(); + QString value = map["value"].toString(); + QNetworkCookie cookie; + cookie.setName(name.toLocal8Bit()); + cookie.setDomain(url); + cookie.setPath(path); + cookie.setSecure(secure); + cookie.setExpirationDate(expirationDate); + cookie.setHttpOnly(httpOnly); + cookie.setValue(value.toLocal8Bit()); + mApp->webProfile()->cookieStore()->setCookie(cookie); +} + +void QmlCookies::remove(const QVariantMap &map) +{ + QNetworkCookie *netCookie = getNetworkCookie(map); + if (!netCookie) { + qWarning() << "Error:" << "Cannot find cookie"; + return; + } + mApp->webProfile()->cookieStore()->deleteCookie(*netCookie); +} diff --git a/src/lib/plugins/qml/qmlplugins.h b/src/lib/plugins/qml/api/cookies/qmlcookies.h similarity index 60% copy from src/lib/plugins/qml/qmlplugins.h copy to src/lib/plugins/qml/api/cookies/qmlcookies.h index f8c3b8f0..555802ad 100644 --- a/src/lib/plugins/qml/qmlplugins.h +++ b/src/lib/plugins/qml/api/cookies/qmlcookies.h @@ -1,37 +1,39 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2018 Anmol Gautam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * ============================================================ */ -#ifndef QMLPLUGINS_H -#define QMLPLUGINS_H +#ifndef QMLCOOKIES_H +#define QMLCOOKIES_H -class QmlPlugins -{ - static void registerQmlPluginInterface(); - - static void registerQmlBookmarkTreeNode(); - static void registerQmlBookmarks(); +#include +#include "qmlcookie.h" - static void registerQmlMostVisitedUrl(); - static void registerQmlTopSites(); - - static void registerQmlHistoryItem(); - static void registerQmlHistory(); +class QmlCookies : public QObject +{ + Q_OBJECT public: - static void registerQmlTypes(); + explicit QmlCookies(QObject *parent = 0); + Q_INVOKABLE QmlCookie *get(const QVariantMap &map); + Q_INVOKABLE QList getAll(const QVariantMap &map); + Q_INVOKABLE void set(const QVariantMap &map); + Q_INVOKABLE void remove(const QVariantMap &map); +signals: + void changed(QmlCookie *cookie, bool removed); +private: + QNetworkCookie *getNetworkCookie(const QVariantMap &map); }; -#endif // QMLPLUGINS_H +#endif // QMLCOOKIES_H diff --git a/src/lib/plugins/qml/qmlplugins.cpp b/src/lib/plugins/qml/qmlplugins.cpp index 255afc75..3157bd9a 100644 --- a/src/lib/plugins/qml/qmlplugins.cpp +++ b/src/lib/plugins/qml/qmlplugins.cpp @@ -1,120 +1,149 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2018 Anmol Gautam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * ============================================================ */ #include "qmlplugins.h" #include "qmlplugininterface.h" #include "api/bookmarks/qmlbookmarktreenode.h" #include "api/bookmarks/qmlbookmarks.h" #include "api/topsites/qmlmostvisitedurl.h" #include "api/topsites/qmltopsites.h" #include "api/history/qmlhistoryitem.h" #include "api/history/qmlhistory.h" +#include "api/cookies/qmlcookie.h" +#include "api/cookies/qmlcookies.h" #include // static void QmlPlugins::registerQmlTypes() { registerQmlPluginInterface(); registerQmlBookmarkTreeNode(); registerQmlBookmarks(); registerQmlMostVisitedUrl(); registerQmlTopSites(); registerQmlHistoryItem(); registerQmlHistory(); + + registerQmlCookie(); + registerQmlCookies(); } // private static void QmlPlugins::registerQmlPluginInterface() { qmlRegisterType("org.kde.falkon", 1, 0, "PluginInterface"); } // private static void QmlPlugins::registerQmlBookmarkTreeNode() { qmlRegisterSingletonType("org.kde.falkon", 1, 0, "BookmarkTreeNode", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * { Q_UNUSED(engine) Q_UNUSED(scriptEngine) auto *object = new QmlBookmarkTreeNode(); return object; }); } // private static void QmlPlugins::registerQmlBookmarks() { qmlRegisterSingletonType("org.kde.falkon", 1, 0, "Bookmarks", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * { Q_UNUSED(engine) Q_UNUSED(scriptEngine) auto *object = new QmlBookmarks(); return object; }); } // private static void QmlPlugins::registerQmlMostVisitedUrl() { qmlRegisterSingletonType("org.kde.falkon", 1, 0, "MostVisitedURL", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * { Q_UNUSED(engine) Q_UNUSED(scriptEngine) auto *object = new QmlMostVisitedUrl(); return object; }); } // private static void QmlPlugins::registerQmlTopSites() { qmlRegisterSingletonType("org.kde.falkon", 1, 0, "TopSites", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * { Q_UNUSED(engine) Q_UNUSED(scriptEngine) auto *object = new QmlTopSites(); return object; }); } // private static void QmlPlugins::registerQmlHistoryItem() { qmlRegisterSingletonType("org.kde.falkon", 1, 0, "HistoryItem", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * { Q_UNUSED(engine) Q_UNUSED(scriptEngine) auto *object = new QmlHistoryItem(); return object; }); } // private static void QmlPlugins::registerQmlHistory() { qmlRegisterSingletonType("org.kde.falkon", 1, 0, "History", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * { Q_UNUSED(engine) Q_UNUSED(scriptEngine) auto *object = new QmlHistory(); return object; }); } + +// private static +void QmlPlugins::registerQmlCookie() +{ + qmlRegisterSingletonType("org.kde.falkon", 1, 0, "Cookie", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * { + Q_UNUSED(engine) + Q_UNUSED(scriptEngine) + + auto *object = new QmlCookie(); + return object; + }); +} + +// private static +void QmlPlugins::registerQmlCookies() +{ + qmlRegisterSingletonType("org.kde.falkon", 1, 0, "Cookies", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * { + Q_UNUSED(engine) + Q_UNUSED(scriptEngine) + + auto *object = new QmlCookies(); + return object; + }); +} diff --git a/src/lib/plugins/qml/qmlplugins.h b/src/lib/plugins/qml/qmlplugins.h index f8c3b8f0..a815ecbe 100644 --- a/src/lib/plugins/qml/qmlplugins.h +++ b/src/lib/plugins/qml/qmlplugins.h @@ -1,37 +1,40 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2018 Anmol Gautam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * ============================================================ */ #ifndef QMLPLUGINS_H #define QMLPLUGINS_H class QmlPlugins { static void registerQmlPluginInterface(); static void registerQmlBookmarkTreeNode(); static void registerQmlBookmarks(); static void registerQmlMostVisitedUrl(); static void registerQmlTopSites(); static void registerQmlHistoryItem(); static void registerQmlHistory(); + + static void registerQmlCookie(); + static void registerQmlCookies(); public: static void registerQmlTypes(); }; #endif // QMLPLUGINS_H