diff --git a/QQt.pro b/QQt.pro index e69ce371..7cc1791c 100644 --- a/QQt.pro +++ b/QQt.pro @@ -43,9 +43,12 @@ SUBDIRS += examples/qqtaudioexample #SUBDIRS += examples/tabwidgetexamples #need QZXing, default closed. #SUBDIRS += examples/qrcodeexample -#必开 +#必开 客户端的 basic SUBDIRS += examples/qqtnetworkexample SUBDIRS += demo/QQtNetworkCreator +#服务器的 highgrade +SUBDIRS += examples/qqtserverexample +SUBDIRS += demo/QQtServerCreator #greaterThan(QT_VERSION, 4.6.0):SUBDIRS += test/voicetest #mac:lessThan(QT_MAJOR_VERSION , 5):SUBDIRS -= test/voicetest diff --git a/README.md b/README.md index 09a896da..eb02eb4b 100644 --- a/README.md +++ b/README.md @@ -23,12 +23,12 @@ LibQQt现进行正式发布版本v2.1.6.0,欢迎工程师们使用。 # 详细介绍 1. 支持绘制图表 - - QQtChart (compatiable with QChart and QCustomPlot) + - [QQtChart](src/charts/qqtchartview.h) (compatiable with QChart and QCustomPlot) 2. 支持检测USB设备热插拔 3. 自定义了一部分特殊需要的控件,用来解决Qt的嵌入式bug。 - 包括完全使用图片的checkbox(switchbutton) - QQtTabWidget,解决QtTab不能竖排横显文字的问题 - - QQt进度条,解决Qt进度条在Dialog中导致系统死机的问题 + - QQt进度条,解决Qt进度条在Dialog中导致系统死机的问题(e-linux) 1. 添加精美控件 - 包括复杂的圆盘进度条, SpeedMeter - 包括有多种效果的Widget、Dialog @@ -36,7 +36,7 @@ LibQQt现进行正式发布版本v2.1.6.0,欢迎工程师们使用。 - 九宫格技术展示图片 - Html解析器 - 以及未列出的等20余种自定义widget。 -4. 有线和无线网络自动连接管理类 +4. 有线和无线网络自动连接管理器 6. 解决Qt4.8.7在嵌入式屏幕上QGraphics系统不正常绘画的问题 7. QQt输入法 - 重写了UI,适配多种屏幕 @@ -47,36 +47,37 @@ LibQQt现进行正式发布版本v2.1.6.0,欢迎工程师们使用。 4. QQtTreeView,添加Qt4内部没有TreeView - 包括QQtXmlTreeModel、QQtJsonTreeModel、QQtFileSystemTreeModel、QQtSqlTreeModel 5. 支持工程的版本变更 - - 在qqt_version.pri里面是QQt的版本和源文件内版本宏定义 - - 在app_version.pri里面是App的版本和源文件内版本宏定义 + - 在[qqt_version.pri](src/qqt_version.pri)里面是QQt的版本和源文件内版本宏定义 + - 在[app_version.pri](app/app_version.pri)里面是App的版本和源文件内版本宏定义 6. QQt通讯套件。 - 通讯口类 - QQtSerialPort 兼容QSerialPort and QextSerialPort - - [QQtSocketTcpClient](src/network/qqtsockettcpclient.h)、QQtSocketTcpServer、QQtSocketUdpClient + - [QQtTcpClient](src/network/qqttcpclient.h)、QQtTcpServer、QQtUdpClient - QQtBluetoothSocket +QQtBluetoothManager - QQtWebAccessManager,支持http、ftp等主流协议,高并发传输。 - - QQtWebSocket接口 + - [QQtWebSocket](src/network/qqtwebsocketclient.h) 接口 - 协议虚类(接口类) [QQtProtocol](src/network/qqtprotocol.h) QQtWebSocketProtocol - - 报文虚类(接口类) [QQtMessage](src/network/qqtmessage.h) + - 报文虚类(接口类) [QQtMessage](src/network/qqtmessage.h) 7. 添加应用中常用的form -8. 支持多页TableWidget +8. 支持多页表格 [QQtMPTableWidget](src/widgets/qqtmptablewidget.h) 9. 添加 [QQtApplication](src/frame/qqtapplication.h),支持入门级、通用级、专用级嵌入式App所必须的初始化内容 5. 支持Qt5.9.2 0. 跨平台支持macOS、iOS、Android、Windows、Linux、MIPS、ARM等。 1. 添加矢量图形widgets - 比如 QQtSvgProgressbar - QQtSvgCheckBox + - [QQtSvgPushButton](src/exquisite/svgwidgets/qqtsvgpushbutton.h) 2. 添加核心类之[QQtDictionary](src/core/qqtdictionary.h) - 化解C Plus Plus中没有字典类别的尴尬。 3. 添加Multi Link工程管理pri组 - - Multi Link technology,既多链接工程管理技术。 + - [Multi Link technology](src/app_multi_link_technology.pri),既多链接工程管理技术。 - 基于qmake,用户可以轻易的链接LibQQt和添加自定义library。 4. 添加gif support Widgets - 可以方便的设置动态按钮等。 - - 有QQtGifWidget、QQtGifButton等。 + - 有[QQtGifWidget](src/exquisite/gifwidgets/qqtgifwidget.h)、QQtGifButton等。 5. 升级多媒体音频 - 添加内存服务器,处理内存和设备之间的数据交互。 - - QQtAudioManager、 + - [QQtAudioManager](src/multimedia/qqtaudiomanager.h)、 - QQtWavAudioInput、QQtWavAudioOutput、QQtWavAudioManager、 - QQtWavSoundEffect - 将AudioDevice、wav输入输出文件,当做一个设备进行读写,App处理获取到的声音。 diff --git a/app/app_version.pri b/app/app_version.pri index 9f5aa634..78c0903c 100644 --- a/app/app_version.pri +++ b/app/app_version.pri @@ -9,5 +9,6 @@ APP_BUILD_VERSION = 0 APP_VERSION = $${APP_MAJOR_VERSION}.$${APP_MINOR_VERSION}.$${APP_PATCH_VERSION} APP_VERSION4 = $${APP_MAJOR_VERSION}.$${APP_MINOR_VERSION}.$${APP_PATCH_VERSION}.$${APP_BUILD_VERSION} +DEFINES += APP_VERSION=$${APP_VERSION} message (Build $${TARGET} version: $$APP_VERSION4) unix:VERSION = $${APP_VERSION} diff --git a/content.md b/content.md index 022d146c..1fa7523d 100644 --- a/content.md +++ b/content.md @@ -30,7 +30,7 @@ 6. QQt通讯套件。 - 通讯口类 - QQtSerialPort 兼容QSerialPort and QextSerialPort - - [QQtSocketTcpClient](src/network/qqtsockettcpclient.h)、QQtSocketTcpServer、QQtSocketUdpClient + - [QQtTcpClient](src/network/qqttcpclient.h)、QQtTcpServer、QQtUdpClient - QQtBluetoothSocket +QQtBluetoothManager - QQtWebAccessManager,支持http、ftp等主流协议,高并发传输。 - QQtWebSocket接口 diff --git a/demo/QQtNetworkCreator/AppRoot/templete/qqtuserprotocol.cpp b/demo/QQtNetworkCreator/AppRoot/templete/qqtuserprotocol.cpp index 0b4cb5b2..dbfea005 100644 --- a/demo/QQtNetworkCreator/AppRoot/templete/qqtuserprotocol.cpp +++ b/demo/QQtNetworkCreator/AppRoot/templete/qqtuserprotocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const QQtUserMessage& msg ) QQtUserProtocol* QQtUserConnectionInstance ( QObject* parent ) { static QQtUserProtocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new QQtUserProtocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/demo/QQtNetworkCreator/AppRoot/templete/qqtuserprotocol.h b/demo/QQtNetworkCreator/AppRoot/templete/qqtuserprotocol.h index 5b5dca78..362b8ec5 100644 --- a/demo/QQtNetworkCreator/AppRoot/templete/qqtuserprotocol.h +++ b/demo/QQtNetworkCreator/AppRoot/templete/qqtuserprotocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class QQtUserMessage : public QQtMessage { diff --git a/demo/QQtNetworkCreator/main.cpp b/demo/QQtNetworkCreator/main.cpp index aab39bb8..219ca126 100644 --- a/demo/QQtNetworkCreator/main.cpp +++ b/demo/QQtNetworkCreator/main.cpp @@ -1,9 +1,9 @@ #include "mainwindow.h" -#include +#include -int main(int argc, char *argv[]) +int main ( int argc, char* argv[] ) { - QApplication a(argc, argv); + QQtApplication a ( argc, argv ); MainWindow w; w.show(); diff --git a/demo/QQtServerCreator/QQtServerCreator.pro b/demo/QQtServerCreator/QQtServerCreator.pro new file mode 100644 index 00000000..e06692c3 --- /dev/null +++ b/demo/QQtServerCreator/QQtServerCreator.pro @@ -0,0 +1,34 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2018-04-22T12:55:57 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = QQtServerCreator +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + + +SOURCES += \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + mainwindow.h + +FORMS += \ + mainwindow.ui diff --git a/demo/QQtServerCreator/main.cpp b/demo/QQtServerCreator/main.cpp new file mode 100644 index 00000000..aab39bb8 --- /dev/null +++ b/demo/QQtServerCreator/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/demo/QQtServerCreator/mainwindow.cpp b/demo/QQtServerCreator/mainwindow.cpp new file mode 100644 index 00000000..12d07c01 --- /dev/null +++ b/demo/QQtServerCreator/mainwindow.cpp @@ -0,0 +1,14 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/demo/QQtServerCreator/mainwindow.h b/demo/QQtServerCreator/mainwindow.h new file mode 100644 index 00000000..29bb970d --- /dev/null +++ b/demo/QQtServerCreator/mainwindow.h @@ -0,0 +1,22 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/demo/QQtServerCreator/mainwindow.ui b/demo/QQtServerCreator/mainwindow.ui new file mode 100644 index 00000000..7de574d7 --- /dev/null +++ b/demo/QQtServerCreator/mainwindow.ui @@ -0,0 +1,24 @@ + + MainWindow + + + + 0 + 0 + 400 + 300 + + + + MainWindow + + + + + + + + + + + diff --git a/examples/animationframe/qqtapp.cpp b/examples/animationframe/qqtapp.cpp index 60dbf08c..551d19c1 100644 --- a/examples/animationframe/qqtapp.cpp +++ b/examples/animationframe/qqtapp.cpp @@ -5,8 +5,8 @@ #include "qqtinput.h" #include "qqtmsgbox.h" #include "qqtframe.h" -#include "qqtsockettcpclient.h" -#include "qqtsockettcpserver.h" +#include "qqttcpclient.h" +#include "qqttcpserver.h" #include "qqtserialport.h" #include "qqtpluginwatcher.h" #include "qqtversion.h" @@ -16,7 +16,7 @@ */ void QQTLanServer ( QObject* parent = 0 ) { - static QQtSocketTcpServer* s = new QQtSocketTcpServer ( parent ); + static QQtTcpServer* s = new QQtTcpServer ( parent ); s->listen ( QHostAddress::Any, 8000 ); s->installedProtocol(); @@ -108,13 +108,13 @@ QQTApp::QQTApp ( int& argc, char** argv ) : QApplication ( argc, argv ) QObject::connect ( QQtPluginWatcher::Instance(), SIGNAL ( storageChanged ( int ) ), this, SLOT ( slotUPanAutoRun ( int ) ) ); #endif - //QQtSocketTcpClient + //QQtTcpClient //QQTCloudClientInstance(this); #ifdef __EMBEDDED_LINUX__ //QQTEthManager QQtEthenetManager::Instance ( this ); #endif - //QQtSocketTcpServer + //QQtTcpServer //QQTPeerPort //QQTPeerPortInstance(this); diff --git a/examples/qqtframe/qqtapp.cpp b/examples/qqtframe/qqtapp.cpp index 66876f88..ebdd3e5f 100644 --- a/examples/qqtframe/qqtapp.cpp +++ b/examples/qqtframe/qqtapp.cpp @@ -6,8 +6,8 @@ #include "qqtinput.h" #include "qqtmsgbox.h" #include "qqtframe.h" -#include "qqtsockettcpclient.h" -#include "qqtsockettcpserver.h" +#include "qqttcpclient.h" +#include "qqttcpserver.h" #include "qqtserialport.h" #include "qqtpluginwatcher.h" @@ -16,7 +16,7 @@ */ void QQTLanServer ( QObject* parent = 0 ) { - static QQtSocketTcpServer* s = new QQtSocketTcpServer ( parent ); + static QQtTcpServer* s = new QQtTcpServer ( parent ); s->listen ( QHostAddress::Any, 8000 ); s->installedProtocol(); @@ -108,13 +108,13 @@ QQTApp::QQTApp ( int& argc, char** argv ) : QApplication ( argc, argv ) QObject::connect ( QQtPluginWatcher::Instance(), SIGNAL ( storageChanged ( int ) ), this, SLOT ( slotUPanAutoRun ( int ) ) ); #endif - //QQtSocketTcpClient + //QQtTcpClient //QQTCloudClientInstance(this); #ifdef __EMBEDDED_LINUX__ //QQTEthManager QQtEthenetManager::Instance ( this ); #endif - //QQtSocketTcpServer + //QQtTcpServer //QQTPeerPort //QQTPeerPortInstance(this); diff --git a/examples/qqtnetworkexample/qqtcloudprotocol.cpp b/examples/qqtnetworkexample/qqtcloudprotocol.cpp index 3c64573a..29719aef 100644 --- a/examples/qqtnetworkexample/qqtcloudprotocol.cpp +++ b/examples/qqtnetworkexample/qqtcloudprotocol.cpp @@ -3,16 +3,16 @@ #include "qqtcore.h" #include "qqt-qt.h" -QQtSocketTcpClient* QQTUpgradeClientInstance ( QObject* parent ) +QQtTcpClient* QQTUpgradeClientInstance ( QObject* parent ) { - static QQtSocketTcpClient* cli = NULL; + static QQtTcpClient* cli = NULL; if ( !cli ) { QStringList ip; ip << "222.175.114.244" << "124.133.1.54"; //"www.QQToo.com" - cli = new QQtSocketTcpClient ( parent ); + cli = new QQtTcpClient ( parent ); cli->SetServerIPAddress ( ip ); cli->SetServerPort ( 8089 ); } @@ -20,15 +20,15 @@ QQtSocketTcpClient* QQTUpgradeClientInstance ( QObject* parent ) return cli; } -QQtSocketTcpClient* QQTCloudClientInstance ( QObject* parent ) +QQtTcpClient* QQTCloudClientInstance ( QObject* parent ) { - static QQtSocketTcpClient* cli = NULL; + static QQtTcpClient* cli = NULL; if ( !cli ) { QStringList ip; ip << "222.175.114.244" << "124.133.1.54"; - cli = new QQtSocketTcpClient ( parent ); + cli = new QQtTcpClient ( parent ); cli->SetServerIPAddress ( ip ); cli->SetServerPort ( 7079 ); } diff --git a/examples/qqtnetworkexample/qqtcloudprotocol.h b/examples/qqtnetworkexample/qqtcloudprotocol.h index 0e20f3c7..25e6e55b 100644 --- a/examples/qqtnetworkexample/qqtcloudprotocol.h +++ b/examples/qqtnetworkexample/qqtcloudprotocol.h @@ -4,7 +4,7 @@ #include #include "qqtprotocol.h" #include "qqtnetworkmessage.h" -#include "qqtsockettcpclient.h" +#include "qqttcpclient.h" #define _TCPCMD_HEART 0x0010 #define _TCPCMD_HEARTBEATRESP 0x8010 @@ -424,10 +424,10 @@ public: }; -QQtSocketTcpClient *QQTUpgradeClientInstance(QObject *parent); +QQtTcpClient *QQTUpgradeClientInstance(QObject *parent); -QQtSocketTcpClient *QQTCloudClientInstance(QObject *parent); +QQtTcpClient *QQTCloudClientInstance(QObject *parent); #endif // QQTCLOUDPROTOCOL_H diff --git a/examples/qqtnetworkexample/qqtlanprotocol.cpp b/examples/qqtnetworkexample/qqtlanprotocol.cpp index 041591a3..4609ff85 100644 --- a/examples/qqtnetworkexample/qqtlanprotocol.cpp +++ b/examples/qqtnetworkexample/qqtlanprotocol.cpp @@ -28,9 +28,9 @@ bool QQTLanProtocol::dispatcher ( const QByteArray& m ) } -QQtSocketTcpServer* QQTSingleServer ( QObject* parent ) +QQtTcpServer* QQTSingleServer ( QObject* parent ) { - static QQtSocketTcpServer* s = new QQtSocketTcpServer ( parent ); + static QQtTcpServer* s = new QQtTcpServer ( parent ); s->listen ( QHostAddress::Any, 8000 ); return s; } @@ -38,12 +38,12 @@ QQtSocketTcpServer* QQTSingleServer ( QObject* parent ) QQTLanProtocol* QQtLanServer ( QObject* parent ) { static QQTLanProtocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new QQTLanProtocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->listen ( QHostAddress::Any, 8000 ); s0->installProtocol ( p0 ); diff --git a/examples/qqtnetworkexample/qqtlanprotocol.h b/examples/qqtnetworkexample/qqtlanprotocol.h index f2fbab09..ef3949bb 100644 --- a/examples/qqtnetworkexample/qqtlanprotocol.h +++ b/examples/qqtnetworkexample/qqtlanprotocol.h @@ -3,7 +3,7 @@ #include "qqtprotocol.h" #include "qqtmessage.h" -#include "qqtsockettcpserver.h" +#include "qqttcpserver.h" class QQtLanMessage : public QQtMessage { @@ -58,7 +58,7 @@ public: bool dispatcher ( const QByteArray& m ) override; }; -QQtSocketTcpServer* QQTSingleServer ( QObject* parent ); +QQtTcpServer* QQTSingleServer ( QObject* parent ); //new QQTLanProtocol* QQtLanServer ( QObject* parent = 0 ); #endif // QQTLANPROTOCOL_H diff --git a/examples/qqtnetworkexample/qqtuserprotocol1.cpp b/examples/qqtnetworkexample/qqtuserprotocol1.cpp index 924d9006..a0fc5146 100644 --- a/examples/qqtnetworkexample/qqtuserprotocol1.cpp +++ b/examples/qqtnetworkexample/qqtuserprotocol1.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const QQtUserMessage1& msg ) QQtUserProtocol1* QQtUserConnectionInstance1 ( QObject* parent ) { static QQtUserProtocol1* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new QQtUserProtocol1 ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/qqtuserprotocol1.h b/examples/qqtnetworkexample/qqtuserprotocol1.h index 48a0cdac..24eed5bf 100644 --- a/examples/qqtnetworkexample/qqtuserprotocol1.h +++ b/examples/qqtnetworkexample/qqtuserprotocol1.h @@ -3,7 +3,7 @@ #include #include -#include +#include class QQtUserMessage1 : public QQtMessage { diff --git a/examples/qqtnetworkexample/qqtuserprotocol2.cpp b/examples/qqtnetworkexample/qqtuserprotocol2.cpp index 8696fffc..f7fdfd33 100644 --- a/examples/qqtnetworkexample/qqtuserprotocol2.cpp +++ b/examples/qqtnetworkexample/qqtuserprotocol2.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const QQtUserMessage2& msg ) QQtUserProtocol2* QQtUserConnectionInstance2 ( QObject* parent ) { static QQtUserProtocol2* p0 = NULL; - static QQtSocketTcpClient* s0 = NULL; + static QQtTcpClient* s0 = NULL; if ( !p0 && !s0 ) { p0 = new QQtUserProtocol2 ( parent ); - s0 = new QQtSocketTcpClient ( parent ); + s0 = new QQtTcpClient ( parent ); s0->installProtocol ( p0 ); s0->connectToHost ( QHostAddress ( "192.168.0.100" ), 8000 ); } diff --git a/examples/qqtnetworkexample/qqtuserprotocol2.h b/examples/qqtnetworkexample/qqtuserprotocol2.h index 47c398de..8e3984f5 100644 --- a/examples/qqtnetworkexample/qqtuserprotocol2.h +++ b/examples/qqtnetworkexample/qqtuserprotocol2.h @@ -3,7 +3,7 @@ #include #include -#include +#include #include diff --git a/examples/qqtnetworkexample/quserbluetoothprotocol.cpp b/examples/qqtnetworkexample/quserbluetoothprotocol.cpp index 98308224..140faaae 100644 --- a/examples/qqtnetworkexample/quserbluetoothprotocol.cpp +++ b/examples/qqtnetworkexample/quserbluetoothprotocol.cpp @@ -1,5 +1,5 @@ #include "quserbluetoothprotocol.h" -#include "qqtsocketbluetoothclient.h" +#include "qqtbluetoothclient.h" #include "qqtbluetoothmanager.h" QUserBluetoothProtocol::QUserBluetoothProtocol ( QObject* parent ) : QObject ( parent ) @@ -7,15 +7,15 @@ QUserBluetoothProtocol::QUserBluetoothProtocol ( QObject* parent ) : QObject ( p } -QQtSocketBluetoothClient* QQtUserBluetoothClientInstance ( QObject* parent ) +QQtBluetoothClient* QQtUserBluetoothClientInstance ( QObject* parent ) { - static QQtSocketBluetoothClient* cli = nullptr; + static QQtBluetoothClient* cli = nullptr; if ( !cli ) { QQtBluetoothManager* inst = QQtBluetoothManager::Instance ( parent ); inst->getDeviceList().first().address(); - cli = new QQtSocketBluetoothClient ( QBluetoothServiceInfo::RfcommProtocol, parent ); + cli = new QQtBluetoothClient ( QBluetoothServiceInfo::RfcommProtocol, parent ); cli->setServiceAddress ( inst->getDeviceList().first().address() ); } diff --git a/examples/qqtnetworkexample/quserbluetoothprotocol.h b/examples/qqtnetworkexample/quserbluetoothprotocol.h index 7ab759c0..a9e57da0 100644 --- a/examples/qqtnetworkexample/quserbluetoothprotocol.h +++ b/examples/qqtnetworkexample/quserbluetoothprotocol.h @@ -2,7 +2,7 @@ #define QUSERBLUETOOTHPROTOCOL_H #include -#include "qqtsocketbluetoothclient.h" +#include "qqtbluetoothclient.h" class QUserBluetoothProtocol : public QObject { @@ -15,6 +15,6 @@ signals: public slots: }; -QQtSocketBluetoothClient* QQtUserBluetoothClientInstance ( QObject* parent = 0 ); +QQtBluetoothClient* QQtUserBluetoothClientInstance ( QObject* parent = 0 ); #endif // QUSERBLUETOOTHPROTOCOL_H diff --git a/examples/qqtnetworkexample/usernode0protocol.cpp b/examples/qqtnetworkexample/usernode0protocol.cpp index fa0a52f5..6ee1cc6d 100644 --- a/examples/qqtnetworkexample/usernode0protocol.cpp +++ b/examples/qqtnetworkexample/usernode0protocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserNode0Message& msg ) UserNode0Protocol* UserNode0ConnectionInstance ( QObject* parent ) { static UserNode0Protocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new UserNode0Protocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/usernode0protocol.h b/examples/qqtnetworkexample/usernode0protocol.h index ada51023..1b50a356 100644 --- a/examples/qqtnetworkexample/usernode0protocol.h +++ b/examples/qqtnetworkexample/usernode0protocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class UserNode0Message : public QQtMessage { diff --git a/examples/qqtnetworkexample/usernode1protocol.cpp b/examples/qqtnetworkexample/usernode1protocol.cpp index 1254f594..f61b9aad 100644 --- a/examples/qqtnetworkexample/usernode1protocol.cpp +++ b/examples/qqtnetworkexample/usernode1protocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserNode1Message& msg ) UserNode1Protocol* UserNode1ConnectionInstance ( QObject* parent ) { static UserNode1Protocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new UserNode1Protocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/usernode1protocol.h b/examples/qqtnetworkexample/usernode1protocol.h index 6ef13f87..fa8f07da 100644 --- a/examples/qqtnetworkexample/usernode1protocol.h +++ b/examples/qqtnetworkexample/usernode1protocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class UserNode1Message : public QQtMessage { diff --git a/examples/qqtnetworkexample/usernode2protocol.cpp b/examples/qqtnetworkexample/usernode2protocol.cpp index 3ff4516e..af203e31 100644 --- a/examples/qqtnetworkexample/usernode2protocol.cpp +++ b/examples/qqtnetworkexample/usernode2protocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserNode2Message& msg ) UserNode2Protocol* UserNode2ConnectionInstance ( QObject* parent ) { static UserNode2Protocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new UserNode2Protocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/usernode2protocol.h b/examples/qqtnetworkexample/usernode2protocol.h index 455b86e1..23228eb5 100644 --- a/examples/qqtnetworkexample/usernode2protocol.h +++ b/examples/qqtnetworkexample/usernode2protocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class UserNode2Message : public QQtMessage { diff --git a/examples/qqtnetworkexample/usernode3protocol.cpp b/examples/qqtnetworkexample/usernode3protocol.cpp index e63afc7b..b095d867 100644 --- a/examples/qqtnetworkexample/usernode3protocol.cpp +++ b/examples/qqtnetworkexample/usernode3protocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserNode3Message& msg ) UserNode3Protocol* UserNode3ConnectionInstance ( QObject* parent ) { static UserNode3Protocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new UserNode3Protocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/usernode3protocol.h b/examples/qqtnetworkexample/usernode3protocol.h index 29b1e4d8..9a2af8c8 100644 --- a/examples/qqtnetworkexample/usernode3protocol.h +++ b/examples/qqtnetworkexample/usernode3protocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class UserNode3Message : public QQtMessage { diff --git a/examples/qqtnetworkexample/usernode4protocol.cpp b/examples/qqtnetworkexample/usernode4protocol.cpp index eac16727..c0aba431 100644 --- a/examples/qqtnetworkexample/usernode4protocol.cpp +++ b/examples/qqtnetworkexample/usernode4protocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserNode4Message& msg ) UserNode4Protocol* UserNode4ConnectionInstance ( QObject* parent ) { static UserNode4Protocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new UserNode4Protocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/usernode4protocol.h b/examples/qqtnetworkexample/usernode4protocol.h index e6ab881b..9881bca6 100644 --- a/examples/qqtnetworkexample/usernode4protocol.h +++ b/examples/qqtnetworkexample/usernode4protocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class UserNode4Message : public QQtMessage { diff --git a/examples/qqtnetworkexample/usernode5protocol.cpp b/examples/qqtnetworkexample/usernode5protocol.cpp index 7212c3eb..82f2a285 100644 --- a/examples/qqtnetworkexample/usernode5protocol.cpp +++ b/examples/qqtnetworkexample/usernode5protocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserNode5Message& msg ) UserNode5Protocol* UserNode5ConnectionInstance ( QObject* parent ) { static UserNode5Protocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new UserNode5Protocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/usernode5protocol.h b/examples/qqtnetworkexample/usernode5protocol.h index 003738cf..29739b96 100644 --- a/examples/qqtnetworkexample/usernode5protocol.h +++ b/examples/qqtnetworkexample/usernode5protocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class UserNode5Message : public QQtMessage { diff --git a/examples/qqtnetworkexample/usernode6protocol.cpp b/examples/qqtnetworkexample/usernode6protocol.cpp index ae5fedc8..5a6fd63a 100644 --- a/examples/qqtnetworkexample/usernode6protocol.cpp +++ b/examples/qqtnetworkexample/usernode6protocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserNode6Message& msg ) UserNode6Protocol* UserNode6ConnectionInstance ( QObject* parent ) { static UserNode6Protocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new UserNode6Protocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/usernode6protocol.h b/examples/qqtnetworkexample/usernode6protocol.h index 5c0ab3ca..dcd4edc5 100644 --- a/examples/qqtnetworkexample/usernode6protocol.h +++ b/examples/qqtnetworkexample/usernode6protocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class UserNode6Message : public QQtMessage { diff --git a/examples/qqtnetworkexample/usernode7protocol.cpp b/examples/qqtnetworkexample/usernode7protocol.cpp index c6206b29..e66e57d1 100644 --- a/examples/qqtnetworkexample/usernode7protocol.cpp +++ b/examples/qqtnetworkexample/usernode7protocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserNode7Message& msg ) UserNode7Protocol* UserNode7ConnectionInstance ( QObject* parent ) { static UserNode7Protocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new UserNode7Protocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/usernode7protocol.h b/examples/qqtnetworkexample/usernode7protocol.h index 95cc0f0c..9205a356 100644 --- a/examples/qqtnetworkexample/usernode7protocol.h +++ b/examples/qqtnetworkexample/usernode7protocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class UserNode7Message : public QQtMessage { diff --git a/examples/qqtnetworkexample/usernode8protocol.cpp b/examples/qqtnetworkexample/usernode8protocol.cpp index d3304ddd..eca598a6 100644 --- a/examples/qqtnetworkexample/usernode8protocol.cpp +++ b/examples/qqtnetworkexample/usernode8protocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserNode8Message& msg ) UserNode8Protocol* UserNode8ConnectionInstance ( QObject* parent ) { static UserNode8Protocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new UserNode8Protocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/usernode8protocol.h b/examples/qqtnetworkexample/usernode8protocol.h index 7d2bd704..3f167b31 100644 --- a/examples/qqtnetworkexample/usernode8protocol.h +++ b/examples/qqtnetworkexample/usernode8protocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class UserNode8Message : public QQtMessage { diff --git a/examples/qqtnetworkexample/usernode9protocol.cpp b/examples/qqtnetworkexample/usernode9protocol.cpp index 0393c849..33a2b6b9 100644 --- a/examples/qqtnetworkexample/usernode9protocol.cpp +++ b/examples/qqtnetworkexample/usernode9protocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserNode9Message& msg ) UserNode9Protocol* UserNode9ConnectionInstance ( QObject* parent ) { static UserNode9Protocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new UserNode9Protocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/usernode9protocol.h b/examples/qqtnetworkexample/usernode9protocol.h index 2fe0a23e..953e19e2 100644 --- a/examples/qqtnetworkexample/usernode9protocol.h +++ b/examples/qqtnetworkexample/usernode9protocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class UserNode9Message : public QQtMessage { diff --git a/examples/qqtnetworkexample/usertest0protocol.cpp b/examples/qqtnetworkexample/usertest0protocol.cpp index 19c4b9cd..b95f0120 100644 --- a/examples/qqtnetworkexample/usertest0protocol.cpp +++ b/examples/qqtnetworkexample/usertest0protocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserTest0Message& msg ) UserTest0Protocol* UserTest0ConnectionInstance ( QObject* parent ) { static UserTest0Protocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new UserTest0Protocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/usertest0protocol.h b/examples/qqtnetworkexample/usertest0protocol.h index a6cb5402..d4623fe5 100644 --- a/examples/qqtnetworkexample/usertest0protocol.h +++ b/examples/qqtnetworkexample/usertest0protocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class UserTest0Message : public QQtMessage { diff --git a/examples/qqtnetworkexample/usertest1protocol.cpp b/examples/qqtnetworkexample/usertest1protocol.cpp index 64aa264e..ed3cb847 100644 --- a/examples/qqtnetworkexample/usertest1protocol.cpp +++ b/examples/qqtnetworkexample/usertest1protocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserTest1Message& msg ) UserTest1Protocol* UserTest1ConnectionInstance ( QObject* parent ) { static UserTest1Protocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new UserTest1Protocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/usertest1protocol.h b/examples/qqtnetworkexample/usertest1protocol.h index aed36593..056d7f9c 100644 --- a/examples/qqtnetworkexample/usertest1protocol.h +++ b/examples/qqtnetworkexample/usertest1protocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class UserTest1Message : public QQtMessage { diff --git a/examples/qqtnetworkexample/usertest2protocol.cpp b/examples/qqtnetworkexample/usertest2protocol.cpp index 172505e2..693a7205 100644 --- a/examples/qqtnetworkexample/usertest2protocol.cpp +++ b/examples/qqtnetworkexample/usertest2protocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserTest2Message& msg ) UserTest2Protocol* UserTest2ConnectionInstance ( QObject* parent ) { static UserTest2Protocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new UserTest2Protocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/usertest2protocol.h b/examples/qqtnetworkexample/usertest2protocol.h index 31ae29f6..73c25c4d 100644 --- a/examples/qqtnetworkexample/usertest2protocol.h +++ b/examples/qqtnetworkexample/usertest2protocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class UserTest2Message : public QQtMessage { diff --git a/examples/qqtnetworkexample/usertest3protocol.cpp b/examples/qqtnetworkexample/usertest3protocol.cpp index 91040541..8be8082f 100644 --- a/examples/qqtnetworkexample/usertest3protocol.cpp +++ b/examples/qqtnetworkexample/usertest3protocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserTest3Message& msg ) UserTest3Protocol* UserTest3ConnectionInstance ( QObject* parent ) { static UserTest3Protocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new UserTest3Protocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/usertest3protocol.h b/examples/qqtnetworkexample/usertest3protocol.h index df3fcbc0..2663a1c3 100644 --- a/examples/qqtnetworkexample/usertest3protocol.h +++ b/examples/qqtnetworkexample/usertest3protocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class UserTest3Message : public QQtMessage { diff --git a/examples/qqtnetworkexample/usertest4protocol.cpp b/examples/qqtnetworkexample/usertest4protocol.cpp index 8aae42b7..4fc1722c 100644 --- a/examples/qqtnetworkexample/usertest4protocol.cpp +++ b/examples/qqtnetworkexample/usertest4protocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserTest4Message& msg ) UserTest4Protocol* UserTest4ConnectionInstance ( QObject* parent ) { static UserTest4Protocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new UserTest4Protocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/usertest4protocol.h b/examples/qqtnetworkexample/usertest4protocol.h index e5a246d6..4a87aec0 100644 --- a/examples/qqtnetworkexample/usertest4protocol.h +++ b/examples/qqtnetworkexample/usertest4protocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class UserTest4Message : public QQtMessage { diff --git a/examples/qqtnetworkexample/usertest5protocol.cpp b/examples/qqtnetworkexample/usertest5protocol.cpp index 1da6e042..36dc6648 100644 --- a/examples/qqtnetworkexample/usertest5protocol.cpp +++ b/examples/qqtnetworkexample/usertest5protocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserTest5Message& msg ) UserTest5Protocol* UserTest5ConnectionInstance ( QObject* parent ) { static UserTest5Protocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new UserTest5Protocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/usertest5protocol.h b/examples/qqtnetworkexample/usertest5protocol.h index 255313bf..a04929be 100644 --- a/examples/qqtnetworkexample/usertest5protocol.h +++ b/examples/qqtnetworkexample/usertest5protocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class UserTest5Message : public QQtMessage { diff --git a/examples/qqtnetworkexample/usertest6protocol.cpp b/examples/qqtnetworkexample/usertest6protocol.cpp index f1851f57..7098c256 100644 --- a/examples/qqtnetworkexample/usertest6protocol.cpp +++ b/examples/qqtnetworkexample/usertest6protocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserTest6Message& msg ) UserTest6Protocol* UserTest6ConnectionInstance ( QObject* parent ) { static UserTest6Protocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new UserTest6Protocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/usertest6protocol.h b/examples/qqtnetworkexample/usertest6protocol.h index f1d909f3..b264107d 100644 --- a/examples/qqtnetworkexample/usertest6protocol.h +++ b/examples/qqtnetworkexample/usertest6protocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class UserTest6Message : public QQtMessage { diff --git a/examples/qqtnetworkexample/usertest7protocol.cpp b/examples/qqtnetworkexample/usertest7protocol.cpp index 5fbfc4b8..efe51d4c 100644 --- a/examples/qqtnetworkexample/usertest7protocol.cpp +++ b/examples/qqtnetworkexample/usertest7protocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserTest7Message& msg ) UserTest7Protocol* UserTest7ConnectionInstance ( QObject* parent ) { static UserTest7Protocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new UserTest7Protocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/usertest7protocol.h b/examples/qqtnetworkexample/usertest7protocol.h index 9b8aa95d..ba68c64e 100644 --- a/examples/qqtnetworkexample/usertest7protocol.h +++ b/examples/qqtnetworkexample/usertest7protocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class UserTest7Message : public QQtMessage { diff --git a/examples/qqtnetworkexample/usertest8protocol.cpp b/examples/qqtnetworkexample/usertest8protocol.cpp index ab4b30bf..ec391511 100644 --- a/examples/qqtnetworkexample/usertest8protocol.cpp +++ b/examples/qqtnetworkexample/usertest8protocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserTest8Message& msg ) UserTest8Protocol* UserTest8ConnectionInstance ( QObject* parent ) { static UserTest8Protocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new UserTest8Protocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/usertest8protocol.h b/examples/qqtnetworkexample/usertest8protocol.h index 33be4d7a..d6f01c9c 100644 --- a/examples/qqtnetworkexample/usertest8protocol.h +++ b/examples/qqtnetworkexample/usertest8protocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class UserTest8Message : public QQtMessage { diff --git a/examples/qqtnetworkexample/usertest9protocol.cpp b/examples/qqtnetworkexample/usertest9protocol.cpp index 5fd80e3f..87479d23 100644 --- a/examples/qqtnetworkexample/usertest9protocol.cpp +++ b/examples/qqtnetworkexample/usertest9protocol.cpp @@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserTest9Message& msg ) UserTest9Protocol* UserTest9ConnectionInstance ( QObject* parent ) { static UserTest9Protocol* p0 = NULL; - static QQtSocketTcpServer* s0 = NULL; + static QQtTcpServer* s0 = NULL; if ( !p0 && !s0 ) { p0 = new UserTest9Protocol ( parent ); - s0 = new QQtSocketTcpServer ( parent ); + s0 = new QQtTcpServer ( parent ); s0->installProtocol ( p0 ); s0->listen ( QHostAddress::Any, 8000 ); diff --git a/examples/qqtnetworkexample/usertest9protocol.h b/examples/qqtnetworkexample/usertest9protocol.h index 40b5b8c1..8ce45484 100644 --- a/examples/qqtnetworkexample/usertest9protocol.h +++ b/examples/qqtnetworkexample/usertest9protocol.h @@ -3,7 +3,7 @@ #include #include -#include +#include class UserTest9Message : public QQtMessage { diff --git a/examples/qqtserverexample/main.cpp b/examples/qqtserverexample/main.cpp new file mode 100644 index 00000000..aab39bb8 --- /dev/null +++ b/examples/qqtserverexample/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/examples/qqtserverexample/mainwindow.cpp b/examples/qqtserverexample/mainwindow.cpp new file mode 100644 index 00000000..12d07c01 --- /dev/null +++ b/examples/qqtserverexample/mainwindow.cpp @@ -0,0 +1,14 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/examples/qqtserverexample/mainwindow.h b/examples/qqtserverexample/mainwindow.h new file mode 100644 index 00000000..29bb970d --- /dev/null +++ b/examples/qqtserverexample/mainwindow.h @@ -0,0 +1,22 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/examples/qqtserverexample/mainwindow.ui b/examples/qqtserverexample/mainwindow.ui new file mode 100644 index 00000000..7de574d7 --- /dev/null +++ b/examples/qqtserverexample/mainwindow.ui @@ -0,0 +1,24 @@ + + MainWindow + + + + 0 + 0 + 400 + 300 + + + + MainWindow + + + + + + + + + + + diff --git a/examples/qqtserverexample/qqtserverexample.pro b/examples/qqtserverexample/qqtserverexample.pro new file mode 100644 index 00000000..d018d504 --- /dev/null +++ b/examples/qqtserverexample/qqtserverexample.pro @@ -0,0 +1,34 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2018-04-22T12:57:27 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = qqtserverexample +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + + +SOURCES += \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + mainwindow.h + +FORMS += \ + mainwindow.ui diff --git a/examples/qqtudpexample/cedianudpserver.cpp b/examples/qqtudpexample/cedianudpserver.cpp index 8b2ba398..2eb316e6 100644 --- a/examples/qqtudpexample/cedianudpserver.cpp +++ b/examples/qqtudpexample/cedianudpserver.cpp @@ -1,6 +1,6 @@ #include "cedianudpserver.h" #include -CedianUdpServer::CedianUdpServer ( QObject* parent ) : QQtSocketUdpClient ( parent ) +CedianUdpServer::CedianUdpServer ( QObject* parent ) : QQtUdpClient ( parent ) { } diff --git a/examples/qqtudpexample/cedianudpserver.h b/examples/qqtudpexample/cedianudpserver.h index 1245faeb..eac56ee5 100644 --- a/examples/qqtudpexample/cedianudpserver.h +++ b/examples/qqtudpexample/cedianudpserver.h @@ -1,10 +1,10 @@ #ifndef CEDIANUDPSERVER_H #define CEDIANUDPSERVER_H -#include +#include #include -class CedianUdpServer : public QQtSocketUdpClient +class CedianUdpServer : public QQtUdpClient { Q_OBJECT public: diff --git a/src/app_base_manager.pri b/src/app_base_manager.pri index 25725fd2..afd2fe8c 100644 --- a/src/app_base_manager.pri +++ b/src/app_base_manager.pri @@ -34,7 +34,7 @@ contains(CONFIG, administrator){ ################################################################ ##Multi-link technology ################################################################ -include($$PWD/app_multi_link_config.pri) +include($$PWD/app_multi_link_technology.pri) ################################################################ ##link QQt diff --git a/src/app_multi_link_config.pri b/src/app_multi_link_technology.pri similarity index 98% rename from src/app_multi_link_config.pri rename to src/app_multi_link_technology.pri index d13242d4..bb5948ad 100644 --- a/src/app_multi_link_config.pri +++ b/src/app_multi_link_technology.pri @@ -1,5 +1,5 @@ #-------------------------------------------------------------------------------- -#app_multi_link_configure.pri +#app_multi_link_technology.pri ##Multi-link technology (Multi Link technology) ##Multi-link 技术,支持多链接库增删的一门工程管理技术。 diff --git a/src/network/qqtsocketbluetoothserver.cpp b/src/highgrade/qqtbluetoothserver.cpp similarity index 51% rename from src/network/qqtsocketbluetoothserver.cpp rename to src/highgrade/qqtbluetoothserver.cpp index b6d079dc..577cef04 100644 --- a/src/network/qqtsocketbluetoothserver.cpp +++ b/src/highgrade/qqtbluetoothserver.cpp @@ -1,33 +1,33 @@ -#include "qqtsocketbluetoothserver.h" +#include "qqtbluetoothserver.h" #include "qqtnetwork.h" -#include "qqtsocketbluetoothclient.h" +#include "qqtbluetoothclient.h" -QQtSocketBluetoothServer::QQtSocketBluetoothServer ( QBluetoothServiceInfo::Protocol serverType, - QObject* parent ) : QBluetoothServer ( serverType, parent ) +QQtBluetoothServer::QQtBluetoothServer ( QBluetoothServiceInfo::Protocol serverType, + QObject* parent ) : QBluetoothServer ( serverType, parent ) { connect ( this, SIGNAL ( newConnection() ), this, SLOT ( comingNewConnection() ) ); } -QQtSocketBluetoothServer::~QQtSocketBluetoothServer() +QQtBluetoothServer::~QQtBluetoothServer() { close(); } -void QQtSocketBluetoothServer::comingNewConnection() +void QQtBluetoothServer::comingNewConnection() { if ( !hasPendingConnections() ) return; QBluetoothSocket* comingSocket = nextPendingConnection(); - QQtSocketBluetoothClient* clientSocket = new QQtSocketBluetoothClient ( this ); + QQtBluetoothClient* clientSocket = new QQtBluetoothClient ( this ); connect ( clientSocket, SIGNAL ( disconnected() ), clientSocket, SLOT ( deleteLater() ) ); clientSocket->installProtocol ( m_protocol ); clientSocket->setSocketDescriptor ( comingSocket->socketDescriptor(), QBluetoothServiceInfo::RfcommProtocol ); } -void QQtSocketBluetoothServer::installProtocol ( QQtProtocol* stack ) +void QQtBluetoothServer::installProtocol ( QQtProtocol* stack ) { if ( m_protocol ) return; @@ -35,7 +35,7 @@ void QQtSocketBluetoothServer::installProtocol ( QQtProtocol* stack ) m_protocol = stack; } -void QQtSocketBluetoothServer::uninstallProtocol ( QQtProtocol* stack ) +void QQtBluetoothServer::uninstallProtocol ( QQtProtocol* stack ) { Q_UNUSED ( stack ) @@ -45,7 +45,7 @@ void QQtSocketBluetoothServer::uninstallProtocol ( QQtProtocol* stack ) m_protocol = NULL; } -QQtProtocol* QQtSocketBluetoothServer::installedProtocol() +QQtProtocol* QQtBluetoothServer::installedProtocol() { return m_protocol; } diff --git a/src/network/qqtsocketbluetoothserver.h b/src/highgrade/qqtbluetoothserver.h similarity index 67% rename from src/network/qqtsocketbluetoothserver.h rename to src/highgrade/qqtbluetoothserver.h index 3f9b4174..b8319b82 100644 --- a/src/network/qqtsocketbluetoothserver.h +++ b/src/highgrade/qqtbluetoothserver.h @@ -5,12 +5,12 @@ #include "qqtprotocol.h" #include -class QQTSHARED_EXPORT QQtSocketBluetoothServer : public QBluetoothServer +class QQTSHARED_EXPORT QQtBluetoothServer : public QBluetoothServer { Q_OBJECT public: - explicit QQtSocketBluetoothServer ( QBluetoothServiceInfo::Protocol serverType, QObject* parent = nullptr ); - ~QQtSocketBluetoothServer(); + explicit QQtBluetoothServer ( QBluetoothServiceInfo::Protocol serverType, QObject* parent = nullptr ); + ~QQtBluetoothServer(); void installProtocol ( QQtProtocol* stack ); void uninstallProtocol ( QQtProtocol* stack ); diff --git a/src/highgrade/qqtprotocolmanager.cpp b/src/highgrade/qqtprotocolmanager.cpp new file mode 100644 index 00000000..32a11590 --- /dev/null +++ b/src/highgrade/qqtprotocolmanager.cpp @@ -0,0 +1,70 @@ +#include "qqtprotocolmanager.h" + +QQtProtocolManager::QQtProtocolManager ( QObject* parent ) : QObject ( parent ) +{ + +} + +QQtProtocolManager::~QQtProtocolManager() +{ + +} + +#define pline2() pline() << metaObject()->className() + +void QQtProtocolManager::translator ( const QByteArray& bytes ) +{ + // queued conn and queued package; + // direct conn and direct package; + + static QByteArray sqbaBlockOnNet; + sqbaBlockOnNet += bytes; + //qint64 aaa = bytesAvailable(); + //pline() << aaa; + + do + { + quint16 nBlockLen = this->splitter ( sqbaBlockOnNet ); + + pline2() << sqbaBlockOnNet.size() << "..." << nBlockLen; + + if ( sqbaBlockOnNet.length() < nBlockLen || nBlockLen < minlength() ) + { + /* + * 收到数据不足或者解析包长小于最小包长 + */ + return; + } + else if ( nBlockLen > maxlength() ) + { + /* + * 数据包长超过了最大长度 + */ + sqbaBlockOnNet.clear(); + pline2() << "forbidden package" << sqbaBlockOnNet.length() << nBlockLen; + return; + } + else if ( sqbaBlockOnNet.length() > nBlockLen ) + { + /* + * 粘包 + * 还没有处理完毕,数据已经接收到,异步信号处理出现这种异常 + * 疑问:如果异步调用这个函数绘出现什么问题?正常情况,同步获取数据,异步处理;检测异步获取并且处理会有什么状况 + */ + pline2() << "stick package" << sqbaBlockOnNet.length() << nBlockLen; + QByteArray netData; + netData.resize ( nBlockLen ); + sqbaBlockOnNet >> netData; + dispatcher ( netData ); + continue; + } + + /* + * 正常分发 + */ + dispatcher ( sqbaBlockOnNet ); + break; + } while ( 1 ); + + sqbaBlockOnNet.clear(); +} diff --git a/src/highgrade/qqtprotocolmanager.h b/src/highgrade/qqtprotocolmanager.h new file mode 100644 index 00000000..40adad99 --- /dev/null +++ b/src/highgrade/qqtprotocolmanager.h @@ -0,0 +1,63 @@ +#ifndef QQTPROTOCOLMANAGER_H +#define QQTPROTOCOLMANAGER_H + +#include +#include +#include "qqtmessage.h" +#include "qqtcore.h" + +/** + * @brief The QQtProtocolManager class + * very good ideology and impliment + */ +class QQTSHARED_EXPORT QQtProtocolManager : public QObject +{ + Q_OBJECT +public: + explicit QQtProtocolManager ( QObject* parent = 0 ); + virtual ~QQtProtocolManager(); + + /* + * 建议:用户在继承类里的函数里直接调用[emit] write(...) + */ +Q_SIGNALS: + qint64 write ( const QByteArray& ); + +public: + /** + * @brief 协议处理器 + * 这个处理器是给QQtTcpSocket用的,不是给客户用的。 + * @param Qt通讯口readAll()读到的bytes + * @return + */ + void translator ( const QByteArray& bytes ); + + /* + * 以下函数,用户必须继承下去,重写,need override + */ +protected: + /** + * @brief 最小包长 + * @return + */ + inline virtual quint16 minlength() { return 0; } + /** + * @brief 最大包长 + * @return + */ + inline virtual quint16 maxlength() { return 0xFFFF; } + /** + * @brief 语法解析器 从流中解析报文长度 + * @param 接收到的数据段 + * @return 按照协议解析到的数据长度 可用,继续接收,丢弃,粘包。 + */ + inline virtual quint16 splitter ( const QByteArray& ) { return 0; } + /** + * @brief 语义解析器 + * @param 数据包 + * @return 0 no dispatched(others) 1 dispatched(own) + */ + inline virtual bool dispatcher ( const QByteArray& ) { return 0; } +}; + +#endif // QQTPROTOCOLMANAGER_H diff --git a/src/highgrade/qqtserverprotocol.cpp b/src/highgrade/qqtserverprotocol.cpp new file mode 100644 index 00000000..51880ec0 --- /dev/null +++ b/src/highgrade/qqtserverprotocol.cpp @@ -0,0 +1,70 @@ +#include "qqtserverprotocol.h" + +QQtServerProtocol::QQtServerProtocol ( QObject* parent ) : QObject ( parent ) +{ + +} + +QQtServerProtocol::~QQtServerProtocol() +{ + +} + +#define pline2() pline() << metaObject()->className() + +void QQtServerProtocol::translator ( const QByteArray& bytes ) +{ + // queued conn and queued package; + // direct conn and direct package; + + static QByteArray sqbaBlockOnNet; + sqbaBlockOnNet += bytes; + //qint64 aaa = bytesAvailable(); + //pline() << aaa; + + do + { + quint16 nBlockLen = this->splitter ( sqbaBlockOnNet ); + + pline2() << sqbaBlockOnNet.size() << "..." << nBlockLen; + + if ( sqbaBlockOnNet.length() < nBlockLen || nBlockLen < minlength() ) + { + /* + * 收到数据不足或者解析包长小于最小包长 + */ + return; + } + else if ( nBlockLen > maxlength() ) + { + /* + * 数据包长超过了最大长度 + */ + sqbaBlockOnNet.clear(); + pline2() << "forbidden package" << sqbaBlockOnNet.length() << nBlockLen; + return; + } + else if ( sqbaBlockOnNet.length() > nBlockLen ) + { + /* + * 粘包 + * 还没有处理完毕,数据已经接收到,异步信号处理出现这种异常 + * 疑问:如果异步调用这个函数绘出现什么问题?正常情况,同步获取数据,异步处理;检测异步获取并且处理会有什么状况 + */ + pline2() << "stick package" << sqbaBlockOnNet.length() << nBlockLen; + QByteArray netData; + netData.resize ( nBlockLen ); + sqbaBlockOnNet >> netData; + dispatcher ( netData ); + continue; + } + + /* + * 正常分发 + */ + dispatcher ( sqbaBlockOnNet ); + break; + } while ( 1 ); + + sqbaBlockOnNet.clear(); +} diff --git a/src/highgrade/qqtserverprotocol.h b/src/highgrade/qqtserverprotocol.h new file mode 100644 index 00000000..9adf2c59 --- /dev/null +++ b/src/highgrade/qqtserverprotocol.h @@ -0,0 +1,63 @@ +#ifndef QQTSERVERPROTOCOL_H +#define QQTSERVERPROTOCOL_H + +#include +#include +#include "qqtmessage.h" +#include "qqtcore.h" + +/** + * @brief The QQtServerProtocol class + * very good ideology and impliment + */ +class QQTSHARED_EXPORT QQtServerProtocol : public QObject +{ + Q_OBJECT +public: + explicit QQtServerProtocol ( QObject* parent = 0 ); + virtual ~QQtServerProtocol(); + + /* + * 建议:用户在继承类里的函数里直接调用[emit] write(...) + */ +Q_SIGNALS: + qint64 write ( const QByteArray& ); + +public: + /** + * @brief 协议处理器 + * 这个处理器是给QQtTcpSocket用的,不是给客户用的。 + * @param Qt通讯口readAll()读到的bytes + * @return + */ + void translator ( const QByteArray& bytes ); + + /* + * 以下函数,用户必须继承下去,重写,need override + */ +protected: + /** + * @brief 最小包长 + * @return + */ + inline virtual quint16 minlength() { return 0; } + /** + * @brief 最大包长 + * @return + */ + inline virtual quint16 maxlength() { return 0xFFFF; } + /** + * @brief 语法解析器 从流中解析报文长度 + * @param 接收到的数据段 + * @return 按照协议解析到的数据长度 可用,继续接收,丢弃,粘包。 + */ + inline virtual quint16 splitter ( const QByteArray& ) { return 0; } + /** + * @brief 语义解析器 + * @param 数据包 + * @return 0 no dispatched(others) 1 dispatched(own) + */ + inline virtual bool dispatcher ( const QByteArray& ) { return 0; } +}; + +#endif // QQTSERVERPROTOCOL_H diff --git a/src/network/qqtsockettcpserver.cpp b/src/highgrade/qqttcpserver.cpp similarity index 52% rename from src/network/qqtsockettcpserver.cpp rename to src/highgrade/qqttcpserver.cpp index e92c114b..99f08c4b 100644 --- a/src/network/qqtsockettcpserver.cpp +++ b/src/highgrade/qqttcpserver.cpp @@ -1,27 +1,27 @@ -#include "qqtsockettcpserver.h" +#include "qqttcpserver.h" #include "qqtnetwork.h" -QQtSocketTcpServer::QQtSocketTcpServer ( QObject* parent ) : +QQtTcpServer::QQtTcpServer ( QObject* parent ) : QTcpServer ( parent ) { } -QQtSocketTcpServer::~QQtSocketTcpServer() +QQtTcpServer::~QQtTcpServer() { if ( isListening() ) close(); } -void QQtSocketTcpServer::incomingConnection ( qintptr handle ) +void QQtTcpServer::incomingConnection ( qintptr handle ) { - QQtSocketTcpClient* clientSocket = new QQtSocketTcpClient ( this ); + QQtTcpClient* clientSocket = new QQtTcpClient ( this ); clientSocket->setSocketDescriptor ( handle ); connect ( clientSocket, SIGNAL ( disconnected() ), clientSocket, SLOT ( deleteLater() ) ); clientSocket->installProtocol ( m_protocol ); } -void QQtSocketTcpServer::installProtocol ( QQtProtocol* stack ) +void QQtTcpServer::installProtocol ( QQtProtocol* stack ) { if ( m_protocol ) return; @@ -29,7 +29,7 @@ void QQtSocketTcpServer::installProtocol ( QQtProtocol* stack ) m_protocol = stack; } -void QQtSocketTcpServer::uninstallProtocol ( QQtProtocol* stack ) +void QQtTcpServer::uninstallProtocol ( QQtProtocol* stack ) { Q_UNUSED ( stack ) @@ -39,7 +39,7 @@ void QQtSocketTcpServer::uninstallProtocol ( QQtProtocol* stack ) m_protocol = NULL; } -QQtProtocol* QQtSocketTcpServer::installedProtocol() +QQtProtocol* QQtTcpServer::installedProtocol() { return m_protocol; } diff --git a/src/network/qqtsockettcpserver.h b/src/highgrade/qqttcpserver.h similarity index 72% rename from src/network/qqtsockettcpserver.h rename to src/highgrade/qqttcpserver.h index a8c8403b..8fa362d8 100644 --- a/src/network/qqtsockettcpserver.h +++ b/src/highgrade/qqttcpserver.h @@ -3,16 +3,16 @@ #include #include "qqtprotocol.h" -#include "qqtsockettcpclient.h" +#include "qqttcpclient.h" #include "qqt-local.h" #include "qqtcore.h" -class QQTSHARED_EXPORT QQtSocketTcpServer : public QTcpServer +class QQTSHARED_EXPORT QQtTcpServer : public QTcpServer { Q_OBJECT public: - explicit QQtSocketTcpServer ( QObject* parent = 0 ); - ~QQtSocketTcpServer(); + explicit QQtTcpServer ( QObject* parent = 0 ); + ~QQtTcpServer(); void installProtocol ( QQtProtocol* stack ); void uninstallProtocol ( QQtProtocol* stack ); diff --git a/src/network/qqtsocketudpclient.cpp b/src/highgrade/qqtudpserver.cpp similarity index 80% rename from src/network/qqtsocketudpclient.cpp rename to src/highgrade/qqtudpserver.cpp index b0f3464c..5fbf0d35 100644 --- a/src/network/qqtsocketudpclient.cpp +++ b/src/highgrade/qqtudpserver.cpp @@ -1,6 +1,6 @@ -#include "qqtsocketudpclient.h" +#include "qqtudpserver.h" -QQtSocketUdpClient::QQtSocketUdpClient ( QObject* parent ) : QUdpSocket ( parent ) +QQtUdpServer::QQtUdpServer ( QObject* parent ) : QUdpSocket ( parent ) { connect ( this, SIGNAL ( stateChanged ( QAbstractSocket::SocketState ) ), this, SLOT ( socketStateChanged ( QAbstractSocket::SocketState ) ) ); @@ -23,7 +23,7 @@ QQtSocketUdpClient::QQtSocketUdpClient ( QObject* parent ) : QUdpSocket ( parent m_protocol = NULL; } -void QQtSocketUdpClient::installProtocol ( QQtUdpProtocol* stack ) +void QQtUdpServer::installProtocol ( QQtUdpProtocol* stack ) { if ( m_protocol ) return; @@ -33,7 +33,7 @@ void QQtSocketUdpClient::installProtocol ( QQtUdpProtocol* stack ) this, SLOT ( slotWriteDatagram ( QByteArray, QHostAddress, quint16 ) ) ); } -void QQtSocketUdpClient::uninstallProtocol ( QQtUdpProtocol* stack ) +void QQtUdpServer::uninstallProtocol ( QQtUdpProtocol* stack ) { Q_UNUSED ( stack ) @@ -45,22 +45,22 @@ void QQtSocketUdpClient::uninstallProtocol ( QQtUdpProtocol* stack ) m_protocol = NULL; } -QQtUdpProtocol* QQtSocketUdpClient::installedProtocol() +QQtUdpProtocol* QQtUdpServer::installedProtocol() { return m_protocol; } -void QQtSocketUdpClient::domainHostFound() +void QQtUdpServer::domainHostFound() { pline(); } /** - * @brief QQtSocketUdpClient::socketStateChanged + * @brief QQtUdpClient::socketStateChanged * @param eSocketState * 状态函数 */ -void QQtSocketUdpClient::socketStateChanged ( QAbstractSocket::SocketState eSocketState ) +void QQtUdpServer::socketStateChanged ( QAbstractSocket::SocketState eSocketState ) { pline() << eSocketState; @@ -85,11 +85,11 @@ void QQtSocketUdpClient::socketStateChanged ( QAbstractSocket::SocketState eSock } /** - * @brief QQtSocketUdpClient::socketErrorOccured + * @brief QQtUdpClient::socketErrorOccured * @param e * 状态函数 */ -void QQtSocketUdpClient::socketErrorOccured ( QAbstractSocket::SocketError e ) +void QQtUdpServer::socketErrorOccured ( QAbstractSocket::SocketError e ) { /* * 在错误状态下重新连接其他热点,直到确定连接类型,写入配置文件 @@ -109,10 +109,10 @@ void QQtSocketUdpClient::socketErrorOccured ( QAbstractSocket::SocketError e ) } /** - * @brief QQtSocketUdpClient::socketConnected + * @brief QQtUdpClient::socketConnected * 功能接口 */ -void QQtSocketUdpClient::socketConnected() +void QQtUdpServer::socketConnected() { pline() << peerName() << peerAddress().toString() << peerPort(); /* @@ -122,26 +122,26 @@ void QQtSocketUdpClient::socketConnected() } /** - * @brief QQtSocketUdpClient::socketDisconnect + * @brief QQtUdpClient::socketDisconnect * 功能接口 */ -void QQtSocketUdpClient::socketDisconnect() +void QQtUdpServer::socketDisconnect() { pline(); } -void QQtSocketUdpClient::updateProgress ( qint64 bytes ) +void QQtUdpServer::updateProgress ( qint64 bytes ) { Q_UNUSED ( bytes ) //pline() << bytes; } -qint64 QQtSocketUdpClient::slotWriteDatagram ( const QByteArray& datagram, const QHostAddress& host, quint16 port ) +qint64 QQtUdpServer::slotWriteDatagram ( const QByteArray& datagram, const QHostAddress& host, quint16 port ) { return writeDatagram ( datagram, host, port ); } -void QQtSocketUdpClient::readyReadData() +void QQtUdpServer::readyReadData() { /*为什么用while?*/ //Qt4 没有那么高级的一次性读取的接口?有 while ( hasPendingDatagrams() ) diff --git a/src/highgrade/qqtudpserver.h b/src/highgrade/qqtudpserver.h new file mode 100644 index 00000000..d9953d51 --- /dev/null +++ b/src/highgrade/qqtudpserver.h @@ -0,0 +1,65 @@ +#ifndef QQTUDPSERVER_H +#define QQTUDPSERVER_H + +#include +#include "qqtudpprotocol.h" +#include "qqtudpclient.h" +#include "qqt-local.h" +#include "qqtcore.h" + +/* + * Udp通信服务器 + * + * Udp通信服务器和客户端操作区别:服务器需要绑定本地端口。 + * 区别很小。 + * 可是在服务器端,和TCP一样需要处理多个客户端通信,在这里处理。 + * 假如不处理,一个服务器会同时和多个客户端通信。 + * + * 默认情况下,就可以接收发送数据了。在协议里处理接收、发送。 + * 只有绑定本地IP、端口才能进行接收 + */ +class QQtUdpServer : public QUdpSocket +{ + Q_OBJECT +public: + explicit QQtUdpServer ( QObject* parent = nullptr ); + virtual ~QQtUdpServer() {} + + void installProtocol ( QQtUdpProtocol* stack ); + void uninstallProtocol ( QQtUdpProtocol* stack ); + QQtUdpProtocol* installedProtocol(); + + QList getClientList() const { + return m_client_list; + } + +signals: + void signalConnecting(); + void signalConnectSucc(); + void signalConnectFail();// + void signalDisConnectSucc();//maybe + void signalDisConnectFail();// + void signalUpdateProgress ( qint64 value ); +public slots: + +protected slots: + void readyReadData(); +private slots: + void domainHostFound(); + void socketStateChanged ( QAbstractSocket::SocketState ); + void socketErrorOccured ( QAbstractSocket::SocketError ); + void socketConnected(); + void socketDisconnect(); + void updateProgress ( qint64 bytes ); + //如果有一个同名的槽,参数不同,并且被用宏控制起来,Qt编译不过。 + //Qt的元对象系统,解析信号和槽函数,不支持宏。 + //QtUdpSocket,writeDatagram不是个槽。 + qint64 slotWriteDatagram ( const QByteArray& datagram, + const QHostAddress& host, quint16 port ); + +private: + QQtUdpProtocol* m_protocol; + QList m_client_list; +}; + +#endif // QQTUDPSERVER_H diff --git a/src/highgrade/qqtudpserverprotocol.cpp b/src/highgrade/qqtudpserverprotocol.cpp new file mode 100644 index 00000000..6da6a079 --- /dev/null +++ b/src/highgrade/qqtudpserverprotocol.cpp @@ -0,0 +1 @@ +#include "qqtudpserverprotocol.h" diff --git a/src/highgrade/qqtudpserverprotocol.h b/src/highgrade/qqtudpserverprotocol.h new file mode 100644 index 00000000..f75a3116 --- /dev/null +++ b/src/highgrade/qqtudpserverprotocol.h @@ -0,0 +1,77 @@ +#ifndef QQTUDPSERVELPROTOCOL_H +#define QQTUDPSERVELPROTOCOL_H + +#include +#include +#include "qqtmessage.h" +#include "qqtcore.h" + +#define QT_VERSION_DATAGRAM QT_VERSION_CHECK(5,8,0) + +#if QT_VERSION > QT_VERSION_DATAGRAM +#include +#endif + +/* +*/ +class QQTSHARED_EXPORT QQtUdpServerProtocol : public QObject +{ + Q_OBJECT +public: + explicit QQtUdpServerProtocol ( QObject* parent = nullptr ) : QObject ( parent ) { + + } + virtual ~QQtUdpServerProtocol() {} + +#if QT_VERSION > QT_VERSION_DATAGRAM + qint64 writeDatagram ( const QNetworkDatagram& datagram ) { + QByteArray dg = datagram.data(); + QHostAddress addr = datagram.destinationAddress(); + int port = datagram.destinationPort(); + emit writeDatagram ( dg, addr, ( quint16 ) port ); + } +#endif + +signals: + qint64 writeDatagram ( const QByteArray& datagram, + const QHostAddress& host, quint16 port ); + +public slots: + +protected: + /** + * @brief 语义解析器 + * @brief 用户必须继承下去,重写,need override + * @param 数据包 + * @return 0 no dispatched(others) 1 dispatched(own) + */ + inline virtual bool dispatcher ( const QByteArray& datagram, + const QHostAddress& host, quint16 port ) { + return 0; + } + /* + * 这两个dispatcher,任选其一重写。 + */ +#if QT_VERSION > QT_VERSION_DATAGRAM + inline virtual bool dispatcher ( const QNetworkDatagram& ) { return 0; } +#endif + +public: + /** + * @brief 协议处理器 + * @brief 这个处理器是给QQtUdpSocket用的,不需要用户管理。 + * @param Qt通讯口readAll()读到的bytes + * @return + */ + void translator ( const QByteArray& datagram, + const QHostAddress& host, quint16 port ) { + dispatcher ( datagram, host, port ); + } +#if QT_VERSION > QT_VERSION_DATAGRAM + void translator ( const QNetworkDatagram& datagram ) { + dispatcher ( datagram ); + } +#endif +}; + +#endif // QQTUDPSERVELPROTOCOL_H diff --git a/src/network/qqtwebsocketserver.cpp b/src/highgrade/qqtwebsocketserver.cpp similarity index 100% rename from src/network/qqtwebsocketserver.cpp rename to src/highgrade/qqtwebsocketserver.cpp diff --git a/src/network/qqtwebsocketserver.h b/src/highgrade/qqtwebsocketserver.h similarity index 100% rename from src/network/qqtwebsocketserver.h rename to src/highgrade/qqtwebsocketserver.h diff --git a/src/network/qqtsocketbluetoothclient.cpp b/src/network/qqtbluetoothclient.cpp similarity index 67% rename from src/network/qqtsocketbluetoothclient.cpp rename to src/network/qqtbluetoothclient.cpp index 3af1329b..ac777ae4 100644 --- a/src/network/qqtsocketbluetoothclient.cpp +++ b/src/network/qqtbluetoothclient.cpp @@ -1,18 +1,18 @@ -#include "qqtsocketbluetoothclient.h" +#include "qqtbluetoothclient.h" #include -QQtSocketBluetoothClient::QQtSocketBluetoothClient ( QBluetoothServiceInfo::Protocol socketType, QObject* parent ) : +QQtBluetoothClient::QQtBluetoothClient ( QBluetoothServiceInfo::Protocol socketType, QObject* parent ) : QBluetoothSocket ( socketType, parent ) { initSocket(); } -QQtSocketBluetoothClient::QQtSocketBluetoothClient ( QObject* parent ) : QBluetoothSocket ( parent ) +QQtBluetoothClient::QQtBluetoothClient ( QObject* parent ) : QBluetoothSocket ( parent ) { initSocket(); } -void QQtSocketBluetoothClient::initSocket() +void QQtBluetoothClient::initSocket() { connect ( this, SIGNAL ( stateChanged ( QBluetoothSocket::SocketState ) ), this, SLOT ( socketStateChanged ( QBluetoothSocket::SocketState ) ) ); @@ -39,7 +39,7 @@ void QQtSocketBluetoothClient::initSocket() m_protocol = nullptr; } -void QQtSocketBluetoothClient::installProtocol ( QQtProtocol* stack ) +void QQtBluetoothClient::installProtocol ( QQtProtocol* stack ) { if ( m_protocol ) return; @@ -49,7 +49,7 @@ void QQtSocketBluetoothClient::installProtocol ( QQtProtocol* stack ) this, SLOT ( write ( const QByteArray& ) ) ); } -void QQtSocketBluetoothClient::uninstallProtocol ( QQtProtocol* stack ) +void QQtBluetoothClient::uninstallProtocol ( QQtProtocol* stack ) { Q_UNUSED ( stack ) @@ -61,12 +61,12 @@ void QQtSocketBluetoothClient::uninstallProtocol ( QQtProtocol* stack ) m_protocol = NULL; } -QQtProtocol* QQtSocketBluetoothClient::installedProtocol() +QQtProtocol* QQtBluetoothClient::installedProtocol() { return m_protocol; } -void QQtSocketBluetoothClient::sendConnectMessage() +void QQtBluetoothClient::sendConnectMessage() { pline() << isOpen() << state(); @@ -90,7 +90,7 @@ void QQtSocketBluetoothClient::sendConnectMessage() } -int QQtSocketBluetoothClient::sendDisConnectFromHost() +int QQtBluetoothClient::sendDisConnectFromHost() { pline() << isOpen() << state(); @@ -110,40 +110,40 @@ int QQtSocketBluetoothClient::sendDisConnectFromHost() } /** - * @brief QQtSocketBluetoothClient::socketStateChanged + * @brief QQtBluetoothClient::socketStateChanged * @param eSocketState * 状态函数 */ -void QQtSocketBluetoothClient::socketStateChanged ( QBluetoothSocket::SocketState eSocketState ) +void QQtBluetoothClient::socketStateChanged ( QBluetoothSocket::SocketState eSocketState ) { pline() << eSocketState; switch ( eSocketState ) { - case ServiceLookupState: - case ConnectingState: - break; + case ServiceLookupState: + case ConnectingState: + break; - case ConnectedState: - break; + case ConnectedState: + break; - case ClosingState: - break; + case ClosingState: + break; - case UnconnectedState: - break; + case UnconnectedState: + break; - default: - break; + default: + break; } } /** - * @brief QQtSocketBluetoothClient::socketErrorOccured + * @brief QQtBluetoothClient::socketErrorOccured * @param e * 状态函数 */ -void QQtSocketBluetoothClient::socketErrorOccured ( QBluetoothSocket::SocketError e ) +void QQtBluetoothClient::socketErrorOccured ( QBluetoothSocket::SocketError e ) { /* * 在错误状态下重新连接其他热点,直到确定连接类型,写入配置文件 @@ -152,18 +152,18 @@ void QQtSocketBluetoothClient::socketErrorOccured ( QBluetoothSocket::SocketErro switch ( e ) { - case HostNotFoundError: - default: - emit signalConnectFail(); - break; + case HostNotFoundError: + default: + emit signalConnectFail(); + break; } } /** - * @brief QQtSocketBluetoothClient::socketConnected + * @brief QQtBluetoothClient::socketConnected * 功能接口 */ -void QQtSocketBluetoothClient::socketConnected() +void QQtBluetoothClient::socketConnected() { pline() << peerName() << peerAddress().toString() << peerPort(); /* @@ -173,21 +173,21 @@ void QQtSocketBluetoothClient::socketConnected() } /** - * @brief QQtSocketBluetoothClient::socketDisconnect + * @brief QQtBluetoothClient::socketDisconnect * 功能接口 */ -void QQtSocketBluetoothClient::socketDisconnect() +void QQtBluetoothClient::socketDisconnect() { pline(); } -void QQtSocketBluetoothClient::updateProgress ( qint64 bytes ) +void QQtBluetoothClient::updateProgress ( qint64 bytes ) { Q_UNUSED ( bytes ) //pline() << bytes; } -void QQtSocketBluetoothClient::connectToSingelHost() +void QQtBluetoothClient::connectToSingelHost() { if ( !m_uuid.isNull() ) { @@ -208,7 +208,7 @@ void QQtSocketBluetoothClient::connectToSingelHost() -void QQtSocketBluetoothClient::readyReadData() +void QQtBluetoothClient::readyReadData() { QByteArray bytes; bytes = readAll(); diff --git a/src/network/qqtsocketbluetoothclient.h b/src/network/qqtbluetoothclient.h similarity index 86% rename from src/network/qqtsocketbluetoothclient.h rename to src/network/qqtbluetoothclient.h index 9d749788..702e4a25 100644 --- a/src/network/qqtsocketbluetoothclient.h +++ b/src/network/qqtbluetoothclient.h @@ -5,13 +5,13 @@ #include "qqtprotocol.h" #include "qqt-local.h" -class QQTSHARED_EXPORT QQtSocketBluetoothClient : public QBluetoothSocket +class QQTSHARED_EXPORT QQtBluetoothClient : public QBluetoothSocket { Q_OBJECT public: - explicit QQtSocketBluetoothClient ( QBluetoothServiceInfo::Protocol socketType = QBluetoothServiceInfo::RfcommProtocol, + explicit QQtBluetoothClient ( QBluetoothServiceInfo::Protocol socketType = QBluetoothServiceInfo::RfcommProtocol, QObject* parent = nullptr ); - explicit QQtSocketBluetoothClient ( QObject* parent = nullptr ); + explicit QQtBluetoothClient ( QObject* parent = nullptr ); /** * @brief setServiceInfo diff --git a/src/network/qqtsockettcpclient.cpp b/src/network/qqttcpclient.cpp similarity index 79% rename from src/network/qqtsockettcpclient.cpp rename to src/network/qqttcpclient.cpp index 2c1b74e2..6ddd8614 100644 --- a/src/network/qqtsockettcpclient.cpp +++ b/src/network/qqttcpclient.cpp @@ -1,4 +1,4 @@ -#include "qqtsockettcpclient.h" +#include "qqttcpclient.h" #include #include @@ -6,7 +6,7 @@ #include "qqtnetwork.h" #include "qqtcore.h" -QQtSocketTcpClient::QQtSocketTcpClient ( QObject* parent ) : +QQtTcpClient::QQtTcpClient ( QObject* parent ) : QTcpSocket ( parent ) { connect ( this, SIGNAL ( stateChanged ( QAbstractSocket::SocketState ) ), this, @@ -43,11 +43,11 @@ QQtSocketTcpClient::QQtSocketTcpClient ( QObject* parent ) : m_protocol = NULL; } -QQtSocketTcpClient::~QQtSocketTcpClient() +QQtTcpClient::~QQtTcpClient() { } -void QQtSocketTcpClient::installProtocol ( QQtProtocol* stack ) +void QQtTcpClient::installProtocol ( QQtProtocol* stack ) { if ( m_protocol ) return; @@ -57,7 +57,7 @@ void QQtSocketTcpClient::installProtocol ( QQtProtocol* stack ) this, SLOT ( write ( const QByteArray& ) ) ); } -void QQtSocketTcpClient::uninstallProtocol ( QQtProtocol* stack ) +void QQtTcpClient::uninstallProtocol ( QQtProtocol* stack ) { Q_UNUSED ( stack ) @@ -69,12 +69,12 @@ void QQtSocketTcpClient::uninstallProtocol ( QQtProtocol* stack ) m_protocol = NULL; } -QQtProtocol* QQtSocketTcpClient::installedProtocol() +QQtProtocol* QQtTcpClient::installedProtocol() { return m_protocol; } -void QQtSocketTcpClient::SendConnectMessage() +void QQtTcpClient::SendConnectMessage() { pline() << isValid() << isOpen() << state(); @@ -98,7 +98,7 @@ void QQtSocketTcpClient::SendConnectMessage() } -int QQtSocketTcpClient::SendDisConnectFromHost() +int QQtTcpClient::SendDisConnectFromHost() { pline() << isValid() << isOpen() << state(); @@ -118,17 +118,17 @@ int QQtSocketTcpClient::SendDisConnectFromHost() return true; } -void QQtSocketTcpClient::domainHostFound() +void QQtTcpClient::domainHostFound() { pline(); } /** - * @brief QQtSocketTcpClient::socketStateChanged + * @brief QQtTcpClient::socketStateChanged * @param eSocketState * 状态函数 */ -void QQtSocketTcpClient::socketStateChanged ( QAbstractSocket::SocketState eSocketState ) +void QQtTcpClient::socketStateChanged ( QAbstractSocket::SocketState eSocketState ) { pline() << eSocketState; @@ -154,11 +154,11 @@ void QQtSocketTcpClient::socketStateChanged ( QAbstractSocket::SocketState eSock } /** - * @brief QQtSocketTcpClient::socketErrorOccured + * @brief QQtTcpClient::socketErrorOccured * @param e * 状态函数 */ -void QQtSocketTcpClient::socketErrorOccured ( QAbstractSocket::SocketError e ) +void QQtTcpClient::socketErrorOccured ( QAbstractSocket::SocketError e ) { /* * 在错误状态下重新连接其他热点,直到确定连接类型,写入配置文件 @@ -178,10 +178,10 @@ void QQtSocketTcpClient::socketErrorOccured ( QAbstractSocket::SocketError e ) } /** - * @brief QQtSocketTcpClient::socketConnected + * @brief QQtTcpClient::socketConnected * 功能接口 */ -void QQtSocketTcpClient::socketConnected() +void QQtTcpClient::socketConnected() { pline() << peerName() << peerAddress().toString() << peerPort(); /* @@ -191,21 +191,21 @@ void QQtSocketTcpClient::socketConnected() } /** - * @brief QQtSocketTcpClient::socketDisconnect + * @brief QQtTcpClient::socketDisconnect * 功能接口 */ -void QQtSocketTcpClient::socketDisconnect() +void QQtTcpClient::socketDisconnect() { pline(); } -void QQtSocketTcpClient::updateProgress ( qint64 bytes ) +void QQtTcpClient::updateProgress ( qint64 bytes ) { Q_UNUSED ( bytes ) //pline() << bytes; } -void QQtSocketTcpClient::connectToSingelHost() +void QQtTcpClient::connectToSingelHost() { int contype = eConType % m_serverIP.size(); QString ip = m_serverIP.at ( contype ); @@ -215,7 +215,7 @@ void QQtSocketTcpClient::connectToSingelHost() } -void QQtSocketTcpClient::readyReadData() +void QQtTcpClient::readyReadData() { QByteArray bytes; bytes = readAll(); diff --git a/src/network/qqtsockettcpclient.h b/src/network/qqttcpclient.h similarity index 90% rename from src/network/qqtsockettcpclient.h rename to src/network/qqttcpclient.h index cd87fa41..159a08b6 100644 --- a/src/network/qqtsockettcpclient.h +++ b/src/network/qqttcpclient.h @@ -1,6 +1,6 @@ /************************************************** - * QQtSocketTcpClient - * 在一个工程当中仅仅存在一个实例,通过调用QQtSocketTcpClient实现。 + * QQtTcpClient + * 在一个工程当中仅仅存在一个实例,通过调用QQtTcpClient实现。 **************************************************/ #ifndef QQT_CLIENT_H #define QQT_CLIENT_H @@ -25,12 +25,12 @@ * 发送,接收,splitter,dispatcher * 关闭。 */ -class QQTSHARED_EXPORT QQtSocketTcpClient : public QTcpSocket +class QQTSHARED_EXPORT QQtTcpClient : public QTcpSocket { Q_OBJECT public: - explicit QQtSocketTcpClient ( QObject* parent = 0 ); - virtual ~QQtSocketTcpClient(); + explicit QQtTcpClient ( QObject* parent = 0 ); + virtual ~QQtTcpClient(); void SetServerIPAddress ( QStringList ip ) { m_serverIP = ip; } void SetServerPort ( quint32 p = 7079 ) { m_PORT = p; } diff --git a/src/network/qqtudpclient.cpp b/src/network/qqtudpclient.cpp new file mode 100644 index 00000000..b79a90fa --- /dev/null +++ b/src/network/qqtudpclient.cpp @@ -0,0 +1,184 @@ +#include "qqtudpclient.h" + +QQtUdpClient::QQtUdpClient ( QObject* parent ) : QUdpSocket ( parent ) +{ + connect ( this, SIGNAL ( stateChanged ( QAbstractSocket::SocketState ) ), this, + SLOT ( socketStateChanged ( QAbstractSocket::SocketState ) ) ); + // connected + connect ( this, SIGNAL ( connected() ), this, SLOT ( socketConnected() ) ); + // disconnected + connect ( this, SIGNAL ( disconnected() ), this, SLOT ( socketDisconnect() ) ); + // domain + connect ( this, SIGNAL ( hostFound() ), this, SLOT ( domainHostFound() ) ); + // error + connect ( this, SIGNAL ( error ( QAbstractSocket::SocketError ) ), this, + SLOT ( socketErrorOccured ( QAbstractSocket::SocketError ) ) ); + + connect ( this, SIGNAL ( readyRead() ), this, SLOT ( readyReadData() ) ); + + connect ( this, SIGNAL ( bytesWritten ( qint64 ) ), this, SLOT ( updateProgress ( qint64 ) ) ); + + connect ( this, SIGNAL ( bytesWritten ( qint64 ) ), this, SIGNAL ( signalUpdateProgress ( qint64 ) ) ); + + m_protocol = NULL; +} + +void QQtUdpClient::installProtocol ( QQtUdpProtocol* stack ) +{ + if ( m_protocol ) + return; + + m_protocol = stack; + connect ( m_protocol, SIGNAL ( writeDatagram ( QByteArray, QHostAddress, quint16 ) ), + this, SLOT ( slotWriteDatagram ( QByteArray, QHostAddress, quint16 ) ) ); +} + +void QQtUdpClient::uninstallProtocol ( QQtUdpProtocol* stack ) +{ + Q_UNUSED ( stack ) + + if ( !m_protocol ) + return; + + disconnect ( m_protocol, SIGNAL ( writeDatagram ( QByteArray, QHostAddress, quint16 ) ), + this, SLOT ( slotWriteDatagram ( QByteArray, QHostAddress, quint16 ) ) ); + m_protocol = NULL; +} + +QQtUdpProtocol* QQtUdpClient::installedProtocol() +{ + return m_protocol; +} + +void QQtUdpClient::domainHostFound() +{ + pline(); +} + +/** + * @brief QQtUdpClient::socketStateChanged + * @param eSocketState + * 状态函数 + */ +void QQtUdpClient::socketStateChanged ( QAbstractSocket::SocketState eSocketState ) +{ + pline() << eSocketState; + + switch ( eSocketState ) + { + case QAbstractSocket::HostLookupState: + case QAbstractSocket::ConnectingState: + break; + + case QAbstractSocket::ConnectedState: + break; + + case QAbstractSocket::ClosingState: + break; + + case QAbstractSocket::UnconnectedState: + break; + + default: + break; + } +} + +/** + * @brief QQtUdpClient::socketErrorOccured + * @param e + * 状态函数 + */ +void QQtUdpClient::socketErrorOccured ( QAbstractSocket::SocketError e ) +{ + /* + * 在错误状态下重新连接其他热点,直到确定连接类型,写入配置文件 + */ + pline() << e; + + switch ( e ) + { + case QAbstractSocket::RemoteHostClosedError: + break; + + case QAbstractSocket::HostNotFoundError: + default: + emit signalConnectFail(); + break; + } +} + +/** + * @brief QQtUdpClient::socketConnected + * 功能接口 + */ +void QQtUdpClient::socketConnected() +{ + pline() << peerName() << peerAddress().toString() << peerPort(); + /* + * 这个步骤,socket重建,资源重新开始 + */ + emit signalConnectSucc(); +} + +/** + * @brief QQtUdpClient::socketDisconnect + * 功能接口 + */ +void QQtUdpClient::socketDisconnect() +{ + pline(); +} + +void QQtUdpClient::updateProgress ( qint64 bytes ) +{ + Q_UNUSED ( bytes ) + //pline() << bytes; +} + +qint64 QQtUdpClient::slotWriteDatagram ( const QByteArray& datagram, const QHostAddress& host, quint16 port ) +{ + return writeDatagram ( datagram, host, port ); +} + +void QQtUdpClient::readyReadData() +{ + /*为什么用while?*/ //Qt4 没有那么高级的一次性读取的接口?有 + while ( hasPendingDatagrams() ) + { + QByteArray bytes; + qint64 maxlen = 0; + QHostAddress host; + quint16 port; + +#if QT_VERSION > QT_VERSION_DATAGRAM + /*能够一次收够一条报文?测试的能。*/ + QNetworkDatagram datagram = receiveDatagram(); + /*由于添加了兼容Qt4的代码,以上注释起来。*/ + + /*数据无意义 "" -1 在此设置*/ + datagram.setDestination ( this->localAddress(), this->localPort() ); + //pline() << "udp sender:" << datagram.senderAddress() << datagram.senderPort(); + //pline() << "udp receiver:" << datagram.destinationAddress() << datagram.destinationPort(); + m_protocol->translator ( datagram ); + + bytes = datagram.data(); + host = datagram.senderAddress(); + port = datagram.senderPort(); + m_protocol->translator ( bytes, host, port ); +#else + qint64 size = pendingDatagramSize(); + //pline() << "udp new msg size:" << size; + //这里的buf用完, 已经释放。 + char* data = new char[size + 1](); + qint64 len = readDatagram ( data, size, &host, &port ); + pline() << len; + bytes.setRawData ( data, size ); + delete[] data; + + m_protocol->translator ( bytes, host, port ); +#endif + + } +} + diff --git a/src/network/qqtsocketudpclient.h b/src/network/qqtudpclient.h similarity index 84% rename from src/network/qqtsocketudpclient.h rename to src/network/qqtudpclient.h index 6694fafb..ad54e294 100644 --- a/src/network/qqtsocketudpclient.h +++ b/src/network/qqtudpclient.h @@ -7,16 +7,19 @@ #include "qqtcore.h" /* - * Udp通信不区分服务器和客户端,都用这个就行啊。操作区别:服务器需要绑定本地端口。 + * Udp通信客户端 + * + * 和服务器操作区别:服务器需要绑定本地端口。 + * * 默认情况下,就可以接收发送数据了。在协议里处理接收、发送。 * 只有绑定本地IP、端口才能进行接收 */ -class QQtSocketUdpClient : public QUdpSocket +class QQTSHARED_EXPORT QQtUdpClient : public QUdpSocket { Q_OBJECT public: - explicit QQtSocketUdpClient ( QObject* parent = nullptr ); - virtual ~QQtSocketUdpClient() {} + explicit QQtUdpClient ( QObject* parent = nullptr ); + virtual ~QQtUdpClient() {} void installProtocol ( QQtUdpProtocol* stack ); void uninstallProtocol ( QQtUdpProtocol* stack ); diff --git a/src/network/qqtudpprotocol.h b/src/network/qqtudpprotocol.h index dc5d126d..02a79a72 100644 --- a/src/network/qqtudpprotocol.h +++ b/src/network/qqtudpprotocol.h @@ -25,7 +25,10 @@ public: #if QT_VERSION > QT_VERSION_DATAGRAM qint64 writeDatagram ( const QNetworkDatagram& datagram ) { - //emit writeDatagram(); + QByteArray dg = datagram.data(); + QHostAddress addr = datagram.destinationAddress(); + int port = datagram.destinationPort(); + emit writeDatagram ( dg, addr, ( quint16 ) port ); } #endif @@ -56,7 +59,7 @@ protected: public: /** * @brief 协议处理器 - * @brief 这个处理器是给QQtSocketUdpSocket用的,不需要用户管理。 + * @brief 这个处理器是给QQtUdpSocket用的,不需要用户管理。 * @param Qt通讯口readAll()读到的bytes * @return */ diff --git a/src/network/qqtwebaccessmanager.cpp b/src/network/qqtwebaccessmanager.cpp index ac00dc2e..e3d15a3c 100644 --- a/src/network/qqtwebaccessmanager.cpp +++ b/src/network/qqtwebaccessmanager.cpp @@ -549,15 +549,6 @@ void QQtWebAccessManager::localUpdateDownloadProgress ( qint64 bytesReceived, qi emit updateDownloadProgress ( session, bytesReceived, bytesTotal ); } -QQtWebAccessSession* QQtWebAccessSessionManager::newWebAccessSession() -{ - QUuid uuid = QUuid::createUuid(); - QQtWebAccessSession* session = new QQtWebAccessSession ( this ); - session->setWebAccessSessionName ( uuid.toString() ); - m_listWebAccessSession.push_back ( session ); - return session; -} - QNetworkReply* QQtWebAccessSessionManager::getReplyHandlerByUrl ( QString& strUrl ) { QQtWebAccessSession* s0 = NULL; diff --git a/src/network/qqtwebaccessmanager.h b/src/network/qqtwebaccessmanager.h index b86ce229..a663ce80 100644 --- a/src/network/qqtwebaccessmanager.h +++ b/src/network/qqtwebaccessmanager.h @@ -159,7 +159,13 @@ public: * user set * @return */ - QQtWebAccessSession* newWebAccessSession(); + QQtWebAccessSession* newWebAccessSession() { + QUuid uuid = QUuid::createUuid(); + QQtWebAccessSession* session = new QQtWebAccessSession ( this ); + session->setWebAccessSessionName ( uuid.toString() ); + m_listWebAccessSession.push_back ( session ); + return session; + } int getSessionCount() const { return m_listWebAccessSession.count(); diff --git a/src/network/qqtwebsocketclient.h b/src/network/qqtwebsocketclient.h index 942d171b..983d4014 100644 --- a/src/network/qqtwebsocketclient.h +++ b/src/network/qqtwebsocketclient.h @@ -3,12 +3,14 @@ #include #include +#include + /** * @brief The QQtWebClient class * QQtWebSocketClient通过安装QQtWebProtocol来实现和RawSocket相似的通信方式。 * 暂时不确定QQtWebProtocol是否和QQtProtocol格式相同,所以暂时使用QQtWebProtocol继承QQtProtocol。 */ -class QQtWebSocketClient : public QWebSocket +class QQTSHARED_EXPORT QQtWebSocketClient : public QWebSocket { Q_OBJECT public: diff --git a/src/qqt_3rdparty.pri b/src/qqt_3rdparty.pri index 7d8c644c..1020b324 100644 --- a/src/qqt_3rdparty.pri +++ b/src/qqt_3rdparty.pri @@ -124,8 +124,8 @@ contains (DEFINES, __EXQUISITE__) { } #mathml widget - #注释:在qqt_header.pri打开 DEFINES += __MATHSUPPORT__ - contains (DEFINES, __MATHSUPPORT__) { + #注释:在qqt_header.pri打开 DEFINES += __MATHWIDGETSUPPORT__ + contains (DEFINES, __MATHWIDGETSUPPORT__) { contains(QKIT_PRIVATE, WIN32|WIN64) { #mathml contains (DEFINES, QQT_LIBRARY) { @@ -138,7 +138,7 @@ contains (DEFINES, __EXQUISITE__) { HEADERS += $$PWD/exquisite/mathml/qtmmlwidget.h } - contains (DEFINES, __LOGICCAMERA__) { + contains (DEFINES, __LOGICCAMERAMODULE__) { #dmmu support #arm mips #TODO: +wince +android +ios +macOS +win +linux diff --git a/src/qqt_header.pri b/src/qqt_header.pri index e7f1dd0e..f508eca7 100644 --- a/src/qqt_header.pri +++ b/src/qqt_header.pri @@ -169,6 +169,9 @@ contains(DEFINES, __QQTCHARTS__) { ##################QQtLogSystem Module############################### DEFINES += __QQTLOGSYSTEMSUPPORT__ +########################################################################### +###QQtSocketClient多组功能组件。 +############ ##################QQt Network Module################################## #包括SerialPort Bluetooth TcpUdp #包括HttpFtp 多路的HttpFtp,QQtAccessManager WebService WebSocket Gumbo @@ -266,6 +269,7 @@ contains (DEFINES, __NETWORKSUPPORT__) { ##################Exquisite Widgets Module############################### #if you use Exquisite widgets, open this annotation #精美模块,包含不少的精美组件,这个模块可以集中开关。 +#依赖基础控件 DEFINES += __EXQUISITE__ contains (DEFINES, __EXQUISITE__) { #if you use QR encode, open this annotation @@ -293,16 +297,31 @@ contains (DEFINES, __EXQUISITE__) { } ##################Mathes Module############################### - DEFINES += __MATHSUPPORT__ + DEFINES += __MATHWIDGETSUPPORT__ #LOGIC CAMERA PREVIEW #depend on dmmu - DEFINES += __LOGICCAMERA__ + DEFINES += __LOGICCAMERAMODULE__ #opengl module DEFINES += __OPENGLWIDGETS__ } +######################################################################## +###这个模块名为高级模块,初始置入QQtSocketServer一组组件。 +###如果初中级工程师能使用这个模块完成App,那么必定是高分实现力学员。 +###建议中级以上工程师尝试。2018年4月22日 星期天 11点08分 +############ +##################HighGrade Module############################### +#if you use HighGrade module, open this annotation +#高级模块,包含不少的高级功能组件,这个模块可以集中开关。 +DEFINES += __HIGHGRADE__ +#依赖网络模块 +!contains (DEFINES, __NETWORKSUPPORT__): DEFINES -= __HIGHGRADE__ +contains (DEFINES, __HIGHGRADE__) { + +} + ################################################################# ##library ################################################################## @@ -388,6 +407,9 @@ defineReplace(qqt_header){ $${path}/exquisite/qrcode/qrdecode/zxing/win32/zxing/msvc } + #highgrade module + command += $${path}/highgrade + return ($$command) } diff --git a/src/qqt_source.pri b/src/qqt_source.pri index 6cd0b71d..e121a0a8 100644 --- a/src/qqt_source.pri +++ b/src/qqt_source.pri @@ -237,16 +237,14 @@ contains (DEFINES, __NETWORKSUPPORT__) { #tcpudpsocket contains(DEFINES, __TCPUDPSOCKET__){ SOURCES += \ - $$PWD/network/qqtsockettcpclient.cpp \ - $$PWD/network/qqtsockettcpserver.cpp + $$PWD/network/qqttcpclient.cpp HEADERS += \ - $$PWD/network/qqtsockettcpclient.h \ - $$PWD/network/qqtsockettcpserver.h + $$PWD/network/qqttcpclient.h SOURCES += \ - $$PWD/network/qqtsocketudpclient.cpp + $$PWD/network/qqtudpclient.cpp HEADERS += \ - $$PWD/network/qqtsocketudpclient.h + $$PWD/network/qqtudpclient.h } #serialport @@ -260,11 +258,9 @@ contains (DEFINES, __NETWORKSUPPORT__) { contains (DEFINES, __BLUETOOTH__) { #bluetooth socket SOURCES += \ - $$PWD/network/qqtsocketbluetoothclient.cpp \ - $$PWD/network/qqtsocketbluetoothserver.cpp + $$PWD/network/qqtbluetoothclient.cpp HEADERS += \ - $$PWD/network/qqtsocketbluetoothserver.h \ - $$PWD/network/qqtsocketbluetoothclient.h + $$PWD/network/qqtbluetoothclient.h #bluetooth manager SOURCES += \ $$PWD/network/qqtbluetoothmanager.cpp @@ -293,12 +289,10 @@ contains (DEFINES, __NETWORKSUPPORT__) { contains (DEFINES, __WEBSOCKETSUPPORT__) { SOURCES += \ - $$PWD/network/qqtwebsocketserver.cpp \ $$PWD/network/qqtwebsocketclient.cpp \ $$PWD/network/qqtwebsocketprotocol.cpp HEADERS += \ $$PWD/network/qqtwebsocketclient.h \ - $$PWD/network/qqtwebsocketserver.h \ $$PWD/network/qqtwebsocketprotocol.h } } @@ -401,4 +395,38 @@ contains (DEFINES, __EXQUISITE__) { } } +contains (DEFINES, __HIGHGRADE__) { + SOURCES += \ + $$PWD/highgrade/qqtprotocolmanager.cpp \ + $$PWD/highgrade/qqtserverprotocol.cpp \ + $$PWD/highgrade/qqtudpserverprotocol.cpp + HEADERS += \ + $$PWD/highgrade/qqtprotocolmanager.h \ + $$PWD/highgrade/qqtserverprotocol.h \ + $$PWD/highgrade/qqtudpserverprotocol.h + + contains(DEFINES, __TCPUDPSOCKET__){ + SOURCES += \ + $$PWD/highgrade/qqttcpserver.cpp + HEADERS += \ + $$PWD/highgrade/qqttcpserver.h + SOURCES += \ + $$PWD/highgrade/qqtudpserver.cpp + HEADERS += \ + $$PWD/highgrade/qqtudpserver.h + } + contains(DEFINES, __BLUETOOTH) { + SOURCES += \ + $$PWD/highgrade/qqtbluetoothserver.cpp + HEADERS += \ + $$PWD/highgrade/qqtbluetoothserver.h + } + contains (DEFINES, __WEBSOCKETSUPPORT__) { + SOURCES += \ + $$PWD/highgrade/qqtwebsocketserver.cpp + HEADERS += \ + $$PWD/highgrade/qqtwebsocketserver.h + } +} + include ($$PWD/qqt_3rdparty.pri) diff --git a/test/qqtffmpegplayer/qqtapp.cpp b/test/qqtffmpegplayer/qqtapp.cpp index d4d11ed6..804e1c67 100644 --- a/test/qqtffmpegplayer/qqtapp.cpp +++ b/test/qqtffmpegplayer/qqtapp.cpp @@ -5,8 +5,8 @@ #include "qqtinput.h" #include "qqtmsgbox.h" #include "qqtframe.h" -#include "qqtsockettcpclient.h" -#include "qqtsockettcpserver.h" +#include "qqttcpclient.h" +#include "qqttcpserver.h" #include "qqtserialport.h" #include "qqtpluginwatcher.h" #include "qqtversion.h" @@ -16,7 +16,7 @@ */ void QQTLanServer(QObject* parent = 0) { - static QQtSocketTcpServer* s = new QQtSocketTcpServer(parent); + static QQtTcpServer* s = new QQtTcpServer(parent); s->listen(QHostAddress::Any, 8000); s->installedProtocol(); @@ -106,13 +106,13 @@ QQTApp::QQTApp(int& argc, char** argv) : QApplication(argc, argv) QObject::connect(QQtPluginWatcher::Instance(), SIGNAL(storageChanged(int)), this, SLOT(slotUPanAutoRun(int))); - //QQtSocketTcpClient + //QQtTcpClient //QQTCloudClientInstance(this); #ifdef __EMBEDDED_LINUX__ //QQTEthManager QQtEthenetManager::Instance(this); #endif - //QQtSocketTcpServer + //QQtTcpServer //QQTPeerPort //QQTPeerPortInstance(this); diff --git a/test/qqtliveplayer/qqtapp.cpp b/test/qqtliveplayer/qqtapp.cpp index 7f24f787..c57c9645 100644 --- a/test/qqtliveplayer/qqtapp.cpp +++ b/test/qqtliveplayer/qqtapp.cpp @@ -5,8 +5,8 @@ #include "qqtinput.h" #include "qqtmsgbox.h" #include "qqtframe.h" -#include "qqtsockettcpclient.h" -#include "qqtsockettcpserver.h" +#include "qqttcpclient.h" +#include "qqttcpserver.h" #include "qqtserialport.h" #include "qqtpluginwatcher.h" #include "qqtversion.h" @@ -15,7 +15,7 @@ */ void QQTLanServer(QObject* parent = 0) { - static QQtSocketTcpServer* s = new QQtSocketTcpServer(parent); + static QQtTcpServer* s = new QQtTcpServer(parent); s->listen(QHostAddress::Any, 8000); s->installedProtocol(); @@ -105,13 +105,13 @@ QQTApp::QQTApp(int& argc, char** argv) : QApplication(argc, argv) QObject::connect(QQtPluginWatcher::Instance(), SIGNAL(storageChanged(int)), this, SLOT(slotUPanAutoRun(int))); - //QQtSocketTcpClient + //QQtTcpClient //QQTCloudClientInstance(this); #ifdef __EMBEDDED_LINUX__ //QQTEthManager QQtEthenetManager::Instance(this); #endif - //QQtSocketTcpServer + //QQtTcpServer //QQTPeerPort //QQTPeerPortInstance(this); diff --git a/test/qqtwebclient/qqtapp.cpp b/test/qqtwebclient/qqtapp.cpp index 1d3ebc79..7740bff1 100644 --- a/test/qqtwebclient/qqtapp.cpp +++ b/test/qqtwebclient/qqtapp.cpp @@ -5,8 +5,8 @@ #include "qqtinput.h" #include "qqtmsgbox.h" #include "qqtframe.h" -#include "qqtsockettcpclient.h" -#include "qqtsockettcpserver.h" +#include "qqttcpclient.h" +#include "qqttcpserver.h" #include "qqtserialport.h" #include "qqtcloudprotocol.h" #include "qqtuserserialprotocol.h" @@ -17,7 +17,7 @@ */ void QQTLanServer(QObject* parent = 0) { - static QQtSocketTcpServer* s = new QQtSocketTcpServer(parent); + static QQtTcpServer* s = new QQtTcpServer(parent); s->listen(QHostAddress::Any, 8000); s->installedProtocol(); @@ -107,13 +107,13 @@ QQTApp::QQTApp(int &argc, char **argv) : QApplication(argc, argv) QObject::connect(QQtPluginWatcher::Instance(), SIGNAL(storageChanged(int)), this, SLOT(slotUPanAutoRun(int))); - //QQtSocketTcpClient + //QQtTcpClient //QQTCloudClientInstance(this); #ifdef __EMBEDDED_LINUX__ //QQTEthManager QQtEthenetManager::Instance(this); #endif - //QQtSocketTcpServer + //QQtTcpServer //QQTPeerPort //QQTPeerPortInstance(this); diff --git a/test/qqtwebkittest/qqtapp.cpp b/test/qqtwebkittest/qqtapp.cpp index a0f0dffb..37b6aed3 100644 --- a/test/qqtwebkittest/qqtapp.cpp +++ b/test/qqtwebkittest/qqtapp.cpp @@ -5,8 +5,8 @@ #include "qqtinput.h" #include "qqtmsgbox.h" #include "qqtframe.h" -#include "qqtsockettcpclient.h" -#include "qqtsockettcpserver.h" +#include "qqttcpclient.h" +#include "qqttcpserver.h" #include "qqtserialport.h" #include "qqtpluginwatcher.h" #include "qqtversion.h" @@ -16,7 +16,7 @@ */ void QQTLanServer ( QObject* parent = 0 ) { - static QQtSocketTcpServer* s = new QQtSocketTcpServer ( parent ); + static QQtTcpServer* s = new QQtTcpServer ( parent ); s->listen ( QHostAddress::Any, 8000 ); s->installedProtocol(); @@ -106,13 +106,13 @@ QQTApp::QQTApp ( int& argc, char** argv ) : QApplication ( argc, argv ) QObject::connect ( QQtPluginWatcher::Instance(), SIGNAL ( storageChanged ( int ) ), this, SLOT ( slotUPanAutoRun ( int ) ) ); - //QQtSocketTcpClient + //QQtTcpClient //QQTCloudClientInstance(this); #ifdef __EMBEDDED_LINUX__ //QQTEthManager QQtEthenetManager::Instance ( this ); #endif - //QQtSocketTcpServer + //QQtTcpServer //QQTPeerPort //QQTPeerPortInstance(this);