gui: add basic gui code.
This commit is contained in:
@@ -15,11 +15,15 @@ find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Network)
|
||||
set(SOURCES
|
||||
ClientCore.cpp
|
||||
ClientCore.h
|
||||
RemoteFile.h
|
||||
RemoteFile.cpp
|
||||
)
|
||||
|
||||
add_library(ClientCore STATIC ${SOURCES})
|
||||
target_link_libraries(ClientCore PRIVATE Protocol
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Network
|
||||
Struct
|
||||
Util
|
||||
)
|
||||
target_include_directories(ClientCore PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
@@ -76,3 +76,24 @@ bool ClientCore::Send(const char* data, qint64 len)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ClientCore::SetClientsCall(const std::function<void(const InfoClientVec& clients)>& call)
|
||||
{
|
||||
}
|
||||
|
||||
void ClientCore::SetPathCall(const std::function<void(const QString& path)>& call)
|
||||
{
|
||||
}
|
||||
|
||||
void ClientCore::SetFileCall(const std::function<void(const DirFileInfoVec& files)>& call)
|
||||
{
|
||||
}
|
||||
|
||||
void ClientCore::SetRemoteID(const QString& id)
|
||||
{
|
||||
}
|
||||
|
||||
QString ClientCore::GetRemoteID()
|
||||
{
|
||||
return remoteID_;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef CLIENTCORE_H
|
||||
#define CLIENTCORE_H
|
||||
|
||||
#include <InfoClient.h>
|
||||
#include <InfoDirFile.h>
|
||||
#include <Protocol.h>
|
||||
#include <QDataStream>
|
||||
#include <QHostAddress>
|
||||
@@ -20,6 +22,8 @@ public:
|
||||
public:
|
||||
bool Connect(const QString& ip, quint16 port);
|
||||
void Disconnect();
|
||||
bool Send(QSharedPointer<FrameBuffer> frame);
|
||||
bool Send(const char* data, qint64 len);
|
||||
|
||||
private:
|
||||
void onReadyRead();
|
||||
@@ -27,8 +31,13 @@ private:
|
||||
|
||||
private:
|
||||
void UseFrame(QSharedPointer<FrameBuffer> frame);
|
||||
bool Send(QSharedPointer<FrameBuffer> frame);
|
||||
bool Send(const char* data, qint64 len);
|
||||
|
||||
public:
|
||||
void SetClientsCall(const std::function<void(const InfoClientVec& clients)>& call);
|
||||
void SetPathCall(const std::function<void(const QString& path)>& call);
|
||||
void SetFileCall(const std::function<void(const DirFileInfoVec& files)>& call);
|
||||
void SetRemoteID(const QString& id);
|
||||
QString GetRemoteID();
|
||||
|
||||
public:
|
||||
QMutex conMutex_;
|
||||
|
||||
31
ClientCore/RemoteFile.cpp
Normal file
31
ClientCore/RemoteFile.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "RemoteFile.h"
|
||||
|
||||
#include <InfoPack.hpp>
|
||||
#include "LocalFile.h"
|
||||
|
||||
void RemoteFile::setClientCore(ClientCore* cliCore)
|
||||
{
|
||||
cliCore_ = cliCore;
|
||||
cliCore_->SetPathCall(pathCall_);
|
||||
cliCore_->SetFileCall(fileCall_);
|
||||
}
|
||||
|
||||
bool RemoteFile::GetHome()
|
||||
{
|
||||
InfoMsg info;
|
||||
auto frame = QSharedPointer<FrameBuffer>::create();
|
||||
frame->data = infoPack(info);
|
||||
frame->type = FBT_CLI_ASK_HOME;
|
||||
frame->tid = cliCore_->GetRemoteID();
|
||||
return cliCore_->Send(frame);
|
||||
}
|
||||
|
||||
bool RemoteFile::GetDirFile(const QString& dir)
|
||||
{
|
||||
InfoMsg info;
|
||||
auto frame = QSharedPointer<FrameBuffer>::create();
|
||||
frame->data = infoPack(info);
|
||||
frame->type = FBT_CLI_ASK_DIRFILE;
|
||||
frame->tid = cliCore_->GetRemoteID();
|
||||
return cliCore_->Send(frame);
|
||||
}
|
||||
26
ClientCore/RemoteFile.h
Normal file
26
ClientCore/RemoteFile.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef REMOTE_FILE_H
|
||||
#define REMOTE_FILE_H
|
||||
|
||||
#include <InfoMsg.h>
|
||||
#include <Util.h>
|
||||
|
||||
#include "ClientCore.h"
|
||||
|
||||
class RemoteFile : public DirFileHelper
|
||||
{
|
||||
public:
|
||||
RemoteFile() = default;
|
||||
~RemoteFile() override = default;
|
||||
|
||||
public:
|
||||
void setClientCore(ClientCore* cliCore);
|
||||
|
||||
public:
|
||||
bool GetHome() override;
|
||||
bool GetDirFile(const QString& dir) override;
|
||||
|
||||
private:
|
||||
ClientCore* cliCore_;
|
||||
};
|
||||
|
||||
#endif // REMOTE_FILE_H
|
||||
Reference in New Issue
Block a user