Files
amnezia-client/client/platforms/android/android_controller.h
T

78 lines
2.3 KiB
C++
Raw Normal View History

2022-12-23 17:32:20 +03:00
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
2021-11-26 17:43:02 +03:00
#ifndef ANDROID_CONTROLLER_H
#define ANDROID_CONTROLLER_H
2022-12-23 17:32:20 +03:00
#include <QJniEnvironment>
#include <QJniObject>
2021-11-26 17:43:02 +03:00
#include "ui/pages_logic/StartPageLogic.h"
2021-11-26 17:43:02 +03:00
#include "protocols/vpnprotocol.h"
using namespace amnezia;
2022-12-23 17:32:20 +03:00
class AndroidController : public QObject
2021-11-26 17:43:02 +03:00
{
Q_OBJECT
public:
explicit AndroidController();
static AndroidController* instance();
virtual ~AndroidController() override = default;
bool initialize(StartPageLogic *startPageLogic);
2021-11-26 17:43:02 +03:00
ErrorCode start();
void stop();
void resumeStart();
void checkStatus();
void setNotificationText(const QString& title, const QString& message, int timerSec);
void shareConfig(const QString& data, const QString& suggestedName);
2021-11-26 17:43:02 +03:00
void setFallbackConnectedNotification();
void getBackendLogs(std::function<void(const QString&)>&& callback);
void cleanupBackendLogs();
void importConfig(const QString& data);
2021-11-26 17:43:02 +03:00
// from QAndroidServiceConnection
2022-12-23 17:32:20 +03:00
// void onServiceConnected(const QString& name, const QAndroidBinder& serviceBinder) override;
// void onServiceDisconnected(const QString& name) override;
2021-11-26 17:43:02 +03:00
const QJsonObject &vpnConfig() const;
void setVpnConfig(const QJsonObject &newVpnConfig);
signals:
2021-11-30 21:51:06 +03:00
void connectionStateChanged(VpnProtocol::VpnConnectionState state);
2021-11-26 17:43:02 +03:00
// This signal is emitted when the controller is initialized. Note that the
// VPN tunnel can be already active. In this case, "connected" should be set
// to true and the "connectionDate" should be set to the activation date if
// known.
// If "status" is set to false, the backend service is considered unavailable.
void initialized(bool status, bool connected,
const QDateTime& connectionDate);
protected slots:
protected:
private:
2022-12-23 17:32:20 +03:00
bool m_init = false;
2021-11-26 17:43:02 +03:00
//Protocol m_protocol;
QJsonObject m_vpnConfig;
StartPageLogic *m_startPageLogic;
2021-11-26 17:43:02 +03:00
bool m_serviceConnected = false;
std::function<void(const QString&)> m_logCallback;
static void startActivityForResult(JNIEnv* env, jobject /*thiz*/, jobject intent);
};
#endif // ANDROID_CONTROLLER_H