diff --git a/.vscode/settings.json b/.vscode/settings.json index 92d0128..d25cfab 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -96,6 +96,14 @@ "xutility": "cpp", "mutex": "cpp", "array": "cpp", - "chrono": "cpp" + "chrono": "cpp", + "condition_variable": "cpp", + "forward_list": "cpp", + "iomanip": "cpp", + "ratio": "cpp", + "shared_mutex": "cpp", + "sstream": "cpp", + "stop_token": "cpp", + "thread": "cpp" } } \ No newline at end of file diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index 47859eb..66616b7 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -16,6 +16,8 @@ mainpanel.h mainpanel.cxx modeDirCtrl.h modeDirCtrl.cxx +transmhandler.h +transmhandler.cxx ) add_executable(gtransm ${PSOURCES}) diff --git a/gui/modeDirCtrl.cxx b/gui/modeDirCtrl.cxx index b7135b7..00b595f 100644 --- a/gui/modeDirCtrl.cxx +++ b/gui/modeDirCtrl.cxx @@ -2,6 +2,13 @@ CModeDirCtrl::CModeDirCtrl(wxWindow* parent, wxWindowID id) : wxGenericDirCtrl(parent, id) { + wxFileSystem::AddHandler(new CTransmHandler()); + wxFileSystem::AddHandler(new wxLocalFSHandler()); + wxFileSystem fs; + wxFSFile* f = fs.OpenFile("transm://D:/test.txt"); + if (f == nullptr) { + wxLogError("Cannot open file"); + } } CModeDirCtrl::~CModeDirCtrl() diff --git a/gui/modeDirCtrl.h b/gui/modeDirCtrl.h index 6b14c48..b617716 100644 --- a/gui/modeDirCtrl.h +++ b/gui/modeDirCtrl.h @@ -1,13 +1,18 @@ #ifndef MODEDIRCTRL_H #define MODEDIRCTRL_H -#include +#include "transmhandler.h" #include +#include -class CModeDirCtrl : public wxGenericDirCtrl { +class CModeDirCtrl : public wxGenericDirCtrl +{ public: - CModeDirCtrl(wxWindow *parent, wxWindowID id = wxID_ANY); + CModeDirCtrl(wxWindow* parent, wxWindowID id = wxID_ANY); ~CModeDirCtrl(); + +protected: + // void OnExpandItem(wxTreeEvent& event) override; }; -#endif // MODEDIRCTRL_H \ No newline at end of file +#endif // MODEDIRCTRL_H \ No newline at end of file diff --git a/gui/transmhandler.cxx b/gui/transmhandler.cxx new file mode 100644 index 0000000..3633c24 --- /dev/null +++ b/gui/transmhandler.cxx @@ -0,0 +1,22 @@ +#include "transmhandler.h" + +CTransmHandler::CTransmHandler() +{ + file_ = std::make_shared(); +} + +wxFSFile* CTransmHandler::OpenFile(wxFileSystem& fs, const wxString& name) +{ + int a = 0; + return nullptr; +} + +bool CTransmHandler::CanOpen(const wxString& location) +{ + return location.StartsWith(wxT("transm://")); +} + +wxString CTransmHandler::FindFirst(const wxString& spec, int flags) +{ + return wxString(); +} diff --git a/gui/transmhandler.h b/gui/transmhandler.h new file mode 100644 index 0000000..9acaece --- /dev/null +++ b/gui/transmhandler.h @@ -0,0 +1,22 @@ +#ifndef FILEHANDLER_H +#define FILEHANDLER_H + +#include +#include +#include + +class CTransmHandler : public wxFileSystemHandler +{ +public: + CTransmHandler(); + +public: + wxFSFile* OpenFile(wxFileSystem& fs, const wxString& name) override; + bool CanOpen(const wxString& location) override; + wxString FindFirst(const wxString& spec, int flags = 0) override; + +private: + std::shared_ptr file_; +}; + +#endif // FILEHANDLER_H \ No newline at end of file diff --git a/protocol/CMakeLists.txt b/protocol/CMakeLists.txt index d223c85..688fb7f 100644 --- a/protocol/CMakeLists.txt +++ b/protocol/CMakeLists.txt @@ -4,16 +4,15 @@ project(protocol LANGUAGES CXX) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) +find_package(wxWidgets CONFIG REQUIRED) + set(PSOURCES -filebase.h -filebase.cxx +transmfile.h +transmfile.cxx communicate.h communicate.cxx -fileimp/localfile.h -fileimp/localfile.cxx -fileimp/remotefile.h -fileimp/remotefile.cxx ) add_library(protocol STATIC ${PSOURCES}) +target_link_libraries(protocol PRIVATE wx::base) target_include_directories(protocol PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) \ No newline at end of file diff --git a/protocol/filebase.cxx b/protocol/filebase.cxx deleted file mode 100644 index e900f63..0000000 --- a/protocol/filebase.cxx +++ /dev/null @@ -1,27 +0,0 @@ -#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 deleted file mode 100644 index 5850aff..0000000 --- a/protocol/filebase.h +++ /dev/null @@ -1,24 +0,0 @@ -#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 deleted file mode 100644 index 026107c..0000000 --- a/protocol/fileimp/localfile.cxx +++ /dev/null @@ -1,14 +0,0 @@ -#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 deleted file mode 100644 index 0dbcd8b..0000000 --- a/protocol/fileimp/localfile.h +++ /dev/null @@ -1,16 +0,0 @@ -#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 deleted file mode 100644 index 4e3f3f2..0000000 --- a/protocol/fileimp/remotefile.cxx +++ /dev/null @@ -1,14 +0,0 @@ -#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 deleted file mode 100644 index 53d5ad2..0000000 --- a/protocol/fileimp/remotefile.h +++ /dev/null @@ -1,16 +0,0 @@ -#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 diff --git a/protocol/transmfile.cxx b/protocol/transmfile.cxx new file mode 100644 index 0000000..45ff52e --- /dev/null +++ b/protocol/transmfile.cxx @@ -0,0 +1,13 @@ +#include "transmfile.h" + +CTransmFile::CTransmFile() +{ +} + +CTransmFile::~CTransmFile() +{ +} + +void CTransmFile::SetRemoteIpPort(const wxString& remote_ip, int remote_port) +{ +} diff --git a/protocol/transmfile.h b/protocol/transmfile.h new file mode 100644 index 0000000..2a2bd38 --- /dev/null +++ b/protocol/transmfile.h @@ -0,0 +1,22 @@ +#ifndef FILEBASE_H +#define FILEBASE_H + +#include +#include +#include + +class CTransmFile +{ +public: + CTransmFile(); + ~CTransmFile(); + +public: + void SetRemoteIpPort(const wxString& remote_ip, int remote_port); + +protected: + wxString remote_ip_{}; + int remote_port_{9898}; +}; + +#endif // FILEBASE_Ha \ No newline at end of file