From ecce50d58f4edffca978d4224ab61bfdd1bea8c3 Mon Sep 17 00:00:00 2001 From: taynpg Date: Thu, 3 Apr 2025 17:19:39 +0800 Subject: [PATCH] =?UTF-8?q?add=EF=BC=9A=E6=B7=BB=E5=8A=A0=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=8D=8F=E8=AE=AE=E6=9E=B6=E5=AD=90=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 3 ++- gui/CMakeLists.txt | 4 +++- gui/design/basepanel.cxx | 2 +- gui/design/basepanel.h | 4 ++-- gui/modeDirCtrl.cxx | 9 +++++++++ gui/modeDirCtrl.h | 13 +++++++++++++ protocol/CMakeLists.txt | 19 +++++++++++++++++++ protocol/communicate.cxx | 0 protocol/communicate.h | 4 ++++ protocol/filebase.cxx | 27 +++++++++++++++++++++++++++ protocol/filebase.h | 24 ++++++++++++++++++++++++ protocol/fileimp/localfile.cxx | 14 ++++++++++++++ protocol/fileimp/localfile.h | 16 ++++++++++++++++ protocol/fileimp/remotefile.cxx | 14 ++++++++++++++ protocol/fileimp/remotefile.h | 16 ++++++++++++++++ 15 files changed, 164 insertions(+), 5 deletions(-) create mode 100644 gui/modeDirCtrl.cxx create mode 100644 gui/modeDirCtrl.h create mode 100644 protocol/CMakeLists.txt create mode 100644 protocol/communicate.cxx create mode 100644 protocol/communicate.h create mode 100644 protocol/filebase.cxx create mode 100644 protocol/filebase.h create mode 100644 protocol/fileimp/localfile.cxx create mode 100644 protocol/fileimp/localfile.h create mode 100644 protocol/fileimp/remotefile.cxx create mode 100644 protocol/fileimp/remotefile.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c8ddef..becdd69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,4 +18,5 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE} add_subdirectory(util) add_subdirectory(server-core) add_subdirectory(server) -add_subdirectory(gui) \ No newline at end of file +add_subdirectory(gui) +add_subdirectory(protocol) \ No newline at end of file diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index cdc0c15..47859eb 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -14,8 +14,10 @@ design/basepanel.h design/basepanel.cxx mainpanel.h mainpanel.cxx +modeDirCtrl.h +modeDirCtrl.cxx ) add_executable(gtransm ${PSOURCES}) -target_link_libraries(gtransm PRIVATE wx::base wx::core) +target_link_libraries(gtransm PRIVATE wx::base wx::core protocol) set_target_properties(gtransm PROPERTIES WIN32_EXECUTABLE TRUE) \ No newline at end of file diff --git a/gui/design/basepanel.cxx b/gui/design/basepanel.cxx index 198782d..03403f9 100644 --- a/gui/design/basepanel.cxx +++ b/gui/design/basepanel.cxx @@ -13,7 +13,7 @@ void CBasePanel::Init() edPort_ = new wxTextCtrl(this, wxID_ANY, _("")); btnConnect_ = new wxButton(this, wxID_ANY, _("Connect")); btnDisconnect_ = new wxButton(this, wxID_ANY, _("DisConnect")); - dirctrl_ = new wxGenericDirCtrl(this); + dirctrl_ = new CModeDirCtrl(this); rbtLocal_ = new wxRadioButton(this, wxID_ANY, _("Local")); rbtRemote_ = new wxRadioButton(this, wxID_ANY, _("Remote")); lbState_ = new wxStaticText(this, wxID_ANY, _("State")); diff --git a/gui/design/basepanel.h b/gui/design/basepanel.h index 435747e..4a8b201 100644 --- a/gui/design/basepanel.h +++ b/gui/design/basepanel.h @@ -2,7 +2,7 @@ #define BASEMAIN_H #include -#include +#include "../modeDirCtrl.h" constexpr int g_BaseBorder = 3; @@ -20,7 +20,7 @@ public: wxTextCtrl* edPort_{}; wxButton* btnConnect_{}; wxButton* btnDisconnect_{}; - wxGenericDirCtrl* dirctrl_{}; + CModeDirCtrl* dirctrl_{}; wxRadioButton* rbtLocal_{}; wxRadioButton* rbtRemote_{}; wxStaticText* lbState_{}; diff --git a/gui/modeDirCtrl.cxx b/gui/modeDirCtrl.cxx new file mode 100644 index 0000000..b7135b7 --- /dev/null +++ b/gui/modeDirCtrl.cxx @@ -0,0 +1,9 @@ +#include "modeDirCtrl.h" + +CModeDirCtrl::CModeDirCtrl(wxWindow* parent, wxWindowID id) : wxGenericDirCtrl(parent, id) +{ +} + +CModeDirCtrl::~CModeDirCtrl() +{ +} diff --git a/gui/modeDirCtrl.h b/gui/modeDirCtrl.h new file mode 100644 index 0000000..6b14c48 --- /dev/null +++ b/gui/modeDirCtrl.h @@ -0,0 +1,13 @@ +#ifndef MODEDIRCTRL_H +#define MODEDIRCTRL_H + +#include +#include + +class CModeDirCtrl : public wxGenericDirCtrl { +public: + CModeDirCtrl(wxWindow *parent, wxWindowID id = wxID_ANY); + ~CModeDirCtrl(); +}; + +#endif // MODEDIRCTRL_H \ No newline at end of file diff --git a/protocol/CMakeLists.txt b/protocol/CMakeLists.txt new file mode 100644 index 0000000..d223c85 --- /dev/null +++ b/protocol/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.16) + +project(protocol LANGUAGES CXX) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(PSOURCES +filebase.h +filebase.cxx +communicate.h +communicate.cxx +fileimp/localfile.h +fileimp/localfile.cxx +fileimp/remotefile.h +fileimp/remotefile.cxx +) + +add_library(protocol STATIC ${PSOURCES}) +target_include_directories(protocol PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) \ No newline at end of file diff --git a/protocol/communicate.cxx b/protocol/communicate.cxx new file mode 100644 index 0000000..e69de29 diff --git a/protocol/communicate.h b/protocol/communicate.h new file mode 100644 index 0000000..ebd4b70 --- /dev/null +++ b/protocol/communicate.h @@ -0,0 +1,4 @@ +#ifndef COMMUNICATE_H +#define COMMUNICATE_H + +#endif // COMMUNICATE_H \ No newline at end of file diff --git a/protocol/filebase.cxx b/protocol/filebase.cxx new file mode 100644 index 0000000..e900f63 --- /dev/null +++ b/protocol/filebase.cxx @@ -0,0 +1,27 @@ +#include "filebase.h" +#include "fileimp/localfile.h" +#include "fileimp/remotefile.h" + +CFileBase::CFileBase() +{ +} + +CFileBase::~CFileBase() +{ +} + +std::shared_ptr CFileBase::Instance(FileOperType type) +{ + std::shared_ptr ret = nullptr; + switch (type) { + case TYPE_LOCAL: + ret = std::make_shared(); + break; + case TYPE_REMOTE: + ret = std::make_shared(); + break; + default: + break; + } + return ret; +} diff --git a/protocol/filebase.h b/protocol/filebase.h new file mode 100644 index 0000000..5850aff --- /dev/null +++ b/protocol/filebase.h @@ -0,0 +1,24 @@ +#ifndef FILEBASE_H +#define FILEBASE_H + +#include + +enum FileOperType { + TYPE_LOCAL, + TYPE_REMOTE +}; + +class CFileBase +{ +public: + CFileBase(); + virtual ~CFileBase(); + +public: + virtual bool Open(const char* filename) = 0; + +public: + static std::shared_ptr Instance(FileOperType type); +}; + +#endif // FILEBASE_H \ No newline at end of file diff --git a/protocol/fileimp/localfile.cxx b/protocol/fileimp/localfile.cxx new file mode 100644 index 0000000..026107c --- /dev/null +++ b/protocol/fileimp/localfile.cxx @@ -0,0 +1,14 @@ +#include "localfile.h" + +CLocalFile::CLocalFile() +{ +} + +CLocalFile::~CLocalFile() +{ +} + +bool CLocalFile::Open(const char* filename) +{ + return false; +} diff --git a/protocol/fileimp/localfile.h b/protocol/fileimp/localfile.h new file mode 100644 index 0000000..0dbcd8b --- /dev/null +++ b/protocol/fileimp/localfile.h @@ -0,0 +1,16 @@ +#ifndef LOCALFILE_H +#define LOCALFILE_H + +#include "../filebase.h" + +class CLocalFile : public CFileBase +{ +public: + CLocalFile(); + ~CLocalFile(); + +public: + bool Open(const char* filename) override; +}; + +#endif // LOCALFILE_H \ No newline at end of file diff --git a/protocol/fileimp/remotefile.cxx b/protocol/fileimp/remotefile.cxx new file mode 100644 index 0000000..4e3f3f2 --- /dev/null +++ b/protocol/fileimp/remotefile.cxx @@ -0,0 +1,14 @@ +#include "remotefile.h" + +CRemoteFile::CRemoteFile() +{ +} + +CRemoteFile::~CRemoteFile() +{ +} + +bool CRemoteFile::Open(const char* filename) +{ + return false; +} diff --git a/protocol/fileimp/remotefile.h b/protocol/fileimp/remotefile.h new file mode 100644 index 0000000..53d5ad2 --- /dev/null +++ b/protocol/fileimp/remotefile.h @@ -0,0 +1,16 @@ +#ifndef REMOTE_H +#define REMOTE_H + +#include "../filebase.h" + +class CRemoteFile : public CFileBase +{ +public: + CRemoteFile(); + ~CRemoteFile(); + +public: + bool Open(const char* filename) override; +}; + +#endif // REMOTE_H \ No newline at end of file