aboutsummaryrefslogtreecommitdiff
path: root/c++-libbu++/src/gatscon
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-11-09 17:20:11 +0000
committerMike Buland <eichlan@xagasoft.com>2012-11-09 17:20:11 +0000
commitd534a56d95bca7bdd812be024d9eacba4734e2b7 (patch)
treef9b98ee2b80e645a7b54e7934882be6c9f73c165 /c++-libbu++/src/gatscon
parent61ccc86fdf06f12cb72a8b7e65286f812cf62154 (diff)
downloadlibgats-d534a56d95bca7bdd812be024d9eacba4734e2b7.tar.gz
libgats-d534a56d95bca7bdd812be024d9eacba4734e2b7.tar.bz2
libgats-d534a56d95bca7bdd812be024d9eacba4734e2b7.tar.xz
libgats-d534a56d95bca7bdd812be024d9eacba4734e2b7.zip
Many changes: tabconv'd the C++ code, added a license, BSD, and docs.
Diffstat (limited to 'c++-libbu++/src/gatscon')
-rw-r--r--c++-libbu++/src/gatscon/clientthread.cpp43
-rw-r--r--c++-libbu++/src/gatscon/clientthread.h29
-rw-r--r--c++-libbu++/src/gatscon/clientwidget.cpp95
-rw-r--r--c++-libbu++/src/gatscon/clientwidget.h23
-rw-r--r--c++-libbu++/src/gatscon/connectdlg.cpp15
-rw-r--r--c++-libbu++/src/gatscon/connectdlg.h17
-rw-r--r--c++-libbu++/src/gatscon/filewidget.cpp75
-rw-r--r--c++-libbu++/src/gatscon/filewidget.h23
-rw-r--r--c++-libbu++/src/gatscon/gatstotree.cpp115
-rw-r--r--c++-libbu++/src/gatscon/gatstotree.h21
-rw-r--r--c++-libbu++/src/gatscon/iobase.cpp7
-rw-r--r--c++-libbu++/src/gatscon/iobase.h9
-rw-r--r--c++-libbu++/src/gatscon/main.cpp15
-rw-r--r--c++-libbu++/src/gatscon/mainwnd.cpp149
-rw-r--r--c++-libbu++/src/gatscon/mainwnd.h31
-rw-r--r--c++-libbu++/src/gatscon/proxythread.cpp113
-rw-r--r--c++-libbu++/src/gatscon/proxythread.h55
-rw-r--r--c++-libbu++/src/gatscon/proxywidget.cpp169
-rw-r--r--c++-libbu++/src/gatscon/proxywidget.h31
-rw-r--r--c++-libbu++/src/gatscon/setupproxydlg.cpp17
-rw-r--r--c++-libbu++/src/gatscon/setupproxydlg.h19
-rw-r--r--c++-libbu++/src/gatscon/treetogats.cpp89
-rw-r--r--c++-libbu++/src/gatscon/treetogats.h9
23 files changed, 665 insertions, 504 deletions
diff --git a/c++-libbu++/src/gatscon/clientthread.cpp b/c++-libbu++/src/gatscon/clientthread.cpp
index 4c7b72a..4032a50 100644
--- a/c++-libbu++/src/gatscon/clientthread.cpp
+++ b/c++-libbu++/src/gatscon/clientthread.cpp
@@ -1,13 +1,20 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#include "clientthread.h" 8#include "clientthread.h"
2 9
3#include <bu/tcpsocket.h> 10#include <bu/tcpsocket.h>
4 11
5ClientThread::ClientThread( QObject *pParent, const QByteArray &baHost, 12ClientThread::ClientThread( QObject *pParent, const QByteArray &baHost,
6 int iPort ) : 13 int iPort ) :
7 QThread( pParent ), 14 QThread( pParent ),
8 baHost( baHost ), 15 baHost( baHost ),
9 iPort( iPort ), 16 iPort( iPort ),
10 gsCli( ssCli ) 17 gsCli( ssCli )
11{ 18{
12} 19}
13 20
@@ -17,22 +24,22 @@ ClientThread::~ClientThread()
17 24
18void ClientThread::send( Gats::Object *pObj ) 25void ClientThread::send( Gats::Object *pObj )
19{ 26{
20 gsCli.writeObject( pObj ); 27 gsCli.writeObject( pObj );
21} 28}
22 29
23void ClientThread::run() 30void ClientThread::run()
24{ 31{
25 ssCli.setStream( 32 ssCli.setStream(
26 new Bu::TcpSocket( baHost.constData(), iPort ) 33 new Bu::TcpSocket( baHost.constData(), iPort )
27 ); 34 );
28 35
29 while( !ssCli.isEos() ) 36 while( !ssCli.isEos() )
30 { 37 {
31 Gats::Object *pObj = gsCli.readObject(); 38 Gats::Object *pObj = gsCli.readObject();
32 if( pObj == NULL ) 39 if( pObj == NULL )
33 continue; 40 continue;
34 41
35 emit recv( pObj ); 42 emit recv( pObj );
36 } 43 }
37} 44}
38 45
diff --git a/c++-libbu++/src/gatscon/clientthread.h b/c++-libbu++/src/gatscon/clientthread.h
index 3182d37..a4343ee 100644
--- a/c++-libbu++/src/gatscon/clientthread.h
+++ b/c++-libbu++/src/gatscon/clientthread.h
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#ifndef CLIENT_THREAD_H 8#ifndef CLIENT_THREAD_H
2#define CLIENT_THREAD_H 9#define CLIENT_THREAD_H
3 10
@@ -9,29 +16,29 @@
9 16
10namespace Gats 17namespace Gats
11{ 18{
12 class Object; 19 class Object;
13}; 20};
14 21
15class ClientThread : public QThread 22class ClientThread : public QThread
16{ 23{
17 Q_OBJECT; 24 Q_OBJECT;
18public: 25public:
19 ClientThread( QObject *pParent, const QByteArray &baHost, int iPort ); 26 ClientThread( QObject *pParent, const QByteArray &baHost, int iPort );
20 virtual ~ClientThread(); 27 virtual ~ClientThread();
21 28
22 void send( Gats::Object *pObj ); 29 void send( Gats::Object *pObj );
23 30
24signals: 31signals:
25 void recv( Gats::Object *pObj ); 32 void recv( Gats::Object *pObj );
26 33
27protected: 34protected:
28 virtual void run(); 35 virtual void run();
29 36
30private: 37private:
31 QByteArray baHost; 38 QByteArray baHost;
32 int iPort; 39 int iPort;
33 Bu::StreamStack ssCli; 40 Bu::StreamStack ssCli;
34 Gats::GatsStream gsCli; 41 Gats::GatsStream gsCli;
35}; 42};
36 43
37#endif 44#endif
diff --git a/c++-libbu++/src/gatscon/clientwidget.cpp b/c++-libbu++/src/gatscon/clientwidget.cpp
index 941d9fa..f13e736 100644
--- a/c++-libbu++/src/gatscon/clientwidget.cpp
+++ b/c++-libbu++/src/gatscon/clientwidget.cpp
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#include "clientwidget.h" 8#include "clientwidget.h"
2#include "clientthread.h" 9#include "clientthread.h"
3 10
@@ -14,16 +21,16 @@
14using namespace Bu; 21using namespace Bu;
15 22
16ClientWidget::ClientWidget( QWidget *pParent, const QByteArray &baHost, 23ClientWidget::ClientWidget( QWidget *pParent, const QByteArray &baHost,
17 int iPort ) : 24 int iPort ) :
18 QWidget( pParent ) 25 QWidget( pParent )
19{ 26{
20 setupUi( this ); 27 setupUi( this );
21 28
22 pCli = new ClientThread( this, baHost, iPort ); 29 pCli = new ClientThread( this, baHost, iPort );
23 connect( pCli, SIGNAL(recv( Gats::Object *)), 30 connect( pCli, SIGNAL(recv( Gats::Object *)),
24 this, SLOT(recv(Gats::Object *)), Qt::QueuedConnection ); 31 this, SLOT(recv(Gats::Object *)), Qt::QueuedConnection );
25 32
26 pCli->start(); 33 pCli->start();
27} 34}
28 35
29ClientWidget::~ClientWidget() 36ClientWidget::~ClientWidget()
@@ -32,51 +39,51 @@ ClientWidget::~ClientWidget()
32 39
33void ClientWidget::saveTo( const QString &sFile ) 40void ClientWidget::saveTo( const QString &sFile )
34{ 41{
35 File fOut( sFile.toAscii().constData(), File::WriteNew ); 42 File fOut( sFile.toAscii().constData(), File::WriteNew );
36 Gats::GatsStream gsOut( fOut ); 43 Gats::GatsStream gsOut( fOut );
37 QTreeWidgetItem *pRoot = twHistory->invisibleRootItem(); 44 QTreeWidgetItem *pRoot = twHistory->invisibleRootItem();
38 for( int j = 0; j < pRoot->childCount(); j++ ) 45 for( int j = 0; j < pRoot->childCount(); j++ )
39 { 46 {
40 Gats::Object *pObj = treeToGats( pRoot->child( j ) ); 47 Gats::Object *pObj = treeToGats( pRoot->child( j ) );
41 gsOut.writeObject( pObj ); 48 gsOut.writeObject( pObj );
42 delete pObj; 49 delete pObj;
43 } 50 }
44} 51}
45 52
46void ClientWidget::send() 53void ClientWidget::send()
47{ 54{
48 try 55 try
49 { 56 {
50 Gats::Object *pObj = Gats::Object::strToGats( 57 Gats::Object *pObj = Gats::Object::strToGats(
51 leGats->text().toAscii().constData() 58 leGats->text().toAscii().constData()
52 ); 59 );
53 sio << "Send: " << *pObj << sio.nl; 60 sio << "Send: " << *pObj << sio.nl;
54 QTreeWidgetItem *pIt = new QTreeWidgetItem( 61 QTreeWidgetItem *pIt = new QTreeWidgetItem(
55 twHistory->invisibleRootItem() 62 twHistory->invisibleRootItem()
56 ); 63 );
57 pIt->setText( 0, "send" ); 64 pIt->setText( 0, "send" );
58 gatsToTree( pIt, pObj ); 65 gatsToTree( pIt, pObj );
59 pCli->send( pObj ); 66 pCli->send( pObj );
60 delete pObj; 67 delete pObj;
61 68
62 leGats->setText(""); 69 leGats->setText("");
63 leGats->setFocus(); 70 leGats->setFocus();
64 } 71 }
65 catch( Bu::ExceptionBase &e ) 72 catch( Bu::ExceptionBase &e )
66 { 73 {
67 QMessageBox::critical( this, "Gats Console - Error", e.what() ); 74 QMessageBox::critical( this, "Gats Console - Error", e.what() );
68 } 75 }
69} 76}
70 77
71void ClientWidget::recv( Gats::Object *pObj ) 78void ClientWidget::recv( Gats::Object *pObj )
72{ 79{
73 sio << "Recv: " << *pObj << sio.nl; 80 sio << "Recv: " << *pObj << sio.nl;
74 81
75 QTreeWidgetItem *pIt = new QTreeWidgetItem( 82 QTreeWidgetItem *pIt = new QTreeWidgetItem(
76 twHistory->invisibleRootItem() 83 twHistory->invisibleRootItem()
77 ); 84 );
78 pIt->setText( 0, "recv" ); 85 pIt->setText( 0, "recv" );
79 gatsToTree( pIt, pObj ); 86 gatsToTree( pIt, pObj );
80 delete pObj; 87 delete pObj;
81} 88}
82 89
diff --git a/c++-libbu++/src/gatscon/clientwidget.h b/c++-libbu++/src/gatscon/clientwidget.h
index 06c154d..b40adf4 100644
--- a/c++-libbu++/src/gatscon/clientwidget.h
+++ b/c++-libbu++/src/gatscon/clientwidget.h
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#ifndef CLIENT_WIDGET_H 8#ifndef CLIENT_WIDGET_H
2#define CLIENT_WIDGET_H 9#define CLIENT_WIDGET_H
3 10
@@ -7,24 +14,24 @@
7 14
8namespace Gats 15namespace Gats
9{ 16{
10 class Object; 17 class Object;
11}; 18};
12 19
13class ClientWidget : public QWidget, protected Ui::ClientWidget, public IoBase 20class ClientWidget : public QWidget, protected Ui::ClientWidget, public IoBase
14{ 21{
15 Q_OBJECT; 22 Q_OBJECT;
16public: 23public:
17 ClientWidget( QWidget *pParent, const QByteArray &baHost, int iPort ); 24 ClientWidget( QWidget *pParent, const QByteArray &baHost, int iPort );
18 virtual ~ClientWidget(); 25 virtual ~ClientWidget();
19 26
20 virtual void saveTo( const QString &sFile ); 27 virtual void saveTo( const QString &sFile );
21 28
22public slots: 29public slots:
23 void send(); 30 void send();
24 void recv( Gats::Object *pObj ); 31 void recv( Gats::Object *pObj );
25 32
26private: 33private:
27 class ClientThread *pCli; 34 class ClientThread *pCli;
28}; 35};
29 36
30#endif 37#endif
diff --git a/c++-libbu++/src/gatscon/connectdlg.cpp b/c++-libbu++/src/gatscon/connectdlg.cpp
index 589ae97..0bb159b 100644
--- a/c++-libbu++/src/gatscon/connectdlg.cpp
+++ b/c++-libbu++/src/gatscon/connectdlg.cpp
@@ -1,9 +1,16 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#include "connectdlg.h" 8#include "connectdlg.h"
2 9
3ConnectDlg::ConnectDlg( QWidget *pParent ) : 10ConnectDlg::ConnectDlg( QWidget *pParent ) :
4 QDialog( pParent ) 11 QDialog( pParent )
5{ 12{
6 setupUi( this ); 13 setupUi( this );
7} 14}
8 15
9ConnectDlg::~ConnectDlg() 16ConnectDlg::~ConnectDlg()
@@ -12,11 +19,11 @@ ConnectDlg::~ConnectDlg()
12 19
13QByteArray ConnectDlg::getHostname() const 20QByteArray ConnectDlg::getHostname() const
14{ 21{
15 return leHost->text().toAscii(); 22 return leHost->text().toAscii();
16} 23}
17 24
18int ConnectDlg::getPort() const 25int ConnectDlg::getPort() const
19{ 26{
20 return sbPort->value(); 27 return sbPort->value();
21} 28}
22 29
diff --git a/c++-libbu++/src/gatscon/connectdlg.h b/c++-libbu++/src/gatscon/connectdlg.h
index 57ea6cd..7396ef6 100644
--- a/c++-libbu++/src/gatscon/connectdlg.h
+++ b/c++-libbu++/src/gatscon/connectdlg.h
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#ifndef CONNECT_DLG_H 8#ifndef CONNECT_DLG_H
2#define CONNECT_DLG_H 9#define CONNECT_DLG_H
3 10
@@ -5,13 +12,13 @@
5 12
6class ConnectDlg : public QDialog, protected Ui::ConnectDlg 13class ConnectDlg : public QDialog, protected Ui::ConnectDlg
7{ 14{
8 Q_OBJECT; 15 Q_OBJECT;
9public: 16public:
10 ConnectDlg( QWidget *pParent ); 17 ConnectDlg( QWidget *pParent );
11 virtual ~ConnectDlg(); 18 virtual ~ConnectDlg();
12 19
13 QByteArray getHostname() const; 20 QByteArray getHostname() const;
14 int getPort() const; 21 int getPort() const;
15}; 22};
16 23
17#endif 24#endif
diff --git a/c++-libbu++/src/gatscon/filewidget.cpp b/c++-libbu++/src/gatscon/filewidget.cpp
index dbd70fd..23f6839 100644
--- a/c++-libbu++/src/gatscon/filewidget.cpp
+++ b/c++-libbu++/src/gatscon/filewidget.cpp
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#include "filewidget.h" 8#include "filewidget.h"
2 9
3#include "gatstotree.h" 10#include "gatstotree.h"
@@ -12,28 +19,28 @@
12using namespace Bu; 19using namespace Bu;
13 20
14FileWidget::FileWidget( QWidget *pParent ) : 21FileWidget::FileWidget( QWidget *pParent ) :
15 QWidget( pParent ) 22 QWidget( pParent )
16{ 23{
17 setupUi( this ); 24 setupUi( this );
18} 25}
19 26
20FileWidget::FileWidget( QWidget *pParent, QString sFile ) : 27FileWidget::FileWidget( QWidget *pParent, QString sFile ) :
21 QWidget( pParent ) 28 QWidget( pParent )
22{ 29{
23 setupUi( this ); 30 setupUi( this );
24 31
25 File fIn( sFile.toAscii().constData(), File::Read ); 32 File fIn( sFile.toAscii().constData(), File::Read );
26 Gats::GatsStream gsIn( fIn ); 33 Gats::GatsStream gsIn( fIn );
27 Gats::Object *pObj; 34 Gats::Object *pObj;
28 while( (pObj = gsIn.readObject()) ) 35 while( (pObj = gsIn.readObject()) )
29 { 36 {
30 QTreeWidgetItem *pNew = new QTreeWidgetItem( 37 QTreeWidgetItem *pNew = new QTreeWidgetItem(
31 twGats->invisibleRootItem() 38 twGats->invisibleRootItem()
32 ); 39 );
33 pNew->setText( 0, "<root>" ); 40 pNew->setText( 0, "<root>" );
34 gatsToTree( pNew, pObj ); 41 gatsToTree( pNew, pObj );
35 delete pObj; 42 delete pObj;
36 } 43 }
37} 44}
38 45
39FileWidget::~FileWidget() 46FileWidget::~FileWidget()
@@ -42,28 +49,28 @@ FileWidget::~FileWidget()
42 49
43void FileWidget::saveTo( const QString &sFile ) 50void FileWidget::saveTo( const QString &sFile )
44{ 51{
45 File fOut( sFile.toAscii().constData(), File::WriteNew ); 52 File fOut( sFile.toAscii().constData(), File::WriteNew );
46 Gats::GatsStream gsOut( fOut ); 53 Gats::GatsStream gsOut( fOut );
47 QTreeWidgetItem *pRoot = twGats->invisibleRootItem(); 54 QTreeWidgetItem *pRoot = twGats->invisibleRootItem();
48 for( int j = 0; j < pRoot->childCount(); j++ ) 55 for( int j = 0; j < pRoot->childCount(); j++ )
49 { 56 {
50 Gats::Object *pObj = treeToGats( pRoot->child( j ) ); 57 Gats::Object *pObj = treeToGats( pRoot->child( j ) );
51 gsOut.writeObject( pObj ); 58 gsOut.writeObject( pObj );
52 delete pObj; 59 delete pObj;
53 } 60 }
54} 61}
55 62
56void FileWidget::addRootItem() 63void FileWidget::addRootItem()
57{ 64{
58 QString sText = QInputDialog::getText( this, "Gats Console - Add Root Item", 65 QString sText = QInputDialog::getText( this, "Gats Console - Add Root Item",
59 "Gats:"); 66 "Gats:");
60 Gats::Object *pObj = Gats::Object::strToGats( sText.toAscii().constData() ); 67 Gats::Object *pObj = Gats::Object::strToGats( sText.toAscii().constData() );
61 QTreeWidgetItem *pNew = new QTreeWidgetItem( 68 QTreeWidgetItem *pNew = new QTreeWidgetItem(
62 twGats->invisibleRootItem() 69 twGats->invisibleRootItem()
63 ); 70 );
64 pNew->setText( 0, "<root>" ); 71 pNew->setText( 0, "<root>" );
65 gatsToTree( pNew, pObj ); 72 gatsToTree( pNew, pObj );
66 delete pObj; 73 delete pObj;
67} 74}
68 75
69void FileWidget::delRootItem() 76void FileWidget::delRootItem()
diff --git a/c++-libbu++/src/gatscon/filewidget.h b/c++-libbu++/src/gatscon/filewidget.h
index 9993bfe..1426eae 100644
--- a/c++-libbu++/src/gatscon/filewidget.h
+++ b/c++-libbu++/src/gatscon/filewidget.h
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#ifndef FILE_WIDGET_H 8#ifndef FILE_WIDGET_H
2#define FILE_WIDGET_H 9#define FILE_WIDGET_H
3 10
@@ -6,22 +13,22 @@
6 13
7namespace Gats 14namespace Gats
8{ 15{
9 class Object; 16 class Object;
10}; 17};
11 18
12class FileWidget : public QWidget, protected Ui::FileWidget, public IoBase 19class FileWidget : public QWidget, protected Ui::FileWidget, public IoBase
13{ 20{
14 Q_OBJECT; 21 Q_OBJECT;
15public: 22public:
16 FileWidget( QWidget *pParent=NULL ); 23 FileWidget( QWidget *pParent=NULL );
17 FileWidget( QWidget *pParent, QString sFile ); 24 FileWidget( QWidget *pParent, QString sFile );
18 virtual ~FileWidget(); 25 virtual ~FileWidget();
19 26
20 virtual void saveTo( const QString &sFile ); 27 virtual void saveTo( const QString &sFile );
21 28
22public slots: 29public slots:
23 void addRootItem(); 30 void addRootItem();
24 void delRootItem(); 31 void delRootItem();
25 32
26private: 33private:
27}; 34};
diff --git a/c++-libbu++/src/gatscon/gatstotree.cpp b/c++-libbu++/src/gatscon/gatstotree.cpp
index e388d5e..192b395 100644
--- a/c++-libbu++/src/gatscon/gatstotree.cpp
+++ b/c++-libbu++/src/gatscon/gatstotree.cpp
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#include "gatstotree.h" 8#include "gatstotree.h"
2 9
3#include <gats/types.h> 10#include <gats/types.h>
@@ -6,86 +13,86 @@
6 13
7void gatsToTree( QTreeWidgetItem *p, Gats::Object *pObj ) 14void gatsToTree( QTreeWidgetItem *p, Gats::Object *pObj )
8{ 15{
9 switch( pObj->getType() ) 16 switch( pObj->getType() )
10 { 17 {
11 case Gats::typeInteger: 18 case Gats::typeInteger:
12 gatsToTree( p, dynamic_cast<Gats::Integer *>( pObj ) ); 19 gatsToTree( p, dynamic_cast<Gats::Integer *>( pObj ) );
13 break; 20 break;
14 21
15 case Gats::typeString: 22 case Gats::typeString:
16 gatsToTree( p, dynamic_cast<Gats::String *>( pObj ) ); 23 gatsToTree( p, dynamic_cast<Gats::String *>( pObj ) );
17 break; 24 break;
18 25
19 case Gats::typeFloat: 26 case Gats::typeFloat:
20 gatsToTree( p, dynamic_cast<Gats::Float *>( pObj ) ); 27 gatsToTree( p, dynamic_cast<Gats::Float *>( pObj ) );
21 break; 28 break;
22 29
23 case Gats::typeBoolean: 30 case Gats::typeBoolean:
24 gatsToTree( p, dynamic_cast<Gats::Boolean *>( pObj ) ); 31 gatsToTree( p, dynamic_cast<Gats::Boolean *>( pObj ) );
25 break; 32 break;
26 33
27 case Gats::typeList: 34 case Gats::typeList:
28 gatsToTree( p, dynamic_cast<Gats::List *>( pObj ) ); 35 gatsToTree( p, dynamic_cast<Gats::List *>( pObj ) );
29 break; 36 break;
30 37
31 case Gats::typeDictionary: 38 case Gats::typeDictionary:
32 gatsToTree( p, dynamic_cast<Gats::Dictionary *>( pObj ) ); 39 gatsToTree( p, dynamic_cast<Gats::Dictionary *>( pObj ) );
33 break; 40 break;
34 41
35 case Gats::typeNull: 42 case Gats::typeNull:
36 gatsToTree( p, dynamic_cast<Gats::Null *>( pObj ) ); 43 gatsToTree( p, dynamic_cast<Gats::Null *>( pObj ) );
37 break; 44 break;
38 } 45 }
39} 46}
40 47
41void gatsToTree( QTreeWidgetItem *p, Gats::Integer *pObj ) 48void gatsToTree( QTreeWidgetItem *p, Gats::Integer *pObj )
42{ 49{
43 p->setText( 1, "int"); 50 p->setText( 1, "int");
44 p->setText( 2, QString("%1").arg( pObj->getValue() ) ); 51 p->setText( 2, QString("%1").arg( pObj->getValue() ) );
45} 52}
46 53
47void gatsToTree( QTreeWidgetItem *p, Gats::String *pObj ) 54void gatsToTree( QTreeWidgetItem *p, Gats::String *pObj )
48{ 55{
49 p->setText( 1, "str"); 56 p->setText( 1, "str");
50 p->setText( 2, QString("%1").arg( pObj->getStr() ) ); 57 p->setText( 2, QString("%1").arg( pObj->getStr() ) );
51} 58}
52 59
53void gatsToTree( QTreeWidgetItem *p, Gats::Float *pObj ) 60void gatsToTree( QTreeWidgetItem *p, Gats::Float *pObj )
54{ 61{
55 p->setText( 1, "float"); 62 p->setText( 1, "float");
56 p->setText( 2, QString("%1").arg( pObj->getValue() ) ); 63 p->setText( 2, QString("%1").arg( pObj->getValue() ) );
57} 64}
58 65
59void gatsToTree( QTreeWidgetItem *p, Gats::Boolean *pObj ) 66void gatsToTree( QTreeWidgetItem *p, Gats::Boolean *pObj )
60{ 67{
61 p->setText( 1, "bool"); 68 p->setText( 1, "bool");
62 p->setText( 2, pObj->getValue()?"true":"false" ); 69 p->setText( 2, pObj->getValue()?"true":"false" );
63} 70}
64 71
65void gatsToTree( QTreeWidgetItem *p, Gats::List *pObj ) 72void gatsToTree( QTreeWidgetItem *p, Gats::List *pObj )
66{ 73{
67 p->setText( 1, "list"); 74 p->setText( 1, "list");
68 int j = 0; 75 int j = 0;
69 for( Gats::List::iterator i = pObj->begin(); i; i++ ) 76 for( Gats::List::iterator i = pObj->begin(); i; i++ )
70 { 77 {
71 QTreeWidgetItem *pIt = new QTreeWidgetItem( p ); 78 QTreeWidgetItem *pIt = new QTreeWidgetItem( p );
72 pIt->setText( 0, QString("%1").arg( j++ ) ); 79 pIt->setText( 0, QString("%1").arg( j++ ) );
73 gatsToTree( pIt, *i ); 80 gatsToTree( pIt, *i );
74 } 81 }
75} 82}
76 83
77void gatsToTree( QTreeWidgetItem *p, Gats::Dictionary *pObj ) 84void gatsToTree( QTreeWidgetItem *p, Gats::Dictionary *pObj )
78{ 85{
79 p->setText( 1, "dict"); 86 p->setText( 1, "dict");
80 for( Gats::Dictionary::iterator i = pObj->begin(); i; i++ ) 87 for( Gats::Dictionary::iterator i = pObj->begin(); i; i++ )
81 { 88 {
82 QTreeWidgetItem *pIt = new QTreeWidgetItem( p ); 89 QTreeWidgetItem *pIt = new QTreeWidgetItem( p );
83 pIt->setText( 0, QString( i.getKey().getStr() ) ); 90 pIt->setText( 0, QString( i.getKey().getStr() ) );
84 gatsToTree( pIt, *i ); 91 gatsToTree( pIt, *i );
85 } 92 }
86} 93}
87 94
88void gatsToTree( QTreeWidgetItem *p, Gats::Null *pObj ) 95void gatsToTree( QTreeWidgetItem *p, Gats::Null *pObj )
89{ 96{
90 p->setText( 1, "null"); 97 p->setText( 1, "null");
91} 98}
diff --git a/c++-libbu++/src/gatscon/gatstotree.h b/c++-libbu++/src/gatscon/gatstotree.h
index a803017..dc8f451 100644
--- a/c++-libbu++/src/gatscon/gatstotree.h
+++ b/c++-libbu++/src/gatscon/gatstotree.h
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#ifndef GATS_TO_TREE_H 8#ifndef GATS_TO_TREE_H
2#define GATS_TO_TREE_H 9#define GATS_TO_TREE_H
3 10
@@ -5,13 +12,13 @@ class QTreeWidgetItem;
5 12
6namespace Gats 13namespace Gats
7{ 14{
8 class Integer; 15 class Integer;
9 class String; 16 class String;
10 class Float; 17 class Float;
11 class Boolean; 18 class Boolean;
12 class List; 19 class List;
13 class Dictionary; 20 class Dictionary;
14 class Object; 21 class Object;
15}; 22};
16 23
17#include <gats/types.h> 24#include <gats/types.h>
diff --git a/c++-libbu++/src/gatscon/iobase.cpp b/c++-libbu++/src/gatscon/iobase.cpp
index 309444c..40af455 100644
--- a/c++-libbu++/src/gatscon/iobase.cpp
+++ b/c++-libbu++/src/gatscon/iobase.cpp
@@ -1 +1,8 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#include "iobase.h" 8#include "iobase.h"
diff --git a/c++-libbu++/src/gatscon/iobase.h b/c++-libbu++/src/gatscon/iobase.h
index 5bd3843..4475551 100644
--- a/c++-libbu++/src/gatscon/iobase.h
+++ b/c++-libbu++/src/gatscon/iobase.h
@@ -1,10 +1,17 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#ifndef IO_BASE_H 8#ifndef IO_BASE_H
2#define IO_BASE_H 9#define IO_BASE_H
3 10
4class IoBase 11class IoBase
5{ 12{
6public: 13public:
7 virtual void saveTo( const class QString &sFile )=0; 14 virtual void saveTo( const class QString &sFile )=0;
8}; 15};
9 16
10#endif 17#endif
diff --git a/c++-libbu++/src/gatscon/main.cpp b/c++-libbu++/src/gatscon/main.cpp
index b9b2327..11b6d4a 100644
--- a/c++-libbu++/src/gatscon/main.cpp
+++ b/c++-libbu++/src/gatscon/main.cpp
@@ -1,13 +1,20 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#include "mainwnd.h" 8#include "mainwnd.h"
2#include <QApplication> 9#include <QApplication>
3 10
4int main( int argc, char *argv[] ) 11int main( int argc, char *argv[] )
5{ 12{
6 QApplication app( argc, argv ); 13 QApplication app( argc, argv );
7 14
8 MainWnd wnd; 15 MainWnd wnd;
9 wnd.show(); 16 wnd.show();
10 17
11 return app.exec(); 18 return app.exec();
12} 19}
13 20
diff --git a/c++-libbu++/src/gatscon/mainwnd.cpp b/c++-libbu++/src/gatscon/mainwnd.cpp
index 5d31019..7cce116 100644
--- a/c++-libbu++/src/gatscon/mainwnd.cpp
+++ b/c++-libbu++/src/gatscon/mainwnd.cpp
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#include "mainwnd.h" 8#include "mainwnd.h"
2 9
3#include "clientwidget.h" 10#include "clientwidget.h"
@@ -12,10 +19,10 @@
12 19
13MainWnd::MainWnd() 20MainWnd::MainWnd()
14{ 21{
15 setupUi( this ); 22 setupUi( this );
16 23
17 pMode = new QLabel( "Idle", this ); 24 pMode = new QLabel( "Idle", this );
18 statusBar()->addPermanentWidget( pMode ); 25 statusBar()->addPermanentWidget( pMode );
19} 26}
20 27
21MainWnd::~MainWnd() 28MainWnd::~MainWnd()
@@ -24,96 +31,96 @@ MainWnd::~MainWnd()
24 31
25void MainWnd::connect() 32void MainWnd::connect()
26{ 33{
27 ConnectDlg dlg( this ); 34 ConnectDlg dlg( this );
28 if( dlg.exec() == QDialog::Accepted ) 35 if( dlg.exec() == QDialog::Accepted )
29 { 36 {
30 sCurFile.clear(); 37 sCurFile.clear();
31 setCentralWidget( 38 setCentralWidget(
32 new ClientWidget( 39 new ClientWidget(
33 this, dlg.getHostname(), dlg.getPort() 40 this, dlg.getHostname(), dlg.getPort()
34 ) 41 )
35 ); 42 );
36 pMode->setText( 43 pMode->setText(
37 QString("Client Mode: %1:%2").arg( QString(dlg.getHostname()) ). 44 QString("Client Mode: %1:%2").arg( QString(dlg.getHostname()) ).
38 arg( dlg.getPort() ) 45 arg( dlg.getPort() )
39 ); 46 );
40 } 47 }
41} 48}
42 49
43void MainWnd::proxy() 50void MainWnd::proxy()
44{ 51{
45 SetupProxyDlg dlg( this ); 52 SetupProxyDlg dlg( this );
46 53
47 if( dlg.exec() == QDialog::Accepted ) 54 if( dlg.exec() == QDialog::Accepted )
48 { 55 {
49 sCurFile.clear(); 56 sCurFile.clear();
50 setCentralWidget( 57 setCentralWidget(
51 new ProxyWidget( 58 new ProxyWidget(
52 this, dlg.getPortIn(), dlg.getHostOut(), dlg.getPortOut() 59 this, dlg.getPortIn(), dlg.getHostOut(), dlg.getPortOut()
53 ) 60 )
54 ); 61 );
55 pMode->setText( 62 pMode->setText(
56 QString("Proxy Mode: :%1 -> %2:%3").arg( dlg.getPortIn() ). 63 QString("Proxy Mode: :%1 -> %2:%3").arg( dlg.getPortIn() ).
57 arg( QString(dlg.getHostOut()) ). 64 arg( QString(dlg.getHostOut()) ).
58 arg( dlg.getPortOut() ) 65 arg( dlg.getPortOut() )
59 ); 66 );
60 } 67 }
61} 68}
62 69
63void MainWnd::open() 70void MainWnd::open()
64{ 71{
65 QString sFile = QFileDialog::getOpenFileName( 72 QString sFile = QFileDialog::getOpenFileName(
66 this, "Gats Console - open gats file" 73 this, "Gats Console - open gats file"
67 ); 74 );
68 if( sFile.isEmpty() ) 75 if( sFile.isEmpty() )
69 return; 76 return;
70 77
71 sCurFile = sFile; 78 sCurFile = sFile;
72 setCentralWidget( 79 setCentralWidget(
73 new FileWidget( this, sFile ) 80 new FileWidget( this, sFile )
74 ); 81 );
75 pMode->setText( QString("File mode: %1").arg( sCurFile ) ); 82 pMode->setText( QString("File mode: %1").arg( sCurFile ) );
76} 83}
77 84
78void MainWnd::newFile() 85void MainWnd::newFile()
79{ 86{
80 sCurFile.clear(); 87 sCurFile.clear();
81 setCentralWidget( 88 setCentralWidget(
82 new FileWidget( this ) 89 new FileWidget( this )
83 ); 90 );
84 pMode->setText( QString("File mode: <untitled>") ); 91 pMode->setText( QString("File mode: <untitled>") );
85} 92}
86 93
87void MainWnd::save() 94void MainWnd::save()
88{ 95{
89 if( sCurFile.isEmpty() ) 96 if( sCurFile.isEmpty() )
90 { 97 {
91 saveAs(); 98 saveAs();
92 } 99 }
93 else 100 else
94 { 101 {
95 IoBase *pIo = dynamic_cast<IoBase *>(centralWidget()); 102 IoBase *pIo = dynamic_cast<IoBase *>(centralWidget());
96 if( !pIo ) 103 if( !pIo )
97 return; 104 return;
98 105
99 pIo->saveTo( sCurFile ); 106 pIo->saveTo( sCurFile );
100 } 107 }
101} 108}
102 109
103void MainWnd::saveAs() 110void MainWnd::saveAs()
104{ 111{
105 IoBase *pIo = dynamic_cast<IoBase *>(centralWidget()); 112 IoBase *pIo = dynamic_cast<IoBase *>(centralWidget());
106 if( !pIo ) 113 if( !pIo )
107 return; 114 return;
108 115
109 QString sFile = QFileDialog::getSaveFileName( 116 QString sFile = QFileDialog::getSaveFileName(
110 this, "Gats Console - save gats file" 117 this, "Gats Console - save gats file"
111 ); 118 );
112 if( sFile.isEmpty() ) 119 if( sFile.isEmpty() )
113 return; 120 return;
114 121
115 pIo->saveTo( sFile ); 122 pIo->saveTo( sFile );
116 123
117 sCurFile = sFile; 124 sCurFile = sFile;
118} 125}
119 126
diff --git a/c++-libbu++/src/gatscon/mainwnd.h b/c++-libbu++/src/gatscon/mainwnd.h
index d1ae080..2a5c3fa 100644
--- a/c++-libbu++/src/gatscon/mainwnd.h
+++ b/c++-libbu++/src/gatscon/mainwnd.h
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#ifndef MAIN_WND_H 8#ifndef MAIN_WND_H
2#define MAIN_WND_H 9#define MAIN_WND_H
3 10
@@ -5,22 +12,22 @@
5 12
6class MainWnd : public QMainWindow, protected Ui::MainWnd 13class MainWnd : public QMainWindow, protected Ui::MainWnd
7{ 14{
8 Q_OBJECT; 15 Q_OBJECT;
9public: 16public:
10 MainWnd(); 17 MainWnd();
11 virtual ~MainWnd(); 18 virtual ~MainWnd();
12 19
13public slots: 20public slots:
14 void connect(); 21 void connect();
15 void proxy(); 22 void proxy();
16 void open(); 23 void open();
17 void newFile(); 24 void newFile();
18 void save(); 25 void save();
19 void saveAs(); 26 void saveAs();
20 27
21private: 28private:
22 QString sCurFile; 29 QString sCurFile;
23 class QLabel *pMode; 30 class QLabel *pMode;
24}; 31};
25 32
26#endif 33#endif
diff --git a/c++-libbu++/src/gatscon/proxythread.cpp b/c++-libbu++/src/gatscon/proxythread.cpp
index 574b56b..733af7f 100644
--- a/c++-libbu++/src/gatscon/proxythread.cpp
+++ b/c++-libbu++/src/gatscon/proxythread.cpp
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#include "proxythread.h" 8#include "proxythread.h"
2 9
3#include <gats/types.h> 10#include <gats/types.h>
@@ -10,15 +17,15 @@
10using namespace Bu; 17using namespace Bu;
11 18
12ProxyThread::ProxyThread( QObject *pParent, int iPortIn, 19ProxyThread::ProxyThread( QObject *pParent, int iPortIn,
13 const QByteArray &baHostOut, int iPortOut ) : 20 const QByteArray &baHostOut, int iPortOut ) :
14 QThread( pParent ), 21 QThread( pParent ),
15 pHost( NULL ), 22 pHost( NULL ),
16 iPortIn( iPortIn ), 23 iPortIn( iPortIn ),
17 baHostOut( baHostOut ), 24 baHostOut( baHostOut ),
18 iPortOut( iPortOut ), 25 iPortOut( iPortOut ),
19 gsCli( ssCli ) 26 gsCli( ssCli )
20{ 27{
21 pHost = new ProxyHostThread( pParent, this ); 28 pHost = new ProxyHostThread( pParent, this );
22} 29}
23 30
24ProxyThread::~ProxyThread() 31ProxyThread::~ProxyThread()
@@ -27,52 +34,52 @@ ProxyThread::~ProxyThread()
27 34
28void ProxyThread::send( Gats::Object *pObj ) 35void ProxyThread::send( Gats::Object *pObj )
29{ 36{
30 MemBuf bg; 37 MemBuf bg;
31 Gats::GatsStream gs( bg ); 38 Gats::GatsStream gs( bg );
32 gs.writeObject( pObj ); 39 gs.writeObject( pObj );
33 ssCli.write( bg.getString().getStr(), bg.getString().getSize() ); 40 ssCli.write( bg.getString().getStr(), bg.getString().getSize() );
34} 41}
35 42
36void ProxyThread::run() 43void ProxyThread::run()
37{ 44{
38 int iSockIn; 45 int iSockIn;
39 46
40 { 47 {
41 TcpServerSocket tsIn( iPortIn ); 48 TcpServerSocket tsIn( iPortIn );
42 do 49 do
43 { 50 {
44 iSockIn = tsIn.accept( 5 ); 51 iSockIn = tsIn.accept( 5 );
45 } while( iSockIn < 0 ); 52 } while( iSockIn < 0 );
46 } 53 }
47 54
48 emit gotConnection(); 55 emit gotConnection();
49 56
50 ssCli.setStream( new TcpSocket( iSockIn ) ); 57 ssCli.setStream( new TcpSocket( iSockIn ) );
51 ssCli.setBlocking( true ); 58 ssCli.setBlocking( true );
52 59
53 pHost->setStream( 60 pHost->setStream(
54 new TcpSocket( baHostOut.constData(), iPortOut ) 61 new TcpSocket( baHostOut.constData(), iPortOut )
55 ); 62 );
56 63
57 pHost->start(); 64 pHost->start();
58 65
59 while( !ssCli.isEos() ) 66 while( !ssCli.isEos() )
60 { 67 {
61 Gats::Object *pObj = gsCli.readObject(); 68 Gats::Object *pObj = gsCli.readObject();
62 if( pObj == NULL ) 69 if( pObj == NULL )
63 continue; 70 continue;
64 71
65 pHost->send( pObj ); 72 pHost->send( pObj );
66 emit recv( pObj ); 73 emit recv( pObj );
67 } 74 }
68 75
69} 76}
70 77
71ProxyHostThread::ProxyHostThread( QObject *pParent, ProxyThread *pClient ) : 78ProxyHostThread::ProxyHostThread( QObject *pParent, ProxyThread *pClient ) :
72 QThread( pParent ), 79 QThread( pParent ),
73 pClient( pClient ), 80 pClient( pClient ),
74 ssHst(), 81 ssHst(),
75 gsHst( ssHst ) 82 gsHst( ssHst )
76{ 83{
77} 84}
78 85
@@ -82,27 +89,27 @@ ProxyHostThread::~ProxyHostThread()
82 89
83void ProxyHostThread::send( Gats::Object *pObj ) 90void ProxyHostThread::send( Gats::Object *pObj )
84{ 91{
85 MemBuf bg; 92 MemBuf bg;
86 Gats::GatsStream gs( bg ); 93 Gats::GatsStream gs( bg );
87 gs.writeObject( pObj ); 94 gs.writeObject( pObj );
88 ssHst.write( bg.getString().getStr(), bg.getString().getSize() ); 95 ssHst.write( bg.getString().getStr(), bg.getString().getSize() );
89} 96}
90 97
91void ProxyHostThread::setStream( Bu::Stream *pStr ) 98void ProxyHostThread::setStream( Bu::Stream *pStr )
92{ 99{
93 ssHst.setStream( pStr ); 100 ssHst.setStream( pStr );
94} 101}
95 102
96void ProxyHostThread::run() 103void ProxyHostThread::run()
97{ 104{
98 while( !ssHst.isEos() ) 105 while( !ssHst.isEos() )
99 { 106 {
100 Gats::Object *pObj = gsHst.readObject(); 107 Gats::Object *pObj = gsHst.readObject();
101 if( pObj == NULL ) 108 if( pObj == NULL )
102 continue; 109 continue;
103 110
104 pClient->send( pObj ); 111 pClient->send( pObj );
105 emit recv( pObj ); 112 emit recv( pObj );
106 } 113 }
107} 114}
108 115
diff --git a/c++-libbu++/src/gatscon/proxythread.h b/c++-libbu++/src/gatscon/proxythread.h
index df75046..e53ca2c 100644
--- a/c++-libbu++/src/gatscon/proxythread.h
+++ b/c++-libbu++/src/gatscon/proxythread.h
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#ifndef PROXY_THREAD_H 8#ifndef PROXY_THREAD_H
2#define PROXY_THREAD_H 9#define PROXY_THREAD_H
3 10
@@ -8,53 +15,53 @@
8 15
9class ProxyThread : public QThread 16class ProxyThread : public QThread
10{ 17{
11 Q_OBJECT; 18 Q_OBJECT;
12public: 19public:
13 ProxyThread( QObject *pParent, int iPortIn, const QByteArray &baHostOut, 20 ProxyThread( QObject *pParent, int iPortIn, const QByteArray &baHostOut,
14 int iPortOut ); 21 int iPortOut );
15 virtual ~ProxyThread(); 22 virtual ~ProxyThread();
16 23
17 class ProxyHostThread *pHost; 24 class ProxyHostThread *pHost;
18 25
19 void send( Gats::Object *pObj ); 26 void send( Gats::Object *pObj );
20 27
21signals: 28signals:
22 void recv( Gats::Object *pObj ); 29 void recv( Gats::Object *pObj );
23 void gotConnection(); 30 void gotConnection();
24 31
25protected: 32protected:
26 virtual void run(); 33 virtual void run();
27 34
28private: 35private:
29 int iPortIn; 36 int iPortIn;
30 QByteArray baHostOut; 37 QByteArray baHostOut;
31 int iPortOut; 38 int iPortOut;
32 39
33 Bu::StreamStack ssCli; 40 Bu::StreamStack ssCli;
34 Gats::GatsStream gsCli; 41 Gats::GatsStream gsCli;
35}; 42};
36 43
37class ProxyHostThread : public QThread 44class ProxyHostThread : public QThread
38{ 45{
39 Q_OBJECT; 46 Q_OBJECT;
40public: 47public:
41 ProxyHostThread( QObject *pParent, ProxyThread *pClient ); 48 ProxyHostThread( QObject *pParent, ProxyThread *pClient );
42 virtual ~ProxyHostThread(); 49 virtual ~ProxyHostThread();
43 50
44 void send( Gats::Object *pObj ); 51 void send( Gats::Object *pObj );
45 52
46 void setStream( Bu::Stream *pStr ); 53 void setStream( Bu::Stream *pStr );
47 54
48signals: 55signals:
49 void recv( Gats::Object *pObj ); 56 void recv( Gats::Object *pObj );
50 57
51protected: 58protected:
52 virtual void run(); 59 virtual void run();
53 60
54private: 61private:
55 ProxyThread *pClient; 62 ProxyThread *pClient;
56 Bu::StreamStack ssHst; 63 Bu::StreamStack ssHst;
57 Gats::GatsStream gsHst; 64 Gats::GatsStream gsHst;
58}; 65};
59 66
60#endif 67#endif
diff --git a/c++-libbu++/src/gatscon/proxywidget.cpp b/c++-libbu++/src/gatscon/proxywidget.cpp
index 215f95f..c95e39a 100644
--- a/c++-libbu++/src/gatscon/proxywidget.cpp
+++ b/c++-libbu++/src/gatscon/proxywidget.cpp
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#include "proxywidget.h" 8#include "proxywidget.h"
2#include "proxythread.h" 9#include "proxythread.h"
3 10
@@ -14,22 +21,22 @@
14using namespace Bu; 21using namespace Bu;
15 22
16ProxyWidget::ProxyWidget( QWidget *pParent, int iPortIn, 23ProxyWidget::ProxyWidget( QWidget *pParent, int iPortIn,
17 const QByteArray baHost, int iPortOut ) : 24 const QByteArray baHost, int iPortOut ) :
18 QWidget( pParent ), 25 QWidget( pParent ),
19 pPrx( NULL ) 26 pPrx( NULL )
20{ 27{
21 setupUi( this ); 28 setupUi( this );
22 29
23 pPrx = new ProxyThread( this, iPortIn, baHost, iPortOut ); 30 pPrx = new ProxyThread( this, iPortIn, baHost, iPortOut );
24 31
25 connect( pPrx, SIGNAL(gotConnection()), 32 connect( pPrx, SIGNAL(gotConnection()),
26 this, SLOT(gotConnection()), Qt::QueuedConnection ); 33 this, SLOT(gotConnection()), Qt::QueuedConnection );
27 connect( pPrx, SIGNAL(recv( Gats::Object *)), 34 connect( pPrx, SIGNAL(recv( Gats::Object *)),
28 this, SLOT(clientRecv(Gats::Object *)), Qt::QueuedConnection ); 35 this, SLOT(clientRecv(Gats::Object *)), Qt::QueuedConnection );
29 connect( pPrx->pHost, SIGNAL(recv( Gats::Object *)), 36 connect( pPrx->pHost, SIGNAL(recv( Gats::Object *)),
30 this, SLOT(hostRecv(Gats::Object *)), Qt::QueuedConnection ); 37 this, SLOT(hostRecv(Gats::Object *)), Qt::QueuedConnection );
31 38
32 pPrx->start(); 39 pPrx->start();
33} 40}
34 41
35ProxyWidget::~ProxyWidget() 42ProxyWidget::~ProxyWidget()
@@ -38,94 +45,94 @@ ProxyWidget::~ProxyWidget()
38 45
39void ProxyWidget::saveTo( const QString &sFile ) 46void ProxyWidget::saveTo( const QString &sFile )
40{ 47{
41 File fOut( sFile.toAscii().constData(), File::WriteNew ); 48 File fOut( sFile.toAscii().constData(), File::WriteNew );
42 Gats::GatsStream gsOut( fOut ); 49 Gats::GatsStream gsOut( fOut );
43 QTreeWidgetItem *pRoot = twHistory->invisibleRootItem(); 50 QTreeWidgetItem *pRoot = twHistory->invisibleRootItem();
44 for( int j = 0; j < pRoot->childCount(); j++ ) 51 for( int j = 0; j < pRoot->childCount(); j++ )
45 { 52 {
46 Gats::Object *pObj = treeToGats( pRoot->child( j ) ); 53 Gats::Object *pObj = treeToGats( pRoot->child( j ) );
47 gsOut.writeObject( pObj ); 54 gsOut.writeObject( pObj );
48 delete pObj; 55 delete pObj;
49 } 56 }
50} 57}
51 58
52void ProxyWidget::sendToClient() 59void ProxyWidget::sendToClient()
53{ 60{
54 try 61 try
55 { 62 {
56 Gats::Object *pObj = Gats::Object::strToGats( 63 Gats::Object *pObj = Gats::Object::strToGats(
57 leGats->text().toAscii().constData() 64 leGats->text().toAscii().constData()
58 ); 65 );
59 sio << "Send: " << *pObj << sio.nl; 66 sio << "Send: " << *pObj << sio.nl;
60 QTreeWidgetItem *pIt = new QTreeWidgetItem( 67 QTreeWidgetItem *pIt = new QTreeWidgetItem(
61 twHistory->invisibleRootItem() 68 twHistory->invisibleRootItem()
62 ); 69 );
63 pIt->setText( 0, "proxy -> client" ); 70 pIt->setText( 0, "proxy -> client" );
64 gatsToTree( pIt, pObj ); 71 gatsToTree( pIt, pObj );
65 pPrx->send( pObj ); 72 pPrx->send( pObj );
66 delete pObj; 73 delete pObj;
67 74
68 leGats->setText(""); 75 leGats->setText("");
69 leGats->setFocus(); 76 leGats->setFocus();
70 } 77 }
71 catch( Bu::ExceptionBase &e ) 78 catch( Bu::ExceptionBase &e )
72 { 79 {
73 QMessageBox::critical( this, "Gats Console - Error", e.what() ); 80 QMessageBox::critical( this, "Gats Console - Error", e.what() );
74 } 81 }
75} 82}
76 83
77void ProxyWidget::sendToServer() 84void ProxyWidget::sendToServer()
78{ 85{
79 try 86 try
80 { 87 {
81 Gats::Object *pObj = Gats::Object::strToGats( 88 Gats::Object *pObj = Gats::Object::strToGats(
82 leGats->text().toAscii().constData() 89 leGats->text().toAscii().constData()
83 ); 90 );
84 sio << "Send: " << *pObj << sio.nl; 91 sio << "Send: " << *pObj << sio.nl;
85 QTreeWidgetItem *pIt = new QTreeWidgetItem( 92 QTreeWidgetItem *pIt = new QTreeWidgetItem(
86 twHistory->invisibleRootItem() 93 twHistory->invisibleRootItem()
87 ); 94 );
88 pIt->setText( 0, "proxy -> host" ); 95 pIt->setText( 0, "proxy -> host" );
89 gatsToTree( pIt, pObj ); 96 gatsToTree( pIt, pObj );
90 pPrx->pHost->send( pObj ); 97 pPrx->pHost->send( pObj );
91 delete pObj; 98 delete pObj;
92 99
93 leGats->setText(""); 100 leGats->setText("");
94 leGats->setFocus(); 101 leGats->setFocus();
95 } 102 }
96 catch( Bu::ExceptionBase &e ) 103 catch( Bu::ExceptionBase &e )
97 { 104 {
98 QMessageBox::critical( this, "Gats Console - Error", e.what() ); 105 QMessageBox::critical( this, "Gats Console - Error", e.what() );
99 } 106 }
100} 107}
101 108
102void ProxyWidget::clientRecv( Gats::Object *pObj ) 109void ProxyWidget::clientRecv( Gats::Object *pObj )
103{ 110{
104 sio << "Recv: " << *pObj << sio.nl; 111 sio << "Recv: " << *pObj << sio.nl;
105 112
106 QTreeWidgetItem *pIt = new QTreeWidgetItem( 113 QTreeWidgetItem *pIt = new QTreeWidgetItem(
107 twHistory->invisibleRootItem() 114 twHistory->invisibleRootItem()
108 ); 115 );
109 pIt->setText( 0, "client -> host" ); 116 pIt->setText( 0, "client -> host" );
110 gatsToTree( pIt, pObj ); 117 gatsToTree( pIt, pObj );
111 delete pObj; 118 delete pObj;
112} 119}
113 120
114void ProxyWidget::hostRecv( Gats::Object *pObj ) 121void ProxyWidget::hostRecv( Gats::Object *pObj )
115{ 122{
116 sio << "Recv: " << *pObj << sio.nl; 123 sio << "Recv: " << *pObj << sio.nl;
117 124
118 QTreeWidgetItem *pIt = new QTreeWidgetItem( 125 QTreeWidgetItem *pIt = new QTreeWidgetItem(
119 twHistory->invisibleRootItem() 126 twHistory->invisibleRootItem()
120 ); 127 );
121 pIt->setText( 0, "host -> client" ); 128 pIt->setText( 0, "host -> client" );
122 gatsToTree( pIt, pObj ); 129 gatsToTree( pIt, pObj );
123 delete pObj; 130 delete pObj;
124} 131}
125 132
126void ProxyWidget::gotConnection() 133void ProxyWidget::gotConnection()
127{ 134{
128 lwConnect->stop(); 135 lwConnect->stop();
129 swRoot->setCurrentIndex( 1 ); 136 swRoot->setCurrentIndex( 1 );
130} 137}
131 138
diff --git a/c++-libbu++/src/gatscon/proxywidget.h b/c++-libbu++/src/gatscon/proxywidget.h
index d6ebf4d..1674a34 100644
--- a/c++-libbu++/src/gatscon/proxywidget.h
+++ b/c++-libbu++/src/gatscon/proxywidget.h
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#ifndef PROXY_WIDGET_H 8#ifndef PROXY_WIDGET_H
2#define PROXY_WIDGET_H 9#define PROXY_WIDGET_H
3 10
@@ -6,28 +13,28 @@
6 13
7namespace Gats 14namespace Gats
8{ 15{
9 class Object; 16 class Object;
10}; 17};
11 18
12class ProxyWidget : public QWidget, protected Ui::ProxyWidget, public IoBase 19class ProxyWidget : public QWidget, protected Ui::ProxyWidget, public IoBase
13{ 20{
14 Q_OBJECT; 21 Q_OBJECT;
15public: 22public:
16 ProxyWidget( QWidget *pParent, int iPortIn, const QByteArray baHost, 23 ProxyWidget( QWidget *pParent, int iPortIn, const QByteArray baHost,
17 int iPortOut ); 24 int iPortOut );
18 virtual ~ProxyWidget(); 25 virtual ~ProxyWidget();
19 26
20 virtual void saveTo( const QString &sFile ); 27 virtual void saveTo( const QString &sFile );
21 28
22public slots: 29public slots:
23 void sendToClient(); 30 void sendToClient();
24 void sendToServer(); 31 void sendToServer();
25 void clientRecv( Gats::Object *pObj ); 32 void clientRecv( Gats::Object *pObj );
26 void hostRecv( Gats::Object *pObj ); 33 void hostRecv( Gats::Object *pObj );
27 void gotConnection(); 34 void gotConnection();
28 35
29private: 36private:
30 class ProxyThread *pPrx; 37 class ProxyThread *pPrx;
31}; 38};
32 39
33#endif 40#endif
diff --git a/c++-libbu++/src/gatscon/setupproxydlg.cpp b/c++-libbu++/src/gatscon/setupproxydlg.cpp
index 7c7a873..6d80683 100644
--- a/c++-libbu++/src/gatscon/setupproxydlg.cpp
+++ b/c++-libbu++/src/gatscon/setupproxydlg.cpp
@@ -1,9 +1,16 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#include "setupproxydlg.h" 8#include "setupproxydlg.h"
2 9
3SetupProxyDlg::SetupProxyDlg( QWidget *pParent ) : 10SetupProxyDlg::SetupProxyDlg( QWidget *pParent ) :
4 QDialog( pParent ) 11 QDialog( pParent )
5{ 12{
6 setupUi( this ); 13 setupUi( this );
7} 14}
8 15
9SetupProxyDlg::~SetupProxyDlg() 16SetupProxyDlg::~SetupProxyDlg()
@@ -12,16 +19,16 @@ SetupProxyDlg::~SetupProxyDlg()
12 19
13int SetupProxyDlg::getPortIn() const 20int SetupProxyDlg::getPortIn() const
14{ 21{
15 return sbPortIn->value(); 22 return sbPortIn->value();
16} 23}
17 24
18QByteArray SetupProxyDlg::getHostOut() const 25QByteArray SetupProxyDlg::getHostOut() const
19{ 26{
20 return leHostOut->text().toAscii(); 27 return leHostOut->text().toAscii();
21} 28}
22 29
23int SetupProxyDlg::getPortOut() const 30int SetupProxyDlg::getPortOut() const
24{ 31{
25 return sbPortOut->value(); 32 return sbPortOut->value();
26} 33}
27 34
diff --git a/c++-libbu++/src/gatscon/setupproxydlg.h b/c++-libbu++/src/gatscon/setupproxydlg.h
index 6cc31bd..685e893 100644
--- a/c++-libbu++/src/gatscon/setupproxydlg.h
+++ b/c++-libbu++/src/gatscon/setupproxydlg.h
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#ifndef SETUP_PROXY_DLG_H 8#ifndef SETUP_PROXY_DLG_H
2#define SETUP_PROXY_DLG_H 9#define SETUP_PROXY_DLG_H
3 10
@@ -5,14 +12,14 @@
5 12
6class SetupProxyDlg : public QDialog, protected Ui::SetupProxyDlg 13class SetupProxyDlg : public QDialog, protected Ui::SetupProxyDlg
7{ 14{
8 Q_OBJECT; 15 Q_OBJECT;
9public: 16public:
10 SetupProxyDlg( QWidget *pParent=NULL ); 17 SetupProxyDlg( QWidget *pParent=NULL );
11 virtual ~SetupProxyDlg(); 18 virtual ~SetupProxyDlg();
12 19
13 int getPortIn() const; 20 int getPortIn() const;
14 QByteArray getHostOut() const; 21 QByteArray getHostOut() const;
15 int getPortOut() const; 22 int getPortOut() const;
16}; 23};
17 24
18#endif 25#endif
diff --git a/c++-libbu++/src/gatscon/treetogats.cpp b/c++-libbu++/src/gatscon/treetogats.cpp
index a1571d1..f12a319 100644
--- a/c++-libbu++/src/gatscon/treetogats.cpp
+++ b/c++-libbu++/src/gatscon/treetogats.cpp
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#include "treetogats.h" 8#include "treetogats.h"
2 9
3#include <QTreeWidgetItem> 10#include <QTreeWidgetItem>
@@ -6,47 +13,47 @@
6 13
7Gats::Object *treeToGats( QTreeWidgetItem *pRoot ) 14Gats::Object *treeToGats( QTreeWidgetItem *pRoot )
8{ 15{
9 QString sType = pRoot->text( 1 ); 16 QString sType = pRoot->text( 1 );
10 QByteArray baDat = pRoot->text( 2 ).toAscii(); 17 QByteArray baDat = pRoot->text( 2 ).toAscii();
11 if( sType == "int" ) 18 if( sType == "int" )
12 { 19 {
13 return new Gats::Integer( strtoll( baDat.constData(), NULL, 10 ) ); 20 return new Gats::Integer( strtoll( baDat.constData(), NULL, 10 ) );
14 } 21 }
15 else if( sType == "str" ) 22 else if( sType == "str" )
16 { 23 {
17 return new Gats::String( baDat.constData(), baDat.size() ); 24 return new Gats::String( baDat.constData(), baDat.size() );
18 } 25 }
19 else if( sType == "float" ) 26 else if( sType == "float" )
20 { 27 {
21 return new Gats::Float( strtod( baDat.constData(), NULL ) ); 28 return new Gats::Float( strtod( baDat.constData(), NULL ) );
22 } 29 }
23 else if( sType == "bool" ) 30 else if( sType == "bool" )
24 { 31 {
25 return new Gats::Boolean( baDat == "true" ); 32 return new Gats::Boolean( baDat == "true" );
26 } 33 }
27 else if( sType == "list" ) 34 else if( sType == "list" )
28 { 35 {
29 Gats::List *pRet = new Gats::List(); 36 Gats::List *pRet = new Gats::List();
30 for( int j = 0; j < pRoot->childCount(); j++ ) 37 for( int j = 0; j < pRoot->childCount(); j++ )
31 { 38 {
32 pRet->append( treeToGats( pRoot->child( j ) ) ); 39 pRet->append( treeToGats( pRoot->child( j ) ) );
33 } 40 }
34 return pRet; 41 return pRet;
35 } 42 }
36 else if( sType == "dict" ) 43 else if( sType == "dict" )
37 { 44 {
38 Gats::Dictionary *pRet = new Gats::Dictionary(); 45 Gats::Dictionary *pRet = new Gats::Dictionary();
39 for( int j = 0; j < pRoot->childCount(); j++ ) 46 for( int j = 0; j < pRoot->childCount(); j++ )
40 { 47 {
41 QTreeWidgetItem *pChild = pRoot->child( j ); 48 QTreeWidgetItem *pChild = pRoot->child( j );
42 pRet->insert( 49 pRet->insert(
43 pChild->text( 0 ).toAscii().constData(), 50 pChild->text( 0 ).toAscii().constData(),
44 treeToGats( pChild ) 51 treeToGats( pChild )
45 ); 52 );
46 } 53 }
47 return pRet; 54 return pRet;
48 } 55 }
49 56
50 throw Bu::ExceptionBase("Unhandled type found."); 57 throw Bu::ExceptionBase("Unhandled type found.");
51} 58}
52 59
diff --git a/c++-libbu++/src/gatscon/treetogats.h b/c++-libbu++/src/gatscon/treetogats.h
index 931623d..29f7d6c 100644
--- a/c++-libbu++/src/gatscon/treetogats.h
+++ b/c++-libbu++/src/gatscon/treetogats.h
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#ifndef TREE_TO_GATS_H 8#ifndef TREE_TO_GATS_H
2#define TREE_TO_GATS_H 9#define TREE_TO_GATS_H
3 10
@@ -5,7 +12,7 @@ class QTreeWidgetItem;
5 12
6namespace Gats 13namespace Gats
7{ 14{
8 class Object; 15 class Object;
9}; 16};
10 17
11Gats::Object *treeToGats( QTreeWidgetItem *pRoot ); 18Gats::Object *treeToGats( QTreeWidgetItem *pRoot );