Warning, file /network/tokodon/src/network/networkcontroller.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com> 0002 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0003 0004 #pragma once 0005 0006 #include <QtQml> 0007 0008 class AbstractAccount; 0009 0010 class NetworkController : public QObject 0011 { 0012 Q_OBJECT 0013 QML_NAMED_ELEMENT(Controller) 0014 QML_SINGLETON 0015 0016 Q_PROPERTY(bool pushNotificationsAvailable READ pushNotificationsAvailable CONSTANT) 0017 0018 public: 0019 static NetworkController *create(QQmlEngine *, QJSEngine *) 0020 { 0021 auto inst = &instance(); 0022 QJSEngine::setObjectOwnership(inst, QJSEngine::ObjectOwnership::CppOwnership); 0023 return inst; 0024 } 0025 0026 static NetworkController &instance(); 0027 Q_INVOKABLE void setApplicationProxy(); 0028 0029 Q_INVOKABLE void openWebApLink(QString input); 0030 void setAuthCode(QUrl authCode); 0031 void startComposing(const QString &text); 0032 0033 void requestRemoteObject(AbstractAccount *account, const QString &url, std::function<void(QNetworkReply *)> callback); 0034 0035 bool pushNotificationsAvailable() const; 0036 0037 QString endpoint; 0038 0039 Q_SIGNALS: 0040 void networkErrorOccurred(const QString &errorString); 0041 void openPost(QString id); 0042 void openAccount(QString id); 0043 void receivedAuthCode(QString authCode); 0044 void openComposer(const QString &text); 0045 0046 private: 0047 explicit NetworkController(QObject *parent = nullptr); 0048 0049 void openLink(); 0050 0051 QUrl m_requestedLink; 0052 bool m_accountsReady = false; 0053 QString m_storedComposedText; 0054 };