1
0
mirror of https://github.com/chylex/Nextcloud-Desktop.git synced 2025-04-09 19:15:43 +02:00

add a network access factory to qml engine

ensure network access made via qml are using our user agent

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
Matthieu Gallien 2021-11-17 10:36:05 +01:00 committed by Matthieu Gallien (Rebase PR Action)
parent 1d704d9352
commit 12c6d6e3bd
2 changed files with 25 additions and 0 deletions

View File

@ -22,6 +22,7 @@
#include "wheelhandler.h"
#include "tray/unifiedsearchresultimageprovider.h"
#include "configfile.h"
#include "accessmanager.h"
#include <QCursor>
#include <QGuiApplication>
@ -59,6 +60,8 @@ void Systray::setTrayEngine(QQmlApplicationEngine *trayEngine)
{
_trayEngine = trayEngine;
_trayEngine->setNetworkAccessManagerFactory(&_accessManagerFactory);
_trayEngine->addImportPath("qrc:/qml/theme");
_trayEngine->addImageProvider("avatars", new ImageProvider);
_trayEngine->addImageProvider(QLatin1String("svgimage-custom-color"), new OCC::Ui::SvgImageProvider);
@ -505,4 +508,14 @@ QPoint Systray::calcTrayIconCenter() const
#endif
}
AccessManagerFactory::AccessManagerFactory()
: QQmlNetworkAccessManagerFactory()
{
}
QNetworkAccessManager* AccessManagerFactory::create(QObject *parent)
{
return new AccessManager(parent);
}
} // namespace OCC

View File

@ -20,6 +20,8 @@
#include "accountmanager.h"
#include "tray/usermodel.h"
#include <QQmlNetworkAccessManagerFactory>
class QScreen;
class QQmlApplicationEngine;
class QQuickWindow;
@ -28,6 +30,14 @@ class QQuickWindow;
namespace OCC {
class AccessManagerFactory : public QQmlNetworkAccessManagerFactory
{
public:
AccessManagerFactory();
QNetworkAccessManager* create(QObject *parent) override;
};
#ifdef Q_OS_OSX
bool canOsXSendUserNotification();
void sendOsXUserNotification(const QString &title, const QString &message);
@ -105,6 +115,8 @@ private:
bool _isOpen = false;
bool _syncIsPaused = true;
QPointer<QQmlApplicationEngine> _trayEngine;
AccessManagerFactory _accessManagerFactory;
};
} // namespace OCC