56 lines
1.6 KiB
C++
56 lines
1.6 KiB
C++
#ifndef DATAMANAGER_H
|
|
#define DATAMANAGER_H
|
|
|
|
#include <QObject>
|
|
#include <QMessageBox>
|
|
#include <QJsonDocument>
|
|
|
|
#include "protocol.h"
|
|
#include "tcpclient.h"
|
|
|
|
class DataManager : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
static DataManager* getInstance();
|
|
|
|
private:
|
|
explicit DataManager(QObject *parent = nullptr);
|
|
//static void recv_from_server(QString &peerAddress,quint16 peerPort,QByteArray &data);
|
|
//static Protocol *protocol;
|
|
//static DataManager *p_this;
|
|
Protocol *protocol;
|
|
TCPClient *tcpclient;
|
|
bool connect_flag = false;
|
|
|
|
signals:
|
|
void connect_to_server();
|
|
void disconnect_from_server();
|
|
void signin_response(bool result);
|
|
void signup_response(bool result);
|
|
void update_text(QString sendname,QString data);
|
|
void update_file(QString sendname,QString filename,QString file_data);
|
|
void update_users(int count,QList<QString>online_users);
|
|
|
|
|
|
public slots:
|
|
/*******ui界面********/
|
|
void Register(QString username,QString password);
|
|
void signin_request(QString username,QString password);
|
|
|
|
/******MAINWIDGET*****/
|
|
void send_text(QString sendname,QString text);
|
|
void send_to_user(QString sendname,QString to_user,QString text);
|
|
void send_file_to_all(QString sendname,QString filename,QByteArray file);
|
|
void send_file_private(QString sendname,QString filename,QByteArray file,QString name);
|
|
void account_cancellation(QString username);
|
|
|
|
/******TCPClient******/
|
|
void TCPClientConnected();
|
|
void TCPClientDisconnected();
|
|
void recv_from_server(QByteArray &data);
|
|
|
|
};
|
|
|
|
#endif // DATAMANAGER_H
|