Kaynağa Gözat

V0.2.1
1、修改工程,可以添加剂啊多个demo
2、添加了qmqtt库和qmqtt的demo
3、添加了qt的http的demo

Apple 7 ay önce
ebeveyn
işleme
4d6f7f2636
94 değiştirilmiş dosya ile 2805 ekleme ve 1568 silme
  1. 14 56
      CMakeLists.txt
  2. 68 0
      Libraries/LHHTTPAPI/FindLHHttpAPI.cmake
  3. 151 0
      Libraries/LHHTTPAPI/inc/lhhttpapi.h
  4. BIN
      Libraries/LHHTTPAPI/lib/MinGW_32/LHSqlWebInterface.dll
  5. BIN
      Libraries/LHHTTPAPI/lib/MinGW_32/LHSqlWebInterfaced.dll
  6. BIN
      Libraries/LHHTTPAPI/lib/MinGW_32/libcurl.dll
  7. BIN
      Libraries/LHHTTPAPI/lib/MinGW_64/LHSqlWebInterface.dll
  8. BIN
      Libraries/LHHTTPAPI/lib/MinGW_64/LHSqlWebInterfaced.dll
  9. BIN
      Libraries/LHHTTPAPI/lib/MinGW_64/libcurl.dll
  10. 270 0
      Libraries/LHHTTPAPI/src/lhhttpapi.cpp
  11. 86 0
      Libraries/LHQLog/FindLHQLog.cmake
  12. 126 0
      Libraries/LHQLog/inc/LHLog_file_sink.h
  13. 78 0
      Libraries/LHQLog/inc/LHQLogAPI.h
  14. 10 0
      Libraries/LHQLog/inc/LogInit.h
  15. BIN
      Libraries/LHQLog/lib/MinGW_32/debug/LHQLogd.dll
  16. BIN
      Libraries/LHQLog/lib/MinGW_32/debug/libLHQLogd.a
  17. BIN
      Libraries/LHQLog/lib/MinGW_32/release/LHQLog.dll
  18. BIN
      Libraries/LHQLog/lib/MinGW_32/release/libLHQLog.a
  19. BIN
      Libraries/LHQLog/lib/MinGW_64/debug/LHQLogd.dll
  20. BIN
      Libraries/LHQLog/lib/MinGW_64/debug/libLHQLogd.a
  21. BIN
      Libraries/LHQLog/lib/MinGW_64/release/LHQLog.dll
  22. BIN
      Libraries/LHQLog/lib/MinGW_64/release/libLHQLog.a
  23. BIN
      Libraries/LHQLog/lib/uos_x64/release/libLHQLog.so.1.0.0.zip
  24. 101 0
      Libraries/LHQLog/src/LHQLogAPI.cpp
  25. 96 0
      Libraries/LHQLog/src/LogInit.cpp
  26. BIN
      Libraries/LIBS.zip
  27. BIN
      Libraries/msvc2022/bin/qmqtt.dll
  28. BIN
      Libraries/msvc2022/bin/qmqttd.dll
  29. 0 38
      Libraries/msvc2022/include/qmqtt/qmqtt.h
  30. 0 286
      Libraries/msvc2022/include/qmqtt/qmqtt_client.h
  31. 0 137
      Libraries/msvc2022/include/qmqtt/qmqtt_frame.h
  32. 0 48
      Libraries/msvc2022/include/qmqtt/qmqtt_global.h
  33. 0 96
      Libraries/msvc2022/include/qmqtt/qmqtt_message.h
  34. 0 92
      Libraries/msvc2022/include/qmqtt/qmqtt_networkinterface.h
  35. 0 71
      Libraries/msvc2022/include/qmqtt/qmqtt_routedmessage.h
  36. 0 60
      Libraries/msvc2022/include/qmqtt/qmqtt_router.h
  37. 0 79
      Libraries/msvc2022/include/qmqtt/qmqtt_routesubscription.h
  38. 0 84
      Libraries/msvc2022/include/qmqtt/qmqtt_socketinterface.h
  39. 0 62
      Libraries/msvc2022/include/qmqtt/qmqtt_timerinterface.h
  40. 0 19
      Libraries/msvc2022/lib/cmake/qmqtt/qmqtt-debug.cmake
  41. 0 19
      Libraries/msvc2022/lib/cmake/qmqtt/qmqtt-release.cmake
  42. 0 107
      Libraries/msvc2022/lib/cmake/qmqtt/qmqtt.cmake
  43. 0 26
      Libraries/msvc2022/lib/cmake/qmqtt/qmqttConfig.cmake
  44. 0 65
      Libraries/msvc2022/lib/cmake/qmqtt/qmqttConfigVersion.cmake
  45. 0 19
      Libraries/msvc2022/lib/cmake/qmqtt/qmqttTargets-debug.cmake
  46. 0 19
      Libraries/msvc2022/lib/cmake/qmqtt/qmqttTargets-release.cmake
  47. 0 107
      Libraries/msvc2022/lib/cmake/qmqtt/qmqttTargets.cmake
  48. BIN
      Libraries/msvc2022/lib/qmqtt.lib
  49. BIN
      Libraries/msvc2022/lib/qmqttd.lib
  50. 6 1
      Libraries/qmqtt/Findqmqtt.cmake
  51. BIN
      Libraries/sm_dll/doc/sm国密算法接口说明文档.docx
  52. 90 0
      Libraries/sm_dll/findSM.cmake
  53. 91 0
      Libraries/sm_dll/inc/defs.h
  54. 285 0
      Libraries/sm_dll/inc/smclass.h
  55. BIN
      Libraries/sm_dll/libs/linux/SM_Dll_exe.zip
  56. BIN
      Libraries/sm_dll/libs/linux/x64/libSM_Dll.so
  57. BIN
      Libraries/sm_dll/libs/linux/x64/with_debug_info/libSM_Dll.so
  58. BIN
      Libraries/sm_dll/libs/win/x64/libSM_Dll.dll
  59. BIN
      Libraries/sm_dll/libs/win/x64/libSM_Dll.lib
  60. BIN
      Libraries/sm_dll/libs/win/x64/ucrtbase.dll
  61. BIN
      Libraries/sm_dll/libs/win/x64/ucrtbased.dll
  62. BIN
      Libraries/sm_dll/libs/win/x64/vcruntime140.dll
  63. BIN
      Libraries/sm_dll/libs/win/x64/vcruntime140d.dll
  64. BIN
      Libraries/sm_dll/libs/win/x64/with_debug_info/libSM_Dll.dll
  65. BIN
      Libraries/sm_dll/libs/win/x64/with_debug_info/libSM_Dll.lib
  66. BIN
      Libraries/sm_dll/libs/win/x86/libSM_Dll.dll
  67. BIN
      Libraries/sm_dll/libs/win/x86/libSM_Dll.lib
  68. BIN
      Libraries/sm_dll/libs/win/x86/ucrtbase.dll
  69. BIN
      Libraries/sm_dll/libs/win/x86/ucrtbased.dll
  70. BIN
      Libraries/sm_dll/libs/win/x86/vcruntime140.dll
  71. BIN
      Libraries/sm_dll/libs/win/x86/vcruntime140d.dll
  72. BIN
      Libraries/sm_dll/libs/win/x86/with_debug_info/libSM_Dll.dll
  73. BIN
      Libraries/sm_dll/libs/win/x86/with_debug_info/libSM_Dll.lib
  74. 483 0
      Libraries/sm_dll/src/smclass.cpp
  75. 0 0
      common/LightLog/LightLog.cpp
  76. 28 0
      common/LightLog/LightLog.h
  77. 3 3
      common/Logs/loginit.cpp
  78. 136 0
      common/http/QtHttps.cpp
  79. 36 0
      common/http/QtHttps.h
  80. 110 0
      common/mqtt/fromMQTT.cpp
  81. 40 0
      common/mqtt/fromMQTT.h
  82. 67 0
      demo/http/CMakeLists.txt
  83. 0 0
      demo/http/main.cpp
  84. 44 0
      demo/http/widget.cpp
  85. 32 0
      demo/http/widget.h
  86. 45 0
      demo/http/widget.ui
  87. 68 0
      demo/mqtt/CMakeLists.txt
  88. 14 0
      demo/mqtt/main.cpp
  89. 0 0
      demo/mqtt/qmqtt-API.md
  90. 170 0
      demo/mqtt/widget.cpp
  91. 6 0
      demo/mqtt/widget.h
  92. 51 0
      demo/mqtt/widget.ui
  93. 0 55
      widget.cpp
  94. 0 19
      widget.ui

+ 14 - 56
CMakeLists.txt

@@ -1,6 +1,6 @@
 cmake_minimum_required(VERSION 3.5)
 
-project(Library VERSION 1.1 LANGUAGES CXX)
+project(Library_Project VERSION 1.1 LANGUAGES CXX)
 
 set(CMAKE_AUTOUIC ON)
 set(CMAKE_AUTOMOC ON)
@@ -133,12 +133,14 @@ elseif(CMAKE_SYSTEM_NAME MATCHES Linux)
 endif()
 
 
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/libraries/sm_dll)
+
 find_package(fmt REQUIRED)
 find_package(spdlog REQUIRED)
 #在Windows中可能有冲突的地方,直接指明路径
 # find_package(Freetype REQUIRED PATHS ${freetype_DIR})
 find_package(qmqtt REQUIRED)
-
+find_package(SM REQUIRED)
 #打印搜索到的信息
 
 message(STATUS "fmt Found: ${fmt_FOUND}")
@@ -151,10 +153,7 @@ message(STATUS "spdlog Version: ${spdlog_VERSION}")
 # message(STATUS "FreeType Version : ${Freetype_VERSION}")
 
 message(STATUS "qmqtt Found : ${qmqtt_FOUND}")
-message(STATUS "qmqtt Version : ${qmqtt_VERSION}")
-message(STATUS "qmqtt_INCLUDE_DIR : ${qmqtt_INCLUDE_DIR}")
-message(STATUS "qmqtt_LIBRARY : ${qmqtt_LIBRARY}")
-
+message(STATUS "SM_LIBRARY FOUND: ${SM_FOUND}")
 
 #=========================================================
 #****************  搜索添加头文件和源文件 *****************
@@ -165,12 +164,18 @@ message(STATUS "qmqtt_LIBRARY : ${qmqtt_LIBRARY}")
 include_directories(
     ${CMAKE_SOURCE_DIR}
     ${CMAKE_SOURCE_DIR}/common/Logs
+    # ${CMAKE_SOURCE_DIR}/common/http
+    ${CMAKE_SOURCE_DIR}/common/LightLog
+    # ${CMAKE_SOURCE_DIR}/common/mqtt
 )
 
 #包含源文件
-file(GLOB SRC
+file(GLOB GLOBAL_SRC
     ${CMAKE_SOURCE_DIR}/*.cpp
     ${CMAKE_SOURCE_DIR}/common/Logs/*.cpp
+    # ${CMAKE_SOURCE_DIR}/common/mqtt/*.cpp
+    # ${CMAKE_SOURCE_DIR}/common/http/*.cpp
+    ${CMAKE_SOURCE_DIR}/common/LightLog/*.cpp
 )
 
 
@@ -179,52 +184,5 @@ file(GLOB SRC
 #=========================================================
 
 
-#这里添加WIN32可以消除release模式下的cmd窗口
-if(CMAKE_BUILD_TYPE MATCHES Debug)
-    add_executable(${exec_name}
-        # WIN32
-        ${SRC}
-    )
-elseif(CMAKE_BUILD_TYPE MATCHES Release)
-    add_executable(${exec_name}
-        # WIN32
-        ${SRC}
-    )
-endif()
-
-target_include_directories(${exec_name} PRIVATE
-    ${qmqtt_INCLUDE_DIR}
-)
-
-
-target_link_libraries(${exec_name} PRIVATE
-    Qt5::Widgets
-    Qt5::Core
-    # Qt5::SerialPort
-    Qt5::Network
-    # Qt5::Multimedia
-    Qt5::Sql
-)
-
-target_link_libraries(${exec_name} PRIVATE 
-    # Freetype::Freetype
-    fmt::fmt
-    spdlog::spdlog
-    ${qmqtt_LIBRARY}
-    
-)
-
-
-#target_link_libraries(${exec_name} PRIVATE ${FT2_Name})
-
-if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
-    target_link_libraries(${exec_name} PRIVATE
-        # debug ${qmqtt_LIBRARY}
-        # optimized ${qmqtt_LIBRARY}
-    )
-elseif(CMAKE_CXX_COMPILER_ID MATCHES GNU)
-    target_link_libraries(${exec_name} PRIVATE
-        # debug ${CMAKE_SOURCE_DIR}/Libraries/gcc7.3/bin/Qt5Qmqtt.dll
-        # optimized ${CMAKE_SOURCE_DIR}/Libraries/gcc7.3/bin/Qt5Qmqtt.dll
-    )
-endif()
+# add_subdirectory(${CMAKE_SOURCE_DIR}/demo/mqtt)
+add_subdirectory(${CMAKE_SOURCE_DIR}/demo/http)

+ 68 - 0
Libraries/LHHTTPAPI/FindLHHttpAPI.cmake

@@ -0,0 +1,68 @@
+
+#查找LHHttpAPI库
+message(STATUS "===== FindLHHTTPAPI.cmake =====")
+
+#查找头文件
+unset(INCLUDE_DIR CACHE)
+find_path(INCLUDE_DIR 
+    NAMES lhhttpapi.h
+    PATHS ${CMAKE_CURRENT_LIST_DIR}/inc
+    NO_DEFAULT_PATH
+)
+
+list(APPEND LHHTTPAPI_INCLUDE_DIRS ${INCLUDE_DIR})
+
+#查找源文件
+unset(SOURCE_DIR CACHE)
+find_path(SOURCE_DIR 
+    NAMES lhhttpapi.cpp
+    PATHS ${CMAKE_CURRENT_LIST_DIR}/src
+    NO_DEFAULT_PATH
+)
+
+list(APPEND LHHTTPAPI_SOURCE_DIRS ${SOURCE_DIR})
+
+#查找库文件,在这里区分平台,Debug和Release,32位和64位
+unset(LIBRARY_DIR CACHE)
+
+if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+    #64位
+    if(CMAKE_SIZEOF_VOID_P MATCHES 8)
+        if(CMAKE_BUILD_TYPE MATCHES "Debug")
+            find_library(LIBRARY_DIR 
+                NAMES LHSqlWebInterfaced
+                PATHS ${CMAKE_CURRENT_LIST_DIR}/lib/MinGW_64
+                NO_DEFAULT_PATH
+            )
+        else()
+            find_library(LIBRARY_DIR 
+                NAMES LHSqlWebInterface
+                PATHS ${CMAKE_CURRENT_LIST_DIR}/lib/MinGW_64
+                NO_DEFAULT_PATH
+            )
+        endif()
+    #32位
+    elseif(CMAKE_SIZEOF_VOID_P MATCHES 4)
+        if(CMAKE_BUILD_TYPE MATCHES "Debug")
+            find_library(LIBRARY_DIR 
+                NAMES LHSqlWebInterfaced
+                PATHS ${CMAKE_CURRENT_LIST_DIR}/lib/MinGW_32
+                NO_DEFAULT_PATH
+            )
+        else()
+            find_library(LIBRARY_DIR 
+                NAMES LHSqlWebInterface
+                PATHS ${CMAKE_CURRENT_LIST_DIR}/lib/MinGW_32
+                NO_DEFAULT_PATH
+            )
+        endif()
+endif()
+
+list(APPLEND LHHTTPAPI_LIBRARY ${LIBRARY_DIR})
+
+#定义变量
+if(LHHTTPAPI_INCLUDE_DIRS AND LHHTTPAPI_SOURCE_DIRS AND LHHTTPAPI_LIBRARY)
+    set(LHHTTPAPI_FOUND TRUE)
+else()
+    set(LHHTTPAPI_FOUND FALSE)
+endif()

+ 151 - 0
Libraries/LHHTTPAPI/inc/lhhttpapi.h

@@ -0,0 +1,151 @@
+#pragma once
+#include <QString>
+#include <QObject>
+#include <QLibrary>
+#include <QDateTime>
+#include <QMutex>
+#include <QWaitCondition>
+// #include "Common/singleton.h"
+#include "threadcontroller.h"
+
+#define LH_HTTPAPI_SUCC 0
+
+// 用New
+#define LHAPI_BUFFER_SIZE_NEW 2048000
+#define LHAPI_BUFFER_SIZE_ARY 4096
+
+extern int g_nHttpTimeOut;
+
+// 操作类型【1查询 2更新 3删除 4插入 5存储过程】
+enum enDBOperatorType
+{
+    EDBOT_Select = 1,
+    EDBOT_Update,
+    EDBOT_Delete,
+    EDBOT_Insert,
+    EDBOT_Procedure,
+    EDBOT_Batch,    // 单动作批量操作,失败全部回滚
+    EDBOT_BatchTransAction // 多动作批量操作,失败回滚
+};
+
+class lhhttpapi : public QObject
+{
+    Q_OBJECT
+public:
+    typedef int (*FunDBInit)(const char* lpUrl);
+    typedef int (*FunDBLogin)(const char *pLocalIP, const char *pSerid, const char* CType, char *pszUserToken, int nSize);
+    typedef int (*FunDBGetServerList)(char *pszList, int nSize);
+    typedef int (*FunDBGetServerInfo)(const char* pSerid, const char* pszUserToken, char* pServerInfo, int nSize);
+    typedef int (*FunDBGetChannelList)(const char* pSerid,char *pszList, int nSize);
+    typedef int (*FunDBDoInterface)(const char* pSerid,const char* CType,const char* strtoken,int nOperatorType, const char * strParam, char *strRet, int nSize);
+    typedef int (*FunDoGetLastError)(char *pError, int nLen, int *nErrorCode);
+
+    typedef int (*FunSetHttpTimeOut)(int nTimeout);
+
+    // 获取网络文件大小,返回文件大小
+    typedef int64_t (*FunDoGetHttpFileSize)(const char *pszHttpAddr);
+
+    // 获取网络文件内容,返回内容大小
+    typedef int64_t (*FunDoGetHttpFileContent)(const char* pHttpAddr, char *pszContent, int nSize);
+
+    // 获取汉字拼音首字母,空格、数字等其它字符保持不动
+    typedef int (*FunDoWord2Pyjc)(const char* pszWord, char *pszContent, int nSize);
+
+    // 文件上传FTP
+    typedef int (*FunDoUploadFtpFile)(const char* pszLocalFilePath, const char* pszFtpFilePath);
+    typedef int (*FunDoUploadFtpFileContent)(const char* pszFileContent, int size, const char* pszFtpFilePath);
+
+    // FTP
+    typedef int (*FunDoCurlDeleteFtpFile)(const char* user, const char* pwd, const char* pszFtpFile);
+    typedef int (*FunDoCurlUploadFtpFile)(const char* user, const char* pwd, const char* pszLocalFilePath, const char* pszFtpFile);
+    typedef int (*FunDoCurlUploadFtpFileContent)(const char* user, const char* pwd, const char* pszFileContent, int nSize, const char* pszFtpFile);
+
+    // 获取数据库信息
+    typedef int (*FunDoGetDBInfo)(const char* strSerid, const char* strtoken, char* pDBInfo, int nsize);
+public:
+    explicit lhhttpapi(QObject *parent = nullptr);
+    ~lhhttpapi();
+
+public:
+    QLibrary *m_pQLib;
+
+    FunDBInit fnDBInit;
+    FunDBLogin fnDBLogin;
+    FunDBGetServerList fnDBGettServerList;
+    FunDBGetChannelList fnDBGetChannelList;
+    FunDBGetServerInfo fnDBGetServerInfo;
+
+    FunSetHttpTimeOut fnSetHttpTimeOut;
+    FunDoGetHttpFileSize fnGetHttpFileSize;
+    FunDoGetHttpFileContent fnGetHttpFileContent;
+    FunDoGetLastError fnGetLastError;
+    FunDoWord2Pyjc    fnDoWord2Pyjc;
+    FunDoUploadFtpFile fnDoUploadFtpFile;
+    FunDoUploadFtpFileContent fnDoUploadFtpFileContent;
+
+    FunDoCurlDeleteFtpFile  fnDoCurlDeleteFtpFile;
+    FunDoCurlUploadFtpFile  fnDoCurlUploadFtpFile;
+    FunDoCurlUploadFtpFileContent fnDoCurlUploadFtpFileContent;
+
+    FunDoGetDBInfo  fnDoGetDBInfo;
+
+    QMutex m_mutexWorkerDestroy;
+    QWaitCondition m_Condition;
+    FunDBDoInterface fnDBDoInterface;
+
+public:
+    bool Load(QString file);
+    bool UnLoad();
+
+    int SetHttpTimeOut(int nTimeout);
+    QString DoGetLastError(int *nErrorCode);
+    QString GetServerID() const {return m_serID;}
+    QString GetClientType() const {return m_clientType;}
+
+    int DBQInit(QString strUrl);
+    int DBQGetServerList(QString& serverList);
+    int DBQGetServerInfo(const QString& serid, QString& serverInfo);
+    /**
+     * @brief 登录数据库
+     * 
+     * @param LocalIP 
+     * @param Serid 
+     * @param CType 
+     * @param strUserToken 传出参数
+     * @return int 
+     */
+    int DBQLogin(QString LocalIP, QString Serid, QString CType, QString &strUserToken);
+    int DBQDoInterface(int nOperatorType, const QString &strParamXml, QString &strRetXml, bool wait = true);
+
+private slots:
+    void OnWorkerFinished();
+private:
+    QString m_token;
+    QMutex m_mtx;
+    QString m_serID;
+    QString m_clientType;
+    QTimer* m_tUpToken;
+};
+
+class DoInterfaceObject : public ThreadWorker
+{
+    Q_OBJECT
+public:
+    explicit DoInterfaceObject(lhhttpapi *pApi, const QString &strToken, int nOperatorType, const QString &strParamXml);
+    virtual ~DoInterfaceObject() override {}
+    QString GetRetXML() const {return m_strRetXml;}
+    int GetResult() const {return m_nResult;}
+public slots:
+    void DoInit() override {}
+    void DoWork() override;
+signals:
+    void sig_WorkFinished();
+public:
+    lhhttpapi *m_pApi;
+    QString m_strToken;
+    int m_nOperatorType;
+    QString m_strParamXml;
+    QString m_strRetXml;
+    int m_nResult;
+};
+

BIN
Libraries/LHHTTPAPI/lib/MinGW_32/LHSqlWebInterface.dll


BIN
Libraries/LHHTTPAPI/lib/MinGW_32/LHSqlWebInterfaced.dll


BIN
Libraries/LHHTTPAPI/lib/MinGW_32/libcurl.dll


BIN
Libraries/LHHTTPAPI/lib/MinGW_64/LHSqlWebInterface.dll


BIN
Libraries/LHHTTPAPI/lib/MinGW_64/LHSqlWebInterfaced.dll


BIN
Libraries/LHHTTPAPI/lib/MinGW_64/libcurl.dll


+ 270 - 0
Libraries/LHHTTPAPI/src/lhhttpapi.cpp

@@ -0,0 +1,270 @@
+#include "lhhttpapi.h"
+#include <QCoreApplication>
+#include <QDebug>
+
+int g_nHttpTimeOut = 0;
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+DoInterfaceObject::DoInterfaceObject(lhhttpapi *pApi, const QString &strToken, int nOperatorType, const QString &strParamXml)
+    : ThreadWorker()
+    , m_pApi(pApi)
+    , m_strToken(strToken)
+    , m_nOperatorType(nOperatorType)
+    , m_strParamXml(strParamXml)
+    , m_nResult(-1)
+{
+
+}
+
+void DoInterfaceObject::DoWork()
+{
+    if(m_pApi != nullptr)
+    {
+        QString serid = m_pApi->GetServerID();
+        QString appType = m_pApi->GetClientType();
+        std::unique_ptr<char[]> buffer(new char[LHAPI_BUFFER_SIZE_NEW]{0});
+        m_nResult = m_pApi->fnDBDoInterface(serid.toUtf8().data(),appType.toUtf8().data(),m_strToken.toUtf8().data(),
+                                            m_nOperatorType,m_strParamXml.toUtf8().data(),buffer.get(),LHAPI_BUFFER_SIZE_NEW);
+        m_strRetXml = QString::fromUtf8(buffer.get());
+    }
+    emit sig_WorkFinished();
+}
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+lhhttpapi::lhhttpapi(QObject *parent)
+    : QObject(parent),
+    m_pQLib(nullptr),
+    fnDBInit(nullptr),
+    fnDBLogin(nullptr),
+    fnDBGettServerList(nullptr),
+    fnDBGetChannelList(nullptr),
+    fnDBGetServerInfo(nullptr),
+    fnSetHttpTimeOut(nullptr),
+    fnGetHttpFileSize(nullptr),
+    fnGetHttpFileContent(nullptr),
+    fnGetLastError(nullptr),
+    fnDoWord2Pyjc(nullptr),
+    fnDoUploadFtpFile(nullptr),
+    fnDoUploadFtpFileContent(nullptr),
+    fnDoCurlDeleteFtpFile(nullptr),
+    fnDoCurlUploadFtpFile(nullptr),
+    fnDoCurlUploadFtpFileContent(nullptr),
+    fnDoGetDBInfo(nullptr),
+    fnDBDoInterface(nullptr),
+    m_tUpToken(nullptr)
+{
+#ifdef Q_OS_WIN
+    QString exePath = QCoreApplication::applicationDirPath();
+
+#ifdef QT_DEBUG
+// #ifdef C_DEBUG
+    exePath += "/LHSqlWebInterfaced.dll";
+    Load(exePath.toLatin1());
+#else
+    exePath += "/LHSqlWebInterface.dll";
+    Load(exePath.toLatin1());
+#endif // debug
+#elif defined Q_OS_LINUX
+    Load(QString("%1/%2").arg(QCoreApplication::applicationDirPath(), "LHSqlWebInterface.so"));
+#endif // win
+    m_tUpToken = new QTimer(this);
+    m_tUpToken->setInterval(25 * 60 * 1000);
+    m_tUpToken->start();
+    connect(m_tUpToken, &QTimer::timeout, this, [this] {
+        QString token("");
+        //qInfo() << "WebApi timeout, old token: " << m_token;
+        DBQLogin("", m_serID, m_clientType, token);
+        //qInfo() << "new token: " << m_token;
+    });
+}
+
+
+lhhttpapi::~lhhttpapi()
+{
+    UnLoad();
+}
+
+bool lhhttpapi::Load(QString file)
+{
+    m_pQLib = new QLibrary(file);
+    if (!m_pQLib->load())
+    {
+        QString strLog = QString("Module %1 load failed -1").arg(file);
+        qInfo() << strLog;
+        qInfo() << m_pQLib->errorString();
+        return false;
+    }
+    fnDBInit = reinterpret_cast<FunDBInit>(m_pQLib->resolve("DBInit"));
+    fnDBLogin = reinterpret_cast<FunDBLogin>(m_pQLib->resolve("DBLogin"));
+    fnDBGettServerList = reinterpret_cast<FunDBGetServerList>(m_pQLib->resolve("DBGetServerList"));
+    fnDBGetChannelList = reinterpret_cast<FunDBGetChannelList>(m_pQLib->resolve("DBGetChannelList"));
+    fnDBGetServerInfo = reinterpret_cast<FunDBGetServerInfo>(m_pQLib->resolve("DBGetServerInfo"));
+    fnDBDoInterface = reinterpret_cast<FunDBDoInterface>(m_pQLib->resolve("DBDoInterface"));
+
+    fnSetHttpTimeOut = reinterpret_cast<FunSetHttpTimeOut>(m_pQLib->resolve("SetHttpTimeOut"));
+    fnGetLastError = reinterpret_cast<FunDoGetLastError>(m_pQLib->resolve("DBGetLastError"));
+    fnGetHttpFileSize = reinterpret_cast<FunDoGetHttpFileSize>(m_pQLib->resolve("DoGetHttpFileSize"));
+    fnGetHttpFileContent = reinterpret_cast<FunDoGetHttpFileContent>(m_pQLib->resolve("DoGetHttpFileContent"));
+    fnDoWord2Pyjc = reinterpret_cast<FunDoWord2Pyjc>(m_pQLib->resolve("DoWord2Pyjc"));
+    fnDoUploadFtpFile = reinterpret_cast<FunDoUploadFtpFile>(m_pQLib->resolve("DoUploadFtpFile"));
+    fnDoUploadFtpFileContent = reinterpret_cast<FunDoUploadFtpFileContent>(m_pQLib->resolve("DoUploadFtpFileContent"));
+
+    fnDoCurlUploadFtpFile = reinterpret_cast<FunDoCurlUploadFtpFile>(m_pQLib->resolve("DoCurlUploadFtpFile"));
+    fnDoCurlDeleteFtpFile = reinterpret_cast<FunDoCurlDeleteFtpFile>(m_pQLib->resolve("DoCurlDeleteFtpFile"));
+    fnDoCurlUploadFtpFileContent = reinterpret_cast<FunDoCurlUploadFtpFileContent>(m_pQLib->resolve("DoCurlUploadFtpFileContent"));
+
+    fnDoGetDBInfo = reinterpret_cast<FunDoGetDBInfo>(m_pQLib->resolve("DoGetDBInfo"));
+
+    if(fnDBInit == nullptr||fnDBLogin == nullptr||fnDBGetChannelList == nullptr||fnSetHttpTimeOut == nullptr||
+            fnDBDoInterface == nullptr|| fnDBGettServerList == nullptr || fnGetLastError == nullptr)
+    {
+        QString strLog = QString("Module %1 load failed,lack interface").arg(file);
+        qInfo() << strLog;
+        return false;
+    }
+    return true;
+}
+
+bool lhhttpapi::UnLoad()
+{
+    if(m_pQLib == nullptr) return false;
+    int ret = m_pQLib->unload();
+    m_pQLib = nullptr;
+    return ret;
+}
+
+int lhhttpapi::SetHttpTimeOut(int nTimeout)
+{
+    if(fnSetHttpTimeOut == nullptr) return -1;
+    return fnSetHttpTimeOut(nTimeout);
+}
+
+QString lhhttpapi::DoGetLastError(int *nErrorCode)
+{
+    if(fnGetLastError == nullptr) return QString();
+
+    int nLen = LHAPI_BUFFER_SIZE_NEW;
+    char *pError = new char[LHAPI_BUFFER_SIZE_NEW]{0};
+    int nRet = fnGetLastError(pError, nLen, nErrorCode);
+
+    if(nRet != 0)
+    {
+        delete [] pError; pError = nullptr;
+        return QString();
+    }
+
+    QString strRet2 = QString::fromUtf8(pError);
+
+    delete [] pError; pError = nullptr;
+    return strRet2;
+}
+
+int lhhttpapi::DBQInit(QString strUrl)
+{
+    char *szUrl = nullptr;
+    QByteArray baUrl = strUrl.toUtf8();
+    szUrl = baUrl.data();
+
+    if(fnDBInit == nullptr) return -1;
+
+    //SetHttpTimeOut(g_nHttpTimeOut);
+    return fnDBInit(szUrl);
+}
+
+int lhhttpapi::DBQGetServerList(QString& serverList)
+{
+    if(fnDBGettServerList == nullptr) return -1;
+    serverList.clear();
+    char* pBuff = new char[LHAPI_BUFFER_SIZE_NEW]{0};
+    int nRet = fnDBGettServerList(pBuff, LHAPI_BUFFER_SIZE_NEW);
+    serverList = QString(pBuff);
+    delete[] pBuff;
+    pBuff = nullptr;
+    return nRet;
+}
+
+int lhhttpapi::DBQGetServerInfo(const QString &serid, QString &serverInfo)
+{
+    if (nullptr == fnDBGetServerInfo) return -1;
+    serverInfo.clear();
+    char* pBuff = new char[LHAPI_BUFFER_SIZE_NEW]{0};
+    int nRet = fnDBGetServerInfo(serid.toUtf8(), m_token.toUtf8(), pBuff, LHAPI_BUFFER_SIZE_NEW);
+    if (LH_HTTPAPI_SUCC == nRet) {
+        serverInfo = QString::fromUtf8(pBuff);
+    }
+    delete[] pBuff;
+    pBuff = nullptr;
+
+    return nRet;
+}
+
+int lhhttpapi::DBQLogin(QString LocalIP, QString Serid, QString CType, QString &strUserToken)
+{
+    //QMutexLocker locker(&m_mtx);
+    std::unique_ptr<char[]> charlist(new char[LHAPI_BUFFER_SIZE_NEW]{0});
+
+    char *szIP = nullptr;
+    QByteArray baIP = LocalIP.toUtf8();
+    szIP = baIP.data();
+
+    char *szDBID = nullptr;
+    QByteArray baDBID = Serid.toUtf8();
+    szDBID = baDBID.data();
+
+    char *szCType = nullptr;
+    QByteArray baCType = CType.toUtf8();
+    szCType = baCType.data();
+
+    if(fnDBLogin == nullptr) {
+        return -1;
+    }
+    int nRet = fnDBLogin(szIP, szDBID, szCType, charlist.get(), LHAPI_BUFFER_SIZE_NEW);
+    if (LH_HTTPAPI_SUCC == nRet)
+    {
+        m_token = QString::fromUtf8(charlist.get());
+        m_serID = Serid;
+        m_clientType = CType;
+
+        strUserToken = m_token;
+    }
+
+    return nRet;
+}
+
+void lhhttpapi::OnWorkerFinished()
+{
+    m_Condition.wakeAll();
+}
+
+int lhhttpapi::DBQDoInterface(int nOperatorType, const QString &strParamXml, QString &strRetXml, bool wait)
+{
+    if(fnDBDoInterface == nullptr) return -1;
+
+    //QMutexLocker locker(&m_mtx);
+    int ret = 0;
+    if(wait)
+    {
+        DoInterfaceObject *pWorker = new DoInterfaceObject(this, m_token, nOperatorType, strParamXml);
+        connect(pWorker, &DoInterfaceObject::sig_WorkFinished, this, &lhhttpapi::OnWorkerFinished, Qt::DirectConnection);
+        pWorker->Start(100000);
+        QMutexLocker locker(&m_mutexWorkerDestroy);
+        m_Condition.wait(&m_mutexWorkerDestroy);
+        strRetXml = pWorker->GetRetXML();
+        ret = pWorker->GetResult();
+        pWorker->BlockStop();
+        if(ret != 0)
+        {
+            int nerror = 0;
+            QString strerror = DoGetLastError(&nerror);
+            qDebug()<<"返回错误为:" << strerror;
+            if (strerror.compare("票据非法") == 0) {
+            }
+        }
+        return ret;
+    }
+
+    std::unique_ptr<char[]> buffer(new char[LHAPI_BUFFER_SIZE_NEW]{0});
+    ret = fnDBDoInterface(m_serID.toUtf8().data(),m_clientType.toUtf8().data(),m_token.toUtf8().data(),
+                              nOperatorType,strParamXml.toUtf8().data(),buffer.get(),LHAPI_BUFFER_SIZE_NEW);
+    strRetXml = QString::fromUtf8(buffer.get());
+    return ret;
+}

+ 86 - 0
Libraries/LHQLog/FindLHQLog.cmake

@@ -0,0 +1,86 @@
+
+#查找LHQLog库
+
+message(STATUS "===== FindLHQLog.cmake =====")
+
+#查找头文件
+unset(INCLUDE_DIR CACHE)
+find_path(INCLUDE_DIR 
+    NAMES LHQLog.h
+    PATHS ${CMAKE_CURRENT_LIST_DIR}/inc
+    NO_DEFAULT_PATH
+)
+
+list(APPEND LHQLog_INCLUDE_DIRS ${INCLUDE_DIR})
+
+#查找源文件
+unset(SOURCE_DIR CACHE)
+find_path(SOURCE_DIR 
+    NAMES LHQLog.cpp
+    PATHS ${CMAKE_CURRENT_LIST_DIR}/src
+    NO_DEFAULT_PATH
+)
+
+list(APPEND LHQLog_SOURCE_DIRS ${SOURCE_DIR})
+
+#查找库文件,在这里区分平台,Debug和Release,32位和64位
+unset(LIBRARY_DIR CACHE)
+
+if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+    #64位
+    if(CMAKE_SIZEOF_VOID_P MATCHES 8)
+        if(CMAKE_BUILD_TYPE MATCHES "Debug")
+            find_library(LIBRARY_DIR 
+                NAMES LHQLog
+                PATHS ${CMAKE_CURRENT_LIST_DIR}/lib/MinGW_64/debug
+                NO_DEFAULT_PATH
+            )
+        else()
+            find_library(LIBRARY_DIR 
+                NAMES LHQLog
+                PATHS ${CMAKE_CURRENT_LIST_DIR}/lib/MinGW_64/release
+                NO_DEFAULT_PATH
+            )
+        endif()
+    #32位
+    elseif(CMAKE_SIZEOF_VOID_P MATCHES 4)
+        if(CMAKE_BUILD_TYPE MATCHES "Debug")
+            find_library(LIBRARY_DIR 
+                NAMES LHQLog
+                PATHS ${CMAKE_CURRENT_LIST_DIR}/lib/MinGW_32/debug
+                NO_DEFAULT_PATH
+            )
+        else()
+            find_library(LIBRARY_DIR 
+                NAMES LHQLog
+                PATHS ${CMAKE_CURRENT_LIST_DIR}/lib/MinGW_32/release
+                NO_DEFAULT_PATH
+            )
+        endif()
+    endif()
+#Linux
+endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
+        find_library(LIBRARY_DIR 
+            NAMES LHQLog
+            PATHS ${CMAKE_CURRENT_LIST_DIR}/lib/uos_x64/release
+            NO_DEFAULT_PATH
+        )
+endif()
+
+list(APPEND LHQLog_LIBRARY ${LIBRARY_DIR})
+
+#设置变量
+if(LHQLog_INCLUDE_DIRS AND LHQLog_SOURCE_DIRS AND LHQLog_LIBRARY)
+    set(LHQLog_FOUND TRUE)
+    # CACHE命令用于定义一个名为LHQLog_INCLUDE_DIRS的缓存变量。这个变量用于存储LHQLog的包含目录路径。
+    # 通过将其定义为缓存变量,用户可以在CMake配置过程中通过命令行或图形界面设置该变量的值。CACHE INTERNAL部分
+    # 指定了缓存变量的类型。在这种情况下,INTERNAL表示该变量只能在CMake脚本内部使用,而不能被外部访问或修改。
+    # 通过使用缓存变量,可以使CMake配置更加灵活和可配置。用户可以根据其特定的需求设置缓存变量的值,而不需要修改
+    # CMake脚本本身。这对于构建可定制的软件项目非常有用。
+    set(LHQLog_INCLUDE_DIRS ${LHQLog_INCLUDE_DIRS} CACHE INTERNAL "LHQLog include directories")
+    set(LHQLog_SOURCE_DIRS ${LHQLog_SOURCE_DIRS} CACHE INTERNAL "LHQLog source directories")
+    set(LHQLog_LIBRARY ${LHQLog_LIBRARY} CACHE INTERNAL "LHQLog library")
+else()
+    set(LHQLog_FOUND FALSE)
+
+endif()

+ 126 - 0
Libraries/LHQLog/inc/LHLog_file_sink.h

@@ -0,0 +1,126 @@
+#ifndef LHLOG_FILE_SINK_H
+#define LHLOG_FILE_SINK_H
+
+/**
+ * @file LHLog_file_sink.h 
+ * @author your name (you@domain.com)
+ * @brief 自定义的日志输出管道,输出到LHQLog中,由他写入文件
+ * @version 0.1
+ * @date 2024-07-18
+ * 
+ * @copyright Copyright (c) 2024
+ * 
+ */
+
+#include "spdlog/common.h"
+#include "spdlog/details/log_msg.h"
+#include "spdlog/details/synchronous_factory.h"
+#include "spdlog/sinks/base_sink.h"
+#include <array>
+#include "LHQLogAPI.h"
+
+#include <QString>
+#include <QDebug>
+
+namespace spdlog {
+namespace sinks {
+
+template<typename Mutex>
+class LHLog_file_sink : public base_sink<Mutex>
+{
+public:
+    /**
+     * @brief Construct a new lhlog file sink object
+     * 
+     * @param lhLog LHLog实例
+     * @param labName 需要加载的库名
+     * @param strLogName 日志模块名称
+     */
+    LHLog_file_sink(CLHQLogApi* lhLog, QString labName, QString strLogName) : 
+        m_lhLog(lhLog),
+        m_libName(labName),
+        m_strLogName(strLogName)
+    {
+        if(m_lhLog != nullptr)
+        {
+            m_lhLog->Load(labName);
+            m_lhLog->DoInitial(strLogName);
+        }
+    }
+    ~LHLog_file_sink() override = default;
+
+protected:
+    /* 关键函数,从这里获取数据 */
+    void sink_it_(const details::log_msg &msg) override {
+
+        /* 获取输出等级 */
+        level::level_enum msgLevel = msg.level;
+
+        /* 内存中的数据 */
+        memory_buf_t formatted;
+        /* 从msg原始数据经过变换,处理通配符相关的东西,好像是处理啥指针问题? */
+        base_sink<Mutex>::formatter_->format(msg, formatted);
+        /* 去掉结尾的换行符 */
+        auto size = formatted.size();
+        // qDebug() << "formatted.size() = " << formatted.size();
+        if(size >= 2 && ( formatted[size - 1] == '\n' ) && ( formatted[size - 2] == '\r') )
+        {
+            formatted.resize(size - 2);
+        }
+        else if(size >= 1 && (formatted[size - 1] == '\n' || formatted[size - 1] == '\r'))
+        {
+            formatted.resize(size - 1);
+        }
+        /* 添加\0,QString以这个为结尾 */
+        formatted.push_back('\0');
+        
+        /* 这个应该是处理兼容性的问题,C++17以前的兼容性问题
+        *  这个可以提供对字符串的快速访问,不需要拷贝字符串 */
+        const string_view_t str = string_view_t(formatted.data(), formatted.size());
+        // qDebug() << "Aftter string_view_t formatted.size() = " << formatted.size();
+        /* 根据等级输出 */
+        if(msgLevel == level::trace) {
+            /* 这个等级不输出,理论上也不会有这个等级的日志到这一步,在外面就拦截了 */
+            
+        }
+        else if (msgLevel == level::debug) {
+            m_lhLog->DoWriteLogEx(m_strLogName, ELT_Log_Debug, str.data());
+        }
+        else if (msgLevel == level::info) {
+            m_lhLog->DoWriteLogEx(m_strLogName, ELT_Log_Common, str.data());
+        }
+        else if(msgLevel == level::warn) {
+            m_lhLog->DoWriteLogEx(m_strLogName, ELT_Log_Error, str.data());
+        }
+        else if (msgLevel == level::err) {
+            m_lhLog->DoWriteLogEx(m_strLogName, ELT_Log_Error, str.data());
+        }
+        else if(msgLevel == level::critical) {
+            /* 因该不会用到这个等级,不输出 */
+            
+        }else if (msgLevel == level::off) {
+            /* 不输出 */
+        
+        }
+
+        // QString strLog = QString::fromLocal8Bit(str.data(), str.size());
+        
+        // qDebug() << strLog;
+    }
+
+    void flush_() override {}
+
+private:
+    CLHQLogApi* m_lhLog = nullptr;
+    QString m_strLogName;
+    QString m_libName;
+};
+
+using LHLog_file_sink_mt = LHLog_file_sink<std::mutex>;
+using LHLog_file_sink_st = LHLog_file_sink<details::null_mutex>;
+
+} // namespace sinks
+} // namespace spdlog
+
+
+#endif /* LHLOG_FILE_SINK_H */

+ 78 - 0
Libraries/LHQLog/inc/LHQLogAPI.h

@@ -0,0 +1,78 @@
+#pragma once
+
+#include <QString>
+#include <QLibrary>
+#include <QTime>
+#include <QElapsedTimer>
+#include <QDebug>
+
+
+
+#define DoLog(msg)      WRITE_LOG(QString("[%1:%2:%3] %4").arg(__FILE__, __FUNCTION__, QString::number(__LINE__), msg))
+#define DoError(msg)    WRITE_ERROR(QString("[%1:%2:%3] %4").arg(__FILE__, __FUNCTION__, QString::number(__LINE__), msg))
+#define DoDebug(msg)    WRITE_LOG_DEBUG(QString("[%1:%2:%3] %4").arg(__FILE__, __FUNCTION__, QString::number(__LINE__), msg))
+#define MyLog(msg)      qDebug() << "[" << __FILE__ << __FUNCTION__ << __LINE__ << QTime::currentTime().toString("hh:mm:ss.zzz") << "]" << msg
+
+
+#define LimitLog(interval, msg) \
+    do{\
+        static QElapsedTimer timer;\
+        if (!timer.isValid()) {\
+            timer.start();\
+        }\
+        if (timer.elapsed() >= interval) {\
+            timer.restart();\
+            DoLog(msg);\
+        }\
+    }while(0);
+
+enum enLogType
+{
+    ELT_Log_ALL = 0,
+
+    // Debug.ini[system]Debug=1生效
+    ELT_Log_Debug,
+    // 错误日志,不自动删除和清空
+    ELT_Log_Error,
+    // 文件日志,就一个文件,超过10M自动清空,如记录xml,json的信息
+    ELT_Log_File,
+
+    // 一定会输出的日志
+    // 操作日志,如点击按钮,按快捷键
+    ELT_Log_Operator,
+    // 仅仅主程序记录,按键日志
+    ELT_Log_KeyDown,
+    // 通用日志,无特殊标记
+    ELT_Log_Common,
+};
+
+extern void WRITE_LOG(QString log);
+extern void WRITE_ERROR(QString log);
+extern void WRITE_LOG_DEBUG(QString log);
+
+class CLHQLogApi
+{
+public:
+    CLHQLogApi();
+    ~CLHQLogApi();
+
+    bool Load(QString file);
+    int DoInitial(QString strLogName);
+
+    // 为了适应,一个进程多模块日志的功能,需要给出Log名称
+    int DoWriteLogEx(QString strLogName, int nLogType, QString strLog);
+    int DoWriteFileLog(QString strLogFilePath, QString strLog);
+    int DoWriteLog(int nLogType, QString strLog);
+private:
+    typedef int (*FunDoInitial)(const char* szLogName);
+    typedef int (*FunDoWriteLog)(const char* szLogName, int nLogType, const char* szLog);
+    typedef int (*FunDoWriteFileLog)(const char* szFilePath, const char* szLog);
+private:
+    QLibrary m_QLib;
+    QString m_strLogName;
+
+    FunDoInitial        fnDoInitial;
+    FunDoWriteLog       fnDoWriteLog;
+    FunDoWriteFileLog   fnDoWriteFileLog;
+};
+extern CLHQLogApi g_apiLhQLog;

+ 10 - 0
Libraries/LHQLog/inc/LogInit.h

@@ -0,0 +1,10 @@
+#ifndef LOGINIT_H
+#define LOGINIT_H
+
+class QString;
+
+void initLog(QString ModuleName);
+
+
+
+#endif /* LOGINIT_H */

BIN
Libraries/LHQLog/lib/MinGW_32/debug/LHQLogd.dll


BIN
Libraries/LHQLog/lib/MinGW_32/debug/libLHQLogd.a


BIN
Libraries/LHQLog/lib/MinGW_32/release/LHQLog.dll


BIN
Libraries/LHQLog/lib/MinGW_32/release/libLHQLog.a


BIN
Libraries/LHQLog/lib/MinGW_64/debug/LHQLogd.dll


BIN
Libraries/LHQLog/lib/MinGW_64/debug/libLHQLogd.a


BIN
Libraries/LHQLog/lib/MinGW_64/release/LHQLog.dll


BIN
Libraries/LHQLog/lib/MinGW_64/release/libLHQLog.a


BIN
Libraries/LHQLog/lib/uos_x64/release/libLHQLog.so.1.0.0.zip


+ 101 - 0
Libraries/LHQLog/src/LHQLogAPI.cpp

@@ -0,0 +1,101 @@
+#include "LHQLogAPI.h"
+#include <QTime>
+// #include "./External/Core/MyDebugLog.h"
+
+CLHQLogApi g_apiLhQLog;
+void WRITE_LOG(QString log)
+{
+    int idx = log.indexOf(QLatin1String("]"));
+    QString msg = idx >= 0 ? log.mid(idx + 1) : log;
+#ifdef QT_NO_DEBUG
+    g_apiLhQLog.DoWriteLog(ELT_Log_Common, msg);
+#else
+    log.insert(idx+1, QTime::currentTime().toString("hh:mm:ss.zzz"));
+    // LOG(log);
+#endif
+}
+
+void WRITE_ERROR(QString log)
+{
+    int idx = log.indexOf(QLatin1String("]"));
+    QString msg = idx >= 0 ? log.mid(idx + 1) : log;
+#ifdef QT_NO_DEBUG
+    g_apiLhQLog.DoWriteLog(ELT_Log_Error, msg);
+#else
+    log.insert(idx+1, QTime::currentTime().toString("hh:mm:ss.zzz"));
+    // LOG(log);
+#endif
+}
+
+void WRITE_LOG_DEBUG(QString log)
+{
+    int idx = log.indexOf(QLatin1String("]"));
+    QString msg = idx >= 0 ? log.mid(idx + 1) : log;
+#ifdef QT_NO_DEBUG
+    g_apiLhQLog.DoWriteLog(ELT_Log_Debug, msg);
+#else
+    log.insert(idx+1, QTime::currentTime().toString("hh:mm:ss.zzz"));
+    // LOG(log);
+#endif
+}
+
+CLHQLogApi::CLHQLogApi()
+{
+    fnDoInitial         = nullptr;
+    fnDoWriteLog        = nullptr;
+    fnDoWriteFileLog    = nullptr;
+}
+
+CLHQLogApi::~CLHQLogApi()
+{
+    m_QLib.unload();
+}
+
+bool CLHQLogApi::Load(QString file)
+{
+    m_QLib.setFileName(file);
+    if (!m_QLib.load())
+	{
+        qDebug() << QString("Liberal %1 load failed!").arg(file);
+        //LOG(QString("模块%1加载失败-1").arg(file));
+		return false;
+    }
+    // qDebug() << QString("Liberal %1 load success!").arg(file);
+
+    fnDoInitial = (FunDoInitial)m_QLib.resolve("Initial");
+    fnDoWriteLog = (FunDoWriteLog)m_QLib.resolve("WriteLog");
+    fnDoWriteFileLog = (FunDoWriteFileLog)m_QLib.resolve("WriteFileLog");
+
+    if(fnDoInitial == nullptr || fnDoWriteLog == nullptr || fnDoWriteFileLog == nullptr)
+    {
+        //LOG(QString("模块%1加载失败,接口错误-2").arg(file));
+        return false;
+    }
+    return true;
+}
+
+int CLHQLogApi::DoInitial(QString strLogName)
+{
+    m_strLogName = strLogName;
+    if(fnDoInitial == nullptr) return -1;
+    return fnDoInitial(strLogName.toUtf8());
+}
+
+int CLHQLogApi::DoWriteLogEx(QString strLogName, int nLogType, QString strLog)
+{
+    if(fnDoWriteLog == nullptr) return -1;
+    return fnDoWriteLog(strLogName.toUtf8(), nLogType, strLog.toUtf8());
+}
+
+int CLHQLogApi::DoWriteLog(int nLogType, QString strLog)
+{
+    if(fnDoWriteLog == nullptr) return -1;
+    return fnDoWriteLog(m_strLogName.toUtf8(), nLogType, strLog.toUtf8());
+}
+
+int CLHQLogApi::DoWriteFileLog(QString strLogFilePath, QString strLog)
+{
+    if(fnDoWriteFileLog == nullptr) return -1;
+    return fnDoWriteFileLog(strLogFilePath.toUtf8(), strLog.toUtf8());
+}
+

+ 96 - 0
Libraries/LHQLog/src/LogInit.cpp

@@ -0,0 +1,96 @@
+#include "LogInit.h"
+
+#include "spdlog.h"
+#include "spdlog/sinks/stdout_color_sinks.h"
+#include "LHLog_file_sink.h"
+
+
+#include <QString>
+#include <QCoreApplication>
+
+/* 初始化spdlog,输入的是模组名称,可以为空 */
+void initLog(QString ModuleName)
+{
+
+    try {
+        /* 创建一个控制台sink */
+        auto sink_consolse = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
+        /* 创建一个文件sink,每天一个,00:00创建新的 */
+        // auto sink_file = std::make_shared<spdlog::sinks::daily_file_sink_mt>("FlowChartLog/log.txt",0,0);
+        /* 自定义的sink */
+    #if C_DEBUG
+        QString libName = QCoreApplication::applicationDirPath() + "/LHQLogd.dll";
+    #elif C_RELEASE
+        QString libName = QCoreApplication::applicationDirPath() + "/LHQLog.dll";
+    #endif
+        auto sink_custom = std::make_shared<spdlog::sinks::LHLog_file_sink_mt>(&g_apiLhQLog, libName, ModuleName);
+        /* 给默认记录器用的sink */
+        auto sink_default = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
+ 
+        /* 修改输出格式 */
+        sink_consolse->set_pattern("%^[%Y-%m-%d %H:%M:%S] [%l] [%n] [%s %#] %v %$");
+        // sink_file->set_pattern("[%Y-%m-%d %H:%M:%S] [%^%n%$] [%^%l%$] %s %#: %v");
+        sink_custom->set_pattern("%v");
+        sink_default->set_pattern("%^[%Y-%m-%d %H:%M:%S] [%l] [%s %#] %v %$");
+
+        /* 日志输出方向,终端和文件 */
+        std::vector<spdlog::sink_ptr> sinks;
+        sinks.push_back(sink_consolse);
+        // sinks.push_back(sink_file);
+        sinks.push_back(sink_custom);
+
+        /* 设置默认日志记录器,设置成自定义的sink */
+        spdlog::default_logger()->sinks().clear();
+        spdlog::default_logger()->sinks().push_back(sink_default);
+        spdlog::default_logger()->sinks().push_back(sink_custom);
+        // auto vecSinks =  spdlog::default_logger()->sinks();
+        // for(auto& sink : vecSinks)
+        // {
+        //     SPDLOG_INFO("sink name = {}", typeid(*sink).name());
+        // }
+        /* 创建一个标准输出 */
+        auto logger_main = std::make_shared<spdlog::logger>("main",begin(sinks),end(sinks));
+
+        /* 创建一个Line输出Logger */
+        auto logger_Line = std::make_shared<spdlog::logger>("Line",begin(sinks),end(sinks));
+        /* 创建一个Device输出Logger */
+        auto logger_Device = std::make_shared<spdlog::logger>("Device",begin(sinks),end(sinks));
+        /* 创建一个FlowChart logger */
+        auto logger_FlowChart = std::make_shared<spdlog::logger>("FlowChart",begin(sinks),end(sinks));
+        /* 创建一个Database logger */
+        auto logger_Database = std::make_shared<spdlog::logger>("Database",begin(sinks),end(sinks));
+        /* 创建一个MQTT logger */
+        auto logger_MQTT = std::make_shared<spdlog::logger>("MQTT",begin(sinks),end(sinks));
+
+//        /* 创建一个设备Info logger */
+//        auto logger_Info = std::make_shared<spdlog::logger>("DevInfo",begin(sinks),end(sinks));
+
+
+        /* 注册到注册表 */
+        spdlog::register_logger(logger_main);
+        spdlog::register_logger(logger_Line);
+        spdlog::register_logger(logger_Device);
+        spdlog::register_logger(logger_FlowChart);
+        spdlog::register_logger(logger_Database);
+        spdlog::register_logger(logger_MQTT);
+
+        /* 设置spdlog输出级别,默认的估计不输出debug这个级别
+         * 这是默认的设置,可以在外面单数设置输出方式
+         * release模式下不输出console的日志输出
+         * */
+#if  defined (C_DEBUG)
+        spdlog::set_level(spdlog::level::trace);
+        spdlog::flush_on(spdlog::level::trace);
+#elif defined(C_RELEASE)
+        spdlog::set_level(spdlog::level::info);             /* 只输出info以上的输出 */
+        spdlog::flush_on(spdlog::level::info);              /* 设置刷新等级 */
+        sink_consolse->set_level(spdlog::level::off);       /* 控制台不输出 */
+        sink_default->set_level(spdlog::level::off);        /* 默认sink也不输出 */
+#endif
+
+//    SPDLOG_LOGGER_DEBUG(logger_main,"******* 有行号且debug也能输出 *******");
+    }
+    catch (const spdlog::spdlog_ex& ex) {
+        qDebug() << "Log initialization failed: " << ex.what() ;
+    }
+}

BIN
Libraries/LIBS.zip


BIN
Libraries/msvc2022/bin/qmqtt.dll


BIN
Libraries/msvc2022/bin/qmqttd.dll


+ 0 - 38
Libraries/msvc2022/include/qmqtt/qmqtt.h

@@ -1,38 +0,0 @@
-/*
- * qmqtt.h - qmqtt library heaer
- *
- * Copyright (c) 2013  Ery Lee <ery.lee at gmail dot com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   * Redistributions of source code must retain the above copyright notice,
- *     this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of mqttc nor the names of its contributors may be used
- *     to endorse or promote products derived from this software without
- *     specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-#ifndef QMQTT_H
-#define QMQTT_H
-
-#include <qmqtt/qmqtt_message.h>
-#include <qmqtt/qmqtt_client.h>
-
-#endif // QMQTT_H

+ 0 - 286
Libraries/msvc2022/include/qmqtt/qmqtt_client.h

@@ -1,286 +0,0 @@
-/*
- * qmqtt_client.h - qmqtt client header
- *
- * Copyright (c) 2013  Ery Lee <ery.lee at gmail dot com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   * Redistributions of source code must retain the above copyright notice,
- *     this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of mqttc nor the names of its contributors may be used
- *     to endorse or promote products derived from this software without
- *     specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-#ifndef QMQTT_CLIENT_H
-#define QMQTT_CLIENT_H
-
-#include <qmqtt/qmqtt_global.h>
-
-#include <QObject>
-#include <QString>
-#include <QHostAddress>
-#include <QByteArray>
-#include <QAbstractSocket>
-#include <QScopedPointer>
-#include <QList>
-
-#ifdef QT_WEBSOCKETS_LIB
-#include <QWebSocket>
-#endif // QT_WEBSOCKETS_LIB
-
-#ifndef QT_NO_SSL
-#include <QSslConfiguration>
-QT_FORWARD_DECLARE_CLASS(QSslError)
-#endif // QT_NO_SSL
-
-#ifndef Q_ENUM_NS
-#define Q_ENUM_NS(x)
-#endif // Q_ENUM_NS
-
-namespace QMQTT {
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
-Q_MQTT_EXPORT Q_NAMESPACE
-#endif
-
-static const quint8 LIBRARY_VERSION_MAJOR = 0;
-static const quint8 LIBRARY_VERSION_MINOR = 3;
-static const quint8 LIBRARY_VERSION_REVISION = 1;
-//static const char* LIBRARY_VERSION = "0.3.1";
-
-enum MQTTVersion
-{
-    V3_1_0 = 3,
-    V3_1_1 = 4
-};
-Q_ENUM_NS(MQTTVersion)
-
-enum ConnectionState
-{
-    STATE_INIT = 0,
-    STATE_CONNECTING,
-    STATE_CONNECTED,
-    STATE_DISCONNECTED
-};
-Q_ENUM_NS(ConnectionState)
-
-enum ClientError
-{
-    UnknownError = 0,
-    SocketConnectionRefusedError,
-    SocketRemoteHostClosedError,
-    SocketHostNotFoundError,
-    SocketAccessError,
-    SocketResourceError,
-    SocketTimeoutError,
-    SocketDatagramTooLargeError,
-    SocketNetworkError,
-    SocketAddressInUseError,
-    SocketAddressNotAvailableError,
-    SocketUnsupportedSocketOperationError,
-    SocketUnfinishedSocketOperationError,
-    SocketProxyAuthenticationRequiredError,
-    SocketSslHandshakeFailedError,
-    SocketProxyConnectionRefusedError,
-    SocketProxyConnectionClosedError,
-    SocketProxyConnectionTimeoutError,
-    SocketProxyNotFoundError,
-    SocketProxyProtocolError,
-    SocketOperationError,
-    SocketSslInternalError,
-    SocketSslInvalidUserDataError,
-    SocketTemporaryError,
-    MqttUnacceptableProtocolVersionError=1<<16,
-    MqttIdentifierRejectedError,
-    MqttServerUnavailableError,
-    MqttBadUserNameOrPasswordError,
-    MqttNotAuthorizedError,
-    MqttNoPingResponse
-};
-Q_ENUM_NS(ClientError)
-
-class ClientPrivate;
-class Message;
-class Frame;
-class NetworkInterface;
-
-class Q_MQTT_EXPORT Client : public QObject
-{
-    Q_OBJECT
-    Q_PROPERTY(quint16 _port READ port WRITE setPort)
-    Q_PROPERTY(QHostAddress _host READ host WRITE setHost)
-    Q_PROPERTY(QString _hostName READ hostName WRITE setHostName)
-    Q_PROPERTY(QString _clientId READ clientId WRITE setClientId)
-    Q_PROPERTY(QString _username READ username WRITE setUsername)
-    Q_PROPERTY(QByteArray _password READ password WRITE setPassword)
-    Q_PROPERTY(quint16 _keepAlive READ keepAlive WRITE setKeepAlive)
-    Q_PROPERTY(MQTTVersion _version READ version WRITE setVersion)
-    Q_PROPERTY(bool _autoReconnect READ autoReconnect WRITE setAutoReconnect)
-    Q_PROPERTY(int _autoReconnectInterval READ autoReconnectInterval WRITE setAutoReconnectInterval)
-    Q_PROPERTY(bool _cleanSession READ cleanSession WRITE setCleanSession)
-    Q_PROPERTY(QString _willTopic READ willTopic WRITE setWillTopic)
-    Q_PROPERTY(quint8 _willQos READ willQos WRITE setWillQos)
-    Q_PROPERTY(bool _willRetain READ willRetain WRITE setWillRetain)
-    Q_PROPERTY(QByteArray _willMessage READ willMessage WRITE setWillMessage)
-    Q_PROPERTY(ConnectionState _connectionState READ connectionState)
-#ifndef QT_NO_SSL
-    Q_PROPERTY(QSslConfiguration _sslConfiguration READ sslConfiguration WRITE setSslConfiguration)
-#endif // QT_NO_SSL
-
-public:
-    Client(const QHostAddress& host = QHostAddress::LocalHost,
-           const quint16 port = 1883,
-           QObject* parent = nullptr);
-
-#ifndef QT_NO_SSL
-    Client(const QString& hostName,
-           const quint16 port,
-           const QSslConfiguration& config,
-           const bool ignoreSelfSigned=false,
-           QObject* parent = nullptr);
-#endif // QT_NO_SSL
-
-    // This function is provided for backward compatibility with older versions of QMQTT.
-    // If the ssl parameter is true, this function will load a private key ('cert.key') and a local
-    // certificate ('cert.crt') from the current working directory. It will also set PeerVerifyMode
-    // to None. This may not be the safest way to set up an SSL connection.
-    Client(const QString& hostName,
-           const quint16 port,
-           const bool ssl,
-           const bool ignoreSelfSigned,
-           QObject* parent = nullptr);
-
-#ifdef QT_WEBSOCKETS_LIB
-    // Create a connection over websockets
-    Client(const QString& url,
-           const QString& origin,
-           QWebSocketProtocol::Version version,
-           bool ignoreSelfSigned = false,
-           QObject* parent = nullptr);
-
-#ifndef QT_NO_SSL
-    Client(const QString& url,
-           const QString& origin,
-           QWebSocketProtocol::Version version,
-           const QSslConfiguration& config,
-           const bool ignoreSelfSigned = false,
-           QObject* parent = nullptr);
-#endif // QT_NO_SSL
-#endif // QT_WEBSOCKETS_LIB
-
-    // for testing purposes only
-    Client(NetworkInterface* network,
-           const QHostAddress& host = QHostAddress::LocalHost,
-           const quint16 port = 1883,
-           QObject* parent = nullptr);
-
-    virtual ~Client();
-
-    QHostAddress host() const;
-    QString hostName() const;
-    quint16 port() const;
-    QString clientId() const;
-    QString username() const;
-    QByteArray password() const;
-    QMQTT::MQTTVersion version() const;
-    quint16 keepAlive() const;
-    bool cleanSession() const;
-    bool autoReconnect() const;
-    int autoReconnectInterval() const;
-    ConnectionState connectionState() const;
-    QString willTopic() const;
-    quint8 willQos() const;
-    bool willRetain() const;
-    QByteArray willMessage() const;
-
-    bool isConnectedToHost() const;
-#ifndef QT_NO_SSL
-    QSslConfiguration sslConfiguration() const;
-    void setSslConfiguration(const QSslConfiguration& config);
-#endif // QT_NO_SSL
-
-public Q_SLOTS:
-    void setHost(const QHostAddress& host);
-    void setHostName(const QString& hostName);
-    void setPort(const quint16 port);
-    void setClientId(const QString& clientId);
-    void setUsername(const QString& username);
-    void setPassword(const QByteArray& password);
-    void setVersion(const MQTTVersion version);
-    void setKeepAlive(const quint16 keepAlive);
-    void setCleanSession(const bool cleanSession);
-    void setAutoReconnect(const bool value);
-    void setAutoReconnectInterval(const int autoReconnectInterval);
-    void setWillTopic(const QString& willTopic);
-    void setWillQos(const quint8 willQos);
-    void setWillRetain(const bool willRetain);
-    void setWillMessage(const QByteArray& willMessage);
-
-    void connectToHost();
-    void disconnectFromHost();
-
-    void subscribe(const QString& topic, const quint8 qos = 0);
-    void unsubscribe(const QString& topic);
-
-    quint16 publish(const QMQTT::Message& message);
-
-#ifndef QT_NO_SSL
-    void ignoreSslErrors();
-    void ignoreSslErrors(const QList<QSslError>& errors);
-#endif // QT_NO_SSL
-
-Q_SIGNALS:
-    void connected();
-    void disconnected();
-    void error(const QMQTT::ClientError error);
-
-    void subscribed(const QString& topic, const quint8 qos = 0);
-    void unsubscribed(const QString& topic);
-    void published(const QMQTT::Message& message, quint16 msgid = 0);
-    void received(const QMQTT::Message& message);
-    void pingresp();
-#ifndef QT_NO_SSL
-    void sslErrors(const QList<QSslError>& errors);
-#endif // QT_NO_SSL
-
-protected Q_SLOTS:
-    void onNetworkConnected();
-    void onNetworkDisconnected();
-    void onNetworkReceived(const QMQTT::Frame& frame);
-    void onTimerPingReq();
-    void onPingTimeout();
-    void onNetworkError(QAbstractSocket::SocketError error);
-#ifndef QT_NO_SSL
-    void onSslErrors(const QList<QSslError>& errors);
-#endif // QT_NO_SSL
-
-protected:
-    QScopedPointer<ClientPrivate> d_ptr;
-
-private:
-    Q_DISABLE_COPY(Client)
-    Q_DECLARE_PRIVATE(Client)
-};
-
-} // namespace QMQTT
-
-Q_DECLARE_METATYPE(QMQTT::ClientError)
-
-#endif // QMQTT_CLIENT_H

+ 0 - 137
Libraries/msvc2022/include/qmqtt/qmqtt_frame.h

@@ -1,137 +0,0 @@
-/*
- * qmqtt_frame.h - qmqtt frame heaer
- *
- * Copyright (c) 2013  Ery Lee <ery.lee at gmail dot com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   * Redistributions of source code must retain the above copyright notice,
- *     this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of mqttc nor the names of its contributors may be used
- *     to endorse or promote products derived from this software without
- *     specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-#ifndef QMQTT_FRAME_H
-#define QMQTT_FRAME_H
-
-#include <qmqtt_global.h>
-
-#include <QMetaType>
-#include <QByteArray>
-#include <QString>
-
-QT_FORWARD_DECLARE_CLASS(QDataStream)
-
-#define PROTOCOL_MAGIC_3_1_0 "MQIsdp"
-#define PROTOCOL_MAGIC_3_1_1 "MQTT"
-
-#define RANDOM_CLIENT_PREFIX "QMQTT-"
-
-#define CONNECT 0x10
-#define CONNACK 0x20
-#define PUBLISH 0x30
-#define PUBACK 0x40
-#define PUBREC 0x50
-#define PUBREL 0x60
-#define PUBCOMP 0x70
-#define SUBSCRIBE 0x80
-#define SUBACK 0x90
-#define UNSUBSCRIBE 0xA0
-#define UNSUBACK 0xB0
-#define PINGREQ 0xC0
-#define PINGRESP 0xD0
-#define DISCONNECT 0xE0
-
-#define LSB(A) quint8(A & 0x00FF)
-#define MSB(A) quint8((A & 0xFF00) >> 8)
-
-/*
-|--------------------------------------
-| 7 6 5 4 |     3    |  2 1  | 0      |
-|  Type   | DUP flag |  QoS  | RETAIN |
-|--------------------------------------
-*/
-#define GETTYPE(HDR)		(HDR & 0xF0)
-#define SETQOS(HDR, Q)		(HDR | ((Q) << 1))
-#define GETQOS(HDR)			((HDR & 0x06) >> 1)
-#define SETDUP(HDR, D)		(HDR | ((D) << 3))
-#define GETDUP(HDR)			((HDR & 0x08) >> 3)
-#define SETRETAIN(HDR, R)	(HDR | (R))
-#define GETRETAIN(HDR)		(HDR & 0x01)
-
-/*
-|----------------------------------------------------------------------------------
-|     7    |    6     |      5     |  4   3  |     2    |       1      |     0    |
-| username | password | willretain | willqos | willflag | cleansession | reserved |
-|----------------------------------------------------------------------------------
-*/
-#define FLAG_CLEANSESS(F, C)	(F | ((C) << 1))
-#define FLAG_WILL(F, W)			(F | ((W) << 2))
-#define FLAG_WILLQOS(F, Q)		(F | ((Q) << 3))
-#define FLAG_WILLRETAIN(F, R) 	(F | ((R) << 5))
-#define FLAG_PASSWD(F, P)		(F | ((P) << 6))
-#define FLAG_USERNAME(F, U)		(F | ((U) << 7))
-
-namespace QMQTT {
-
-class Q_MQTT_EXPORT Frame
-{
-public:
-    explicit Frame();
-    explicit Frame(const quint8 header);
-    explicit Frame(const quint8 header, const QByteArray &data);
-    virtual ~Frame();
-
-    Frame(const Frame& other);
-    Frame& operator=(const Frame& other);
-
-    bool operator==(const Frame& other) const;
-    inline bool operator!=(const Frame& other) const
-    { return !operator==(other); }
-
-    quint8 header() const;
-    QByteArray data() const;
-
-    quint16 readInt();
-    quint8 readChar();
-    QByteArray readByteArray();
-    QString readString();
-
-    void writeInt(const quint16 i);
-    void writeChar(const quint8 c);
-    void writeByteArray(const QByteArray &data);
-    void writeString(const QString &string);
-    void writeRawData(const QByteArray &data);
-
-    //TODO: FIXME LATER
-    void write(QDataStream &stream) const;
-    bool encodeLength(QByteArray &lenbuf, int length) const;
-
-private:
-    quint8 _header;
-    QByteArray _data;
-};
-
-} // namespace QMQTT
-
-Q_DECLARE_METATYPE(QMQTT::Frame)
-
-#endif // QMQTT_FRAME_H

+ 0 - 48
Libraries/msvc2022/include/qmqtt/qmqtt_global.h

@@ -1,48 +0,0 @@
-/*
- * qmqtt_global.h - qmqtt libray global
- *
- * Copyright (c) 2013  Ery Lee <ery.lee at gmail dot com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   * Redistributions of source code must retain the above copyright notice,
- *     this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of mqttc nor the names of its contributors may be used
- *     to endorse or promote products derived from this software without
- *     specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-#ifndef QMQTT_GLOBAL_H
-#define QMQTT_GLOBAL_H
-
-#include <QtGlobal>
-
-#if !defined(QT_STATIC) && !defined(MQTT_PROJECT_INCLUDE_SRC)
-#  if defined(QT_BUILD_QMQTT_LIB)
-#    define Q_MQTT_EXPORT Q_DECL_EXPORT
-#  else
-#    define Q_MQTT_EXPORT Q_DECL_IMPORT
-#  endif
-#else
-#  define Q_MQTT_EXPORT
-#endif
-
-#endif // QMQTT_GLOBAL_H
-

+ 0 - 96
Libraries/msvc2022/include/qmqtt/qmqtt_message.h

@@ -1,96 +0,0 @@
-/*
- * qmqtt_message.h - qmqtt message header
- *
- * Copyright (c) 2013  Ery Lee <ery.lee at gmail dot com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   * Redistributions of source code must retain the above copyright notice,
- *     this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of mqttc nor the names of its contributors may be used
- *     to endorse or promote products derived from this software without
- *     specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-#ifndef QMQTT_MESSAGE_H
-#define QMQTT_MESSAGE_H
-
-#include <qmqtt/qmqtt_global.h>
-
-#include <QMetaType>
-#include <QString>
-#include <QByteArray>
-#include <QSharedDataPointer>
-
-namespace QMQTT {
-
-class MessagePrivate;
-
-class Q_MQTT_EXPORT Message
-{
-public:
-    Message();
-    explicit Message(const quint16 id, const QString &topic, const QByteArray &payload,
-                     const quint8 qos = 0, const bool retain = false, const bool dup = false);
-    Message(const Message &other);
-    ~Message();
-
-    Message &operator=(const Message &other);
-#ifdef Q_COMPILER_RVALUE_REFS
-    inline Message &operator=(Message &&other) Q_DECL_NOTHROW
-    { swap(other); return *this; }
-#endif
-
-    bool operator==(const Message &other) const;
-    inline bool operator!=(const Message &other) const
-    { return !operator==(other); }
-
-    inline void swap(Message &other) Q_DECL_NOTHROW
-    { qSwap(d, other.d); }
-
-    quint16 id() const;
-    void setId(const quint16 id);
-
-    quint8 qos() const;
-    void setQos(const quint8 qos);
-
-    bool retain() const;
-    void setRetain(const bool retain);
-
-    bool dup() const;
-    void setDup(const bool dup);
-
-    QString topic() const;
-    void setTopic(const QString &topic);
-
-    QByteArray payload() const;
-    void setPayload(const QByteArray &payload);
-
-private:
-    QSharedDataPointer<MessagePrivate> d;
-};
-
-} // namespace QMQTT
-
-Q_DECLARE_SHARED(QMQTT::Message)
-
-Q_DECLARE_METATYPE(QMQTT::Message)
-
-#endif // QMQTT_MESSAGE_H

+ 0 - 92
Libraries/msvc2022/include/qmqtt/qmqtt_networkinterface.h

@@ -1,92 +0,0 @@
-/*
- * qmqtt_networkinterface.h - qmqtt network interface header
- *
- * Copyright (c) 2013  Ery Lee <ery.lee at gmail dot com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   * Redistributions of source code must retain the above copyright notice,
- *     this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of mqttc nor the names of its contributors may be used
- *     to endorse or promote products derived from this software without
- *     specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-#ifndef QMQTT_NETWORK_INTERFACE_H
-#define QMQTT_NETWORK_INTERFACE_H
-
-#include <qmqtt_global.h>
-
-#include <QObject>
-#include <QAbstractSocket>
-#include <QHostAddress>
-#include <QString>
-#include <QList>
-
-#ifndef QT_NO_SSL
-#include <QSslConfiguration>
-QT_FORWARD_DECLARE_CLASS(QSslError)
-#endif // QT_NO_SSL
-
-namespace QMQTT {
-
-class Frame;
-
-class Q_MQTT_EXPORT NetworkInterface : public QObject
-{
-    Q_OBJECT
-public:
-    explicit NetworkInterface(QObject* parent = nullptr) : QObject(parent) {}
-    virtual ~NetworkInterface() {}
-
-    virtual void sendFrame(const Frame& frame) = 0;
-    virtual bool isConnectedToHost() const = 0;
-    virtual bool autoReconnect() const = 0;
-    virtual void setAutoReconnect(const bool autoReconnect) = 0;
-    virtual int autoReconnectInterval() const = 0;
-    virtual void setAutoReconnectInterval(const int autoReconnectInterval) = 0;
-    virtual QAbstractSocket::SocketState state() const = 0;
-#ifndef QT_NO_SSL
-    virtual void ignoreSslErrors(const QList<QSslError>& errors) = 0;
-    virtual QSslConfiguration sslConfiguration() const = 0;
-    virtual void setSslConfiguration(const QSslConfiguration& config) = 0;
-#endif // QT_NO_SSL
-
-public Q_SLOTS:
-    virtual void connectToHost(const QHostAddress& host, const quint16 port) = 0;
-    virtual void connectToHost(const QString& hostName, const quint16 port) = 0;
-    virtual void disconnectFromHost() = 0;
-#ifndef QT_NO_SSL
-    virtual void ignoreSslErrors() = 0;
-#endif // QT_NO_SSL
-
-Q_SIGNALS:
-    void connected();
-    void disconnected();
-    void received(const QMQTT::Frame& frame);
-    void error(QAbstractSocket::SocketError error);
-#ifndef QT_NO_SSL
-    void sslErrors(const QList<QSslError>& errors);
-#endif // QT_NO_SSL
-};
-
-} // namespace QMQTT
-
-#endif // QMQTT_NETWORK_INTERFACE_H

+ 0 - 71
Libraries/msvc2022/include/qmqtt/qmqtt_routedmessage.h

@@ -1,71 +0,0 @@
-/*
- * qmqtt_router.h - qmqtt router
- *
- * Copyright (c) 2013  Ery Lee <ery.lee at gmail dot com>
- * Router added by Niklas Wulf <nwulf at geenen-it-systeme dot de>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   * Redistributions of source code must retain the above copyright notice,
- *     this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of mqttc nor the names of its contributors may be used
- *     to endorse or promote products derived from this software without
- *     specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-#ifndef QMQTT_ROUTEDMESSAGE_H
-#define QMQTT_ROUTEDMESSAGE_H
-
-#include <qmqtt_message.h>
-
-#include <QMetaType>
-#include <QHash>
-#include <QString>
-
-namespace QMQTT {
-
-class RouteSubscription;
-
-class Q_MQTT_EXPORT RoutedMessage
-{
-public:
-    inline RoutedMessage()
-    {}
-    inline RoutedMessage(const Message &message)
-        : _message(message)
-    {}
-
-    inline const Message &message() const
-    { return _message; }
-    inline QHash<QString, QString> parameters() const
-    { return _parameters; }
-
-private:
-    friend class RouteSubscription;
-
-    Message _message;
-    QHash<QString, QString> _parameters;
-};
-
-} // namespace QMQTT
-
-Q_DECLARE_METATYPE(QMQTT::RoutedMessage)
-
-#endif // QMQTT_ROUTEDMESSAGE_H

+ 0 - 60
Libraries/msvc2022/include/qmqtt/qmqtt_router.h

@@ -1,60 +0,0 @@
-/*
- * qmqtt_router.h - qmqtt router
- *
- * Copyright (c) 2013  Ery Lee <ery.lee at gmail dot com>
- * Router added by Niklas Wulf <nwulf at geenen-it-systeme dot de>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   * Redistributions of source code must retain the above copyright notice,
- *     this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of mqttc nor the names of its contributors may be used
- *     to endorse or promote products derived from this software without
- *     specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-#ifndef QMQTT_ROUTER_H
-#define QMQTT_ROUTER_H
-
-#include <qmqtt_global.h>
-
-#include <QObject>
-
-namespace QMQTT {
-
-class Client;
-class RouteSubscription;
-
-class Q_MQTT_EXPORT Router : public QObject
-{
-    Q_OBJECT
-public:
-    explicit Router(Client *parent = nullptr);
-
-    RouteSubscription *subscribe(const QString &route);
-    Client *client() const;
-
-private:
-    Client *_client;
-};
-
-} // namespace QMQTT
-
-#endif // QMQTT_ROUTER_H

+ 0 - 79
Libraries/msvc2022/include/qmqtt/qmqtt_routesubscription.h

@@ -1,79 +0,0 @@
-/*
- * qmqtt_router.h - qmqtt router
- *
- * Copyright (c) 2013  Ery Lee <ery.lee at gmail dot com>
- * Router added by Niklas Wulf <nwulf at geenen-it-systeme dot de>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   * Redistributions of source code must retain the above copyright notice,
- *     this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of mqttc nor the names of its contributors may be used
- *     to endorse or promote products derived from this software without
- *     specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-#ifndef QMQTT_ROUTESUBSCRIPTION_H
-#define QMQTT_ROUTESUBSCRIPTION_H
-
-#include <qmqtt_global.h>
-
-#include <QObject>
-#include <QPointer>
-#include <QString>
-#include <QRegularExpression>
-#include <QStringList>
-
-namespace QMQTT {
-
-class Client;
-class Message;
-class RoutedMessage;
-class Router;
-
-class Q_MQTT_EXPORT RouteSubscription : public QObject
-{
-    Q_OBJECT
-public:
-    ~RouteSubscription();
-
-    QString route() const;
-
-Q_SIGNALS:
-    void received(const RoutedMessage &message);
-
-private Q_SLOTS:
-    void routeMessage(const Message &message);
-
-private:
-    friend class Router;
-
-    explicit RouteSubscription(Router *parent = nullptr);
-    void setRoute(const QString &route);
-
-    QPointer<Client> _client;
-    QString _topic;
-    QRegularExpression _regularExpression;
-    QStringList _parameterNames;
-};
-
-} // namespace QMQTT
-
-#endif // QMQTT_ROUTESUBSCRIPTION_H

+ 0 - 84
Libraries/msvc2022/include/qmqtt/qmqtt_socketinterface.h

@@ -1,84 +0,0 @@
-/*
- * qmqtt_socketinterface.h - qmqtt socket interface header
- *
- * Copyright (c) 2013  Ery Lee <ery.lee at gmail dot com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   * Redistributions of source code must retain the above copyright notice,
- *     this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of mqttc nor the names of its contributors may be used
- *     to endorse or promote products derived from this software without
- *     specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-#ifndef QMQTT_SOCKET_INTERFACE_H
-#define QMQTT_SOCKET_INTERFACE_H
-
-#include <qmqtt_global.h>
-
-#include <QObject>
-#include <QHostAddress>
-#include <QString>
-#include <QAbstractSocket>
-#include <QList>
-
-#ifndef QT_NO_SSL
-#include <QSslConfiguration>
-QT_FORWARD_DECLARE_CLASS(QSslError)
-#endif // QT_NO_SSL
-
-QT_FORWARD_DECLARE_CLASS(QIODevice)
-
-namespace QMQTT
-{
-
-class Q_MQTT_EXPORT SocketInterface : public QObject
-{
-    Q_OBJECT
-public:
-    explicit SocketInterface(QObject* parent = nullptr) : QObject(parent) {}
-    virtual ~SocketInterface() {}
-
-    virtual QIODevice* ioDevice() = 0;
-    virtual void connectToHost(const QHostAddress& address, quint16 port) = 0;
-    virtual void connectToHost(const QString& hostName, quint16 port) = 0;
-    virtual void disconnectFromHost() = 0;
-    virtual QAbstractSocket::SocketState state() const = 0;
-    virtual QAbstractSocket::SocketError error() const = 0;
-#ifndef QT_NO_SSL
-    virtual void ignoreSslErrors(const QList<QSslError>& errors) { Q_UNUSED(errors); }
-    virtual void ignoreSslErrors() {}
-    virtual QSslConfiguration sslConfiguration() const { return QSslConfiguration(); }
-    virtual void setSslConfiguration(const QSslConfiguration& config) { Q_UNUSED(config); }
-#endif // QT_NO_SSL
-
-Q_SIGNALS:
-    void connected();
-    void disconnected();
-    void error(QAbstractSocket::SocketError socketError);
-#ifndef QT_NO_SSL
-    void sslErrors(const QList<QSslError>& errors);
-#endif // QT_NO_SSL
-};
-
-}
-
-#endif // QMQTT_SOCKET_INTERFACE_H

+ 0 - 62
Libraries/msvc2022/include/qmqtt/qmqtt_timerinterface.h

@@ -1,62 +0,0 @@
-/*
- * qmqtt_timerinterface.h - qmqtt timer interface header
- *
- * Copyright (c) 2013  Ery Lee <ery.lee at gmail dot com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   * Redistributions of source code must retain the above copyright notice,
- *     this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of mqttc nor the names of its contributors may be used
- *     to endorse or promote products derived from this software without
- *     specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-#ifndef QMQTT_TIMER_INTERFACE_H
-#define QMQTT_TIMER_INTERFACE_H
-
-#include <qmqtt_global.h>
-
-#include <QObject>
-
-namespace QMQTT {
-
-class Q_MQTT_EXPORT TimerInterface : public QObject
-{
-    Q_OBJECT
-public:
-    explicit TimerInterface(QObject* parent = nullptr) : QObject(parent) {}
-    virtual ~TimerInterface() {}
-
-    virtual bool isSingleShot() const = 0;
-    virtual void setSingleShot(bool singleShot) = 0;
-    virtual int interval() const = 0;
-    virtual void setInterval(int msec) = 0;
-    virtual void start() = 0;
-    virtual void stop() = 0;
-
-Q_SIGNALS:
-    void timeout();
-};
-
-}
-
-#endif // QMQTT_TIMER_INTERFACE_H
-

+ 0 - 19
Libraries/msvc2022/lib/cmake/qmqtt/qmqtt-debug.cmake

@@ -1,19 +0,0 @@
-#----------------------------------------------------------------
-# Generated CMake target import file for configuration "Debug".
-#----------------------------------------------------------------
-
-# Commands may need to know the format version.
-set(CMAKE_IMPORT_FILE_VERSION 1)
-
-# Import target "qmqtt" for configuration "Debug"
-set_property(TARGET qmqtt APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
-set_target_properties(qmqtt PROPERTIES
-  IMPORTED_IMPLIB_DEBUG "${_IMPORT_PREFIX}/lib/qmqttd.lib"
-  IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/bin/qmqttd.dll"
-  )
-
-list(APPEND _cmake_import_check_targets qmqtt )
-list(APPEND _cmake_import_check_files_for_qmqtt "${_IMPORT_PREFIX}/lib/qmqttd.lib" "${_IMPORT_PREFIX}/bin/qmqttd.dll" )
-
-# Commands beyond this point should not need to know the version.
-set(CMAKE_IMPORT_FILE_VERSION)

+ 0 - 19
Libraries/msvc2022/lib/cmake/qmqtt/qmqtt-release.cmake

@@ -1,19 +0,0 @@
-#----------------------------------------------------------------
-# Generated CMake target import file for configuration "Release".
-#----------------------------------------------------------------
-
-# Commands may need to know the format version.
-set(CMAKE_IMPORT_FILE_VERSION 1)
-
-# Import target "qmqtt" for configuration "Release"
-set_property(TARGET qmqtt APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
-set_target_properties(qmqtt PROPERTIES
-  IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/lib/qmqtt.lib"
-  IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/bin/qmqtt.dll"
-  )
-
-list(APPEND _cmake_import_check_targets qmqtt )
-list(APPEND _cmake_import_check_files_for_qmqtt "${_IMPORT_PREFIX}/lib/qmqtt.lib" "${_IMPORT_PREFIX}/bin/qmqtt.dll" )
-
-# Commands beyond this point should not need to know the version.
-set(CMAKE_IMPORT_FILE_VERSION)

+ 0 - 107
Libraries/msvc2022/lib/cmake/qmqtt/qmqtt.cmake

@@ -1,107 +0,0 @@
-# Generated by CMake
-
-if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8)
-   message(FATAL_ERROR "CMake >= 2.8.0 required")
-endif()
-if(CMAKE_VERSION VERSION_LESS "2.8.3")
-   message(FATAL_ERROR "CMake >= 2.8.3 required")
-endif()
-cmake_policy(PUSH)
-cmake_policy(VERSION 2.8.3...3.26)
-#----------------------------------------------------------------
-# Generated CMake target import file.
-#----------------------------------------------------------------
-
-# Commands may need to know the format version.
-set(CMAKE_IMPORT_FILE_VERSION 1)
-
-# Protect against multiple inclusion, which would fail when already imported targets are added once more.
-set(_cmake_targets_defined "")
-set(_cmake_targets_not_defined "")
-set(_cmake_expected_targets "")
-foreach(_cmake_expected_target IN ITEMS qmqtt)
-  list(APPEND _cmake_expected_targets "${_cmake_expected_target}")
-  if(TARGET "${_cmake_expected_target}")
-    list(APPEND _cmake_targets_defined "${_cmake_expected_target}")
-  else()
-    list(APPEND _cmake_targets_not_defined "${_cmake_expected_target}")
-  endif()
-endforeach()
-unset(_cmake_expected_target)
-if(_cmake_targets_defined STREQUAL _cmake_expected_targets)
-  unset(_cmake_targets_defined)
-  unset(_cmake_targets_not_defined)
-  unset(_cmake_expected_targets)
-  unset(CMAKE_IMPORT_FILE_VERSION)
-  cmake_policy(POP)
-  return()
-endif()
-if(NOT _cmake_targets_defined STREQUAL "")
-  string(REPLACE ";" ", " _cmake_targets_defined_text "${_cmake_targets_defined}")
-  string(REPLACE ";" ", " _cmake_targets_not_defined_text "${_cmake_targets_not_defined}")
-  message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_cmake_targets_defined_text}\nTargets not yet defined: ${_cmake_targets_not_defined_text}\n")
-endif()
-unset(_cmake_targets_defined)
-unset(_cmake_targets_not_defined)
-unset(_cmake_expected_targets)
-
-
-# Compute the installation prefix relative to this file.
-get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
-get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
-get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
-get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
-if(_IMPORT_PREFIX STREQUAL "/")
-  set(_IMPORT_PREFIX "")
-endif()
-
-# Create imported target qmqtt
-add_library(qmqtt SHARED IMPORTED)
-
-set_target_properties(qmqtt PROPERTIES
-  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
-  INTERFACE_LINK_LIBRARIES "Qt5::Core;Qt5::Network"
-)
-
-if(CMAKE_VERSION VERSION_LESS 2.8.12)
-  message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
-endif()
-
-# Load information for each installed configuration.
-file(GLOB _cmake_config_files "${CMAKE_CURRENT_LIST_DIR}/qmqtt-*.cmake")
-foreach(_cmake_config_file IN LISTS _cmake_config_files)
-  include("${_cmake_config_file}")
-endforeach()
-unset(_cmake_config_file)
-unset(_cmake_config_files)
-
-# Cleanup temporary variables.
-set(_IMPORT_PREFIX)
-
-# Loop over all imported files and verify that they actually exist
-foreach(_cmake_target IN LISTS _cmake_import_check_targets)
-  foreach(_cmake_file IN LISTS "_cmake_import_check_files_for_${_cmake_target}")
-    if(NOT EXISTS "${_cmake_file}")
-      message(FATAL_ERROR "The imported target \"${_cmake_target}\" references the file
-   \"${_cmake_file}\"
-but this file does not exist.  Possible reasons include:
-* The file was deleted, renamed, or moved to another location.
-* An install or uninstall procedure did not complete successfully.
-* The installation package was faulty and contained
-   \"${CMAKE_CURRENT_LIST_FILE}\"
-but not all the files it references.
-")
-    endif()
-  endforeach()
-  unset(_cmake_file)
-  unset("_cmake_import_check_files_for_${_cmake_target}")
-endforeach()
-unset(_cmake_target)
-unset(_cmake_import_check_targets)
-
-# This file does not depend on other imported targets which have
-# been exported from the same project but in a separate export set.
-
-# Commands beyond this point should not need to know the version.
-set(CMAKE_IMPORT_FILE_VERSION)
-cmake_policy(POP)

+ 0 - 26
Libraries/msvc2022/lib/cmake/qmqtt/qmqttConfig.cmake

@@ -1,26 +0,0 @@
-
-####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
-####### Any changes to this file will be overwritten by the next CMake run ####
-####### The input file was qmqttConfig.cmake.in                            ########
-
-get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
-
-macro(set_and_check _var _file)
-  set(${_var} "${_file}")
-  if(NOT EXISTS "${_file}")
-    message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
-  endif()
-endmacro()
-
-macro(check_required_components _NAME)
-  foreach(comp ${${_NAME}_FIND_COMPONENTS})
-    if(NOT ${_NAME}_${comp}_FOUND)
-      if(${_NAME}_FIND_REQUIRED_${comp})
-        set(${_NAME}_FOUND FALSE)
-      endif()
-    endif()
-  endforeach()
-endmacro()
-
-####################################################################################
-include( ${CMAKE_CURRENT_LIST_DIR}/qmqttTargets.cmake )

+ 0 - 65
Libraries/msvc2022/lib/cmake/qmqtt/qmqttConfigVersion.cmake

@@ -1,65 +0,0 @@
-# This is a basic version file for the Config-mode of find_package().
-# It is used by write_basic_package_version_file() as input file for configure_file()
-# to create a version-file which can be installed along a config.cmake file.
-#
-# The created file sets PACKAGE_VERSION_EXACT if the current version string and
-# the requested version string are exactly the same and it sets
-# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version,
-# but only if the requested major version is the same as the current one.
-# The variable CVF_VERSION must be set before calling configure_file().
-
-
-set(PACKAGE_VERSION "1.0.3")
-
-if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
-  set(PACKAGE_VERSION_COMPATIBLE FALSE)
-else()
-
-  if("1.0.3" MATCHES "^([0-9]+)\\.")
-    set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
-    if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0)
-      string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}")
-    endif()
-  else()
-    set(CVF_VERSION_MAJOR "1.0.3")
-  endif()
-
-  if(PACKAGE_FIND_VERSION_RANGE)
-    # both endpoints of the range must have the expected major version
-    math (EXPR CVF_VERSION_MAJOR_NEXT "${CVF_VERSION_MAJOR} + 1")
-    if (NOT PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
-        OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX_MAJOR STREQUAL CVF_VERSION_MAJOR)
-          OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX VERSION_LESS_EQUAL CVF_VERSION_MAJOR_NEXT)))
-      set(PACKAGE_VERSION_COMPATIBLE FALSE)
-    elseif(PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
-        AND ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS_EQUAL PACKAGE_FIND_VERSION_MAX)
-        OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MAX)))
-      set(PACKAGE_VERSION_COMPATIBLE TRUE)
-    else()
-      set(PACKAGE_VERSION_COMPATIBLE FALSE)
-    endif()
-  else()
-    if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR)
-      set(PACKAGE_VERSION_COMPATIBLE TRUE)
-    else()
-      set(PACKAGE_VERSION_COMPATIBLE FALSE)
-    endif()
-
-    if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
-      set(PACKAGE_VERSION_EXACT TRUE)
-    endif()
-  endif()
-endif()
-
-
-# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
-if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "")
-  return()
-endif()
-
-# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
-if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8")
-  math(EXPR installedBits "8 * 8")
-  set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
-  set(PACKAGE_VERSION_UNSUITABLE TRUE)
-endif()

+ 0 - 19
Libraries/msvc2022/lib/cmake/qmqtt/qmqttTargets-debug.cmake

@@ -1,19 +0,0 @@
-#----------------------------------------------------------------
-# Generated CMake target import file for configuration "Debug".
-#----------------------------------------------------------------
-
-# Commands may need to know the format version.
-set(CMAKE_IMPORT_FILE_VERSION 1)
-
-# Import target "qmqtt" for configuration "Debug"
-set_property(TARGET qmqtt APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
-set_target_properties(qmqtt PROPERTIES
-  IMPORTED_IMPLIB_DEBUG "${_IMPORT_PREFIX}/lib/qmqttd.lib"
-  IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/bin/qmqttd.dll"
-  )
-
-list(APPEND _cmake_import_check_targets qmqtt )
-list(APPEND _cmake_import_check_files_for_qmqtt "${_IMPORT_PREFIX}/lib/qmqttd.lib" "${_IMPORT_PREFIX}/bin/qmqttd.dll" )
-
-# Commands beyond this point should not need to know the version.
-set(CMAKE_IMPORT_FILE_VERSION)

+ 0 - 19
Libraries/msvc2022/lib/cmake/qmqtt/qmqttTargets-release.cmake

@@ -1,19 +0,0 @@
-#----------------------------------------------------------------
-# Generated CMake target import file for configuration "Release".
-#----------------------------------------------------------------
-
-# Commands may need to know the format version.
-set(CMAKE_IMPORT_FILE_VERSION 1)
-
-# Import target "qmqtt" for configuration "Release"
-set_property(TARGET qmqtt APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
-set_target_properties(qmqtt PROPERTIES
-  IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/lib/qmqtt.lib"
-  IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/bin/qmqtt.dll"
-  )
-
-list(APPEND _cmake_import_check_targets qmqtt )
-list(APPEND _cmake_import_check_files_for_qmqtt "${_IMPORT_PREFIX}/lib/qmqtt.lib" "${_IMPORT_PREFIX}/bin/qmqtt.dll" )
-
-# Commands beyond this point should not need to know the version.
-set(CMAKE_IMPORT_FILE_VERSION)

+ 0 - 107
Libraries/msvc2022/lib/cmake/qmqtt/qmqttTargets.cmake

@@ -1,107 +0,0 @@
-# Generated by CMake
-
-if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8)
-   message(FATAL_ERROR "CMake >= 2.8.0 required")
-endif()
-if(CMAKE_VERSION VERSION_LESS "2.8.3")
-   message(FATAL_ERROR "CMake >= 2.8.3 required")
-endif()
-cmake_policy(PUSH)
-cmake_policy(VERSION 2.8.3...3.26)
-#----------------------------------------------------------------
-# Generated CMake target import file.
-#----------------------------------------------------------------
-
-# Commands may need to know the format version.
-set(CMAKE_IMPORT_FILE_VERSION 1)
-
-# Protect against multiple inclusion, which would fail when already imported targets are added once more.
-set(_cmake_targets_defined "")
-set(_cmake_targets_not_defined "")
-set(_cmake_expected_targets "")
-foreach(_cmake_expected_target IN ITEMS qmqtt)
-  list(APPEND _cmake_expected_targets "${_cmake_expected_target}")
-  if(TARGET "${_cmake_expected_target}")
-    list(APPEND _cmake_targets_defined "${_cmake_expected_target}")
-  else()
-    list(APPEND _cmake_targets_not_defined "${_cmake_expected_target}")
-  endif()
-endforeach()
-unset(_cmake_expected_target)
-if(_cmake_targets_defined STREQUAL _cmake_expected_targets)
-  unset(_cmake_targets_defined)
-  unset(_cmake_targets_not_defined)
-  unset(_cmake_expected_targets)
-  unset(CMAKE_IMPORT_FILE_VERSION)
-  cmake_policy(POP)
-  return()
-endif()
-if(NOT _cmake_targets_defined STREQUAL "")
-  string(REPLACE ";" ", " _cmake_targets_defined_text "${_cmake_targets_defined}")
-  string(REPLACE ";" ", " _cmake_targets_not_defined_text "${_cmake_targets_not_defined}")
-  message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_cmake_targets_defined_text}\nTargets not yet defined: ${_cmake_targets_not_defined_text}\n")
-endif()
-unset(_cmake_targets_defined)
-unset(_cmake_targets_not_defined)
-unset(_cmake_expected_targets)
-
-
-# Compute the installation prefix relative to this file.
-get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
-get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
-get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
-get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
-if(_IMPORT_PREFIX STREQUAL "/")
-  set(_IMPORT_PREFIX "")
-endif()
-
-# Create imported target qmqtt
-add_library(qmqtt SHARED IMPORTED)
-
-set_target_properties(qmqtt PROPERTIES
-  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
-  INTERFACE_LINK_LIBRARIES "Qt5::Core;Qt5::Network"
-)
-
-if(CMAKE_VERSION VERSION_LESS 2.8.12)
-  message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
-endif()
-
-# Load information for each installed configuration.
-file(GLOB _cmake_config_files "${CMAKE_CURRENT_LIST_DIR}/qmqttTargets-*.cmake")
-foreach(_cmake_config_file IN LISTS _cmake_config_files)
-  include("${_cmake_config_file}")
-endforeach()
-unset(_cmake_config_file)
-unset(_cmake_config_files)
-
-# Cleanup temporary variables.
-set(_IMPORT_PREFIX)
-
-# Loop over all imported files and verify that they actually exist
-foreach(_cmake_target IN LISTS _cmake_import_check_targets)
-  foreach(_cmake_file IN LISTS "_cmake_import_check_files_for_${_cmake_target}")
-    if(NOT EXISTS "${_cmake_file}")
-      message(FATAL_ERROR "The imported target \"${_cmake_target}\" references the file
-   \"${_cmake_file}\"
-but this file does not exist.  Possible reasons include:
-* The file was deleted, renamed, or moved to another location.
-* An install or uninstall procedure did not complete successfully.
-* The installation package was faulty and contained
-   \"${CMAKE_CURRENT_LIST_FILE}\"
-but not all the files it references.
-")
-    endif()
-  endforeach()
-  unset(_cmake_file)
-  unset("_cmake_import_check_files_for_${_cmake_target}")
-endforeach()
-unset(_cmake_target)
-unset(_cmake_import_check_targets)
-
-# This file does not depend on other imported targets which have
-# been exported from the same project but in a separate export set.
-
-# Commands beyond this point should not need to know the version.
-set(CMAKE_IMPORT_FILE_VERSION)
-cmake_policy(POP)

BIN
Libraries/msvc2022/lib/qmqtt.lib


BIN
Libraries/msvc2022/lib/qmqttd.lib


+ 6 - 1
Libraries/qmqtt/Findqmqtt.cmake

@@ -87,4 +87,9 @@ else()
     set(qmqtt_FOUND FALSE)
 endif()
 
-message(STATUS "***** FInd qmqtt.cmake end *****")
+message(STATUS "qmqtt Version : ${qmqtt_VERSION}")
+message(STATUS "include : qmqtt_INCLUDE_DIR")
+message(STATUS "Library : qmqtt_LIBRARY")
+
+
+message(STATUS "---------------------------------")

BIN
Libraries/sm_dll/doc/sm国密算法接口说明文档.docx


+ 90 - 0
Libraries/sm_dll/findSM.cmake

@@ -0,0 +1,90 @@
+
+
+#国密加解密库
+
+message(STATUS "***** Find SM Library *****")
+
+#寻找头文件
+find_path(SM_INCLUDE_DIR
+    NAMES smclass.h
+    PATHS ${CMAKE_CURRENT_LIST_DIR}/inc
+    NO_DEFAULT_PATH
+)
+
+#查找源文件
+find_path(SM_SOURCE_DIR
+    NAMES smclass.cpp
+    PATHS ${CMAKE_CURRENT_LIST_DIR}/src
+    NO_DEFAULT_PATH
+)
+
+#find_linrary查找的是“.lib”,“.a”,“.so”文件,不会查找.dll文件
+#因此,在这里无法使用,直接使用list添加路径
+
+# unset(SM_LIB CACHE)
+# find_library(SM_LIB
+#     NAMES SM_DLL
+#     HINTS ${CMAKE_CURRENT_LIST_DIR}/libs/win/x64
+#     NO_DEFAULT_PATH)
+            
+# list(APPEND SM_LIB_LIBRARY ${SM_LIB})
+# message(STATUS "SM_LIB: ${SM_LIB}")
+
+#查找库文件,需要判断操作系统,位数
+if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+    if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+        if(CMAKE_BUILD_TYPE MATCHES "Debug")
+            list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x64/with_debug_info/libSM_DLL.lib)
+            list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x64/ucrtbased.dll)
+            list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x64/vcruntime140d.dll)
+        else()
+            list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x64/libSM_DLL.lib)
+            list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x64/ucrtbase.dll)
+            list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x64/vcruntime140.dll)
+        endif()
+    elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
+        if(CMAKE_BUILD_TYPE MATCHES "Debug")
+            list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x86/with_debug_info/libSM_DLL.lib)
+            list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x86/ucrtbased.dll)
+            list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x86/vcruntime140d.dll)
+        else()
+            list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x86/libSM_DLL.lib)
+            list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x86/ucrtbase.dll)
+            list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x86/vcruntime140.dll)
+        endif()
+    endif()
+elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
+    if(CMAKE_BUILD_TYPE MATCHES "Debug")
+        unset(SM_LIB CACHE)
+        find_library(SM_LIB
+            NAMES SM_DLL
+            HINTS ${CMAKE_CURRENT_LIST_DIR}/libs/linux/x64/with_debug_info/SM_Dll
+            NO_DEFAULT_PATH)
+        list(APPEND SM_LIB_LIBRARY ${SM_DLL})
+    else()
+        unset(SM_LIB CACHE)
+        find_library(SM_LIB
+            NAMES SM_DLL
+            HINTS ${CMAKE_CURRENT_LIST_DIR}/libs/linux/x64/SM_Dll
+            NO_DEFAULT_PATH)
+        list(APPEND SM_LIB_LIBRARY ${SM_DLL})
+    endif()
+endif()
+
+# message(STATUS "SM_INCLUDE_DIR: ${SM_INCLUDE_DIR}")
+# message(STATUS "SM_SOURCE_DIR: ${SM_SOURCE_DIR}")
+# message(STATUS "SM_LIB_LIBRARY: ${SM_LIB_LIBRARY}")
+
+
+#设置查找到后的变量
+if(SM_INCLUDE_DIR AND SM_SOURCE_DIR AND SM_LIB_LIBRARY)
+    set(SM_FOUND TRUE)
+else()
+    set(SM_FOUND FALSE)
+endif()
+
+message(STATUS "include : SM_INCLUDE_DIR")
+message(STATUS "source : SM_SOURCE_DIR")
+message(STATUS "Library : SM_LIB_LIBRARY")
+
+message(STATUS "---------------------------------")

+ 91 - 0
Libraries/sm_dll/inc/defs.h

@@ -0,0 +1,91 @@
+#ifndef _DEF_SM_H
+#define _DEF_SM_H
+
+#include <cstddef>
+//#ifdef __GNUC__
+//#ifdef __i386
+//typedef unsigned int size_t;
+//#else
+//typedef long unsigned int size_t;
+//#endif // __i386
+//#endif
+
+typedef unsigned char uint8_t;
+typedef unsigned int  uint32_t;
+/*
+* 32-bit integer manipulation macros (big endian)
+*/
+#ifndef GET_ULONG_BE
+#define GET_ULONG_BE(n,b,i)                             \
+{                                                       \
+    (n) = ( (unsigned long) (b)[(i)    ] << 24 )        \
+        | ( (unsigned long) (b)[(i) + 1] << 16 )        \
+        | ( (unsigned long) (b)[(i) + 2] <<  8 )        \
+        | ( (unsigned long) (b)[(i) + 3]       );       \
+}
+#endif
+
+#ifndef PUT_ULONG_BE
+#define PUT_ULONG_BE(n,b,i)                             \
+{                                                       \
+    (b)[(i)    ] = (unsigned char) ( (n) >> 24 );       \
+    (b)[(i) + 1] = (unsigned char) ( (n) >> 16 );       \
+    (b)[(i) + 2] = (unsigned char) ( (n) >>  8 );       \
+    (b)[(i) + 3] = (unsigned char) ( (n)       );       \
+}
+#endif
+
+#define FF0(x,y,z) ( (x) ^ (y) ^ (z)) 
+#define FF1(x,y,z) (((x) & (y)) | ( (x) & (z)) | ( (y) & (z)))
+
+#define GG0(x,y,z) ( (x) ^ (y) ^ (z)) 
+#define GG1(x,y,z) (((x) & (y)) | ( (~(x)) & (z)) )
+
+/*
+* rotate shift left marco definition
+*/
+#define SHL(x,n) (((x) & 0xFFFFFFFF) << n)
+#define ROTL(x,n) (SHL((x),n) | ((x) >> (32 - n)))
+#define SWAP(a,b) { unsigned long t = a; a = b; b = t; t = 0; }
+
+#define P0(x) ((x) ^  ROTL((x),9) ^ ROTL((x),17)) 
+#define P1(x) ((x) ^  ROTL((x),15) ^ ROTL((x),23)) 
+
+struct st_point
+{
+	uint8_t x[32];
+	uint8_t y[32];
+};
+
+/**
+* \brief          SM2 context structure
+*/
+struct sm2_context
+{
+	st_point pubkey;
+	uint8_t prikey[32];
+};
+
+/**
+* \brief          SM3 context structure
+*/
+struct sm3_context
+{
+	unsigned long total[2];     /*!< number of bytes processed  */
+	unsigned long state[8];     /*!< intermediate digest state  */
+	unsigned char buffer[64];   /*!< data block being processed */
+
+	unsigned char ipad[64];     /*!< HMAC: inner padding        */
+	unsigned char opad[64];     /*!< HMAC: outer padding        */
+
+};
+
+/**
+* \brief          SM4 context structure
+*/
+struct sm4_context
+{
+	uint32_t sk[32];       /*!<  SM4 subkeys          */
+};
+
+#endif // _DEF_SM_H

+ 285 - 0
Libraries/sm_dll/inc/smclass.h

@@ -0,0 +1,285 @@
+/**
+  * 描述:SM算法类,提供SM2, SM3和SM4加解密算法接口
+  * 版本:V1.0.0.0
+  * 日期:2023/08
+  */
+#ifndef SMCLASS_H
+#define SMCLASS_H
+
+#include <memory>
+#include <QLibrary>
+#include <QMutex>
+#include "defs.h"
+#ifndef _stdcall
+#define _stdcall
+#endif
+
+// sm2
+typedef bool(_stdcall *psm2CreateKey)(sm2_context* ctx);
+typedef bool(_stdcall *psm2PublicKey)(sm2_context* ctx, uint8_t key[130]);
+typedef bool(_stdcall *psm2PublicKeyASN1)(sm2_context* ctx, uint8_t* key, size_t* keylen);
+typedef bool(_stdcall *psm2PublicKeyToPem)(sm2_context* ctx, const char* path, int len);
+typedef bool(_stdcall *psm2SetPublicKey)(sm2_context* ctx, int mode, const uint8_t* data, size_t len);
+typedef bool(_stdcall *psm2EncryptRaw)(sm2_context* ctx, int mode, const uint8_t* msg, size_t len, uint8_t* output, size_t* outlen);
+typedef bool(_stdcall *psm2DecryptRaw)(sm2_context* ctx, int mode, const uint8_t* msg, size_t len, uint8_t* output, size_t* outlen);
+typedef bool(_stdcall *psm2EncryptASN1)(sm2_context* ctx, const uint8_t* msg, size_t len, uint8_t* output, size_t* outlen);
+typedef bool(_stdcall *psm2DecryptASN1)(sm2_context* ctx, const uint8_t* msg, size_t len, uint8_t* output, size_t* outlen);
+typedef bool(_stdcall *psm2Signature)(sm2_context* ctx, const uint8_t* msg, size_t len, uint8_t* sign, size_t* siglen);
+typedef bool(_stdcall *psm2VerifySign)(sm2_context* ctx, const uint8_t* msg, size_t len, const uint8_t* sign, size_t siglen);
+// sm3
+typedef void(_stdcall *psm3)(uint8_t*input, int len, uint8_t output[64]);
+//typedef int(_stdcall *psm3_file)(char* path, unsigned char output[32]);
+// sm4
+typedef int (_stdcall *psm4Encrypt)(const char* key, size_t len, const char* input, size_t inlen, char* output, size_t* outlen);
+typedef int (_stdcall *psm4Decrypt)(const char* key, size_t len, const char* input, size_t inlen, char* output, size_t* outlen);
+typedef void(_stdcall *psm4RandKey)(uint8_t* key, size_t len);
+typedef void(_stdcall *psm4SetKeyEnc)(sm4_context* ctx, const uint8_t key[32]);
+typedef void(_stdcall *psm4SetKeyDec)(sm4_context* ctx, const uint8_t key[32]);
+typedef int(_stdcall *psm4EncryptEcb)(sm4_context *ctx, const uint8_t* input, int length, uint8_t* output);
+typedef int(_stdcall *psm4DecryptEcb)(sm4_context *ctx, const uint8_t* input, int length, uint8_t* output);
+typedef int(_stdcall *psm4EncryptCbc)(sm4_context *ctx, const uint8_t iv[32], const uint8_t* input, size_t len, uint8_t* output);
+typedef int(_stdcall *psm4DecryptCbc)(sm4_context *ctx, const uint8_t iv[32], const uint8_t* input, size_t len, uint8_t* output);
+
+class SMClass
+{
+private:
+    using pUchar = std::unique_ptr<uint8_t[]>;
+
+    SMClass();
+    SMClass(const SMClass&) =delete;
+    SMClass& operator=(const SMClass&) =delete;
+public:
+    static SMClass* Instance();
+    ~SMClass();
+    /**
+     * @brief 装载函数接口
+     */
+    void LoadFunc();
+    /**
+     * @brief 释放函数接口
+     */
+    void Release();
+
+    /**
+     * 描述:	创建sm2算法的密钥对
+     * 参数:
+     * ctx      上下文结构体,不能为空
+     */
+    bool Sm2CreateKey(sm2_context* ctx);
+    /**
+    * 描述:		获取上下文中未压缩的公钥信息
+    * 参数:
+    * ctx		上下文结构体
+    * Key       二进制公钥信息,固定长度65 bytes
+    */
+    bool Sm2PublicKey(sm2_context* ctx, QString& key);
+    /**
+    * 描述:		获取上下文中ASN1编码的公钥信息
+    * 参数:
+    * ctx		上下文结构体
+    * Key       二进制公钥信息
+    */
+    bool Sm2PublicKeyASN1(sm2_context* ctx, QString& key);
+    /**
+    * 描述:		从上下文中导出公钥信息到PEM文件
+    * 参数:
+    * ctx		上下文结构体
+    * path      pem文件路径
+    */
+    bool Sm2PublicKey2Pem(sm2_context* ctx, const QString& path);
+    /**
+    * 描述:		设置公钥信息到上下文中
+    * 参数:
+    * ctx		上下文结构体
+    * mode      0-Hex格式,1-ASN1编码格式,2-Pem数据
+    * data      二进制公钥数据(16进制)
+    */
+    bool Sm2SetPublicKey(sm2_context* ctx, int mode, const QString& data);
+    /**
+    * 描述:		不压缩消息加密
+    * 参数:
+    * ctx		上下文结构体
+    * mode      0-C1 C2 C3排列,1-C1 C3 C2排列
+    * msg       待加密信息(最大长度255)
+    * output    输出加密信息
+    */
+    bool Sm2EncryptRaw(sm2_context* ctx, int mode, const QString& msg, QString& output);
+    /**
+    * 描述:		不压缩消息解密
+    * 参数:
+    * ctx		上下文结构体
+    * mode      0-C1 C2 C3排列,1-C1 C3 C2排列
+    * msg       待解密信息
+    * output    输出明文
+    */
+    bool Sm2DecryptRaw(sm2_context* ctx, int mode, const QString& msg, QString& output);
+    /**
+    * 描述:		ASN1编码消息加密
+    * 参数:
+    * ctx		上下文结构体
+    * msg       待加密信息(最大长度255)
+    * output    输出加密信息
+    */
+    bool Sm2EncryptASN1(sm2_context* ctx, const QString& msg, QString& output);
+    /**
+    * 描述:		ASN1编码消息解密
+    * 参数:
+    * ctx		上下文结构体
+    * msg       待解密信息
+    * output    输出明文
+    */
+    bool Sm2DecryptASN1(sm2_context* ctx, const QString& msg, QString& output);
+    /**
+    * 描述:		私钥签名
+    * 参数:
+    * ctx		上下文结构体
+    * msg       待签名数据
+    * sign      签名数据
+    */
+    bool Sm2Signature(sm2_context* ctx, const QString& msg, QString& sign);
+    /**
+    * 描述:		公钥验证签名
+    * 参数:
+    * ctx		上下文结构体
+    * msg		待验证密文数据(Hex)
+    * sign		签名数据
+    * 返回值     true-验证通过,false-验证失败
+    */
+    bool Sm2VerifySign(sm2_context* ctx, const QString& msg, const QString& sign);
+
+    /**
+    * 描述:		计算输入数据input的256位哈希值
+    * 参数:
+    * input		输入数据
+    * output	输出256位消息摘要
+    */
+    void Sm3Hash(const QString& input, QString& output);
+
+    /**
+    * 描述:		SM4 自定义加密
+    * 参数:
+    * key       自定义密钥
+    * input		待加密数据
+    * output	输出的密文数据
+    * 返回值:
+    * 输出数据长度,<=0为失败
+    */
+    int Sm4Encrypt(const QString& key, const QString& input, QString& output);
+    /**
+    * 描述:		SM4 自定义解密
+    * 参数:
+    * key       自定义密钥
+    * input		待解密数据
+    * output	输出的明文数据
+    * 返回值:
+    * 输出数据长度,<=0为失败
+    */
+    int Sm4Decrypt(const QString& key, const QString& input, QString& output);
+
+    /**
+    * 描述:		SM4产生随机密钥
+    * 参数:
+    * key		密钥数据,长度固定16 bytes
+    */
+    void Sm4RandKey(QString& key);
+    /**
+    * 描述:		SM4加密密钥扩展
+    * 参数:
+    * ctx		上下文结构体
+    * key		原始128位密钥
+    */
+    void Sm4KeyEncrypt(sm4_context* ctx, const QString& key);
+    /**
+    * 描述:		SM4解密密钥扩展
+    * 参数:
+    * ctx		上下文结构体
+    * key		原始128位密钥
+    */
+    void Sm4KeyDecrypt(sm4_context* ctx, const QString& key);
+    /**
+    * 描述:		SM4-ECB方式加密128bit
+    * 参数:
+    * ctx		上下文结构体
+    * input		输入信息(pkcs7填充)
+    * output	输出信息
+    * 返回值:
+    * int       密文长度
+    */
+    int Sm4EncryptEcb(sm4_context *ctx, const QString& input, QString& output);
+    /**
+    * 描述:		SM4-ECB方式解密128bit
+    * 参数:
+    * ctx		上下文结构体
+    * input		输入信息(pkcs7填充)
+    * output	输出信息
+    * 返回值:
+    * int       明文长度
+    */
+    int Sm4DecryptEcb(sm4_context *ctx, const QString& input, QString& output);
+    /**
+    * 描述:		SM4-CBC方式加密128bit
+    * 参数:
+    * ctx		上下文结构体
+    * iv		初始化向量(IV),通常采用随机数值或者预设的固定值,长度16 bytes
+    * input		输入信息(pkcs7填充)
+    * output	输出信息
+    * 返回值:
+    * int       密文长度
+    */
+    int Sm4EncryptCbc(sm4_context *ctx, const QString& iv, const QString& input, QString& output);
+    /**
+    * 描述:		SM4-CBC方式解密128bit
+    * 参数:
+    * ctx		上下文结构体
+    * iv		初始化向量(IV),通常采用随机数值或者预设的固定值,长度16 bytes
+    * input		输入信息(pkcs7填充)
+    * output	输出信息
+    * 返回值:
+    * int       明文长度
+    */
+    int Sm4DecryptCbc(sm4_context *ctx, const QString& iv, const QString& input, QString& output);
+
+    /* 返回其他进程的结果,防止curl库的干扰 */
+    void ExeSm3Hash(const QString& input, QString& out);
+    int ExeSm4Encrypt(const QString& key, const QString& input, QString& out);
+    int ExeSm4Decrypt(const QString& key, const QString& input, QString& out);
+
+    void sm3(const QString& input, QString& out);
+    int sm4Enc(const QString& key, const QString& input, QString& out);
+    int sm4Dec(const QString& key, const QString& input, QString& out);
+private:
+    QString uchartoHex(uint8_t* input, size_t size);
+    std::unique_ptr<uint8_t[]> hextoUchar(const QString& hexString, size_t& size);
+    void readResultAndDelete(const QString& fileName, QString& out);
+private:
+    static SMClass* s_inst;
+    static QMutex   s_mtx;
+    QLibrary*       m_plib;
+
+    psm2CreateKey m_pfCreateK;
+    psm2PublicKey m_pfPubKey;
+    psm2PublicKeyASN1 m_pfPubKeyASN1;
+    psm2PublicKeyToPem m_pfPubKey2Pem;
+    psm2SetPublicKey m_pfSetPubKey;
+    psm2EncryptRaw m_pfEncRaw;
+    psm2DecryptRaw m_pfDecRaw;
+    psm2EncryptASN1 m_pfEncrypt;
+    psm2DecryptASN1 m_pfDecrypt;
+    psm2Signature m_pfSignature;
+    psm2VerifySign m_pfVerifySign;
+
+    psm3 m_pfSm3;
+    //psm3_file m_pfSm3File;
+
+    psm4Encrypt m_pfSm4Encrypt;
+    psm4Decrypt m_pfSm4Decrypt;
+    psm4RandKey m_pfSm4RandKey;
+    psm4SetKeyEnc m_pfSm4Enc;
+    psm4SetKeyDec m_pfSm4Dec;
+    psm4EncryptEcb m_pfSm4EncEcb;
+    psm4DecryptEcb m_pfSm4DecEcb;
+    psm4EncryptCbc m_pfSm4EncCbc;
+    psm4DecryptCbc m_pfSm4DecCbc;
+};
+
+#endif // SMCLASS_H

BIN
Libraries/sm_dll/libs/linux/SM_Dll_exe.zip


BIN
Libraries/sm_dll/libs/linux/x64/libSM_Dll.so


BIN
Libraries/sm_dll/libs/linux/x64/with_debug_info/libSM_Dll.so


BIN
Libraries/sm_dll/libs/win/x64/libSM_Dll.dll


BIN
Libraries/sm_dll/libs/win/x64/libSM_Dll.lib


BIN
Libraries/sm_dll/libs/win/x64/ucrtbase.dll


BIN
Libraries/sm_dll/libs/win/x64/ucrtbased.dll


BIN
Libraries/sm_dll/libs/win/x64/vcruntime140.dll


BIN
Libraries/sm_dll/libs/win/x64/vcruntime140d.dll


BIN
Libraries/sm_dll/libs/win/x64/with_debug_info/libSM_Dll.dll


BIN
Libraries/sm_dll/libs/win/x64/with_debug_info/libSM_Dll.lib


BIN
Libraries/sm_dll/libs/win/x86/libSM_Dll.dll


BIN
Libraries/sm_dll/libs/win/x86/libSM_Dll.lib


BIN
Libraries/sm_dll/libs/win/x86/ucrtbase.dll


BIN
Libraries/sm_dll/libs/win/x86/ucrtbased.dll


BIN
Libraries/sm_dll/libs/win/x86/vcruntime140.dll


BIN
Libraries/sm_dll/libs/win/x86/vcruntime140d.dll


BIN
Libraries/sm_dll/libs/win/x86/with_debug_info/libSM_Dll.dll


BIN
Libraries/sm_dll/libs/win/x86/with_debug_info/libSM_Dll.lib


+ 483 - 0
Libraries/sm_dll/src/smclass.cpp

@@ -0,0 +1,483 @@
+#include "smclass.h"
+#include <QCoreApplication>
+#include <QProcess>
+#include <QFile>
+#include <QDebug>
+
+#define MAX_KEY_LEN 256
+#define MAX_MSG_LEN 512
+
+#ifdef __unix
+#define memcpy_s(dest, dst_size, src, src_size) memcpy((dest), (src), (src_size))
+#endif // __unit
+
+SMClass* SMClass::s_inst = nullptr;
+QMutex SMClass::s_mtx;
+
+SMClass* SMClass::Instance()
+{
+    if (nullptr == s_inst) {
+        QMutexLocker locker(&s_mtx);
+        if (nullptr == s_inst) {
+            s_inst = new SMClass();
+        }
+    }
+    return s_inst;
+}
+
+SMClass::SMClass() : m_plib(nullptr)
+{
+    Release();
+#ifdef __unix
+    m_plib = new QLibrary(QCoreApplication::applicationDirPath() + "/libSM_Dll.so");
+#else
+    m_plib = new QLibrary("libSM_Dll.dll");
+#endif
+    LoadFunc();
+}
+
+SMClass::~SMClass()
+{
+    if (m_plib->isLoaded()) {
+        m_plib->unload();
+    }
+    if (nullptr != m_plib) {
+        delete m_plib;
+    }
+}
+
+void SMClass::Release()
+{
+    m_pfCreateK = nullptr;
+    m_pfPubKey = nullptr;
+    m_pfPubKeyASN1 = nullptr;
+    m_pfPubKey2Pem = nullptr;
+    m_pfSetPubKey = nullptr;
+    m_pfEncRaw = nullptr;
+    m_pfDecRaw = nullptr;
+    m_pfDecrypt = nullptr;
+    m_pfEncrypt = nullptr;
+    m_pfSignature = nullptr;
+    m_pfVerifySign = nullptr;
+
+    m_pfSm3 = nullptr;
+    //m_pfSm3File = nullptr;
+
+    m_pfSm4Encrypt = nullptr;
+    m_pfSm4Decrypt = nullptr;
+    m_pfSm4RandKey = nullptr;
+    m_pfSm4Dec = nullptr;
+    m_pfSm4Enc = nullptr;
+    m_pfSm4EncEcb = nullptr;
+    m_pfSm4DecEcb = nullptr;
+    m_pfSm4EncCbc = nullptr;
+    m_pfSm4DecCbc = nullptr;
+}
+
+void SMClass::LoadFunc()
+{
+    m_pfCreateK = (psm2CreateKey)m_plib->resolve("sm2_create_key");
+    m_pfPubKey = (psm2PublicKey)m_plib->resolve("sm2_public_key");
+    m_pfPubKeyASN1 = (psm2PublicKeyASN1)m_plib->resolve("sm2_public_key_asn1");
+    m_pfPubKey2Pem = (psm2PublicKeyToPem)m_plib->resolve("sm2_public_key_to_pem");
+    m_pfSetPubKey = (psm2SetPublicKey)m_plib->resolve("sm2_set_public_key");
+    m_pfEncRaw = (psm2EncryptRaw)m_plib->resolve("sm2_encrypt_raw");
+    m_pfDecRaw = (psm2DecryptRaw)m_plib->resolve("sm2_decrypt_raw");
+    m_pfDecrypt = (psm2DecryptASN1)m_plib->resolve("sm2_decrypt_asn1");
+    m_pfEncrypt = (psm2EncryptASN1)m_plib->resolve("sm2_encrypt_asn1");
+    m_pfSignature = (psm2Signature)m_plib->resolve("sm2_signature");
+    m_pfVerifySign = (psm2VerifySign)m_plib->resolve("sm2_verify_sign");
+
+    m_pfSm3 = (psm3)m_plib->resolve("sm3");
+    //m_pfSm3File = (psm3_file)m_plib->resolve("sm3_file");
+
+    m_pfSm4Encrypt = (psm4Encrypt)m_plib->resolve("sm4_doencrypt");
+    m_pfSm4Decrypt = (psm4Decrypt)m_plib->resolve("sm4_dodecrypt");
+    m_pfSm4RandKey = (psm4RandKey)m_plib->resolve("sm4_rand_key");
+    m_pfSm4Dec = (psm4SetKeyDec)m_plib->resolve("sm4_setkey_dec");
+    m_pfSm4Enc = (psm4SetKeyEnc)m_plib->resolve("sm4_setkey_enc");
+    m_pfSm4EncEcb = (psm4EncryptEcb)m_plib->resolve("sm4_encrypt_ecb");
+    m_pfSm4DecEcb = (psm4DecryptEcb)m_plib->resolve("sm4_decrypt_ecb");
+    m_pfSm4EncCbc = (psm4EncryptCbc)m_plib->resolve("sm4_encrypt_cbc");
+    m_pfSm4DecCbc = (psm4DecryptCbc)m_plib->resolve("sm4_decrypt_cbc");
+}
+
+bool SMClass::Sm2CreateKey(sm2_context* ctx)
+{
+    if (nullptr == m_pfCreateK) {
+        qDebug() << "sm2_create_key接口未加载。";
+        return false;
+    }
+
+    return m_pfCreateK(ctx);
+}
+
+bool SMClass::Sm2PublicKey(sm2_context* ctx, QString& key)
+{
+    if (nullptr == m_pfPubKey) {
+        qDebug() << "sm2_public_key接口未加载。";
+        return false;
+    }
+    uint8_t tmpKey[130]{0};
+    bool bRet = m_pfPubKey(ctx, tmpKey);
+    key = QString::fromStdString(std::string((char*)tmpKey, sizeof(tmpKey)));
+    return bRet;
+}
+
+bool SMClass::Sm2PublicKeyASN1(sm2_context* ctx, QString& key)
+{
+    if (nullptr == m_pfPubKeyASN1) {
+        qDebug() << "sm2_public_key_asn1接口未加载。";
+        return false;
+    }
+    uint8_t tmpKey[MAX_KEY_LEN]{0};
+    size_t len = sizeof(tmpKey);
+    bool bRet = m_pfPubKeyASN1(ctx, tmpKey, &len);
+    key = QString::fromStdString(std::string((char*)tmpKey, len));
+    return bRet;
+}
+
+bool SMClass::Sm2PublicKey2Pem(sm2_context* ctx, const QString& path)
+{
+    if (nullptr == m_pfPubKey2Pem) {
+        qDebug() << "sm2_public_key_to_pem接口未加载。";
+        return false;
+    }
+    auto str = path.toStdString();// QString的size不考虑编码
+    return m_pfPubKey2Pem(ctx, str.c_str(), str.size());
+}
+
+bool SMClass::Sm2SetPublicKey(sm2_context* ctx, int mode, const QString& data)
+{
+    if (nullptr == m_pfSetPubKey) {
+        qDebug() << "sm2_set_public_key接口未加载。";
+        return false;
+    }
+    bool bRet = false;
+    if (2 != mode) {
+        bRet = m_pfSetPubKey(ctx, mode, (const uint8_t*)data.toStdString().c_str(), data.toStdString().size());
+    } else {
+        // 读取pem文件
+        auto str = data.toStdString();
+        bRet = m_pfSetPubKey(ctx, mode, (uint8_t*)str.c_str(), str.size());
+    }
+
+    return bRet;
+}
+
+bool SMClass::Sm2EncryptRaw(sm2_context* ctx, int mode, const QString& msg, QString& output)
+{
+    if (nullptr == m_pfEncRaw) {
+        qDebug() << "sm2_encrypt_raw接口未加载。";
+        return false;
+    }
+    uint8_t tmpOut[MAX_MSG_LEN]{0};
+    size_t len = MAX_MSG_LEN;
+    auto str = msg.toStdString();
+    bool bRet = m_pfEncRaw(ctx, mode, (uint8_t*)(str.c_str()), str.size(), tmpOut, &len);
+    output = QString::fromStdString(std::string((char*)tmpOut, len));
+    return bRet;
+}
+
+bool SMClass::Sm2DecryptRaw(sm2_context* ctx, int mode, const QString& msg, QString& output)
+{
+    if (nullptr == m_pfDecRaw) {
+        qDebug() << "sm2_decrypt_raw接口未加载。";
+        return false;
+    }
+    uint8_t tmpOut[255]{0};
+    size_t outlen = 255;
+    bool bRet = m_pfDecRaw(ctx, mode, (uint8_t*)msg.toStdString().c_str(), msg.toStdString().size(), tmpOut, &outlen);
+    output = QString::fromStdString(std::string((char*)tmpOut, outlen));
+    return bRet;
+}
+
+bool SMClass::Sm2EncryptASN1(sm2_context* ctx, const QString& msg, QString& output)
+{
+    if (nullptr == m_pfEncrypt) {
+        qDebug() << "sm2_encrypt_asn1接口未加载。";
+        return false;
+    }
+    uint8_t tmpOut[MAX_MSG_LEN]{0};
+    size_t len = MAX_MSG_LEN;
+    auto str = msg.toStdString();
+    bool bRet = m_pfEncrypt(ctx, (uint8_t*)str.c_str(), str.size(), tmpOut, &len);
+    output = QString::fromStdString(std::string((char*)tmpOut, len));
+    return bRet;
+}
+
+bool SMClass::Sm2DecryptASN1(sm2_context* ctx, const QString& msg, QString& output)
+{
+    if (nullptr == m_pfDecrypt) {
+        qDebug() << "sm2_decrypt_asn1接口未加载。";
+        return false;
+    }
+    uint8_t tmpOut[MAX_MSG_LEN]{0};
+    size_t outlen = MAX_MSG_LEN;
+    bool bRet = m_pfDecrypt(ctx, (uint8_t*)msg.toStdString().c_str(), msg.toStdString().size(), tmpOut, &outlen);
+    output = QString::fromStdString(std::string((char*)tmpOut));
+    return bRet;
+}
+
+bool SMClass::Sm2Signature(sm2_context* ctx, const QString& msg, QString& sign)
+{
+    if (nullptr == m_pfSignature) {
+        qDebug() << "sm2_signature接口未加载。";
+        return false;
+    }
+    uint8_t tmpOut[366]{0};
+    size_t len = 366;
+    bool bRet = m_pfSignature(ctx, (uint8_t*)msg.toStdString().c_str(), msg.toStdString().size(), tmpOut, &len);
+    sign = QString::fromStdString(std::string((char*)tmpOut, len));
+    return bRet;
+}
+
+bool SMClass::Sm2VerifySign(sm2_context* ctx, const QString& msg, const QString& sign)
+{
+    if (nullptr == m_pfVerifySign) {
+        qDebug() << "sm2_verify_sign接口未加载。";
+        return false;
+    }
+    bool bRet = m_pfVerifySign(ctx, (uint8_t*)msg.toStdString().c_str(), msg.toStdString().size(), (uint8_t*)sign.toStdString().c_str(), sign.toStdString().size());
+    return bRet;
+}
+
+void SMClass::Sm3Hash(const QString& input, QString& output)
+{
+    if (nullptr == m_pfSm3) {
+        qDebug() << "sm3接口未加载。";
+        return;
+    }
+#ifdef Q_OS_LINUX
+    ExeSm3Hash(input, output);
+#else
+    sm3(input, output);
+#endif
+}
+
+int SMClass::Sm4Encrypt(const QString& key, const QString& input, QString& output)
+{
+    if (nullptr == m_pfSm4Encrypt) {
+        qDebug() << "sm4_encrypt接口未加载";
+        return 0;
+    }
+#ifdef Q_OS_LINUX
+    ExeSm4Encrypt(key, input, output);
+    return output.length();
+#else
+    return sm4Enc(key, input, output);
+#endif
+}
+
+int SMClass::Sm4Decrypt(const QString& key, const QString &input, QString &output)
+{
+    if (nullptr == m_pfSm4Decrypt) {
+        qDebug() << "sm4_decrypt接口未加载";
+        return 0;
+    }
+#ifdef Q_OS_LINUX
+    ExeSm4Decrypt(key, input, output);
+    return output.length();
+#else
+    return sm4Dec(key, input, output);
+#endif
+}
+
+void SMClass::Sm4RandKey(QString& key)
+{
+    if (nullptr == m_pfSm4RandKey) {
+        qDebug() << "sm4_rand_key接口未加载。";
+        return;
+    }
+    uint8_t tmpKey[32]{0};
+    m_pfSm4RandKey(tmpKey, sizeof(tmpKey));
+    key = QString::fromStdString(std::string((char*)tmpKey, sizeof(tmpKey)));
+}
+
+void SMClass::Sm4KeyEncrypt(sm4_context* ctx, const QString& key)
+{
+    if (nullptr == m_pfSm4Enc) {
+        qDebug() << "sm4_setkey_enc接口未加载。";
+        return;
+    }
+    uint8_t aKey[32]{0};
+    memcpy_s(aKey, sizeof(aKey), key.toStdString().c_str(), key.toStdString().size());
+    m_pfSm4Enc(ctx, aKey);
+}
+
+void SMClass::Sm4KeyDecrypt(sm4_context* ctx, const QString& key)
+{
+    if (nullptr == m_pfSm4Dec) {
+        qDebug() << "sm4_setkey_dec接口未加载。";
+        return;
+    }
+
+    uint8_t aKey[32]{0};
+    memcpy_s(aKey, sizeof(aKey), key.toStdString().c_str(), key.toStdString().size());
+    m_pfSm4Dec(ctx, aKey);
+}
+
+int SMClass::Sm4EncryptEcb(sm4_context *ctx, const QString& input, QString& output)
+{
+    if (nullptr == m_pfSm4EncEcb) {
+        qDebug() << "sm4_encrypt_ecb接口未加载。";
+        return 0;
+    }
+    auto str = input.toStdString();
+    size_t inlen = input.toStdString().size();
+    pUchar pOut(new uint8_t[MAX_MSG_LEN]{0});
+    int outlen = m_pfSm4EncEcb(ctx, (uint8_t*)input.toStdString().c_str(), inlen, pOut.get());
+    output = QString::fromStdString(std::string((char*)pOut.get(), outlen));
+    return outlen;
+}
+
+int SMClass::Sm4DecryptEcb(sm4_context *ctx, const QString& input, QString& output)
+{
+    if (nullptr == m_pfSm4DecEcb) {
+        qDebug() << "sm4_decrypt_ecb接口未加载。";
+        return 0;
+    }
+    if (input.size() % 16 != 0) return 0;
+    pUchar pOut(new unsigned char[MAX_MSG_LEN]{0});
+    int outlen = m_pfSm4DecEcb(ctx, (uint8_t*)input.toStdString().c_str(), input.toStdString().size(), pOut.get());
+    if (outlen < 0) return 0;
+    output = QString::fromStdString(std::string((char*)pOut.get(), outlen));
+    return outlen;
+}
+
+int SMClass::Sm4EncryptCbc(sm4_context *ctx, const QString& iv, const QString& input, QString& output)
+{
+    if (nullptr == m_pfSm4EncCbc) {
+        qDebug() << "sm4_encrypt_cbc接口未加载。";
+        return 0;
+    }
+
+    pUchar pOut(new uint8_t[MAX_MSG_LEN]{0});
+    uint8_t arrIv[32]{0};
+    memcpy_s(arrIv, sizeof(arrIv), iv.toStdString().c_str(), iv.toStdString().size());
+    int outlen = m_pfSm4EncCbc(ctx, arrIv, (uint8_t*)input.toStdString().c_str(), input.toStdString().size(), pOut.get());
+    output = QString::fromStdString(std::string((char*)pOut.get(), outlen));
+    return outlen;
+}
+
+int SMClass::Sm4DecryptCbc(sm4_context *ctx, const QString& iv, const QString& input, QString& output)
+{
+    if (nullptr == m_pfSm4DecCbc) {
+        qDebug() << "sm4_decrypt_cbc接口未加载。";
+        return 0;
+    }
+    uint8_t arrIv[32]{0};
+    memcpy_s(arrIv, sizeof(arrIv), iv.toStdString().c_str(), iv.toStdString().size());
+
+    pUchar pOut(new unsigned char[MAX_MSG_LEN]{0});
+    int outlen = m_pfSm4DecCbc(ctx, arrIv, (uint8_t*)input.toStdString().c_str(), input.toStdString().size(), pOut.get());
+    if (outlen < 0) return 0;
+    output = QString::fromStdString(std::string((char*)pOut.get(), outlen));
+    return outlen;
+}
+
+void SMClass::ExeSm3Hash(const QString& input, QString& out)
+{
+    QProcess process;
+    process.start("./SM_Dll", QStringList() << "sm3" << input);
+    if (process.waitForStarted()) {
+        if (process.waitForFinished()) {
+            out = process.readAllStandardOutput();
+        }
+    }
+}
+
+int SMClass::ExeSm4Encrypt(const QString& key, const QString& input, QString& out)
+{
+    QProcess process;
+    process.start(QString("./SM_Dll"), QStringList() << "sm4Enc" << key << input);
+    if (process.waitForStarted()) {
+        if (process.waitForFinished()) {
+            out = process.readAllStandardOutput();
+            return !out.isEmpty();
+        }
+    }
+    return 0;
+}
+
+int SMClass::ExeSm4Decrypt(const QString& key, const QString& input, QString& out)
+{
+    QProcess process;
+    process.start("./SM_Dll", QStringList() << "sm4Dec" << key << input);
+    if (process.waitForStarted()) {
+        if (process.waitForFinished()) {
+            out = process.readAllStandardOutput();
+            return !out.isEmpty();
+        }
+    }
+    return 0;
+}
+
+void SMClass::sm3(const QString& input, QString& output)
+{
+    auto str = input.toStdString();
+    uint8_t out[64]{0};
+    m_pfSm3((uint8_t*)str.c_str(), str.size(), out);
+    output = QString::fromStdString(std::string((char*)out, sizeof(out)));
+}
+
+int SMClass::sm4Enc(const QString& key, const QString& input, QString& output)
+{
+    char out[MAX_MSG_LEN]{0};
+    size_t outlen = MAX_MSG_LEN; // 真实大小
+    outlen = m_pfSm4Encrypt(key.toStdString().c_str(), key.toStdString().size(), input.toStdString().c_str(), input.toStdString().size(), out, &outlen);
+    output = QString::fromStdString(std::string(out, outlen));
+    return outlen;
+}
+
+int SMClass::sm4Dec(const QString& key, const QString& input, QString& output)
+{
+    char out[MAX_MSG_LEN]{0};
+    size_t outlen = MAX_MSG_LEN; // 真实大小
+    outlen = m_pfSm4Decrypt(key.toStdString().c_str(), key.toStdString().size(), input.toStdString().c_str(), input.toStdString().size(), out, &outlen);
+    output = QString::fromStdString(std::string(out, outlen));
+    return outlen;
+}
+
+QString SMClass::uchartoHex(uint8_t* input, size_t size) {
+    if (nullptr == input) return QString();
+
+    std::unique_ptr<char[]> output(new char[size * 2 + 1]{0});
+    for (size_t i = 0; i < size; ++i) {
+        sprintf(&output[i * 2], "%02x", input[i]);
+    }
+    QString ret(output.get());
+    return ret.toUpper();
+}
+
+std::unique_ptr<uint8_t[]> SMClass::hextoUchar(const QString& hexString, size_t& size) {
+    size_t length = hexString.size();
+    size = 0;
+    if (length % 2 != 0) {
+        return std::unique_ptr<uint8_t[]>(); // 非偶数长度的十六进制字符串无法转换
+    }
+    size = length / 2;
+    std::string pHex = hexString.toStdString();
+    std::unique_ptr<uint8_t[]> output(new unsigned char[size]{0});
+    try {
+        for (size_t i = 0; i < size; ++i) {
+            int value = 0;
+            sscanf(&pHex[i * 2], "%2x", &value);
+            output[i] = (unsigned char)value;
+        }
+    } catch(...) {
+        qDebug() << "从Hex string到uint8_t*转换失败!";
+    }
+
+    return std::move(output);
+}
+
+void SMClass::readResultAndDelete(const QString &fileName, QString &out)
+{
+    QFile tmpF(fileName);
+    if (tmpF.open(QIODevice::ReadOnly)) {
+        out = tmpF.readAll();
+        tmpF.close();
+    }
+    //QFile::remove(fileName);
+}

+ 0 - 0
common/LightLog/LightLog.cpp


+ 28 - 0
common/LightLog/LightLog.h

@@ -0,0 +1,28 @@
+#ifndef LIGHTLOG_H
+#define LIGHTLOG_H
+
+#include <QDebug>
+#include <QDateTime>
+
+// #define LOG_DEBUG(msg) do{ QString file = __FILE__; qDebug("[%s] [ %s:%d ] %s", QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString().c_str() , file.right(file.count() - file.lastIndexOf('/') -1).toStdString().c_str() , __LINE__ , msg); }while(0)
+// #define LOG_INFO(msg) do{ QString file = __FILE__; qInfo("[%s] [ %s:%d ] %s", QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString().c_str() , file.right(file.count() - file.lastIndexOf('/') -1).toStdString().c_str() , __LINE__ , msg); }while(0)
+// #define LOG_WARN(msg) do{ QString file = __FILE__; qWarning("[%s] [ %s:%d ] %s", QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString().c_str() , file.right(file.count() - file.lastIndexOf('/') -1).toStdString().c_str() , __LINE__ , msg); }while(0)
+
+
+#define LOG_DEBUG(msg) do{ QString file = __FILE__; QString str = '[' +  QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz") + ']' + '[' + file.right(file.count() - file.lastIndexOf('/') -1) + ':' + QString::number(__LINE__) + "] " + msg; qDebug() << str; }while(0)
+#define LOG_INFO(msg) do{ QString file = __FILE__; QString str = '[' +  QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz") + ']' + '[' + file.right(file.count() - file.lastIndexOf('/') -1) + ':' + QString::number(__LINE__) + "] " + msg; qInfo() << str; }while(0)
+#define LOG_WARN(msg) do{ QString file = __FILE__; QString str = '[' +  QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz") + ']' + '[' + file.right(file.count() - file.lastIndexOf('/') -1) + ':' + QString::number(__LINE__) + "] " + msg; qWarning() << str; }while(0)
+
+
+
+// void hello()
+// {
+//     QString file = __FILE__;
+//     file.lastIndexOf('/');
+//     file.right(file.count() - file.lastIndexOf('/')).toStdString().c_str();
+//     QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz");
+//     qInfo("[%s] [ %s:%d ] %s", QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString().c_str() , file.right(file.count() - file.lastIndexOf('/') -1).toStdString().c_str() , __LINE__ , "hello");
+    
+// }
+
+#endif /* LIGHTLOG_H */

+ 3 - 3
common/Logs/loginit.cpp

@@ -25,8 +25,8 @@ void init_log()
         /* 创建一个标准输出 */
         auto logger_main = std::make_shared<spdlog::logger>("main",begin(sinks),end(sinks));
 
-        /* 创建一个UI输出Logger */
-        auto logger_UI_Main = std::make_shared<spdlog::logger>("UI_Main",begin(sinks),end(sinks));
+        /* 创建一个MQTT输出Logger */
+        auto logger_MQTT = std::make_shared<spdlog::logger>("MQTT",begin(sinks),end(sinks));
         /* 创建一个UI输出Logger */
         auto logger_UI_IPSet = std::make_shared<spdlog::logger>("UI_IPSet",begin(sinks),end(sinks));
         /* 创建一个设备IO logger,包括网络和串口 */
@@ -45,7 +45,7 @@ void init_log()
 
         /* 注册到注册表 */
         spdlog::register_logger(logger_main);
-        spdlog::register_logger(logger_UI_Main);
+        spdlog::register_logger(logger_MQTT);
         spdlog::register_logger(logger_UI_IPSet);
         spdlog::register_logger(logger_DeviceIO);
         spdlog::register_logger(logger_UIBoardCast);

+ 136 - 0
common/http/QtHttps.cpp

@@ -0,0 +1,136 @@
+
+#include "QtHttps.h"
+#include "lightlog.h"
+
+#include <QEventLoop>
+
+QtHttps::QtHttps(QObject *parent) :
+    QObject(parent)
+{
+    /* 初始化函数 */
+    m_manager = new QNetworkAccessManager(this);
+
+
+    /* 链接信号 */
+    // connect(m_manager, &QNetworkAccessManager::finished, this, &QtHttps::do_replyFinished);
+
+}
+QtHttps::~QtHttps()
+{
+    delete m_manager;
+}
+
+bool QtHttps::Get(const QString &url)
+{
+    if(m_manager == nullptr)
+    {
+        LOG_WARN("m_manager is nullptr");
+        return false;
+    }
+    QNetworkRequest request;
+    request.setUrl(QUrl(url));
+    /* 等待返回 */
+    
+    m_reply = m_manager->get(request);
+    connect(m_reply, &QNetworkReply::finished, this, &QtHttps::do_replyFinished);
+    return true;
+}
+
+/* 获取请求头信息 */
+bool QtHttps::GetHead(const QString &url)
+{
+    if(m_manager == nullptr)
+    {
+        LOG_WARN("m_manager is nullptr");
+        return false;
+    }
+    QNetworkRequest request;
+    request.setUrl(url);
+
+    m_reply = m_manager->head(request);
+    connect(m_reply, &QNetworkReply::finished, this, &QtHttps::do_replyFinished);
+    connect(m_reply, &QNetworkReply::readyRead, this, &QtHttps::do_replyReadyRead);
+    // connect(m_reply, &QNetworkReply::downloadProgress, this, &QtHttps::do_downloadProgress);
+
+    return true;
+}
+
+void QtHttps::Post(const QString &url, const QByteArray &data)
+{
+
+}
+
+
+/* 下载文件 */
+void QtHttps::downloadFile(const QString &url, const QString &filePath)
+{
+    if(m_manager == nullptr)
+    {
+        LOG_WARN("m_manager is nullptr");
+        return;
+    }
+    /* 检查文件有效性 */
+    m_file = new QFile(this);
+    m_file->setFileName(filePath);
+    if(!m_file->open(QIODevice::WriteOnly | QIODevice::Truncate))
+    {
+        LOG_WARN("open file failed , file path : " + filePath);
+        m_file->close();
+        delete m_file;
+        m_file = nullptr;
+        return;
+    }
+    /* 发送请求 */
+    QNetworkRequest request;
+    request.setUrl(QUrl(url));
+    m_reply = m_manager->get(request);
+    /* 链接信号 */
+    connect(m_reply, &QNetworkReply::finished, this, &QtHttps::do_replyFinished);
+    connect(m_reply, &QNetworkReply::readyRead, this, &QtHttps::do_replyReadyRead);
+    connect(m_reply, &QNetworkReply::downloadProgress, this, &QtHttps::do_downloadProgress);
+}
+
+
+/* 请求完成的槽函数 */
+void QtHttps::do_replyFinished()
+{
+    LOG_DEBUG("do_replyFinished");
+
+    if(m_reply->error() == QNetworkReply::NoError)
+    {
+        LOG_DEBUG("reply success");
+        auto list = m_reply->rawHeaderList();
+        for(auto &item : list)
+        {
+            LOG_DEBUG(item + " : " + m_reply->rawHeader(item));
+        }
+
+        auto ret = m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+        LOG_DEBUG("Status Code : " + QString::number(ret));
+    }
+    else
+    {
+        LOG_WARN("reply error : " + m_reply->errorString());
+    }
+    /* 记得设置这个,需要手动释放 */
+    m_reply->deleteLater();
+    m_reply = nullptr;
+}
+
+/* 读取数据 */
+void QtHttps::do_replyReadyRead()
+{
+    LOG_DEBUG("do_replyReadyRead");
+    if(m_file != nullptr)
+    {
+        m_file->write(m_reply->readAll());
+    }
+}
+
+/* 下载进度 */
+void QtHttps::do_downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
+{
+    LOG_DEBUG("do_downloadProgress");
+    LOG_DEBUG("bytesReceived : " + QString::number(bytesReceived));
+    LOG_DEBUG("bytesTotal : " + QString::number(bytesTotal));
+}

+ 36 - 0
common/http/QtHttps.h

@@ -0,0 +1,36 @@
+#ifndef QTHTTPS_H
+#define QTHTTPS_H
+
+#include <QObject>
+#include <QNetworkReply>
+#include <QNetworkAccessManager>
+#include <QNetworkRequest>
+#include <QFile>
+
+class QtHttps : public QObject
+{
+    Q_OBJECT
+public:
+    explicit QtHttps(QObject *parent = nullptr);
+    ~QtHttps();
+
+    bool Get(const QString &url);
+    bool GetHead(const QString &url);
+    void Post(const QString &url, const QByteArray &data);
+
+    void downloadFile(const QString &url, const QString &filePath);
+
+private slots:
+    void do_replyFinished();
+    void do_replyReadyRead();
+    void do_downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
+
+private:
+    QNetworkAccessManager *m_manager = nullptr;
+    QNetworkReply *m_reply = nullptr;
+
+    QFile *m_file = nullptr;                /* 保存临时文件 */
+};
+
+
+#endif /* QTHTTPS_H */

+ 110 - 0
common/mqtt/fromMQTT.cpp

@@ -0,0 +1,110 @@
+#include "fromMQTT.h"
+
+#include <QDebug>
+#include <QJsonDocument>
+#include <QJsonObject>
+#include <QJsonParseError>
+
+#include "qmqtt_message.h"
+
+
+FromMQTT::FromMQTT(QObject* parent) : QObject(parent)
+{
+    /* 获取日志 */
+    m_logger = spdlog::get("MQTT");
+    if(m_logger == nullptr)
+    {
+        qDebug() << "获取MQTT logger 失败!";
+        exit(-1);
+    }
+
+    /* 连接信号和槽 */
+    connect(&m_client,SIGNAL(connected()),this,SLOT(do_connected()));
+    connect(&m_client,SIGNAL(disconnected()),this,SLOT(do_disconnect()));
+    connect(&m_client,SIGNAL(error(QMQTT::ClientError)),this,SLOT(do_error(QMQTT::ClientError)));
+    connect(&m_client,SIGNAL(received(QMQTT::Message)),this,SLOT(do_received(QMQTT::Message)));
+    connect(&m_client,SIGNAL(subscribed(QString,quint8)),this,SLOT(do_subscribed(QString, quint8)));
+
+    
+}
+
+/* 设置地址 */
+void FromMQTT::setHostName(const QString& hostName)
+{
+    QHostAddress addr = QHostAddress(hostName);
+    m_client.setHost(addr);
+}
+
+/* 设置订阅 */
+void FromMQTT::setSubcribe(const QString& topic, int qos)
+{
+    m_client.subscribe(topic,qos);
+}
+
+/* 连接到服务器 */
+void FromMQTT::connectToServer()
+{
+    m_client.connectToHost();
+}
+
+/* 解析所有消息 */
+void FromMQTT::analyzeAllMessage()
+{
+    while (!m_queueMessage.isEmpty())
+    {
+        analyzeOneMessage();
+    }
+}
+
+/* 解析消息数据 */
+void FromMQTT::analyzeOneMessage()
+{
+    /* 先解锁,目前没有锁 */
+    if(m_queueMessage.isEmpty())
+    {
+        return;
+    }
+    SPDLOG_LOGGER_INFO(m_logger,"message:{}",m_queueMessage.front().toStdString());
+
+    /* 出队 */
+    m_queueMessage.dequeue();
+}
+
+
+/* 连接成功 */
+void FromMQTT::do_connected()
+{
+    SPDLOG_LOGGER_INFO(m_logger,"连接成功!");
+    m_client.subscribe("test/one");
+}
+
+/* 断开连接 */
+void FromMQTT::do_disconnect()
+{
+    SPDLOG_LOGGER_INFO(m_logger,"断开连接!");
+}
+
+/* 错误 */
+void FromMQTT::do_error(const QMQTT::ClientError error)
+{
+    SPDLOG_LOGGER_ERROR(m_logger,"错误:{}",(int)error);
+}
+
+/* 订阅成功 */
+void FromMQTT::do_subscribed(const QString& topic, const quint8 qos)
+{
+    SPDLOG_LOGGER_INFO(m_logger,"订阅:{},QoS:{} 成功",topic.toStdString(),qos);
+}
+
+/* 接收到消息 */
+void FromMQTT::do_received(const QMQTT::Message& message)
+{
+    // SPDLOG_LOGGER_INFO(m_logger,"接收到一条消息:{}",message.topic().toStdString());
+    /* 接收到消息,加入列表中 */
+    QByteArray ba = message.payload();
+    /* 这里可以添加锁,不过目前是单线程,不需要添加 */
+    m_queueMessage.enqueue(ba);
+
+    analyzeOneMessage();
+}
+

+ 40 - 0
common/mqtt/fromMQTT.h

@@ -0,0 +1,40 @@
+#ifndef FROMMQTT_H
+#define FROMMQTT_H
+
+#include <QObject>
+#include <QQueue>
+
+#include "qmqtt.h"
+#include "spdlog/spdlog.h"
+
+class FromMQTT : public QObject
+{
+    Q_OBJECT
+public:
+    FromMQTT(QObject* parent = nullptr);
+
+    void setHostName(const QString& hostName);      /* 设置地址 */
+    void setSubcribe(const QString& topic,int qos = 0);/* 设置订阅 */
+    void connectToServer();                         /* 连接到服务器 */
+    void analyzeAllMessage();                       /* 解析所有消息 */
+
+private:
+    void analyzeOneMessage();                       /* 解析消息数据 */
+
+private slots:
+    void do_connected();                            /* 连接成功 */
+    void do_disconnect();                           /* 断开连接 */
+    void do_error(const QMQTT::ClientError error);  /* 错误 */
+    void do_subscribed(const QString& topic, const quint8 qos);     /* 订阅成功 */
+    void do_received(const QMQTT::Message& message);/* 接收到消息 */
+
+
+private:
+    std::shared_ptr<spdlog::logger> m_logger = nullptr;
+
+    QMQTT::Client m_client;                         /* MQTT客户端 */
+    QQueue<QByteArray> m_queueMessage;              /* 消息列表 */
+};
+
+
+#endif /* FROMMQTT_H */

+ 67 - 0
demo/http/CMakeLists.txt

@@ -0,0 +1,67 @@
+cmake_minimum_required(VERSION 3.5)
+
+set(exec_name http)
+
+
+#包含源文件
+file(GLOB LOCAL_SRC
+    ${CMAKE_CURRENT_SOURCE_DIR}/*.qrc
+    ${CMAKE_CURRENT_SOURCE_DIR}/*.rc
+    ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/*.ui
+
+    ${CMAKE_SOURCE_DIR}/common/http/*.cpp
+)
+
+
+# 生成可执行程序
+if(CMAKE_BUILD_TYPE MATCHES Debug)
+    add_executable(${exec_name}
+        # WIN32
+        ${GLOBAL_SRC}
+        ${LOCAL_SRC}
+        
+    )
+elseif(CMAKE_BUILD_TYPE MATCHES Release)
+    add_executable(${exec_name}
+        # WIN32
+        ${GLOBAL_SRC}
+        ${LOCAL_SRC}
+    )
+endif()
+
+#添加头文件
+target_include_directories(${exec_name} PRIVATE
+
+    ${CMAKE_CURRENT_SOURCE_DIR}
+    ${CMAKE_SOURCE_DIR}/common/http
+    ${qmqtt_INCLUDE_DIR}
+)
+
+target_link_libraries(${exec_name} PRIVATE
+    Qt5::Widgets
+    Qt5::Core
+    Qt5::Network
+    # Qt5::Multimedia
+    # Qt5::Xml
+    # Qt5::Sql
+)
+
+target_link_libraries(${exec_name} PRIVATE 
+    fmt::fmt
+    spdlog::spdlog
+
+)
+
+
+if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
+    target_link_libraries(${exec_name} PRIVATE
+        # debug spdlogd.lib
+        # optimized spdlog.lib
+    )
+elseif(CMAKE_CXX_COMPILER_ID MATCHES GNU)
+    target_link_libraries(${exec_name} PRIVATE
+        # debug 
+        # optimized ${SM_DLL}
+    )
+endif()

+ 0 - 0
main.cpp → demo/http/main.cpp


+ 44 - 0
demo/http/widget.cpp

@@ -0,0 +1,44 @@
+#include "widget.h"
+#include "./ui_widget.h"
+
+#include <QNetworkReply>
+#include <QNetworkAccessManager>
+#include <QNetworkRequest>
+#include <QTimer>
+#include <QNetworkProxy>
+
+#include "spdlog/spdlog.h"
+
+
+Widget::Widget(QWidget *parent)
+    : QWidget(parent)
+    , ui(new Ui::Widget)
+{
+    ui->setupUi(this);
+
+    // 初始化QtHttps
+    m_qtHttps = new QtHttps(this);
+
+    SPDLOG_INFO("***** Qt Library *****");
+
+}
+
+Widget::~Widget()
+{
+    delete m_qtHttps;
+    delete ui;
+}
+
+
+void Widget::on_pBtn_connectHTTP_clicked()
+{
+    SPDLOG_INFO("点击了“连接按钮”");
+    m_qtHttps->GetHead("http://192.168.50.100:3000/apple/Embedded_A33.git");
+}
+
+void Widget::on_pBtn_downloadFile_clicked()
+{
+    SPDLOG_INFO("点击了“下载文件”");
+    m_qtHttps->downloadFile("http://192.168.50.100:3000/apple/Embedded_A33.git", "Embedded_A33.zip");
+}
+

+ 32 - 0
demo/http/widget.h

@@ -0,0 +1,32 @@
+#ifndef WIDGET_H
+#define WIDGET_H
+
+#include <QWidget>
+
+#include "QtHttps.h"
+
+QT_BEGIN_NAMESPACE
+namespace Ui { class Widget; }
+QT_END_NAMESPACE
+
+class Widget : public QWidget
+{
+    Q_OBJECT
+
+public:
+    Widget(QWidget *parent = nullptr);
+    ~Widget();
+
+private slots:
+
+    void on_pBtn_connectHTTP_clicked();
+
+    void on_pBtn_downloadFile_clicked();
+
+private:
+    Ui::Widget *ui;
+
+    QtHttps *m_qtHttps = nullptr;
+
+};
+#endif // WIDGET_H

+ 45 - 0
demo/http/widget.ui

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Widget</class>
+ <widget class="QWidget" name="Widget">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>800</width>
+    <height>600</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Widget</string>
+  </property>
+  <widget class="QWidget" name="widget_pBtn" native="true">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>30</y>
+     <width>381</width>
+     <height>121</height>
+    </rect>
+   </property>
+   <layout class="QGridLayout" name="gridLayout">
+    <item row="0" column="0">
+     <widget class="QPushButton" name="pBtn_connectHTTP">
+      <property name="text">
+       <string>连接HTTP</string>
+      </property>
+     </widget>
+    </item>
+    <item row="0" column="1">
+     <widget class="QPushButton" name="pBtn_downloadFile">
+      <property name="text">
+       <string>下载文件</string>
+      </property>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 68 - 0
demo/mqtt/CMakeLists.txt

@@ -0,0 +1,68 @@
+cmake_minimum_required(VERSION 3.5)
+
+set(exec_name mqtt)
+
+
+#包含源文件
+file(GLOB LOCAL_SRC
+    ${CMAKE_CURRENT_SOURCE_DIR}/*.qrc
+    ${CMAKE_CURRENT_SOURCE_DIR}/*.rc
+    ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/*.ui
+
+    ${CMAKE_SOURCE_DIR}/common/mqtt/*.cpp
+)
+
+
+# 生成可执行程序
+if(CMAKE_BUILD_TYPE MATCHES Debug)
+    add_executable(${exec_name}
+        # WIN32
+        ${GLOBAL_SRC}
+        ${LOCAL_SRC}
+        
+    )
+elseif(CMAKE_BUILD_TYPE MATCHES Release)
+    add_executable(${exec_name}
+        # WIN32
+        ${GLOBAL_SRC}
+        ${LOCAL_SRC}
+    )
+endif()
+
+#添加头文件
+target_include_directories(${exec_name} PRIVATE
+
+    ${CMAKE_CURRENT_SOURCE_DIR}
+
+    ${CMAKE_SOURCE_DIR}/common/mqtt
+    ${qmqtt_INCLUDE_DIR}
+)
+
+target_link_libraries(${exec_name} PRIVATE
+    Qt5::Widgets
+    Qt5::Core
+    Qt5::Network
+    # Qt5::Multimedia
+    # Qt5::Xml
+    # Qt5::Sql
+)
+
+target_link_libraries(${exec_name} PRIVATE 
+    fmt::fmt
+    spdlog::spdlog
+    ${qmqtt_LIBRARY}
+)
+
+
+if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
+    target_link_libraries(${exec_name} PRIVATE
+        # debug spdlogd.lib
+        # optimized spdlog.lib
+    )
+elseif(CMAKE_CXX_COMPILER_ID MATCHES GNU)
+    target_link_libraries(${exec_name} PRIVATE
+        # debug 
+        # optimized ${SM_DLL}
+    )
+endif()

+ 14 - 0
demo/mqtt/main.cpp

@@ -0,0 +1,14 @@
+#include "widget.h"
+
+#include <QApplication>
+#include "loginit.h"
+#include "spdlog/spdlog.h"
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+    init_log();
+    Widget w;
+    w.show();
+    return a.exec();
+}

+ 0 - 0
qmqtt-API.md → demo/mqtt/qmqtt-API.md


+ 170 - 0
demo/mqtt/widget.cpp

@@ -0,0 +1,170 @@
+#include "widget.h"
+#include "./ui_widget.h"
+
+#include <QNetworkReply>
+#include <QNetworkAccessManager>
+#include <QNetworkRequest>
+#include <QTimer>
+#include <QNetworkProxy>
+#include <QJsonDocument>
+#include <QJsonParseError>
+
+#include "spdlog/spdlog.h"
+
+Widget::Widget(QWidget *parent)
+    : QWidget(parent)
+    , ui(new Ui::Widget)
+{
+    ui->setupUi(this);
+
+
+    SPDLOG_INFO("***** Qt Library *****");
+
+    /* 这个好像是设置代理,设置成无代理,不然可能会报错 */
+    QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
+    m_client = new QMQTT::Client;
+    QHostAddress addr("192.1.2.61");
+    m_client->setHost(addr);
+    m_client->setPort(1883);
+    m_client->setClientId("qt_client");
+    m_client->setKeepAlive(60);
+    m_client->setWillQos(0);
+
+    connect(m_client,SIGNAL(received(const QMQTT::Message)),this,SLOT(do_receiveFromMqtt(const QMQTT::Message)));
+    connect(m_client,&QMQTT::Client::connected,this,[&](){
+        SPDLOG_INFO("连接成功!");
+        // m_client->subscribe("test/one");
+        m_client->subscribe(ui->lineEdit_subscribe->text());
+    });
+    connect(m_client,&QMQTT::Client::error,this,[&](const QMQTT::ClientError error){
+        SPDLOG_ERROR("MQTT Error: {}", (int)error);
+    });
+    connect(m_client,&QMQTT::Client::subscribed,this,[&](const QString& topic, const quint8 qos){
+        SPDLOG_INFO("Subscribed to: {}", topic.toStdString());
+    });
+    
+
+
+    auto timer = new QTimer(this);
+    timer->setTimerType(Qt::PreciseTimer);
+    connect(timer,&QTimer::timeout,this,[&](){
+        SPDLOG_INFO("Publishing to MQTT broker");
+        m_client->publish(QMQTT::Message(0,"test/one","Hello from Qt"));
+    });
+    // timer->start(1000);
+    ui->lineEdit_IP->setText("192.1.2.61");
+    ui->lineEdit_subscribe->setText("LH_ENERGY_FILE/ME24052101-hzlh-com");
+}
+
+Widget::~Widget()
+{
+    delete m_client;
+    delete ui;
+}
+/* 接收到数据 */
+void Widget::do_receiveFromMqtt(const QMQTT::Message& msg)
+{
+    SPDLOG_INFO("Received: {}", msg.payload().toStdString());
+    QJsonParseError error;
+    QJsonDocument doc = QJsonDocument::fromJson(msg.payload(),&error);
+    // if(error.error != QJsonParseError::NoError){
+    //     SPDLOG_ERROR("Json Parse Error: {}", error.errorString().toStdString());
+    //     return;
+    // }
+    SPDLOG_INFO("JSON : {}", doc.toJson().toStdString());
+    SPDLOG_INFO("原始数据 : {}", msg.payload().toHex().toStdString());
+}
+
+void Widget::on_pBtn_connectMQTT_clicked()
+{
+    SPDLOG_INFO("点击了“连接按钮”");
+    m_client->setHost(QHostAddress(ui->lineEdit_IP->text()));
+    m_client->connectToHost();
+}
+
+void Widget::on_pBtn_publishMSG_clicked()
+{
+    SPDLOG_INFO("点击了“发布按钮”");
+    m_client->publish(QMQTT::Message(0,"test/one","Hello from Qt"));
+}
+
+
+// void mqtt_handle()  {
+// sleep(5);
+//     struct mosquitto* mosq = NULL;
+//     int ret;
+	
+//     // 初始化Mosquitto库
+//     mosquitto_lib_init();
+// 	printf("mqtt 1\n");
+
+//     // 创建Mosquitto实例
+//     mosq = mosquitto_new(NULL, true, NULL);
+//     if (!mosq) {
+//         printf("Failed to create Mosquitto instance\n");
+//         return 1;
+//     }
+// 	printf("mqtt 2\n");
+
+//     // 设置连接成功和发布完成的回调函数
+//     mosquitto_connect_callback_set(mosq, on_connect);
+//     mosquitto_publish_callback_set(mosq, on_publish);
+// 	printf("mqtt 3\n");
+
+//     // 连接到MQTT代理
+//     ret = mosquitto_connect(mosq, MQTT_HOST, MQTT_PORT, 60);
+//     if (ret != MOSQ_ERR_SUCCESS) {
+//         printf("Failed to connect to MQTT broker: %s\n", mosquitto_strerror(ret));
+//         return 1;
+//     }
+// 	printf("mqtt 4\n");
+
+//    unsigned  char devicename[] = "GX24053004-hzlh-com";  // 设备名
+//    unsigned char timestr[] = "2024-07-31 15:05:36.010";  // 时间
+//    unsigned char hexValue[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};  // 十六进制值
+
+//   //  unsigned char* binaryValue;
+//   //  size_t binarySize;
+//    // hexStringToBinary(hexValue, &binaryValue, &binarySize);
+
+//     cJSON* root = cJSON_CreateObject();  // 创建根节点
+//    cJSON_AddItemToObject(root, "devicename", cJSON_CreateString((unsigned char*)devicename));  // 添加设备名
+//     cJSON_AddItemToObject(root, "time", cJSON_CreateString((unsigned char*)timestr));  // 添加时间
+//     cJSON_AddItemToObject(root, "value", cJSON_CreateRaw((unsigned char*)hexValue));  // 添加值
+//     unsigned char* jsonMessage = cJSON_PrintUnformatted(root);  // 将JSON对象转换为字符串
+//   // int bufferSize = 0;
+//  //  unsigned char*  jsonMessage = cJSON_PrintBuffered(root, bufferSize, false);
+// 	mqtt_flg =1;
+	
+// 	printf("ssmqttflg 4\n");
+
+//     // 发布消息
+//     while (1) {
+// 		if (mqtt_flg && sel_ok)
+// 			{
+// 			printf("jsonlen:%d\n",strlen(jsonMessage));
+//         ret = mosquitto_publish(mosq, NULL, TOPIC, strlen(jsonMessage), jsonMessage, QOS, false);
+//         if (ret != MOSQ_ERR_SUCCESS) {
+//             printf("Failed to publish message: %s\n", mosquitto_strerror(ret));
+//         }
+// 		printf("msg:%s\n",jsonMessage);
+//         // 控制消息发布频率,以避免太快或太频繁
+//         usleep(1000000);  // 暂停1秒
+//         ret = mosquitto_loop(mosq, 0, 1);  // 处理网络消息
+//         if (ret != MOSQ_ERR_SUCCESS) {
+//             printf("Failed to handle network events: %s\n", mosquitto_strerror(ret));
+//             break;
+//         }
+// 			}
+//     }
+
+//    // free(binaryValue);
+//     free(jsonMessage);
+//     cJSON_Delete(root);
+
+//     // 清理Mosquitto实例和Mosquitto库
+//     mosquitto_destroy(mosq);
+//     mosquitto_lib_cleanup();
+
+   
+// }

+ 6 - 0
widget.h → demo/mqtt/widget.h

@@ -19,7 +19,13 @@ public:
 private slots:
     void do_receiveFromMqtt(const QMQTT::Message& msg);
 
+    void on_pBtn_connectMQTT_clicked();
+
+    void on_pBtn_publishMSG_clicked();
+
 private:
     Ui::Widget *ui;
+
+    QMQTT::Client* m_client = nullptr;
 };
 #endif // WIDGET_H

+ 51 - 0
demo/mqtt/widget.ui

@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Widget</class>
+ <widget class="QWidget" name="Widget">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>800</width>
+    <height>600</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Widget</string>
+  </property>
+  <widget class="QWidget" name="widget_pBtn" native="true">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>30</y>
+     <width>601</width>
+     <height>191</height>
+    </rect>
+   </property>
+   <layout class="QGridLayout" name="gridLayout">
+    <item row="1" column="1">
+     <widget class="QPushButton" name="pBtn_publishMSG">
+      <property name="text">
+       <string>发送消息</string>
+      </property>
+     </widget>
+    </item>
+    <item row="1" column="0">
+     <widget class="QPushButton" name="pBtn_connectMQTT">
+      <property name="text">
+       <string>连接MQTT</string>
+      </property>
+     </widget>
+    </item>
+    <item row="0" column="0">
+     <widget class="QLineEdit" name="lineEdit_IP"/>
+    </item>
+    <item row="0" column="1">
+     <widget class="QLineEdit" name="lineEdit_subscribe"/>
+    </item>
+   </layout>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 0 - 55
widget.cpp

@@ -1,55 +0,0 @@
-#include "widget.h"
-#include "./ui_widget.h"
-
-#include <QNetworkReply>
-#include <QNetworkAccessManager>
-#include <QNetworkRequest>
-
-#include "spdlog/spdlog.h"
-
-
-Widget::Widget(QWidget *parent)
-    : QWidget(parent)
-    , ui(new Ui::Widget)
-{
-    ui->setupUi(this);
-
-
-    SPDLOG_INFO("***** Qt Https *****");
-
-    QNetworkRequest request;
-    request.setUrl(QUrl("http://www.baidu.com"));
-
-    QNetworkAccessManager manager;
-    auto reply = manager.get(request);
-    if(reply->error() != QNetworkReply::NoError)
-    {
-        SPDLOG_ERROR("Error: {}", reply->errorString().toStdString());
-    }
-    else
-    {
-        SPDLOG_INFO("Http get Success");
-    }
-
-
-    auto client = new QMQTT::Client;
-    client->setHostName("192.168.50.100");
-    client->setPort(1883);
-    connect(client,&QMQTT::Client::received,this,&Widget::do_receiveFromMqtt);
-    connect(client,&QMQTT::Client::connected,this,[&](){
-        SPDLOG_INFO("Connected to MQTT broker");
-        client->subscribe("test/one",1);
-    });
-    client->connected();
-}
-
-Widget::~Widget()
-{
-    delete ui;
-}
-
-void Widget::do_receiveFromMqtt(const QMQTT::Message& msg)
-{
-    SPDLOG_INFO("Received: {}", msg.payload().toStdString());
-}
-

+ 0 - 19
widget.ui

@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>Widget</class>
- <widget class="QWidget" name="Widget">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>800</width>
-    <height>600</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>Widget</string>
-  </property>
- </widget>
- <resources/>
- <connections/>
-</ui>