init commit
This commit is contained in:
63
src/app/AppController.h
Normal file
63
src/app/AppController.h
Normal file
@@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariantList>
|
||||
#include "LocalSendCore/DiscoveryManager.h"
|
||||
#include "LocalSendCore/HttpServer.h"
|
||||
#include "LocalSendCore/HttpClient.h"
|
||||
#include "LocalSendCore/SessionManager.h"
|
||||
#include "LocalSendCore/SecurityContext.h"
|
||||
#include "LocalSendCore/Settings.h"
|
||||
|
||||
class AppController : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString alias READ alias WRITE setAlias NOTIFY aliasChanged)
|
||||
Q_PROPERTY(quint16 port READ port WRITE setPort NOTIFY portChanged)
|
||||
Q_PROPERTY(QVariantList devices READ devices NOTIFY devicesChanged)
|
||||
Q_PROPERTY(bool serverRunning READ serverRunning NOTIFY serverRunningChanged)
|
||||
|
||||
public:
|
||||
explicit AppController(QObject* parent = nullptr);
|
||||
~AppController() override;
|
||||
|
||||
void initialize();
|
||||
|
||||
QString alias() const;
|
||||
void setAlias(const QString& alias);
|
||||
|
||||
quint16 port() const;
|
||||
void setPort(quint16 port);
|
||||
|
||||
QVariantList devices() const;
|
||||
bool serverRunning() const;
|
||||
|
||||
Q_INVOKABLE void startDiscovery();
|
||||
Q_INVOKABLE void stopDiscovery();
|
||||
Q_INVOKABLE void refreshDevices();
|
||||
|
||||
signals:
|
||||
void aliasChanged();
|
||||
void portChanged();
|
||||
void devicesChanged();
|
||||
void serverRunningChanged();
|
||||
void receiveRequest(const QString& sessionId, const QString& senderAlias, const QVariantList& files);
|
||||
void sendProgress(const QString& sessionId, double progress);
|
||||
void sendCompleted(const QString& sessionId);
|
||||
|
||||
private slots:
|
||||
void onDeviceDiscovered(const LocalSend::Device& device);
|
||||
void onDeviceLost(const QString& fingerprint);
|
||||
void onPrepareUploadRequest(const LocalSend::PrepareUploadRequestDto& dto, const QHostAddress& sender);
|
||||
|
||||
private:
|
||||
LocalSend::Settings* m_settings = nullptr;
|
||||
LocalSend::SecurityContext* m_security = nullptr;
|
||||
LocalSend::DiscoveryManager* m_discovery = nullptr;
|
||||
LocalSend::HttpServer* m_server = nullptr;
|
||||
LocalSend::SessionManager* m_sessions = nullptr;
|
||||
|
||||
QMap<QString, LocalSend::Device> m_devices;
|
||||
|
||||
LocalSend::InfoDto buildInfoDto() const;
|
||||
};
|
||||
Reference in New Issue
Block a user