From 4b86ebc5c5e3a0cb2391f7a6af0285fde6cc54a1 Mon Sep 17 00:00:00 2001 From: taynpg Date: Tue, 17 Jun 2025 12:00:46 +0800 Subject: [PATCH] console: basic code. --- CMakeLists.txt | 3 ++- ClientCore/FileTrans.cpp | 4 ++++ Console/CMakeLists.txt | 17 +++++++++++++++++ Console/Console.cpp | 1 + Console/Console.h | 9 +++++++++ Console/main.cpp | 14 ++++++++++++++ 6 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 Console/CMakeLists.txt create mode 100644 Console/Console.cpp create mode 100644 Console/Console.h create mode 100644 Console/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a50d65..45b8db2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.16) project(frelay VERSION 0.1.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 11) @@ -32,5 +32,6 @@ add_subdirectory(Server) add_subdirectory(ClientCore) add_subdirectory(Util) add_subdirectory(Gui) +add_subdirectory(Console) add_subdirectory(Struct) add_subdirectory(Test) diff --git a/ClientCore/FileTrans.cpp b/ClientCore/FileTrans.cpp index 6b84142..8efd667 100644 --- a/ClientCore/FileTrans.cpp +++ b/ClientCore/FileTrans.cpp @@ -27,6 +27,8 @@ void FileTrans::fbtReqSend(QSharedPointer frame) { // judget is same client's same file. + // judget if file exits etc. + // send InfoMsg info = infoUnpack(frame->data); auto doTask = QSharedPointer::create(); @@ -123,6 +125,8 @@ void FileTrans::fbtFileTrans(QSharedPointer frame) void FileTrans::fbtAnsSendFailed(QSharedPointer frame) { + InfoMsg info = infoUnpack(frame->data); + qCritical() << QString(tr("request file:%1 failed. reason:%2")).arg(info.path).arg(info.msg); } void FileTrans::fbtAnsSendSuccess(QSharedPointer frame) diff --git a/Console/CMakeLists.txt b/Console/CMakeLists.txt new file mode 100644 index 0000000..1544ada --- /dev/null +++ b/Console/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.16) + +project(frelayConsole LANGUAGES CXX) + +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Network) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Network) + +add_executable(frelayConsole Console.h Console.cpp main.cpp ../Res/ico.rc) +target_link_libraries(frelayConsole PRIVATE Protocol Util) +target_link_libraries(frelayConsole PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Network) \ No newline at end of file diff --git a/Console/Console.cpp b/Console/Console.cpp new file mode 100644 index 0000000..4a357f9 --- /dev/null +++ b/Console/Console.cpp @@ -0,0 +1 @@ +#include "Console.h" \ No newline at end of file diff --git a/Console/Console.h b/Console/Console.h new file mode 100644 index 0000000..961c86d --- /dev/null +++ b/Console/Console.h @@ -0,0 +1,9 @@ +#ifndef FRELAY_CONSOLE_H +#define FRELAY_CONSOLE_H + +class RelayConsole +{ + +}; + +#endif // FRELAY_CONSOLE_H diff --git a/Console/main.cpp b/Console/main.cpp new file mode 100644 index 0000000..4c4b42d --- /dev/null +++ b/Console/main.cpp @@ -0,0 +1,14 @@ +#include + +#include "Console.h" +#include + +int main(int argc, char* argv[]) +{ + QCoreApplication app(argc, argv); + + Util::InitLogger("frelayConsole.log", "frelayConsole"); + qInstallMessageHandler(Util::ConsoleMsgHander); + + return app.exec(); +} \ No newline at end of file