From 02c60c6720f41bcfc367d02ae4c655b651642991 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 16 May 2011 20:51:20 +0000 Subject: Almost there! I'm adding a qtbenc-like program for gats, only cooler. It'll really help us debug gats based protocols and look at gats files, and the like. --- default.bld | 23 +++++++++ src/gatscon/clientwidget.cpp | 24 +++++++++ src/gatscon/clientwidget.h | 21 ++++++++ src/gatscon/clientwidget.ui | 62 +++++++++++++++++++++++ src/gatscon/connectdlg.cpp | 22 +++++++++ src/gatscon/connectdlg.h | 17 +++++++ src/gatscon/connectdlg.ui | 99 +++++++++++++++++++++++++++++++++++++ src/gatscon/gatstotree.cpp | 8 +++ src/gatscon/gatstotree.h | 8 +++ src/gatscon/main.cpp | 13 +++++ src/gatscon/mainwnd.cpp | 25 ++++++++++ src/gatscon/mainwnd.h | 20 ++++++++ src/gatscon/mainwnd.ui | 115 +++++++++++++++++++++++++++++++++++++++++++ 13 files changed, 457 insertions(+) create mode 100644 src/gatscon/clientwidget.cpp create mode 100644 src/gatscon/clientwidget.h create mode 100644 src/gatscon/clientwidget.ui create mode 100644 src/gatscon/connectdlg.cpp create mode 100644 src/gatscon/connectdlg.h create mode 100644 src/gatscon/connectdlg.ui create mode 100644 src/gatscon/gatstotree.cpp create mode 100644 src/gatscon/gatstotree.h create mode 100644 src/gatscon/main.cpp create mode 100644 src/gatscon/mainwnd.cpp create mode 100644 src/gatscon/mainwnd.h create mode 100644 src/gatscon/mainwnd.ui diff --git a/default.bld b/default.bld index de34acf..35302dd 100644 --- a/default.bld +++ b/default.bld @@ -9,6 +9,11 @@ action "all" build: [targets("header-links"), "libgats.a", targets()]; } +action "gatscon" +{ + build: [targets("header-links"), "libgats.a", + targets("headers"), "gatscon"]; +} CXXFLAGS += "-ggdb -Wall"; @@ -70,3 +75,21 @@ rule "unit" } } +include "qt4.bld"; + +QTDIR = "/opt/qt-4"; + +target "gatscon" +{ + input files("src/gatscon/*.h", "src/gatscon/*.cpp", "src/gatscon/*.ui"); + rule "exe"; + + CXXFLAGS += qt_getCXXFLAGS(); + LDFLAGS += qt_getLDFLAGS(); + + CXXFLAGS += "-Isrc/gatscon"; + + CXXFLAGS += "-I. -Ilibbu++"; + LDFLAGS += "-L. -lgats -Llibbu++ -lbu++"; +} + diff --git a/src/gatscon/clientwidget.cpp b/src/gatscon/clientwidget.cpp new file mode 100644 index 0000000..4872d9d --- /dev/null +++ b/src/gatscon/clientwidget.cpp @@ -0,0 +1,24 @@ +#include "clientwidget.h" +#include "connectdlg.h" + +ClientWidget::ClientWidget( QWidget *pParent ) : + QWidget( pParent ), + gsCli( ssCli ) +{ + setupUi( this ); + + ConnectDlg dlg( this ); + dlg.exec(); + + ssCli.setStream( + new Bu::TcpSocket( dlg.getHost().constData(), dlg.getPort() ) + ); + + Gats::Object *pObj = gsCli.readObject(); + gatsToTree( twHistory, pObj ); +} + +ClientWidget::~ClientWidget() +{ +} + diff --git a/src/gatscon/clientwidget.h b/src/gatscon/clientwidget.h new file mode 100644 index 0000000..3a96f07 --- /dev/null +++ b/src/gatscon/clientwidget.h @@ -0,0 +1,21 @@ +#ifndef CLIENT_WIDGET_H +#define CLIENT_WIDGET_H + +#include "ui_clientwidget.h" + +#include +#include + +class ClientWidget : public QWidget, protected Ui::ClientWidget +{ + Q_OBJECT; +public: + ClientWidget( QWidget *pParent=NULL ); + virtual ~ClientWidget(); + +private: + Bu::StreamStack ssCli; + Gats::GatsStream gsCli; +}; + +#endif diff --git a/src/gatscon/clientwidget.ui b/src/gatscon/clientwidget.ui new file mode 100644 index 0000000..9761401 --- /dev/null +++ b/src/gatscon/clientwidget.ui @@ -0,0 +1,62 @@ + + + ClientWidget + + + + 0 + 0 + 364 + 289 + + + + Form + + + + + + + Name + + + + + Value + + + + + + + + + + Gats: + + + + + + + + + + Send + + + true + + + true + + + + + + + + + + diff --git a/src/gatscon/connectdlg.cpp b/src/gatscon/connectdlg.cpp new file mode 100644 index 0000000..589ae97 --- /dev/null +++ b/src/gatscon/connectdlg.cpp @@ -0,0 +1,22 @@ +#include "connectdlg.h" + +ConnectDlg::ConnectDlg( QWidget *pParent ) : + QDialog( pParent ) +{ + setupUi( this ); +} + +ConnectDlg::~ConnectDlg() +{ +} + +QByteArray ConnectDlg::getHostname() const +{ + return leHost->text().toAscii(); +} + +int ConnectDlg::getPort() const +{ + return sbPort->value(); +} + diff --git a/src/gatscon/connectdlg.h b/src/gatscon/connectdlg.h new file mode 100644 index 0000000..57ea6cd --- /dev/null +++ b/src/gatscon/connectdlg.h @@ -0,0 +1,17 @@ +#ifndef CONNECT_DLG_H +#define CONNECT_DLG_H + +#include "ui_connectdlg.h" + +class ConnectDlg : public QDialog, protected Ui::ConnectDlg +{ + Q_OBJECT; +public: + ConnectDlg( QWidget *pParent ); + virtual ~ConnectDlg(); + + QByteArray getHostname() const; + int getPort() const; +}; + +#endif diff --git a/src/gatscon/connectdlg.ui b/src/gatscon/connectdlg.ui new file mode 100644 index 0000000..fd2d909 --- /dev/null +++ b/src/gatscon/connectdlg.ui @@ -0,0 +1,99 @@ + + + ConnectDlg + + + + 0 + 0 + 300 + 93 + + + + GatsCon - Connect + + + + + + + + Hostname: + + + + + + + Port: + + + + + + + localhost + + + + + + + 1 + + + 32767 + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + ConnectDlg + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + ConnectDlg + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/gatscon/gatstotree.cpp b/src/gatscon/gatstotree.cpp new file mode 100644 index 0000000..af94fa5 --- /dev/null +++ b/src/gatscon/gatstotree.cpp @@ -0,0 +1,8 @@ +#include + +#include + +void gatsToTree( QTreeWidgetItem *p, Gats::Object *pObj ) +{ +} + diff --git a/src/gatscon/gatstotree.h b/src/gatscon/gatstotree.h new file mode 100644 index 0000000..cab9eee --- /dev/null +++ b/src/gatscon/gatstotree.h @@ -0,0 +1,8 @@ +#ifndef GATS_TO_TREE_H +#define GATS_TO_TREE_H + +class QTreeWidgetItem; + +void gatsToTree( QTreeWidgetItem *p, Gats::Object *pObj ); + +#endif diff --git a/src/gatscon/main.cpp b/src/gatscon/main.cpp new file mode 100644 index 0000000..b9b2327 --- /dev/null +++ b/src/gatscon/main.cpp @@ -0,0 +1,13 @@ +#include "mainwnd.h" +#include + +int main( int argc, char *argv[] ) +{ + QApplication app( argc, argv ); + + MainWnd wnd; + wnd.show(); + + return app.exec(); +} + diff --git a/src/gatscon/mainwnd.cpp b/src/gatscon/mainwnd.cpp new file mode 100644 index 0000000..c86e1c2 --- /dev/null +++ b/src/gatscon/mainwnd.cpp @@ -0,0 +1,25 @@ +#include "mainwnd.h" +#include "clientwidget.h" + +MainWnd::MainWnd() +{ + setupUi( this ); +} + +MainWnd::~MainWnd() +{ +} + +void MainWnd::connect() +{ + setCentralWidget( new ClientWidget( this ) ); +} + +void MainWnd::proxy() +{ +} + +void MainWnd::open() +{ +} + diff --git a/src/gatscon/mainwnd.h b/src/gatscon/mainwnd.h new file mode 100644 index 0000000..8f638d8 --- /dev/null +++ b/src/gatscon/mainwnd.h @@ -0,0 +1,20 @@ +#ifndef MAIN_WND_H +#define MAIN_WND_H + +#include "ui_mainwnd.h" + +class MainWnd : public QMainWindow, protected Ui::MainWnd +{ + Q_OBJECT; +public: + MainWnd(); + virtual ~MainWnd(); + +public slots: + void connect(); + void proxy(); + void open(); + +}; + +#endif diff --git a/src/gatscon/mainwnd.ui b/src/gatscon/mainwnd.ui new file mode 100644 index 0000000..e080dd3 --- /dev/null +++ b/src/gatscon/mainwnd.ui @@ -0,0 +1,115 @@ + + + MainWnd + + + + 0 + 0 + 431 + 319 + + + + GatsCon + + + + + + 0 + 0 + 431 + 21 + + + + + &File + + + + + + &Network + + + + + + + + + + + &Open connection... + + + + + &Start proxy... + + + + + &Open gats file... + + + + + + + action_Open_connection + triggered() + MainWnd + connect() + + + 215 + 159 + + + 215 + 159 + + + + + action_Open_proxy_connection + triggered() + MainWnd + proxy() + + + -1 + -1 + + + 215 + 159 + + + + + action_Open_gats_file + triggered() + MainWnd + open() + + + -1 + -1 + + + 215 + 159 + + + + + + connect() + proxy() + open() + + -- cgit v1.2.3